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,7 +216,8 @@ class KTInit { | ||
| 216 | * Eduardo Polidor, et. al. | 216 | * Eduardo Polidor, et. al. |
| 217 | */ | 217 | */ |
| 218 | if (ini_get('register_globals')) { | 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 | foreach ($superglob as $key => $val) { | 221 | foreach ($superglob as $key => $val) { |
| 221 | if (isset($GLOBALS[$key]) && $GLOBALS[$key] == $val) { | 222 | if (isset($GLOBALS[$key]) && $GLOBALS[$key] == $val) { |
| 222 | unset($GLOBALS[$key]); | 223 | unset($GLOBALS[$key]); |
| @@ -639,7 +640,14 @@ require_once(KT_LIB_DIR . '/session/control.inc'); | @@ -639,7 +640,14 @@ require_once(KT_LIB_DIR . '/session/control.inc'); | ||
| 639 | require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); | 640 | require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); |
| 640 | 641 | ||
| 641 | if ($checkup !== true) { | 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 | if ($checkup !== true) { | 653 | if ($checkup !== true) { |
lib/plugins/KTAdminNavigation.php
| @@ -5,32 +5,32 @@ | @@ -5,32 +5,32 @@ | ||
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | 8 | + * |
| 9 | * This program is free software; you can redistribute it and/or modify it under | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU General Public License version 3 as published by the | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | * Free Software Foundation. | 11 | * Free Software Foundation. |
| 12 | - * | 12 | + * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | * details. | 16 | * details. |
| 17 | - * | 17 | + * |
| 18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | 20 | + * |
| 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | 23 | + * |
| 24 | * The interactive user interfaces in modified source and object code versions | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | * of this program must display Appropriate Legal Notices, as required under | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | * Section 5 of the GNU General Public License version 3. | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | 27 | + * |
| 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | * these Appropriate Legal Notices must retain the display of the "Powered by | 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 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 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 | * Contributor( s): ______________________________________ | 34 | * Contributor( s): ______________________________________ |
| 35 | * | 35 | * |
| 36 | */ | 36 | */ |
| @@ -91,7 +91,7 @@ class KTAdminNavigationRegistry { | @@ -91,7 +91,7 @@ class KTAdminNavigationRegistry { | ||
| 91 | // FIXME this probably needs to use require_once mojo. | 91 | // FIXME this probably needs to use require_once mojo. |
| 92 | $aInfo = $this->aResources[$sName]; | 92 | $aInfo = $this->aResources[$sName]; |
| 93 | if ($aInfo["filepath"] !== null) { require_once($aInfo["filepath"]); } | 93 | if ($aInfo["filepath"] !== null) { require_once($aInfo["filepath"]); } |
| 94 | - if ($aInfo["url"] !== null) { | 94 | + if (!empty($aInfo['url'])) { |
| 95 | return new RedirectingDispatcher($aInfo["url"]); | 95 | return new RedirectingDispatcher($aInfo["url"]); |
| 96 | } | 96 | } |
| 97 | return new $aInfo["class"]; | 97 | return new $aInfo["class"]; |
lib/plugins/plugin.inc.php
| @@ -5,32 +5,32 @@ | @@ -5,32 +5,32 @@ | ||
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | 8 | + * |
| 9 | * This program is free software; you can redistribute it and/or modify it under | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU General Public License version 3 as published by the | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | * Free Software Foundation. | 11 | * Free Software Foundation. |
| 12 | - * | 12 | + * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | * details. | 16 | * details. |
| 17 | - * | 17 | + * |
| 18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | 20 | + * |
| 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | 23 | + * |
| 24 | * The interactive user interfaces in modified source and object code versions | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | * of this program must display Appropriate Legal Notices, as required under | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | * Section 5 of the GNU General Public License version 3. | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | 27 | + * |
| 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | * these Appropriate Legal Notices must retain the display of the "Powered by | 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 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 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 | * Contributor( s): ______________________________________ | 34 | * Contributor( s): ______________________________________ |
| 35 | * | 35 | * |
| 36 | */ | 36 | */ |
| @@ -81,27 +81,51 @@ class KTPlugin { | @@ -81,27 +81,51 @@ class KTPlugin { | ||
| 81 | function registerPortlet($aLocation, $sPortletClassName, $sPortletNamespace, $sFilename = null) { | 81 | function registerPortlet($aLocation, $sPortletClassName, $sPortletNamespace, $sFilename = null) { |
| 82 | $sFilename = $this->_fixFilename($sFilename); | 82 | $sFilename = $this->_fixFilename($sFilename); |
| 83 | $this->_aPortlets[$sPortletNamespace] = array($aLocation, $sPortletClassName, $sPortletNamespace, $sFilename, $this->sNamespace); | 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 | function registerTrigger($sAction, $sStage, $sTriggerClassName, $sTriggerNamespace, $sFilename = null) { | 93 | function registerTrigger($sAction, $sStage, $sTriggerClassName, $sTriggerNamespace, $sFilename = null) { |
| 87 | $sFilename = $this->_fixFilename($sFilename); | 94 | $sFilename = $this->_fixFilename($sFilename); |
| 88 | $this->_aTriggers[$sTriggerNamespace] = array($sAction, $sStage, $sTriggerClassName, $sTriggerNamespace, $sFilename, $this->sNamespace); | 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 | function registerAction($sActionType, $sActionClassName, $sActionNamespace, $sFilename = null) { | 102 | function registerAction($sActionType, $sActionClassName, $sActionNamespace, $sFilename = null) { |
| 92 | $sFilename = $this->_fixFilename($sFilename); | 103 | $sFilename = $this->_fixFilename($sFilename); |
| 93 | $this->_aActions[$sActionNamespace] = array($sActionType, $sActionClassName, $sActionNamespace, $sFilename, $this->sNamespace); | 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 | function registerPage($sWebPath, $sPageClassName, $sFilename = null) { | 111 | function registerPage($sWebPath, $sPageClassName, $sFilename = null) { |
| 97 | $sFilename = $this->_fixFilename($sFilename); | 112 | $sFilename = $this->_fixFilename($sFilename); |
| 98 | $sWebPath = sprintf("%s/%s", $this->sNamespace, $sWebPath); | 113 | $sWebPath = sprintf("%s/%s", $this->sNamespace, $sWebPath); |
| 114 | + | ||
| 99 | $this->_aPages[$sWebPath] = array($sWebPath, $sPageClassName, $sFilename, $this->sNamespace); | 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 | function registerWorkflowTrigger($sNamespace, $sTriggerClassName, $sFilename = null) { | 122 | function registerWorkflowTrigger($sNamespace, $sTriggerClassName, $sFilename = null) { |
| 103 | $sFilename = $this->_fixFilename($sFilename); | 123 | $sFilename = $this->_fixFilename($sFilename); |
| 104 | $this->_aWFTriggers[$sNamespace] = array($sNamespace, $sTriggerClassName, $sFilename); | 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 | function getPagePath($sPath) { | 131 | function getPagePath($sPath) { |
| @@ -120,6 +144,10 @@ class KTPlugin { | @@ -120,6 +144,10 @@ class KTPlugin { | ||
| 120 | function registerAuthenticationProvider($sName, $sClass, $sNamespace, $sFilename = null) { | 144 | function registerAuthenticationProvider($sName, $sClass, $sNamespace, $sFilename = null) { |
| 121 | $sFilename = $this->_fixFilename($sFilename); | 145 | $sFilename = $this->_fixFilename($sFilename); |
| 122 | $this->_aAuthenticationProviders[$sNamespace] = array($sName, $sClass, $sNamespace, $sFilename, $this->sNamespace); | 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 | //registerLocation($sName, $sClass, $sCategory, $sTitle, $sDescription, $sDispatcherFilePath = null, $sURL = null) | 153 | //registerLocation($sName, $sClass, $sCategory, $sTitle, $sDescription, $sDispatcherFilePath = null, $sURL = null) |
| @@ -127,20 +155,42 @@ class KTPlugin { | @@ -127,20 +155,42 @@ class KTPlugin { | ||
| 127 | $sFullname = $sCategory . '/' . $sName; | 155 | $sFullname = $sCategory . '/' . $sName; |
| 128 | $sFilename = $this->_fixFilename($sFilename); | 156 | $sFilename = $this->_fixFilename($sFilename); |
| 129 | $this->_aAdminPages[$sFullname] = array($sName, $sClass, $sCategory, $sTitle, $sDescription, $sFilename, null, $this->sNamespace); | 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 | function registerAdminCategory($sPath, $sName, $sDescription) { | 164 | function registerAdminCategory($sPath, $sName, $sDescription) { |
| 133 | $this->_aAdminCategories[$sPath] = array($sPath, $sName, $sDescription); | 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 | function registerDashlet($sClassName, $sNamespace, $sFilename) { | 179 | function registerDashlet($sClassName, $sNamespace, $sFilename) { |
| 137 | $sFilename = $this->_fixFilename($sFilename); | 180 | $sFilename = $this->_fixFilename($sFilename); |
| 138 | $this->_aDashlets[$sNamespace] = array($sClassName, $sNamespace, $sFilename, $this->sNamespace); | 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 | function registeri18n($sDomain, $sPath) { | 187 | function registeri18n($sDomain, $sPath) { |
| 142 | $sPath = $this->_fixFilename($sPath); | 188 | $sPath = $this->_fixFilename($sPath); |
| 143 | $this->_ai18n[$sDomain] = array($sDomain, $sPath); | 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 | function registeri18nLang($sDomain, $sLang, $sPath) { | 196 | function registeri18nLang($sDomain, $sLang, $sPath) { |
| @@ -148,55 +198,151 @@ class KTPlugin { | @@ -148,55 +198,151 @@ class KTPlugin { | ||
| 148 | $sPath = $this->_fixFilename($sPath); | 198 | $sPath = $this->_fixFilename($sPath); |
| 149 | } | 199 | } |
| 150 | $this->_ai18nLang["$sDomain/$sLang"] = array($sDomain, $sLang, $sPath); | 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 | function registerLanguage($sLanguage, $sLanguageName) { | 207 | function registerLanguage($sLanguage, $sLanguageName) { |
| 154 | $this->_aLanguage[$sLanguage] = array($sLanguage, $sLanguageName); | 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 | function registerHelpLanguage($sPlugin, $sLanguage, $sBasedir) { | 215 | function registerHelpLanguage($sPlugin, $sLanguage, $sBasedir) { |
| 158 | $this->_aHelpLanguage[$sLanguage] = array($sPlugin, $sLanguage, $sBasedir); | 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 | function registerColumn($sName, $sNamespace, $sClassName, $sFile) { | 223 | function registerColumn($sName, $sNamespace, $sClassName, $sFile) { |
| 162 | $sFile = $this->_fixFilename($sFile); | 224 | $sFile = $this->_fixFilename($sFile); |
| 163 | $this->_aColumns[$sNamespace] = array($sName, $sNamespace, $sClassName, $sFile); | 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 | function registerView($sName, $sNamespace) { | 232 | function registerView($sName, $sNamespace) { |
| 167 | $this->_aViews[$sNamespace] = array($sName, $sNamespace); | 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 | function registerNotificationHandler($sName, $sNamespace, $sPath) { | 240 | function registerNotificationHandler($sName, $sNamespace, $sPath) { |
| 171 | $sPath = $this->_fixFilename($sPath); | 241 | $sPath = $this->_fixFilename($sPath); |
| 172 | $this->_aNotificationHandlers[$sNamespace] = array($sNamespace, $sName, $sPath); | 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 | function registerTemplateLocation($sName, $sPath) { | 249 | function registerTemplateLocation($sName, $sPath) { |
| 176 | $sPath = $this->_fixFilename($sPath); | 250 | $sPath = $this->_fixFilename($sPath); |
| 177 | $this->_aTemplateLocations[$sName] = array($sName, $sPath); | 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 | function registerWidget($sClassname, $sNamespace, $sPath) { | 266 | function registerWidget($sClassname, $sNamespace, $sPath) { |
| 182 | $sPath = $this->_fixFilename($sPath); | 267 | $sPath = $this->_fixFilename($sPath); |
| 183 | $this->_aWidgets[$sNamespace] = array($sClassname, $sNamespace, $sPath); | 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 | function registerValidator($sClassname, $sNamespace, $sPath) { | 275 | function registerValidator($sClassname, $sNamespace, $sPath) { |
| 187 | $sPath = $this->_fixFilename($sPath); | 276 | $sPath = $this->_fixFilename($sPath); |
| 188 | $this->_aValidators[$sNamespace] = array($sClassname, $sNamespace, $sPath); | 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 | function registerCriterion($sClassName, $sNamespace, $sFilename = null, $aInitialize = null) { | 285 | function registerCriterion($sClassName, $sNamespace, $sFilename = null, $aInitialize = null) { |
| 193 | $sFilename = $this->_fixFilename($sFilename); | 286 | $sFilename = $this->_fixFilename($sFilename); |
| 194 | $this->_aCriteria[$sNamespace] = array($sClassName, $sNamespace, $sFilename, $aInitialize); | 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 | function registerInterceptor($sClassname, $sNamespace, $sPath = null) { | 298 | function registerInterceptor($sClassname, $sNamespace, $sPath = null) { |
| 198 | $sPath = $this->_fixFilename($sPath); | 299 | $sPath = $this->_fixFilename($sPath); |
| 199 | $this->_aInterceptors[$sNamespace] = array($sClassname, $sNamespace, $sPath); | 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 | function _fixFilename($sFilename) { | 348 | function _fixFilename($sFilename) { |
| @@ -240,7 +386,120 @@ class KTPlugin { | @@ -240,7 +386,120 @@ class KTPlugin { | ||
| 240 | return true; | 386 | return true; |
| 241 | } | 387 | } |
| 242 | 388 | ||
| 389 | + /** | ||
| 390 | + * Load the actions, portlets, etc as part of the parent plugin | ||
| 391 | + * | ||
| 392 | + */ | ||
| 243 | function load() { | 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 | if (!$this->isRegistered()) { | 503 | if (!$this->isRegistered()) { |
| 245 | return; | 504 | return; |
| 246 | } | 505 | } |
| @@ -411,6 +670,7 @@ class KTPlugin { | @@ -411,6 +670,7 @@ class KTPlugin { | ||
| 411 | // remember to -start- the upgrade from the "next" version | 670 | // remember to -start- the upgrade from the "next" version |
| 412 | $iEndVersion = $this->upgradePlugin($oEntity->getVersion()+1, $this->iVersion); | 671 | $iEndVersion = $this->upgradePlugin($oEntity->getVersion()+1, $this->iVersion); |
| 413 | } | 672 | } |
| 673 | + | ||
| 414 | if ($iEndVersion != $this->iVersion) { | 674 | if ($iEndVersion != $this->iVersion) { |
| 415 | // we obviously failed. | 675 | // we obviously failed. |
| 416 | $oEntity->updateFromArray(array( | 676 | $oEntity->updateFromArray(array( |
| @@ -421,7 +681,7 @@ class KTPlugin { | @@ -421,7 +681,7 @@ class KTPlugin { | ||
| 421 | 'friendlyname' => $friendly_name, | 681 | 'friendlyname' => $friendly_name, |
| 422 | )); | 682 | )); |
| 423 | // FIXME we -really- need to raise an error here, somehow. | 683 | // FIXME we -really- need to raise an error here, somehow. |
| 424 | - return $oEntity; | 684 | + |
| 425 | } else { | 685 | } else { |
| 426 | $oEntity->updateFromArray(array( | 686 | $oEntity->updateFromArray(array( |
| 427 | 'path' => $this->stripKtDir($this->sFilename), | 687 | 'path' => $this->stripKtDir($this->sFilename), |
| @@ -429,8 +689,11 @@ class KTPlugin { | @@ -429,8 +689,11 @@ class KTPlugin { | ||
| 429 | 'unavailable' => false, | 689 | 'unavailable' => false, |
| 430 | 'friendlyname' => $friendly_name, | 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 | $disabled = 1; | 698 | $disabled = 1; |
| 436 | if ($this->bAlwaysInclude || $this->autoRegister) { $disabled = 0; } | 699 | if ($this->bAlwaysInclude || $this->autoRegister) { $disabled = 0; } |
| @@ -446,6 +709,9 @@ class KTPlugin { | @@ -446,6 +709,9 @@ class KTPlugin { | ||
| 446 | if (PEAR::isError($oEntity)) { | 709 | if (PEAR::isError($oEntity)) { |
| 447 | return $oEntity; | 710 | return $oEntity; |
| 448 | } | 711 | } |
| 712 | + | ||
| 713 | + /* ** Quick fix for optimisation. Reread must run plugin setup. ** */ | ||
| 714 | + $this->setup(); | ||
| 449 | return true; | 715 | return true; |
| 450 | } | 716 | } |
| 451 | 717 |
lib/plugins/pluginregistry.inc.php
| @@ -5,32 +5,32 @@ | @@ -5,32 +5,32 @@ | ||
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | 8 | + * |
| 9 | * This program is free software; you can redistribute it and/or modify it under | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU General Public License version 3 as published by the | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | * Free Software Foundation. | 11 | * Free Software Foundation. |
| 12 | - * | 12 | + * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | * details. | 16 | * details. |
| 17 | - * | 17 | + * |
| 18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | 20 | + * |
| 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | 23 | + * |
| 24 | * The interactive user interfaces in modified source and object code versions | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | * of this program must display Appropriate Legal Notices, as required under | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | * Section 5 of the GNU General Public License version 3. | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | 27 | + * |
| 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | * these Appropriate Legal Notices must retain the display of the "Powered by | 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 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 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 | * Contributor( s): ______________________________________ | 34 | * Contributor( s): ______________________________________ |
| 35 | * | 35 | * |
| 36 | */ | 36 | */ |
| @@ -46,8 +46,18 @@ class KTPluginRegistry { | @@ -46,8 +46,18 @@ class KTPluginRegistry { | ||
| 46 | return $GLOBALS['_KT_PLUGIN']['oKTPluginRegistry']; | 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 | function registerPlugin($sClassName, $sNamespace, $sFilename = null) { | 56 | function registerPlugin($sClassName, $sNamespace, $sFilename = null) { |
| 50 | $this->_aPluginDetails[$sNamespace] = array($sClassName, $sNamespace, $sFilename); | 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 | function &getPlugin($sNamespace) { | 63 | function &getPlugin($sNamespace) { |
| @@ -56,14 +66,21 @@ class KTPluginRegistry { | @@ -56,14 +66,21 @@ class KTPluginRegistry { | ||
| 56 | } | 66 | } |
| 57 | $aDetails = KTUtil::arrayGet($this->_aPluginDetails, $sNamespace); | 67 | $aDetails = KTUtil::arrayGet($this->_aPluginDetails, $sNamespace); |
| 58 | if (empty($aDetails)) { | 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 | $sFilename = $aDetails[2]; | 77 | $sFilename = $aDetails[2]; |
| 62 | if (!empty($sFilename)) { | 78 | if (!empty($sFilename)) { |
| 63 | require_once($sFilename); | 79 | require_once($sFilename); |
| 64 | } | 80 | } |
| 65 | $sClassName = $aDetails[0]; | 81 | $sClassName = $aDetails[0]; |
| 66 | - $oPlugin =new $sClassName($sFilename); | 82 | + $oPlugin = new $sClassName($sFilename); |
| 83 | + | ||
| 67 | $this->_aPlugins[$sNamespace] =& $oPlugin; | 84 | $this->_aPlugins[$sNamespace] =& $oPlugin; |
| 68 | return $oPlugin; | 85 | return $oPlugin; |
| 69 | } | 86 | } |
lib/plugins/pluginutil.inc.php
| @@ -5,32 +5,32 @@ | @@ -5,32 +5,32 @@ | ||
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | 8 | + * |
| 9 | * This program is free software; you can redistribute it and/or modify it under | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU General Public License version 3 as published by the | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | * Free Software Foundation. | 11 | * Free Software Foundation. |
| 12 | - * | 12 | + * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | * details. | 16 | * details. |
| 17 | - * | 17 | + * |
| 18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | 20 | + * |
| 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | 23 | + * |
| 24 | * The interactive user interfaces in modified source and object code versions | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | * of this program must display Appropriate Legal Notices, as required under | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | * Section 5 of the GNU General Public License version 3. | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | 27 | + * |
| 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | * these Appropriate Legal Notices must retain the display of the "Powered by | 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 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 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 | * Contributor( s): ______________________________________ | 34 | * Contributor( s): ______________________________________ |
| 35 | * | 35 | * |
| 36 | */ | 36 | */ |
| @@ -69,7 +69,7 @@ class KTPluginUtil { | @@ -69,7 +69,7 @@ class KTPluginUtil { | ||
| 69 | 69 | ||
| 70 | /** | 70 | /** |
| 71 | * Store the plugin cache in the cache directory. | 71 | * Store the plugin cache in the cache directory. |
| 72 | - * | 72 | + * @deprecated |
| 73 | */ | 73 | */ |
| 74 | static function savePluginCache($array) | 74 | static function savePluginCache($array) |
| 75 | { | 75 | { |
| @@ -97,7 +97,7 @@ class KTPluginUtil { | @@ -97,7 +97,7 @@ class KTPluginUtil { | ||
| 97 | 97 | ||
| 98 | /** | 98 | /** |
| 99 | * Remove the plugin cache. | 99 | * Remove the plugin cache. |
| 100 | - * | 100 | + * @deprecated |
| 101 | */ | 101 | */ |
| 102 | static function removePluginCache() | 102 | static function removePluginCache() |
| 103 | { | 103 | { |
| @@ -115,7 +115,7 @@ class KTPluginUtil { | @@ -115,7 +115,7 @@ class KTPluginUtil { | ||
| 115 | 115 | ||
| 116 | /** | 116 | /** |
| 117 | * Reads the plugin cache file. This must still be unserialised. | 117 | * Reads the plugin cache file. This must still be unserialised. |
| 118 | - * | 118 | + * @deprecated |
| 119 | * @return mixed Returns false on failure, or the serialised cache. | 119 | * @return mixed Returns false on failure, or the serialised cache. |
| 120 | */ | 120 | */ |
| 121 | static function readPluginCache() | 121 | static function readPluginCache() |
| @@ -148,58 +148,213 @@ class KTPluginUtil { | @@ -148,58 +148,213 @@ class KTPluginUtil { | ||
| 148 | return unserialize($cache); | 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 | KTPluginUtil::registerPlugins(); | 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,32 +5,32 @@ | ||
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | 8 | + * |
| 9 | * This program is free software; you can redistribute it and/or modify it under | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU General Public License version 3 as published by the | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | * Free Software Foundation. | 11 | * Free Software Foundation. |
| 12 | - * | 12 | + * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | * details. | 16 | * details. |
| 17 | - * | 17 | + * |
| 18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | 20 | + * |
| 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | 23 | + * |
| 24 | * The interactive user interfaces in modified source and object code versions | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | * of this program must display Appropriate Legal Notices, as required under | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | * Section 5 of the GNU General Public License version 3. | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | 27 | + * |
| 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | * these Appropriate Legal Notices must retain the display of the "Powered by | 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 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 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 | * Contributor( s): ______________________________________ | 34 | * Contributor( s): ______________________________________ |
| 35 | * | 35 | * |
| 36 | * | 36 | * |
| @@ -156,11 +156,17 @@ class KTPage { | @@ -156,11 +156,17 @@ class KTPage { | ||
| 156 | 156 | ||
| 157 | // initiliase the menu. | 157 | // initiliase the menu. |
| 158 | function initMenu() { | 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,32 +7,32 @@ | ||
| 7 | * KnowledgeTree Open Source Edition | 7 | * KnowledgeTree Open Source Edition |
| 8 | * Document Management Made Simple | 8 | * Document Management Made Simple |
| 9 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 9 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 10 | - * | 10 | + * |
| 11 | * This program is free software; you can redistribute it and/or modify it under | 11 | * This program is free software; you can redistribute it and/or modify it under |
| 12 | * the terms of the GNU General Public License version 3 as published by the | 12 | * the terms of the GNU General Public License version 3 as published by the |
| 13 | * Free Software Foundation. | 13 | * Free Software Foundation. |
| 14 | - * | 14 | + * |
| 15 | * This program is distributed in the hope that it will be useful, but WITHOUT | 15 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 17 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 17 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 18 | * details. | 18 | * details. |
| 19 | - * | 19 | + * |
| 20 | * You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | - * | 22 | + * |
| 23 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 23 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 24 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 24 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 25 | - * | 25 | + * |
| 26 | * The interactive user interfaces in modified source and object code versions | 26 | * The interactive user interfaces in modified source and object code versions |
| 27 | * of this program must display Appropriate Legal Notices, as required under | 27 | * of this program must display Appropriate Legal Notices, as required under |
| 28 | * Section 5 of the GNU General Public License version 3. | 28 | * Section 5 of the GNU General Public License version 3. |
| 29 | - * | 29 | + * |
| 30 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 30 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 31 | * these Appropriate Legal Notices must retain the display of the "Powered by | 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 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 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 | * Contributor( s): ______________________________________ | 36 | * Contributor( s): ______________________________________ |
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| @@ -121,11 +121,28 @@ class KTTemplating { | @@ -121,11 +121,28 @@ class KTTemplating { | ||
| 121 | // }}} | 121 | // }}} |
| 122 | 122 | ||
| 123 | // {{{ addLocation | 123 | // {{{ addLocation |
| 124 | + /** | ||
| 125 | + * Register a new location in the database | ||
| 126 | + * | ||
| 127 | + * @param unknown_type $descr | ||
| 128 | + * @param unknown_type $loc | ||
| 129 | + */ | ||
| 124 | function addLocation ($descr, $loc) { | 130 | function addLocation ($descr, $loc) { |
| 125 | $this->aLocationRegistry[$descr] = $loc; | 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 | // {{{ getSingleton | 146 | // {{{ getSingleton |
| 130 | static function &getSingleton () { | 147 | static function &getSingleton () { |
| 131 | if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTTemplating')) { | 148 | if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTTemplating')) { |
sql/mysql/install/structure.sql
| @@ -1238,6 +1238,27 @@ CREATE TABLE `plugins` ( | @@ -1238,6 +1238,27 @@ CREATE TABLE `plugins` ( | ||
| 1238 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | 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 | -- Table structure for table `role_allocations` | 1262 | -- Table structure for table `role_allocations` |
| 1242 | -- | 1263 | -- |
| 1243 | 1264 | ||
| @@ -2263,6 +2284,17 @@ CREATE TABLE `zseq_plugins` ( | @@ -2263,6 +2284,17 @@ CREATE TABLE `zseq_plugins` ( | ||
| 2263 | ) ENGINE=MyISAM AUTO_INCREMENT=82 DEFAULT CHARSET=latin1; | 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 | -- Table structure for table `zseq_role_allocations` | 2298 | -- Table structure for table `zseq_role_allocations` |
| 2267 | -- | 2299 | -- |
| 2268 | 2300 |