X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fajax.inc;h=b95d1928a353b702c882b1c266eed11b43b2e117;hb=402235dd9bb7b00d0a560e70fd9ea96efdce8575;hp=3ad2966e821ea4236ff6d2ae60b6119c4dd42217;hpb=c935a4090e3f152dd5549217d69b5b5036197024;p=fa-stable.git diff --git a/includes/ajax.inc b/includes/ajax.inc index 3ad2966e..b95d1928 100644 --- a/includes/ajax.inc +++ b/includes/ajax.inc @@ -25,11 +25,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) @@ -114,11 +120,18 @@ class Ajax extends JsHttpRequest { } else if($com['n'] == 'up' && $com['t'] == '_page_body') { - $this->aCommands = array($com); + $cmds = array($com); + foreach( $this->aCommands as $k=> $cmd) { + if ($cmd['n'] == 'fc') { // save focus + $cmds[] = $cmd; break; + } + } + $this->aCommands = $cmds; break; } } -// display_error(htmlentities(print_r($this->aCommands, true))); +// display_error('Activate:'.htmlentities(print_r($this->triggers, true))); +// display_error('Commands :'.htmlentities(print_r($this->aCommands, true))); $GLOBALS['_RESULT'] = $this->aCommands; // exit(); } @@ -129,4 +142,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; +} ?>