Esempio n. 1
0
 public function __construct($val, $name = null, $isFunction = false, $registerGlobal = false)
 {
     $n = $this->name = $this->_pointer = $name !== null ? $name : '_v' . self::$vid++;
     if (!$isFunction) {
         $this->value = RaxanClientExtension::encodeVar($val);
     } else {
         $fn = trim($val);
         $this->value = substr($fn, 0, 8) != 'function' ? 'function() {' . $val . '}' : $fn;
     }
     if (!$registerGlobal) {
         RaxanWebPage::$vars[] = $n . '=' . $this->value;
     } else {
         $n = $this->name = 'window.' . $n;
         RaxanWebPage::$varsGlobal[] = $n . '=' . $this->value;
     }
 }
Esempio n. 2
0
 /**
  * Registers a value or variable to be accessed from the client-side Raxan JavaScript library
  * Use registerVar() to send PHP arrays, objects and other datatypes to the client.
  * To retrieve the value from JavaScript use Raxan.getVar('name');
  * @param string $name
  * @param mixed $value
  * @return RaxanWebPage
  */
 public function registerVar($name, $value)
 {
     self::loadClientExtension();
     $name = Raxan::escapeText($name);
     self::$actions[] = 'Raxan.regvar[\'' . $name . '\']=' . RaxanClientExtension::encodeVar($value);
     return $this;
 }