Esempio n. 1
0
 protected function setFunction($name, $code)
 {
     if (!TJavaScript::isJsLiteral($code)) {
         $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code));
     }
     $this->setOption($name, $code);
 }
Esempio n. 2
0
 /**
  * Converts a value to string type.
  * Note, a boolean value will be converted to 'true' if it is true
  * and 'false' if it is false.
  * @param mixed the value to be converted.
  * @return string
  */
 public static function ensureString($value)
 {
     if (TJavaScript::isJsLiteral($value)) {
         return $value;
     }
     if (is_bool($value)) {
         return $value ? 'true' : 'false';
     } else {
         return (string) $value;
     }
 }