diff --git a/lib/plugins/plugin.inc.php b/lib/plugins/plugin.inc.php new file mode 100644 index 0000000..143c572 --- /dev/null +++ b/lib/plugins/plugin.inc.php @@ -0,0 +1,84 @@ +sFilename = $sFilename; + } + + function setFilename($sFilename) { + $this->sFilename = $sFilename; + } + + function registerPortlet($aLocation, $sPortletClassName, $sPortletNamespace, $sFilename = null) { + $sFilename = $this->_fixFilename($sFilename); + $this->_aPortlets[$sPortletNamespace] = array($aLocation, $sPortletClassName, $sPortletNamespace, $sFilename, &$this); + } + + function registerTrigger($sAction, $sStage, $sTriggerClassName, $sTriggerNamespace, $sFilename = null) { + $sFilename = $this->_fixFilename($sFilename); + $this->_aTriggers[$sTriggerNamespace] = array($sAction, $sStage, $sTriggerClassName, $sTriggerNamespace, $sFilename, &$this); + } + + function registerAction($sActionType, $sActionClassName, $sActionNamespace, $sFilename = null) { + $sFilename = $this->_fixFilename($sFilename); + $this->_aActions[$sActionNamespace] = array($sActionType, $sActionClassName, $sActionNamespace, $sFilename, &$this); + } + + 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); + } + + function getPagePath($sPath) { + return sprintf('/plugin.php/%s/%s', $this->sNamespace, $sPath); + } + + function _fixFilename($sFilename) { + if (empty($sFilename)) { + $sFilename = $this->sFilename; + } else if (substr($sFilename, 0, 1) != '/') { + if ($this->sFilename) { + $sDirPath = dirname($this->sFilename); + $sFilename = sprintf("%s/%s", $sDirPath, $sFilename); + } + } + return $sFilename; + } + + function register() { + 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'); + + $oPRegistry =& KTPortletRegistry::getSingleton(); + $oTRegistry =& KTTriggerRegistry::getSingleton(); + $oARegistry =& KTActionRegistry::getSingleton(); + $oPageRegistry =& KTPageRegistry::getSingleton(); + + foreach ($this->_aPortlets as $k => $v) { + call_user_func_array(array(&$oPRegistry, 'registerPortlet'), $v); + } + + foreach ($this->_aTriggers as $k => $v) { + call_user_func_array(array(&$oTRegistry, 'registerTrigger'), $v); + } + + foreach ($this->_aActions as $k => $v) { + call_user_func_array(array(&$oARegistry, 'registerAction'), $v); + } + + foreach ($this->_aPages as $k => $v) { + call_user_func_array(array(&$oPageRegistry, 'registerPage'), $v); + } + } +} +