Perforce Chronicle 2012.2/486814
API Documentation

EasyCron_Module Class Reference

Sets up view to add easy cron script. More...

Inheritance diagram for EasyCron_Module:
P4Cms_Module_Integration

List of all members.

Static Public Member Functions

static load ()
 Load the easy cron scripts into the head section of the page.

Detailed Description

Sets up view to add easy cron script.

The Easy Cron module runs the core Cron operation using normal page requests instead of having to set up a crontab. The module inserts a small amount of JavaScript to send Ajax requests on each page when it is enabled (by default, the module is enabled.)

The users should not notice any kind of delay or disruption when viewing the site. However, it does have a performance impact to the server because every page load will send a request to run the cron tasks. The core Cron module will decide if the tasks need to run upon each request.

This module requires that the site gets regular traffic/visitors in order to trigger the cron tasks.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

static EasyCron_Module::load ( ) [static]

Load the easy cron scripts into the head section of the page.

Reimplemented from P4Cms_Module_Integration.

    {
        // add the script to send a cron run request.
        $view = Zend_Layout::getMvcInstance()->getView();
        $view->headScript()->appendScript(
            "
            // we want this to happen last, so we wait until the page
            // is otherwise loaded, then add 100ms for good measure.
            dojo.connect(dojo.body(), 'onload', function() {
                window.setTimeout(
                    function() {
                        dojo.xhrGet({
                            url:   p4cms.url({
                                module:     'cron',
                                background: true,
                                format:     'json'
                            })
                        });
                    },
                    100
                );
            });
"
        );
    }

The documentation for this class was generated from the following file: