administrator/classloader.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*******************************************************************************
00004  * Aliro - the modern, accessible content management system
00005  *
00006  * Aliro is open source software, free to use, and licensed under GPL.
00007  * You can find the full licence at http://www.gnu.org/copyleft/gpl.html GNU/GPL
00008  *
00009  * The author freely draws attention to the fact that Aliro derives from Mambo,
00010  * software that is controlled by the Mambo Foundation.  However, this section
00011  * of code is totally new.  If it should contain any fragments that are similar
00012  * to Mambo, please bear in mind (1) there are only so many ways to do things
00013  * and (2) the author of Aliro is also the author and copyright owner for large
00014  * parts of Mambo 4.6.
00015  *
00016  * Tribute should be paid to all the developers who took Mambo to the stage
00017  * it had reached at the time Aliro was created.  It is a feature rich system
00018  * that contains a good deal of innovation.
00019  *
00020  * Your attention is also drawn to the fact that Aliro relies on other items of
00021  * open source software, which is very much in the spirit of open source.  Aliro
00022  * wishes to give credit to those items of code.  Please refer to
00023  * http://aliro.org/credits for details.  The credits are not included within
00024  * the Aliro package simply to avoid providing a marker that allows hackers to
00025  * identify the system.
00026  *
00027  * Copyright in this code is strictly reserved by its author, Martin Brampton.
00028  * If it seems appropriate, the copyright will be vested in the Aliro Organisation
00029  * at a suitable time.
00030  *
00031  * Copyright (c) 2007 Martin Brampton
00032  *
00033  * http://aliro.org
00034  *
00035  * counterpoint@aliro.org
00036  *
00037  * This file is solely to hold the admine side smart class mapper.
00038  *
00039  * The smartAdminClassMapper is used to find classes.  It has written into it the
00040  * locations for permanent classes on the user side, and separately holds locations
00041  * for external classes from third parties outside the Aliro project.  These are
00042  * from other open source projects.  The third source for class information is the
00043  * database, which contains details of installed classes.  Unlike the user side,
00044  * classes must be specifically identified in the map to constrain as much as
00045  * possible the code that will be loaded on the admin side.
00046  *
00047  */
00048 
00049 class smartAdminClassMapper extends smartClassMapper {
00050     private static $instance = __CLASS__;
00051 
00052     private static $adminmap = array (
00053     'aliroAdminRequest' => 'aliroAdminRequest',
00054     'aliroAdminTemplateBase' => 'aliroAdminTemplateBase',
00055     'defaultAdminTemplate' => 'defaultAdminTemplate',
00056     'aliroAdminMenu' => 'aliroAdminMenu',
00057     'aliroAdminMenuHandler' => 'aliroAdminMenu',
00058     'aliroAdminToolbar' => 'aliroAdminToolbar',
00059     'aliroAdminPageNav' => 'aliroAdminPageNav',
00060     'aliroComponentAdminManager' => 'aliroComponentAdminManager',
00061     'aliroComponentAdminControllers' => 'aliroComponentAdminManager',
00062     'aliroDBUpdateController' => 'aliroDBUpdateController',
00063     'basicAdminHTML' => 'basicAdminHTML',
00064     'advancedAdminHTML' => 'basicAdminHTML',
00065     'widgetAdminHTML' => 'basicAdminHTML',
00066     'configAdminConfig' => 'cor_config/admin.config',
00067     'listConfigHTML' => 'cor_config/admin.config.html',
00068     'sefAdminSef' => 'cor_sef/admin.sef',
00069     'sefAdminPage404' => 'cor_sef/admin.sef',
00070     'sefAdminUri' => 'cor_sef/admin.sef',
00071     'sefAdminMetadata' => 'cor_sef/admin.sef',
00072     'sefAdminHTML' => 'cor_sef/admin.sef.html',
00073     'HTML_installer' => 'cor_installer/admin.installer.html',
00074     'HTML_component' => 'cor_installer/component.html',
00075     'HTML_module' => 'cor_installer/module.html',
00076     'HTML_mambot' => 'cor_installer/mambot.html',
00077     'modulesAdminModules' => 'cor_modules/admin.modules',
00078     'HTML_modules' => 'cor_modules/admin.modules.html',
00079     'mambotsAdminMambots' => 'cor_mambots/admin.mambots',
00080     'listMambotsHTML' => 'cor_mambots/admin.mambots.html',
00081     'templatesAdminTemplates' => 'cor_templates/admin.templates',
00082     'listTemplatesHTML' => 'cor_templates/admin.templates.html',
00083     'errorsAdminErrors' => 'cor_errors/admin.errors',
00084     'listErrorsHTML' => 'cor_errors/admin.errors.html',
00085     'err404AdminErr404' => 'cor_err404/admin.err404',
00086     'listErr404HTML' => 'cor_err404/admin.err404.html',
00087     'foldersAdminFolders' => 'cor_folders/admin.folders',
00088     'foldersAdminHTML' => 'cor_folders/admin.folders.html',
00089     'listFoldersHTML' => 'cor_folders/admin.folders.html',
00090     'editFoldersHTML' => 'cor_folders/admin.folders.html',
00091     'sysinfoAdminSysinfo' => 'cor_sysinfo/admin.sysinfo',
00092     'helpAdminHelp' => 'cor_help/admin.help',
00093     'aliroExtensionInstaller' => 'aliroExtensionInstaller',
00094     'aliroLanguageHandler' => 'aliroExtensionInstaller',
00095     'aliroPatchHandler' => 'aliroExtensionInstaller',
00096     'aliroIncludeHandler' => 'aliroExtensionInstaller',
00097     'aliroParameterHandler' => 'aliroExtensionInstaller',
00098     'installerAdminInstaller' => 'cor_installer/admin.installer',
00099     'aliroInstaller' => 'cor_installer/installer.class',
00100     'extensionsAdminExtensions' => 'cor_extensions/admin.extensions',
00101     'listExtensionsHTML' => 'cor_extensions/admin.extensions.html',
00102     'menutypesAdminMenutypes' => 'cor_menutypes/admin.menutypes',
00103     'listMenutypesHTML' => 'cor_menutypes/admin.menutypes.html',
00104     'menusAdminMenus' => 'cor_menus/admin.menus',
00105     'menuInterface' => 'cor_menus/admin.menus',
00106     'listMenusHTML' => 'cor_menus/admin.menus.html',
00107     'languagesControllers' => 'cor_languages/admin.languages',
00108     'catalogsView' => 'cor_languages/views/catalogs.view',
00109     'editView' => 'cor_languages/views/edit.view',
00110     'indexView' => 'cor_languages/views/index.view',
00111     'languageView' => 'cor_languages/views/language.view',
00112     'applyAction' => 'cor_languages/actions/apply.action',
00113     'auto_translateAction' => 'cor_languages/actions/auto_translate.action',
00114     'cancelAction' => 'cor_languages/actions/cancel.action',
00115     'convertAction' => 'cor_languages/actions/convert.action',
00116     'defaultAction' => 'cor_languages/actions/default.action',
00117     'editAction' => 'cor_languages/actions/edit.action',
00118     'exportAction' => 'cor_languages/actions/export.action',
00119     'extractAction' => 'cor_languages/actions/extract.action',
00120     'indexAction' => 'cor_languages/actions/index.action',
00121     'installAction' => 'cor_languages/actions/install.action',
00122     'newAction' => 'cor_languages/actions/new.action',
00123     'publishAction' => 'cor_languages/actions/publish.action',
00124     'removeAction' => 'cor_languages/actions/remove.action',
00125     'saveAction' => 'cor_languages/actions/save.action',
00126     'sortAction' => 'cor_languages/actions/sort.action',
00127     'translateAction' => 'cor_languages/actions/translate.action',
00128     'updateAction' => 'cor_languages/actions/update.action',
00129     'languagesAdminLanguages' => 'cor_languages/languagesAdmin',
00130     'languagesAdminCatalogs' => 'cor_languages/catalogsAdmin',
00131     'catalogsAdminLanguages' => 'cor_languages/catalogsAdmin',
00132     'tagsAdminTags' => 'cor_tags/admin.tags',
00133     'aliroTag' => 'cor_tags/admin.tags',
00134     'listTagsHTML' => 'cor_tags/admin.tags.html',
00135     'editTagsHTML' => 'cor_tags/admin.tags.html'
00136     );
00137 
00138     public static function getInstance () {
00139         if (!is_object(self::$instance)) {
00140             self::$instance = parent::getCachedSingleton(self::$instance);
00141             self::$instance->reset();
00142         }
00143         self::$instance->checkDynamic();
00144         return self::$instance;
00145     }
00146 
00147     protected function populateMap () {
00148         $database = aliroCoreDatabase::getInstance();
00149         $database->setQuery('SELECT * FROM #__classmap');
00150         $maps = $database->loadObjectList();
00151         $admindir = substr(criticalInfo::getInstance()->admin_dir, 1);
00152         if ($maps) foreach ($maps as $map) {
00153             switch ($map->type) {
00154                 case 'component':
00155                     $path = ($map->side == 'admin') ? $admindir.'/components/' : 'components/';
00156                     $path .= $map->formalname.'/';
00157                     break;
00158                 case 'module':
00159                     $path = ($map->side == 'admin') ? $admindir.'/modules/' : 'modules/';
00160                     $path .= $map->formalname.'/';
00161                     break;
00162                 case 'mambot':
00163                     $path = 'mambots/'.$map->formalname.'/';
00164                     break;
00165                 case 'template':
00166                     $path = ($map->side == 'admin') ? $admindir.'/templates/' : 'templates/';
00167                     $path .= $map->formalname.'/';
00168                     break;
00169                 default: continue;
00170             }
00171             $this->saveMap($path, $map);
00172         }
00173     }
00174 
00175     protected function getClassPath ($classname) {
00176         if (isset(self::$adminmap[$classname])) {
00177             $debuginfo = aliroDebug::getInstance();
00178             $debuginfo->setDebugData ("About to load $classname, current free memory ".(is_callable('memory_get_usage') ? memory_get_usage() : 'not known').$this->timer->mark('seconds'));
00179             return str_replace('\\', '/', dirname(__FILE__)).'/classes/'.self::$adminmap[$classname].'.php';
00180         }
00181         return parent::getClassPath($classname);
00182     }
00183     
00184 }

Generated on Thu Apr 17 13:03:27 2008 for ALIRO by  doxygen 1.5.5