/**
  * Build editing toolbar
  * @param array $links
  * @return string
  */
 public function __invoke(array $links)
 {
     $html = '<ul class="tableEdit">';
     foreach ($links as $link) {
         $html .= '<li><a href="' . $link['href'] . '"';
         if (isset($link['attribs']) && is_array($link['attribs'])) {
             $html .= HtmlAttribute::attributeArray($link['attribs']);
         }
         $html .= '>' . $link['label'] . '</a></li>';
     }
     $html .= '</ul>';
     return $html;
 }
 /**
  * Created a list depending on the given array
  *
  * @param array $links condition for the list
  * @return string list in html
  */
 public function __invoke(array $links, $std = false, array $list = null, $translate = true)
 {
     $this->emptyProps();
     $this->setStandards($list);
     $html = '<ul';
     $html .= HtmlAttribute::attributeArray($this->attribute);
     $html .= '>';
     foreach ($links as $key => $link) {
         $standard = array();
         if (is_array($link) && true === $std && ($standard = $this->getStandards($key))) {
             $link = ArrayMergeRecursiveDistinct::merge($standard, $link);
         } else {
             $link = $this->getStandards($key);
         }
         $html .= '<li><' . $this->tag;
         if ('a' == $this->tag && false !== $link['href']) {
             $html .= ' href="' . $link['href'] . '"';
         }
         if (isset($link['attribs']) && is_array($link['attribs'])) {
             foreach ($link['attribs'] as $attr => $val) {
                 if (false !== $val) {
                     if ('title' === $attr) {
                         $val = $this->view->translate($val);
                     }
                     $html .= HtmlAttribute::attributeString($attr, $val, true);
                 }
             }
         }
         $html .= '>';
         $html .= true === $translate ? $this->view->translate($link['label']) : $link['label'];
         $html .= '</' . $this->tag . '>';
         $html .= '</li>';
     }
     $html .= '</ul>';
     return $html;
 }
 /**
  *
  * @param unknown $html
  * @param unknown $content
  */
 protected function formatElement($html, $content)
 {
     if (strlen($content->element) > 0) {
         $attr = '';
         switch ($content->element) {
             case 'panel':
             case 'flexvideo':
             case 'flexwide':
             case 'flexvimeo':
             case 'column2':
                 $element = 'div';
                 break;
             default:
                 $element = $content->element;
                 break;
         }
         if (strlen($content->elementAttribute) > 0) {
             $attribute = $this->elementAttribute($content->elementAttribute);
             $attr = HtmlAttribute::attributeArray($attribute);
         }
         $elmContent = '';
         if (strlen($content->elementContent) > 0) {
             $elmContent = $content->elementContent;
         }
         switch ($content->element) {
             case 'flexvideo':
             case 'flexwide':
             case 'flexvimeo':
             case 'column2':
                 $html .= '<' . $element . $attr . '>' . $elmContent . '</' . $element . '>';
                 break;
             default:
                 $html = '<' . $element . $attr . '>' . $html . $elmContent . '</' . $element . '>';
                 break;
         }
     }
     return $html;
 }
 /**
  *
  * @param unknown $link
  * @return string
  */
 protected function buildLink($link)
 {
     $ln = '<a href="' . $link['href'] . '"';
     if (isset($link['attr'])) {
         $ln .= HtmlAttribute::attributeArray($link['attr']);
     }
     $ln .= '>';
     $label = '';
     if (isset($link['icon'])) {
         $label .= $link['icon'];
     }
     if (isset($link['content'])) {
         if (strlen($label) > 1) {
             $label .= ' ';
         }
         $label .= $link['content'];
     }
     $ln .= $label . '</a>';
     return $ln;
 }
 /**
  * List years
  * @param array $entries
  * @return string html
  */
 protected function listitems($entries)
 {
     $grid = $this->getTemplateProperty('grid', 'element');
     $row = $this->getTemplateProperty('row', 'element');
     $html = '';
     foreach ($entries as $year => $url) {
         $html .= '<' . $grid;
         $attr = array();
         $html .= HtmlAttribute::attributeArray($attr);
         $html .= '><a class="getArchivEvent" ';
         $attr = array();
         $attr['href'] = '/' . $url . '/archive/' . $year;
         $html .= HtmlAttribute::attributeArray($attr);
         $html .= '>' . $this->view->translate('Year') . ' ' . $year . '</a>';
         $html .= '</' . $grid . '>';
     }
     return $html;
 }
 /**
  * Set html tag attributte
  *
  * @param array $defaults            
  * @param array $page            
  * @param Zend\View\Model\ViewModel $layout            
  */
 protected function setHtmlAttribute($pageOptions, $layout)
 {
     $attribute = '';
     foreach ($this->htmlAttributes as $column => $attr) {
         $value = $this->getPageAttribute($pageOptions, $column);
         if (false !== $value) {
             $attribute .= HtmlAttribute::attributeString($attr, $value, true);
         }
     }
     if (strlen($attribute) > 0) {
         $layout->htmlTagAttribs = $attribute;
     }
 }
 public function __invoke($content, $groupIdent, $template, $contentstyles, array $specified = null)
 {
     $this->setTemplate($template);
     if (null !== $specified) {
         $this->setSpecified($specified);
     }
     $str = '';
     $i = 0;
     $filter = new Prepare();
     $grid = $this->getTemplateProperty('body', 'grid', 'element');
     foreach ($content as $entry) {
         if ($groupIdent == $entry->webContentgroup) {
             $attr = $this->getTemplateProperty('body', 'grid', 'attr');
             $panelId = $filter->filter($entry->webContent->title);
             if (0 === $i) {
                 $this->headercontent[] = '<a href="#' . $panelId . '" role="tab" tabindex="0" aria-selected="true" controls="' . $panelId . '">' . $entry->webContent->title . '</a>';
             } else {
                 $this->headercontent[] = '<a href="#' . $panelId . '" role="tab" tabindex="0" aria-selected="false" controls="' . $panelId . '">' . $entry->webContent->title . '</a>';
             }
             $str .= '<' . $grid;
             if (0 === $i) {
                 $attr['class'] .= ' ' . $this->active;
                 $attr['aria-hidden'] = 'false';
             } else {
                 $attr['aria-hidden'] = 'true';
             }
             $attr['id'] = $panelId;
             $str .= HtmlAttribute::attributeArray($attr) . '>';
             $str .= $this->view->contribution($entry->webContent, $contentstyles);
             $str .= '</' . $grid . '>';
             $i++;
         }
     }
     $attr = false;
     $factory = new HtmlElements(new FactoryElement());
     $row = $this->getTemplateProperty('body', 'row', 'element');
     if ($row) {
         $factory->setContentTag($row);
         $attr = $this->getTemplateProperty('body', 'row', 'attr');
         if (false !== $attr) {
             $factory->setTagAttributtes(false, $attr, 0);
             $attr = false;
         }
     }
     $factory->setHtmlContent($str);
     $str = '';
     $tabBody = $factory->display();
     $factory = new HtmlElements(new FactoryElement());
     $row = $this->getTemplateProperty('header', 'row', 'element');
     if ($row) {
         $factory->setContentTag($row);
         $attr = $this->getTemplateProperty('header', 'row', 'attr');
         if (false !== $attr) {
             $factory->setTagAttributtes(false, $attr, 0);
             $attr = false;
         }
     }
     $grid = $this->getTemplateProperty('header', 'grid', 'element');
     $i = 0;
     foreach ($this->headercontent as $headerentry) {
         $attr = $this->getTemplateProperty('header', 'grid', 'attr');
         $str .= '<' . $grid;
         if (0 === $i) {
             $attr['class'] .= ' ' . $this->active;
         }
         $str .= HtmlAttribute::attributeArray($attr);
         $str .= '>';
         $str .= $headerentry;
         $str .= '</' . $grid . '>';
         $i++;
     }
     $factory->setHtmlContent($str);
     $tabHeader = $factory->display();
     return $tabHeader . $tabBody;
 }
 /**
  * Copy from Zend View Helper Menu
  * @see \Zend\View\Helper\Navigation\Menu::renderNormalMenu()
  */
 protected function renderNormalMenu(AbstractContainer $container, $ulClass, $indent, $minDepth, $maxDepth, $onlyActive, $escapeLabels, $addClassToListItem, $liActiveClass)
 {
     $html = '';
     // find deepest active
     $found = $this->findActive($container, $minDepth, $maxDepth);
     if ($found) {
         $foundPage = $found['page'];
         $foundDepth = $found['depth'];
     } else {
         $foundPage = null;
     }
     // create iterator
     $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::SELF_FIRST);
     if (is_int($maxDepth)) {
         $iterator->setMaxDepth($maxDepth);
     }
     // iterate container
     $prevDepth = -1;
     foreach ($iterator as $page) {
         $depth = $iterator->getDepth();
         if (false === ($isActive = $page->isActive(true))) {
             if ('index' === $this->view->url) {
                 $url = '/';
             } else {
                 $url = '/' . $this->view->url;
             }
             if ($url === $page->uri) {
                 $isActive = true;
             }
         }
         if ($depth < $minDepth || !$this->accept($page)) {
             // page is below minDepth or not accepted by acl/visibility
             continue;
         } elseif ($onlyActive && !$isActive) {
             // page is not active itself, but might be in the active branch
             $accept = false;
             if ($foundPage) {
                 if ($foundPage->hasPage($page)) {
                     // accept if page is a direct child of the active page
                     $accept = true;
                 } elseif ($foundPage->getParent()->hasPage($page)) {
                     // page is a sibling of the active page...
                     if (!$foundPage->hasPages() || is_int($maxDepth) && $foundDepth + 1 > $maxDepth) {
                         // accept if active page has no children, or the
                         // children are too deep to be rendered
                         $accept = true;
                     }
                 }
             }
             if (!$accept) {
                 continue;
             }
         }
         //print '<pre>';
         //var_dump($page);exit;
         // make sure indentation is correct
         $depth -= $minDepth;
         $myIndent = $indent . str_repeat('        ', $depth);
         if ($depth > $prevDepth) {
             // start new ul tag
             if ($ulClass && $depth == 0) {
                 $ulClass = ' class="' . $ulClass . '"';
                 $ulAttribute = '';
                 if (!empty($this->ulAttribute)) {
                     foreach ($this->ulAttribute as $ulKey => $ulVal) {
                         $ulAttribute .= ' ' . $ulKey . '="' . $ulVal . '"';
                     }
                 }
                 $ulIdent = '';
             } else {
                 $ulClass = $this->subUlClass . $this->subUlAttribute;
                 $ulAttribute = '';
                 $ulIdent = ' data-ident="subIdent' . $page->get('aIdent') . '"';
             }
             $html .= $myIndent . '<ul' . $ulIdent . $ulClass . $ulAttribute . '>' . self::EOL;
         } elseif ($prevDepth > $depth) {
             // close li/ul tags until we're at current depth
             for ($i = $prevDepth; $i > $depth; $i--) {
                 $ind = $indent . str_repeat('        ', $i);
                 $html .= $ind . '    </li>' . self::EOL;
                 $html .= $ind . '</ul>' . self::EOL;
             }
             // close previous li tag
             $html .= $myIndent . '    </li>' . self::EOL;
         } else {
             // close previous li tag
             $html .= $myIndent . '    </li>' . self::EOL;
         }
         // render li tag and page
         $liClasses = array();
         // Is page active?
         if ($isActive) {
             $liClasses[1] = 'active';
         }
         if (true == ($subUlClass = $page->get('subUlClass'))) {
             $this->subUlClass = ' class="' . $subUlClass . '"';
         } else {
             $this->subUlClass = '';
         }
         if (true == ($subUlAttribute = $page->get('subUlAttribute'))) {
             $this->subUlAttribute = HtmlAttribute::attributeArray($subUlAttribute);
         } else {
             $this->subUlAttribute = '';
         }
         if (true == ($listClass = $page->get('listClass'))) {
             $liClasses[2] = $listClass;
         }
         $liIdent = '';
         if (true == ($listIdent = $page->get('listIdent'))) {
             $liIdent = ' id="' . $listIdent . '"';
         }
         $liClass = empty($liClasses) ? '' : ' class="' . implode(' ', $liClasses) . '"';
         $html .= $myIndent . '    <li' . $liIdent . $liClass . '>' . self::EOL . $myIndent . '        ' . $this->htmlify($page, $escapeLabels, $addClassToListItem) . self::EOL;
         // store as previous depth for next iteration
         $prevDepth = $depth;
     }
     if ($html) {
         // done iterating container; close open ul/li tags
         for ($i = $prevDepth + 1; $i > 0; $i--) {
             $myIndent = $indent . str_repeat('        ', $i - 1);
             $html .= $myIndent . '    </li>' . self::EOL . $myIndent . '</ul>' . self::EOL;
         }
         $html = rtrim($html, self::EOL);
     }
     return $html;
 }
 /**
  *
  * @param unknown $script
  * @param unknown $attribute
  */
 protected function linkScript($src, $attribute = array())
 {
     return '<script src="' . $src . '"' . HtmlAttribute::attributeArray($attribute) . '></script>';
 }