[ Pobierz całość w formacie PDF ] .The rest of the code is similar to that used to invoke thepaged list of users.Extending the information gathered about users in this way depends on a feature ofthe aliroDatabaseRow class.With support from the aliroAbstractDatabase classmethods, the aliroDatabaseRow can be extended to build simple data objects.Thestandard Aliro user class is one such class.The significant feature is that details of the fields in the class are not built into the PHP code, but are derived from the database.So, if the relevant database table is enlarged with additional fields, the correspondingclass automatically becomes aware of them.Insert, update, and delete methods areavailable for classes based on aliroDatabaseRow, and they are used in the standardAliro user administration component.Because of this, it is sufficient to modify thedatabase table and include a more extensive view class to handle the information inthe browser, without any other requirement to change code.More information ondatabase related classes is given in a later chapter.The default view class for administering users starts off with this code:class listUsersHTML extends basicAdminHTML{public function performView ($rows, $lists, $search, $limitstart,$listfooter){$html =MAIN_HTML;}}This module is a single class, and it extends the aliroFriendlyBase class.In fact,the custom module does not take advantage of aliroFriendlyBase, but it is a usefulclass to build on, since it makes a lot of information about the CMS environmentdirectly available.For example, it makes the general configuration available throughcalls like $this->getCfg('nameOfConfigurationItem').All modules implementthe Aliro module interface, ifAliroModule.The only requirement imposed by the interface is that a module implements themethod activate with the parameters shown in the preceding code.Wheneverthe module is needed, the framework will instantiate the class and call theactivate method.Parameters provide as much information as possible from the framework, to makemodule development relatively simple.Specifically:•$module is a module object which represents a particular screen box ratherthan the module code itself.Every instance of a box is recorded as a row inthe Aliro modules table, and can be retrieved as a module object.•$content is passed by reference, and is used by the module to storewhatever XHTML it wants to be included in the output to the browser.[ 152 ]Chapter 7•$area is a block or screen area object, the main properties of which arecurrently minimum width and maximum width.Other properties may beadded in future.The module can make use of the information providedabout the screen area available to it.•$params is a parameter object for this module instance.It knows the valuesset by the administrator, and can provide information through its methodssuch as get($key,$default) which accepts the name of a parameter item,and an optional default value which is returned if the item is not set.The work of this module starts with acquiring two items of information from theparameters, the class suffix, and the actual content, which has been set by theadministrator.The function of this module is simply to display whatever has beenentered by the administrator.Generally, modules create output that is wrapped in anXHTML element , which has a class indicating the identity of the module, butwhich can be individuated by the administrator setting a suffix parameter.This way,full control is given over the possibility of CSS styling through the site CSS.With the information from the parameters, the desired content can be created, usinga single PHP heredoc assignment.Another module, the latest news module, illustrates another technique that is easilyapplied.The outline of its code is:class mod_latestnews extends aliroFriendlyBaseimplements ifAliroModule{function activate ($module, &$content, $area, $params){$cache = new aliroCache('mod_latestnews');$content = $cache->get(array($area,$params));// If the cache returned us the desired content we canreturn immediatelyif ($content) return;$type= intval( $params->get( 'type', 1 ) );// Code that constructs the desired content.// Now cache the created content$cache->save($content);}}[ 153 ]Handling ExtensionsClearly, the overall structure is very similar to the custom module
[ Pobierz całość w formacie PDF ]
zanotowane.pldoc.pisz.plpdf.pisz.plhanula1950.keep.pl
|