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     'aliroMakeManifest' => 'aliroMakeManifest',
00064     'basicAdminHTML' => 'basicAdminHTML',
00065     'advancedAdminHTML' => 'basicAdminHTML',
00066     'widgetAdminHTML' => 'basicAdminHTML',
00067     'configAdminConfig' => 'cor_config/admin.config',
00068     'listConfigHTML' => 'cor_config/admin.config.html',
00069     'sefAdminSef' => 'cor_sef/admin.sef',
00070     'sefAdminPage404' => 'cor_sef/admin.sef',
00071     'sefAdminUri' => 'cor_sef/admin.sef',
00072     'sefAdminMetadata' => 'cor_sef/admin.sef',
00073     'sefAdminHTML' => 'cor_sef/admin.sef.html',
00074     'HTML_installer' => 'cor_installer/admin.installer.html',
00075     'HTML_component' => 'cor_installer/component.html',
00076     'HTML_module' => 'cor_installer/module.html',
00077     'HTML_mambot' => 'cor_installer/mambot.html',
00078     'modulesAdminModules' => 'cor_modules/admin.modules',
00079     'HTML_modules' => 'cor_modules/admin.modules.html',
00080     'mambotsAdminMambots' => 'cor_mambots/admin.mambots',
00081     'listMambotsHTML' => 'cor_mambots/admin.mambots.html',
00082     'templatesAdminTemplates' => 'cor_templates/admin.templates',
00083     'listTemplatesHTML' => 'cor_templates/admin.templates.html',
00084     'errorsAdminErrors' => 'cor_errors/admin.errors',
00085     'listErrorsHTML' => 'cor_errors/admin.errors.html',
00086     'err404AdminErr404' => 'cor_err404/admin.err404',
00087     'listErr404HTML' => 'cor_err404/admin.err404.html',
00088     'foldersAdminFolders' => 'cor_folders/admin.folders',
00089     'foldersAdminHTML' => 'cor_folders/admin.folders.html',
00090     'listFoldersHTML' => 'cor_folders/admin.folders.html',
00091     'editFoldersHTML' => 'cor_folders/admin.folders.html',
00092     'sysinfoAdminSysinfo' => 'cor_sysinfo/admin.sysinfo',
00093     'helpAdminHelp' => 'cor_help/admin.help',
00094     'aliroExtensionInstaller' => 'aliroExtensionInstaller',
00095     'aliroLanguageHandler' => 'aliroExtensionInstaller',
00096     'aliroPatchHandler' => 'aliroExtensionInstaller',
00097     'aliroIncludeHandler' => 'aliroExtensionInstaller',
00098     'aliroParameterHandler' => 'aliroExtensionInstaller',
00099     'installerAdminInstaller' => 'cor_installer/admin.installer',
00100     'aliroInstaller' => 'cor_installer/installer.class',
00101     'extensionsAdminExtensions' => 'cor_extensions/admin.extensions',
00102     'listExtensionsHTML' => 'cor_extensions/admin.extensions.html',
00103     'menutypesAdminMenutypes' => 'cor_menutypes/admin.menutypes',
00104     'listMenutypesHTML' => 'cor_menutypes/admin.menutypes.html',
00105     'menusAdminMenus' => 'cor_menus/admin.menus',
00106     'menuInterface' => 'cor_menus/admin.menus',
00107     'listMenusHTML' => 'cor_menus/admin.menus.html',
00108     'languagesControllers' => 'cor_languages/admin.languages',
00109     'catalogsView' => 'cor_languages/views/catalogs.view',
00110     'editView' => 'cor_languages/views/edit.view',
00111     'indexView' => 'cor_languages/views/index.view',
00112     'languageView' => 'cor_languages/views/language.view',
00113     'applyAction' => 'cor_languages/actions/apply.action',
00114     'auto_translateAction' => 'cor_languages/actions/auto_translate.action',
00115     'cancelAction' => 'cor_languages/actions/cancel.action',
00116     'convertAction' => 'cor_languages/actions/convert.action',
00117     'defaultAction' => 'cor_languages/actions/default.action',
00118     'editAction' => 'cor_languages/actions/edit.action',
00119     'exportAction' => 'cor_languages/actions/export.action',
00120     'extractAction' => 'cor_languages/actions/extract.action',
00121     'indexAction' => 'cor_languages/actions/index.action',
00122     'installAction' => 'cor_languages/actions/install.action',
00123     'newAction' => 'cor_languages/actions/new.action',
00124     'publishAction' => 'cor_languages/actions/publish.action',
00125     'removeAction' => 'cor_languages/actions/remove.action',
00126     'saveAction' => 'cor_languages/actions/save.action',
00127     'sortAction' => 'cor_languages/actions/sort.action',
00128     'translateAction' => 'cor_languages/actions/translate.action',
00129     'updateAction' => 'cor_languages/actions/update.action',
00130     'languagesAdminLanguages' => 'cor_languages/languagesAdmin',
00131     'languagesAdminCatalogs' => 'cor_languages/catalogsAdmin',
00132     'catalogsAdminLanguages' => 'cor_languages/catalogsAdmin',
00133     'tagsAdminTags' => 'cor_tags/admin.tags',
00134     'aliroTag' => 'cor_tags/admin.tags',
00135     'listTagsHTML' => 'cor_tags/admin.tags.html',
00136     'editTagsHTML' => 'cor_tags/admin.tags.html'
00137     );
00138 
00139     public static function getInstance () {
00140         if (!is_object(self::$instance)) {
00141             self::$instance = parent::getCachedSingleton(self::$instance);
00142             self::$instance->reset();
00143         }
00144         self::$instance->checkDynamic();
00145         return self::$instance;
00146     }
00147 
00148     protected function populateMap () {
00149         $database = aliroCoreDatabase::getInstance();
00150         $database->setQuery('SELECT * FROM #__classmap');
00151         $maps = $database->loadObjectList();
00152         $admindir = substr(criticalInfo::getInstance()->admin_dir, 1);
00153         if ($maps) foreach ($maps as $map) {
00154             switch ($map->type) {
00155                 case 'component':
00156                     $path = ($map->side == 'admin') ? $admindir.'/components/' : 'components/';
00157                     $path .= $map->formalname.'/';
00158                     break;
00159                 case 'module':
00160                     $path = ($map->side == 'admin') ? $admindir.'/modules/' : 'modules/';
00161                     $path .= $map->formalname.'/';
00162                     break;
00163                 case 'mambot':
00164                     $path = 'mambots/'.$map->formalname.'/';
00165                     break;
00166                 case 'template':
00167                     $path = ($map->side == 'admin') ? $admindir.'/templates/' : 'templates/';
00168                     $path .= $map->formalname.'/';
00169                     break;
00170                 default: continue;
00171             }
00172             $this->saveMap($path, $map);
00173         }
00174     }
00175 
00176     protected function getClassPath ($classname) {
00177         if (isset(self::$adminmap[$classname])) {
00178             $debuginfo = aliroDebug::getInstance();
00179             $debuginfo->setDebugData ("About to load $classname, current free memory ".(is_callable('memory_get_usage') ? memory_get_usage() : 'not known').$this->timer->mark('seconds'));
00180             return str_replace('\\', '/', dirname(__FILE__)).'/classes/'.self::$adminmap[$classname].'.php';
00181         }
00182         return parent::getClassPath($classname);
00183     }
00184     
00185 }

Generated on Wed May 14 13:01:56 2008 for ALIRO by  doxygen 1.5.5