Пример #1
0
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 public function paint(Stream\IStream\Out $out)
 {
     $root = $this->getAbstractElementSuperRoot();
     $value = $this->computeValue();
     $with = '__main__';
     if (true === $this->abstract->attributeExists('with')) {
         $with = $this->abstract->readAttribute('with');
     }
     $translation = $root->getTranslation($with);
     if (null === $translation) {
         $out->writeAll($value);
         return;
     }
     $callable = null;
     $arguments = [$value];
     if (true === $this->abstract->attributeExists('n')) {
         $callable = xcallable($translation, '_n');
         $arguments[] = $this->abstract->readAttribute('n');
     } else {
         $callable = xcallable($translation, '_');
     }
     $with = $this->abstract->readCustomAttributes('with');
     if (!empty($with)) {
         foreach ($with as $w) {
             $arguments[] = $this->computeAttributeValue($w);
         }
     }
     $result = $callable->distributeArguments($arguments);
     if (false !== strpos($result, '<')) {
         $this->computeFromString($result);
     } else {
         $out->writeAll($result);
     }
     return;
 }
Пример #2
0
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 protected function paint(Stream\IStream\Out $out)
 {
     $root = $this->getAbstractElementSuperRoot();
     $locale = $root->getLocale();
     $language = null;
     if (null !== $locale) {
         $language .= ' lang="' . $locale->getLanguage() . '"';
     }
     $out->writeAll('<!DOCTYPE html>' . "\n\n" . '<!--[if lt IE 7]><html class="ie6"><![endif]-->' . "\n" . '<!--[if    IE 7]><html class="ie7"><![endif]-->' . "\n" . '<!--[if    IE 8]><html class="ie8"><![endif]-->' . "\n" . '<!--[if (gte IE 9)|!(IE)]>' . "\n" . '<html' . $language . '>' . "\n" . '<![endif]-->' . "\n" . '<head>' . "\n");
     if (null !== $this->_title) {
         $out->writeAll('  ');
         $this->_title->render($out);
     }
     $out->writeAll("\n" . '  <meta http-equiv="content-type" content="text/html; charset=utf-8" />' . "\n" . '  <meta http-equiv="content-type" content="text/javascript; charset=utf-8" />' . "\n" . '  <meta http-equiv="content-type" content="text/css; charset=utf-8" />' . "\n");
     foreach ($root->getMetas() as $meta) {
         $out->writeAll('  <meta ' . $meta . ' />' . "\n");
     }
     $stylesheets = $root->getStylesheets();
     if (!empty($stylesheets)) {
         $out->writeAll("\n");
         foreach ($stylesheets as $href) {
             $out->writeAll('  <link type="text/css" href="' . $href . '" rel="stylesheet" />' . "\n");
         }
     }
     $out->writeAll('</head>' . "\n" . '<body>' . "\n\n");
     foreach ($this as $child) {
         if ('title' != $child->getName()) {
             $child->render($out);
         }
     }
     $out->writeAll("\n\n" . '</body>' . "\n" . '</html>');
     return;
 }
Пример #3
0
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 protected function paint(Stream\IStream\Out $out)
 {
     // Early draft.
     $out->writeAll('<div class="debug"' . $this->readAttributesAsString() . '>' . "\n");
     $out->writeAll(self::$_message);
     $out->writeAll('</div>' . "\n");
     return;
 }
Пример #4
0
Файл: Error.php Проект: Jir4/Xyl
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 protected function paint(Stream\IStream\Out $out)
 {
     $this->writeAttribute('class', 'error');
     $out->writeAll('<div' . $this->readAttributesAsString() . '>');
     $this->computeValue($out);
     $out->writeAll('</div>');
     return;
 }
Пример #5
0
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 protected function paint(Stream\IStream\Out $out)
 {
     $name = $this->getName();
     $out->writeAll('<' . $name . $this->readAttributesAsString() . '>');
     // Force Internet Explorer <= 8 to use UTF-8.
     $out->writeAll('<input type="hidden" name="__utf8" value="✓" />');
     $this->computeValue($out);
     $out->writeAll('</' . $name . '>');
     return;
 }
