Global Functions

Global functions are wrappers or shortcuts to commonly used objects or methods.

The p() Function

This function provides a reference the default page controller, which is normally the first instance of the RaxanWebPage class. Calling this function will automatically create an instance of the RaxanWebPage class if a Page Controller was not found.

<?php
    p()->append('Hi there!');
?>

The c() Function

This provides a reference to the RaxanClientExtension class, which is used to generate and execute client-side action scripts. These action scripts are normally jQuery commands that are executed within the client's browser. Calling this method will automatically create an instance of the RaxanClientExtension class and load the Raxan startup and jQuery libraries.

<?php
    c('#box')->fadeOut();
?>

The _fn() function

Generates a client-side function and returns a reference to the function, which can then be passed to other action script commands. For Example:

<?php
    $cb = _fn('alert("Hello")'); 
    C('body')->click($cb);
?>

The _var() Function

Generates a client-side JavaScript variable and returns a reference to the variable, which can then be passed to other action script commands

<?php
    $v = _var(array(1,2,3,4)); 
    Cc)->alert($v);
?>

The _event() Function

Generates a client-side function that's used to trigger a server-side event and returns a reference the function, which can be passed to other action script commands.

<?php

    require_once('raxan/pdi/autostart.php');

    class NewPage extends RaxanWebPage {

        protected function _load() {
            if (!$this->isPostback)
                c()->confirm("Are you sure you want to continue?",_event('ok'),_event('cancel'));

            // register the 'ok' and 'cancel' page events
            $this->registerEvent('ok', '.okShow');
            $this->registerEvent('cancel', '.cancelShow');

        }

        protected function okShow($e){
            $this->content('Welcome to the Online Demo...');
        }

        protected function cancelShow($e){
            $this->content('Goodbye!');
        }

    }

?>

For more information about the above global functions see the RaxanWebPage class reference.


Up Next: Server-Side Events