示例#1
0
 protected function search($e)
 {
     $q = $this->post->textVal('txtQuery');
     // load remote html page
     $url = $this->url . urlencode($q);
     $searchPage = new RaxanWebPage($url);
     // find the search titles (h3)
     $titles = $searchPage->find('h3');
     $html = '';
     foreach ($titles->get() as $node) {
         $html .= '<div class="bmm">' . P($node)->html() . "</div>\n";
         //
     }
     $this->result->html($html);
 }
示例#2
0
 /**
  * Redirect client to the specified url
  * @param string $url page url
  * @param boolean $useJavaScript Optional. Enable page redirection using client-side JavaScript
  */
 public static function redirectTo($url, $useJavaScript = false)
 {
     if (!$useJavaScript) {
         header('Location: ' . $url);
     } else {
         $redirect = 'window.location = "' . self::escapeText($url) . '"';
         RaxanWebPage::$actions = array($redirect);
         RaxanWebPage::controller()->endResponse()->reply();
     }
     exit;
 }
 /**
  * Writes the value of a server-side variable or object to the client-side console
  * @param mixed $var Variable to be displayed inside console
  * @param boolean $halt Halt servide operations
  * @return RaxanClientExtension
  */
 public function console($var, $halt = false)
 {
     $var = $var === null ? 'null' : print_r($var, true);
     $this->chain = ($this->chain == '$()' ? '' : $this->chain . ';') . 'Raxan.log("' . $this->escapeString($var) . '")';
     if (!$halt) {
         return $this;
     } else {
         RaxanWebPage::controller()->endResponse()->reply();
         exit;
     }
 }
示例#4
0
 public function __construct($id, $properties = null)
 {
     // configure ui
     $this->_config();
     $autoid = $idIsString = $isArray = false;
     // setup properties
     if ($properties instanceof RaxanDOMDocument) {
         $doc = $properties;
     } else {
         if ($properties instanceof RaxanWebPage) {
             $doc = $properties->document();
         } else {
             $doc = RaxanWebPage::controller()->document();
             $isArray = is_array($properties);
         }
     }
     if ($id instanceof DOMElement) {
         $elm = $id;
         $autoid = true;
     } else {
         if (is_string($id)) {
             $elm = $doc->page->getElementById($id);
             $idIsString = true;
         }
     }
     if (!$elm) {
         $elm = $this->elmMarkup;
         $autoid = true;
     }
     // create instance
     parent::__construct($elm, $doc);
     if ($autoid) {
         // auto id
         if ($idIsString) {
             $this->attr('id', $id);
         } else {
             $this->autoId();
         }
     }
     $this->element = $this->elms[0];
     $this->elmId = $this->element->getAttribute('id');
     // import properties from element attributes
     $xtAttrs = array();
     $propkeys = null;
     foreach ($this->element->attributes as $attr) {
         if (substr($attr->name, 0, 6) == 'xt-ui-') {
             if ($propkeys == null) {
                 // // make properrty names case-insensitive for xt-ui attributes
                 $propkeys = array_keys($this->properties);
                 $propkeys = array_combine($propkeys, $propkeys);
                 $propkeys = array_change_key_case($propkeys);
             }
             $xtKey = substr($attr->name, 6);
             if (isset($propkeys[$xtKey])) {
                 $this->properties[$propkeys[$xtKey]] = $attr->value;
             }
             $xtAttrs[] = $attr->name;
         }
     }
     // remove xt-ui attribs
     foreach ($xtAttrs as $attr) {
         $this->element->removeAttribute($attr);
     }
     // merge properties
     if ($isArray) {
         $this->properties = array_merge($this->properties, $properties);
     }
     $this->_init();
     // init
     $page = $this->doc->page;
     // setup default ui state
     if ($this->preserveState && $elm) {
         if (!$page->isLoaded && !$elm->hasAttribute('xt-preservestate')) {
             $elm->setAttribute('xt-preservestate', $this->preserveState);
         }
     }
     $page->registerUIWidget($this);
 }
示例#5
0
 /**
  * Localize matched elements that have a valid locale key/value pair assigned to the langid attribute
  * @return RaxanElement
  */
 public function localize()
 {
     foreach ($this->elms as $n) {
         $nl = $this->doc->xQuery('descendant-or-self::*[@langid]', $n);
         RaxanWebPage::NodeL10n($nl);
     }
 }
示例#6
0
 public function __get($name)
 {
     if ($name == 'page') {
         return RaxanWebPage::controller($this->pageId);
     }
 }