Пример #6
0
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 protected function paint(Stream\IStream\Out $out)
 {
     $this->writeAttribute('class', 'toc');
     $out->writeAll('<ol' . $this->readAttributesAsString() . '>');
     $links = $this->selectChildElements('a');
     if (!empty($links)) {
         foreach ($links as $link) {
             $out->writeAll('<li>');
             $this->getConcreteElement($link)->render($out);
             $out->writeAll('</li>');
         }
         $out->writeAll('</ol>');
         return;
     }
     if (empty($this->_headings)) {
         $out->writeAll('</ol>');
         return;
     }
     $n = 1;
     $first = true;
     foreach ($this->_headings as $heading) {
         $ni = $heading->getLevel();
         if (true === $first) {
             $n = $ni;
         }
         if ($n < $ni) {
             for ($i = $ni - $n - 1; $i >= 0; --$i) {
                 $out->writeAll('<ol class="toc toc-depth-' . $ni . '">');
             }
         } elseif ($n > $ni) {
             $out->writeAll('</li>');
             for ($i = $n - $ni - 1; $i >= 0; --$i) {
                 $out->writeAll('</ol></li>');
             }
         } elseif (false === $first) {
             $out->writeAll('</li>');
         } else {
             $first = false;
         }
         $n = $ni;
         $out->writeAll('<li>');
         if (true === $heading->attributeExists('id')) {
             $out->writeAll('<a href="#' . $heading->readAttribute('id') . '">');
             $heading->computeTransientValue($out);
             $out->writeAll('</a>');
         } else {
             $heading->computeTransientValue($out);
         }
     }
     for ($i = $n - 2; $i >= 0; --$i) {
         $out->writeAll('</li></ol>');
     }
     return;
 }
Пример #7
0
Файл: Code.php Проект: Jir4/Xyl
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 protected function paint(Stream\IStream\Out $out)
 {
     $out->writeAll('<code' . $this->readAttributesAsString() . '>');
     if (true === $this->attributeExists('class') && 'language-' === substr($this->readAttribute('class'), 0, 9)) {
         $out->writeAll($this->computeValue());
     } else {
         $this->computeValue($out);
     }
     $out->writeAll('</code>');
     return;
 }
Пример #8
0
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 protected function paint(Stream\IStream\Out $out)
 {
     $name = $this->getName();
     if (0 !== $this->_contentFlow) {
         $out->writeAll('<' . $name . $this->readAttributesAsString() . '>');
         $this->computeValue($out);
         $out->writeAll('</' . $name . '>');
         return;
     }
     $out->writeAll('<' . $name . $this->readAttributesAsString() . ' />');
     return;
 }
Пример #9
0
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 protected function paint(Stream\IStream\Out $out)
 {
     $name = $this->getName();
     $out->writeAll('<' . $name . $this->readAttributesAsString() . '>');
     if (null === $this->_value) {
         $this->computeValue($out);
     } else {
         $out->writeAll($this->_value);
     }
     $out->writeAll('</' . $name . '>');
     return;
 }
Пример #10
0
Файл: Value.php Проект: Jir4/Xyl
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 public function paint(Stream\IStream\Out $out)
 {
     $value = $this->computeValue();
     if (true === $this->abstract->attributeExists('formatter')) {
         $value = $this->formatValue(empty($value) ? null : $value);
     }
     if (true === $this->abstract->attributeExists('link')) {
         $out->writeAll($this->computeAttributeValue($this->abstract->readAttribute('link'), parent::ATTRIBUTE_TYPE_LINK));
         return;
     }
     $out->writeAll($value);
     return;
 }
Пример #11
0
Файл: Tab.php Проект: Jir4/Xyl
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 protected function paint(Stream\IStream\Out $out)
 {
     $name = $this->getName();
     $for = $this->abstract->readAttribute('for');
     $selected = $this->abstract->readAttribute('aria-selected');
     if ('true' !== $selected) {
         $selected = 'false';
     }
     $this->writeAttribute('role', 'presentation');
     $out->writeAll('<' . $name . $this->readAttributesAsString() . '>' . '<a href="#' . $for . '" role="tab" aria-controls="' . $for . '" ' . 'aria-selected="' . $selected . '" tabindex="-1" ' . 'id="' . $for . '__tab">');
     $this->computeValue($out);
     $out->writeAll('</a></' . $name . '>');
     return;
 }
Пример #12
0
 /**
  * Paint the element.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Out stream.
  * @return  void
  */
 protected function paint(Stream\IStream\Out $out)
 {
     $out->writeAll($this->readAll());
     return;
 }
Пример #13
0
 /**
  * Compute value. If the @bind attribute exists, compute the current data,
  * else compute the abstract element casted as string if no child is
  * present, else rendering all children.
  *
  * @param   \Hoa\Stream\IStream\Out  $out    Output stream. If null, we
  *                                           return the result.
  * @return  string
  */
 public function computeValue(Stream\IStream\Out $out = null)
 {
     $data = false;
     if (true === $this->abstract->attributeExists('bind')) {
         $data = $this->_transientValue = $this->getCurrentData();
     }
     if (null === $out) {
         if (false !== $data) {
             return $data;
         } else {
             return $data = $this->_transientValue = $this->abstract->readAll();
         }
     }
     if (0 === count($this)) {
         if (false !== $data) {
             $out->writeAll($data);
         } else {
             $out->writeAll($this->abstract->readAll());
         }
         return;
     }
     foreach ($this as $child) {
         $child->render($out);
     }
     return;
 }
 /**
  * @param Out $outputStream
  * @param string $line
  *
  * Writes the line ending with a CRLF on the output stream
  */
 protected function writeHttpLine(Out $outputStream, string $line)
 {
     $outputStream->writeString($line . static::CRLF);
 }