Пример #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>';
 }
Пример #2
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);
 }
 /**
  * @param \Render\APIs\APIv1\HeadAPI $api
  * @param \Render\Unit               $unit
  * @param \Render\ModuleInfo         $moduleInfo
  *
  * @return array
  */
 public function provideUnitData($api, $unit, $moduleInfo)
 {
     return array('method' => __METHOD__, 'module' => $moduleInfo->getId(), 'unit' => $unit->getId());
 }
Пример #4
0
 /**
  * Loads the DynCSS helper if needed
  * NOTE: This should never be called on a published page! (as it requires v8js php-ext)
  * @param \Render\ModuleInfo $moduleInfo
  * @return Lib\DynCSS
  */
 private function getDynCSSLib($moduleInfo)
 {
     require_once dirname(__FILE__) . '/lib/dyncss/DynCSS.php';
     return new Lib\DynCSS(new DynCSSEngine($moduleInfo->getAssetPath()));
 }
Пример #5
0
 /**
  * Returns the available js assets defined in the module manifest dependent
  * on a given type ("module" or "script") and the current mode of execution
  * @private
  * @param \Render\APIs\APIv1\HeadAPI $api
  * @param string $assetType
  * @param \Render\ModuleInfo $moduleInfo
  * @return array
  */
 private function getJsAssets($api, $assetType, $moduleInfo)
 {
     $customData = $moduleInfo->getCustomData();
     $jsAssets = $this->getValue('assets.js', $customData, array());
     $result = array();
     foreach ($jsAssets as $asset) {
         $mode = $this->getValue('mode', $asset, '');
         $type = $this->getValue('type', $asset, 'script');
         if ($type === $assetType && $this->isAvailableInMode($mode, $api)) {
             if (!$this->cachebusterDisabled) {
                 $cachebuster = new CacheBuster();
                 $cachebuster->setModuleManifest($moduleInfo->getManifest());
                 $result[] = $moduleInfo->getAssetUrl($cachebuster->suffix($this->getValue('file', $asset)));
             } else {
                 $result[] = $moduleInfo->getAssetUrl($this->getValue('file', $asset));
             }
         }
     }
     return $result;
 }