Commit 526faee16a279bf1bc30eff8ef7d188fa8b34e16
1 parent
c1ae68cf
Move all plugin-dynamic structures into $GLOBALS['_KT_PLUGIN'] for easier later
caching. Implement the caching code, but don't use it yet. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5492 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
11 changed files
with
49 additions
and
33 deletions
lib/actions/actionregistry.inc.php
| ... | ... | @@ -30,10 +30,10 @@ class KTActionRegistry { |
| 30 | 30 | var $actions = array(); |
| 31 | 31 | // {{{ getSingleton |
| 32 | 32 | function &getSingleton () { |
| 33 | - if (!KTUtil::arrayGet($GLOBALS, 'oKTActionRegistry')) { | |
| 34 | - $GLOBALS['oKTActionRegistry'] = new KTActionRegistry; | |
| 33 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTActionRegistry')) { | |
| 34 | + $GLOBALS['_KT_PLUGIN']['oKTActionRegistry'] = new KTActionRegistry; | |
| 35 | 35 | } |
| 36 | - return $GLOBALS['oKTActionRegistry']; | |
| 36 | + return $GLOBALS['_KT_PLUGIN']['oKTActionRegistry']; | |
| 37 | 37 | } |
| 38 | 38 | // }}} |
| 39 | 39 | ... | ... |
lib/actions/portletregistry.inc.php
| ... | ... | @@ -30,10 +30,10 @@ class KTPortletRegistry { |
| 30 | 30 | var $actions = array(); |
| 31 | 31 | // {{{ getSingleton |
| 32 | 32 | function &getSingleton () { |
| 33 | - if (!KTUtil::arrayGet($GLOBALS, 'oKTPortletRegistry')) { | |
| 34 | - $GLOBALS['oKTPortletRegistry'] =& new KTPortletRegistry; | |
| 33 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTPortletRegistry')) { | |
| 34 | + $GLOBALS['_KT_PLUGIN']['oKTPortletRegistry'] =& new KTPortletRegistry; | |
| 35 | 35 | } |
| 36 | - return $GLOBALS['oKTPortletRegistry']; | |
| 36 | + return $GLOBALS['_KT_PLUGIN']['oKTPortletRegistry']; | |
| 37 | 37 | } |
| 38 | 38 | // }}} |
| 39 | 39 | |
| ... | ... | @@ -81,7 +81,7 @@ class KTPortletRegistry { |
| 81 | 81 | if (file_exists($sPortletFile)) { |
| 82 | 82 | require_once($sPortletFile); |
| 83 | 83 | } |
| 84 | - $oPortlet =& new $sPortletClass; | |
| 84 | + $oPortlet =& new $sPortletClass; | |
| 85 | 85 | $oPortlet->setPlugin($oPlugin); |
| 86 | 86 | array_push($aReturn, $oPortlet); |
| 87 | 87 | } | ... | ... |
lib/authentication/authenticationproviderregistry.inc.php
| ... | ... | @@ -53,10 +53,10 @@ class KTAuthenticationProviderRegistry { |
| 53 | 53 | |
| 54 | 54 | // {{{ getSingleton |
| 55 | 55 | function &getSingleton () { |
| 56 | - if (!KTUtil::arrayGet($GLOBALS, 'oKTAuthenticationProviderRegistry')) { | |
| 57 | - $GLOBALS['oKTAuthenticationProviderRegistry'] = new KTAuthenticationProviderRegistry; | |
| 56 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTAuthenticationProviderRegistry')) { | |
| 57 | + $GLOBALS['_KT_PLUGIN']['oKTAuthenticationProviderRegistry'] = new KTAuthenticationProviderRegistry; | |
| 58 | 58 | } |
| 59 | - return $GLOBALS['oKTAuthenticationProviderRegistry']; | |
| 59 | + return $GLOBALS['_KT_PLUGIN']['oKTAuthenticationProviderRegistry']; | |
| 60 | 60 | } |
| 61 | 61 | // }}} |
| 62 | 62 | ... | ... |
lib/dashboard/dashletregistry.inc.php
| ... | ... | @@ -32,10 +32,10 @@ class KTDashletRegistry { |
| 32 | 32 | var $nsnames = array(); |
| 33 | 33 | // {{{ getSingleton |
| 34 | 34 | function &getSingleton () { |
| 35 | - if (!KTUtil::arrayGet($GLOBALS, 'oKTDashboardRegistry')) { | |
| 36 | - $GLOBALS['oKTDashboardRegistry'] = new KTDashletRegistry; | |
| 35 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTDashboardRegistry')) { | |
| 36 | + $GLOBALS['_KT_PLUGIN']['oKTDashboardRegistry'] = new KTDashletRegistry; | |
| 37 | 37 | } |
| 38 | - return $GLOBALS['oKTDashboardRegistry']; | |
| 38 | + return $GLOBALS['_KT_PLUGIN']['oKTDashboardRegistry']; | |
| 39 | 39 | } |
| 40 | 40 | // }}} |
| 41 | 41 | ... | ... |
lib/help/help.inc.php
| ... | ... | @@ -201,11 +201,11 @@ class KTHelpRegistry { |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | function &getSingleton () { |
| 204 | - if (!KTUtil::arrayGet($GLOBALS, 'oKTHelpRegistry')) { | |
| 205 | - $GLOBALS['oKTHelpRegistry'] = new KTHelpRegistry; | |
| 204 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTHelpRegistry')) { | |
| 205 | + $GLOBALS['_KT_PLUGIN']['oKTHelpRegistry'] = new KTHelpRegistry; | |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - return $GLOBALS['oKTHelpRegistry']; | |
| 208 | + return $GLOBALS['_KT_PLUGIN']['oKTHelpRegistry']; | |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | function registerHelp($sPluginName, $sLang, $sBaseDir) { | ... | ... |
lib/i18n/i18nregistry.inc.php
| ... | ... | @@ -35,10 +35,10 @@ class KTi18nRegistry { |
| 35 | 35 | var $_aLanguages = array(); |
| 36 | 36 | |
| 37 | 37 | function &getSingleton() { |
| 38 | - if (!KTUtil::arrayGet($GLOBALS, 'oKTi18nRegistry')) { | |
| 39 | - $GLOBALS['oKTi18nRegistry'] =& new KTi18nRegistry; | |
| 38 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTi18nRegistry')) { | |
| 39 | + $GLOBALS['_KT_PLUGIN']['oKTi18nRegistry'] =& new KTi18nRegistry; | |
| 40 | 40 | } |
| 41 | - return $GLOBALS['oKTi18nRegistry']; | |
| 41 | + return $GLOBALS['_KT_PLUGIN']['oKTi18nRegistry']; | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | function registeri18n($sDomain, $sDirectory) { | ... | ... |
lib/plugins/KTAdminNavigation.php
| ... | ... | @@ -34,10 +34,10 @@ class KTAdminNavigationRegistry { |
| 34 | 34 | var $aCategories = array(); |
| 35 | 35 | |
| 36 | 36 | function &getSingleton() { |
| 37 | - if (!KTUtil::arrayGet($GLOBALS, 'oKTAdminNavigationRegistry')) { | |
| 38 | - $GLOBALS['oKTAdminNavigationRegistry'] = new KTAdminNavigationRegistry; | |
| 37 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTAdminNavigationRegistry')) { | |
| 38 | + $GLOBALS['_KT_PLUGIN']['oKTAdminNavigationRegistry'] = new KTAdminNavigationRegistry; | |
| 39 | 39 | } |
| 40 | - return $GLOBALS['oKTAdminNavigationRegistry']; | |
| 40 | + return $GLOBALS['_KT_PLUGIN']['oKTAdminNavigationRegistry']; | |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // name is the suburl below admin |
| ... | ... | @@ -100,4 +100,4 @@ class RedirectingDispatcher { |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | -?> | |
| 104 | 103 | \ No newline at end of file |
| 104 | +?> | ... | ... |
lib/plugins/pageregistry.inc.php
| ... | ... | @@ -30,10 +30,10 @@ class KTPageRegistry { |
| 30 | 30 | var $aResources = array(); |
| 31 | 31 | |
| 32 | 32 | function &getSingleton() { |
| 33 | - if (!KTUtil::arrayGet($GLOBALS, 'oKTPageRegistry')) { | |
| 34 | - $GLOBALS['oKTPageRegistry'] = new KTPageRegistry; | |
| 33 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTPageRegistry')) { | |
| 34 | + $GLOBALS['_KT_PLUGIN']['oKTPageRegistry'] = new KTPageRegistry; | |
| 35 | 35 | } |
| 36 | - return $GLOBALS['oKTPageRegistry']; | |
| 36 | + return $GLOBALS['_KT_PLUGIN']['oKTPageRegistry']; | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | function registerPage($sPath, $sClassName, $sFilename = null) { | ... | ... |
lib/plugins/pluginregistry.inc.php
| ... | ... | @@ -31,10 +31,10 @@ class KTPluginRegistry { |
| 31 | 31 | var $_aPlugins = array(); |
| 32 | 32 | |
| 33 | 33 | function &getSingleton() { |
| 34 | - if (!KTUtil::arrayGet($GLOBALS, 'oKTPluginRegistry')) { | |
| 35 | - $GLOBALS['oKTPluginRegistry'] = new KTPluginRegistry; | |
| 34 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTPluginRegistry')) { | |
| 35 | + $GLOBALS['_KT_PLUGIN']['oKTPluginRegistry'] = new KTPluginRegistry; | |
| 36 | 36 | } |
| 37 | - return $GLOBALS['oKTPluginRegistry']; | |
| 37 | + return $GLOBALS['_KT_PLUGIN']['oKTPluginRegistry']; | |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | function registerPlugin($sClassName, $sNamespace, $sFilename = null) { | ... | ... |
lib/plugins/pluginutil.inc.php
| ... | ... | @@ -57,6 +57,22 @@ class KTPluginResourceRegistry { |
| 57 | 57 | |
| 58 | 58 | class KTPluginUtil { |
| 59 | 59 | function loadPlugins () { |
| 60 | + $sPluginCache = KT_DIR . '/var/plugin-cache'; | |
| 61 | + if (file_exists($sPluginCache)) { | |
| 62 | + require_once(KT_LIB_DIR . '/actions/actionregistry.inc.php'); | |
| 63 | + require_once(KT_LIB_DIR . '/actions/portletregistry.inc.php'); | |
| 64 | + require_once(KT_LIB_DIR . '/triggers/triggerregistry.inc.php'); | |
| 65 | + require_once(KT_LIB_DIR . '/plugins/pageregistry.inc.php'); | |
| 66 | + require_once(KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php'); | |
| 67 | + require_once(KT_LIB_DIR . "/plugins/KTAdminNavigation.php"); | |
| 68 | + require_once(KT_LIB_DIR . "/dashboard/dashletregistry.inc.php"); | |
| 69 | + require_once(KT_LIB_DIR . "/i18n/i18nregistry.inc.php"); | |
| 70 | + require_once(KT_LIB_DIR . "/help/help.inc.php"); | |
| 71 | + $GLOBALS['_KT_PLUGIN'] = unserialize(file_get_contents($sPluginCache)); | |
| 72 | + $GLOBALS['_KT_PLUGIN']['oKTPluginRegistry']->_aPlugins = array(); | |
| 73 | + return; | |
| 74 | + } | |
| 75 | + $GLOBALS['_KT_PLUGIN'] = array(); | |
| 60 | 76 | $aPlugins = KTPluginEntity::getList(); |
| 61 | 77 | if (count($aPlugins) === 0) { |
| 62 | 78 | KTPluginUtil::registerPlugins(); |
| ... | ... | @@ -83,7 +99,6 @@ class KTPluginUtil { |
| 83 | 99 | require_once($sPath); |
| 84 | 100 | } |
| 85 | 101 | } |
| 86 | - | |
| 87 | 102 | $oRegistry =& KTPluginRegistry::getSingleton(); |
| 88 | 103 | $aPlugins =& $oRegistry->getPlugins(); |
| 89 | 104 | foreach ($aPlugins as $oPlugin) { |
| ... | ... | @@ -98,6 +113,7 @@ class KTPluginUtil { |
| 98 | 113 | $oPlugin->load(); |
| 99 | 114 | } |
| 100 | 115 | } |
| 116 | + // file_put_contents($sPluginCache, serialize($GLOBALS['_KT_PLUGIN'])); | |
| 101 | 117 | } |
| 102 | 118 | |
| 103 | 119 | function registerPlugins () { | ... | ... |
lib/triggers/triggerregistry.inc.php
| ... | ... | @@ -30,10 +30,10 @@ class KTTriggerRegistry { |
| 30 | 30 | var $triggers = array(); |
| 31 | 31 | // {{{ getSingleton |
| 32 | 32 | function &getSingleton () { |
| 33 | - if (!KTUtil::arrayGet($GLOBALS, 'oKTTriggerRegistry')) { | |
| 34 | - $GLOBALS['oKTTriggerRegistry'] = new KTTriggerRegistry; | |
| 33 | + if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTTriggerRegistry')) { | |
| 34 | + $GLOBALS['_KT_PLUGIN']['oKTTriggerRegistry'] = new KTTriggerRegistry; | |
| 35 | 35 | } |
| 36 | - return $GLOBALS['oKTTriggerRegistry']; | |
| 36 | + return $GLOBALS['_KT_PLUGIN']['oKTTriggerRegistry']; | |
| 37 | 37 | } |
| 38 | 38 | // }}} |
| 39 | 39 | ... | ... |