Exemple #1
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 public function render($renderApi, $unit, $moduleInfo)
 {
     $classes = array($moduleInfo->getId(), 'isModule', 'isColumnBox', htmlspecialchars($unit->getHtmlClass(), ENT_QUOTES, 'UTF-8'));
     // show add module button in page mode if this is a ghost container
     if ($renderApi->isEditMode() && $renderApi->isPage() && $unit->isGhostContainer()) {
         $classes[] = 'showAddModuleButton';
     }
     // Dimensions, Grid, Responsive-Settings
     $i = 0;
     $resolutions = $renderApi->getResolutions();
     $childWidth = $this->getResponsiveValue($unit, 'cssChildWidth', $renderApi);
     $maxCols = 0;
     $cols = array();
     foreach ($childWidth as $widths) {
         $col = count(explode(' ', trim($widths['value'])));
         $cols[] = $col;
         if ($col > $maxCols) {
             $maxCols = $col;
         }
     }
     $allItems = $renderApi->getChildren($unit);
     $renderItems = array();
     // normal units
     $nonRenderItems = array();
     // extension units
     foreach ($allItems as $item) {
         if ($renderApi->getModuleInfo($item)->isExtension()) {
             // assume that extension modules (i.e. styles) render no html output
             $nonRenderItems[] = $item;
         } else {
             $renderItems[] = $item;
         }
     }
     $counter = max($maxCols, count($renderItems));
     $unitId = $unit->getId();
     $classesStr = implode(' ', $classes);
     echo "<div id='{$unitId}' class='{$classesStr}'><div class='isColumnBoxTable wkFixTableLayout'>";
     for ($i = 0; $i < $counter; $i++) {
         if (array_key_exists($i, $renderItems)) {
             // cell has an item
             echo '<div class="isColumnBoxCell">';
             $renderApi->renderUnit($renderItems[$i]);
             echo '</div>';
             if ($i === count($renderItems) - 1) {
                 echo '<div class="boxSpacer boxSpacerLast"></div>';
             } else {
                 echo '<div class="boxSpacer"></div>';
             }
         } else {
             // empty cell
             echo '<div class="boxPreview isColumnBoxCell">';
             if ($renderApi->isEditMode()) {
                 echo '<div class="RUKZUKemptyBox"></div>';
             }
             echo '</div>';
             echo '<div class="boxSpacer boxPreviewSpacer"></div>';
         }
     }
     echo '</div></div>';
 }
 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit                 $unit
  *
  * @return array
  */
 public function getImageIds($renderApi, $unit)
 {
     $ids = $renderApi->getFormValue($unit, 'galleryImageIds', array());
     if (!is_array($ids)) {
         return array();
     }
     return array_filter($ids);
 }
 /**
  * @param \Render\APIs\APIv1\RenderAPI $api
  *
  * @return array
  */
 private function getAnchors($api)
 {
     $anchors = array();
     $allUnitData = $api->getAllUnitData();
     foreach ($allUnitData as $unitData) {
         if (isset($unitData['anchor'])) {
             if (isset($unitData['anchor']['id']) && isset($unitData['anchor']['name'])) {
                 $anchors[] = $unitData['anchor'];
             }
         }
     }
     return $anchors;
 }
 /**
  * @param \Render\APIs\APIv1\RenderAPI $api
  * @param \Render\Unit                 $unit
  * @param \Render\ModuleInfo           $moduleInfo
  */
 public function render($api, $unit, $moduleInfo)
 {
     echo "START-RENDER:" . $unit->getId() . "\n";
     echo "ASSET-PATH:" . $moduleInfo->getAssetPath('assetPath') . "\n";
     echo "ASSET-URL:" . $moduleInfo->getAssetUrl('assetUrl') . "\n";
     try {
         $url = $api->getMediaItem('ITEM-NOT-EXISTS')->getUrl();
     } catch (\Exception $ignore) {
         $url = '#exception';
     }
     echo "NOT-EXISTS-MEDIA-URL:" . $url . "\n";
     $api->renderChildren($unit);
     echo "END-RENDER:" . $unit->getId() . "\n";
 }
Exemple #5
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $embedCode = $renderApi->getFormValue($unit, 'htmlCode');
     if (!empty($embedCode)) {
         try {
             $attributes = $this->extractAttributes($embedCode);
             echo $this->renderVideo($attributes['src'], $attributes['ratio']);
         } catch (\Exception $e) {
             // in case of errors just echo the entered code
             echo $embedCode;
         }
     }
     $renderApi->renderChildren($unit);
 }
