public static isJsLiteral ( $js ) : boolean | ||
Résultat | boolean | true if the parameter is marked as a javascript function, i.e. if it's considered as a raw javascript function that is not supposed to be encoded by {@link encode} |
/** * Adds on client-side event handler by wrapping the code within a * javascript function block. If the code begins with "javascript:", the * code is assumed to be a javascript function block rather than arbiturary * javascript statements. * @param string option name * @param string javascript statements. */ protected function setFunction($name, $code) { if (!TJavaScript::isJsLiteral($code)) { $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); } $this->setOption($name, $code); }
/** * 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; } }