API15

JHTMLBehavior/keepalive

From Joomla! Documentation

< API15:JHTMLBehavior
Revision as of 17:21, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Keep session alive, for example, while editing or creating an article. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JHTMLBehavi...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Keep session alive, for example, while editing or creating an article.

[Edit Descripton]

Template:Description:JHTMLBehavior/keepalive

Syntax[edit]

keepalive()


Defined in[edit]

libraries/joomla/html/html/behavior.php

Importing[edit]

jimport( 'joomla.html.html.behavior' );

Source Body[edit]

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;
}

[Edit See Also] Template:SeeAlso:JHTMLBehavior/keepalive

Examples[edit]

<CodeExamplesForm />