protected function renderDropzone(FrontendController $frontendController, $dropZoneID, $blackListedElements = array(), $whiteListedElements = array()) { if (!$frontendController->getAuth()->isLoggedIn()) { return null; } $this->dropZones[$dropZoneID] = array('whitelist' => $whiteListedElements, 'blacklist' => $blackListedElements); return '<div class="dropzone" dropzone="' . $dropZoneID . '"><a href="#">click <b>or</b> drag module here</a></div>' . "\n"; }
public function render(FrontendController $frontendController, CmsView $view) { /** @var CmsModuleFrontendController $cmsMod */ $cmsMod = $frontendController->getCmsModule(); if ($cmsMod === null) { return $this->renderEditable($frontendController, '<p>No module active for this route to render: ' . $frontendController->getHttpRequest()->getPath() . '</p>'); } $moduleResponse = $cmsMod->getCurrentResponse(); if ($moduleResponse instanceof CmsModuleResponse) { return $this->renderEditable($frontendController, $frontendController->getCmsView()->renderModuleResponse($moduleResponse)); } elseif (is_scalar($cmsMod->getCurrentResponse()) === true) { return $this->renderEditable($frontendController, $moduleResponse); } return $this->renderEditable($frontendController, 'Illegal return type from CMS module.'); }
/** * @param FrontendController $fec * @param $navEntries * @param $activeRouteID * @param null $parentNavID * @return array */ private function generateNavigationReal($fec, $navEntries, $activeRouteID, $parentNavID = null) { $navArr = array(); foreach ($navEntries as $n) { if ($n->parent_navigation_entry_IDFK != $parentNavID) { continue; } if ($n->route_IDFK == $activeRouteID) { $this->getActiveRoutes($fec->getDB(), $n->ID, $n->navigation_IDFK, $fec->getLocaleHandler()->getLanguage()); } $n->subNav = $this->generateNavigationReal($fec, $navEntries, $activeRouteID, $n->ID); $navArr[] = $n; } return $navArr; }
/** * @param FrontendController $fec * @param $navEntries * @param $activeRouteID * @param null $parentNavID * @return array */ private function generateNavigationReal($fec, $navEntries, $activeRouteID, $parentNavID = null) { $navArr = array(); foreach ($navEntries as $n) { if ($n->parent_navigation_entry_IDFK != $parentNavID) { continue; } if ($activeRouteID !== null && $n->route_IDFK == $activeRouteID) { $this->getActiveRoutes($fec->getDB(), $n->ID, $n->navigation_IDFK, $fec->getLocaleHandler()->getLanguage()); } // Call HOOK HERE! $n->subNav = array(); $subNavLoadedEvent = new SubNavLoadedEvent($n, in_array($n->route_IDFK, $this->activeRoutes), $this->activeRoutes, $this->settings); $fec->getEventDispatcher()->dispatch($this->identifier . '.beforeSubNavLoaded', $subNavLoadedEvent); $n->subNav += $this->generateNavigationReal($fec, $navEntries, $activeRouteID, $n->ID); $fec->getEventDispatcher()->dispatch($this->identifier . '.afterSubNavLoaded', $subNavLoadedEvent); $n->active = in_array($n->route_IDFK, $this->activeRoutes); $navArr[] = $n; } return $navArr; }
/** * @return HttpResponse * @throws CMSException * @throws HttpException * @throws \Exception */ public function restoreElementAjax() { list($elementType, $elementID, $elementPageID) = explode('-', $this->httpRequest->getVar('module', 'strip_tags')); $revisionFile = $this->httpRequest->getVar('revision', 'strip_tags'); $cmsPage = $this->pageModel->getPageByID($elementPageID); $moduleModel = new ModuleModel($this->db); $modInstance = $moduleModel->getElementInstanceByID($elementID, $cmsPage); try { $this->db->setListenersMute(true); $this->db->beginTransaction(); $revisionControl = new RevisionControl($this->db); $revisionControl->restoreFromFile($revisionFile); $fileNameParts = explode('.', StringUtils::afterLast($revisionFile, '/')); $this->updateElementRevision($modInstance, $fileNameParts[2]); $this->db->commit(); $this->db->setListenersMute(false); } catch (\Exception $e) { $this->db->setListenersMute(false); $this->db->rollBack(); $this->logger->error('Could not restore element ' . $e->getMessage()); return new HttpResponse(500, 'Could not restore element: ' . $e->getMessage()); } // RENDER ELEMENT AGAIN, SEND BACK if ($modInstance instanceof CmsElementSettingsLoadable) { /** @var CmsElement $modInstance */ $moduleModel->reloadSettings($modInstance, $cmsPage); } $referrerPath = StringUtils::beforeFirst($this->httpRequest->getVar('referrer', 'strip_tags'), '?'); $httpRequestFrontend = clone $this->httpRequest; $httpRequestFrontend->setPath($referrerPath); $httpRequestFrontend->setRequestMethod('GET'); $frontendController = new FrontendController($this->core, $httpRequestFrontend, $this->route); $frontendController->deliverCMSPage(); // @TODO render and replace parent module of this one $newModuleHtml = $modInstance->render($frontendController, $this->moduleView); return new HttpResponse(200, $newModuleHtml); }
public function render(FrontendController $frontendController, CmsView $view) { $siteTitle = '<h2>' . $frontendController->getCmsPage()->getTitle() . '</h2>'; return $this->renderEditable($frontendController, $siteTitle); }
/** * @param FrontendController $frontendController * @param $html * * @return null|string */ protected function renderEditable(FrontendController $frontendController, $html) { $pageModel = new PageModel($frontendController->getDB()); // @TODO dont know if it works 2014-02-03 pam else comment in and delete line after again //$cmsPage = $pageModel->getPageByID($frontendController->getCmsPage()->getID()); $cmsPage = $frontendController->getCmsPage(); // @TODO Move the $this->hidden compare earlier in the code, before the rendering begins or is over to save resources if ($pageModel->hasUserWriteAccess($cmsPage, $frontendController->getAuth()) === false) { return $this->hidden === false ? $html : null; } $modIDStr = 'mod-' . $this->ID . '-' . $frontendController->getCmsPage()->getID(); $layerClass = 'element'; $sortableClass = null; $hiddenClass = null; if ($this instanceof LayoutElement) { $layerClass = 'element-layout'; } if ($this instanceof CmsElementSortable) { $sortableClass = 'element-sortable '; } if ($this->hidden === true) { $hiddenClass = 'element-hidden '; } $editableHtml = '<div id="' . $modIDStr . '" class="element-editable ' . $hiddenClass . $sortableClass . str_replace('_', '-', $this->identifier) . ' clearfix"> <div id="' . $modIDStr . '-content" class="' . $layerClass . ' edit-area clearfix"> ' . $html . ' <div class="edit-area-btn-group"> <!--<a class="edit-area-btn edit-area-btn-info ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" href="javascript:alert(\'Element type: ' . $this->identifier . '\');"><span class="ui-button-icon-primary ui-icon ui-icon-info"></span><span class="ui-button-text">Element Info</span></a>--> ' . ($this->parentElement instanceof CmsElementSortable ? '<a class="edit-area-btn edit-area-btn-history ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-move" title="move" role="button"><span class="ui-button-icon-primary ui-icon ui-icon-arrow-4"></span><span class="ui-button-text">move</span></a>' : null) . ' ' . ($this instanceof TextElement ? '<a class="edit-area-btn edit-area-btn-edit ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" title="edit content" role="button"><span class="ui-button-icon-primary ui-icon ui-icon-pencil"></span><span class="ui-button-text">edit</span></a> ' : null) . ' ' . ($this->hasConfig($frontendController) ? '<a class="edit-area-btn edit-area-btn-settings ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" href="/backend/element/' . $this->ID . '-' . $frontendController->getCmsPage()->getID() . '/ajax-settingsbox" role="button" title="Module settings: ' . $modIDStr . ' (' . $this->identifier . ')"><span class="ui-button-icon-primary ui-icon ui-icon-gear"></span><span class="ui-button-text">Settings</span></a> ' : null) . ' <a class="edit-area-btn edit-area-btn-history ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" href="/backend/element/' . $this->ID . '-' . $frontendController->getCmsPage()->getID() . '/ajax-revision-control" role="button" title="Revision control: ' . $modIDStr . ' (' . $this->identifier . ')"><span class="ui-button-icon-primary ui-icon ui-icon-clock"></span><span class="ui-button-text">Revision control</span></a>'; if ($this->pageID == $frontendController->getCmsPage()->getID()) { $editableHtml .= '<a class="edit-area-btn edit-area-btn-delete ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" title="delete" role="button"><span class="ui-button-icon-primary ui-icon ui-icon-trash"></span><span class="ui-button-text">delete</span></a>'; } else { $editableHtml .= $this->hidden === false ? '<a class="edit-area-btn edit-area-btn-hide ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" title="hide" role="button"><span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span><span class="ui-button-text">hide</span></a>' : '<a class="edit-area-btn edit-area-btn-reveal ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" title="show" role="button"><span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span><span class="ui-button-text">show</span></a>'; } $editableHtml .= '</div> </div> </div>'; return $editableHtml; }