Commit 410fdf0aa7be7a9d69b0d4e26acd30c796564b8f

Authored by Conrad Vermeulen
1 parent c0d8b29c

KTS-1753

" Implement Disk Usage Plugin"
Implemented.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7358 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 63 additions and 50 deletions
lib/plugins/plugin.inc.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * License Version 1.1.2 ("License"); You may not use this file except in 6 * License Version 1.1.2 ("License"); You may not use this file except in
7 * compliance with the License. You may obtain a copy of the License at 7 * compliance with the License. You may obtain a copy of the License at
8 * http://www.knowledgetree.com/KPL 8 * http://www.knowledgetree.com/KPL
9 - * 9 + *
10 * Software distributed under the License is distributed on an "AS IS" 10 * Software distributed under the License is distributed on an "AS IS"
11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
12 * See the License for the specific language governing rights and 12 * See the License for the specific language governing rights and
@@ -17,9 +17,9 @@ @@ -17,9 +17,9 @@
17 * (ii) the KnowledgeTree copyright notice 17 * (ii) the KnowledgeTree copyright notice
18 * in the same form as they appear in the distribution. See the License for 18 * in the same form as they appear in the distribution. See the License for
19 * requirements. 19 * requirements.
20 - * 20 + *
21 * The Original Code is: KnowledgeTree Open Source 21 * The Original Code is: KnowledgeTree Open Source
22 - * 22 + *
23 * The Initial Developer of the Original Code is The Jam Warehouse Software 23 * The Initial Developer of the Original Code is The Jam Warehouse Software
24 * (Pty) Ltd, trading as KnowledgeTree. 24 * (Pty) Ltd, trading as KnowledgeTree.
25 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright 25 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
@@ -39,9 +39,9 @@ class KTPlugin { @@ -39,9 +39,9 @@ class KTPlugin {
39 var $iOrder = 0; 39 var $iOrder = 0;
40 var $sFriendlyName = null; 40 var $sFriendlyName = null;
41 var $sSQLDir = null; 41 var $sSQLDir = null;
42 - 42 +
43 var $autoRegister = false; 43 var $autoRegister = false;
44 - 44 +
45 var $_aPortlets = array(); 45 var $_aPortlets = array();
46 var $_aTriggers = array(); 46 var $_aTriggers = array();
47 var $_aActions = array(); 47 var $_aActions = array();
@@ -55,14 +55,14 @@ class KTPlugin { @@ -55,14 +55,14 @@ class KTPlugin {
55 var $_aLanguage = array(); 55 var $_aLanguage = array();
56 var $_aHelpLanguage = array(); 56 var $_aHelpLanguage = array();
57 var $_aWFTriggers = array(); 57 var $_aWFTriggers = array();
58 - var $_aColumns = array();  
59 - var $_aViews = array();  
60 - var $_aNotificationHandlers = array();  
61 - var $_aTemplateLocations = array();  
62 - var $_aWidgets = array();  
63 - var $_aValidators = array();  
64 - var $_aCriteria = array();  
65 - var $_aInterceptors = array(); 58 + var $_aColumns = array();
  59 + var $_aViews = array();
  60 + var $_aNotificationHandlers = array();
  61 + var $_aTemplateLocations = array();
  62 + var $_aWidgets = array();
  63 + var $_aValidators = array();
  64 + var $_aCriteria = array();
  65 + var $_aInterceptors = array();
66 66
67 function KTPlugin($sFilename = null) { 67 function KTPlugin($sFilename = null) {
68 $this->sFilename = $sFilename; 68 $this->sFilename = $sFilename;
@@ -92,7 +92,7 @@ class KTPlugin { @@ -92,7 +92,7 @@ class KTPlugin {
92 $sWebPath = sprintf("%s/%s", $this->sNamespace, $sWebPath); 92 $sWebPath = sprintf("%s/%s", $this->sNamespace, $sWebPath);
93 $this->_aPages[$sWebPath] = array($sWebPath, $sPageClassName, $sFilename, $this->sNamespace); 93 $this->_aPages[$sWebPath] = array($sWebPath, $sPageClassName, $sFilename, $this->sNamespace);
94 } 94 }
95 - 95 +
96 function registerWorkflowTrigger($sNamespace, $sTriggerClassName, $sFilename = null) { 96 function registerWorkflowTrigger($sNamespace, $sTriggerClassName, $sFilename = null) {
97 $sFilename = $this->_fixFilename($sFilename); 97 $sFilename = $this->_fixFilename($sFilename);
98 $this->_aWFTriggers[$sNamespace] = array($sNamespace, $sTriggerClassName, $sFilename); 98 $this->_aWFTriggers[$sNamespace] = array($sNamespace, $sTriggerClassName, $sFilename);
@@ -126,7 +126,7 @@ class KTPlugin { @@ -126,7 +126,7 @@ class KTPlugin {
126 function registerAdminCategory($sPath, $sName, $sDescription) { 126 function registerAdminCategory($sPath, $sName, $sDescription) {
127 $this->_aAdminCategories[$sPath] = array($sPath, $sName, $sDescription); 127 $this->_aAdminCategories[$sPath] = array($sPath, $sName, $sDescription);
128 } 128 }
129 - 129 +
130 function registerDashlet($sClassName, $sNamespace, $sFilename) { 130 function registerDashlet($sClassName, $sNamespace, $sFilename) {
131 $sFilename = $this->_fixFilename($sFilename); 131 $sFilename = $this->_fixFilename($sFilename);
132 $this->_aDashlets[$sNamespace] = array($sClassName, $sNamespace, $sFilename, $this->sNamespace); 132 $this->_aDashlets[$sNamespace] = array($sClassName, $sNamespace, $sFilename, $this->sNamespace);
@@ -147,36 +147,36 @@ class KTPlugin { @@ -147,36 +147,36 @@ class KTPlugin {
147 function registerLanguage($sLanguage, $sLanguageName) { 147 function registerLanguage($sLanguage, $sLanguageName) {
148 $this->_aLanguage[$sLanguage] = array($sLanguage, $sLanguageName); 148 $this->_aLanguage[$sLanguage] = array($sLanguage, $sLanguageName);
149 } 149 }
150 - 150 +
151 function registerHelpLanguage($sPlugin, $sLanguage, $sBasedir) { 151 function registerHelpLanguage($sPlugin, $sLanguage, $sBasedir) {
152 $this->_aHelpLanguage[$sLanguage] = array($sPlugin, $sLanguage, $sBasedir); 152 $this->_aHelpLanguage[$sLanguage] = array($sPlugin, $sLanguage, $sBasedir);
153 } 153 }
154 - 154 +
155 function registerColumn($sName, $sNamespace, $sClassName, $sFile) { 155 function registerColumn($sName, $sNamespace, $sClassName, $sFile) {
156 $sFile = $this->_fixFilename($sFile); 156 $sFile = $this->_fixFilename($sFile);
157 $this->_aColumns[$sNamespace] = array($sName, $sNamespace, $sClassName, $sFile); 157 $this->_aColumns[$sNamespace] = array($sName, $sNamespace, $sClassName, $sFile);
158 - }  
159 - 158 + }
  159 +
160 function registerView($sName, $sNamespace) { 160 function registerView($sName, $sNamespace) {
161 $this->_aViews[$sNamespace] = array($sName, $sNamespace); 161 $this->_aViews[$sNamespace] = array($sName, $sNamespace);
162 - } 162 + }
163 163
164 function registerNotificationHandler($sName, $sNamespace, $sPath) { 164 function registerNotificationHandler($sName, $sNamespace, $sPath) {
165 $sPath = $this->_fixFilename($sPath); 165 $sPath = $this->_fixFilename($sPath);
166 $this->_aNotificationHandlers[$sNamespace] = array($sNamespace, $sName, $sPath); 166 $this->_aNotificationHandlers[$sNamespace] = array($sNamespace, $sName, $sPath);
167 - } 167 + }
168 168
169 function registerTemplateLocation($sName, $sPath) { 169 function registerTemplateLocation($sName, $sPath) {
170 $sPath = $this->_fixFilename($sPath); 170 $sPath = $this->_fixFilename($sPath);
171 $this->_aTemplateLocations[$sName] = array($sName, $sPath); 171 $this->_aTemplateLocations[$sName] = array($sName, $sPath);
172 - } 172 + }
  173 +
173 174
174 -  
175 function registerWidget($sClassname, $sNamespace, $sPath) { 175 function registerWidget($sClassname, $sNamespace, $sPath) {
176 $sPath = $this->_fixFilename($sPath); 176 $sPath = $this->_fixFilename($sPath);
177 $this->_aWidgets[$sNamespace] = array($sClassname, $sNamespace, $sPath); 177 $this->_aWidgets[$sNamespace] = array($sClassname, $sNamespace, $sPath);
178 } 178 }
179 - 179 +
180 function registerValidator($sClassname, $sNamespace, $sPath) { 180 function registerValidator($sClassname, $sNamespace, $sPath) {
181 $sPath = $this->_fixFilename($sPath); 181 $sPath = $this->_fixFilename($sPath);
182 $this->_aValidators[$sNamespace] = array($sClassname, $sNamespace, $sPath); 182 $this->_aValidators[$sNamespace] = array($sClassname, $sNamespace, $sPath);
@@ -245,15 +245,15 @@ class KTPlugin { @@ -245,15 +245,15 @@ class KTPlugin {
245 require_once(KT_LIB_DIR . '/triggers/triggerregistry.inc.php'); 245 require_once(KT_LIB_DIR . '/triggers/triggerregistry.inc.php');
246 require_once(KT_LIB_DIR . '/plugins/pageregistry.inc.php'); 246 require_once(KT_LIB_DIR . '/plugins/pageregistry.inc.php');
247 require_once(KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php'); 247 require_once(KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php');
248 - require_once(KT_LIB_DIR . "/plugins/KTAdminNavigation.php");  
249 - require_once(KT_LIB_DIR . "/dashboard/dashletregistry.inc.php");  
250 - require_once(KT_LIB_DIR . "/i18n/i18nregistry.inc.php"); 248 + require_once(KT_LIB_DIR . "/plugins/KTAdminNavigation.php");
  249 + require_once(KT_LIB_DIR . "/dashboard/dashletregistry.inc.php");
  250 + require_once(KT_LIB_DIR . "/i18n/i18nregistry.inc.php");
251 require_once(KT_LIB_DIR . "/help/help.inc.php"); 251 require_once(KT_LIB_DIR . "/help/help.inc.php");
252 require_once(KT_LIB_DIR . "/workflow/workflowutil.inc.php"); 252 require_once(KT_LIB_DIR . "/workflow/workflowutil.inc.php");
253 - require_once(KT_LIB_DIR . "/widgets/widgetfactory.inc.php");  
254 - require_once(KT_LIB_DIR . "/validation/validatorfactory.inc.php");  
255 - require_once(KT_LIB_DIR . "/browse/columnregistry.inc.php");  
256 - require_once(KT_LIB_DIR . "/browse/criteriaregistry.php"); 253 + require_once(KT_LIB_DIR . "/widgets/widgetfactory.inc.php");
  254 + require_once(KT_LIB_DIR . "/validation/validatorfactory.inc.php");
  255 + require_once(KT_LIB_DIR . "/browse/columnregistry.inc.php");
  256 + require_once(KT_LIB_DIR . "/browse/criteriaregistry.php");
257 require_once(KT_LIB_DIR . "/authentication/interceptorregistry.inc.php"); 257 require_once(KT_LIB_DIR . "/authentication/interceptorregistry.inc.php");
258 258
259 $oPRegistry =& KTPortletRegistry::getSingleton(); 259 $oPRegistry =& KTPortletRegistry::getSingleton();
@@ -261,16 +261,16 @@ class KTPlugin { @@ -261,16 +261,16 @@ class KTPlugin {
261 $oARegistry =& KTActionRegistry::getSingleton(); 261 $oARegistry =& KTActionRegistry::getSingleton();
262 $oPageRegistry =& KTPageRegistry::getSingleton(); 262 $oPageRegistry =& KTPageRegistry::getSingleton();
263 $oAPRegistry =& KTAuthenticationProviderRegistry::getSingleton(); 263 $oAPRegistry =& KTAuthenticationProviderRegistry::getSingleton();
264 - $oAdminRegistry =& KTAdminNavigationRegistry::getSingleton(); 264 + $oAdminRegistry =& KTAdminNavigationRegistry::getSingleton();
265 $oDashletRegistry =& KTDashletRegistry::getSingleton(); 265 $oDashletRegistry =& KTDashletRegistry::getSingleton();
266 $oi18nRegistry =& KTi18nRegistry::getSingleton(); 266 $oi18nRegistry =& KTi18nRegistry::getSingleton();
267 $oKTHelpRegistry =& KTHelpRegistry::getSingleton(); 267 $oKTHelpRegistry =& KTHelpRegistry::getSingleton();
268 $oWFTriggerRegistry =& KTWorkflowTriggerRegistry::getSingleton(); 268 $oWFTriggerRegistry =& KTWorkflowTriggerRegistry::getSingleton();
269 - $oColumnRegistry =& KTColumnRegistry::getSingleton(); 269 + $oColumnRegistry =& KTColumnRegistry::getSingleton();
270 $oNotificationHandlerRegistry =& KTNotificationRegistry::getSingleton(); 270 $oNotificationHandlerRegistry =& KTNotificationRegistry::getSingleton();
271 $oTemplating =& KTTemplating::getSingleton(); 271 $oTemplating =& KTTemplating::getSingleton();
272 $oWidgetFactory =& KTWidgetFactory::getSingleton(); 272 $oWidgetFactory =& KTWidgetFactory::getSingleton();
273 - $oValidatorFactory =& KTValidatorFactory::getSingleton(); 273 + $oValidatorFactory =& KTValidatorFactory::getSingleton();
274 $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton(); 274 $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton();
275 $oInterceptorRegistry =& KTInterceptorRegistry::getSingleton(); 275 $oInterceptorRegistry =& KTInterceptorRegistry::getSingleton();
276 276
@@ -301,7 +301,7 @@ class KTPlugin { @@ -301,7 +301,7 @@ class KTPlugin {
301 foreach ($this->_aAdminPages as $k => $v) { 301 foreach ($this->_aAdminPages as $k => $v) {
302 call_user_func_array(array(&$oAdminRegistry, 'registerLocation'), $v); 302 call_user_func_array(array(&$oAdminRegistry, 'registerLocation'), $v);
303 } 303 }
304 - 304 +
305 foreach ($this->_aDashlets as $k => $v) { 305 foreach ($this->_aDashlets as $k => $v) {
306 call_user_func_array(array(&$oDashletRegistry, 'registerDashlet'), $v); 306 call_user_func_array(array(&$oDashletRegistry, 'registerDashlet'), $v);
307 } 307 }
@@ -317,38 +317,38 @@ class KTPlugin { @@ -317,38 +317,38 @@ class KTPlugin {
317 foreach ($this->_aLanguage as $k => $v) { 317 foreach ($this->_aLanguage as $k => $v) {
318 call_user_func_array(array(&$oi18nRegistry, 'registerLanguage'), $v); 318 call_user_func_array(array(&$oi18nRegistry, 'registerLanguage'), $v);
319 } 319 }
320 - 320 +
321 foreach ($this->_aHelpLanguage as $k => $v) { 321 foreach ($this->_aHelpLanguage as $k => $v) {
322 call_user_func_array(array(&$oKTHelpRegistry, 'registerHelp'), $v); 322 call_user_func_array(array(&$oKTHelpRegistry, 'registerHelp'), $v);
323 } 323 }
324 - 324 +
325 foreach ($this->_aWFTriggers as $k => $v) { 325 foreach ($this->_aWFTriggers as $k => $v) {
326 call_user_func_array(array(&$oWFTriggerRegistry, 'registerWorkflowTrigger'), $v); 326 call_user_func_array(array(&$oWFTriggerRegistry, 'registerWorkflowTrigger'), $v);
327 } 327 }
328 - 328 +
329 foreach ($this->_aColumns as $k => $v) { 329 foreach ($this->_aColumns as $k => $v) {
330 call_user_func_array(array(&$oColumnRegistry, 'registerColumn'), $v); 330 call_user_func_array(array(&$oColumnRegistry, 'registerColumn'), $v);
331 - }  
332 - 331 + }
  332 +
333 foreach ($this->_aViews as $k => $v) { 333 foreach ($this->_aViews as $k => $v) {
334 call_user_func_array(array(&$oColumnRegistry, 'registerView'), $v); 334 call_user_func_array(array(&$oColumnRegistry, 'registerView'), $v);
335 - } 335 + }
336 336
337 foreach ($this->_aNotificationHandlers as $k => $v) { 337 foreach ($this->_aNotificationHandlers as $k => $v) {
338 call_user_func_array(array(&$oNotificationHandlerRegistry, 'registerNotificationHandler'), $v); 338 call_user_func_array(array(&$oNotificationHandlerRegistry, 'registerNotificationHandler'), $v);
339 - } 339 + }
340 340
341 foreach ($this->_aTemplateLocations as $k => $v) { 341 foreach ($this->_aTemplateLocations as $k => $v) {
342 call_user_func_array(array(&$oTemplating, 'addLocation'), $v); 342 call_user_func_array(array(&$oTemplating, 'addLocation'), $v);
343 - } 343 + }
344 344
345 foreach ($this->_aCriteria as $k => $v) { 345 foreach ($this->_aCriteria as $k => $v) {
346 call_user_func_array(array(&$oCriteriaRegistry, 'registerCriterion'), $v); 346 call_user_func_array(array(&$oCriteriaRegistry, 'registerCriterion'), $v);
347 - }  
348 - 347 + }
  348 +
349 foreach ($this->_aWidgets as $k => $v) { 349 foreach ($this->_aWidgets as $k => $v) {
350 call_user_func_array(array(&$oWidgetFactory, 'registerWidget'), $v); 350 call_user_func_array(array(&$oWidgetFactory, 'registerWidget'), $v);
351 - } 351 + }
352 352
353 foreach ($this->_aValidators as $k => $v) { 353 foreach ($this->_aValidators as $k => $v) {
354 call_user_func_array(array(&$oValidatorFactory, 'registerValidator'), $v); 354 call_user_func_array(array(&$oValidatorFactory, 'registerValidator'), $v);
@@ -369,9 +369,9 @@ class KTPlugin { @@ -369,9 +369,9 @@ class KTPlugin {
369 } 369 }
370 return $sFilename; 370 return $sFilename;
371 } 371 }
372 - 372 +
373 function upgradePlugin($iStart, $iEnd) { 373 function upgradePlugin($iStart, $iEnd) {
374 - if (is_null($this->sSQLDir)) { 374 + if (is_null($this->sSQLDir)) {
375 return $iEnd; // no db changes, must reach the "end". 375 return $iEnd; // no db changes, must reach the "end".
376 } 376 }
377 global $default; 377 global $default;
@@ -382,7 +382,7 @@ class KTPlugin { @@ -382,7 +382,7 @@ class KTPlugin {
382 if (!file_exists($sqlfile)) { 382 if (!file_exists($sqlfile)) {
383 continue; // skip it. 383 continue; // skip it.
384 } 384 }
385 - $queries = SQLFile::sqlFromFile($sqlfile); 385 + $queries = SQLFile::sqlFromFile($sqlfile);
386 $res = DBUtil::runQueries($queries, $default->_admindb); 386 $res = DBUtil::runQueries($queries, $default->_admindb);
387 387
388 if (PEAR::isError($res)) { 388 if (PEAR::isError($res)) {
@@ -415,7 +415,7 @@ class KTPlugin { @@ -415,7 +415,7 @@ class KTPlugin {
415 'friendlyname' => $friendly_name, 415 'friendlyname' => $friendly_name,
416 )); 416 ));
417 // FIXME we -really- need to raise an error here, somehow. 417 // FIXME we -really- need to raise an error here, somehow.
418 - return $oEntity; 418 + return $oEntity;
419 } else { 419 } else {
420 $oEntity->updateFromArray(array( 420 $oEntity->updateFromArray(array(
421 'path' => $this->stripKtDir($this->sFilename), 421 'path' => $this->stripKtDir($this->sFilename),
@@ -442,5 +442,18 @@ class KTPlugin { @@ -442,5 +442,18 @@ class KTPlugin {
442 } 442 }
443 return true; 443 return true;
444 } 444 }
  445 +
  446 + function getURLPath($filename = null)
  447 + {
  448 + $config = KTConfig::getSingleton();
  449 + $dir = $config->get('KnowledgeTree/fileSystemRoot');
  450 +
  451 + $path = substr(dirname($this->sFilename), strlen($dir));
  452 + if (!is_null($filename))
  453 + {
  454 + $path .= '/' . $filename;
  455 + }
  456 + return $path;
  457 + }
445 } 458 }
446 459