Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 52 lines (43 sloc) 1.22 kb
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
1 <?PHP
2 /**
3 * Simple example that shows the two ways
4 * to embedd HTML in a XUL document.
5 *
6 * @author Stephan Schmidt <schst@php.net>
7 * @package XML_XUL
8 * @subpackage Examples
9 */
10
11 /**
12 * require XML_XUL package
13 */
14 require_once 'XML/XUL.php';
15
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
16 $doc = XML_XUL::createDocument( );
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
17
18 $doc->addStylesheet('chrome://global/skin/');
19 $doc->setHtmlNamespace('html');
20
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
21 $win = $doc->createElement('Window', array('title'=> 'Example for PEAR::XML_XUL'));
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
22 $doc->addRoot($win);
23
24 /**
25 * create HTML like you would create XUL
26 */
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
27 $p = $doc->createHtmlElement( 'p', array(), 'This is HTML.' );
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
28 $win->appendChild($p);
29
30 /**
31 * create HTML from a raw string
32 */
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
33 $html = $doc->createHtmlRaw( '<html:p>This is also HTML, including a <html:a href="http://pear.php.net">link</html:a>.</html:p>' );
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
34 $win->appendChild($html);
35
7a0fea7 fixed E_ALL notices
Stephan Schmidt authored
36 if (!isset($_GET['mode'])) {
37 $_GET['mode'] = 'default';
38 }
39
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
40 if ($_GET['mode'] == 'debug') {
41 require_once 'XML/Beautifier.php';
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
42 $fmt = new XML_Beautifier( array( 'indent' => ' ' ) );
d94cdcf initial import on PEAR cvs
Stephan Schmidt authored
43 echo '<pre>';
44 echo htmlspecialchars( $fmt->formatString($doc->serialize()) );
45 echo '</pre>';
46 } elseif ($_GET['mode'] == 'source') {
47 highlight_file( __FILE__ );
48 } else {
49 $doc->send();
50 }
ed444d1 @CloCkWeRX PHP5-ify
CloCkWeRX authored
51 ?>
Something went wrong with that request. Please try again.