root/branches/gettext/examples/example_api_toxml.php

Revision 394, 1.6 kB (checked in by gerd, 1 year ago)

Switched to patI18n

  • removed all setLocale / getLocale functions from patForms, elements etc.
  • use patI18n::dgettext with textdomain "patForms"
  • added patI18n example
  • added helper script to setup patI18n
  • mended examples accordingly
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * Example that shows how to serialize an element to XML
4  *
5  * $Id$
6  *
7  * @access        public
8  * @package        patForms
9  * @subpackage    Examples
10  * @author        Sebastian Mordziol <argh@php-tools.net>
11  * @license        LGPL, see license.txt for details
12  * @link        http://www.php-tools.net
13  */
14
15     /**
16      * Main examples prepend file, needed *only* for the examples framework!
17      */
18     include_once 'patExampleGen/prepend.php';
19     $exampleGen->displayHead( 'Example' );
20
21     
22     // EXAMPLE START ------------------------------------------------------
23
24     /**
25      * main patForms class
26      */
27     require_once $neededFiles['patForms'];
28     
29     /**
30      * patErrorManager class
31      */
32     require_once $neededFiles['patErrorManager'];
33     
34     /**
35      * localisation stuff
36      */
37     require_once $neededFiles['patI18n_configure'];
38
39
40     // attribute collection for the element
41     $attributes    =    array(
42         'required'        =>    'yes',
43         'display'        =>    'yes',
44         'edit'            =>    'yes',
45         'label'            =>    'Username',
46         'description'    =>    'Enter your username here.',
47         'default'        =>    'Tom & Jerry',
48         'title'            =>    'Username',
49     );
50     
51     // create the element
52     $el = patForms::createElement( 'toXML', 'String', $attributes );
53     
54     // display the element
55     echo $el->getAttribute( 'label' )."<br>";
56     echo "<div>".$el->serialize()."</div>";
57     echo "<i>".$el->getAttribute( 'description' )."</i><br><br>";
58     
59     // serialize the element to xml
60     $xml = $el->toXML();
61
62     // display the xml (we use the example framwrok's XML hilighter for this)
63     echo 'XML output:<br><br>';
64     $exampleGen->displayXMLString( $xml );
65
66
67     
68     
69     // EXAMPLE END ------------------------------------------------------
70     $exampleGen->displayFooter();
71 ?>
Note: See TracBrowser for help on using the browser.