Пример #1
0
/**
 * Automatically initializes a Raxan Web Page
 * This function will initialize either the last declared subclass of RaxanWebPage
 * or the first subclass with an $autostart property.
 *
 * Example:
 *<code>
 * class Page1 extends RaxanWebPage {    // this will be executed first because of $autostart.
 *     protected $autostart;
 *     protected function _load(){
 *          $this->content('Page1');
 *     }
 * }
 * class Page2 extends RaxanWebPage {    // this will be executed if $autostart was removed from Page1
 *     protected function _load(){
 *          $this->content('Page2');
 *     }
 * }
 * </code>
 */
function raxan_auto_startup($pth)
{
    // fix php CWD path bug when running under apache
    if ($pth != getcwd()) {
        chdir($pth);
    }
    $i = 0;
    $ok = false;
    $page = 'RaxanWebPage';
    $autostart = Raxan::config('autostart');
    if ($autostart === false) {
        return;
    }
    // stop here if autostart is set to false
    $src = trim(ob_get_clean());
    $class = 'RaxanWebPage';
    if ($autostart && is_subclass_of($autostart, $class)) {
        $page = $autostart;
    } else {
        // find page classes
        $cls = get_declared_classes();
        foreach ($cls as $cn) {
            if ($cn == $class) {
                $ok = true;
                continue;
            }
            if (!$ok) {
                continue;
            }
            if (is_subclass_of($cn, $class)) {
                // only init classes that extends RaxanWebPage
                $page = $cn;
                $r = new ReflectionClass($cn);
                if ($r->hasProperty('autostart')) {
                    break;
                }
            }
        }
    }
    // create page
    raxan_auto_create($page, $src);
}
Пример #2
0
 function testLog()
 {
     $msg = 'Base Class test log';
     $t = date('Y-m-d H:i:s', time());
     $file = dirname(__FILE__) . '/logfile.txt';
     file_put_contents($file, '');
     Raxan::config('log.enable', true);
     Raxan::config('log.file', $file);
     // log
     $base = new BaseClass();
     $base->log($msg);
     $c = file_get_contents($file);
     $this->compare("INFO \t" . $t . " \t \t" . $msg, trim($c), 'Log file content');
     // log with params
     file_put_contents($file, '');
     $base->log($msg, 'ERROR', 'Label');
     $t = date('Y-m-d H:i:s', time());
     $c = file_get_contents($file);
     $this->compare("ERROR \t" . $t . " \t [Label] \t" . $msg, trim($c), 'Log with label params');
 }
Пример #3
0
 protected function _init()
 {
     if (!session_id()) {
         // no current session exists so let's create one
         if ($this->id) {
             session_id($this->id);
         }
         session_name($name = Raxan::config('session.name'));
         $timeout = intval(Raxan::config('session.timeout')) * 60;
         if ($timeout) {
             session_set_cookie_params($timeout);
         }
         //set timeout
         session_start();
         if (!$this->id) {
             $this->id = session_id();
         }
         // reset cookie timeout on page load/refesh
         if (isset($_COOKIE[$name])) {
             setcookie($name, $_COOKIE[$name], time() + $timeout, '/');
         }
     }
     $this->store =& $_SESSION;
     // use current session object
 }
Пример #4
0
<?php

require_once '../raxan/pdi/autostart.php';
// system configuration
Raxan::loadConfig('config.php');
// load external config file
Raxan::config('site.timezone', 'America/Toronto');
// set timezone
class SearchBoxPage extends RaxanWebPage
{
    protected $db;
    protected $infoTpl, $searchTpl;
    protected function _init()
    {
        $this->source('views/searchbox.html');
        try {
            // see config.php for connection info
            // For employee sample data visit http://dev.mysql.com/doc/
            $this->db = $this->Raxan->connect('employees');
            // connect to db
        } catch (Exception $e) {
            $this->db = null;
            $msg = $this->getView('connection-failed.html');
            $this->flashmsg($msg, 'bounce', 'rax-box error');
        }
    }
    protected function _load()
    {
        // event to handle employee click
        $this->results->delegate('a', '#click', '.employeeClick');
        // event to handle auto-complete search
Пример #5
0
 function testSetBasePath()
 {
     $pth = dirname(__FILE__) . '/';
     $oldbase = Raxan::config('base.path');
     Raxan::setBasePath($pth);
     $this->ok($pth == $pth, 'Set new base path');
     Raxan::config('base.path', $oldbase);
 }
Пример #6
0
<?php

require_once "../raxan/pdi/autostart.php";
// set timezone - needed when using E_STRICT
Raxan::config('site.timezone', 'America/Jamaica');
class DateEntry extends RaxanWebPage
{
    protected function _config()
    {
        $this->preserveFormContent = true;
    }
    protected function buttonClick($e)
    {
        $f = $this->post->textVal('format');
        $dt = $this->post->dateVal('date', $f);
        if (!$dt) {
            $dt = 'Invalid date';
        }
        $this->msg->text($dt);
    }
}
?>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Date Entry</title>
    <link href="../raxan/ui/css/master.css" type="text/css" rel="stylesheet" />
    <!--[if lt IE 8]><link rel="stylesheet" href="../raxan/ui/css/master.ie.css" type="text/css"><![endif]-->
Пример #7
0
 public function __construct($array = null, $charset = null)
 {
     $this->_charset = $charset ? $charset : Raxan::config('site.charset');
     $this->setDataArray($array);
 }
Пример #8
0
 /**
  * Loads the RaxanClientExtension class
  */
 public static function loadClientExtension()
 {
     if (self::$cliExtLoaded) {
         return;
     }
     require_once Raxan::config('base.path') . 'shared/raxan.clientextension.php';
     self::$cliExtLoaded = true;
 }