Documentation
Introduction & Structure
The code of unicycle.tv based on php5.1 (with PDO) and mysql4.1 with
InnoDB as storage engine.
The organisation of the filesystem is mainly flat with just some subfolders.
Internally the code passes through XMLDocuments that are imported into others, while a big one is parsed against an XSL Template, which transforms the xml into the desired output (xml/html/text) but only xml (XHTML/RSS) is attractive for us.
Database ERM
The ERM can be found here:
http://www.einrad.tv/dev/erm.png∞
Languages
Besides the language stored in the database there is a language-xml file in the I18n folder for each language. This language file is used to store several constants not saved in the database because of no relations to other entities. E.g. the labels for the menuitems are stored in the xml file. Other situations are possible. This constants can be edited in the admin area.
Every language string will be kept in the language_text table (see ERM above).
Entities & Elements
Entities
Entities reflecting database relations. So e.g. the news table in the db got a
NewsItem as an entity for object instantiation. Every entity should implement the save() method to store the obj in the db. Either update an existent entry, insert a new object or insert new language record.
Every entity should inherit from the Class 'Entity' and should be located in the /entity folder in the filesystem. The above mentioned save() and the delete() method must be implemented as defined as abstract methods in the abstract 'Entity'.
Elements
Such Elements are the content elements that represent some part of the content on the site. Every element can be feed with parameters (that is the usage for putting in parameters from the url). Elements are returning a xml fragment which is imported into the page xml. Also returning a filename for a xsl template which will be imported in the main xsl-file and translate their content element part in the main xml file.
Elements must implement the IElement Interface and adopt the public methods.
Admin Elements
Admin Elements are a special kind of content elements. Instead of implementing the IElement interface, inherit from the
AdminElement (which is implementing the IElement interface).
What you simply have to to do is to create methods like ACTION_* where * is the dedicated action. This is for [admin].php?action=* usage, pretty simple though. Also define the protected $aXslMap array.
How To: Writing Own Elements
Writing own elements is very simple and easy following these steps:
- Create a [Element].class.php file in the /elements folder. The Class inside is the same as in the filename [Element] (CamelCase). (See topic above)
- Create an xsl-file in the /templates/elements folder and return the name of this file in the getStyleSheet() method of the elements Class.
- Create an entity in the /entity folder if necessary.
If the element needs administrative stuff, have a look at this:
- Create a new element as described above but add the suffix Admin (->see: AdminElements above).
- Create a php-file in the admin folder.
- Copy code from another admin element (news e.g.) biggrin
You can have a look at the News. The News is a simple and lightweight element with straight forward code. Easy to get.
Url
The url is in the following format:
domain/[lang-code/]element[/params][.ext]
There are 580 comments on this page. [Display comments]