public static function registerPackage(TControl $control, $name) { static $instance; if ($instance === null) { $instance = new self($control->getPage()); } $instance->_packages[$name] = true; }
/** * */ function renderBody() { $contents = trim(parent::renderBody()); $contents = addslashes($contents); $lines = preg_split("/\n|\r/", $contents); $jslines = ''; foreach ($lines as $line) { if (!empty($line)) { $jslines .= "\"{$line}\" + \n"; } } $jslines .= "\"\""; //var_dump($jslines); $id = $this->ID; $value = "{ '{$id}' : {$jslines} }"; $this->Page->registerArrayDeclaration('TJSTemplate', $value); $script = ' function findTemplateById(name) { for(i in TJSTemplate) { for(index in TJSTemplate[i]) { if(index == name) return TJSTemplate[i][index]; } } return null; }'; $this->Page->registerEndScript('TJSTemplate', $script); return; }
public function onPreRender($param) { parent::onPreRender($param); if ($this->getPage()->getClientScript()->isEndScriptRegistered('protect_unsave_form') == false) { $this->getPage()->getClientScript()->registerEndScript('protect_unsave_form', $this->getJavaScriptCode()); } }
/** * This overrides the parent implementation by rendering more THiddenField-specific attributes. * @return ArrayObject the attributes to be rendered */ protected function getAttributesToRender() { $attributes = parent::getAttributesToRender(); $attributes['type'] = "hidden"; $attributes['name'] = $this->getUniqueID(); $attributes['value'] = strtr($this->getValue(), array('&' => '&', '"' => '"')); return $attributes; }
/** * This overrides the parent implementation by rendering the <b>Text</b> property if it is not empty. * @return string the rendering result */ public function renderBody() { $text = $this->getText(); if (strlen($text)) { return $text; } else { return parent::renderBody(); } }
/** * Calls the client script manager to add each of the requested client * script libraries. * @param mixed event parameter */ public function onPreRender($param) { parent::onPreRender($param); $scripts = preg_split('/,|\\s+/', $this->getPradoScripts()); $cs = $this->getPage()->getClientScript(); foreach ($scripts as $script) { if (($script = trim($script)) !== '') { $cs->registerPradoScript($script); } } }
/** * Performs XSL transformation and render the output. * @param THtmlWriter The writer used for the rendering purpose */ public function render($writer) { if (($document = $this->getSourceXmlDocument()) === null) { $textWriter = new TTextWriter(); parent::render(new THtmlWriter($textWriter)); $document = new DOMDocument(); $document->loadXML($textWriter->flush()); } $stylesheet = $this->getTransformXmlDocument(); // Perform XSL transformation $xslt = new XSLTProcessor(); $xslt->importStyleSheet($stylesheet); // Check for parameters $parameters = $this->getParameters(); foreach ($parameters as $name => $value) { $xslt->setParameter('', $name, $value); } $output = $xslt->transformToXML($document); // Write output $writer->write($output); }
public function onLoad($param) { parent::onLoad($param); $this->dataBind(); }
/** * Renders body content. * This method overrides parent implementation by removing * malicious javascript code from the body content * @param THtmlWriter writer */ public function render($writer) { $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); parent::render($htmlWriter); $writer->write($this->parseSafeHtml($htmlWriter->flush())); }
/** * @param string the unique ID of the container control * @param string the unique ID of the button control * @return array default button options. */ protected function getDefaultButtonOptions($panelID, $buttonID) { $options['Panel'] = TControl::convertUniqueIdToClientId($panelID); $options['Target'] = TControl::convertUniqueIdToClientId($buttonID); $options['EventTarget'] = $buttonID; $options['Event'] = 'click'; return $options; }
/** * Creates a new callback control, sets the adapter to * TActiveControlAdapter. If you override this class, be sure to set the * adapter appropriately by, for example, by calling this constructor. */ public function __construct() { parent::__construct(); $this->setAdapter(new TActiveControlAdapter($this)); }
/** * Renders the localized number, be it currency or decimal, or percentage. * If the culture is not specified, the default application * culture will be used. * This method overrides parent's implementation. */ protected function renderBody() { $app = $this->Application->getGlobalization(); //initialized the default class wide formatter if (is_null(self::$formatter)) { self::$formatter = new NumberFormat($app->Culture); } $culture = $this->getCulture(); $pattern = $this->getPattern(); $type = $this->getType(); if (empty($pattern)) { $pattern = $type; } $value = $this->getValue(); if (strlen($value) == 0) { $value = parent::renderBody(); } //return the specific cultural formatted number if (!empty($culture) && $app->Culture != $culture) { $formatter = new NumberFormat($culture); return $formatter->format($value, $pattern, $this->getCurrency()); } //return the application wide culture formatted number. return self::$formatter->format($value, $pattern, $this->getCurrency()); }
/** * Performs the OnInit step for the control and all its child controls. * This method overrides the parent implementation * by ensuring child controls are created first. * Only framework developers should use this method. * @param TControl the naming container control */ protected function initRecursive($namingContainer = null) { $this->ensureChildControls(); parent::initRecursive($namingContainer); }
/** * Checks if an item can be added into body collection. * @param mixed the item to be added * @param boolean whether the item should be added into the colleciton. */ protected function onAddItem($item) { if ($this->control->allowBody($item)) { if ($item instanceof TControl) { $this->control->synchronizeControl($item); } return true; } else { return false; } }
public function render($writer) { if ($this->_dataCached) { $writer->write($this->_contents); } else { if ($this->_cacheAvailable) { $textWriter = new TTextWriter(); $stack = $this->getPage()->getCachingStack(); $stack->push($this); parent::render(new THtmlWriter($textWriter)); $stack->pop(); $content = $textWriter->flush(); $data = array($content, $this->_state, $this->_actions, time()); $this->_cache->set($this->getCacheKey(), $data, $this->getDuration(), $this->getCacheDependency()); $writer->write($content); } else { parent::render($writer); } } }
/** * Renders the literal control. * @param THtmlWriter the writer used for the rendering purpose */ public function render($writer) { if (($text = $this->getText()) !== '') { if ($this->getEncode()) { $writer->write(THttpUtility::htmlEncode($text)); } else { $writer->write($text); } } else { parent::render($writer); } }
/** * Registers the needed javascripts & css files * @param TEventParameter $param */ public function onPreRender($param) { parent::onPreRender($param); if ($this->getItems()->count() > 0) { $cs = $this->getPage()->getClientScript(); if (!$cs->isScriptFileRegistered('proto-menu')) { $cs->registerScriptFile('proto-menu', $this->publishAsset('assets/' . self::DEFAULT_JS_NAME, __CLASS__)); } if (!$cs->isScriptFileRegistered('CContextMenu')) { $cs->registerScriptFile('CContextMenu', $this->publishAsset('assets/CContextMenu.js', __CLASS__)); } if (($css = $this->getCssUrl()) === '') { $css = $this->publishAsset('assets/' . self::DEFAULT_CSS_NAME, __CLASS__); } $cs->registerStyleSheetFile('proto-css', $css); $this->renderClientControlScript(); } }
/** * Get the date-time value for this control. * @return string date time value. */ function getValue() { $value = $this->getViewState('Value', ''); if (empty($value)) { $text = parent::renderBody(); if (empty($text)) { return time(); } else { return $text; } } return $value; }
/** * Get the contents and add the content to the TTranslate * component. This component does not render anything. * The parent container must be of TTranslate, otherwise * error. */ protected function renderBody() { $text = parent::renderBody(); if ($this->doTrim()) { $text = trim($text); } $container = $this->getContainer(); $container->addParameter($this->getKey(), $text); }
/** * Display the translated string. */ protected function renderBody() { $app = $this->Application->getGlobalization(); //get the text from either Property Text or the body $text = $this->getText(); if (strlen($text) == 0) { $text = parent::renderBody(); } //trim it if ($this->doTrim()) { $text = trim($text); } //no translation handler provided if (empty($app->Translation)) { return strtr($text, $this->getParameters()); } Translation::init(); $catalogue = $this->getCatalogue(); if (empty($catalogue) && isset($app->Translation['catalogue'])) { $catalogue = $app->Translation['catalogue']; } $key = $this->getKey(); if (!empty($key)) { $text = $key; } $charset = $this->getCharset(); if (empty($charset)) { $charset = 'UTF-8'; } //translate it return Translation::formatter()->format($text, $this->getParameters(), $catalogue, $charset); }
/** * Constructor. */ public function __construct() { parent::__construct(); $this->EnableViewState = false; }
/** * @param boolean whether this view is active. */ public function setActive($value) { $value = TPropertyValue::ensureBoolean($value); $this->_active = $value; parent::setVisible($value); }
/** * This overrides the parent implementation by rendering more TWebControl-specific attributes. * @return ArrayObject the attributes to be rendered */ protected function getAttributesToRender() { $attributes = parent::getAttributesToRender(); if (!$this->isEnabled()) { $attributes['disabled'] = "disabled"; } $tabIndex = $this->getTabIndex(); if (!empty($tabIndex)) { $attributes['tabindex'] = $tabIndex; } $toolTip = $this->getToolTip(); if (strlen($toolTip)) { $attributes['title'] = $toolTip; } $accessKey = $this->getAccessKey(); if (strlen($accessKey)) { $attributes['accesskey'] = $accessKey; } $cssClass = $this->getCssClass(); if (strlen($cssClass)) { $attributes['class'] = $cssClass; } $style = $this->getStyle(); $width = $this->getWidth(); if (!empty($width)) { $style['width'] = $width; } $height = $this->getHeight(); if (!empty($height)) { $style['height'] = $height; } $foreColor = $this->getForeColor(); if (strlen($foreColor)) { $style['color'] = $foreColor; } $backColor = $this->getBackColor(); if (strlen($backColor)) { $style['background-color'] = $backColor; } $borderColor = $this->getBorderColor(); if (strlen($borderColor)) { $style['border-color'] = $borderColor; } $borderWidth = $this->getBorderWidth(); if (!empty($borderWidth)) { $style['border-width'] = $borderWidth; } $borderStyle = $this->getBorderStyle(); if (strlen($borderStyle)) { $style['border-style'] = $borderStyle; } if (count($style) > 0) { $s = ''; foreach ($style as $k => $v) { $s .= "{$k}:{$v};"; } $attributes['style'] = isset($attributes['style']) ? trim($attributes['style'], ';') . ";{$s}" : $s; } //append the javascript events $jsEvents = $this->getJavascriptEvents(); if (!empty($jsEvents) && is_array($jsEvents)) { foreach ($jsEvents as $event => $statements) { $javascripts = array(); $attribute = $this->getAttribute($event); if (!empty($attribute)) { $javascripts = explode(';', $attribute); } $javascripts = array_merge($javascripts, array_keys($statements)); $attributes[$event] = implode(';', $javascripts); } } return $attributes; }
/** * Overrides the parent implementation by invoking {@link TControl::clearNamingContainer} */ public function clear() { parent::clear(); if ($this->_o instanceof INamingContainer) { $this->_o->clearNamingContainer(); } }
/** * Renders the head control. * @param THtmlWriter the writer for rendering purpose. */ public function render($writer) { $page = $this->getPage(); $title = $this->getTitle(); $writer->write("<head>\n<title>" . THttpUtility::htmlEncode($title) . "</title>\n"); if (($baseUrl = $this->getBaseUrl()) !== '') { $writer->write('<base href="' . $baseUrl . "\" />\n"); } if (($icon = $this->getShortcutIcon()) !== '') { $writer->write('<link rel="shortcut icon" href="' . $icon . "\" />\n"); } if (($metaTags = $this->getMetaTags()) !== null) { foreach ($metaTags as $metaTag) { $metaTag->render($writer); $writer->writeLine(); } } $cs = $page->getClientScript(); $cs->renderStyleSheetFiles($writer); $cs->renderStyleSheets($writer); if ($page->getClientSupportsJavaScript()) { $cs->renderHeadScriptFiles($writer); $cs->renderHeadScripts($writer); } parent::render($writer); $writer->write("</head>\n"); }
public function render($writer) { $writer->renderBeginTag("ul"); parent::renderChildren($writer); $writer->renderEndTag(); }
/** * Processes an object that is created during parsing template. * This method overrides the parent implementation by removing * all contents enclosed in the template tag. * @param string|TComponent text string or component parsed and instantiated in template * @see createdOnTemplate */ public function addParsedObject($object) { if ($this->_creatingChildren) { parent::addParsedObject($object); } }
public function onPreRender($param) { parent::onPreRender($param); MyJavascriptLib::registerPackage($this, $this->_class); }
public function render($writer) { if ($this->_dataCached) { $writer->write($this->_contents); } else { if ($this->_cacheAvailable) { $textwriter = new TTextWriter(); $multiwriter = new TOutputCacheTextWriterMulti(array($writer->getWriter(), $textwriter)); $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), $multiwriter); $stack = $this->getPage()->getCachingStack(); $stack->push($this); parent::render($htmlWriter); $stack->pop(); $content = $textwriter->flush(); $data = array($content, $this->_state, $this->_actions, time()); $this->_cache->set($this->getCacheKey(), $data, $this->getDuration(), $this->getCacheDependency()); } else { parent::render($writer); } } }
/** * Renders the body content enclosed between the control tag. * By default, child controls and text strings will be rendered. * You can override this method to provide customized content rendering. * @param THtmlWriter the writer used for the rendering purpose */ public function renderContents($writer) { parent::renderChildren($writer); }