/**
  * Sets the location of image file of the THyperLink.
  * @param string the image file location
  */
 public function setImageUrl($value)
 {
     parent::setImageUrl($value);
     if ($this->getActiveControl()->canUpdateClientSide() && $value !== '') {
         $textWriter = new TTextWriter();
         $renderer = new THtmlWriter($textWriter);
         $this->createImage($value)->renderControl($renderer);
         $this->getPage()->getCallbackClient()->update($this, $textWriter->flush());
     }
 }
 /**
  * Renders body content.
  * This method overrides the parent implementation by replacing
  * the body content with the processed text content.
  * @param THtmlWriter writer
  */
 public function renderContents($writer)
 {
     if (($text = $this->getText()) === '' && $this->getHasControls()) {
         $textWriter = new TTextWriter();
         parent::renderContents(new THtmlWriter($textWriter));
         $text = $textWriter->flush();
     }
     if ($text !== '') {
         $writer->write($this->processText($text));
     }
 }
Esempio n. 3
0
 /**
  * Renders the form.
  * @param THtmlWriter writer
  */
 public function render($writer)
 {
     $page = $this->getPage();
     $page->beginFormRender($writer);
     $textWriter = new TTextWriter();
     $this->renderChildren(new THtmlWriter($textWriter));
     $content = $textWriter->flush();
     $page->endFormRender($writer);
     $this->addAttributesToRender($writer);
     $writer->renderBeginTag('form');
     $cs = $page->getClientScript();
     if ($page->getClientSupportsJavaScript()) {
         $cs->renderHiddenFields($writer);
         $cs->renderScriptFiles($writer);
         $cs->renderBeginScripts($writer);
         $writer->write($content);
         $cs->renderEndScripts($writer);
     } else {
         $cs->renderHiddenFields($writer);
         $writer->write($content);
     }
     $writer->renderEndTag();
 }
 /**
  * Returns the text content wrapped within a HTML comment with boundary
  * identifier as its comment content.
  * @return string text content chunck.
  */
 public function flush()
 {
     $content = parent::flush();
     if (empty($content)) {
         return "";
     }
     return '<!--' . $this->getBoundary() . '-->' . $content . '<!--//' . $this->getBoundary() . '-->';
 }
Esempio n. 5
0
 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);
         }
     }
 }
 /**
  * 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);
 }
Esempio n. 7
0
 public function testRenderWithDocumentPathAndTransformPath()
 {
     $expected = "<b>Hello World!</b>\n";
     $transform = new TXmlTransform();
     $transform->setDocumentPath($this->documentPath);
     $transform->setTransformPath($this->transformPath);
     $textWriter = new TTextWriter();
     $htmlWriter = new THtmlWriter($textWriter);
     $transform->render($htmlWriter);
     $actual = $textWriter->flush();
     self::assertEquals($expected, $actual);
 }
 /**
  * Returns the text content wrapped within a HTML comment with boundary
  * identifier as its comment content.
  * @return string text content chunck.
  */
 public function flush()
 {
     $content = '<!--' . $this->getBoundary() . '-->';
     $content .= parent::flush();
     $content .= '<!--//' . $this->getBoundary() . '-->';
     return $content;
 }
Esempio n. 9
0
 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);
         }
     }
 }
 /**
  * @return string parameter contents.
  */
 public function getParameter()
 {
     $value = $this->getValue();
     if (strlen($value) > 0) {
         return $value;
     }
     $textWriter = new TTextWriter();
     $this->renderControl(new THtmlWriter($textWriter));
     return $this->getTrim() ? trim($textWriter->flush()) : $textWriter->flush();
 }
Esempio n. 11
0
 /**
  * Renders body content.
  * This method overrides parent implementation by removing
  * malicious javascript code from the body content
  * @param THtmlWriter writer
  */
 public function render($writer)
 {
     $textWriter = new TTextWriter();
     parent::render(new THtmlWriter($textWriter));
     $writer->write($this->parseSafeHtml($textWriter->flush()));
 }
Esempio n. 12
0
 /**
  * renders the translated string.
  */
 public function render($writer)
 {
     $textWriter = new TTextWriter();
     $htmlWriter = new THtmlWriter($textWriter);
     $subs = array();
     foreach ($this->getParameters() as $key => $value) {
         $subs['{' . $key . '}'] = $value;
     }
     foreach ($this->getControls() as $control) {
         if ($control instanceof TTranslateParameter) {
             $subs['{' . $control->getKey() . '}'] = $control->getParameter();
         } elseif ($control instanceof TControl) {
             $control->render($htmlWriter);
         } elseif (is_string($control)) {
             $textWriter->write($control);
         }
     }
     $text = $this->getText();
     if (strlen($text) == 0) {
         $text = $textWriter->flush();
     }
     if ($this->getTrim()) {
         $text = trim($text);
     }
     $writer->write($this->translateText($text, $subs));
 }
Esempio n. 13
0
 public function testWriteLine()
 {
     $writer = new TTextWriter();
     $writer->writeLine('some text');
     self::assertEquals("some text\n", $writer->flush());
 }