Ejemplo n.º 1
0
 protected function render_inner_html()
 {
     global $core;
     $page = $core->request->context->page;
     $translations_by_language = $this->collect();
     new LanguagesElement\CollectEvent($this, array('languages' => &$translations_by_language));
     if (count($translations_by_language) == 1) {
         throw new ElementIsEmpty();
     }
     /*
     if ($template)
     {
     	return $patron($template, $translations_by_language);
     }
     */
     $page_language = $page->language;
     $links = array();
     foreach ($translations_by_language as $language => $record) {
         $link = new Element('a', array(Element::INNER_HTML => $language, 'class' => 'btn language--' . \Brickrouge\normalize($language), 'href' => $record->url));
         if ($language == $page_language) {
             $link->add_class('active');
         }
         $links[$language] = $link;
     }
     new LanguagesElement\AlterEvent($this, array('links' => &$links, 'languages' => &$translations_by_language, 'page' => $page));
     return implode('', $links);
 }
Ejemplo n.º 2
0
 /**
  * Resolve group definitions into {@link Element} instances and sort them according to their
  * {@link WEIGHT}.
  *
  * @param array $groups
  *
  * @return Element[]
  */
 protected function resolve_groups(array $groups)
 {
     foreach ($groups as $group_id => &$group) {
         $group = $this->resolve_group($group);
         if ($group_id && !is_numeric($group_id)) {
             $group->add_class('group--' . \Brickrouge\normalize($group_id));
         }
     }
     return \ICanBoogie\sort_by_weight($groups, function ($v) {
         return $v[self::WEIGHT];
     });
 }
Ejemplo n.º 3
0
 /**
  * Convert the thumbnail into a IMG element.
  *
  * @param array $attributes
  *
  * @return \Brickrouge\Element
  */
 public function to_element(array $attributes = array())
 {
     $w = $this->w;
     $h = $this->h;
     $src = $this->src;
     if ($src instanceof \Icybee\Modules\Images\Image) {
         $alt = $src->alt;
         $size_reference = array($src->width, $src->height);
     } else {
         $alt = '';
         $size_reference = \Brickrouge\DOCUMENT_ROOT . $src;
     }
     list($w, $h) = \ICanBoogie\Image::compute_final_size($w, $h, $this->method, $size_reference);
     $class = 'thumbnail';
     $version_name = $this->version_name;
     if ($version_name) {
         $class .= ' thumbnail--' . \Brickrouge\normalize($version_name);
     }
     return new Element('img', $attributes + array('src' => $this->url, 'alt' => $alt, 'width' => $w, 'height' => $h, 'class' => $class));
 }