plugin.inc.php
4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
class KTPlugin {
var $sNamespace;
var $sFilename = null;
var $_aPortlets = array();
var $_aTriggers = array();
var $_aActions = array();
var $_aPages = array();
var $_aAuthenticationProviders = array();
var $_aAdminCategories = array();
var $_aAdminPages = array();
function KTPlugin($sFilename = null) {
$this->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->sNamespace);
}
function registerTrigger($sAction, $sStage, $sTriggerClassName, $sTriggerNamespace, $sFilename = null) {
$sFilename = $this->_fixFilename($sFilename);
$this->_aTriggers[$sTriggerNamespace] = array($sAction, $sStage, $sTriggerClassName, $sTriggerNamespace, $sFilename, $this->sNamespace);
}
function registerAction($sActionType, $sActionClassName, $sActionNamespace, $sFilename = null) {
$sFilename = $this->_fixFilename($sFilename);
$this->_aActions[$sActionNamespace] = array($sActionType, $sActionClassName, $sActionNamespace, $sFilename, $this->sNamespace);
}
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);
}
function getPagePath($sPath) {
return sprintf('/plugin.php/%s/%s', $this->sNamespace, $sPath);
}
function registerAuthenticationProvider($sClass, $sNamespace, $sFilename = null) {
$sFilename = $this->_fixFilename($sFilename);
$this->_aAuthenticationProviders[$sNamespace] = array($sClass, $sNamespace, $sFilename, $this->sNamespace);
}
//registerLocation($sName, $sClass, $sCategory, $sTitle, $sDescription, $sDispatcherFilePath = null, $sURL = null)
function registerAdminPage($sName, $sClass, $sCategory, $sTitle, $sDescription, $sFilename) {
$sFullname = $sCategory . '/' . $sName;
$sFilename = $this->_fixFilename($sFilename);
$this->_aAdminPages[$sFullname] = array($sName, $sClass, $sCategory, $sTitle, $sDescription, $sFilename, null, $this->sNamespace);
}
function registerAdminCategories($sPath, $sName, $sDescription) {
$this->_aAdminCategories[$sPath] = array($sPath, $sName, $sDescription);
}
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');
require_once(KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php');
require_once(KT_LIB_DIR . "/plugins/KTAdminNavigation.php");
$oPRegistry =& KTPortletRegistry::getSingleton();
$oTRegistry =& KTTriggerRegistry::getSingleton();
$oARegistry =& KTActionRegistry::getSingleton();
$oPageRegistry =& KTPageRegistry::getSingleton();
$oAPRegistry =& KTAuthenticationProviderRegistry::getSingleton();
$oAdminRegistry =& KTAdminNavigationRegistry::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);
}
foreach ($this->_aAuthenticationProviders as $k => $v) {
call_user_func_array(array(&$oAPRegistry, 'registerAuthenticationProvider'), $v);
}
foreach ($this->_aAdminCategories as $k => $v) {
call_user_func_array(array(&$oAdminRegistry, 'registerCategory'), $v);
}
foreach ($this->_aAdminPages as $k => $v) {
call_user_func_array(array(&$oAdminRegistry, 'registerLocation'), $v);
}
}
}