Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 59 lines (46 sloc) 1.505 kb
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
1 <?PHP
2 /**
3 * Simple example that creates a XUL menu
4 *
5 * @author Stephan Schmidt <schst@php.net>
6 * @package XML_XUL
7 * @subpackage Examples
8 */
9
10 /**
11 * require XML_XUL package
12 */
13 require_once 'XML/XUL.php';
14
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
15 $doc = XML_XUL::createDocument( );
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
16
17 $doc->addStylesheet('chrome://global/skin/');
18
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
19 $win = $doc->createElement('Window', array('title'=> 'Example for PEAR::XML_XUL'));
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
20 $doc->addRoot($win);
21
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
22 $box = $doc->createElement('Toolbox', array('flex' => '1'));
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
23 $win->appendChild($box);
24
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
25 $bar = $doc->createElement('Menubar', array('id' => 'myBar'));
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
26 $box->appendChild( $bar );
27
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
28 $menu = $bar->addMenu(array('id' => 'file', 'label' => 'File'));
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
29 $menu->addItem(array('label' => 'Open'));
30 $menu->addItem(array('label' => 'Save'));
31
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
32 $sub = $menu->addSubmenu(array('label' => 'Save as...'));
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
33 $sub->addItem(array('label' => 'XML'));
34 $sub->addItem(array('label' => 'Plain Text'));
35
36 $menu->addSeparator();
37 $menu->addItem(array('label' => 'Exit'));
38
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
39 $menu2 = $bar->addMenu(array('id' => 'edit', 'label' => 'Edit'));
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
40 $menu2->addItem(array('label' => 'Copy'));
41 $menu2->addItem(array('label' => 'Paste'));
42
7a0fea7 fixed E_ALL notices
Stephan Schmidt authored
43 if (!isset($_GET['mode'])) {
44 $_GET['mode'] = 'default';
45 }
46
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
47 if ($_GET['mode'] == 'debug') {
48 require_once 'XML/Beautifier.php';
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
49 $fmt = new XML_Beautifier( array( 'indent' => ' ' ) );
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
50 echo '<pre>';
51 echo htmlspecialchars( $fmt->formatString($doc->serialize()) );
52 echo '</pre>';
53 } elseif ($_GET['mode'] == 'source') {
54 highlight_file( __FILE__ );
55 } else {
56 $doc->send();
57 }
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
58 ?>
Something went wrong with that request. Please try again.