Commit 8303862943e54679c8fe54dd9790ba01d584136f
1 parent
ec6094fe
KTS-2358
"php5 migration" Updated. Removed & from &new. Added statics. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7171 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
38 additions
and
34 deletions
lib/browse/columnregistry.inc.php
| @@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
| 8 | * compliance with the License. You may obtain a copy of the License at | 8 | * compliance with the License. You may obtain a copy of the License at |
| 9 | * http://www.knowledgetree.com/KPL | 9 | * http://www.knowledgetree.com/KPL |
| 10 | - * | 10 | + * |
| 11 | * Software distributed under the License is distributed on an "AS IS" | 11 | * Software distributed under the License is distributed on an "AS IS" |
| 12 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | 12 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing rights and | 13 | * See the License for the specific language governing rights and |
| @@ -18,9 +18,9 @@ | @@ -18,9 +18,9 @@ | ||
| 18 | * (ii) the KnowledgeTree copyright notice | 18 | * (ii) the KnowledgeTree copyright notice |
| 19 | * in the same form as they appear in the distribution. See the License for | 19 | * in the same form as they appear in the distribution. See the License for |
| 20 | * requirements. | 20 | * requirements. |
| 21 | - * | 21 | + * |
| 22 | * The Original Code is: KnowledgeTree Open Source | 22 | * The Original Code is: KnowledgeTree Open Source |
| 23 | - * | 23 | + * |
| 24 | * The Initial Developer of the Original Code is The Jam Warehouse Software | 24 | * The Initial Developer of the Original Code is The Jam Warehouse Software |
| 25 | * (Pty) Ltd, trading as KnowledgeTree. | 25 | * (Pty) Ltd, trading as KnowledgeTree. |
| 26 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | 26 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright |
| @@ -36,11 +36,13 @@ class KTColumnRegistry { | @@ -36,11 +36,13 @@ class KTColumnRegistry { | ||
| 36 | var $columns = array(); | 36 | var $columns = array(); |
| 37 | var $views = array(); // should be in here | 37 | var $views = array(); // should be in here |
| 38 | // {{{ getSingleton | 38 | // {{{ getSingleton |
| 39 | - function &getSingleton () { | ||
| 40 | - if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTColumnRegistry')) { | ||
| 41 | - $GLOBALS['_KT_PLUGIN']['oKTColumnRegistry'] =& new KTColumnRegistry; | ||
| 42 | - } | ||
| 43 | - return $GLOBALS['_KT_PLUGIN']['oKTColumnRegistry']; | 39 | + static function &getSingleton () { |
| 40 | + static $singleton = null; | ||
| 41 | + if (is_null($singleton)) | ||
| 42 | + { | ||
| 43 | + $singleton = new KTColumnRegistry; | ||
| 44 | + } | ||
| 45 | + return $singleton; | ||
| 44 | } | 46 | } |
| 45 | // }}} | 47 | // }}} |
| 46 | 48 | ||
| @@ -49,55 +51,55 @@ class KTColumnRegistry { | @@ -49,55 +51,55 @@ class KTColumnRegistry { | ||
| 49 | 'name' => $sName, | 51 | 'name' => $sName, |
| 50 | 'namespace' => $sNamespace, | 52 | 'namespace' => $sNamespace, |
| 51 | 'class' => $sClass, | 53 | 'class' => $sClass, |
| 52 | - 'file' => $sFile | 54 | + 'file' => $sFile |
| 53 | ); | 55 | ); |
| 54 | } | 56 | } |
| 55 | - | 57 | + |
| 56 | function getViewName($sNamespace) { return KTUtil::arrayGet($this->views, $sNamespace); } | 58 | function getViewName($sNamespace) { return KTUtil::arrayGet($this->views, $sNamespace); } |
| 57 | function getViews() { return $this->views; } | 59 | function getViews() { return $this->views; } |
| 58 | function getColumns() { return $this->columns; } | 60 | function getColumns() { return $this->columns; } |
| 59 | function registerView($sName, $sNamespace) { $this->views[$sNamespace] = $sName; } | 61 | function registerView($sName, $sNamespace) { $this->views[$sNamespace] = $sName; } |
| 60 | - | 62 | + |
| 61 | function getColumnInfo($sNamespace) { | 63 | function getColumnInfo($sNamespace) { |
| 62 | return KTUtil::arrayGet($this->columns, $sNamespace, null); | 64 | return KTUtil::arrayGet($this->columns, $sNamespace, null); |
| 63 | - } | ||
| 64 | - | 65 | + } |
| 66 | + | ||
| 65 | function getColumn($sNamespace) { | 67 | function getColumn($sNamespace) { |
| 66 | $aInfo = $this->getColumnInfo($sNamespace); | 68 | $aInfo = $this->getColumnInfo($sNamespace); |
| 67 | if (empty($aInfo)) { | 69 | if (empty($aInfo)) { |
| 68 | return PEAR::raiseError(sprintf(_kt("No such column: %s"), $sNamespace)); | 70 | return PEAR::raiseError(sprintf(_kt("No such column: %s"), $sNamespace)); |
| 69 | - } | ||
| 70 | - | 71 | + } |
| 72 | + | ||
| 71 | require_once($aInfo['file']); | 73 | require_once($aInfo['file']); |
| 72 | 74 | ||
| 73 | return new $aInfo['class']; | 75 | return new $aInfo['class']; |
| 74 | } | 76 | } |
| 75 | - | 77 | + |
| 76 | function getColumnsForView($sViewNamespace) { | 78 | function getColumnsForView($sViewNamespace) { |
| 77 | $view_entry = KTUtil::arrayGet($this->views, $sViewNamespace); | 79 | $view_entry = KTUtil::arrayGet($this->views, $sViewNamespace); |
| 78 | if (is_null($view_entry)) { | 80 | if (is_null($view_entry)) { |
| 79 | return PEAR::raiseError(sprintf(_kt("No such view: %s"), $sViewNamespace)); | 81 | return PEAR::raiseError(sprintf(_kt("No such view: %s"), $sViewNamespace)); |
| 80 | - } | ||
| 81 | - | 82 | + } |
| 83 | + | ||
| 82 | $view_column_entries = KTColumnEntry::getByView($sViewNamespace); | 84 | $view_column_entries = KTColumnEntry::getByView($sViewNamespace); |
| 83 | - if (PEAR::isError($view_column_entries)) { | ||
| 84 | - return $view_column_entries; | 85 | + if (PEAR::isError($view_column_entries)) { |
| 86 | + return $view_column_entries; | ||
| 85 | } | 87 | } |
| 86 | - | 88 | + |
| 87 | $view_columns = array(); | 89 | $view_columns = array(); |
| 88 | foreach ($view_column_entries as $oEntry) { | 90 | foreach ($view_column_entries as $oEntry) { |
| 89 | $res = $this->getColumn($oEntry->getColumnNamespace()); | 91 | $res = $this->getColumn($oEntry->getColumnNamespace()); |
| 90 | if (PEAR::isError($res)) { return $res; } | 92 | if (PEAR::isError($res)) { return $res; } |
| 91 | - | 93 | + |
| 92 | $aOptions = $oEntry->getConfigArray(); | 94 | $aOptions = $oEntry->getConfigArray(); |
| 93 | - $aOptions['column_id'] = $oEntry->getId(); | ||
| 94 | - $aOptions['required_in_view'] = $oEntry->getRequired(); | 95 | + $aOptions['column_id'] = $oEntry->getId(); |
| 96 | + $aOptions['required_in_view'] = $oEntry->getRequired(); | ||
| 95 | $res->setOptions($aOptions); | 97 | $res->setOptions($aOptions); |
| 96 | - | 98 | + |
| 97 | $view_columns[] = $res; | 99 | $view_columns[] = $res; |
| 98 | } | 100 | } |
| 99 | - | ||
| 100 | - return $view_columns; | 101 | + |
| 102 | + return $view_columns; | ||
| 101 | } | 103 | } |
| 102 | } | 104 | } |
| 103 | 105 |
lib/browse/criteriaregistry.php
| @@ -33,14 +33,16 @@ class KTCriteriaRegistry { | @@ -33,14 +33,16 @@ class KTCriteriaRegistry { | ||
| 33 | var $_aCriteriaDetails = array(); | 33 | var $_aCriteriaDetails = array(); |
| 34 | var $_bGenericRegistered = false; | 34 | var $_bGenericRegistered = false; |
| 35 | 35 | ||
| 36 | - function &getSingleton() { | ||
| 37 | - if (!KTUtil::arrayGet($GLOBALS['_KT_CRITERIA'], 'oKTCriteriaRegistry')) { | ||
| 38 | - $GLOBALS['_KT_CRITERIA']['oKTCriteriaRegistry'] = new KTCriteriaRegistry; | ||
| 39 | - // $GLOBALS['_KT_CRITERIA']['oKTCriteriaRegistry']->_buildGenericCriteria(); | ||
| 40 | - } | ||
| 41 | - return $GLOBALS['_KT_CRITERIA']['oKTCriteriaRegistry']; | 36 | + static function &getSingleton () { |
| 37 | + static $singleton=null; | ||
| 38 | + if (is_null($singleton)) | ||
| 39 | + { | ||
| 40 | + $singleton = new KTCriteriaRegistry(); | ||
| 41 | + } | ||
| 42 | + return $singleton; | ||
| 42 | } | 43 | } |
| 43 | 44 | ||
| 45 | + | ||
| 44 | function _buildGenericCriteria() { | 46 | function _buildGenericCriteria() { |
| 45 | $aFields =& DocumentField::getList(); | 47 | $aFields =& DocumentField::getList(); |
| 46 | foreach($aFields as $oField) { | 48 | foreach($aFields as $oField) { |
| @@ -81,7 +83,7 @@ class KTCriteriaRegistry { | @@ -81,7 +83,7 @@ class KTCriteriaRegistry { | ||
| 81 | require_once($sFilename); | 83 | require_once($sFilename); |
| 82 | } | 84 | } |
| 83 | $sClassName = $aDetails[0]; | 85 | $sClassName = $aDetails[0]; |
| 84 | - $oCriterion =& new $sClassName(); | 86 | + $oCriterion =new $sClassName(); |
| 85 | 87 | ||
| 86 | 88 | ||
| 87 | if(is_array($aDetails[3])) { | 89 | if(is_array($aDetails[3])) { |