root/tags/RELEASE_0_2_0/examples/Example1.php

Revision 28, 1.8 kB (checked in by mikey, 2 years ago)

corrected doc block

Line 
1 <?php
2 /**
3  * First example to show how XJConf has to be used and what it does.
4  *
5  * @author  Stephan Schmidt <stephan.schmidt@schlund.de>
6  * @author  Frank Kleine <frank.kleine@schlund.de>
7  */
8 require_once '../XJConf/XJConfLoader.php';
9 XJConfLoader::load('DefinitionParser',
10                    'XmlParser'
11 );
12 require 'Color.php';
13 require 'Complex.php';
14 require 'UpperString.php';
15 /**
16  * First example to show how XJConf has to be used and what it does.
17  *
18  * @package     XJConf
19  * @subpackage  examples
20  */
21 class Example1
22 {
23
24     public static function main()
25     {
26         $tagParser = new DefinitionParser();
27         $defs      = $tagParser->parse(getcwd() . '/xml/defines.xml');
28
29         echo 'Number of defined tags: ';
30         var_dump($defs->countTagDefinitions());
31
32         $conf = new XmlParser();
33         try {
34             $conf->setTagDefinitions($defs);
35     
36             $conf->parse(getcwd() . '/xml/test.xml');
37         } catch (Exception $e) {
38             echo $e->getTraceAsString();
39             exit(0);
40         }
41         
42         echo 'foo:';
43         $foo = $conf->getConfigValue('foo');
44         var_dump($foo);
45         
46         echo 'zahl:';
47         $zahl = $conf->getConfigValue('zahl');
48         var_dump($zahl);
49         
50         echo 'schst:';
51         $schst = $conf->getConfigValue('schst');
52         var_dump($schst->getString());
53         
54         echo 'complex:';
55         $bar = $conf->getConfigValue('complex');
56         var_dump($bar->render());
57         
58         echo 'complex2:';
59         $bar2 = $conf->getConfigValue('complex2');
60         var_dump($bar2->render());
61         
62         echo 'array:';
63         $arr = $conf->getConfigValue('array');
64         var_dump($arr);
65         
66         echo 'complex3:';
67         // with default values
68         $bar3 = $conf->getConfigValue('complex3');
69         var_dump($bar3->render());
70     }
71 }
72 Example1::main();
73 ?>
Note: See TracBrowser for help on using the browser.