Commit 9f83fbe9ba15cbf6fd4e42219411940d9b1e8e46

Authored by conradverm
1 parent 6bad9c7e

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@7193 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/util/KTStopwords.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
... ... @@ -44,7 +44,7 @@ class KTStopwords {
44 44 $this->words = unserialize($cache_str);
45 45 return true;
46 46 }
47   -
  47 +
48 48 function createCache($filename) {
49 49 file_put_contents($filename, serialize($this->words));
50 50 }
... ... @@ -60,13 +60,16 @@ class KTStopwords {
60 60 return in_array($sWord, $this->words);
61 61 }
62 62  
63   - function &getSingleton() {
64   - if (!KTUtil::arrayGet($GLOBALS, 'KTStopwords')) {
65   - $GLOBALS['KTStopwords'] =& new KTStopwords;
66   - $oConfig =& KTConfig::getSingleton();
67   - $GLOBALS['KTStopwords']->loadFile($oConfig->get('urls/stopwordsFile'));
68   - }
69   - return $GLOBALS['KTStopwords'];
  63 + static function &getSingleton() {
  64 + static $singleton = null;
  65 + if (is_null($singleton))
  66 + {
  67 + $singleton = new KTStopwords;
  68 + $oConfig =& KTConfig::getSingleton();
  69 + $singleton->loadFile($oConfig->get('urls/stopwordsFile'));
  70 + }
  71 +
  72 + return $singleton;
70 73 }
71 74 }
72 75  
... ...
lib/util/ktutil.inc
... ... @@ -104,7 +104,7 @@ class KTUtil {
104 104 return strlen(utf8_decode($str));
105 105 }
106 106  
107   - function &arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) {
  107 + static function &arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) {
108 108 if (!is_array($aArray)) {
109 109 $aArray = (array) $aArray;
110 110 }
... ... @@ -132,7 +132,7 @@ class KTUtil {
132 132 *
133 133 * Return null in case of an empty array.
134 134 */
135   - function whereToString($aWhere) {
  135 + static function whereToString($aWhere) {
136 136 $aStrings = array();
137 137 $aParams = array();
138 138 foreach ($aWhere as $oSomething) {
... ... @@ -143,12 +143,12 @@ class KTUtil {
143 143 $aNewParams = array();
144 144 foreach ($oSomething[1] as $oParam) {
145 145 if (is_array($oParam)) {
146   - $aNewParams = kt_array_merge($aNewParams, $oParam);
  146 + $aNewParams = array_merge($aNewParams, $oParam);
147 147 } else {
148 148 $aNewParams[] = $oParam;
149 149 }
150 150 }
151   - $aParams = kt_array_merge($aParams, $aNewParams);
  151 + $aParams = array_merge($aParams, $aNewParams);
152 152 } else {
153 153 return PEAR::raiseError(_kt("Weird WhereClause passed"));
154 154 }
... ... @@ -382,7 +382,7 @@ class KTUtil {
382 382 * The one true way to get the correct name for a table whilst
383 383 * respecting the administrator's choice of table naming.
384 384 */
385   - function getTableName($sTable) {
  385 + static function getTableName($sTable) {
386 386 $sDefaultsTable = $sTable . "_table";
387 387 if (isset($GLOBALS['default']->$sDefaultsTable)) {
388 388 return $GLOBALS['default']->$sDefaultsTable;
... ... @@ -422,14 +422,14 @@ class KTUtil {
422 422 // }}}
423 423  
424 424 // {{{ meldOptions
425   - function meldOptions($aStartOptions, $aAddOptions) {
  425 + static function meldOptions($aStartOptions, $aAddOptions) {
426 426 if (!is_array($aStartOptions)) {
427 427 $aStartOptions = array();
428 428 }
429 429 if (!is_array($aAddOptions)) {
430 430 $aAddOptions = array();
431 431 }
432   - return kt_array_merge($aStartOptions, $aAddOptions);
  432 + return array_merge($aStartOptions, $aAddOptions);
433 433 }
434 434 // }}}
435 435  
... ... @@ -512,7 +512,7 @@ class KTUtil {
512 512  
513 513 // now accepts strings OR arrays!
514 514 // {{{ addQueryString
515   - function addQueryString($url, $qs) {
  515 + static function addQueryString($url, $qs) {
516 516 require_once(KT_DIR . '/thirdparty/pear/Net/URL.php');
517 517 $oUrl = new Net_URL($url);
518 518  
... ... @@ -560,13 +560,13 @@ class KTUtil {
560 560 // }}}
561 561  
562 562 // {{{ addQueryStringSelf
563   - function addQueryStringSelf($qs) {
  563 + static function addQueryStringSelf($qs) {
564 564 return KTUtil::addQueryString($_SERVER['PHP_SELF'], $qs);
565 565 }
566 566 // }}}
567 567  
568 568 // {{{ isAbsolutePath
569   - function isAbsolutePath($sPath) {
  569 + static function isAbsolutePath($sPath) {
570 570 if (substr($sPath, 0, 1) == '/') {
571 571 return true;
572 572 }
... ... @@ -650,7 +650,7 @@ class KTUtil {
650 650 return implode(' ',$q_set);
651 651 }
652 652  
653   - function running_user() {
  653 + static function running_user() {
654 654 if (substr(PHP_OS, 0, 3) == "WIN") {
655 655 return null;
656 656 }
... ...