Example #1
0
 /**
  * Keep session alive, for example, while editing or creating an article.
  */
 public static function keepalive()
 {
     // Include mootools framework
     JHtmlBehavior::mootools();
     $config =& JFactory::getConfig();
     $lifetime = $config->getValue('lifetime') * 60000;
     $refreshTime = $lifetime <= 60000 ? 30000 : $lifetime - 60000;
     //refresh time is 1 minute less than the liftime assined in the configuration.php file
     $document =& JFactory::getDocument();
     $script = '';
     $script .= 'function keepAlive() {';
     $script .= '	var myAjax = new Ajax("index.php", { method: "get" }).request();';
     $script .= '}';
     $script .= ' window.addEvent("domready", function()';
     $script .= '{ keepAlive.periodical(' . $refreshTime . '); }';
     $script .= ');';
     $document->addScriptDeclaration($script);
     return;
 }