public function __construct(PageModuleWrapper $moduleWrapper)
 {
     $this->moduleWrapper = $moduleWrapper;
     $this->enabled = $moduleWrapper->getEnabled();
     $this->template = $moduleWrapper->getTemplate();
     $this->target = $moduleWrapper->getTarget();
 }
Beispiel #2
0
 public function getInfo(PageModuleWrapper $wrapper)
 {
     $icons = '';
     $pageModule = $wrapper->getPageModule();
     if ($wrapper->isInherited()) {
         $pageUrl = url('', array('module', 'view', 'page_id' => $pageModule->getPageId()));
         $icons .= '<a href="' . $pageUrl . '" title="Inherited from ' . $pageModule->getPage() . '"><i class="icon-double-angle-up"></i></a>';
     } else {
         $icons .= '<i class="icon-double-angle-down" title="Content is inherited to subpages"></i>';
     }
     $langContent = ModuleDataQuery::create()->filterByPageModule($wrapper->getPageModule())->filterByPageRevision($wrapper->getPageRevision())->filterByLangcode("", Criteria::NOT_EQUAL)->select('Langcode')->find()->getArrayCopy();
     if (!$wrapper->getEnabled()) {
         $icons .= ' <i class="icon-eye-close"></i>';
     }
     if ($wrapper->hasData()) {
         $icons .= ' <i class="icon-picture" title="Page content"></i>';
     }
     if (count($langContent)) {
         $icons .= ' <i class="icon-flag" title="Language specific content: ' . htmlspecialchars(join(', ', $langContent)) . '"></i>';
     }
     return $icons;
 }
 /**
  * Insert module and return generated content.
  *
  * @param PageModuleWrapper $pageModuleWrapper
  * @return string
  */
 protected function insertModule(PageModuleWrapper $pageModuleWrapper)
 {
     $this->app->logger->debug(($pageModuleWrapper->getEnabled() ? 'Inserting' : 'Skipping') . ' module "' . $pageModuleWrapper->getName() . '" of type "' . $pageModuleWrapper->getClassName() . '" with target "' . $pageModuleWrapper->getTarget() . '"');
     /** @var PreModuleEvent $event */
     $event = $this->app->dispatcher->dispatch(GeneratorEvents::PRE_MODULE, new PreModuleEvent($pageModuleWrapper));
     if ($event->getContent() === null) {
         // TODO: how do we handle $event->isEnabled() ?
         /** @var \Curry\Module\AbstractModule $module */
         $module = $pageModuleWrapper->createObject();
         $template = null;
         if ($event->getTemplate() !== null) {
             $this->app->twig->loadTemplate($event->getTemplate());
         } else {
             if ($module->getDefaultTemplate()) {
                 $template = $this->app->loadTemplateString($module->getDefaultTemplate());
             }
         }
         if ($template && $template->getEnvironment()) {
             $twig = $template->getEnvironment();
             $twig->addGlobal('module', array('Id' => $pageModuleWrapper->getPageModuleId(), 'ClassName' => $pageModuleWrapper->getClassName(), 'Name' => $pageModuleWrapper->getName(), 'ModuleDataId' => $pageModuleWrapper->getModuleDataId(), 'Target' => $pageModuleWrapper->getTarget()));
         }
         $content = (string) $module->showFront($template);
     } else {
         $content = $event->getContent();
     }
     /** @var PostModuleEvent $postEvent */
     $postEvent = $this->app->dispatcher->dispatch(GeneratorEvents::POST_MODULE, new PostModuleEvent($pageModuleWrapper, $content, $event->getExtras()));
     return $postEvent->getContent();
 }