/** * @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); }
/** * @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"; }
/** * @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 $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); }
/** * @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); }
/** * @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; } }
/** * Creates the html code for a single unit and writes it to output buffer. * This is an empty implementation and should be overridden if you want * to output any html code. * * @param \Render\APIs\APIv1\RenderAPI $renderApi - reference to the module api * @param \Render\Unit $unit - an object which provides general unit specific * data (e.g. unit id, form values, ... etc.) * @param \Render\ModuleInfo $moduleInfo - reference an object which provides * the general module information (e.g. module id, asset url, manifest * data, ... etc.) */ public function render($renderApi, $unit, $moduleInfo) { if ($moduleInfo->isExtension()) { return; } $tag = new HtmlTagBuilder('div'); $tag->set('id', $unit->getId()); $tag->addClass($moduleInfo->getId()); $tag->addClass('isModule'); $tag->addClass($unit->getHtmlClass()); // add style Set classes $children = $renderApi->getChildren($unit); $styleSetClasses = ''; foreach ($children as $childUnit) { $styleSetClass = $renderApi->getFormValue($childUnit, 'cssStyleSets', false); if ($styleSetClass) { $styleSetClasses .= str_replace(",", " ", $styleSetClass) . " "; } } if ($styleSetClasses != '') { $tag->addClass($styleSetClasses); } // call hook $this->modifyWrapperTag($tag, $renderApi, $unit, $moduleInfo); echo $tag->getOpenString(); $this->renderContent($renderApi, $unit, $moduleInfo); echo $tag->getCloseString(); }
/** * @param \Render\APIs\APIv1\RenderAPI $renderApi * @param Unit $unit * @param $moduleInfo * @param \Render\APIs\APIv1\Page $productPage * @param Translator $i18n * * @return HtmlTagBuilder|void */ private function getAddCartTag($renderApi, $unit, $moduleInfo, $productPage, $i18n) { $shopSettings = $renderApi->getWebsiteSettings('rz_shop'); $cartPageId = $shopSettings['cartPage']; if (!$cartPageId) { return HtmlTagBuilder::div(HtmlTagBuilder::button($i18n->translate('msg.noCartPage'))->set(array('style' => 'cursor: default;')))->set(array('class' => 'RUKZUKmissingInputHint')); } $cartText = $i18n->translateInput($renderApi->getFormValue($unit, 'cartText')); $cartUrl = $renderApi->getNavigation()->getPage($cartPageId)->getUrl(); return $this->displayCartButton($cartText, $productPage, $cartUrl, $renderApi->isEditMode() || $renderApi->isTemplate(), $i18n); }
/** * @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; }
/** * @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)); }
/** * @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(); }