Exemple #6
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param $startPageId
  * @param $enableRecursive
  * @return array
  */
 private function getTeaserItemsRecursive($renderApi, $startPageId, $enableRecursive)
 {
     $items = array();
     $navigation = $renderApi->getNavigation();
     $currentPageId = $renderApi->getNavigation()->getCurrentPageId();
     $childrenIds = $navigation->getChildrenIds($startPageId);
     if (!empty($childrenIds)) {
         foreach ($childrenIds as $pageId) {
             // skip current page
             if ($currentPageId === $pageId) {
                 continue;
             }
             $page = $navigation->getPage($pageId);
             $pageAttributes = $page->getPageAttributes();
             if (array_key_exists('notInPageList', $pageAttributes)) {
                 if ($pageAttributes['notInPageList'] == 1) {
                     if ($enableRecursive) {
                         $items = array_merge($items, $this->getTeaserItemsRecursive($renderApi, $pageId, $enableRecursive));
                     }
                     continue;
                 }
             }
             $items[] = array('pageId' => $pageId, 'pageUrl' => $page->getUrl(), 'pageNavigationTitle' => $page->getNavigationTitle(), 'pageTitle' => $page->getTitle(), 'pageDate' => $page->getDate(), 'pageDescription' => $page->getDescription());
             //iterate recursively?
             if ($enableRecursive) {
                 $items = array_merge($items, $this->getTeaserItemsRecursive($renderApi, $pageId, $enableRecursive));
             }
         }
     }
     return $items;
 }
 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param $startPageId
  * @param $enableRecursive
  * @return array
  */
 private function getTeaserItemsRecursive($renderApi, $startPageId, $enableRecursive)
 {
     $items = array();
     $navigation = $renderApi->getNavigation();
     $currentPageId = $renderApi->getNavigation()->getCurrentPageId();
     $childrenIds = $navigation->getChildrenIds($startPageId);
     if (!empty($childrenIds)) {
         foreach ($childrenIds as $pageId) {
             // skip current page
             if ($currentPageId === $pageId) {
                 continue;
             }
             $page = $navigation->getPage($pageId);
             // page needs to be of type rz_shop_product
             if ($page->getPageType() === 'rz_shop_product') {
                 $attr = $page->getPageAttributes();
                 $price = isset($attr['price']) ? floatval($attr['price']) : 0;
                 $items[] = array('pageId' => $pageId, 'pageUrl' => $page->getUrl(), 'pageNavigationTitle' => $page->getNavigationTitle(), 'pageTitle' => $page->getTitle(), 'pageDate' => $page->getDate(), 'pageDescription' => $page->getDescription(), 'productPrice' => $price);
             }
             //iterate recursively?
             if ($enableRecursive) {
                 $items = array_merge($items, $this->getTeaserItemsRecursive($renderApi, $pageId, $enableRecursive));
             }
         }
     }
     return $items;
 }
Exemple #8
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $responsiveImage = new ResponsiveImageBuilder($renderApi, $unit, $moduleInfo);
     $imageIds = $renderApi->getFormValue($unit, 'sliderImageIds', array());
     $imageQuality = null;
     if ($renderApi->getFormValue($unit, 'enableImageQuality')) {
         $imageQuality = $renderApi->getFormValue($unit, 'imageQuality');
     }
     $globalHeightPercent = str_replace('%', '', $renderApi->getFormValue($unit, 'imgHeight'));
     // render children (non extensions)
     if (count($imageIds) > 0) {
         echo '<ul class="slides">';
         $i = 0;
         foreach ($imageIds as $imageId) {
             // image
             try {
                 $image = $renderApi->getMediaItem($imageId)->getImage();
                 if ($globalHeightPercent == 0) {
                     $heightPercent = $image->getHeight() / $image->getWidth() * 100;
                 } else {
                     $heightPercent = $globalHeightPercent;
                 }
                 $cropHeight = $image->getWidth() * $heightPercent / 100;
                 // slides
                 if ($i == 0) {
                     echo '<li class="slide slideActive">';
                 } else {
                     echo '<li class="slide">';
                 }
                 $i++;
                 // image tag
                 $imgTag = $responsiveImage->getImageTag($image, array('resize' => array('width' => $image->getWidth(), 'height' => $cropHeight), 'quality' => $imageQuality));
                 if (isset($imgTag)) {
                     echo $imgTag->toString();
                 }
                 echo '</li>';
             } catch (\Exception $e) {
             }
         }
         echo '</ul>';
     } else {
         if ($renderApi->isEditMode()) {
             // missing input hint
             $i18n = new Translator($renderApi, $moduleInfo);
             echo '<div class="RUKZUKmissingInputHint">';
             echo '<div>';
             echo '<button onclick="javascript:CMS.openFormPanel(\'sliderImageIds\');">';
             echo $i18n->translate('button.missingInputHint', 'Choose images');
             echo '</button>';
             echo '</div>';
             echo '</div>';
         }
     }
     $renderApi->renderChildren($unit);
 }
