コード例 #1
0
 /**
  * @inheritdoc
  */
 protected function getCurrentPage()
 {
     if (false === $this->currentArticle) {
         $this->currentArticle = ArticleModel::findByPk($this->dataContainer->id);
     }
     if (null === $this->currentArticle) {
         return null;
     }
     return PageModel::findWithDetails($this->currentArticle->pid);
 }
コード例 #2
0
 /**
  * Adds missing translation warning to article tree.
  *
  * @param array $args
  * @param mixed $previousResult
  *
  * @return string
  */
 public function onArticleLabel(array $args, $previousResult = null)
 {
     list($row, $label) = $args;
     if ($previousResult) {
         $label = $previousResult;
     }
     $page = PageModel::findWithDetails($row['pid']);
     $root = PageModel::findByPk($page->rootId);
     if ((!$root->fallback || $root->languageRoot > 0) && $page->languageMain > 0 && null !== PageModel::findByPk($page->languageMain) && (!$row['languageMain'] || null === ArticleModel::findByPk($row['languageMain']))) {
         return $this->generateLabelWithWarning($label);
     }
     return $label;
 }
コード例 #3
0
 public function onLanguageMainOptions(DataContainer $dc)
 {
     $pageFinder = new PageFinder();
     $current = ArticleModel::findByPk($dc->id);
     $page = PageModel::findByPk($current->pid);
     if (null === $page || ($master = $pageFinder->findAssociatedInMaster($page)) === null) {
         return [];
     }
     $options = [];
     $result = Database::getInstance()->prepare('
             SELECT id, title 
             FROM tl_article 
             WHERE pid=? AND id NOT IN (
                 SELECT languageMain FROM tl_article WHERE id!=? AND pid=? AND languageMain > 0
             )
         ')->execute($master->id, $current->id, $page->id);
     while ($result->next()) {
         $options[$result->id] = sprintf('%s [ID %s]', $result->title, $result->id);
     }
     return $options;
 }
コード例 #4
0
 /**
  * Render a single message content element.
  *
  * @param RenderMessageContentEvent $event
  *
  * @return string
  */
 public function renderContent(RenderMessageContentEvent $event)
 {
     global $container;
     $content = $event->getMessageContent();
     if ($content->getType() != 'article' || $event->getRenderedContent() || !$content->getArticleId()) {
         return;
     }
     /** @var EntityAccessor $entityAccessor */
     $entityAccessor = $container['doctrine.orm.entityAccessor'];
     /** @var EventDispatcher $eventDispatcher */
     $eventDispatcher = $container['event-dispatcher'];
     $articles = array();
     foreach ($content->getArticleId() as $articleId) {
         if (empty($articleId)) {
             continue;
         }
         $getArticleEvent = new GetArticleEvent($articleId, !$content->getArticleFull(), $content->getCell());
         if (!$content->getArticleFull()) {
             $article = ArticleModel::findByPk($articleId);
             $article->showTeaser = 1;
             global $objPage;
             if (!$objPage) {
                 $objPage = $article->getRelated('pid');
                 $objPage->loadDetails();
             }
         }
         $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GET_ARTICLE, $getArticleEvent);
         $context = $entityAccessor->getProperties($content);
         $context['article'] = $getArticleEvent->getArticle();
         array_push($articles, $context);
     }
     $buffer = '';
     foreach ($articles as $article) {
         $template = new TwigTemplate('avisota/message/renderer/default/mce_article', 'html');
         $buffer .= $template->parse($article);
     }
     $event->setRenderedContent($buffer);
 }
 /**
  * Generate a URL and return it as string.
  *
  * @param EventDispatcherInterface $eventDispatcher The event dispatcher.
  *
  * @param NewsModel                $objItem         The news model.
  *
  * @param boolean                  $blnAddArchive   Add the current archive parameter (news archive) (default: false).
  *
  * @return string
  *
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 protected function generateNewsUrl(EventDispatcherInterface $eventDispatcher, NewsModel $objItem, $blnAddArchive = false)
 {
     $url = null;
     switch ($objItem->source) {
         // Link to an external page.
         case 'external':
             if (substr($objItem->url, 0, 7) == 'mailto:') {
                 $url = StringHelper::encodeEmail($objItem->url);
             } else {
                 $url = ampersand($objItem->url);
             }
             break;
             // Link to an internal page.
         // Link to an internal page.
         case 'internal':
             if (($objTarget = $objItem->getRelated('jumpTo')) !== null) {
                 $generateFrontendUrlEvent = new GenerateFrontendUrlEvent($objTarget->row());
                 $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL, $generateFrontendUrlEvent);
                 $url = $generateFrontendUrlEvent->getUrl();
             }
             break;
             // Link to an article.
         // Link to an article.
         case 'article':
             if (($objArticle = ArticleModel::findByPk($objItem->articleId, array('eager' => true))) !== null && ($objPid = $objArticle->getRelated('pid')) !== null) {
                 $generateFrontendUrlEvent = new GenerateFrontendUrlEvent($objPid->row(), '/articles/' . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id));
                 $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL, $generateFrontendUrlEvent);
                 $url = $generateFrontendUrlEvent->getUrl();
             }
             break;
         default:
     }
     // Link to the default page.
     if ($url === null) {
         $objPage = PageModel::findByPk($objItem->getRelated('pid')->jumpTo);
         if ($objPage === null) {
             $url = ampersand(Environment::get('request'), true);
         } else {
             $generateFrontendUrlEvent = new GenerateFrontendUrlEvent($objPage->row(), ($GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/' : '/items/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objItem->alias != '' ? $objItem->alias : $objItem->id));
             $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL, $generateFrontendUrlEvent);
             $url = $generateFrontendUrlEvent->getUrl();
         }
         // Add the current archive parameter (news archive).
         if ($blnAddArchive && Input::get('month') != '') {
             $url .= ($GLOBALS['TL_CONFIG']['disableAlias'] ? '&' : '?') . 'month=' . Input::get('month');
         }
     }
     return $url;
 }
コード例 #6
0
ファイル: BackendMain.php プロジェクト: bytehead/core-bundle
 /**
  * Output the template file
  *
  * @return Response
  */
 protected function output()
 {
     // Default headline
     if ($this->Template->headline == '') {
         $this->Template->headline = \Config::get('websiteTitle');
     }
     // Default title
     if ($this->Template->title == '') {
         $this->Template->title = $this->Template->headline;
     }
     /** @var SessionInterface $objSession */
     $objSession = \System::getContainer()->get('session');
     // File picker reference
     if (\Input::get('popup') && \Input::get('act') != 'show' && (\Input::get('do') == 'page' || \Input::get('do') == 'files') && $objSession->get('filePickerRef')) {
         $this->Template->managerHref = ampersand($objSession->get('filePickerRef'));
         $this->Template->manager = strpos($objSession->get('filePickerRef'), 'contao/page?') !== false ? $GLOBALS['TL_LANG']['MSC']['pagePickerHome'] : $GLOBALS['TL_LANG']['MSC']['filePickerHome'];
     }
     // Website title
     if (\Config::get('websiteTitle') != 'Contao Open Source CMS') {
         $this->Template->websiteTitle = \Config::get('websiteTitle');
     }
     $this->Template->theme = \Backend::getTheme();
     $this->Template->base = \Environment::get('base');
     $this->Template->language = $GLOBALS['TL_LANGUAGE'];
     $this->Template->title = \StringUtil::specialchars($this->Template->title);
     $this->Template->charset = \Config::get('characterSet');
     $this->Template->account = $GLOBALS['TL_LANG']['MOD']['login'][1];
     $this->Template->preview = $GLOBALS['TL_LANG']['MSC']['fePreview'];
     $this->Template->previewTitle = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['fePreviewTitle']);
     $this->Template->pageOffset = \Input::cookie('BE_PAGE_OFFSET');
     $this->Template->logout = $GLOBALS['TL_LANG']['MSC']['logoutBT'];
     $this->Template->logoutTitle = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['logoutBTTitle']);
     $this->Template->backendModules = $GLOBALS['TL_LANG']['MSC']['backendModules'];
     $this->Template->username = $GLOBALS['TL_LANG']['MSC']['user'] . ' ' . $GLOBALS['TL_USERNAME'];
     $this->Template->skipNavigation = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']);
     $this->Template->request = ampersand(\Environment::get('request'));
     $this->Template->top = $GLOBALS['TL_LANG']['MSC']['backToTop'];
     $this->Template->modules = $this->User->navigation();
     $this->Template->home = $GLOBALS['TL_LANG']['MSC']['home'];
     $this->Template->homeTitle = $GLOBALS['TL_LANG']['MSC']['homeTitle'];
     $this->Template->backToTop = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['backToTopTitle']);
     $this->Template->expandNode = $GLOBALS['TL_LANG']['MSC']['expandNode'];
     $this->Template->collapseNode = $GLOBALS['TL_LANG']['MSC']['collapseNode'];
     $this->Template->loadingData = $GLOBALS['TL_LANG']['MSC']['loadingData'];
     $this->Template->isPopup = \Input::get('popup');
     $this->Template->systemMessages = $GLOBALS['TL_LANG']['MSC']['systemMessages'];
     $strSystemMessages = \Backend::getSystemMessages();
     $this->Template->systemMessagesCount = substr_count($strSystemMessages, 'class="tl_');
     $this->Template->systemErrorMessagesCount = substr_count($strSystemMessages, 'class="tl_error"');
     // Front end preview links
     if (defined('CURRENT_ID') && CURRENT_ID != '') {
         if (\Input::get('do') == 'page') {
             $this->Template->frontendFile = '?page=' . CURRENT_ID;
         } elseif (\Input::get('do') == 'article' && ($objArticle = \ArticleModel::findByPk(CURRENT_ID)) !== null) {
             $this->Template->frontendFile = '?page=' . $objArticle->pid;
         } elseif (\Input::get('do') != '') {
             $event = new PreviewUrlCreateEvent(\Input::get('do'), CURRENT_ID);
             \System::getContainer()->get('event_dispatcher')->dispatch(ContaoCoreEvents::PREVIEW_URL_CREATE, $event);
             if (($strQuery = $event->getQuery()) !== null) {
                 $this->Template->frontendFile = '?' . $strQuery;
             }
         }
     }
     return $this->Template->getResponse();
 }
