Commit 62f89fdc6eb1c437c018f3414ea5e4845026eb08

Authored by Conrad Vermeulen
1 parent 97930996

KTS-2358

"php5 migration"
Updated. Removed & from &new.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7198 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 49 additions and 49 deletions
lib/dispatcher.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
... ... @@ -53,12 +53,12 @@ class KTDispatcher {
53 53 var $bTransactionStarted = false;
54 54 var $oValidator = null;
55 55 var $sParentUrl = null; // it is handy for subdispatched items to have an "exit" url, for cancels, etc.
56   -
  56 +
57 57 var $aPersistParams = array();
58 58  
59 59 function KTDispatcher() {
60   - $this->oValidator =& new KTDispatcherValidation($this);
61   - $this->oRedirector =& new KTDispatchStandardRedirector($this);
  60 + $this->oValidator =new KTDispatcherValidation($this);
  61 + $this->oRedirector =new KTDispatchStandardRedirector($this);
62 62 }
63 63  
64 64 function redispatch($event_var, $action_prefix = null, $orig_dispatcher = null, $parent_url = null) {
... ... @@ -68,11 +68,11 @@ class KTDispatcher {
68 68 if ($action_prefix) {
69 69 $this->action_prefix = $action_prefix;
70 70 }
71   -
  71 +
72 72 if (!is_null($orig_dispatcher)) {
73 73 $this->persistParams($orig_dispatcher->aPersistParams);
74   - $this->persistParams(array($orig_dispatcher->event_var));
75   - $core = array('aBreadcrumbs',
  74 + $this->persistParams(array($orig_dispatcher->event_var));
  75 + $core = array('aBreadcrumbs',
76 76 'bTransactionStarted',
77 77 'oUser',
78 78 'session',
... ... @@ -82,10 +82,10 @@ class KTDispatcher {
82 82 if(isset($orig_dispatcher->$k)) {
83 83 $this->$k = $orig_dispatcher->$k;
84 84 }
85   - }
  85 + }
86 86 }
87   - $this->event_var = $event_var;
88   -
  87 + $this->event_var = $event_var;
  88 +
89 89 return $this->dispatch();
90 90 }
91 91  
... ... @@ -126,14 +126,14 @@ class KTDispatcher {
126 126  
127 127 $ret = $this->$method();
128 128 $this->handleOutput($ret);
129   -
  129 +
130 130 if ($this->bTransactionStarted) {
131 131 $this->commitTransaction();
132 132 }
133 133 }
134 134  
135 135 function subDispatch(&$oOrigDispatcher) {
136   - $core = array('aBreadcrumbs',
  136 + $core = array('aBreadcrumbs',
137 137 'bTransactionStarted',
138 138 'oUser',
139 139 'session',
... ... @@ -185,14 +185,14 @@ class KTDispatcher {
185 185 }
186 186 $this->redirectTo($event, $sQuery);
187 187 }
188   -
  188 +
189 189 function errorRedirectToParent($error_message) {
190 190 if ($this->bTransactionStarted) {
191 191 $this->rollbackTransaction();
192 192 }
193 193  
194 194 $_SESSION['KTErrorMessage'][] = $error_message;
195   - redirect($this->sParentUrl);
  195 + redirect($this->sParentUrl);
196 196 exit(0);
197 197 }
198 198  
... ... @@ -203,14 +203,14 @@ class KTDispatcher {
203 203 if (!empty($info_message)) {
204 204 $_SESSION['KTInfoMessage'][] = $info_message;
205 205 }
206   - redirect($this->sParentUrl);
  206 + redirect($this->sParentUrl);
207 207 exit(0);
208   - }
  208 + }
209 209  
210 210 function redirectTo($event, $sQuery = "") {
211 211 // meld persistant options
212 212 $sQuery = $this->meldPersistQuery($sQuery, $event);
213   -
  213 +
214 214 $sRedirect = KTUtil::addQueryString($_SERVER['PHP_SELF'], $sQuery);
215 215 $this->oRedirector->redirect($sRedirect);
216 216 exit(0);
... ... @@ -231,14 +231,14 @@ class KTDispatcher {
231 231 function handleOutput($sOutput) {
232 232 print $sOutput;
233 233 }
234   -
  234 +
235 235 /* persist the following parameters between requests (via redirect), unless a value is passed in. */
236 236 function persistParams($aParamKeys) {
237 237 $this->aPersistParams = kt_array_merge($this->aPersistParams, $aParamKeys);
238 238 }
239   -
240   - function meldPersistQuery($sQuery = "", $event = "", $asArray = false) {
241   -
  239 +
  240 + function meldPersistQuery($sQuery = "", $event = "", $asArray = false) {
  241 +
242 242 if (is_array($sQuery)) {
243 243 $aQuery = $sQuery;
244 244 } else {
... ... @@ -248,11 +248,11 @@ class KTDispatcher {
248 248 } else {
249 249 $aQuery = array();
250 250 }
251   - }
  251 + }
252 252 // now try to grab each persisted entry
253   - // don't overwrite the existing values, if added.
  253 + // don't overwrite the existing values, if added.
254 254  
255   - if (is_array($this->aPersistParams)) {
  255 + if (is_array($this->aPersistParams)) {
256 256 foreach ($this->aPersistParams as $k) {
257 257 if (!array_key_exists($k, $aQuery)) {
258 258 $v = KTUtil::arrayGet($_REQUEST, $k);
... ... @@ -260,10 +260,10 @@ class KTDispatcher {
260 260 $aQuery[$k] = $v;
261 261 }
262 262 }
263   - // handle the case where action is passed in already.
264   - }
  263 + // handle the case where action is passed in already.
  264 + }
265 265 }
266   - // if it isn't already set
  266 + // if it isn't already set
267 267 if ((!array_key_exists($this->event_var, $aQuery)) && (!empty($event))) {
268 268 $aQuery[$this->event_var] = urlencode($event);
269 269 }
... ... @@ -291,26 +291,26 @@ class KTStandardDispatcher extends KTDispatcher {
291 291 var $oPage = false;
292 292 var $sHelpPage = null;
293 293 var $bJSONMode = false;
294   -
  294 +
295 295 function KTStandardDispatcher() {
296 296 if (empty($GLOBALS['main'])) {
297   - $GLOBALS['main'] =& new KTPage;
  297 + $GLOBALS['main'] =new KTPage;
298 298 }
299 299 $this->oPage =& $GLOBALS['main'];
300 300 parent::KTDispatcher();
301 301 }
302 302  
303 303 function permissionDenied () {
304   - // handle anonymous specially.
  304 + // handle anonymous specially.
305 305 if ($this->oUser->getId() == -2) {
306 306 redirect(KTUtil::ktLink('login.php','',sprintf("redirect=%s&errorMessage=%s", urlencode($_SERVER['REQUEST_URI']), urlencode(_kt("You must be logged in to perform this action"))))); exit(0);
307   - }
308   -
  307 + }
  308 +
309 309 global $default;
310   -
  310 +
311 311 $msg = '<h2>' . _kt('Permission Denied') . '</h2>';
312 312 $msg .= '<p>' . _kt('If you feel that this is incorrect, please report both the action and your username to a system administrator.') . '</p>';
313   -
  313 +
314 314 $this->oPage->setPageContents($msg);
315 315 $this->oPage->setUser($this->oUser);
316 316 $this->oPage->hideSection();
... ... @@ -324,11 +324,11 @@ class KTStandardDispatcher extends KTDispatcher {
324 324 if ($oKTConfig->get('allowAnonymousLogin', false)) {
325 325 // anonymous logins are now allowed.
326 326 // the anonymous user is -1.
327   - //
  327 + //
328 328 // we short-circuit the login mechanisms, setup the session, and go.
329   -
  329 +
330 330 $oUser =& User::get(-2);
331   - if (PEAR::isError($oUser) || ($oUser->getName() != 'Anonymous')) {
  331 + if (PEAR::isError($oUser) || ($oUser->getName() != 'Anonymous')) {
332 332 ; // do nothing - the database integrity would break if we log the user in now.
333 333 } else {
334 334 $session = new Session();
... ... @@ -339,7 +339,7 @@ class KTStandardDispatcher extends KTDispatcher {
339 339 }
340 340 }
341 341 }
342   -
  342 +
343 343 $sErrorMessage = "";
344 344 if (PEAR::isError($this->sessionStatus)) {
345 345 $sErrorMessage = $this->sessionStatus->getMessage();
... ... @@ -348,8 +348,8 @@ class KTStandardDispatcher extends KTDispatcher {
348 348 // check if we're in JSON mode - in which case, throw error
349 349 // but JSON mode only gets set later, so gonna have to check action
350 350 if(KTUtil::arrayGet($_REQUEST, 'action', '') == 'json') { //$this->bJSONMode) {
351   - $this->handleOutputJSON(array('error'=>true,
352   - 'type'=>'kt.not_logged_in',
  351 + $this->handleOutputJSON(array('error'=>true,
  352 + 'type'=>'kt.not_logged_in',
353 353 'alert'=>true,
354 354 'message'=>_kt('Your session has expired, please log in again.')));
355 355 exit(0);
... ... @@ -410,8 +410,8 @@ class KTStandardDispatcher extends KTDispatcher {
410 410 }
411 411  
412 412 function addInfoMessage($sMessage) { $_SESSION['KTInfoMessage'][] = $sMessage; }
413   -
414   - function addErrorMessage($sMessage) { $_SESSION['KTErrorMessage'][] = $sMessage; }
  413 +
  414 + function addErrorMessage($sMessage) { $_SESSION['KTErrorMessage'][] = $sMessage; }
415 415  
416 416 function errorPage($errorMessage, $oException = null) {
417 417 if ($this->bTransactionStarted) {
... ... @@ -442,7 +442,7 @@ class KTStandardDispatcher extends KTDispatcher {
442 442 $this->oPage->setPageContents($data);
443 443 $this->oPage->setUser($this->oUser);
444 444 $this->oPage->setHelp($this->sHelpPage);
445   -
  445 +
446 446 // handle errors that were set using KTErrorMessage.
447 447 $errors = KTUtil::arrayGet($_SESSION, 'KTErrorMessage', array());
448 448 if (!empty($errors)) {
... ... @@ -454,7 +454,7 @@ class KTStandardDispatcher extends KTDispatcher {
454 454  
455 455 // handle notices that were set using KTInfoMessage.
456 456 $info = KTUtil::arrayGet($_SESSION, 'KTInfoMessage', array());
457   -
  457 +
458 458 if (!empty($info)) {
459 459 foreach ($info as $sInfo) {
460 460 $this->oPage->addInfo($sInfo);
... ... @@ -480,17 +480,17 @@ class KTStandardDispatcher extends KTDispatcher {
480 480 print $oJSON->encode($data);
481 481 exit(0);
482 482 }
483   -
  483 +
484 484 function do_json() {
485 485 $this->bJSONMode = true;
486   - $this->redispatch('json_action', 'json');
  486 + $this->redispatch('json_action', 'json');
487 487 }
488 488  
489 489 function json_main() {
490 490 return array('type'=>'error', 'value'=>'Not implemented');
491 491 }
492 492  
493   -
  493 +
494 494  
495 495 }
496 496  
... ...