Exemple #9
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $allItems = $renderApi->getChildren($unit);
     $renderItems = array();
     // normal units
     $nonRenderItems = array();
     // extension units
     foreach ($allItems as $item) {
         if ($renderApi->getModuleInfo($item)->isExtension()) {
             // assume that extension modules (i.e. styles) render no html output
             $nonRenderItems[] = $item;
         } else {
             $renderItems[] = $item;
         }
     }
     // render children (non extensions)
     if (count($renderItems) > 0) {
         echo '<ul class="slides">';
         $i = 0;
         foreach ($renderItems as $nextUnit) {
             if ($i == 0) {
                 echo '<li class="slide slideActive">';
             } else {
                 echo '<li class="slide">';
             }
             $i++;
             $renderApi->renderUnit($nextUnit);
             echo '</li>';
         }
         echo '</ul>';
     } else {
         $this->insertMissingInputHint($renderApi, $unit);
     }
     // render extensions
     foreach ($nonRenderItems as $item) {
         $renderApi->renderUnit($item);
     }
 }
 /**
  * @param \Render\APIs\APIv1\RenderAPI $api
  * @param \Render\Unit                 $unit
  * @param \Render\ModuleInfo           $moduleInfo
  */
 public function render($api, $unit, $moduleInfo)
 {
     echo "START-RENDER:" . $unit->getId() . "\n";
     echo "ASSET-PATH:" . $moduleInfo->getAssetPath('assetPath') . "\n";
     echo "ASSET-URL:" . $moduleInfo->getAssetUrl('assetUrl') . "\n";
     echo "MEDIA-URL:" . $api->getMediaItem($api->getFormValue($unit, 'download'))->getUrl() . "\n";
     echo "IMAGE-URL:" . $api->getMediaItem($api->getFormValue($unit, 'image'))->getImage()->resizeCenter(100, 100)->getUrl() . "\n";
     try {
         $url = $api->getMediaItem('ITEM-NOT-EXISTS')->getUrl();
     } catch (\Exception $ignore) {
         $url = '#exception';
     }
     echo "NOT-EXISTS-MEDIA-URL:" . $url . "\n";
     $api->renderChildren($unit);
     echo "END-RENDER:" . $unit->getId() . "\n";
 }
Exemple #11
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $imgClass = '';
     $svgUrl = $moduleInfo->getAssetUrl('imageBlank.svg');
     $svgMedia = $renderApi->getFormValue($unit, 'svg');
     if ($svgMedia == '') {
         $imgClass = 'blankImgPlaceholder';
     } else {
         try {
             $svgUrl = $renderApi->getMediaItem($svgMedia)->getUrl();
         } catch (\Exception $e) {
         }
     }
     $svgImgTag = new HtmlTagBuilder('img', array('src' => $svgUrl, 'alt' => $renderApi->getFormValue($unit, 'svgAlt')));
     if (!empty($imgClass)) {
         $svgImgTag->set('class', $imgClass);
     }
     $svgTitle = $renderApi->getFormValue($unit, 'svgTitle');
     if (!empty($svgTitle)) {
         $svgImgTag->set('title', $svgTitle);
     }
     echo $svgImgTag->toString();
     $renderApi->renderChildren($unit);
 }
Exemple #12
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 protected function renderContent($renderApi, $unit, $moduleInfo)
 {
     $renderApi->renderChildren($unit);
 }