コード例 #7
0
 /**
  * Output the template file
  *
  * @return Response
  */
 protected function output()
 {
     // Default headline
     if ($this->Template->headline == '') {
         $this->Template->headline = \Config::get('websiteTitle');
     }
     // Default title
     if ($this->Template->title == '') {
         $this->Template->title = $this->Template->headline;
     }
     /** @var SessionInterface $objSession */
     $objSession = \System::getContainer()->get('session');
     // File picker reference
     if (\Input::get('popup') && \Input::get('act') != 'show' && (\Input::get('do') == 'page' || \Input::get('do') == 'files') && $objSession->get('filePickerRef')) {
         $this->Template->managerHref = ampersand($this->Session->get('filePickerRef'));
         $this->Template->manager = strpos($objSession->get('filePickerRef'), 'contao/page?') !== false ? $GLOBALS['TL_LANG']['MSC']['pagePickerHome'] : $GLOBALS['TL_LANG']['MSC']['filePickerHome'];
     }
     $this->Template->theme = \Backend::getTheme();
     $this->Template->base = \Environment::get('base');
     $this->Template->language = $GLOBALS['TL_LANGUAGE'];
     $this->Template->title = specialchars($this->Template->title);
     $this->Template->charset = \Config::get('characterSet');
     $this->Template->account = $GLOBALS['TL_LANG']['MOD']['login'][1];
     $this->Template->preview = $GLOBALS['TL_LANG']['MSC']['fePreview'];
     $this->Template->previewTitle = specialchars($GLOBALS['TL_LANG']['MSC']['fePreviewTitle']);
     $this->Template->pageOffset = \Input::cookie('BE_PAGE_OFFSET');
     $this->Template->logout = $GLOBALS['TL_LANG']['MSC']['logoutBT'];
     $this->Template->logoutTitle = specialchars($GLOBALS['TL_LANG']['MSC']['logoutBTTitle']);
     $this->Template->backendModules = $GLOBALS['TL_LANG']['MSC']['backendModules'];
     $this->Template->username = $GLOBALS['TL_LANG']['MSC']['user'] . ' ' . $GLOBALS['TL_USERNAME'];
     $this->Template->skipNavigation = specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']);
     $this->Template->request = ampersand(\Environment::get('request'));
     $this->Template->top = $GLOBALS['TL_LANG']['MSC']['backToTop'];
     $this->Template->modules = $this->User->navigation();
     $this->Template->home = $GLOBALS['TL_LANG']['MSC']['home'];
     $this->Template->homeTitle = $GLOBALS['TL_LANG']['MSC']['homeTitle'];
     $this->Template->backToTop = specialchars($GLOBALS['TL_LANG']['MSC']['backToTopTitle']);
     $this->Template->expandNode = $GLOBALS['TL_LANG']['MSC']['expandNode'];
     $this->Template->collapseNode = $GLOBALS['TL_LANG']['MSC']['collapseNode'];
     $this->Template->loadingData = $GLOBALS['TL_LANG']['MSC']['loadingData'];
     $this->Template->loadFonts = \Config::get('loadGoogleFonts');
     $this->Template->isAdmin = $this->User->isAdmin;
     $this->Template->isMaintenanceMode = \Config::get('maintenanceMode');
     $this->Template->maintenanceMode = $GLOBALS['TL_LANG']['MSC']['maintenanceMode'];
     $this->Template->maintenanceOff = specialchars($GLOBALS['TL_LANG']['MSC']['maintenanceOff']);
     $this->Template->maintenanceHref = $this->addToUrl('mmo=1');
     $this->Template->buildCacheLink = $GLOBALS['TL_LANG']['MSC']['buildCacheLink'];
     $this->Template->buildCacheText = sprintf($GLOBALS['TL_LANG']['MSC']['buildCacheText'], \System::getContainer()->getParameter('kernel.environment'));
     $this->Template->buildCacheHref = $this->addToUrl('bic=1');
     $this->Template->needsCacheBuild = !is_dir(\System::getContainer()->getParameter('kernel.cache_dir') . '/contao/sql');
     $this->Template->isPopup = \Input::get('popup');
     // Front end preview links
     if (defined('CURRENT_ID') && CURRENT_ID != '') {
         // Pages
         if (\Input::get('do') == 'page') {
             $this->Template->frontendFile = '?page=' . CURRENT_ID;
         } elseif (\Input::get('do') == 'article') {
             if (($objArticle = \ArticleModel::findByPk(CURRENT_ID)) !== null) {
                 $this->Template->frontendFile = '?page=' . $objArticle->pid;
             }
         }
     }
     return $this->Template->getResponse();
 }