/** * @param \Render\APIs\APIv1\RenderAPI $renderApi * @param \Render\Unit $unit * @param \Render\ModuleInfo $moduleInfo */ public function renderContent($renderApi, $unit, $moduleInfo) { $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; } } // render children (non extensions) if (count($renderItems) > 0) { echo '<ul class="slides">'; $i = 0; foreach ($renderItems as $nextUnit) { if ($i == 0) { echo '<li class="slide slideActive">'; } else { echo '<li class="slide">'; } $i++; $renderApi->renderUnit($nextUnit); echo '</li>'; } echo '</ul>'; } else { $this->insertMissingInputHint($renderApi, $unit); } // render extensions foreach ($nonRenderItems as $item) { $renderApi->renderUnit($item); } }
/** * @param \Render\APIs\APIv1\RenderAPI $api * @param \Render\Unit $unit */ protected function insertMissingInputHint($api, $unit) { // only available in edit mode if (!$api->isEditMode()) { return; } $isPage = $api->isPage(); $isGhostContainer = $unit->isGhostContainer(); $isEmpty = true; // check if this module contains any other module which is not a extension module // if we have children, search for non extension modules $children = $api->getChildren($unit); foreach ($children as $nextUnit) { if (!$api->getModuleInfo($nextUnit)->isExtension()) { $isEmpty = false; break; } } $html = ''; // module has no children and we are not in page mode if ($isEmpty && !$isPage) { $html = '<div class="RUKZUKemptyBox"></div>'; } else { if ($isPage && $isGhostContainer) { $id = $unit->getId(); $i18n = new Translator($api, $api->getModuleInfo($unit)); $title = $i18n->translate('button.missingInputHintTitle', 'Click to insert module'); $html .= '<div class="' . ($isEmpty ? ' RUKZUKemptyBox' : 'RUKZUKaddModuleBox') . '">'; $html .= ' <div class="RUKZUKmissingInputHint">'; $html .= ' <div>'; $html .= ' <button class="add" onclick="javascript:CMS.openInsertWindow(\'' . $id . '\', 0);" title="' . $title . '"></button>'; $html .= ' </div>'; $html .= ' </div>'; $html .= '</div>'; } } echo $html; }
/** * @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'); } }