Exemple #13
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit                 $unit
  *
  * @return null|string
  */
 protected function getMailToUrl($renderApi, $unit)
 {
     $mailTo = $renderApi->getFormValue($unit, 'mailtoEmail');
     if (empty($mailTo)) {
         return null;
     } else {
         return 'mailto:' . $mailTo;
     }
 }
Exemple #14
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI $api
  * @param \Render\Unit $unit
  */
 protected function insertMissingInputHint($api, $unit)
 {
     // only available in edit mode
     if (!$api->isEditMode()) {
         return;
     }
     $isPage = $api->isPage();
     $isGhostContainer = $unit->isGhostContainer();
     $isEmpty = true;
     // check if this module contains any other module which is not a extension module
     // if we have children, search for non extension modules
     $children = $api->getChildren($unit);
     foreach ($children as $nextUnit) {
         if (!$api->getModuleInfo($nextUnit)->isExtension()) {
             $isEmpty = false;
             break;
         }
     }
     $html = '';
     // module has no children and we are not in page mode
     if ($isEmpty && !$isPage) {
         $html = '<div class="RUKZUKemptyBox"></div>';
     } else {
         if ($isPage && $isGhostContainer) {
             $id = $unit->getId();
             $i18n = new Translator($api, $api->getModuleInfo($unit));
             $title = $i18n->translate('button.missingInputHintTitle', 'Click to insert module');
             $html .= '<div class="' . ($isEmpty ? ' RUKZUKemptyBox' : 'RUKZUKaddModuleBox') . '">';
             $html .= '	<div class="RUKZUKmissingInputHint">';
             $html .= '	  <div>';
             $html .= '		<button class="add" onclick="javascript:CMS.openInsertWindow(\'' . $id . '\', 0);" title="' . $title . '"></button>';
             $html .= '	  </div>';
             $html .= '	</div>';
             $html .= '</div>';
         }
     }
     echo $html;
 }
 /**
  * @param \Render\APIs\APIv1\RenderAPI $api
  * @param \Render\Unit                 $unit
  * @param \Render\ModuleInfo           $moduleInfo
  */
 public function render($api, $unit, $moduleInfo)
 {
     echo "START-RENDER:" . $unit->getId() . "\n";
     $api->renderChildren($unit);
     echo "END-RENDER:" . $unit->getId() . "\n";
 }
Exemple #16
0
 /**
  * @param HtmlTagBuilder               $tag
  * @param \Render\APIs\APIv1\RenderAPI $api
  * @param \Render\Unit                 $unit
  * @param \Render\ModuleInfo           $moduleInfo
  */
 protected function modifyWrapperTag($tag, $api, $unit, $moduleInfo)
 {
     if (count($api->getChildren($unit)) === 0) {
         $tag->addClass('isAnchorAbsolute');
     }
 }
 /**
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\APIs\APIv1\Page $page
  * @return string
  */
 private function getUrl($renderApi, $page)
 {
     return $renderApi->isEditMode() ? 'javascript:void(0);' : $page->getUrl();
 }
Exemple #18
0
 /**
  * @param RenderAPI $renderApi
  * @param Unit      $unit
  * @param array     $postRequest <FormValueSetSet>
  */
 private function sentEmail($renderApi, $unit, $postRequest)
 {
     $mailer = new Mailer($renderApi);
     $mailer->setFrom($renderApi->getFormValue($unit, 'senderMail'));
     $mailer->addTo($renderApi->getFormValue($unit, 'recipientMail'));
     $mailer->setSubject($renderApi->getFormValue($unit, 'mailSubject'));
     $mailer->setHtmlBody($this->getMailBody($postRequest));
     $mailer->send();
 }
Exemple #19
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI  $renderApi
  * @param \Render\Unit                  $unit
  * @param int                           $level
  *
  * @return bool
  */
 protected function shouldIterateIntoSubLevels($renderApi, $unit, $level)
 {
     $maxLevel = $this->getNumberOfTotalLevels();
     $onlyShowActiveSubItems = false;
     $subLevel = $level;
     do {
         $subLevel++;
         $subLevelEnabled = $renderApi->getFormValue($unit, 'enableLevel' . $subLevel, false) == true;
         if ($subLevelEnabled) {
             $onlyShowActiveSubItems = $renderApi->getFormValue($unit, 'enableOnlyShowActiveItemsOfLevel' . $subLevel, false) == true;
         }
     } while (!$subLevelEnabled && $subLevel <= $maxLevel);
     return $onlyShowActiveSubItems;
 }