Ejemplo n.º 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>';
 }
Ejemplo n.º 2
0
 /**
  * @test
  * @group rendering
  * @group small
  * @group dev
  */
 public function test_createNewInstance()
 {
     // ARRANGE
     $expectedId = 'this is the unit id';
     $expectedModuleId = 'this is the unit module id';
     $expectedName = 'this is the unit name';
     $expectedFormValues = array('this is one unit form value');
     $expectedGhostContainer = true;
     $expectedTemplateUnitId = 'this is the unit template id';
     $expectedHtmlClass = 'this is the html class';
     // ACT
     $actualUnit = new Unit($expectedId, $expectedModuleId, $expectedName, $expectedFormValues, $expectedGhostContainer, $expectedTemplateUnitId, $expectedHtmlClass);
     // ASSERT
     $this->assertEquals($expectedId, $actualUnit->getId());
     $this->assertEquals($expectedModuleId, $actualUnit->getModuleId());
     $this->assertEquals($expectedName, $actualUnit->getName());
     $this->assertEquals($expectedFormValues, $actualUnit->getFormValues());
     $this->assertEquals($expectedGhostContainer, $actualUnit->isGhostContainer());
     $this->assertEquals($expectedTemplateUnitId, $actualUnit->getTemplateUnitId());
     $this->assertEquals($expectedHtmlClass, $actualUnit->getHtmlClass());
 }
Ejemplo n.º 3
0
 /**
  * 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());
     // call hook
     $this->modifyWrapperTag($tag, $renderApi, $unit, $moduleInfo);
     echo $tag->getOpenString();
     $this->renderContent($renderApi, $unit, $moduleInfo);
     echo $tag->getCloseString();
 }
Ejemplo n.º 4
0
 /**
  * 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();
 }