X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fajax.inc;h=096d2391c0f9d91fdb782839222e36214d89accc;hb=5d3fcb9c57e586c20651594edf91a2dccb08df00;hp=135ee03df2dc91cd46d75d79d63a0d22f91adee3;hpb=c09be0dad6b05131e240349a375af7a4b7bf3444;p=fa-stable.git diff --git a/includes/ajax.inc b/includes/ajax.inc index 135ee03d..096d2391 100644 --- a/includes/ajax.inc +++ b/includes/ajax.inc @@ -1,4 +1,14 @@ . +***********************************************************************/ require_once($path_to_root. "/includes/JsHttpRequest.php"); class Ajax extends JsHttpRequest { @@ -8,7 +18,7 @@ class Ajax extends JsHttpRequest { function Ajax() { - $this->JsHttpRequest($_SESSION['language']->encoding); + $this->JsHttpRequest(@$_SESSION['language']->encoding); } // // This function is used in ctrl routines to activate @@ -25,11 +35,17 @@ class Ajax extends JsHttpRequest { // function redirect($url) { if(in_ajax()) { - $this->_addCommand(true, array('n'=>'rd'),$url); - $this->run(); + $this->_addCommand(true, array('n'=>'rd'), absolute_url($url)); + $this->run(); } } // + // Popup window (target=_blank) + // + function popup($url) { + $this->_addCommand(true, array('n'=>'pu'), absolute_url($url)); + } + // // Adds an executable Javascript code. // function addScript($trigger, $sJS) @@ -116,8 +132,8 @@ class Ajax extends JsHttpRequest { if($com['n'] == 'up' && $com['t'] == '_page_body') { $cmds = array($com); foreach( $this->aCommands as $k=> $cmd) { - if ($cmd['n'] == 'fc') { // save focus - $cmds[] = $cmd; break; + if ($cmd['n'] == 'fc' || $cmd['n'] == 'js') { // save focus + $cmds[] = $cmd; //break; } } $this->aCommands = $cmds; @@ -136,4 +152,11 @@ function in_ajax() { return $Ajax->isActive(); } +// Returns absolute path of relative $url. To be used in ajax calls +// for proper redirection from any referer page. +// +function absolute_url($url) +{ + return strpos($url, '..')===0 ? dirname($_SERVER['PHP_SELF']).'/'.$url : $url; +} ?>