How to modify XsltCMS
Abstract
- Modify PHP files
- You can also create modules, i.e. additionnal PHP files, into XsltCMS
1. What to do
XsltCMS is in PHP. This is a common web scripting language. Everything in this tool can be modified (behavious, skins of the private part, etc.).
You should know how to use PHP and how XsltCMS behave before reading this documentation (excepting 5. Translating below which is easy).
XsltCMS is GPLed (v.2). You should have received a copy of the GNU Lesser General Public
License along with this tool ; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2. Special features
XsltCMS should work in any release of PHP from 5.0. It should not require any optionnal extesnsion (php_*.dll files for example) but php_xsl. This extension is documented as "active" by default.
PHP 4 do not fit at all as DOM is heavily used (PHP 4 DOM XML being weak).
Everything is kept as simple as possible. Object Oriented Programming is not used, excepting using existing (DOM, XSL) classes.
3. Main architecture
3.1 Introduction
The public part of XlstCMS is generated, and often do not include any PHP code (but it is possible to do so : include some PHP code in your template)
This documentation id about the private part of XsltCMS (.../create/static/*).
3.1 MVC
The main file is index.php. AS any MVC2 implementation, every call use it (then there are some inclusions...).
The $_GET informations (i.e. index.php?...) should contains an action. An action is like this : module.function.subfunction.subfunction.... . This action (and the other data received) will be processed ( useAction() ) in a .actions.php file in order to :
- Modify data
- Prepare some messages
Then the action, and the result of useAction(), are used to select a view (module.view.subview.... ). This view (HTML code) is created in a .view.php file then sent to the navigator.
3.3 Global variables and data
You should not read (or write) any global variable from your own code, excepting superglobal variables ($_GET, $_POST...).
You can find a lot of useful functions in *.model.php files, including some function to read and write existing global variables.
- data.model.php : read and write into current.xml file (and backups)
- config.model.php : read from config.xml file
- misc.model.php : miscellaneous functions (about dates, files, ...)
3.5 Rules
Here are some major rules that you should follow :
- Keep it simple and short
- Do it in english (labels and comments)
- Stick to the obvious coding decoration rules used (variables, functions, file names, indentation, etc).
- Usually modified parameters belongs to config.xml. Less modified ones are defined as constants in the head of PHP files.
- Use other PHP extentions, modules, tools only in case of absolute necessity
- Code source do modify current.xml and create backups. In any case no other file should be modified automaticaly
4. Modules
There are for now 4 modules in XsltCMS.
A module has 2 files (at least), in create/static/mdoules/ directory : themodule.actions.php and themodule.view.php. This file names are mandatory, there are dynamic includes done corresponding ti actions and view requested.
In order to create a new module, you should add :
- useYoumoduleActions() in yourmodule.actions.php
- showYourmoduleView() in yourmodule.view.php
- a line in website/config.xml calling your module
- some translations in languages/yourmodule.english.php
- a line in languages/misc.english.php naming your module
5. Translating
Translating the private part of XsltCMS is easy :
- Verify that your language or dialect does not exists in /create/static/languages/
- Create the new files copying old ones.
- Each important line of this file is as this : $translations['key'] = 'Text'. Replace "Text" with the appropriate translation.
- Some text can contain %xyz tags : this items will be replaced with value, you should include them in your translation without modification
- You can send this file back to XsltCMS official website if you want
About this document
Document base url : http://xsltcms.org/ how_to_modify.html
Version : 070828
Author : Askywhale