nb Core Community
May 22, 2012, 03:49:20 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: 1.2.3 +nb is now final and released

@new registrations. I will not allow any new registrations here as there are more (real person) spambots here than ever.... captcha proved to be ineffective.

After your registration, mail me at ( admin AT shinobilegends.com ) from the mail address you want to register. Provide some text about you and possibly your game.
 
   Home   Help Search Calendar Downloads Login Register  
Pages: [1]
  Print  
Author Topic: integrating xajax  (Read 1808 times)
genmac
Guest
« on: September 15, 2008, 08:17:26 pm »

Ok so I have started a simple task, and yet it's not working so I thought to myself, Nightborn would know what was wrong.  And then I realized you weren't on AIM.

Basically I just want to have xajax integrated into the core (I'm using a DP copy but either will work).

I did three things
* Added a require_once for the xajax lib in common.php
* Added a hook in common.php called xajax-register (right after including and creating the global $xajax object)
* Added an $xajax->processRequest command in pageparts.php in page_header

I get "undefined object: xajaxResponse" when writing my functions, but the question is - how would you integrate this if you were doing it?  A short summary would be sweet, I'm just missing something.  I really thought common.php would be the key, as I was assuming it would be present even in modules, but this appears to not be the case.
Logged
genmac
Guest
« Reply #1 on: September 15, 2008, 08:18:16 pm »

And as a side note, I am assuming I need to define ALLOW_ANONYMOUS in any module that I use with xajax, for when it calls the functions right?
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 307



View Profile WWW
« Reply #2 on: September 16, 2008, 08:33:38 am »

Hi Genmac,

Ajax can be done easliy, but you'd need response files like the mailinfo_*.php I placed in the root dir... those get called by xajax, and the reason is, as you indicated, that they need to be done by
Code:
define("OVERRIDE_FORCED_NAV",true);
require_once("common.php");

in that order to not break the page navigation with an update -> badnav
I have yet worked on the commentary system for that reason (thinking required)

To get xajax working, you need to do only

Code:
97         //add XAJAX mail stuff
 98         if ($session['user']['prefs']['ajax']) {
 99                 require("mailinfo_common.php");
100                 $xajax->printJavascript("lib/xajax");
101                 addnav("","mailinfo_server.php");
102         }
103         //END XAJAX

this.

I assume you have.

I don't know what exactly you want to update/handle by request with xajax. So I don't know where you need to place things.

Common.php is okay, but think that some browsers (I had it) along with "parenteral guidance" stuff and/or "internet security packages" block Ajax requests - I have had ~4% of my players complaining, so I turned "auto refresh the mail counter" into a preference defaulting to 0.

Putting the require of the Ajax functions in a separate file would be a good thing =)
and then one file to handle the request, I would rather not do it in runmodule directly.

If you want to fetch new information without causing the rest of the site to change -> Ajax is a good thing to do.
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
genmac
Guest
« Reply #3 on: September 16, 2008, 11:56:46 pm »

I want to use xajax in basically all of my modules (to handle button presses, the whole nine yard, although there will be some regular navigation (basically regular navigation between sections, and then xajax to navigate inside of a section))

So to use xajax in a module, I'd need to place

Code:
require("mailinfo_common.php");
100                 $xajax->printJavascript("lib/xajax");
101                 addnav("","mailinfo_server.php");

in common.php, and this:

Code:
define("OVERRIDE_FORCED_NAV",true);
require_once("common.php");

in the module itself?  Or could I just make an xajax.php file with first section in it, and then include that when necessary.  Where does $xajax->processRequest go in this scenario - in common.php?
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 307



View Profile WWW
« Reply #4 on: September 17, 2008, 07:25:38 am »

yes, I believe so.

the processrequest goes into the called file where the request jumps in -> I call the mailinfo_server to get a response
Code:
<?php

define
("OVERRIDE_FORCED_NAV",true);
require(
"common.php");

function 
mail_status($args) {
$new=maillink();
$objResponse = new xajaxResponse();
$objResponse->assign("maillink","innerHTML"$new);
global $session;
$warning='';
$timeout=strtotime($session['user']['laston'])-strtotime(date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT",900)." seconds")));
if ($timeout<200){
$warning="<br>".appoencode("`t").sprintf("TIMEOUT in %s seconds!",$timeout);
} elseif ($timeout<0) {
$warning="<br>".appoencode("`t")."Your session has timed out. Please log in again.";
} else $warning='';
$objResponse->assign("notify","innerHTML"$warning);
return $objResponse;
}
require(
"mailinfo_common.php");
$xajax->processRequest();

I always require (even before a request is processed) the common file to get the class up and running.

You don't need to override the forced nav if you make sure all navs the user can click carry over - means each AJAX hit you build new navs... which is a big adventure - the &c=234235 stuff does not help, you need to even replace the <a href>'s Sad
and making modules anonymous means making them vulnerable and callable from the outside - so users can escape the nav system to break out of bad fights and stuff.

Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!