public function render() { if ($this->icon) { $label = Html::icon($this->icon) . ' ' . Html::escape($this->label); } else { $label = Html::escape($this->label); } echo Html::element($this->tag, $this->attributes, $label); }
/** * Render the element(s). */ public function render() { if (method_exists($this, 'renderContents')) { echo Html::element($this->tag, $this->attributes, true); $this->renderContents(); echo '</', $this->tag, '>'; } else { echo Html::element($this->tag, $this->attributes); } }
public function renderContents() { foreach ($this->items as $label => $values) { echo "\t"; echo Html::element('dt', array(), $label); if (is_array($values)) { foreach ($values as $value) { echo Html::element('dd', array(), $value); } } else { echo Html::element('dd', array(), $values); } } }
public function renderContents() { echo "\n"; foreach ($this->crumbs as $crumb) { if ($crumb['url'] == false || \Sledgehammer\value($crumb['active'])) { echo "\t<li class=\"active\">"; } else { echo "\t<li>"; } if (isset($crumb['icon'])) { $label = Html::icon($crumb['icon']) . ' ' . Html::escape($crumb['label']); } else { $label = Html::escape($crumb['label']); } if ($crumb['url']) { echo Html::element('a', array('href' => $crumb['url']), $label); } else { echo $label; } echo "</li>\n"; } }
public function render() { if ($this->count == 0) { // No pages, no pagination return; } $start = 1; $end = $this->count; $pages = array(); $class = 'pagination'; if ($this->align != 'left') { $class .= ' pagination-' . $this->align; } echo '<div class="' . $class . "\"><ul>\n"; // previous if ($this->current != 1) { echo "\t<li>", Html::element('a', array('href' => $this->href . ($this->current - 1)), '«'), "</li>\n"; } if ($this->count > $this->max) { $offset = floor($this->max / 2); if ($this->current < $offset + 2) { $end = $this->max - 1; } else { if ($this->current + $offset > $this->count) { $start = $this->count - $this->max; } else { $start = $this->current - $offset; } $end = $this->current + $offset; if ($end > $this->count) { $end = $this->count; } } } // numbers for ($i = $start; $i <= $end; ++$i) { $attributes = $i == $this->current ? array('class' => 'active') : array(); echo "\t", Html::element('li', $attributes, Html::element('a', array('href' => $this->href . $i), $i)), "\n"; } // total pages indication if ($end != $this->count) { if ($end != $this->count - 1) { $nextDecimal = floor($this->current / 10) * 10 + 10; if ($nextDecimal > $this->count) { $nextDecimal = $this->count; } echo "\t<li>", Html::element('a', array('href' => $this->href . $nextDecimal), '...'), "</li>\n"; // @todo jump to page } echo "\t<li>", Html::element('a', array('href' => $this->href . $this->count), $this->count), "</li>\n"; } // next if ($this->current != $this->count) { echo "\t<li>", Html::element('a', array('href' => $this->href . ($this->current + 1)), '»'), "</li>\n"; } echo '</ul></div>'; }
protected function renderElement() { $type = strtolower($this->getAttribute('type')); if (in_array($type, ['select', 'textarea'])) { $this->tag = $type; unset($this->attributes['type']); } $attributes = $this->attributes; switch ($this->tag) { case 'select': $options = $attributes['options']; unset($attributes['options'], $attributes['value']); echo Html::element($this->tag, $attributes, true); $selected = $this->getAttribute('value'); $isIndexed = \Sledgehammer\is_indexed($options); foreach ($options as $value => $label) { $option = array(); if ($isIndexed) { $value = $label; } else { $option['value'] = $value; } if (\Sledgehammer\equals($value, $selected)) { $option['selected'] = 'selected'; } echo Html::element('option', $option, Html::escape($label)); } echo '</select>'; break; case 'textarea': unset($attributes['value']); echo Html::element($this->tag, $attributes, Html::escape($this->getAttribute('value'))); break; default: echo Html::element($this->tag, $attributes); break; } }