| 1 | jonen | 1.1 | <?php | 
| 2 |  |  |  | 
| 3 |  |  | /** | 
| 4 |  |  | * This example illustrates the use of the | 
| 5 |  |  | * permissions checking mechanism built into the | 
| 6 |  |  | * PageWidget object. | 
| 7 |  |  | * | 
| 8 |  |  | * | 
| 9 |  |  | * $Id: widget14.php,v 1.4 2004/02/03 23:46:51 hemna Exp $ | 
| 10 |  |  | * | 
| 11 |  |  | * @author Walter A. Boring IV <waboring@buildabetterweb.com> | 
| 12 |  |  | * @package phpHtmlLib | 
| 13 |  |  | * @subpackage widget-examples | 
| 14 |  |  | * @version 2.4.0 | 
| 15 |  |  | * | 
| 16 |  |  | */ | 
| 17 |  |  |  | 
| 18 |  |  | /** | 
| 19 |  |  | * Include the phphtmllib libraries | 
| 20 |  |  | * | 
| 21 |  |  | */ | 
| 22 |  |  | include_once("includes.inc"); | 
| 23 |  |  |  | 
| 24 |  |  | require_once($phphtmllib."/widgets/TabWidget.inc"); | 
| 25 |  |  |  | 
| 26 |  |  | class FirstTab extends TabWidget { | 
| 27 |  |  | function FirstTab($title='First Tab Title') { | 
| 28 |  |  | $this->TabWidget($title); | 
| 29 |  |  | } | 
| 30 |  |  |  | 
| 31 |  |  | function content() { | 
| 32 |  |  | return 'testing 123'; | 
| 33 |  |  | } | 
| 34 |  |  | } | 
| 35 |  |  |  | 
| 36 |  |  | class FooTab extends TabWidget { | 
| 37 |  |  | function FooTab() { | 
| 38 |  |  | $this->TabWidget('Foo'); | 
| 39 |  |  | } | 
| 40 |  |  |  | 
| 41 |  |  | function content() { | 
| 42 |  |  | $dialog = new MessageBoxWidget("Some title", "400", | 
| 43 |  |  | container("This is a message", | 
| 44 |  |  | html_br(2), | 
| 45 |  |  | "Want to see a permissions error?", | 
| 46 |  |  | html_br(), | 
| 47 |  |  | html_a($_SERVER["PHP_SELF"]."?failed=1", | 
| 48 |  |  | "Click Here")) | 
| 49 |  |  | ); | 
| 50 |  |  | return container(html_br(),$dialog, html_br()); | 
| 51 |  |  | } | 
| 52 |  |  | } | 
| 53 |  |  |  | 
| 54 |  |  | class test extends TabWidget { | 
| 55 |  |  | function content() { | 
| 56 |  |  | return "test ".$this->get_title(); | 
| 57 |  |  | } | 
| 58 |  |  | } | 
| 59 |  |  |  | 
| 60 |  |  | class WidgetListPage extends PageWidget { | 
| 61 |  |  |  | 
| 62 |  |  |  | 
| 63 |  |  | function WidgetListPage($title) { | 
| 64 |  |  | $this->PageWidget($title, HTML); | 
| 65 |  |  |  | 
| 66 |  |  | //we need this for the css defined for the InfoTable | 
| 67 |  |  | //for the DialogWidget.  The DialogWidget uses InfoTable. | 
| 68 |  |  | $this->add_css_link("/phphtmllib/css/defaulttheme.php"); | 
| 69 |  |  | } | 
| 70 |  |  |  | 
| 71 |  |  | /** | 
| 72 |  |  | * This will only get called if we have permissions to | 
| 73 |  |  | * build and render the content for this page object. | 
| 74 |  |  | * | 
| 75 |  |  | * @return object | 
| 76 |  |  | */ | 
| 77 |  |  | function body_content() { | 
| 78 |  |  | $tablist = new TabList("Scan"); | 
| 79 |  |  | $tablist->add( new FirstTab ); | 
| 80 |  |  | $tablist->add( new FooTab ); | 
| 81 |  |  | $tablist->add( new FirstTab('Third tab!') ); | 
| 82 |  |  |  | 
| 83 |  |  | $subtab = new TabList("list"); | 
| 84 |  |  | $subtab->add( new test("sub 1") ); | 
| 85 |  |  | $subtab->add( new test("sub 2") ); | 
| 86 |  |  | $subtab->add( new test("sub 3") ); | 
| 87 |  |  | $subtab->add( new test("sub 4") ); | 
| 88 |  |  |  | 
| 89 |  |  | $tablist->add( $subtab ); | 
| 90 |  |  |  | 
| 91 |  |  |  | 
| 92 |  |  | $div = html_div('', $tablist); | 
| 93 |  |  | $div->set_style('width: 600px'); | 
| 94 |  |  | return $div; | 
| 95 |  |  | } | 
| 96 |  |  | } | 
| 97 |  |  |  | 
| 98 |  |  | //build the Page object and try and | 
| 99 |  |  | //render it's content. | 
| 100 |  |  | //the permissions checking happens at | 
| 101 |  |  | //'constructor' time. | 
| 102 |  |  | $page = new WidgetListPage("testing"); | 
| 103 |  |  |  | 
| 104 |  |  | //the render method will not call the | 
| 105 |  |  | //content building methods if the permissions | 
| 106 |  |  | //fail. | 
| 107 |  |  | print $page->render(); | 
| 108 |  |  | ?> |