Component Writer's Guide :: Resources
There are several ways in which you can design your application interface, but to save time and isolate even more the aspect from the code, RPCL provide a mecanism to retrieve objects and properties from an xml-like file.
XML resource file
Here is a trimmed version of an .xml.php file:
<?php
<object class="LayerSample" name="LayerSample" baseclass="page">
<property name="Caption">Layer sample</property>
<property name="DocType">dtNone</property>
<property name="Font">
<property name="Align">taNone</property>
<property name="Family">Verdana</property>
<property name="Size">10px</property>
</property>
<property name="Height">600</property>
<property name="IsMaster">0</property>
<property name="Layout">
<property name="Cols">5</property>
<property name="Rows">5</property>
<property name="Type">ABS_XY_LAYOUT</property>
</property>
<property name="Name">LayerSample</property>
<property name="Width">800</property>
<property name="OnTemplate"></property>
<object class="Panel" name="Panel1" >
<property name="ActiveLayer">Layer2</property>
<property name="Caption">Panel1</property>
<property name="Font">
<property name="Align">taNone</property>
<property name="Family">Verdana</property>
<property name="Size">10px</property>
</property>
<property name="Height">400</property>
<property name="Layout">
<property name="Cols">5</property>
<property name="Rows">5</property>
<property name="Type">XY_LAYOUT</property>
</property>
<property name="Left">144</property>
<property name="Name">Panel1</property>
<property name="Top">56</property>
<property name="Width">528</property>
<object class="Button" name="Button1" >
<property name="Caption">Button1</property>
<property name="Font">
<property name="Align">taNone</property>
<property name="Family">Verdana</property>
<property name="Size">10px</property>
</property>
<property name="Height">25</property>
<property name="Layer">Layer1</property>
<property name="Left">53</property>
<property name="Name">Button1</property>
<property name="Top">59</property>
<property name="Width">75</property>
<property name="OnClick">Button1Click</property>
</object>
</object>
</object>
?>
The starting <?php and ending ?> tags are there to protect the contents on the webserver, as it will be interpreted as PHP. The XML file is not meant to be valid XML, it's a format designed to be fast to parse and load.
Basically, the first <object> tag is the owner of all the components read, and an <object> tag can contain another <object> tags, that is a parent-children relationship. Objects can have a name, and a class, and Pages have a baseclass to inform about the inheritance.
Inside <objects> you can find <property> tags, with a name and a value and properties can be nested (only 1 level at the time of writting).
You can create .xml.php files by yourself with a text editor, but using RadPHP is faster, as it's automatically created.
Reading the resource file
Loading of the resource file is done by this line:
//Read from resource file $Index->loadResource(__FILE__);
__FILE__ is a PHP predefined constant, which, in run-time, gets substituted by the file it contains the constant, passing this value to loadResource() makes it read the .xml.php file that has the same basename as the file the script is running.