protected function imagesrc($content, $media, $template, $mediaStyle = null, $setSize = null)
 {
     $mediaMetas = $this->setConvertparams($media->mediaMetas, true);
     $src = $media->mediaLink;
     $img = '<img src="' . $src . '"';
     if (null !== $setSize) {
         if (is_array($setSize) && isset($setSize['landscape']) && false !== $setSize['landscape']) {
             $landscape = $setSize['landscape'];
             $styleAttr = ' landscape';
             if (isset($setSize['portrait']) && false !== $setSize['portrait']) {
                 $styleAttr = ' portrait';
                 $portrait = $setSize['portrait'];
             } else {
                 $styleAttr = ' portrait';
                 $portrait = $landscape;
             }
         } else {
             $portrait = $landscape = $setSize;
         }
         $resize = new CalculateResize($landscape);
         $resize->setFile(DOCUMENT_ROOT . DS . $src);
         $resize->getNewSize();
         if ('portrait' == $resize->getFormat()) {
             $resize->setTarget($portrait);
             $resize->getNewSize();
         }
         $img .= ' ' . $resize->getHtmlString();
     }
     if (isset($mediaMetas['alt'])) {
         $img .= ' alt="' . $mediaMetas['alt'] . '"';
     }
     if (false !== ($title = $this->hasValue($mediaMetas, 'title'))) {
         $img .= ' title="' . $title . '"';
     }
     $img .= ' />';
     if (strlen($content->mediaLinkUrl) > 0) {
         $img = '<a href="' . $content->mediaLinkUrl . '">' . $img . '</a>';
     }
     $mediarows = $template;
     if (null !== $mediaStyle) {
         $mediarows['row']['attr']['class'] .= ' ' . $mediaStyle;
     }
     if (false !== ($caption = $this->hasValue($mediaMetas, 'caption'))) {
         $mediarows['row']['content:before'] = $img;
         $images = $this->deployRow($mediarows, $caption);
     } else {
         $images = $this->deployRow(array('grid' => $mediarows['row']), $img);
     }
     return $images;
 }
 public function __invoke($entries, $template, $media)
 {
     $templateKey = static::VIEW_TEMPLATE;
     if (isset($entries['modulFormat'])) {
         $templateKey = $entries['modulFormat'];
     }
     $this->setTemplate($template->plugins->{$templateKey});
     $labelReadMore = $this->labelReadMore->toArray();
     $publishDate = $this->publishDate->toArray();
     $publishDate['grid']['format']['dateFormat']['attr'] = $this->getDateFormat($entries);
     $filter = new \Zend\Filter\HtmlEntities();
     $html = '';
     foreach ($entries['modulContent']['news'] as $entry) {
         $article = '';
         $head = '';
         $arr = preg_split('/[\\s]+/', $entry['publish_date']);
         $lnPublishDate = $arr[0];
         $publishDate['grid']['attr']['datetime'] = $entry['publish_date'];
         $head .= $this->deployRow($publishDate, $entry['publish_date']);
         if (isset($entry['publish_author'])) {
             $head .= $this->deployRow($this->publishAuthor, $entry['publish_author']);
         }
         $blogId = 'blog' . $entry['id'];
         if (null !== $this->toolbar) {
             $links['pdf'] = array('href' => '/' . $entry['id']);
             $links['facebook'] = array('href' => '?u=' . urlencode($this->view->protocol . '://' . $this->view->host . '/' . $entry['url'] . '/' . $entry['source'] . '/' . $entry['lnPublishDate'] . '#' . $blogId));
             $links['sendmail'] = array('href' => '/' . $entry['id']);
             $head .= $this->view->contenttoolbar($links, $this->toolbar->toArray());
         }
         $head .= $this->deployRow($this->headline, $entry['headline']);
         $article .= $this->deployRow($this->header, $head);
         if (1 !== (int) $entry['web_medias_id'] && 'no' !== $this->displayimage) {
             if ('mediateaserright' == $entry['htmlwidgets']) {
                 $mediaTemplate = $this->mediateaserright->toArray();
             } else {
                 $mediaTemplate = $this->mediateaserleft->toArray();
             }
             $setSize = array('landscape' => $this->teaserLandscapeSize, 'portrait' => $this->teaserPortraitSize);
             $mediaMetas = $this->setConvertparams($entry['media_metas'], true);
             $img = '<img src="' . $entry['media_link'] . '"';
             if (is_array($setSize) && isset($setSize['landscape']) && false !== $setSize['landscape']) {
                 $landscape = $setSize['landscape'];
                 $styleAttr = ' landscape';
                 if (isset($setSize['portrait']) && false !== $setSize['portrait']) {
                     $styleAttr = ' portrait';
                     $portrait = $setSize['portrait'];
                 } else {
                     $styleAttr = ' portrait';
                     $portrait = $landscape;
                 }
             } else {
                 $portrait = $landscape = $setSize;
             }
             $resize = new CalculateResize($landscape);
             $resize->setFile(DOCUMENT_ROOT . DS . $entry['media_link']);
             $resize->getNewSize();
             if ('portrait' == $resize->getFormat()) {
                 $resize->setTarget($portrait);
                 $resize->getNewSize();
             }
             $img .= ' ' . $resize->getHtmlString();
             if (isset($mediaMetas['alt'])) {
                 $img .= ' alt="' . $mediaMetas['alt'] . '"';
             }
             if (false !== ($title = $this->hasValue($mediaMetas, 'title'))) {
                 $img .= ' title="' . $title . '"';
             }
             $img .= ' />';
             $mediaTemplate['row']['attr']['class'] .= ' teaser-imageitem-size';
             if (false !== ($caption = $this->hasValue($mediaMetas, 'caption'))) {
                 $mediaTemplate['row']['content:before'] = $img;
                 $images = $this->deployRow($mediaTemplate, $caption);
             } else {
                 $images = $this->deployRow(array('grid' => $mediaTemplate['row']), $img);
             }
             $article .= $images;
         }
         $labelReadMore["grid"]["attr"]['href'] = '/' . $entry['url'] . '/' . $entry['source'] . '/' . $entry['lnPublishDate'] . '#' . $blogId;
         $labelReadMore["grid"]["attr"]['title'] = $entry['label_read_more'] . ' zu ' . $filter->filter($entry['headline']);
         if (strlen($entry['content_teaser']) > 1) {
             $article .= $entry['content_teaser'];
             $article .= $this->deployRow($labelReadMore, $entry['label_read_more']);
         } else {
             $content = $entry['content'];
             if ($entry['number_character_teaser'] > 0 && strlen($content) > $entry['number_character_teaser']) {
                 $content = substr($content, 0, $entry['number_character_teaser']);
                 $content = substr($content, 0, strrpos($content, " "));
                 $content = $content . ' ...</p>';
                 $article .= $content;
                 $article .= $this->deployRow($labelReadMore, $entry['label_read_more']);
             } else {
                 $article .= $content;
             }
         }
         //$article .= '<p><a class="button expand" title="Lesen Sie mehr" href="#">Lesen Sie mehr</a></p>';
         //$newtemplate = $this->news->toArray();
         //$newtemplate['grid']['content:after:outside'] = '<p><a class="button expand" title="Lesen Sie mehr" href="#">Lesen Sie mehr</a></p>';
         $html .= $this->deployRow($this->news, $article);
     }
     if (null !== $this->wrapper) {
         $html = $this->deployRow($this->wrapper, $html);
     }
     return $html;
 }