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