Пример #1
0
 public static function onRender(RendererEvent $event)
 {
     $renderer = $event->getRenderer();
     $em = $event->getApplication()->getEntityManager();
     $content = $event->getTarget();
     $links = $content->getParamValue('link');
     $link = ['url' => '', 'title' => 'Visit', 'target' => '_self'];
     if (!empty($links)) {
         $links = reset($links);
         if (isset($links['pageUid']) && !empty($links['pageUid'])) {
             $page = $em->getRepository('BackBee\\NestedNode\\Page')->find($links['pageUid']);
             if ($page !== null) {
                 $link['url'] = $renderer->getUri($page->getUrl());
             }
         }
         if (empty($link['url']) && isset($links['url'])) {
             $link['url'] = $links['url'];
         }
         if (isset($links['title'])) {
             $link['title'] = $links['title'];
         }
         if (isset($links['target'])) {
             $link['target'] = $links['target'];
         }
     }
     $renderer->assign('link', $link);
 }
Пример #2
0
 public static function onRender(RendererEvent $event)
 {
     $renderer = $event->getRenderer();
     self::$application = $event->getApplication();
     self::$em = self::$application->getEntityManager();
     $content = $renderer->getObject();
     $mediaRepository = self::$em->getRepository('BackBee\\ClassContent\\Media\\Image');
     $mediasParam = $content->getParamValue('medias');
     $linksParam = $content->getParamValue('links');
     $slides = [];
     $i = 0;
     foreach ($mediasParam as $mediaParam) {
         if (isset($mediaParam['uid'])) {
             $media = $mediaRepository->find($mediaParam['uid']);
             if (null !== $media) {
                 $slides[$i] = [];
                 $slides[$i]['media'] = $media;
                 if (isset($linksParam[$i])) {
                     $slides[$i]['link'] = self::getLink($linksParam[$i]);
                 }
             }
         }
         $i++;
     }
     $renderer->assign('slides', $slides);
 }
 public static function onRender(RendererEvent $event)
 {
     self::$renderer = $event->getRenderer();
     self::$application = self::$renderer->getApplication();
     self::$em = self::$application->getEntityManager();
     $content = $event->getTarget();
     $parentNode = self::getParentNode($content->getParamValue('parent_node'));
     $selector = ['parentnode' => [$parentNode !== null ? $parentNode->getUid() : null]];
     $contents = self::$em->getRepository('BackBee\\ClassContent\\AbstractClassContent')->getSelection($selector, in_array('multipage', $content->getParamValue('multipage')), in_array('recursive', $content->getParamValue('recursive')), (int) $content->getParamValue('start'), (int) $content->getParamValue('limit'), self::$application->getBBUserToken() === null, false, (array) $content->getParamValue('content_to_show'), (int) $content->getParamValue('delta'));
     $count = $contents instanceof Paginator ? $contents->count() : count($contents);
     self::$renderer->assign('contents', $contents);
     self::$renderer->assign('nbContents', $count);
     self::$renderer->assign('parentNode', $parentNode);
 }
Пример #4
0
 public static function onRenderTwitter(RendererEvent $event)
 {
     $renderer = $event->getEventArgs();
     self::$application = $event->getDispatcher()->getApplication();
     $config = self::getSocialConfig('twitter');
     $content = $renderer->getObject();
     $widgetId = $content->getParamValue('widget_id');
     if (empty($widgetId) || !self::checkTwitterId($widgetId)) {
         if (null !== $config && isset($config['widget_id'])) {
             $widgetId = $config['widget_id'];
         }
     }
     $renderer->assign('widget_id', $widgetId);
 }
Пример #5
0
 public static function onRender(RendererEvent $event)
 {
     $renderer = $event->getRenderer();
     $content = $event->getTarget();
     $tag = null;
     $url = '#';
     $mainNode = $content->getMainNode();
     if ($mainNode !== null) {
         $url = $renderer->getUri($mainNode->getUrl());
         $parentNode = $mainNode->getParent();
         if (null !== $parentNode) {
             $altTitle = $parentNode->getAltTitle();
             $tag = !empty($altTitle) ? $altTitle : $parentNode->getTitle();
         }
     }
     $renderer->assign('tag', $tag);
     $renderer->assign('url', $url);
 }
Пример #6
0
 /**
  * Saves in cache the rendered page data.
  *
  * @param \BackBee\Event\Event $event
  */
 public function onPostRenderPage(RendererEvent $event)
 {
     // Checks if page caching is available
     $this->object = $event->getTarget();
     if (false === $this->object instanceof Page || false === $this->checkCachePageEvent()) {
         return;
     }
     // Checks if cache_id is available
     if (false === ($cache_id = $this->getPageCacheId())) {
         return;
     }
     $column_uids = array();
     foreach ($this->object->getContentSet() as $column) {
         if ($column instanceof AbstractClassContent) {
             $column_uids[] = $column->getUid();
         }
     }
     $lifetime = $this->cache_page->getMinExpireByTag($column_uids);
     $render = $event->getRender();
     $this->cache_page->save($cache_id, $render, $lifetime, $this->object->getUid());
     $this->application->debug(sprintf('Save cache (id: %s, lifetime: %d) for rendering `%s(%s)` with mode `%s`.', $cache_id, $lifetime, get_class($this->object), $this->object->getUid(), $event->getRenderer()->getMode()));
 }