Username:
Password:
    Forgot your password?
Member Login

Hacking on Sitellite

Notes

Chat Loading chat status
  • Please subscribe to chat.
  • Older messages can be viewed in the chat archive.

Subscribe  |  The Lounge  |  Share Lesson

Chapter 3: Parts of Sitellite

As far as PHP projects go, Sitellite is fairly large at over 300,000 lines of code. This chapter will break the codebase down into its different areas so you can more easily find what you're looking for when hunting down bugs or adding new features.

Sitellite's Standard Library

At the core of Sitellite is a collection of PHP classes. They vary in purpose from input handling and validation to database access to template parsing. They aren't all consistent, since Sitellite grew over a period of about 8 years already, and even PHP has changed quite a bit in that time. But to go back now and make everything consistent is not just impractical, but also wastes time that can be better spent moving forward. So we move forward instead.

The classes live in the "saf/lib" folder. You'll find the reference documentation for them here:

The core classes of interest to general Sitellite developers are saf.CGI, saf.Database, saf.Template.*, saf.Loader, saf.Misc.Document, saf.MailForm, and saf.I18n. There are others that are also handy too, but these are probably the most frequently used.

Template Engines

Sitellite contains two template engines, XT and SimpleTemplate, although only XT is required. The other is there as a convenience to app developers and is better suited for use in apps than for global design files. But if you prefer Smarty or another template language, feel free to include that in your custom apps and use that instead. Sitellite is not exclusionary at all of external libraries. In fact, we'd prefer to use external libraries wherever possible since that reduces development time.

XT Templates

The XT template engine (saf.XML.XT) is an XML-based template engine inspired by Zope's template engine. Since it's XML-based, templates must be valid XML and the output is syntactically valid but not semantically valid XHTML.

XT templates live in the inc/html folder in template sets. A template set is a collections of templates and related files (CSS, Javascript and images) that comprise a complete design for a site. Most sites only need one or two templates (global design and possibly a custom homepage look), but some use separate templates for each sub-section of a site.

SimpleTemplate

SimpleTemplate files live in the "html" sub-folder of an app. Their syntax is described elsewhere.

Configurations

The global configurations go in the "inc/conf" folder. Additional configurations related to sessions go in the "inc/sessions" folder, but these rarely change. The core configuration files are inc/conf/config.ini.php and inc/conf/cache.php. These files are now typically managed through the Control Panel > Admin menu in the Sitellite GUI instead of being edited directly.

An inc/conf/properties.php file can also contain global custom settings, which is usually only used on highly custom sites for preloading libraries before any template parsing has happened. A more extensible way of loading custom settings would be a good future feature...

Applications

Requests sent to Sitellite either call pages in the database or applications. All applications live in their own folders inside the "inc/app" folder, and apps are also broken down into numerous sub-folders described in the "Programming in Sitellite" lesson.

The 'index' File

All request parsing happens through Sitellite's "index" file. This is a PHP script minus the extension, but the .htaccess file clues Apache in so it's handled properly. This script loads all the necessary libraries automatically, checks whether a request should go to the cache or be dynamic, connects to the database, and builds the request based on the specified page or app request and output mode.

Historically, requests in Sitellite had an "/index/" prefix which called this file, but as of Sitellite 5 the default is to dynamically map requests to "index" via mod_rewrite and to leave that part out.

Those are all the major components of Sitellite, and should give you a good idea where to look to start hacking on your pet bug or new feature. Make sure to join the discussion and get involved – we're always eager for new help!