Commit 8303862943e54679c8fe54dd9790ba01d584136f

Authored by Conrad Vermeulen
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
lib/browse/columnregistry.inc.php
... ... @@ -7,7 +7,7 @@
7 7 * License Version 1.1.2 ("License"); You may not use this file except in
8 8 * compliance with the License. You may obtain a copy of the License at
9 9 * http://www.knowledgetree.com/KPL
10   - *
  10 + *
11 11 * Software distributed under the License is distributed on an "AS IS"
12 12 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
13 13 * See the License for the specific language governing rights and
... ... @@ -18,9 +18,9 @@
18 18 * (ii) the KnowledgeTree copyright notice
19 19 * in the same form as they appear in the distribution. See the License for
20 20 * requirements.
21   - *
  21 + *
22 22 * The Original Code is: KnowledgeTree Open Source
23   - *
  23 + *
24 24 * The Initial Developer of the Original Code is The Jam Warehouse Software
25 25 * (Pty) Ltd, trading as KnowledgeTree.
26 26 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
... ... @@ -36,11 +36,13 @@ class KTColumnRegistry {
36 36 var $columns = array();
37 37 var $views = array(); // should be in here
38 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 51 'name' => $sName,
50 52 'namespace' => $sNamespace,
51 53 'class' => $sClass,
52   - 'file' => $sFile
  54 + 'file' => $sFile
53 55 );
54 56 }
55   -
  57 +
56 58 function getViewName($sNamespace) { return KTUtil::arrayGet($this->views, $sNamespace); }
57 59 function getViews() { return $this->views; }
58 60 function getColumns() { return $this->columns; }
59 61 function registerView($sName, $sNamespace) { $this->views[$sNamespace] = $sName; }
60   -
  62 +
61 63 function getColumnInfo($sNamespace) {
62 64 return KTUtil::arrayGet($this->columns, $sNamespace, null);
63   - }
64   -
  65 + }
  66 +
65 67 function getColumn($sNamespace) {
66 68 $aInfo = $this->getColumnInfo($sNamespace);
67 69 if (empty($aInfo)) {
68 70 return PEAR::raiseError(sprintf(_kt("No such column: %s"), $sNamespace));
69   - }
70   -
  71 + }
  72 +
71 73 require_once($aInfo['file']);
72 74  
73 75 return new $aInfo['class'];
74 76 }
75   -
  77 +
76 78 function getColumnsForView($sViewNamespace) {
77 79 $view_entry = KTUtil::arrayGet($this->views, $sViewNamespace);
78 80 if (is_null($view_entry)) {
79 81 return PEAR::raiseError(sprintf(_kt("No such view: %s"), $sViewNamespace));
80   - }
81   -
  82 + }
  83 +
82 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 89 $view_columns = array();
88 90 foreach ($view_column_entries as $oEntry) {
89 91 $res = $this->getColumn($oEntry->getColumnNamespace());
90 92 if (PEAR::isError($res)) { return $res; }
91   -
  93 +
92 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 97 $res->setOptions($aOptions);
96   -
  98 +
97 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 33 var $_aCriteriaDetails = array();
34 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 46 function _buildGenericCriteria() {
45 47 $aFields =& DocumentField::getList();
46 48 foreach($aFields as $oField) {
... ... @@ -81,7 +83,7 @@ class KTCriteriaRegistry {
81 83 require_once($sFilename);
82 84 }
83 85 $sClassName = $aDetails[0];
84   - $oCriterion =& new $sClassName();
  86 + $oCriterion =new $sClassName();
85 87  
86 88  
87 89 if(is_array($aDetails[3])) {
... ...