Ejemplo n.º 1
0
 function testCurrentURL()
 {
     $url = Raxan::currentURL();
     $q = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
     $url2 = $_SERVER['PHP_SELF'] . ($q ? '?' . $q : '');
     $this->compare($url, $url2, 'Current URL');
 }
Ejemplo n.º 2
0
 public function __construct($xhtml = '', $charset = null, $type = null)
 {
     parent::__construct();
     $this->_endResponse = false;
     // get instance of Raxan main class
     $this->Raxan = Raxan::singleton();
     // set start time must be set before page_config
     if ($this->showRenderTime) {
         $this->_startTime = Raxan::startTimer();
     }
     // initialize Raxan
     if (!Raxan::$isInit) {
         Raxan::init();
     }
     // add page to page controller array
     self::$pages[$this->objId] = $this;
     if (self::$mPageId == null) {
         self::$mPageId = $this->objId;
     }
     // script dependencies
     $dep = array('jquery');
     $this->registerScript('jquery-ui', 'jquery-ui', $dep);
     $this->registerScript('jquery-tools', 'jquery-tools', $dep);
     $this->registerScript('jquery-ui-utils', 'jquery-ui-utils', $dep);
     $this->registerScript('jquery-ui-effects', 'jquery-ui-effects', $dep);
     $this->registerScript('jquery-ui-interactions', 'jquery-ui-interactions', $dep);
     // call page setup
     if (Raxan::$isDebug) {
         Raxan::debug('Page _config()');
     }
     $this->_config();
     Raxan::triggerSysEvent('page_config', $this);
     // apply default page settings to the specified page object
     $c = Raxan::config();
     if (!isset($this->localizeOnResponse)) {
         $this->localizeOnResponse = $c['page.localizeOnResponse'];
     }
     if (!isset($this->showRenderTime)) {
         $this->showRenderTime = $c['page.showRenderTime'];
     }
     if (!isset($this->initStartupScript)) {
         $this->initStartupScript = $c['page.initStartupScript'];
     }
     if (!isset($this->resetDataOnFirstLoad)) {
         $this->resetDataOnFirstLoad = $c['page.resetDataOnFirstLoad'];
     }
     if (!isset($this->preserveFormContent)) {
         $this->preserveFormContent = $c['page.preserveFormContent'];
     }
     if (!isset($this->disableInlineEvents)) {
         $this->disableInlineEvents = $c['page.disableInlineEvents'];
     }
     if (!isset($this->masterTemplate)) {
         $this->masterTemplate = $c['page.masterTemplate'];
     }
     if (!isset($this->serializeOnPostBack)) {
         $this->serializeOnPostBack = $c['page.serializeOnPostBack'];
     }
     if (!isset($this->degradable)) {
         $this->degradable = $c['page.degradable'];
     }
     // set clientPostbackUrl
     if (!isset($this->clientPostbackUrl)) {
         $this->clientPostbackUrl = Raxan::currentURL();
     }
     // load default settings, charset, etc
     $this->_charset = $charset ? $charset : $c['site.charset'];
     $this->doc = self::createDOM(null, $this->_charset);
     $this->doc->initPageController($this->objId);
     $this->source($xhtml, $type);
     // set document source
     // init postback variables
     $this->isPostBack = $this->isPostback = count($_POST) ? true : false;
     // @todo: deprecate $t->isPostback
     $this->isAjaxRequest = $this->isCallback = isset($_POST['_ajax_call_']) ? true : false;
     if (isset($_GET['embed'])) {
         $em = $_GET['embed'];
         $opt = ($this->isEmbedded = isset($em['js'])) ? $_GET['embed']['js'] : '';
         $this->embedOptions = $opt;
     }
     // get active view. defaults to index view
     $hasVuHandler = false;
     if (isset($_GET['vu'])) {
         preg_match('/[a-z0-9_]+/i', $_GET['vu'], $matches);
         // get view name from url (vu)
         $this->activeView = $matches ? trim($matches[0]) : '';
     }
     if (!$this->activeView) {
         $this->activeView = 'index';
     }
     // call page  _init, _*Views and _load event handlers
     if (Raxan::$isDebug) {
         Raxan::debug('Page _init()');
     }
     $this->_init();
     $this->isInitialized = true;
     Raxan::triggerSysEvent('page_init', $this);
     // check authorization
     if (!$this->_endResponse) {
         if (Raxan::$isDebug) {
             Raxan::debug('Page _authorize()');
         }
         $this->isAuthorized = $this->_authorize();
         $pluginAuth = Raxan::triggerSysEvent('page_authorize', $this);
         if ($this->isAuthorized && $pluginAuth !== null) {
             $this->isAuthorized = $pluginAuth;
         }
     }
     if ($this->isAuthorized || $this->_endResponse) {
         // continue if authized or _endResponse = true
         // initialize view
         if (!$this->_endResponse) {
             $hasVuFile = false;
             $vu = $this->activeView;
             $vuHandler = '_' . $vu . 'View';
             $autov = $this->autoAppendView;
             if ($autov) {
                 if ($autov !== true && is_string($autov)) {
                     $vuFile = str_replace('{view}', $vu, $autov);
                 } else {
                     // default view file name
                     $filePrefix = basename(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : $_SERVER['SCRIPT_NAME']);
                     $filePrefix = substr($filePrefix, 0, strrpos($filePrefix, '.'));
                     $filePrefix = str_replace(array('/', '\\', ' '), '', $filePrefix);
                     // remove special chars from script name
                     $vuFile = $filePrefix . '.' . $vu . '.php';
                 }
                 $hasVuFile = file_exists($c['views.path'] . $vuFile);
                 if ($hasVuFile) {
                     if (Raxan::$isDebug) {
                         Raxan::debug('Page  - Load view ' . $vuFile);
                     }
                     $this->appendView($vuFile);
                 }
             }
             if ($vu != 'index') {
                 $hasVuHandler = method_exists($this, $vuHandler);
             }
             if ($hasVuHandler || $vu == 'index') {
                 if (Raxan::$isDebug) {
                     Raxan::debug('Page ' . $vuHandler . '()');
                 }
                 $this->{$vuHandler}();
                 // call view handler
             } else {
                 if (!$hasVuFile) {
                     // view handler or file not found
                     Raxan::sendError(Raxan::locale('view_not_found'));
                 }
             }
         }
         // initialize UI Widgets
         $this->initUIWidgets();
         // initialize inline events
         $this->initInlineEvents();
         // initialize preserved state
         $this->initPreservedElements();
         // initialize hidden elments
         $dl = $this->doc->xQuery('//*[@xt-hidefromclient]');
         if ($dl->length) {
             foreach ($dl as $node) {
                 $node->removeAttribute('xt-hidefromclient');
                 $this->hideElementFromClient($node, true);
             }
         }
         // load page and widgets
         if (Raxan::$isDebug) {
             Raxan::debug('Page _load()');
         }
         if (!$this->_endResponse) {
             $this->_load();
             $this->isLoaded = true;
             $this->loadUIWidgets();
             Raxan::triggerSysEvent('page_load', $this);
         }
         // update form elements
         if ($this->preserveFormContent && $this->isPostBack) {
             if (Raxan::$isDebug) {
                 Raxan::debug('Page - Restore Form State');
             }
             $this->updateFormFields();
             // update form fields on postbacks
         }
     } else {
         // if authorization failed then return HTTP: 403
         Raxan::sendError(Raxan::locale('unauth_access'), 403);
     }
 }