- OpenX Community Forums
![]() ![]() |
Jun 3 2008, 08:13 PM
Post
#1
|
|
|
Member ![]() ![]() Group: Members Posts: 17 Joined: 15-May 08 Member No.: 21,357 |
To customize some pages, I have make Xajax run in /www/admin/* for both IE and FF.
I saw /www/admin/js/xajax.js but didnt' see anyon refer to it, so I assume people abondan the work in the middle, so hope the following developer howto helps, and it assumes adding xajax feature for existing web page(such as www/admin/xxx.php): 1. create a file to contain Xajax related stuff as name xxx.xajax.php, it should contain 1.1 security check to avoid misuse. 1.2 require MAX_PATH.'/lib/xajax/xajax.inc.php'; 1.3 Xajax response functions such as responseA(A) 1.4 logistics $xajax = new xajax(); $xajax->debugOn(); // Uncomment this line to turn debugging on $xajax->registerFunction("responseA"); $xajax->processRequests(); 1.5 client side javascript preparation if(isset($submit) && $submit == $strSaveChanges) { unset($session['use_xajax']['xxx']); if (count($session['use_xajax']) == 1) unset($session['use_xajax']['xajaxHdr']); } else { if (count($session['use_xajax']) == 0) $session['use_xajax']['xajaxHdr'] = '<script type="text/javascript" src="js/xajax.js"></script> <script type="text/javascript"> window.setTimeout(function () { if (!xajaxLoaded) { alert("Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\nURL: ../../lib/xajax/xajax_js/xajax.js"); } }, 6000); </script>'; ob_start(); $xajax->printJavascript(); // output the xajax javascript. This must be called between the head tags $session['use_xajax']['xxx'] = ob_get_contents(); ob_end_clean(); } 2. insert require xxx.xajax.php into xxx.php at the right place, following is guideline to select such a place: 2.1 after security check 2.2 before parameter check, because dynamic data inbound flow might not be as ordinary as xxx.php originally planned for. 2.3 before HTML <head> is issued because client side JS should be membedded between <head> and </head> 3. change www/admin/lib-gui.inc.php to open a door for including XJAX related JS in header: in function phpAds_PageHeader() add following lines + if ($session['use_xajax']) { + $xajaxHdrIncluded = false; + foreach($session['use_xajax'] as $xajax_idx => $xajax_script) { + if ($xajax_idx!="xajaxHdr") + echo $xajax_script; + } + echo $session['use_xajax']['xajaxHdr']; + } Enjoy! Ben |
|
|
|
Jun 4 2008, 12:24 PM
Post
#2
|
|
|
Mentor ![]() Group: OpenX Support Posts: 7,576 Joined: 28-November 06 From: London, England Member No.: 14,171 |
Hi,
Thank you for the useful post and good explanation The xajax script is present because it was used in some developer tools that are available when downloading the SVN copy of OpenX - it is/was also used in the 'Manage previous upgrades' history subpage of Settings->Product Updates I'll make this a sticky for others to see |
|
|
|
![]() ![]() |