/** * @param $src * @param $ratio */ protected function renderVideo($src, $ratio) { // fill height element which helps to keep aspect ratio of video (using %-padding technique) $fillHeight = new HtmlTagBuilder('div', array('class' => 'fillHeight', 'style' => 'padding-bottom: ' . sprintf('%F', $ratio) . '%;')); $videoWrapper = new HtmlTagBuilder('div', array('class' => 'videoWrapper'), array(new HtmlTagBuilder('iframe', array('data-src' => $src, 'class' => 'lazyload', 'allowfullscreen' => null)), $fillHeight)); echo $videoWrapper->toString(); }
public function renderContent($renderApi, $unit, $moduleInfo) { // find all children modules $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; } } // wrap all children if (empty($renderItems)) { if ($renderApi->isEditMode() && $renderApi->isTemplate()) { $i18n = new Translator($renderApi, $moduleInfo); $msg = $i18n->translate('msg.emptyInEditMode'); $errorTag = new HtmlTagBuilder('div', array('class' => 'RUKZUKmissingInputHint'), array(new HtmlTagBuilder('button', array('style' => 'cursor: default;'), array($msg)))); echo $errorTag->toString(); } } else { $wrapTag = new HtmlTagBuilder('div'); foreach ($renderItems as $renderItem) { echo $wrapTag->getOpenString(); $renderApi->renderUnit($renderItem); echo $wrapTag->getCloseString(); } } }
protected function renderContent($renderApi, $unit, $moduleInfo) { $elementsTag = new HtmlTagBuilder('div', array('class' => 'cntElements')); echo $elementsTag->getOpenString(); // find all children modules $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; } } // wrap all children $wrapTag = new HtmlTagBuilder('div'); for ($i = 0; $i < count($renderItems); $i++) { echo $wrapTag->getOpenString(); $renderApi->renderUnit($renderItems[$i]); echo $wrapTag->getCloseString(); } echo $elementsTag->getCloseString(); // needed for vertical alignment when container is higher than contained children $fillHeightTag = new HtmlTagBuilder('div', array('class' => 'fillHeight')); echo $fillHeightTag->toString(); }
public function testBuild() { $tag = new HtmlTagBuilder('div'); $tag->attributes->set('class', 'foo'); $tag->setText('bar'); $this->assertEquals('<div class="foo">bar</div>', $tag->render()); }
private function renderTeaserList($renderApi, $unit) { $startPage = $renderApi->getFormValue($unit, 'teaserStartPage'); $enableRecursive = $renderApi->getFormValue($unit, 'enableRecursive'); $teaserItems = $this->getTeaserItemsRecursive($renderApi, $startPage, $enableRecursive); // sorting $teaserItems = $this->sortTeaserItems($renderApi, $unit, $teaserItems); // limit $teaserItems = $this->limitTeaserItems($renderApi, $unit, $teaserItems); $listItemTag = new HtmlTagBuilder('li', array('class' => 'teaserItem')); // TODO find better solution to communicate with rz_page_property global $currentTeaserPageId; if (count($teaserItems) === 0 && $renderApi->isEditMode()) { echo $listItemTag->getOpenString(); $renderApi->renderChildren($unit); echo $listItemTag->getCloseString(); } else { foreach ($teaserItems as $item) { $currentTeaserPageId = $item['pageId']; echo $listItemTag->getOpenString(); $renderApi->renderChildren($unit); echo $listItemTag->getCloseString(); // show only one page due to multiple unit id problem if ($renderApi->isEditMode()) { break; } } // TODO fill teaser placeholders //echo '<div class="RUKZUKmissingInputHint"><button style="cursor: default;">(Teaser ' . ($iTeaserItemPos + 1) . ')</button></div>'; } $currentTeaserPageId = null; }
/** * @param $renderApi * @param \Render\Unit $unit * @param Array $tabTitles */ protected function renderTabContent($renderApi, $unit, $tabTitles) { // get all children which are no extensions $children = array(); foreach ($renderApi->getChildren($unit) as $childUnit) { if (!$renderApi->getModuleInfo($childUnit)->isExtension()) { $children[] = $childUnit; } } $tabsWrapper = new HtmlTagBuilder('div', array('class' => 'tabsWrapper')); echo $tabsWrapper->getOpenString(); $tabCount = 0; foreach ($tabTitles as $tabTitle) { $tabWrapper = new HtmlTagBuilder('section', array('class' => 'tabContent')); echo $tabWrapper->getOpenString(); $tabId = $unit->getId() . '_tab' . $tabCount; $label = new HtmlTagBuilder('label', array('for' => $tabId, 'class' => 'tabLabel'), array(new HtmlTagBuilder('h2', null, $tabTitle))); echo $label->toString(); if (!empty($children[$tabCount])) { $contentWrapper = new HtmlTagBuilder('div'); echo $contentWrapper->getOpenString(); $renderApi->renderUnit($children[$tabCount]); echo $contentWrapper->getCloseString(); } echo $tabWrapper->getCloseString(); $tabCount++; } echo $tabsWrapper->getCloseString(); }
/** * @param \Render\APIs\APIv1\RenderAPI $renderApi * @param \Render\Unit $unit * @param \Render\ModuleInfo $moduleInfo */ protected function showNoAnchorsHint($renderApi, $unit, $moduleInfo) { $i18n = new Translator($renderApi, $moduleInfo); $msg = $i18n->translate('hint.noAnchor'); $errorTag = new HtmlTagBuilder('div', array('class' => 'RUKZUKmissingInputHint'), array(new HtmlTagBuilder('button', array('style' => 'cursor: default;'), array($msg)))); echo $errorTag->toString(); }
/** * @param $renderApi * @param \Render\Unit $unit * @param \Render\ModuleInfo $moduleInfo */ public function renderContent($renderApi, $unit, $moduleInfo) { $src = $renderApi->getFormValue($unit, 'iframeSrc', ''); if (preg_match('/^http[s]?:\\/\\//', $src)) { $htb = new HtmlTagBuilder('iframe', array('data-src' => $src, 'class' => 'lazyload')); echo $htb->toString(); } $renderApi->renderChildren($unit); }
/** * @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 * @param \Render\Unit $unit * @param \Render\ModuleInfo $moduleInfo */ public function renderContent($renderApi, $unit, $moduleInfo) { $apiKey = $renderApi->getFormValue($unit, 'googleMapsApiKey'); // use rukzuk key if user didn't enter own key if (empty($apiKey)) { $apiKey = 'AIzaSyBRaLr53MrNTKCGqdf7b2VpJNITysGPpPw'; } $googleMapsUrl = 'https://www.google.com/maps/embed/v1/place?key=' . $apiKey . '&q=' . urlencode($renderApi->getFormValue($unit, 'address')) . '&zoom=' . $renderApi->getFormValue($unit, 'zoom') . '&maptype=' . $renderApi->getFormValue($unit, 'maptype'); $htb = new HtmlTagBuilder('div', null, array(new HtmlTagBuilder('iframe', array('data-src' => $googleMapsUrl, 'class' => 'lazyload')))); echo $htb->toString(); $renderApi->renderChildren($unit); }
protected function getHandleCode($api, $unit) { $textExpand = $api->getFormValue($unit, 'handleTextExpand'); $textCollapse = $api->getFormValue($unit, 'handleTextCollapse'); if (empty($textCollapse)) { $textCollapse = $textExpand; } $handle = new HtmlTagBuilder('div', array('class' => 'collapsibleHandle', 'data-duration' => str_replace('ms', '', $api->getFormValue($unit, 'animationDuration')), 'data-closeonlinkclick' => $api->getFormValue($unit, 'enableCloseOnLinkClick')), array(new HtmlTagBuilder('div', array('class' => 'collapse'), array(new HtmlTagBuilder('span', null, array($textCollapse)))), new HtmlTagBuilder('div', array('class' => 'expand'), array(new HtmlTagBuilder('span', null, array($textExpand)))))); if ($api->getFormValue($unit, 'initialState') == 'collapsed') { $handle->addClass('collapsed'); } return $handle->toString(); }
/** * @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'); } } } }
/** * Content for the <head> area of the website * @param \Render\APIs\APIv1\CSSAPI $api * @param \Render\Unit $unit * @param \Render\ModuleInfo $moduleInfo * @return string */ public function htmlHeadUnit($api, $unit, $moduleInfo) { // TODO: allow this module only once! $ogTitle = new HtmlTagBuilder('meta', array('property' => 'og:title', 'content' => $api->getFormValue($unit, 'ogTitle'))); $ogType = new HtmlTagBuilder('meta', array('property' => 'og:type', 'content' => $api->getFormValue($unit, 'ogType'))); $url = $api->getFormValue($unit, 'ogUrl'); $ogUrl = new HtmlTagBuilder('meta', array('property' => 'og:url', 'content' => $api->getFormValue($unit, 'ogUrl'))); $ogImageStr = ''; try { $mediaItem = $api->getMediaItem($api->getFormValue($unit, 'ogImage')); $imgUrl = $mediaItem->getUrl(); $absoluteImgUrl = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $imgUrl; $ogImage = new HtmlTagBuilder('meta', array('property' => 'og:image', 'content' => $absoluteImgUrl)); $ogImageStr = $ogImage->toString(); } catch (\Exception $ignore) { } $ogDesc = new HtmlTagBuilder('meta', array('property' => 'og:description', 'content' => $api->getFormValue($unit, 'ogDesc'))); return $ogTitle->toString() . $ogType->toString() . $ogUrl->toString() . $ogImageStr . $ogDesc->toString(); }
/** * @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); }
protected function renderContent($renderApi, $unit, $moduleInfo) { // find all children modules $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; } } // wrap all children $wrapTag = new HtmlTagBuilder('div'); echo $wrapTag->getOpenString(); for ($i = 0; $i < count($renderItems); $i++) { $renderApi->renderUnit($renderItems[$i]); } echo $wrapTag->getCloseString(); }
/** * @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); } }
/** * @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(); }
public function getTextTag($renderApi, $unit, $moduleInfo, $content, $url) { $charLimit = $renderApi->getFormValue($unit, 'textCharLimit'); if (empty($content) && $renderApi->isEditMode()) { $i18n = new Translator($renderApi, $moduleInfo); $description = $i18n->translate('placeholder.pageDescription'); $content = $description . ' - Lorem ipsum dolor sit amet, eos ea soleat causae. Pro elitr eleifend prodesset ad, etiam volutpat no per, vim ea consul denique. Ullum lobortis evertitur ne vim, has audire incorrupte theophrastus at. Labitur vivendum electram pro et, sed movet accusata gloriatur at. Amet oratio repudiandae cu vis.'; } if ($charLimit > 0) { $content = $this->trimText($content, $charLimit); } // add space if link will get appended if ($renderApi->getFormValue($unit, 'enableTextLink')) { $content .= ' '; } $return = new HtmlTagBuilder('p', array('class' => 'teaserText'), array($content)); if ($renderApi->getFormValue($unit, 'enableTextLink')) { $return->append(new HtmlTagBuilder('a', array('href' => $url, 'class' => 'teaserTextLink'), array($renderApi->getFormValue($unit, 'textLinkLabel')))); } return $return; }
/** * @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'); } }