Ejemplo n.º 1
0
 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();
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @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();
 }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
 /**
  * @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();
 }
Ejemplo n.º 5
0
 /**
  * @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();
 }
Ejemplo n.º 6
0
 /**
  * @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);
 }
Ejemplo n.º 7
0
 /**
  * @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);
 }
Ejemplo n.º 8
0
 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();
 }
Ejemplo n.º 9
0
 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $listTag = new HtmlTagBuilder('ul', array('class' => 'isTeaserList'));
     echo $listTag->getOpenString();
     // show hint when no children inserted
     if ($renderApi->isEditMode() && count($renderApi->getChildren($unit)) === 0) {
         $i18n = new Translator($renderApi, $moduleInfo);
         $msg = $i18n->translate('error.pleaseInsertModules');
         $errorTag = new HtmlTagBuilder('div', array('class' => 'RUKZUKmissingInputHint'), array(new HtmlTagBuilder('button', array('style' => 'cursor: default;'), array($msg))));
         echo $errorTag->toString();
     } else {
         $this->renderTeaserList($renderApi, $unit);
     }
     echo $listTag->getCloseString();
 }
Ejemplo n.º 10
0
 /**
  * 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();
 }
Ejemplo n.º 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);
 }