Exemple #1
0
 /**
  * Renders any custom LINK tags for the page header.
  */
 public static function outputLinkTags()
 {
     foreach (self::getLinks() as $link) {
         echo Tag::renderTag('link', $link), PHP_EOL;
     }
 }
Exemple #2
0
 /**
  * Render a custom block of HTML.
  *
  * @param  string  $error  An error message to show, if applicable.
  *
  * @return  string
  */
 public function render($error = null)
 {
     $out = '';
     if (isset($this['label'])) {
         $labelcontent = String::escape($this['label']) . ':';
         if (isset($this['required']) && $this['required']) {
             $labelcontent .= ' <em>Required</em>';
         }
         $out .= Tag::renderTag('label', array('for' => $this['id']), $labelcontent) . "\n";
     }
     if (isset($this['content'])) {
         $content = $this['content'];
     } else {
         $content = '';
     }
     if ($error) {
         $out .= self::renderError($this->props, $error);
         if (!isset($this->props['class'])) {
             $this->props['class'] = 'haserror';
         } elseif (!preg_match('/(?:^| )haserror(?:$| )/', $this->props['class'])) {
             $this->props['class'] .= ' haserror';
         }
     }
     $attrs = array_diff_key($this->props, array_flip(array('content', 'escape', 'name', 'type')));
     $out .= Tag::renderTag('div', $attrs, $content) . "\n";
     return $out;
 }
Exemple #3
0
 /**
  * Render this footnote list using the current render context and return it 
  * as a string.
  *
  * @return  string
  */
 public function render()
 {
     $out = Tag::renderTag('ul', array('class' => $this->class_list)) . PHP_EOL;
     $index = 1;
     foreach ($this->footnotes as $footnote) {
         $attrs = array('href' => '#' . $this->fragment . '-' . $index);
         $a = Tag::renderTag('a', $attrs, $index);
         $attrs = array('id' => $this->fragment . $index);
         $out .= Tag::renderTag('li', $attrs, $a . ': ' . $footnote) . PHP_EOL;
         $index++;
     }
     $out .= '</ul>' . PHP_EOL;
     return $out;
 }
Exemple #4
0
 /**
  * Render a list of URLs and their child lists, applying highlight classes
  * to the \t <li> items as necessary.
  *
  * @param  array  $urls       The list of URLs to be rendered.
  * @param  array  $top_attrs  The attributes for the \t &lt;ul&gt; parent.
  * @param  int    $level      The current level in the URL tree.
  *
  * @return  string
  */
 protected function renderURLs($urls, $top_attrs, $level = 0)
 {
     $out = '';
     if ($this->level_hints) {
         if (isset($top_attrs['class'])) {
             $top_attrs['class'] .= ' level' . $level;
         } else {
             $top_attrs['class'] = 'level' . $level;
         }
     }
     $out .= Tag::renderTag('ul', $top_attrs);
     $cururl = $this->getOurUrl();
     $besturl = $this->getBestUrl($level);
     foreach ($urls as $url) {
         if (!isset($url[1])) {
             $a_text = htmlentities($url[0], ENT_QUOTES, 'UTF-8');
             $content = Tag::renderTag('span', array('class' => 'nolink'), $a_text);
             if (isset($i_attrs['_children']) && count($i_attrs['_children'])) {
                 $children = $i_attrs['_children'];
                 $child_attrs = isset($i_attrs['_child_attrs']) ? $i_attrs['_child_attrs'] : array();
                 $content .= $this->renderURLs($children, $child_attrs, $level + 1);
             }
             $out .= Tag::renderTag('li', $i_attrs, $content);
             continue;
         }
         $a_text = htmlentities($url[0], ENT_QUOTES, 'UTF-8');
         $a_attrs = array('href' => $url[1]);
         $i_attrs = isset($url[2]) ? $url[2] : array();
         $i_class = isset($i_attrs['class']) ? array($i_attrs['class']) : array();
         if (isset($i_attrs['accesskey'])) {
             $a_attrs['accesskey'] =& $i_attrs['accesskey'];
             unset($i_attrs['accesskey']);
         }
         $static_link = false;
         if (!is_null($this->exact_url_class) && $url[1] == $cururl) {
             $i_class[] = $this->exact_url_class;
             $static_link |= $this->static_exact;
         } elseif (!is_null($this->best_match_class)) {
             if ($besturl == false && isset($i_attrs['_default']) && $i_attrs['_default'] || $url[1] == $besturl) {
                 $i_class[] = $this->best_match_class;
                 $static_link |= $this->static_best;
             }
         }
         if (count($i_class)) {
             $i_attrs['class'] = implode(' ', $i_class);
         }
         if ($static_link) {
             $content = Tag::renderTag('span', array(), $a_text);
             if (isset($i_attrs['_children']) && count($i_attrs['_children'])) {
                 $children = $i_attrs['_children'];
                 $child_attrs = isset($i_attrs['_child_attrs']) ? $i_attrs['_child_attrs'] : array();
                 $content .= $this->renderURLs($children, $child_attrs, $level + 1);
             }
         } else {
             $content = Tag::renderTag('a', $a_attrs, $a_text);
             if (isset($i_attrs['_children']) && count($i_attrs['_children'])) {
                 $children = $i_attrs['_children'];
                 $child_attrs = isset($i_attrs['_child_attrs']) ? $i_attrs['_child_attrs'] : array();
                 $content .= $this->renderURLs($children, $child_attrs, $level + 1);
             }
         }
         $out .= Tag::renderTag('li', $i_attrs, $content);
     }
     $out .= "</ul>";
     return $out;
 }