diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php
index 940a916..9ed406a 100644
--- a/config/dmsDefaults.php
+++ b/config/dmsDefaults.php
@@ -216,7 +216,8 @@ class KTInit {
* Eduardo Polidor, et. al.
*/
if (ini_get('register_globals')) {
- foreach (array($_ENV, $_GET, $_POST, $_COOKIE, $_SERVER) as $superglob) {
+ $aGlobals = array($_ENV, $_GET, $_POST, $_COOKIE, $_SERVER);
+ foreach ($aGlobals as $superglob) {
foreach ($superglob as $key => $val) {
if (isset($GLOBALS[$key]) && $GLOBALS[$key] == $val) {
unset($GLOBALS[$key]);
@@ -639,7 +640,14 @@ require_once(KT_LIB_DIR . '/session/control.inc');
require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php');
if ($checkup !== true) {
- KTPluginUtil::loadPlugins();
+ // Replace function later
+ /* ** Get the page being loaded and load the plugins specific to the page ** */
+ $sScriptName = $GLOBALS['_SERVER']['SCRIPT_NAME'];
+ $sScript = basename($sScriptName);
+ $pos = strpos($sScript, '.');
+ $sType = substr($sScript, 0, $pos);
+
+ KTPluginUtil::loadPlugins($sType);
}
if ($checkup !== true) {
diff --git a/lib/plugins/KTAdminNavigation.php b/lib/plugins/KTAdminNavigation.php
index 9c2c3b2..a7c93dd 100644
--- a/lib/plugins/KTAdminNavigation.php
+++ b/lib/plugins/KTAdminNavigation.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
+ *
* You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -91,7 +91,7 @@ class KTAdminNavigationRegistry {
// FIXME this probably needs to use require_once mojo.
$aInfo = $this->aResources[$sName];
if ($aInfo["filepath"] !== null) { require_once($aInfo["filepath"]); }
- if ($aInfo["url"] !== null) {
+ if (!empty($aInfo['url'])) {
return new RedirectingDispatcher($aInfo["url"]);
}
return new $aInfo["class"];
diff --git a/lib/plugins/plugin.inc.php b/lib/plugins/plugin.inc.php
index f164362..ed67ca2 100644
--- a/lib/plugins/plugin.inc.php
+++ b/lib/plugins/plugin.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
+ *
* You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -81,27 +81,51 @@ class KTPlugin {
function registerPortlet($aLocation, $sPortletClassName, $sPortletNamespace, $sFilename = null) {
$sFilename = $this->_fixFilename($sFilename);
$this->_aPortlets[$sPortletNamespace] = array($aLocation, $sPortletClassName, $sPortletNamespace, $sFilename, $this->sNamespace);
+
+ // Register helper in DB
+ if(is_array($aLocation)){
+ $sLocation = implode('_|', $aLocation);
+ }
+ $params = $sLocation.'|'.$sPortletClassName.'|'.$sPortletNamespace.'|'.$sFilename.'|'.$this->sNamespace;
+ $this->registerPluginHelper($sPortletNamespace, $sPortletClassName, $sFilename, $params, 'general', 'portlet');
}
function registerTrigger($sAction, $sStage, $sTriggerClassName, $sTriggerNamespace, $sFilename = null) {
$sFilename = $this->_fixFilename($sFilename);
$this->_aTriggers[$sTriggerNamespace] = array($sAction, $sStage, $sTriggerClassName, $sTriggerNamespace, $sFilename, $this->sNamespace);
+
+ // Register helper in DB
+ $params = $sAction.'|'.$sStage.'|'.$sTriggerClassName.'|'.$sTriggerNamespace.'|'.$sFilename.'|'.$this->sNamespace;
+ $this->registerPluginHelper($sTriggerNamespace, $sTriggerClassName, $sFilename, $params, 'general', 'trigger');
}
function registerAction($sActionType, $sActionClassName, $sActionNamespace, $sFilename = null) {
$sFilename = $this->_fixFilename($sFilename);
$this->_aActions[$sActionNamespace] = array($sActionType, $sActionClassName, $sActionNamespace, $sFilename, $this->sNamespace);
+
+ // Register helper in DB
+ $params = $sActionType.'|'.$sActionClassName.'|'.$sActionNamespace.'|'.$sFilename.'|'.$this->sNamespace;
+ $this->registerPluginHelper($sActionNamespace, $sActionClassName, $sFilename, $params, 'general', 'action');
}
function registerPage($sWebPath, $sPageClassName, $sFilename = null) {
$sFilename = $this->_fixFilename($sFilename);
$sWebPath = sprintf("%s/%s", $this->sNamespace, $sWebPath);
+
$this->_aPages[$sWebPath] = array($sWebPath, $sPageClassName, $sFilename, $this->sNamespace);
+
+ // Register helper in DB
+ $params = $sWebPath.'|'.$sPageClassName.'|'.$sFilename.'|'.$this->sNamespace;
+ $this->registerPluginHelper($sWebPath, $sPageClassName, $sFilename, $params, 'general', 'page');
}
function registerWorkflowTrigger($sNamespace, $sTriggerClassName, $sFilename = null) {
$sFilename = $this->_fixFilename($sFilename);
$this->_aWFTriggers[$sNamespace] = array($sNamespace, $sTriggerClassName, $sFilename);
+
+ // Register helper in DB
+ $params = $sNamespace.'|'.$sTriggerClassName.'|'.$sFilename;
+ $this->registerPluginHelper($sNamespace, $sTriggerClassName, $sFilename, $params, 'general', 'workflow_trigger');
}
function getPagePath($sPath) {
@@ -120,6 +144,10 @@ class KTPlugin {
function registerAuthenticationProvider($sName, $sClass, $sNamespace, $sFilename = null) {
$sFilename = $this->_fixFilename($sFilename);
$this->_aAuthenticationProviders[$sNamespace] = array($sName, $sClass, $sNamespace, $sFilename, $this->sNamespace);
+
+ // Register helper in DB
+ $params = $sName.'|'.$sClass.'|'.$sNamespace.'|'.$sFilename.'|'.$this->sNamespace;
+ $this->registerPluginHelper($sNamespace, $sClass, $sFilename, $params, 'general', 'authentication_provider');
}
//registerLocation($sName, $sClass, $sCategory, $sTitle, $sDescription, $sDispatcherFilePath = null, $sURL = null)
@@ -127,20 +155,42 @@ class KTPlugin {
$sFullname = $sCategory . '/' . $sName;
$sFilename = $this->_fixFilename($sFilename);
$this->_aAdminPages[$sFullname] = array($sName, $sClass, $sCategory, $sTitle, $sDescription, $sFilename, null, $this->sNamespace);
+
+ // Register helper in DB
+ $params = $sName.'|'.$sClass.'|'.$sCategory.'|'.$sTitle.'|'.$sDescription.'|'.$sFilename.'|'.null.'|'.$this->sNamespace;
+ $this->registerPluginHelper($sFullname, $sClass, $sFilename, $params, 'general', 'admin_page');
}
function registerAdminCategory($sPath, $sName, $sDescription) {
$this->_aAdminCategories[$sPath] = array($sPath, $sName, $sDescription);
+
+ // Register helper in DB
+ $params = $sPath.'|'.$sName.'|'.$sDescription;
+ $this->registerPluginHelper($sPath, $sName, $sPath, $params, 'general', 'admin_category');
}
+ /**
+ * Register a new dashlet
+ *
+ * @param string $sClassName
+ * @param string $sNamespace
+ * @param string $sFilename
+ */
function registerDashlet($sClassName, $sNamespace, $sFilename) {
$sFilename = $this->_fixFilename($sFilename);
$this->_aDashlets[$sNamespace] = array($sClassName, $sNamespace, $sFilename, $this->sNamespace);
+
+ $params = $sClassName.'|'.$sNamespace.'|'.$sFilename.'|'.$this->sNamespace;
+ $this->registerPluginHelper($sNamespace, $sClassName, $sFilename, $params, 'dashboard', 'dashlet');
}
function registeri18n($sDomain, $sPath) {
$sPath = $this->_fixFilename($sPath);
$this->_ai18n[$sDomain] = array($sDomain, $sPath);
+
+ // Register helper in DB
+ $params = $sDomain.'|'.$sPath;
+ $this->registerPluginHelper($sDomain, $sDomain, $sPath, $params, 'general', 'i18n');
}
function registeri18nLang($sDomain, $sLang, $sPath) {
@@ -148,55 +198,151 @@ class KTPlugin {
$sPath = $this->_fixFilename($sPath);
}
$this->_ai18nLang["$sDomain/$sLang"] = array($sDomain, $sLang, $sPath);
+
+ // Register helper in DB
+ $params = $sDomain.'|'.$sLang.'|'.$sPath;
+ $this->registerPluginHelper("$sDomain/$sLang", $sDomain, $sPath, $params, 'general', 'i18nlang');
}
function registerLanguage($sLanguage, $sLanguageName) {
$this->_aLanguage[$sLanguage] = array($sLanguage, $sLanguageName);
+
+ // Register helper in DB
+ $params = $sLanguage.'|'.$sLanguageName;
+ $this->registerPluginHelper($sLanguage, $sClassName, $sFilename, $params, 'general', 'language');
}
function registerHelpLanguage($sPlugin, $sLanguage, $sBasedir) {
$this->_aHelpLanguage[$sLanguage] = array($sPlugin, $sLanguage, $sBasedir);
+
+ // Register helper in DB
+ $params = $sPlugin.'|'.$sLanguage.'|'.$sBasedir;
+ $this->registerPluginHelper($sLanguage, $sClassName, $sFilename, $params, 'general', 'help_language');
}
function registerColumn($sName, $sNamespace, $sClassName, $sFile) {
$sFile = $this->_fixFilename($sFile);
$this->_aColumns[$sNamespace] = array($sName, $sNamespace, $sClassName, $sFile);
+
+ // Register helper in DB
+ $params = $sName.'|'.$sNamespace.'|'.$sClassName.'|'.$sFile;
+ $this->registerPluginHelper($sNamespace, $sClassName, $sFile, $params, 'general', 'column');
}
function registerView($sName, $sNamespace) {
$this->_aViews[$sNamespace] = array($sName, $sNamespace);
+
+ // Register helper in DB
+ $params = $sName.'|'.$sNamespace;
+ $this->registerPluginHelper($sNamespace, '', '', $params, 'general', 'view');
}
function registerNotificationHandler($sName, $sNamespace, $sPath) {
$sPath = $this->_fixFilename($sPath);
$this->_aNotificationHandlers[$sNamespace] = array($sNamespace, $sName, $sPath);
+
+ // Register helper in DB
+ $params = $sNamespace.'|'.$sName.'|'.$sPath;
+ $this->registerPluginHelper($sNamespace, $sName, $sPath, $params, 'general', 'notification_handler');
}
function registerTemplateLocation($sName, $sPath) {
$sPath = $this->_fixFilename($sPath);
$this->_aTemplateLocations[$sName] = array($sName, $sPath);
+
+ // Register helper in DB
+ $params = $sName.'|'.$sPath;
+ $this->registerPluginHelper($sName, $sName, $sPath, $params, 'general', 'template_location');
}
+ /**
+ * Register a new widget
+ *
+ * @param unknown_type $sClassname
+ * @param unknown_type $sNamespace
+ * @param unknown_type $sPath
+ */
function registerWidget($sClassname, $sNamespace, $sPath) {
$sPath = $this->_fixFilename($sPath);
$this->_aWidgets[$sNamespace] = array($sClassname, $sNamespace, $sPath);
+
+ // Register helper in DB
+ $params = $sClassname.'|'.$sNamespace.'|'.$sPath;
+ $this->registerPluginHelper($sNamespace, $sClassname, $sPath, $params, 'general', 'widget');
}
function registerValidator($sClassname, $sNamespace, $sPath) {
$sPath = $this->_fixFilename($sPath);
$this->_aValidators[$sNamespace] = array($sClassname, $sNamespace, $sPath);
+
+ // Register helper in DB
+ $params = $sClassname.'|'.$sNamespace.'|'.$sPath;
+ $this->registerPluginHelper($sNamespace, $sClassname, $sPath, $params, 'general', 'validator');
}
function registerCriterion($sClassName, $sNamespace, $sFilename = null, $aInitialize = null) {
$sFilename = $this->_fixFilename($sFilename);
$this->_aCriteria[$sNamespace] = array($sClassName, $sNamespace, $sFilename, $aInitialize);
+
+ // Register helper in DB
+ if(is_array($aInitialize)){
+ $sInitialize = implode('_|', $aInitialize);
+ }
+
+ $params = $sClassName.'|'.$sNamespace.'|'.$sFilename.'|'.$sInitialize;
+ $this->registerPluginHelper($sNamespace, $sClassName, $sFilename, $params, 'general', 'criterion');
}
function registerInterceptor($sClassname, $sNamespace, $sPath = null) {
$sPath = $this->_fixFilename($sPath);
$this->_aInterceptors[$sNamespace] = array($sClassname, $sNamespace, $sPath);
+
+ // Register helper in DB
+ $params = $sClassname.'|'.$sNamespace.'|'.$sPath;
+ $this->registerPluginHelper($sNamespace, $sClassname, $sPath, $params, 'general', 'interceptor');
+ }
+
+ /* ** Refactor into another class ** */
+ /**
+ * Register the plugin in the DB
+ *
+ * @param unknown_type $sClassName
+ * @param unknown_type $path
+ * @param unknown_type $object
+ * @param unknown_type $type
+ */
+ function registerPluginHelper($sNamespace, $sClassName, $path, $object, $view, $type) {
+
+ $sql = "SELECT * FROM plugin_helper WHERE namespace = '{$sNamespace}' AND classtype = '{$type}'";
+ $res = DBUtil::getOneResult($sql);
+
+ $aValues = array();
+ $aValues['namespace'] = $sNamespace;
+ $aValues['plugin'] = (!empty($this->sNamespace)) ? $this->sNamespace : $sNamespace;
+ $aValues['classname'] = $sClassName;
+ $aValues['pathname'] = $path;
+ $aValues['object'] = $object;
+ $aValues['viewtype'] = $view;
+ $aValues['classtype'] = $type;
+
+ // if record exists - update it.
+ if(!empty($res)){
+ $id = $res['id'];
+ $updateRes = DBUtil::autoUpdate('plugin_helper', $aValues, $id);
+ if(PEAR::isError($updateRes)){
+ return $updateRes;
+ }
+ return true;
+ }
+
+ // Insert into DB
+ $res = DBUtil::autoInsert('plugin_helper', $aValues);
+ if(PEAR::isError($res)){
+ return $res;
+ }
+ return true;
}
function _fixFilename($sFilename) {
@@ -240,7 +386,120 @@ class KTPlugin {
return true;
}
+ /**
+ * Load the actions, portlets, etc as part of the parent plugin
+ *
+ */
function load() {
+ // Get actions, portlets, etc, create arrays as part of plugin
+ $query = "SELECT * FROM plugin_helper h WHERE plugin = '{$this->sNamespace}'";
+ $aPluginHelpers = DBUtil::getResultArray($query);
+
+ if(!empty($aPluginHelpers)){
+ foreach ($aPluginHelpers as $plugin) {
+ $sName = $plugin['namespace'];
+ $sParams = $plugin['object'];
+ $aParams = explode('|', $sParams);
+ $sClassType = $plugin['classtype'];
+
+ switch ($sClassType) {
+ case 'portlet':
+ $aLocation = explode('_|', $aParams[0]);
+ $aParams[0] = $aLocation;
+ $this->_aPortlets[$sName] = $aParams;
+ break;
+
+ case 'trigger':
+ $this->_aTriggers[$sName] = $aParams;
+ break;
+
+ case 'action':
+ $this->_aActions[$sName] = $aParams;
+ break;
+
+ case 'page':
+ $this->_aPages[$sName] = $aParams;
+ break;
+
+ case 'authentication_provider':
+ $this->_aAuthenticationProviders[$sName] = $aParams;
+ break;
+
+ case 'admin_category':
+ $this->_aAdminCategories[$sName] = $aParams;
+ break;
+
+ case 'admin_page':
+ $this->_aAdminPages[$sName] = $aParams;
+ break;
+
+ case 'dashlet':
+ $this->_aDashlets[$sName] = $aParams;
+ break;
+
+ case 'i18n':
+ $this->_ai18n[$sName] = $aParams;
+ break;
+
+ case 'i18nlang':
+ $this->_ai18nLang[$sName] = $aParams;
+ break;
+
+ case 'language':
+ $this->_aLanguage[$sName] = $aParams;
+ break;
+
+ case 'help_language':
+ $this->_aHelpLanguage[$sName] = $aParams;
+ break;
+
+ case 'workflow_trigger':
+ $this->_aWFTriggers[$sName] = $aParams;
+ break;
+
+ case 'column':
+ $this->_aColumns[$sName] = $aParams;
+ break;
+
+ case 'view':
+ $this->_aViews[$sName] = $aParams;
+ break;
+
+ case 'notification_handler':
+ $this->_aNotificationHandlers[$sName] = $aParams;
+ break;
+
+ case 'template_location':
+ $this->_aTemplateLocations[$sName] = $aParams;
+ break;
+
+ case 'criterion':
+ $aInit = explode('_|', $aParams[3]);
+ $aParams[3] = $aInit;
+ $this->_aCriteria[$sName] = $aParams;
+ break;
+
+ case 'widget':
+ $this->_aWidgets[$sName] = $aParams;
+ break;
+
+ case 'validator':
+ $this->_aValidators[$sName] = $aParams;
+ break;
+
+ case 'interceptor':
+ $this->_aInterceptors[$sName] = $aParams;
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Original load function for the plugins
+ * @deprecated
+ */
+ function load2() {
if (!$this->isRegistered()) {
return;
}
@@ -411,6 +670,7 @@ class KTPlugin {
// remember to -start- the upgrade from the "next" version
$iEndVersion = $this->upgradePlugin($oEntity->getVersion()+1, $this->iVersion);
}
+
if ($iEndVersion != $this->iVersion) {
// we obviously failed.
$oEntity->updateFromArray(array(
@@ -421,7 +681,7 @@ class KTPlugin {
'friendlyname' => $friendly_name,
));
// FIXME we -really- need to raise an error here, somehow.
- return $oEntity;
+
} else {
$oEntity->updateFromArray(array(
'path' => $this->stripKtDir($this->sFilename),
@@ -429,8 +689,11 @@ class KTPlugin {
'unavailable' => false,
'friendlyname' => $friendly_name,
));
- return $oEntity;
+
}
+ /* ** Quick fix for optimisation. Reread must run plugin setup. ** */
+ $this->setup();
+ return $oEntity;
}
$disabled = 1;
if ($this->bAlwaysInclude || $this->autoRegister) { $disabled = 0; }
@@ -446,6 +709,9 @@ class KTPlugin {
if (PEAR::isError($oEntity)) {
return $oEntity;
}
+
+ /* ** Quick fix for optimisation. Reread must run plugin setup. ** */
+ $this->setup();
return true;
}
diff --git a/lib/plugins/pluginregistry.inc.php b/lib/plugins/pluginregistry.inc.php
index f583455..9b24f61 100644
--- a/lib/plugins/pluginregistry.inc.php
+++ b/lib/plugins/pluginregistry.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
+ *
* You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -46,8 +46,18 @@ class KTPluginRegistry {
return $GLOBALS['_KT_PLUGIN']['oKTPluginRegistry'];
}
+ /**
+ * Register the plugin in the database
+ *
+ * @param unknown_type $sClassName
+ * @param unknown_type $sNamespace
+ * @param unknown_type $sFilename
+ */
function registerPlugin($sClassName, $sNamespace, $sFilename = null) {
$this->_aPluginDetails[$sNamespace] = array($sClassName, $sNamespace, $sFilename);
+
+ $object = $sClassName.'|'.$sNamespace.'|'.$sFilename;
+ KTPlugin::registerPluginHelper($sNamespace, $sClassName, $sFilename, $object, 'general', 'plugin');
}
function &getPlugin($sNamespace) {
@@ -56,14 +66,21 @@ class KTPluginRegistry {
}
$aDetails = KTUtil::arrayGet($this->_aPluginDetails, $sNamespace);
if (empty($aDetails)) {
- return null;
+ // plugin hasn't been registered - check the DB
+// $query = "SELECT * FROM plugin_helper WHERE namespace = '{$sNamespace}'";
+// $plugin = DBUtil::getOneResult($query);
+// if(empty($plugin)){
+ return null;
+// }
+// $aDetails = explode('|', $plugin['object']);
}
$sFilename = $aDetails[2];
if (!empty($sFilename)) {
require_once($sFilename);
}
$sClassName = $aDetails[0];
- $oPlugin =new $sClassName($sFilename);
+ $oPlugin = new $sClassName($sFilename);
+
$this->_aPlugins[$sNamespace] =& $oPlugin;
return $oPlugin;
}
diff --git a/lib/plugins/pluginutil.inc.php b/lib/plugins/pluginutil.inc.php
index 3376b96..f1a936c 100644
--- a/lib/plugins/pluginutil.inc.php
+++ b/lib/plugins/pluginutil.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
+ *
* You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -69,7 +69,7 @@ class KTPluginUtil {
/**
* Store the plugin cache in the cache directory.
- *
+ * @deprecated
*/
static function savePluginCache($array)
{
@@ -97,7 +97,7 @@ class KTPluginUtil {
/**
* Remove the plugin cache.
- *
+ * @deprecated
*/
static function removePluginCache()
{
@@ -115,7 +115,7 @@ class KTPluginUtil {
/**
* Reads the plugin cache file. This must still be unserialised.
- *
+ * @deprecated
* @return mixed Returns false on failure, or the serialised cache.
*/
static function readPluginCache()
@@ -148,58 +148,213 @@ class KTPluginUtil {
return unserialize($cache);
}
- static function loadPlugins () {
+ /**
+ * Load the plugins for the current page
+ *
+ * @param unknown_type $sType
+ */
+ static function loadPlugins ($sType) {
- $GLOBALS['_KT_PLUGIN'] = array();
- $cache = KTPluginUtil::readPluginCache();
- if ($cache === false)
- {
- $aPlugins = KTPluginEntity::getList("disabled=0");
- KTPluginUtil::savePluginCache($aPlugins);
- }
- else
- {
- $aPlugins = $cache;
+ // Check the current page - can be extended.
+ // Currently we only distinguish between the dashboard and everything else.
+ if($sType != 'dashboard'){
+ $sType = 'general';
}
+ $GLOBALS['_KT_PLUGIN'] = array();
+
+ $aPlugins = array();
+ $aPluginHelpers = array();
- if (count($aPlugins) === 0) {
+ // Get the list of enabled plugins
+ $query = "SELECT * FROM plugin_helper h, plugins p
+ WHERE p.namespace = h.plugin AND p.disabled = 0 AND h.classtype='plugin'";
+ $aPluginHelpers = DBUtil::getResultArray($query);
+
+ // Check that there are plugins and if not, register them
+ if (empty($aPluginHelpers)) {
KTPluginUtil::registerPlugins();
+
+ $query = "SELECT * FROM plugin_helper h, plugins p
+ WHERE p.namespace = h.plugin AND p.disabled = 0 AND h.viewtype='{$sType}' AND h.classtype='plugin'";
+ $aPluginHelpers = DBUtil::getResultArray($query);
}
- $aPaths = array();
- $aPaths[] = KT_DIR . '/plugins/ktcore/KTCorePlugin.php';
- $aPaths[] = KT_DIR . '/plugins/ktcore/KTCoreLanguagePlugin.php';
- foreach ($aPlugins as $oPlugin) {
- if (!is_a($oPlugin, 'KTPluginEntity')) {
- print "
";
- print "loadPlugins()\n";
- var_dump($aPlugins);
- exit(0);
- }
- $sPath = $oPlugin->getPath();
- if (!KTUtil::isAbsolutePath($sPath)) {
- $sPath = sprintf("%s/%s", KT_DIR, $sPath);
- }
- $aPaths[] = $sPath;
- }
- $aPaths = array_unique($aPaths);
- foreach ($aPaths as $sPath) {
- if (file_exists($sPath)) {
- require_once($sPath);
+
+ // Create plugin objects
+ foreach ($aPluginHelpers as $aItem){
+ $classname = $aItem['classname'];
+ $path = $aItem['pathname'];
+
+ if (!empty($path)) {
+ require_once($path);
}
+
+ $oPlugin = new $classname($path);
+ $aPlugins[] = $oPlugin;
+ $oPlugin->load();
}
- $oRegistry =& KTPluginRegistry::getSingleton();
- $aPlugins =& $oRegistry->getPlugins();
- foreach ($aPlugins as $oPlugin) {
- if (!isset($aOrder[$oPlugin->iOrder])) {
- $aOrder[$oPlugin->iOrder] = array();
+
+ // load plugin helpers into global space
+ $query = "SELECT h.* FROM plugin_helper h, plugins p
+ WHERE p.namespace = h.plugin AND p.disabled = 0 ";//WHERE viewtype='{$sType}'";
+ $aPluginList = DBUtil::getResultArray($query);
+ KTPluginUtil::load($aPluginList);
+
+ // Load the template locations
+ $query = "SELECT * FROM plugin_helper h WHERE h.classtype='locations'";
+ $aLocations = DBUtil::getResultArray($query);
+ if(!empty($aLocations)){
+ $oTemplating =& KTTemplating::getSingleton();
+ foreach ($aLocations as $location){
+ $aParams = explode('|', $location['object']);
+ call_user_func_array(array(&$oTemplating, 'addLocation2'), $aParams);
}
- $aOrder[$oPlugin->iOrder][] = $oPlugin;
}
- ksort($aOrder, SORT_NUMERIC);
- foreach ($aOrder as $iOrder => $aOrderPlugins) {
- foreach ($aOrderPlugins as $oPlugin) {
- $oPlugin->load();
- }
+ return;
+ }
+
+ /**
+ * Load the plugins into the global space
+ *
+ * @param array $aPlugins
+ */
+ function load($aPlugins) {
+
+ require_once(KT_LIB_DIR . '/actions/actionregistry.inc.php');
+ require_once(KT_LIB_DIR . '/actions/portletregistry.inc.php');
+ require_once(KT_LIB_DIR . '/triggers/triggerregistry.inc.php');
+ require_once(KT_LIB_DIR . '/plugins/pageregistry.inc.php');
+ require_once(KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php');
+ require_once(KT_LIB_DIR . "/plugins/KTAdminNavigation.php");
+ require_once(KT_LIB_DIR . "/dashboard/dashletregistry.inc.php");
+ require_once(KT_LIB_DIR . "/i18n/i18nregistry.inc.php");
+ require_once(KT_LIB_DIR . "/help/help.inc.php");
+ require_once(KT_LIB_DIR . "/workflow/workflowutil.inc.php");
+ require_once(KT_LIB_DIR . "/widgets/widgetfactory.inc.php");
+ require_once(KT_LIB_DIR . "/validation/validatorfactory.inc.php");
+ require_once(KT_LIB_DIR . "/browse/columnregistry.inc.php");
+ require_once(KT_LIB_DIR . "/browse/criteriaregistry.php");
+ require_once(KT_LIB_DIR . "/authentication/interceptorregistry.inc.php");
+
+ $oPRegistry =& KTPortletRegistry::getSingleton();
+ $oTRegistry =& KTTriggerRegistry::getSingleton();
+ $oARegistry =& KTActionRegistry::getSingleton();
+ $oPageRegistry =& KTPageRegistry::getSingleton();
+ $oAPRegistry =& KTAuthenticationProviderRegistry::getSingleton();
+ $oAdminRegistry =& KTAdminNavigationRegistry::getSingleton();
+ $oDashletRegistry =& KTDashletRegistry::getSingleton();
+ $oi18nRegistry =& KTi18nRegistry::getSingleton();
+ $oKTHelpRegistry =& KTHelpRegistry::getSingleton();
+ $oWFTriggerRegistry =& KTWorkflowTriggerRegistry::getSingleton();
+ $oColumnRegistry =& KTColumnRegistry::getSingleton();
+ $oNotificationHandlerRegistry =& KTNotificationRegistry::getSingleton();
+ $oTemplating =& KTTemplating::getSingleton();
+ $oWidgetFactory =& KTWidgetFactory::getSingleton();
+ $oValidatorFactory =& KTValidatorFactory::getSingleton();
+ $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton();
+ $oInterceptorRegistry =& KTInterceptorRegistry::getSingleton();
+ $oKTPluginRegistry =& KTPluginRegistry::getSingleton();
+
+
+ // Loop through the loaded plugins and register them for access
+ foreach ($aPlugins as $plugin){
+ $sName = $plugin['namespace'];
+ $sParams = $plugin['object'];
+ $aParams = explode('|', $sParams);
+ $sClassType = $plugin['classtype'];
+
+ switch ($sClassType) {
+ case 'portlet':
+ $aLocation = explode('_|', $aParams[0]);
+ $aParams[0] = $aLocation;
+ call_user_func_array(array(&$oPRegistry, 'registerPortlet'), $aParams);
+ break;
+
+ case 'trigger':
+ call_user_func_array(array(&$oTRegistry, 'registerTrigger'), $aParams);
+ break;
+
+ case 'action':
+ call_user_func_array(array(&$oARegistry, 'registerAction'), $aParams);
+ break;
+
+ case 'page':
+ call_user_func_array(array(&$oPageRegistry, 'registerPage'), $aParams);
+ break;
+
+ case 'authentication_provider':
+ call_user_func_array(array(&$oAPRegistry, 'registerAuthenticationProvider'), $aParams);
+ break;
+
+ case 'admin_category':
+ call_user_func_array(array(&$oAdminRegistry, 'registerCategory'), $aParams);
+ break;
+
+ case 'admin_page':
+ call_user_func_array(array(&$oAdminRegistry, 'registerLocation'), $aParams);
+ break;
+
+ case 'dashlet':
+ call_user_func_array(array(&$oDashletRegistry, 'registerDashlet'), $aParams);
+ break;
+
+ case 'i18n':
+ call_user_func_array(array(&$oi18nRegistry, 'registeri18n'), $aParams);
+ break;
+
+ case 'i18nlang':
+ call_user_func_array(array(&$oi18nRegistry, 'registeri18nLang'), $aParams);
+ break;
+
+ case 'language':
+ call_user_func_array(array(&$oi18nRegistry, 'registerLanguage'), $aParams);
+ break;
+
+ case 'help_language':
+ call_user_func_array(array(&$oKTHelpRegistry, 'registerHelp'), $aParams);
+ break;
+
+ case 'workflow_trigger':
+ call_user_func_array(array(&$oWFTriggerRegistry, 'registerWorkflowTrigger'), $aParams);
+ break;
+
+ case 'column':
+ call_user_func_array(array(&$oColumnRegistry, 'registerColumn'), $aParams);
+ break;
+
+ case 'view':
+ call_user_func_array(array(&$oColumnRegistry, 'registerView'), $aParams);
+ break;
+
+ case 'notification_handler':
+ call_user_func_array(array(&$oNotificationHandlerRegistry, 'registerNotificationHandler'), $aParams);
+ break;
+
+ case 'template_location':
+ call_user_func_array(array(&$oTemplating, 'addLocation'), $aParams);
+ break;
+
+ case 'criterion':
+ $aInit = explode('_|', $aParams[3]);
+ $aParams[3] = $aInit;
+ call_user_func_array(array(&$oCriteriaRegistry, 'registerCriterion'), $aParams);
+ break;
+
+ case 'widget':
+ call_user_func_array(array(&$oWidgetFactory, 'registerWidget'), $aParams);
+ break;
+
+ case 'validator':
+ call_user_func_array(array(&$oValidatorFactory, 'registerValidator'), $aParams);
+ break;
+
+ case 'interceptor':
+ call_user_func_array(array(&$oInterceptorRegistry, 'registerInterceptor'), $aParams);
+ break;
+
+ case 'plugin':
+ $oKTPluginRegistry->_aPluginDetails[$sName] = $aParams;
+ break;
+ }
}
}
diff --git a/lib/templating/kt3template.inc.php b/lib/templating/kt3template.inc.php
index dc665c1..447395d 100644
--- a/lib/templating/kt3template.inc.php
+++ b/lib/templating/kt3template.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
+ *
* You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*
@@ -156,11 +156,17 @@ class KTPage {
// initiliase the menu.
function initMenu() {
- // FIXME: we lost the getDefaultAction stuff - do we care?
- // note that key == action. this is _important_, since we crossmatch the breadcrumbs against this for "active"
- $this->menu = array("dashboard" => $this->_actionHelper(array("name" => _kt("Dashboard"), "action" => "dashboard", "active" => 0)),
- "browse" => $this->_actionHelper(array("name" => _kt("Browse Documents"), "action" => "browse", "active" => 0)),
- "administration" => $this->_actionHelper(array("name" => _kt("DMS Administration"), "action" => "administration", "active" => 0)),);
+ // FIXME: we lost the getDefaultAction stuff - do we care?
+ // note that key == action. this is _important_, since we crossmatch the breadcrumbs against this for "active"
+ $this->menu = array();
+ $this->menu['dashboard'] = array('label' => _kt("Dashboard"), 'url' => 'dashboard.php');
+ $this->menu['browse'] = array('label' => _kt("Browse Documents"), 'url' => 'browse.php');
+ $this->menu['administration'] = array('label' => _kt("DMS Administration"), 'url' => 'admin.php');
+ /*
+ $this->menu = array("dashboard" => $this->_actionHelper(array("name" => _kt("Dashboard"), "action" => "dashboard", "active" => 0)),
+ "browse" => $this->_actionHelper(array("name" => _kt("Browse Documents"), "action" => "browse", "active" => 0)),
+ "administration" => $this->_actionHelper(array("name" => _kt("DMS Administration"), "action" => "administration", "active" => 0)),);
+ */
}
diff --git a/lib/templating/templating.inc.php b/lib/templating/templating.inc.php
index 1d86cd0..7b8861b 100644
--- a/lib/templating/templating.inc.php
+++ b/lib/templating/templating.inc.php
@@ -7,32 +7,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
+ *
* You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*/
@@ -121,11 +121,28 @@ class KTTemplating {
// }}}
// {{{ addLocation
+ /**
+ * Register a new location in the database
+ *
+ * @param unknown_type $descr
+ * @param unknown_type $loc
+ */
function addLocation ($descr, $loc) {
$this->aLocationRegistry[$descr] = $loc;
+ KTPlugin::registerPluginHelper($descr, $descr, $loc, $descr.'|'.$loc, 'general', 'locations');
}
// }}}
+ /**
+ * Add the template location to the location registry
+ *
+ * @param unknown_type $descr
+ * @param unknown_type $loc
+ */
+ function addLocation2 ($descr, $loc) {
+ $this->aLocationRegistry[$descr] = $loc;
+ }
+
// {{{ getSingleton
static function &getSingleton () {
if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTTemplating')) {
diff --git a/sql/mysql/install/structure.sql b/sql/mysql/install/structure.sql
index 747b7d1..d3d6a7c 100644
--- a/sql/mysql/install/structure.sql
+++ b/sql/mysql/install/structure.sql
@@ -1238,6 +1238,27 @@ CREATE TABLE `plugins` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
+-- Table structure for table `plugin_helper`
+--
+
+CREATE TABLE `plugin_helper` (
+ `id` INT NOT NULL default '0',
+ `namespace` VARCHAR(120) NOT NULL,
+ `plugin` VARCHAR(120) NOT NULL,
+ `classname` VARCHAR(120),
+ `pathname` VARCHAR(255),
+ `object` VARCHAR(1000) NOT NULL,
+ `classtype` VARCHAR(120) NOT NULL,
+ `viewtype` ENUM('general', 'dashboard', 'plugin', 'folder', 'document', 'admindispatcher', 'dispatcher') NOT NULL default 'general',
+ PRIMARY KEY (`id`),
+ KEY `name` (`namespace`),
+ KEY `parent` (`plugin`),
+ KEY `view` (`viewtype`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
-- Table structure for table `role_allocations`
--
@@ -2263,6 +2284,17 @@ CREATE TABLE `zseq_plugins` (
) ENGINE=MyISAM AUTO_INCREMENT=82 DEFAULT CHARSET=latin1;
--
+-- Table structure for table `zseq_plugin_helper`
+--
+
+CREATE TABLE `zseq_plugin_helper` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
-- Table structure for table `zseq_role_allocations`
--