Commit b2017d1d4de9c6a21532ef183529ef21781f444e
1 parent
e59f3c41
KTS-2708
"Refactor plugins registration and loading" Fixed. Added a helper table for registering all the dashlets, actions, etc. Reduced the number of calls made when loading the plugins. Committed by: Megan Watson Reviewed by: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7703 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
8 changed files
with
613 additions
and
112 deletions
config/dmsDefaults.php
| ... | ... | @@ -216,7 +216,8 @@ class KTInit { |
| 216 | 216 | * Eduardo Polidor, et. al. |
| 217 | 217 | */ |
| 218 | 218 | if (ini_get('register_globals')) { |
| 219 | - foreach (array($_ENV, $_GET, $_POST, $_COOKIE, $_SERVER) as $superglob) { | |
| 219 | + $aGlobals = array($_ENV, $_GET, $_POST, $_COOKIE, $_SERVER); | |
| 220 | + foreach ($aGlobals as $superglob) { | |
| 220 | 221 | foreach ($superglob as $key => $val) { |
| 221 | 222 | if (isset($GLOBALS[$key]) && $GLOBALS[$key] == $val) { |
| 222 | 223 | unset($GLOBALS[$key]); |
| ... | ... | @@ -639,7 +640,14 @@ require_once(KT_LIB_DIR . '/session/control.inc'); |
| 639 | 640 | require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); |
| 640 | 641 | |
| 641 | 642 | if ($checkup !== true) { |
| 642 | - KTPluginUtil::loadPlugins(); | |
| 643 | + // Replace function later | |
| 644 | + /* ** Get the page being loaded and load the plugins specific to the page ** */ | |
| 645 | + $sScriptName = $GLOBALS['_SERVER']['SCRIPT_NAME']; | |
| 646 | + $sScript = basename($sScriptName); | |
| 647 | + $pos = strpos($sScript, '.'); | |
| 648 | + $sType = substr($sScript, 0, $pos); | |
| 649 | + | |
| 650 | + KTPluginUtil::loadPlugins($sType); | |
| 643 | 651 | } |
| 644 | 652 | |
| 645 | 653 | if ($checkup !== true) { | ... | ... |
lib/plugins/KTAdminNavigation.php
| ... | ... | @@ -5,32 +5,32 @@ |
| 5 | 5 | * KnowledgeTree Open Source Edition |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | |
| 8 | + * | |
| 9 | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | 11 | * Free Software Foundation. |
| 12 | - * | |
| 12 | + * | |
| 13 | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | 16 | * details. |
| 17 | - * | |
| 17 | + * | |
| 18 | 18 | * You should have received a copy of the GNU General Public License |
| 19 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | - * copyright notice. | |
| 32 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | + * copyright notice. | |
| 34 | 34 | * Contributor( s): ______________________________________ |
| 35 | 35 | * |
| 36 | 36 | */ |
| ... | ... | @@ -91,7 +91,7 @@ class KTAdminNavigationRegistry { |
| 91 | 91 | // FIXME this probably needs to use require_once mojo. |
| 92 | 92 | $aInfo = $this->aResources[$sName]; |
| 93 | 93 | if ($aInfo["filepath"] !== null) { require_once($aInfo["filepath"]); } |
| 94 | - if ($aInfo["url"] !== null) { | |
| 94 | + if (!empty($aInfo['url'])) { | |
| 95 | 95 | return new RedirectingDispatcher($aInfo["url"]); |
| 96 | 96 | } |
| 97 | 97 | return new $aInfo["class"]; | ... | ... |
lib/plugins/plugin.inc.php
| ... | ... | @@ -5,32 +5,32 @@ |
| 5 | 5 | * KnowledgeTree Open Source Edition |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | |
| 8 | + * | |
| 9 | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | 11 | * Free Software Foundation. |
| 12 | - * | |
| 12 | + * | |
| 13 | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | 16 | * details. |
| 17 | - * | |
| 17 | + * | |
| 18 | 18 | * You should have received a copy of the GNU General Public License |
| 19 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | - * copyright notice. | |
| 32 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | + * copyright notice. | |
| 34 | 34 | * Contributor( s): ______________________________________ |
| 35 | 35 | * |
| 36 | 36 | */ |
| ... | ... | @@ -81,27 +81,51 @@ class KTPlugin { |
| 81 | 81 | function registerPortlet($aLocation, $sPortletClassName, $sPortletNamespace, $sFilename = null) { |
| 82 | 82 | $sFilename = $this->_fixFilename($sFilename); |
| 83 | 83 | $this->_aPortlets[$sPortletNamespace] = array($aLocation, $sPortletClassName, $sPortletNamespace, $sFilename, $this->sNamespace); |
| 84 | + | |
| 85 | + // Register helper in DB | |
| 86 | + if(is_array($aLocation)){ | |
| 87 | + $sLocation = implode('_|', $aLocation); | |
| 88 | + } | |
| 89 | + $params = $sLocation.'|'.$sPortletClassName.'|'.$sPortletNamespace.'|'.$sFilename.'|'.$this->sNamespace; | |
| 90 | + $this->registerPluginHelper($sPortletNamespace, $sPortletClassName, $sFilename, $params, 'general', 'portlet'); | |
| 84 | 91 | } |
| 85 | 92 | |
| 86 | 93 | function registerTrigger($sAction, $sStage, $sTriggerClassName, $sTriggerNamespace, $sFilename = null) { |
| 87 | 94 | $sFilename = $this->_fixFilename($sFilename); |
| 88 | 95 | $this->_aTriggers[$sTriggerNamespace] = array($sAction, $sStage, $sTriggerClassName, $sTriggerNamespace, $sFilename, $this->sNamespace); |
| 96 | + | |
| 97 | + // Register helper in DB | |
| 98 | + $params = $sAction.'|'.$sStage.'|'.$sTriggerClassName.'|'.$sTriggerNamespace.'|'.$sFilename.'|'.$this->sNamespace; | |
| 99 | + $this->registerPluginHelper($sTriggerNamespace, $sTriggerClassName, $sFilename, $params, 'general', 'trigger'); | |
| 89 | 100 | } |
| 90 | 101 | |
| 91 | 102 | function registerAction($sActionType, $sActionClassName, $sActionNamespace, $sFilename = null) { |
| 92 | 103 | $sFilename = $this->_fixFilename($sFilename); |
| 93 | 104 | $this->_aActions[$sActionNamespace] = array($sActionType, $sActionClassName, $sActionNamespace, $sFilename, $this->sNamespace); |
| 105 | + | |
| 106 | + // Register helper in DB | |
| 107 | + $params = $sActionType.'|'.$sActionClassName.'|'.$sActionNamespace.'|'.$sFilename.'|'.$this->sNamespace; | |
| 108 | + $this->registerPluginHelper($sActionNamespace, $sActionClassName, $sFilename, $params, 'general', 'action'); | |
| 94 | 109 | } |
| 95 | 110 | |
| 96 | 111 | function registerPage($sWebPath, $sPageClassName, $sFilename = null) { |
| 97 | 112 | $sFilename = $this->_fixFilename($sFilename); |
| 98 | 113 | $sWebPath = sprintf("%s/%s", $this->sNamespace, $sWebPath); |
| 114 | + | |
| 99 | 115 | $this->_aPages[$sWebPath] = array($sWebPath, $sPageClassName, $sFilename, $this->sNamespace); |
| 116 | + | |
| 117 | + // Register helper in DB | |
| 118 | + $params = $sWebPath.'|'.$sPageClassName.'|'.$sFilename.'|'.$this->sNamespace; | |
| 119 | + $this->registerPluginHelper($sWebPath, $sPageClassName, $sFilename, $params, 'general', 'page'); | |
| 100 | 120 | } |
| 101 | 121 | |
| 102 | 122 | function registerWorkflowTrigger($sNamespace, $sTriggerClassName, $sFilename = null) { |
| 103 | 123 | $sFilename = $this->_fixFilename($sFilename); |
| 104 | 124 | $this->_aWFTriggers[$sNamespace] = array($sNamespace, $sTriggerClassName, $sFilename); |
| 125 | + | |
| 126 | + // Register helper in DB | |
| 127 | + $params = $sNamespace.'|'.$sTriggerClassName.'|'.$sFilename; | |
| 128 | + $this->registerPluginHelper($sNamespace, $sTriggerClassName, $sFilename, $params, 'general', 'workflow_trigger'); | |
| 105 | 129 | } |
| 106 | 130 | |
| 107 | 131 | function getPagePath($sPath) { |
| ... | ... | @@ -120,6 +144,10 @@ class KTPlugin { |
| 120 | 144 | function registerAuthenticationProvider($sName, $sClass, $sNamespace, $sFilename = null) { |
| 121 | 145 | $sFilename = $this->_fixFilename($sFilename); |
| 122 | 146 | $this->_aAuthenticationProviders[$sNamespace] = array($sName, $sClass, $sNamespace, $sFilename, $this->sNamespace); |
| 147 | + | |
| 148 | + // Register helper in DB | |
| 149 | + $params = $sName.'|'.$sClass.'|'.$sNamespace.'|'.$sFilename.'|'.$this->sNamespace; | |
| 150 | + $this->registerPluginHelper($sNamespace, $sClass, $sFilename, $params, 'general', 'authentication_provider'); | |
| 123 | 151 | } |
| 124 | 152 | |
| 125 | 153 | //registerLocation($sName, $sClass, $sCategory, $sTitle, $sDescription, $sDispatcherFilePath = null, $sURL = null) |
| ... | ... | @@ -127,20 +155,42 @@ class KTPlugin { |
| 127 | 155 | $sFullname = $sCategory . '/' . $sName; |
| 128 | 156 | $sFilename = $this->_fixFilename($sFilename); |
| 129 | 157 | $this->_aAdminPages[$sFullname] = array($sName, $sClass, $sCategory, $sTitle, $sDescription, $sFilename, null, $this->sNamespace); |
| 158 | + | |
| 159 | + // Register helper in DB | |
| 160 | + $params = $sName.'|'.$sClass.'|'.$sCategory.'|'.$sTitle.'|'.$sDescription.'|'.$sFilename.'|'.null.'|'.$this->sNamespace; | |
| 161 | + $this->registerPluginHelper($sFullname, $sClass, $sFilename, $params, 'general', 'admin_page'); | |
| 130 | 162 | } |
| 131 | 163 | |
| 132 | 164 | function registerAdminCategory($sPath, $sName, $sDescription) { |
| 133 | 165 | $this->_aAdminCategories[$sPath] = array($sPath, $sName, $sDescription); |
| 166 | + | |
| 167 | + // Register helper in DB | |
| 168 | + $params = $sPath.'|'.$sName.'|'.$sDescription; | |
| 169 | + $this->registerPluginHelper($sPath, $sName, $sPath, $params, 'general', 'admin_category'); | |
| 134 | 170 | } |
| 135 | 171 | |
| 172 | + /** | |
| 173 | + * Register a new dashlet | |
| 174 | + * | |
| 175 | + * @param string $sClassName | |
| 176 | + * @param string $sNamespace | |
| 177 | + * @param string $sFilename | |
| 178 | + */ | |
| 136 | 179 | function registerDashlet($sClassName, $sNamespace, $sFilename) { |
| 137 | 180 | $sFilename = $this->_fixFilename($sFilename); |
| 138 | 181 | $this->_aDashlets[$sNamespace] = array($sClassName, $sNamespace, $sFilename, $this->sNamespace); |
| 182 | + | |
| 183 | + $params = $sClassName.'|'.$sNamespace.'|'.$sFilename.'|'.$this->sNamespace; | |
| 184 | + $this->registerPluginHelper($sNamespace, $sClassName, $sFilename, $params, 'dashboard', 'dashlet'); | |
| 139 | 185 | } |
| 140 | 186 | |
| 141 | 187 | function registeri18n($sDomain, $sPath) { |
| 142 | 188 | $sPath = $this->_fixFilename($sPath); |
| 143 | 189 | $this->_ai18n[$sDomain] = array($sDomain, $sPath); |
| 190 | + | |
| 191 | + // Register helper in DB | |
| 192 | + $params = $sDomain.'|'.$sPath; | |
| 193 | + $this->registerPluginHelper($sDomain, $sDomain, $sPath, $params, 'general', 'i18n'); | |
| 144 | 194 | } |
| 145 | 195 | |
| 146 | 196 | function registeri18nLang($sDomain, $sLang, $sPath) { |
| ... | ... | @@ -148,55 +198,151 @@ class KTPlugin { |
| 148 | 198 | $sPath = $this->_fixFilename($sPath); |
| 149 | 199 | } |
| 150 | 200 | $this->_ai18nLang["$sDomain/$sLang"] = array($sDomain, $sLang, $sPath); |
| 201 | + | |
| 202 | + // Register helper in DB | |
| 203 | + $params = $sDomain.'|'.$sLang.'|'.$sPath; | |
| 204 | + $this->registerPluginHelper("$sDomain/$sLang", $sDomain, $sPath, $params, 'general', 'i18nlang'); | |
| 151 | 205 | } |
| 152 | 206 | |
| 153 | 207 | function registerLanguage($sLanguage, $sLanguageName) { |
| 154 | 208 | $this->_aLanguage[$sLanguage] = array($sLanguage, $sLanguageName); |
| 209 | + | |
| 210 | + // Register helper in DB | |
| 211 | + $params = $sLanguage.'|'.$sLanguageName; | |
| 212 | + $this->registerPluginHelper($sLanguage, $sClassName, $sFilename, $params, 'general', 'language'); | |
| 155 | 213 | } |
| 156 | 214 | |
| 157 | 215 | function registerHelpLanguage($sPlugin, $sLanguage, $sBasedir) { |
| 158 | 216 | $this->_aHelpLanguage[$sLanguage] = array($sPlugin, $sLanguage, $sBasedir); |
| 217 | + | |
| 218 | + // Register helper in DB | |
| 219 | + $params = $sPlugin.'|'.$sLanguage.'|'.$sBasedir; | |
| 220 | + $this->registerPluginHelper($sLanguage, $sClassName, $sFilename, $params, 'general', 'help_language'); | |
| 159 | 221 | } |
| 160 | 222 | |
| 161 | 223 | function registerColumn($sName, $sNamespace, $sClassName, $sFile) { |
| 162 | 224 | $sFile = $this->_fixFilename($sFile); |
| 163 | 225 | $this->_aColumns[$sNamespace] = array($sName, $sNamespace, $sClassName, $sFile); |
| 226 | + | |
| 227 | + // Register helper in DB | |
| 228 | + $params = $sName.'|'.$sNamespace.'|'.$sClassName.'|'.$sFile; | |
| 229 | + $this->registerPluginHelper($sNamespace, $sClassName, $sFile, $params, 'general', 'column'); | |
| 164 | 230 | } |
| 165 | 231 | |
| 166 | 232 | function registerView($sName, $sNamespace) { |
| 167 | 233 | $this->_aViews[$sNamespace] = array($sName, $sNamespace); |
| 234 | + | |
| 235 | + // Register helper in DB | |
| 236 | + $params = $sName.'|'.$sNamespace; | |
| 237 | + $this->registerPluginHelper($sNamespace, '', '', $params, 'general', 'view'); | |
| 168 | 238 | } |
| 169 | 239 | |
| 170 | 240 | function registerNotificationHandler($sName, $sNamespace, $sPath) { |
| 171 | 241 | $sPath = $this->_fixFilename($sPath); |
| 172 | 242 | $this->_aNotificationHandlers[$sNamespace] = array($sNamespace, $sName, $sPath); |
| 243 | + | |
| 244 | + // Register helper in DB | |
| 245 | + $params = $sNamespace.'|'.$sName.'|'.$sPath; | |
| 246 | + $this->registerPluginHelper($sNamespace, $sName, $sPath, $params, 'general', 'notification_handler'); | |
| 173 | 247 | } |
| 174 | 248 | |
| 175 | 249 | function registerTemplateLocation($sName, $sPath) { |
| 176 | 250 | $sPath = $this->_fixFilename($sPath); |
| 177 | 251 | $this->_aTemplateLocations[$sName] = array($sName, $sPath); |
| 252 | + | |
| 253 | + // Register helper in DB | |
| 254 | + $params = $sName.'|'.$sPath; | |
| 255 | + $this->registerPluginHelper($sName, $sName, $sPath, $params, 'general', 'template_location'); | |
| 178 | 256 | } |
| 179 | 257 | |
| 180 | 258 | |
| 259 | + /** | |
| 260 | + * Register a new widget | |
| 261 | + * | |
| 262 | + * @param unknown_type $sClassname | |
| 263 | + * @param unknown_type $sNamespace | |
| 264 | + * @param unknown_type $sPath | |
| 265 | + */ | |
| 181 | 266 | function registerWidget($sClassname, $sNamespace, $sPath) { |
| 182 | 267 | $sPath = $this->_fixFilename($sPath); |
| 183 | 268 | $this->_aWidgets[$sNamespace] = array($sClassname, $sNamespace, $sPath); |
| 269 | + | |
| 270 | + // Register helper in DB | |
| 271 | + $params = $sClassname.'|'.$sNamespace.'|'.$sPath; | |
| 272 | + $this->registerPluginHelper($sNamespace, $sClassname, $sPath, $params, 'general', 'widget'); | |
| 184 | 273 | } |
| 185 | 274 | |
| 186 | 275 | function registerValidator($sClassname, $sNamespace, $sPath) { |
| 187 | 276 | $sPath = $this->_fixFilename($sPath); |
| 188 | 277 | $this->_aValidators[$sNamespace] = array($sClassname, $sNamespace, $sPath); |
| 278 | + | |
| 279 | + // Register helper in DB | |
| 280 | + $params = $sClassname.'|'.$sNamespace.'|'.$sPath; | |
| 281 | + $this->registerPluginHelper($sNamespace, $sClassname, $sPath, $params, 'general', 'validator'); | |
| 189 | 282 | } |
| 190 | 283 | |
| 191 | 284 | |
| 192 | 285 | function registerCriterion($sClassName, $sNamespace, $sFilename = null, $aInitialize = null) { |
| 193 | 286 | $sFilename = $this->_fixFilename($sFilename); |
| 194 | 287 | $this->_aCriteria[$sNamespace] = array($sClassName, $sNamespace, $sFilename, $aInitialize); |
| 288 | + | |
| 289 | + // Register helper in DB | |
| 290 | + if(is_array($aInitialize)){ | |
| 291 | + $sInitialize = implode('_|', $aInitialize); | |
| 292 | + } | |
| 293 | + | |
| 294 | + $params = $sClassName.'|'.$sNamespace.'|'.$sFilename.'|'.$sInitialize; | |
| 295 | + $this->registerPluginHelper($sNamespace, $sClassName, $sFilename, $params, 'general', 'criterion'); | |
| 195 | 296 | } |
| 196 | 297 | |
| 197 | 298 | function registerInterceptor($sClassname, $sNamespace, $sPath = null) { |
| 198 | 299 | $sPath = $this->_fixFilename($sPath); |
| 199 | 300 | $this->_aInterceptors[$sNamespace] = array($sClassname, $sNamespace, $sPath); |
| 301 | + | |
| 302 | + // Register helper in DB | |
| 303 | + $params = $sClassname.'|'.$sNamespace.'|'.$sPath; | |
| 304 | + $this->registerPluginHelper($sNamespace, $sClassname, $sPath, $params, 'general', 'interceptor'); | |
| 305 | + } | |
| 306 | + | |
| 307 | + /* ** Refactor into another class ** */ | |
| 308 | + /** | |
| 309 | + * Register the plugin in the DB | |
| 310 | + * | |
| 311 | + * @param unknown_type $sClassName | |
| 312 | + * @param unknown_type $path | |
| 313 | + * @param unknown_type $object | |
| 314 | + * @param unknown_type $type | |
| 315 | + */ | |
| 316 | + function registerPluginHelper($sNamespace, $sClassName, $path, $object, $view, $type) { | |
| 317 | + | |
| 318 | + $sql = "SELECT * FROM plugin_helper WHERE namespace = '{$sNamespace}' AND classtype = '{$type}'"; | |
| 319 | + $res = DBUtil::getOneResult($sql); | |
| 320 | + | |
| 321 | + $aValues = array(); | |
| 322 | + $aValues['namespace'] = $sNamespace; | |
| 323 | + $aValues['plugin'] = (!empty($this->sNamespace)) ? $this->sNamespace : $sNamespace; | |
| 324 | + $aValues['classname'] = $sClassName; | |
| 325 | + $aValues['pathname'] = $path; | |
| 326 | + $aValues['object'] = $object; | |
| 327 | + $aValues['viewtype'] = $view; | |
| 328 | + $aValues['classtype'] = $type; | |
| 329 | + | |
| 330 | + // if record exists - update it. | |
| 331 | + if(!empty($res)){ | |
| 332 | + $id = $res['id']; | |
| 333 | + $updateRes = DBUtil::autoUpdate('plugin_helper', $aValues, $id); | |
| 334 | + if(PEAR::isError($updateRes)){ | |
| 335 | + return $updateRes; | |
| 336 | + } | |
| 337 | + return true; | |
| 338 | + } | |
| 339 | + | |
| 340 | + // Insert into DB | |
| 341 | + $res = DBUtil::autoInsert('plugin_helper', $aValues); | |
| 342 | + if(PEAR::isError($res)){ | |
| 343 | + return $res; | |
| 344 | + } | |
| 345 | + return true; | |
| 200 | 346 | } |
| 201 | 347 | |
| 202 | 348 | function _fixFilename($sFilename) { |
| ... | ... | @@ -240,7 +386,120 @@ class KTPlugin { |
| 240 | 386 | return true; |
| 241 | 387 | } |
| 242 | 388 | |
| 389 | + /** | |
| 390 | + * Load the actions, portlets, etc as part of the parent plugin | |
| 391 | + * | |
| 392 | + */ | |
| 243 | 393 | function load() { |
| 394 | + // Get actions, portlets, etc, create arrays as part of plugin | |
| 395 | + $query = "SELECT * FROM plugin_helper h WHERE plugin = '{$this->sNamespace}'"; | |
| 396 | + $aPluginHelpers = DBUtil::getResultArray($query); | |
| 397 | + | |
| 398 | + if(!empty($aPluginHelpers)){ | |
| 399 | + foreach ($aPluginHelpers as $plugin) { | |
| 400 | + $sName = $plugin['namespace']; | |
| 401 | + $sParams = $plugin['object']; | |
| 402 | + $aParams = explode('|', $sParams); | |
| 403 | + $sClassType = $plugin['classtype']; | |
| 404 | + | |
| 405 | + switch ($sClassType) { | |
| 406 | + case 'portlet': | |
| 407 | + $aLocation = explode('_|', $aParams[0]); | |
| 408 | + $aParams[0] = $aLocation; | |
| 409 | + $this->_aPortlets[$sName] = $aParams; | |
| 410 | + break; | |
| 411 | + | |
| 412 | + case 'trigger': | |
| 413 | + $this->_aTriggers[$sName] = $aParams; | |
| 414 | + break; | |
| 415 | + | |
| 416 | + case 'action': | |
| 417 | + $this->_aActions[$sName] = $aParams; | |
| 418 | + break; | |
| 419 | + | |
| 420 | + case 'page': | |
| 421 | + $this->_aPages[$sName] = $aParams; | |
| 422 | + break; | |
| 423 | + | |
| 424 | + case 'authentication_provider': | |
| 425 | + $this->_aAuthenticationProviders[$sName] = $aParams; | |
| 426 | + break; | |
| 427 | + | |
| 428 | + case 'admin_category': | |
| 429 | + $this->_aAdminCategories[$sName] = $aParams; | |
| 430 | + break; | |
| 431 | + | |
| 432 | + case 'admin_page': | |
| 433 | + $this->_aAdminPages[$sName] = $aParams; | |
| 434 | + break; | |
| 435 | + | |
| 436 | + case 'dashlet': | |
| 437 | + $this->_aDashlets[$sName] = $aParams; | |
| 438 | + break; | |
| 439 | + | |
| 440 | + case 'i18n': | |
| 441 | + $this->_ai18n[$sName] = $aParams; | |
| 442 | + break; | |
| 443 | + | |
| 444 | + case 'i18nlang': | |
| 445 | + $this->_ai18nLang[$sName] = $aParams; | |
| 446 | + break; | |
| 447 | + | |
| 448 | + case 'language': | |
| 449 | + $this->_aLanguage[$sName] = $aParams; | |
| 450 | + break; | |
| 451 | + | |
| 452 | + case 'help_language': | |
| 453 | + $this->_aHelpLanguage[$sName] = $aParams; | |
| 454 | + break; | |
| 455 | + | |
| 456 | + case 'workflow_trigger': | |
| 457 | + $this->_aWFTriggers[$sName] = $aParams; | |
| 458 | + break; | |
| 459 | + | |
| 460 | + case 'column': | |
| 461 | + $this->_aColumns[$sName] = $aParams; | |
| 462 | + break; | |
| 463 | + | |
| 464 | + case 'view': | |
| 465 | + $this->_aViews[$sName] = $aParams; | |
| 466 | + break; | |
| 467 | + | |
| 468 | + case 'notification_handler': | |
| 469 | + $this->_aNotificationHandlers[$sName] = $aParams; | |
| 470 | + break; | |
| 471 | + | |
| 472 | + case 'template_location': | |
| 473 | + $this->_aTemplateLocations[$sName] = $aParams; | |
| 474 | + break; | |
| 475 | + | |
| 476 | + case 'criterion': | |
| 477 | + $aInit = explode('_|', $aParams[3]); | |
| 478 | + $aParams[3] = $aInit; | |
| 479 | + $this->_aCriteria[$sName] = $aParams; | |
| 480 | + break; | |
| 481 | + | |
| 482 | + case 'widget': | |
| 483 | + $this->_aWidgets[$sName] = $aParams; | |
| 484 | + break; | |
| 485 | + | |
| 486 | + case 'validator': | |
| 487 | + $this->_aValidators[$sName] = $aParams; | |
| 488 | + break; | |
| 489 | + | |
| 490 | + case 'interceptor': | |
| 491 | + $this->_aInterceptors[$sName] = $aParams; | |
| 492 | + break; | |
| 493 | + } | |
| 494 | + } | |
| 495 | + } | |
| 496 | + } | |
| 497 | + | |
| 498 | + /** | |
| 499 | + * Original load function for the plugins | |
| 500 | + * @deprecated | |
| 501 | + */ | |
| 502 | + function load2() { | |
| 244 | 503 | if (!$this->isRegistered()) { |
| 245 | 504 | return; |
| 246 | 505 | } |
| ... | ... | @@ -411,6 +670,7 @@ class KTPlugin { |
| 411 | 670 | // remember to -start- the upgrade from the "next" version |
| 412 | 671 | $iEndVersion = $this->upgradePlugin($oEntity->getVersion()+1, $this->iVersion); |
| 413 | 672 | } |
| 673 | + | |
| 414 | 674 | if ($iEndVersion != $this->iVersion) { |
| 415 | 675 | // we obviously failed. |
| 416 | 676 | $oEntity->updateFromArray(array( |
| ... | ... | @@ -421,7 +681,7 @@ class KTPlugin { |
| 421 | 681 | 'friendlyname' => $friendly_name, |
| 422 | 682 | )); |
| 423 | 683 | // FIXME we -really- need to raise an error here, somehow. |
| 424 | - return $oEntity; | |
| 684 | + | |
| 425 | 685 | } else { |
| 426 | 686 | $oEntity->updateFromArray(array( |
| 427 | 687 | 'path' => $this->stripKtDir($this->sFilename), |
| ... | ... | @@ -429,8 +689,11 @@ class KTPlugin { |
| 429 | 689 | 'unavailable' => false, |
| 430 | 690 | 'friendlyname' => $friendly_name, |
| 431 | 691 | )); |
| 432 | - return $oEntity; | |
| 692 | + | |
| 433 | 693 | } |
| 694 | + /* ** Quick fix for optimisation. Reread must run plugin setup. ** */ | |
| 695 | + $this->setup(); | |
| 696 | + return $oEntity; | |
| 434 | 697 | } |
| 435 | 698 | $disabled = 1; |
| 436 | 699 | if ($this->bAlwaysInclude || $this->autoRegister) { $disabled = 0; } |
| ... | ... | @@ -446,6 +709,9 @@ class KTPlugin { |
| 446 | 709 | if (PEAR::isError($oEntity)) { |
| 447 | 710 | return $oEntity; |
| 448 | 711 | } |
| 712 | + | |
| 713 | + /* ** Quick fix for optimisation. Reread must run plugin setup. ** */ | |
| 714 | + $this->setup(); | |
| 449 | 715 | return true; |
| 450 | 716 | } |
| 451 | 717 | ... | ... |
lib/plugins/pluginregistry.inc.php
| ... | ... | @@ -5,32 +5,32 @@ |
| 5 | 5 | * KnowledgeTree Open Source Edition |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | |
| 8 | + * | |
| 9 | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | 11 | * Free Software Foundation. |
| 12 | - * | |
| 12 | + * | |
| 13 | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | 16 | * details. |
| 17 | - * | |
| 17 | + * | |
| 18 | 18 | * You should have received a copy of the GNU General Public License |
| 19 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | - * copyright notice. | |
| 32 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | + * copyright notice. | |
| 34 | 34 | * Contributor( s): ______________________________________ |
| 35 | 35 | * |
| 36 | 36 | */ |
| ... | ... | @@ -46,8 +46,18 @@ class KTPluginRegistry { |
| 46 | 46 | return $GLOBALS['_KT_PLUGIN']['oKTPluginRegistry']; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | + /** | |
| 50 | + * Register the plugin in the database | |
| 51 | + * | |
| 52 | + * @param unknown_type $sClassName | |
| 53 | + * @param unknown_type $sNamespace | |
| 54 | + * @param unknown_type $sFilename | |
| 55 | + */ | |
| 49 | 56 | function registerPlugin($sClassName, $sNamespace, $sFilename = null) { |
| 50 | 57 | $this->_aPluginDetails[$sNamespace] = array($sClassName, $sNamespace, $sFilename); |
| 58 | + | |
| 59 | + $object = $sClassName.'|'.$sNamespace.'|'.$sFilename; | |
| 60 | + KTPlugin::registerPluginHelper($sNamespace, $sClassName, $sFilename, $object, 'general', 'plugin'); | |
| 51 | 61 | } |
| 52 | 62 | |
| 53 | 63 | function &getPlugin($sNamespace) { |
| ... | ... | @@ -56,14 +66,21 @@ class KTPluginRegistry { |
| 56 | 66 | } |
| 57 | 67 | $aDetails = KTUtil::arrayGet($this->_aPluginDetails, $sNamespace); |
| 58 | 68 | if (empty($aDetails)) { |
| 59 | - return null; | |
| 69 | + // plugin hasn't been registered - check the DB | |
| 70 | +// $query = "SELECT * FROM plugin_helper WHERE namespace = '{$sNamespace}'"; | |
| 71 | +// $plugin = DBUtil::getOneResult($query); | |
| 72 | +// if(empty($plugin)){ | |
| 73 | + return null; | |
| 74 | +// } | |
| 75 | +// $aDetails = explode('|', $plugin['object']); | |
| 60 | 76 | } |
| 61 | 77 | $sFilename = $aDetails[2]; |
| 62 | 78 | if (!empty($sFilename)) { |
| 63 | 79 | require_once($sFilename); |
| 64 | 80 | } |
| 65 | 81 | $sClassName = $aDetails[0]; |
| 66 | - $oPlugin =new $sClassName($sFilename); | |
| 82 | + $oPlugin = new $sClassName($sFilename); | |
| 83 | + | |
| 67 | 84 | $this->_aPlugins[$sNamespace] =& $oPlugin; |
| 68 | 85 | return $oPlugin; |
| 69 | 86 | } | ... | ... |
lib/plugins/pluginutil.inc.php
| ... | ... | @@ -5,32 +5,32 @@ |
| 5 | 5 | * KnowledgeTree Open Source Edition |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | |
| 8 | + * | |
| 9 | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | 11 | * Free Software Foundation. |
| 12 | - * | |
| 12 | + * | |
| 13 | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | 16 | * details. |
| 17 | - * | |
| 17 | + * | |
| 18 | 18 | * You should have received a copy of the GNU General Public License |
| 19 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | - * copyright notice. | |
| 32 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | + * copyright notice. | |
| 34 | 34 | * Contributor( s): ______________________________________ |
| 35 | 35 | * |
| 36 | 36 | */ |
| ... | ... | @@ -69,7 +69,7 @@ class KTPluginUtil { |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * Store the plugin cache in the cache directory. |
| 72 | - * | |
| 72 | + * @deprecated | |
| 73 | 73 | */ |
| 74 | 74 | static function savePluginCache($array) |
| 75 | 75 | { |
| ... | ... | @@ -97,7 +97,7 @@ class KTPluginUtil { |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * Remove the plugin cache. |
| 100 | - * | |
| 100 | + * @deprecated | |
| 101 | 101 | */ |
| 102 | 102 | static function removePluginCache() |
| 103 | 103 | { |
| ... | ... | @@ -115,7 +115,7 @@ class KTPluginUtil { |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * Reads the plugin cache file. This must still be unserialised. |
| 118 | - * | |
| 118 | + * @deprecated | |
| 119 | 119 | * @return mixed Returns false on failure, or the serialised cache. |
| 120 | 120 | */ |
| 121 | 121 | static function readPluginCache() |
| ... | ... | @@ -148,58 +148,213 @@ class KTPluginUtil { |
| 148 | 148 | return unserialize($cache); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - static function loadPlugins () { | |
| 151 | + /** | |
| 152 | + * Load the plugins for the current page | |
| 153 | + * | |
| 154 | + * @param unknown_type $sType | |
| 155 | + */ | |
| 156 | + static function loadPlugins ($sType) { | |
| 152 | 157 | |
| 153 | - $GLOBALS['_KT_PLUGIN'] = array(); | |
| 154 | - $cache = KTPluginUtil::readPluginCache(); | |
| 155 | - if ($cache === false) | |
| 156 | - { | |
| 157 | - $aPlugins = KTPluginEntity::getList("disabled=0"); | |
| 158 | - KTPluginUtil::savePluginCache($aPlugins); | |
| 159 | - } | |
| 160 | - else | |
| 161 | - { | |
| 162 | - $aPlugins = $cache; | |
| 158 | + // Check the current page - can be extended. | |
| 159 | + // Currently we only distinguish between the dashboard and everything else. | |
| 160 | + if($sType != 'dashboard'){ | |
| 161 | + $sType = 'general'; | |
| 163 | 162 | } |
| 163 | + $GLOBALS['_KT_PLUGIN'] = array(); | |
| 164 | + | |
| 165 | + $aPlugins = array(); | |
| 166 | + $aPluginHelpers = array(); | |
| 164 | 167 | |
| 165 | - if (count($aPlugins) === 0) { | |
| 168 | + // Get the list of enabled plugins | |
| 169 | + $query = "SELECT * FROM plugin_helper h, plugins p | |
| 170 | + WHERE p.namespace = h.plugin AND p.disabled = 0 AND h.classtype='plugin'"; | |
| 171 | + $aPluginHelpers = DBUtil::getResultArray($query); | |
| 172 | + | |
| 173 | + // Check that there are plugins and if not, register them | |
| 174 | + if (empty($aPluginHelpers)) { | |
| 166 | 175 | KTPluginUtil::registerPlugins(); |
| 176 | + | |
| 177 | + $query = "SELECT * FROM plugin_helper h, plugins p | |
| 178 | + WHERE p.namespace = h.plugin AND p.disabled = 0 AND h.viewtype='{$sType}' AND h.classtype='plugin'"; | |
| 179 | + $aPluginHelpers = DBUtil::getResultArray($query); | |
| 167 | 180 | } |
| 168 | - $aPaths = array(); | |
| 169 | - $aPaths[] = KT_DIR . '/plugins/ktcore/KTCorePlugin.php'; | |
| 170 | - $aPaths[] = KT_DIR . '/plugins/ktcore/KTCoreLanguagePlugin.php'; | |
| 171 | - foreach ($aPlugins as $oPlugin) { | |
| 172 | - if (!is_a($oPlugin, 'KTPluginEntity')) { | |
| 173 | - print "<pre>"; | |
| 174 | - print "loadPlugins()\n"; | |
| 175 | - var_dump($aPlugins); | |
| 176 | - exit(0); | |
| 177 | - } | |
| 178 | - $sPath = $oPlugin->getPath(); | |
| 179 | - if (!KTUtil::isAbsolutePath($sPath)) { | |
| 180 | - $sPath = sprintf("%s/%s", KT_DIR, $sPath); | |
| 181 | - } | |
| 182 | - $aPaths[] = $sPath; | |
| 183 | - } | |
| 184 | - $aPaths = array_unique($aPaths); | |
| 185 | - foreach ($aPaths as $sPath) { | |
| 186 | - if (file_exists($sPath)) { | |
| 187 | - require_once($sPath); | |
| 181 | + | |
| 182 | + // Create plugin objects | |
| 183 | + foreach ($aPluginHelpers as $aItem){ | |
| 184 | + $classname = $aItem['classname']; | |
| 185 | + $path = $aItem['pathname']; | |
| 186 | + | |
| 187 | + if (!empty($path)) { | |
| 188 | + require_once($path); | |
| 188 | 189 | } |
| 190 | + | |
| 191 | + $oPlugin = new $classname($path); | |
| 192 | + $aPlugins[] = $oPlugin; | |
| 193 | + $oPlugin->load(); | |
| 189 | 194 | } |
| 190 | - $oRegistry =& KTPluginRegistry::getSingleton(); | |
| 191 | - $aPlugins =& $oRegistry->getPlugins(); | |
| 192 | - foreach ($aPlugins as $oPlugin) { | |
| 193 | - if (!isset($aOrder[$oPlugin->iOrder])) { | |
| 194 | - $aOrder[$oPlugin->iOrder] = array(); | |
| 195 | + | |
| 196 | + // load plugin helpers into global space | |
| 197 | + $query = "SELECT h.* FROM plugin_helper h, plugins p | |
| 198 | + WHERE p.namespace = h.plugin AND p.disabled = 0 ";//WHERE viewtype='{$sType}'"; | |
| 199 | + $aPluginList = DBUtil::getResultArray($query); | |
| 200 | + KTPluginUtil::load($aPluginList); | |
| 201 | + | |
| 202 | + // Load the template locations | |
| 203 | + $query = "SELECT * FROM plugin_helper h WHERE h.classtype='locations'"; | |
| 204 | + $aLocations = DBUtil::getResultArray($query); | |
| 205 | + if(!empty($aLocations)){ | |
| 206 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 207 | + foreach ($aLocations as $location){ | |
| 208 | + $aParams = explode('|', $location['object']); | |
| 209 | + call_user_func_array(array(&$oTemplating, 'addLocation2'), $aParams); | |
| 195 | 210 | } |
| 196 | - $aOrder[$oPlugin->iOrder][] = $oPlugin; | |
| 197 | 211 | } |
| 198 | - ksort($aOrder, SORT_NUMERIC); | |
| 199 | - foreach ($aOrder as $iOrder => $aOrderPlugins) { | |
| 200 | - foreach ($aOrderPlugins as $oPlugin) { | |
| 201 | - $oPlugin->load(); | |
| 202 | - } | |
| 212 | + return; | |
| 213 | + } | |
| 214 | + | |
| 215 | + /** | |
| 216 | + * Load the plugins into the global space | |
| 217 | + * | |
| 218 | + * @param array $aPlugins | |
| 219 | + */ | |
| 220 | + function load($aPlugins) { | |
| 221 | + | |
| 222 | + require_once(KT_LIB_DIR . '/actions/actionregistry.inc.php'); | |
| 223 | + require_once(KT_LIB_DIR . '/actions/portletregistry.inc.php'); | |
| 224 | + require_once(KT_LIB_DIR . '/triggers/triggerregistry.inc.php'); | |
| 225 | + require_once(KT_LIB_DIR . '/plugins/pageregistry.inc.php'); | |
| 226 | + require_once(KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php'); | |
| 227 | + require_once(KT_LIB_DIR . "/plugins/KTAdminNavigation.php"); | |
| 228 | + require_once(KT_LIB_DIR . "/dashboard/dashletregistry.inc.php"); | |
| 229 | + require_once(KT_LIB_DIR . "/i18n/i18nregistry.inc.php"); | |
| 230 | + require_once(KT_LIB_DIR . "/help/help.inc.php"); | |
| 231 | + require_once(KT_LIB_DIR . "/workflow/workflowutil.inc.php"); | |
| 232 | + require_once(KT_LIB_DIR . "/widgets/widgetfactory.inc.php"); | |
| 233 | + require_once(KT_LIB_DIR . "/validation/validatorfactory.inc.php"); | |
| 234 | + require_once(KT_LIB_DIR . "/browse/columnregistry.inc.php"); | |
| 235 | + require_once(KT_LIB_DIR . "/browse/criteriaregistry.php"); | |
| 236 | + require_once(KT_LIB_DIR . "/authentication/interceptorregistry.inc.php"); | |
| 237 | + | |
| 238 | + $oPRegistry =& KTPortletRegistry::getSingleton(); | |
| 239 | + $oTRegistry =& KTTriggerRegistry::getSingleton(); | |
| 240 | + $oARegistry =& KTActionRegistry::getSingleton(); | |
| 241 | + $oPageRegistry =& KTPageRegistry::getSingleton(); | |
| 242 | + $oAPRegistry =& KTAuthenticationProviderRegistry::getSingleton(); | |
| 243 | + $oAdminRegistry =& KTAdminNavigationRegistry::getSingleton(); | |
| 244 | + $oDashletRegistry =& KTDashletRegistry::getSingleton(); | |
| 245 | + $oi18nRegistry =& KTi18nRegistry::getSingleton(); | |
| 246 | + $oKTHelpRegistry =& KTHelpRegistry::getSingleton(); | |
| 247 | + $oWFTriggerRegistry =& KTWorkflowTriggerRegistry::getSingleton(); | |
| 248 | + $oColumnRegistry =& KTColumnRegistry::getSingleton(); | |
| 249 | + $oNotificationHandlerRegistry =& KTNotificationRegistry::getSingleton(); | |
| 250 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 251 | + $oWidgetFactory =& KTWidgetFactory::getSingleton(); | |
| 252 | + $oValidatorFactory =& KTValidatorFactory::getSingleton(); | |
| 253 | + $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton(); | |
| 254 | + $oInterceptorRegistry =& KTInterceptorRegistry::getSingleton(); | |
| 255 | + $oKTPluginRegistry =& KTPluginRegistry::getSingleton(); | |
| 256 | + | |
| 257 | + | |
| 258 | + // Loop through the loaded plugins and register them for access | |
| 259 | + foreach ($aPlugins as $plugin){ | |
| 260 | + $sName = $plugin['namespace']; | |
| 261 | + $sParams = $plugin['object']; | |
| 262 | + $aParams = explode('|', $sParams); | |
| 263 | + $sClassType = $plugin['classtype']; | |
| 264 | + | |
| 265 | + switch ($sClassType) { | |
| 266 | + case 'portlet': | |
| 267 | + $aLocation = explode('_|', $aParams[0]); | |
| 268 | + $aParams[0] = $aLocation; | |
| 269 | + call_user_func_array(array(&$oPRegistry, 'registerPortlet'), $aParams); | |
| 270 | + break; | |
| 271 | + | |
| 272 | + case 'trigger': | |
| 273 | + call_user_func_array(array(&$oTRegistry, 'registerTrigger'), $aParams); | |
| 274 | + break; | |
| 275 | + | |
| 276 | + case 'action': | |
| 277 | + call_user_func_array(array(&$oARegistry, 'registerAction'), $aParams); | |
| 278 | + break; | |
| 279 | + | |
| 280 | + case 'page': | |
| 281 | + call_user_func_array(array(&$oPageRegistry, 'registerPage'), $aParams); | |
| 282 | + break; | |
| 283 | + | |
| 284 | + case 'authentication_provider': | |
| 285 | + call_user_func_array(array(&$oAPRegistry, 'registerAuthenticationProvider'), $aParams); | |
| 286 | + break; | |
| 287 | + | |
| 288 | + case 'admin_category': | |
| 289 | + call_user_func_array(array(&$oAdminRegistry, 'registerCategory'), $aParams); | |
| 290 | + break; | |
| 291 | + | |
| 292 | + case 'admin_page': | |
| 293 | + call_user_func_array(array(&$oAdminRegistry, 'registerLocation'), $aParams); | |
| 294 | + break; | |
| 295 | + | |
| 296 | + case 'dashlet': | |
| 297 | + call_user_func_array(array(&$oDashletRegistry, 'registerDashlet'), $aParams); | |
| 298 | + break; | |
| 299 | + | |
| 300 | + case 'i18n': | |
| 301 | + call_user_func_array(array(&$oi18nRegistry, 'registeri18n'), $aParams); | |
| 302 | + break; | |
| 303 | + | |
| 304 | + case 'i18nlang': | |
| 305 | + call_user_func_array(array(&$oi18nRegistry, 'registeri18nLang'), $aParams); | |
| 306 | + break; | |
| 307 | + | |
| 308 | + case 'language': | |
| 309 | + call_user_func_array(array(&$oi18nRegistry, 'registerLanguage'), $aParams); | |
| 310 | + break; | |
| 311 | + | |
| 312 | + case 'help_language': | |
| 313 | + call_user_func_array(array(&$oKTHelpRegistry, 'registerHelp'), $aParams); | |
| 314 | + break; | |
| 315 | + | |
| 316 | + case 'workflow_trigger': | |
| 317 | + call_user_func_array(array(&$oWFTriggerRegistry, 'registerWorkflowTrigger'), $aParams); | |
| 318 | + break; | |
| 319 | + | |
| 320 | + case 'column': | |
| 321 | + call_user_func_array(array(&$oColumnRegistry, 'registerColumn'), $aParams); | |
| 322 | + break; | |
| 323 | + | |
| 324 | + case 'view': | |
| 325 | + call_user_func_array(array(&$oColumnRegistry, 'registerView'), $aParams); | |
| 326 | + break; | |
| 327 | + | |
| 328 | + case 'notification_handler': | |
| 329 | + call_user_func_array(array(&$oNotificationHandlerRegistry, 'registerNotificationHandler'), $aParams); | |
| 330 | + break; | |
| 331 | + | |
| 332 | + case 'template_location': | |
| 333 | + call_user_func_array(array(&$oTemplating, 'addLocation'), $aParams); | |
| 334 | + break; | |
| 335 | + | |
| 336 | + case 'criterion': | |
| 337 | + $aInit = explode('_|', $aParams[3]); | |
| 338 | + $aParams[3] = $aInit; | |
| 339 | + call_user_func_array(array(&$oCriteriaRegistry, 'registerCriterion'), $aParams); | |
| 340 | + break; | |
| 341 | + | |
| 342 | + case 'widget': | |
| 343 | + call_user_func_array(array(&$oWidgetFactory, 'registerWidget'), $aParams); | |
| 344 | + break; | |
| 345 | + | |
| 346 | + case 'validator': | |
| 347 | + call_user_func_array(array(&$oValidatorFactory, 'registerValidator'), $aParams); | |
| 348 | + break; | |
| 349 | + | |
| 350 | + case 'interceptor': | |
| 351 | + call_user_func_array(array(&$oInterceptorRegistry, 'registerInterceptor'), $aParams); | |
| 352 | + break; | |
| 353 | + | |
| 354 | + case 'plugin': | |
| 355 | + $oKTPluginRegistry->_aPluginDetails[$sName] = $aParams; | |
| 356 | + break; | |
| 357 | + } | |
| 203 | 358 | } |
| 204 | 359 | } |
| 205 | 360 | ... | ... |
lib/templating/kt3template.inc.php
| ... | ... | @@ -5,32 +5,32 @@ |
| 5 | 5 | * KnowledgeTree Open Source Edition |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | |
| 8 | + * | |
| 9 | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | 11 | * Free Software Foundation. |
| 12 | - * | |
| 12 | + * | |
| 13 | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | 16 | * details. |
| 17 | - * | |
| 17 | + * | |
| 18 | 18 | * You should have received a copy of the GNU General Public License |
| 19 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | - * copyright notice. | |
| 32 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | + * copyright notice. | |
| 34 | 34 | * Contributor( s): ______________________________________ |
| 35 | 35 | * |
| 36 | 36 | * |
| ... | ... | @@ -156,11 +156,17 @@ class KTPage { |
| 156 | 156 | |
| 157 | 157 | // initiliase the menu. |
| 158 | 158 | function initMenu() { |
| 159 | - // FIXME: we lost the getDefaultAction stuff - do we care? | |
| 160 | - // note that key == action. this is _important_, since we crossmatch the breadcrumbs against this for "active" | |
| 161 | - $this->menu = array("dashboard" => $this->_actionHelper(array("name" => _kt("Dashboard"), "action" => "dashboard", "active" => 0)), | |
| 162 | - "browse" => $this->_actionHelper(array("name" => _kt("Browse Documents"), "action" => "browse", "active" => 0)), | |
| 163 | - "administration" => $this->_actionHelper(array("name" => _kt("DMS Administration"), "action" => "administration", "active" => 0)),); | |
| 159 | + // FIXME: we lost the getDefaultAction stuff - do we care? | |
| 160 | + // note that key == action. this is _important_, since we crossmatch the breadcrumbs against this for "active" | |
| 161 | + $this->menu = array(); | |
| 162 | + $this->menu['dashboard'] = array('label' => _kt("Dashboard"), 'url' => 'dashboard.php'); | |
| 163 | + $this->menu['browse'] = array('label' => _kt("Browse Documents"), 'url' => 'browse.php'); | |
| 164 | + $this->menu['administration'] = array('label' => _kt("DMS Administration"), 'url' => 'admin.php'); | |
| 165 | + /* | |
| 166 | + $this->menu = array("dashboard" => $this->_actionHelper(array("name" => _kt("Dashboard"), "action" => "dashboard", "active" => 0)), | |
| 167 | + "browse" => $this->_actionHelper(array("name" => _kt("Browse Documents"), "action" => "browse", "active" => 0)), | |
| 168 | + "administration" => $this->_actionHelper(array("name" => _kt("DMS Administration"), "action" => "administration", "active" => 0)),); | |
| 169 | + */ | |
| 164 | 170 | } |
| 165 | 171 | |
| 166 | 172 | ... | ... |
lib/templating/templating.inc.php
| ... | ... | @@ -7,32 +7,32 @@ |
| 7 | 7 | * KnowledgeTree Open Source Edition |
| 8 | 8 | * Document Management Made Simple |
| 9 | 9 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 10 | - * | |
| 10 | + * | |
| 11 | 11 | * This program is free software; you can redistribute it and/or modify it under |
| 12 | 12 | * the terms of the GNU General Public License version 3 as published by the |
| 13 | 13 | * Free Software Foundation. |
| 14 | - * | |
| 14 | + * | |
| 15 | 15 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 | 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 17 | 17 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 18 | 18 | * details. |
| 19 | - * | |
| 19 | + * | |
| 20 | 20 | * You should have received a copy of the GNU General Public License |
| 21 | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | - * | |
| 22 | + * | |
| 23 | 23 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 24 | 24 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 25 | - * | |
| 25 | + * | |
| 26 | 26 | * The interactive user interfaces in modified source and object code versions |
| 27 | 27 | * of this program must display Appropriate Legal Notices, as required under |
| 28 | 28 | * Section 5 of the GNU General Public License version 3. |
| 29 | - * | |
| 29 | + * | |
| 30 | 30 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 31 | 31 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 32 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 33 | 33 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 34 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | - * copyright notice. | |
| 34 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | + * copyright notice. | |
| 36 | 36 | * Contributor( s): ______________________________________ |
| 37 | 37 | */ |
| 38 | 38 | |
| ... | ... | @@ -121,11 +121,28 @@ class KTTemplating { |
| 121 | 121 | // }}} |
| 122 | 122 | |
| 123 | 123 | // {{{ addLocation |
| 124 | + /** | |
| 125 | + * Register a new location in the database | |
| 126 | + * | |
| 127 | + * @param unknown_type $descr | |
| 128 | + * @param unknown_type $loc | |
| 129 | + */ | |
| 124 | 130 | function addLocation ($descr, $loc) { |
| 125 | 131 | $this->aLocationRegistry[$descr] = $loc; |
| 132 | + KTPlugin::registerPluginHelper($descr, $descr, $loc, $descr.'|'.$loc, 'general', 'locations'); | |
| 126 | 133 | } |
| 127 | 134 | // }}} |
| 128 | 135 | |
| 136 | + /** | |
| 137 | + * Add the template location to the location registry | |
| 138 | + * | |
| 139 | + * @param unknown_type $descr | |
| 140 | + * @param unknown_type $loc | |
| 141 | + */ | |
| 142 | + function addLocation2 ($descr, $loc) { | |
| 143 | + $this->aLocationRegistry[$descr] = $loc; | |
| 144 | + } | |
| 145 | + | |
| 129 | 146 | // {{{ getSingleton |
| 130 | 147 | static function &getSingleton () { |
| 131 | 148 | if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTTemplating')) { | ... | ... |
sql/mysql/install/structure.sql
| ... | ... | @@ -1238,6 +1238,27 @@ CREATE TABLE `plugins` ( |
| 1238 | 1238 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
| 1239 | 1239 | |
| 1240 | 1240 | -- |
| 1241 | +-- Table structure for table `plugin_helper` | |
| 1242 | +-- | |
| 1243 | + | |
| 1244 | +CREATE TABLE `plugin_helper` ( | |
| 1245 | + `id` INT NOT NULL default '0', | |
| 1246 | + `namespace` VARCHAR(120) NOT NULL, | |
| 1247 | + `plugin` VARCHAR(120) NOT NULL, | |
| 1248 | + `classname` VARCHAR(120), | |
| 1249 | + `pathname` VARCHAR(255), | |
| 1250 | + `object` VARCHAR(1000) NOT NULL, | |
| 1251 | + `classtype` VARCHAR(120) NOT NULL, | |
| 1252 | + `viewtype` ENUM('general', 'dashboard', 'plugin', 'folder', 'document', 'admindispatcher', 'dispatcher') NOT NULL default 'general', | |
| 1253 | + PRIMARY KEY (`id`), | |
| 1254 | + KEY `name` (`namespace`), | |
| 1255 | + KEY `parent` (`plugin`), | |
| 1256 | + KEY `view` (`viewtype`) | |
| 1257 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
| 1258 | + | |
| 1259 | +-- -------------------------------------------------------- | |
| 1260 | + | |
| 1261 | +-- | |
| 1241 | 1262 | -- Table structure for table `role_allocations` |
| 1242 | 1263 | -- |
| 1243 | 1264 | |
| ... | ... | @@ -2263,6 +2284,17 @@ CREATE TABLE `zseq_plugins` ( |
| 2263 | 2284 | ) ENGINE=MyISAM AUTO_INCREMENT=82 DEFAULT CHARSET=latin1; |
| 2264 | 2285 | |
| 2265 | 2286 | -- |
| 2287 | +-- Table structure for table `zseq_plugin_helper` | |
| 2288 | +-- | |
| 2289 | + | |
| 2290 | +CREATE TABLE `zseq_plugin_helper` ( | |
| 2291 | + `id` int(10) unsigned NOT NULL auto_increment, | |
| 2292 | + PRIMARY KEY (`id`) | |
| 2293 | +) ENGINE=MyISAM DEFAULT CHARSET=latin1; | |
| 2294 | + | |
| 2295 | +-- -------------------------------------------------------- | |
| 2296 | + | |
| 2297 | +-- | |
| 2266 | 2298 | -- Table structure for table `zseq_role_allocations` |
| 2267 | 2299 | -- |
| 2268 | 2300 | ... | ... |