protected function renderBody() { $contents = parent::renderBody(); $options = TJavascript::toList(array('revert' => $this->getRevert())); $script = "new Draggable('{$this->ClientID}', {$options});"; $contents .= TJavascript::render($script); return $contents; }
protected function renderClientScriptOptions() { $updateOptions = $this->getClientScriptOptions(); $callbackOptions = $this->getCallbackOptions(); return TJavascript::toList($updateOptions, $callbackOptions); }
protected function renderJs() { $ID = $this->ClientID; $result = self::RESULT_PANEL_ID; $option['tokens'] = $this->renderTokens(); $options = TJavascript::toList($option); //$this->renderTokens(); $js = "new Prado.AutoCompleter('{$ID}', '{$ID}:{$result}', {$options});"; $this->Page->registerEndScript($ID, $js); }
/** * Coverts PHP arrays (both key and value) into javascript objects. * @param array the array data to convert * @param string append additional javascript object data * @param boolean if true empty string and empty array will be converted * @return string javascript object as string. */ public static function toList($array, $append = null, $strict = false) { $results = array(); $converter = new TJavascript(); foreach ($array as $k => $v) { if ($strict || !$strict && $v !== '' && $v !== array()) { $type = 'to_' . gettype($v); if ($type == 'to_array') { $results[] = "'{$k}':" . $converter->toList($v, $append, $strict); } else { $results[] = "'{$k}':" . $converter->{$type}($v); } } } $extra = ''; if (strlen($append) > 0) { $extra .= count($results) > 0 ? ',' . $append : $append; } return '{' . implode(',', $results) . $extra . '}'; }