Loader is a package in SAF that allows you to import classes, boxes, and forms into your own code, allowing for a high degree of code reuse in Sitellite.
The main functions of Loader are accessible as global functions, that are aliases of calling methods on the global $loader object instance. These are:
bool loader_import (string $pkg);
$pkg is a dot-delimited location specifier instead of a filesystem path like include and require do. Some examples are:
- saf.CGI = saf/lib/CGI/CGI.php
- pear.Mail.mimeDecode = saf/lib/PEAR/Mail/mimeDecode.php
- ext.htmldoc = saf/lib/Ext/htmldoc/htmldoc.php
- cms.Versioning.Rex = inc/app/cms/lib/Versioning/Rex.php
saf, pear, and ext are default path names that point to saf/lib, saf/lib/PEAR, and saf/lib/Ext respectively. As you saw with cms, you can also specify any app name and Loader knows to look in inc/app/app_name/lib for the specified package.
string loader_box (string $box, hash $parameters = []);
$box is the slash-delimited name of a box, starting with the app name. For example, the inc/app/cms/boxes/buttons box would be cms/buttons since Sitellite knows to add the inc/app and boxes/ for you.
$parameters is an optional associative array of values to pass to the box. Some boxes have required parameters.
loader_box() returns the output of the specified box.
string loader_form(string $form)
loader_form() is just like loader_box(), except that there is no $parameters list, and it looks in the forms subfolder of your app instead of boxes.
Created on April 4, 2005 2:16 PM by lux
Linked from: Libraries