Esempio n. 1
0
 /**
  * @param HtmlTagBuilder $tag
  * @param \Render\APIs\APIv1\RenderAPI $api
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 public function modifyWrapperTag($tag, $api, $unit, $moduleInfo)
 {
     $sliderConfig = array('mode' => $api->getFormValue($unit, 'sliderMode'), 'speed' => $api->getFormValue($unit, 'sliderSpeed') ? (int) str_replace('ms', '', $api->getFormValue($unit, 'sliderSpeed')) : 500, 'controls' => $api->getFormValue($unit, 'enableDirectionNav') ? true : false, 'pager' => $api->getFormValue($unit, 'enableControlNav') ? true : false, 'adaptiveHeight' => $api->getFormValue($unit, 'enableSmoothHeight') ? true : false, 'auto' => $api->getFormValue($unit, 'enableSlideshow') && !$api->isEditMode() ? true : false, 'autoHover' => $api->getFormValue($unit, 'enableAutoStopOnHover') ? true : false, 'pause' => (int) str_replace('s', '', $api->getFormValue($unit, 'slideshowSpeed')) * 1000, 'infiniteLoop' => $api->getFormValue($unit, 'enableInfiniteLoop') && !$api->isEditMode() ? true : false, 'hideControlOnEnd' => !$api->getFormValue($unit, 'enableInfiniteLoop'), 'nextText' => '', 'prevText' => '', 'slideSelector' => 'li.slide', 'unitId' => $unit->getId(), 'useCSS' => $api->isEditMode(), 'keyboardEnabled' => $api->getFormValue($unit, 'enableKeyboard') && !$api->isEditMode() ? true : false);
     $startSlide = $api->getFormValue($unit, 'startSlide');
     if ($startSlide === 'random') {
         $sliderConfig['randomStart'] = true;
     } else {
         $sliderConfig['startSlide'] = (int) $startSlide - 1;
     }
     $tag->set('data-sliderconfig', json_encode($sliderConfig, JSON_HEX_APOS));
 }
Esempio n. 2
0
 /**
  * @param HtmlTagBuilder $tag
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 protected function modifyWrapperTag($tag, $renderApi, $unit, $moduleInfo)
 {
     // use a only if not in edit mode (to be able to use inline editor)
     if (!$renderApi->isEditMode()) {
         $tag->setTagName('a');
         $tag->set('href', $this->geturl($renderApi, $unit));
         if ($renderApi->getFormValue($unit, 'openNewWindow')) {
             $tag->set('target', '_blank');
         }
     }
     // add title
     $linkTitle = $renderApi->getFormValue($unit, 'linkTitle');
     if (!empty($linkTitle)) {
         $tag->set('title', $linkTitle);
     }
     // add active/current classes when linking to internal page
     if ($renderApi->getFormValue($unit, 'linkType') == 'page') {
         $pageId = $renderApi->getFormValue($unit, 'pageId');
         if (!empty($pageId)) {
             $nav = $renderApi->getNavigation();
             $navIds = $this->getNavigatorIds($nav);
             if ($this->isPageActive($pageId, $navIds)) {
                 $tag->addClass('linkPageActive');
             }
             if ($pageId == $nav->getCurrentPageId()) {
                 $tag->addClass('linkPageCurrent');
             }
         }
     }
 }
Esempio n. 3
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>';
 }
Esempio n. 4
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);
 }
Esempio n. 5
0
 /**
  * @param HtmlTagBuilder $tag
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 protected function modifyWrapperTag($tag, $renderApi, $unit, $moduleInfo)
 {
     // use a only if not in edit mode (to be able to use inline editor)
     if (!$renderApi->isEditMode()) {
         $tag->setTagName('a');
         $tag->set('href', $this->geturl($renderApi, $unit));
         if ($renderApi->getFormValue($unit, 'openNewWindow')) {
             $tag->set('target', '_blank');
         }
     }
     // add title
     $linkTitle = $renderApi->getFormValue($unit, 'linkTitle');
     if (!empty($linkTitle)) {
         $tag->set('title', $linkTitle);
     }
     // add active/current classes when linking to internal page
     if ($renderApi->getFormValue($unit, 'linkType') == 'page') {
         $pageId = $renderApi->getFormValue($unit, 'pageId');
         if (!empty($pageId)) {
             $nav = $renderApi->getNavigation();
             $navIds = $this->getNavigatorIds($nav);
             if ($this->isPageActive($pageId, $navIds)) {
                 $tag->addClass('linkPageActive');
             }
             if ($pageId == $nav->getCurrentPageId()) {
                 $tag->addClass('linkPageCurrent');
             }
         }
     }
     // anchor
     if ($renderApi->getFormValue($unit, 'linkType') == 'anchor' && !$renderApi->isEditMode()) {
         $jsCode = "\$.scrollTo('" . $renderApi->getFormValue($unit, 'anchorId') . "', " . intval($renderApi->getFormValue($unit, 'scrollSpeed')) . ", {";
         $jsCode .= "easing: 'swing',axis: 'y'}); return false;";
         $tag->set('onclick', $jsCode);
     }
 }
Esempio n. 6
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;
 }
Esempio n. 7
0
 /**
  * @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();
 }
Esempio n. 8
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI  $renderApi
  * @param \Render\Unit                  $unit
  * @param \Render\APIs\APIv1\Navigation $navigation
  * @param array                         $navigatorIds
  * @param \Render\APIs\APIv1\Page       $page
  * @param int                           $level
  * @param string                        $childrenMarkup
  *
  * @return string
  */
 protected function getNavItemMarkup($renderApi, $unit, $navigation, array &$navigatorIds, $page, $level, $childrenMarkup)
 {
     $pageId = $page->getPageId();
     $linkTag = new HtmlTagBuilder('a', array('class' => 'navLink'), array($page->getNavigationTitle()));
     $listTag = new HtmlTagBuilder('li', array('class' => 'navItem'), array($linkTag, $childrenMarkup));
     // get url
     if ($renderApi->isEditMode()) {
         $linkTag->set('href', 'javascript:void(0);');
     } else {
         $linkTag->set('href', $page->getUrl());
     }
     // collect classes
     if ($this->isItemActive($pageId, $navigatorIds)) {
         $listTag->addClass('navItemActive');
         $linkTag->addClass('navLinkActive');
     }
     if ($pageId == $navigation->getCurrentPageId()) {
         $listTag->addClass('navItemCurrent');
         $linkTag->addClass('navLinkCurrent');
     }
     if ($this->hasChildPages($pageId, $navigation)) {
         $listTag->addClass('hasChildPages');
         $linkTag->addClass('hasChildPages');
     }
     return $listTag;
     // return $listTag->toString();
 }