/**
  * Get config value from transformed arrData and add logic to modify the value here
  * @param $strKey
  *
  * @return mixed|string
  */
 public function __get($strKey)
 {
     $varValue = $this->arrData[$strKey];
     switch ($strKey) {
         case 'strAction':
             if ($varValue && ($objActionPage = \PageModel::findWithDetails($varValue)) !== null) {
                 $varValue = \Controller::generateFrontendUrl($objActionPage->row(), null, null, true);
             } else {
                 $varValue = Url::removeQueryString(array('file'), \Environment::get('uri'));
                 // remove all query parameters within ajax request
                 if (Ajax::isRelated(Form::FORMHYBRID_NAME) !== false) {
                     $varValue = AjaxAction::removeAjaxParametersFromUrl($varValue);
                 }
             }
             // async form
             if ($this->async) {
                 $varValue = AjaxAction::generateUrl(Form::FORMHYBRID_NAME, 'asyncFormSubmit');
             }
             // add hash
             if ($this->addHashToAction) {
                 $varValue .= '#' . ($this->customHash ?: $this->strFormId);
             }
             break;
         case 'arrDefaultValues':
             $varValue = FormHelper::getAssocMultiColumnWizardList($varValue, 'field');
             break;
     }
     return $varValue;
 }
Пример #2
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     // Set the trail and level
     if ($this->defineRoot && $this->rootPage > 0) {
         $trail = array($this->rootPage);
         $level = 0;
     } else {
         $trail = $objPage->trail;
         $level = $this->levelOffset > 0 ? $this->levelOffset : 0;
     }
     $lang = null;
     $host = null;
     // Overwrite the domain and language if the reference page belongs to a differnt root page (see #3765)
     if ($this->defineRoot && $this->rootPage > 0) {
         $objRootPage = \PageModel::findWithDetails($this->rootPage);
         // Set the language
         if (\Config::get('addLanguageToUrl') && $objRootPage->rootLanguage != $objPage->rootLanguage) {
             $lang = $objRootPage->rootLanguage;
         }
         // Set the domain
         if ($objRootPage->rootId != $objPage->rootId && $objRootPage->domain != '' && $objRootPage->domain != $objPage->domain) {
             $host = $objRootPage->domain;
         }
     }
     $this->Template->request = ampersand(\Environment::get('indexFreeRequest'));
     $this->Template->skipId = 'skipNavigation' . $this->id;
     $this->Template->skipNavigation = specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']);
     $this->Template->items = $this->renderNavigation($trail[$level], 1, $host, $lang);
 }
Пример #3
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $lang = null;
     $host = null;
     // Start from the website root if there is no reference page
     if (!$this->rootPage) {
         $this->rootPage = $objPage->rootId;
     } else {
         $objRootPage = \PageModel::findWithDetails($this->rootPage);
         // Set the language
         if (\Config::get('addLanguageToUrl') && $objRootPage->rootLanguage != $objPage->rootLanguage) {
             $lang = $objRootPage->rootLanguage;
         }
         // Set the domain
         if ($objRootPage->rootId != $objPage->rootId && $objRootPage->domain != '' && $objRootPage->domain != $objPage->domain) {
             $host = $objRootPage->domain;
         }
     }
     $this->Template->formId = 'tl_quicknav_' . $this->id;
     $this->Template->targetPage = $GLOBALS['TL_LANG']['MSC']['targetPage'];
     $this->Template->button = specialchars($GLOBALS['TL_LANG']['MSC']['go']);
     $this->Template->title = $this->customLabel ?: $GLOBALS['TL_LANG']['MSC']['quicknav'];
     $this->Template->request = ampersand(\Environment::get('request'), true);
     $this->Template->items = $this->getQuicknavPages($this->rootPage, 1, $host, $lang);
 }
Пример #4
0
 public function getActiveLayoutSections(\DataContainer $dc)
 {
     $callback = $GLOBALS['TL_DCA']['tl_article']['fields']['inColumn']['bit3_merger_original_options_callback'];
     if (is_array($callback)) {
         $object = \System::importStatic($callback[0]);
         $methodName = $callback[1];
         $sections = $object->{$methodName}($dc);
     } else {
         $sections = call_user_func($callback, $dc);
     }
     if ($dc->activeRecord->pid) {
         $page = \PageModel::findWithDetails($dc->activeRecord->pid);
         // Get the layout sections
         foreach (array('layout', 'mobileLayout') as $key) {
             if (!$page->{$key}) {
                 continue;
             }
             $layout = \LayoutModel::findByPk($page->{$key});
             if ($layout === null) {
                 continue;
             }
             $modules = deserialize($layout->modules);
             if (empty($modules) || !is_array($modules)) {
                 continue;
             }
             // Find all sections with an article module (see #6094)
             foreach ($modules as $module) {
                 if ($module['mod'] != 0 && $module['enable']) {
                     $this->joinModule($module['col'], $module['mod'], $sections);
                 }
             }
         }
     }
     return array_values(array_unique($sections));
 }
Пример #5
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $lang = null;
     $host = null;
     // Start from the website root if there is no reference page
     if (!$this->rootPage) {
         $this->rootPage = $objPage->rootId;
     } else {
         $objRootPage = \PageModel::findWithDetails($this->rootPage);
         // Set the language
         if (\Config::get('addLanguageToUrl') && $objRootPage->rootLanguage != $objPage->rootLanguage) {
             $lang = $objRootPage->rootLanguage;
         }
         // Set the domain
         if ($objRootPage->rootId != $objPage->rootId && $objRootPage->domain != '' && $objRootPage->domain != $objPage->domain) {
             $host = $objRootPage->domain;
         }
     }
     $this->showLevel = 0;
     $this->hardLimit = false;
     $this->levelOffset = 0;
     $this->Template->items = $this->renderNavigation($this->rootPage, 1, $host, $lang);
 }
Пример #6
0
 /**
  * Return the page view button
  * @param string
  * @param string
  * @param string
  * @param string
  * @param string
  * @param string
  * @param array
  * @return string
  */
 public function getPageViewButton($href, $label, $title, $class, $attributes, $table, $root)
 {
     $objPage = \PageModel::findWithDetails(\Input::get('page_id'));
     if (null === $objPage) {
         return '';
     }
     return '<a href="contao/main.php?do=feRedirect&page=' . $objPage->id . '" target="_blank" class="header_preview" title="' . specialchars($title) . '"' . $attributes . '>' . $label . '</a>';
 }
Пример #7
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     // add miscellaneous vars to the template
     $this->addTemplateVars();
     // get href for the detail-page
     $objDetailPage = \PageModel::findWithDetails($this->detailPage);
     if ($objDetailPage === NULL) {
         $href = NULL;
     } else {
         $href = $this->generateFrontendUrl($objDetailPage->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/member/%s', $objDetailPage->language);
     }
     $objMember = $this->Database->prepare('SELECT * FROM tl_member WHERE disable = ?')->execute(0);
     $arrRows = array();
     while ($row = $objMember->fetchAssoc()) {
         foreach ($row as $k => $v) {
             if ($k == 'id' || $k == 'tstamp' || $k == 'password' || $k == 'avatar') {
                 continue;
             }
             $row[$k] = $v;
         }
         // score and grade
         $row['score'] = $this->getScore($row['id']);
         $row['averageRating'] = $this->getAverageRating($row['id']);
         $row['ratingEnities'] = $this->getRatingEnities($row['id']);
         $row['gradeLabel'] = $this->getGrade($row['id'], 'label');
         $row['gradeIcon'] = $this->getGrade($row['id'], 'label');
         // link to detail page
         $row['hrefDetailPage'] = $href ? sprintf($href, $row['id']) : false;
         // get avatar of member
         $arrSize = deserialize($this->avatarSizeListing);
         $title = $row['firstname'] . ' ' . $row['lastname'];
         $row['avatar'] = $this->getAvatar($objMember->id, $arrSize, 'avatar', $title, 'avatar_thumb', $this);
         // Show only Members from a selected group
         if ($this->limitUsers) {
             $arrGroups = deserialize($this->listedGroups);
             $oMember = \MemberModel::findByPk($objMember->id);
             if ($oMember !== null) {
                 if (count(array_intersect(deserialize($oMember->groups), $arrGroups)) < 1) {
                     continue;
                 }
             }
         }
         $arrRows[] = $row;
     }
     // Sorting
     $arrSorting = array();
     if (!empty($this->sortingField1) && !empty($this->sortingDirection1)) {
         $arrSorting[$this->sortingField1] = constant($this->sortingDirection1);
     }
     if (!empty($this->sortingField2) && !empty($this->sortingDirection2)) {
         $arrSorting[$this->sortingField2] = constant($this->sortingDirection2);
     }
     if (!empty($this->sortingField3) && !empty($this->sortingDirection3)) {
         $arrSorting[$this->sortingField3] = constant($this->sortingDirection3);
     }
     $arrRows = sortArrayByFields($arrRows, $arrSorting);
     $this->Template->rows = count($arrRows) ? $arrRows : false;
 }
Пример #8
0
 /**
  * Add FAQs to the indexer
  *
  * @param array   $arrPages
  * @param integer $intRoot
  * @param boolean $blnIsSitemap
  *
  * @return array
  */
 public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page');
     }
     $arrProcessed = array();
     $time = \Date::floorToMinute();
     // Get all categories
     $objFaq = \FaqCategoryModel::findAll();
     // Walk through each category
     if ($objFaq !== null) {
         while ($objFaq->next()) {
             // Skip FAQs without target page
             if (!$objFaq->jumpTo) {
                 continue;
             }
             // Skip FAQs outside the root nodes
             if (!empty($arrRoot) && !in_array($objFaq->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objFaq->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objFaq->jumpTo);
                 // The target page does not exist
                 if ($objParent === null) {
                     continue;
                 }
                 // The target page has not been published (see #5520)
                 if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop <= $time + 60) {
                     continue;
                 }
                 if ($blnIsSitemap) {
                     // The target page is protected (see #8416)
                     if ($objParent->protected) {
                         continue;
                     }
                     // The target page is exempt from the sitemap (see #6418)
                     if ($objParent->sitemap == 'map_never') {
                         continue;
                     }
                 }
                 // Generate the URL
                 $arrProcessed[$objFaq->jumpTo] = $objParent->getAbsoluteUrl(\Config::get('useAutoItem') ? '/%s' : '/items/%s');
             }
             $strUrl = $arrProcessed[$objFaq->jumpTo];
             // Get the items
             $objItems = \FaqModel::findPublishedByPid($objFaq->id);
             if ($objItems !== null) {
                 while ($objItems->next()) {
                     $arrPages[] = sprintf($strUrl, $objItems->alias ?: $objItems->id);
                 }
             }
         }
     }
     return $arrPages;
 }
Пример #9
0
 /**
  * Add product items to the indexer
  * @param array
  * @param integer
  * @param boolean
  * @return array
  */
 public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page');
     }
     $time = time();
     $arrProcessed = array();
     // Get all catalog categories
     $objCatalog = \ProductCatalogModel::findByProtected('');
     // Walk through each archive
     if ($objCatalog !== null) {
         while ($objCatalog->next()) {
             // Skip catalog categories without target page
             if (!$objCatalog->jumpTo) {
                 continue;
             }
             // Skip catalog categories outside the root nodes
             if (!empty($arrRoot) && !in_array($objCatalog->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objCatalog->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objCatalog->jumpTo);
                 // The target page does not exist
                 if ($objParent === null) {
                     continue;
                 }
                 // The target page has not been published (see #5520)
                 if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop < $time) {
                     continue;
                 }
                 // The target page is exempt from the sitemap (see #6418)
                 if ($blnIsSitemap && $objParent->sitemap == 'map_never') {
                     continue;
                 }
                 // Set the domain (see #6421)
                 $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/';
                 // Generate the URL
                 $arrProcessed[$objCatalog->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrProcessed[$objCatalog->jumpTo];
             // Get the items
             $objProduct = \ProductModel::findPublishedByPid($objCatalog->id);
             if ($objProduct !== null) {
                 while ($objProduct->next()) {
                     $objElement = \ContentModel::findPublishedByPidAndTable($objProduct->id, 'tl_product');
                     if ($objElement !== null) {
                         $arrPages[] = $this->getLink($objProduct, $strUrl);
                     }
                 }
             }
         }
     }
     return $arrPages;
 }
Пример #10
0
 /**
  * Add FAQs to the indexer
  *
  * @param array   $arrPages
  * @param integer $intRoot
  * @param boolean $blnIsSitemap
  *
  * @return array
  */
 public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page');
     }
     $arrProcessed = array();
     $time = \Date::floorToMinute();
     // Get all categories
     $objFaq = \FaqCategoryModel::findAll();
     // Walk through each category
     if ($objFaq !== null) {
         while ($objFaq->next()) {
             // Skip FAQs without target page
             if (!$objFaq->jumpTo) {
                 continue;
             }
             // Skip FAQs outside the root nodes
             if (!empty($arrRoot) && !in_array($objFaq->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objFaq->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objFaq->jumpTo);
                 // The target page does not exist
                 if ($objParent === null) {
                     continue;
                 }
                 // The target page has not been published (see #5520)
                 if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop <= $time + 60) {
                     continue;
                 }
                 // The target page is exempt from the sitemap (see #6418)
                 if ($blnIsSitemap && $objParent->sitemap == 'map_never') {
                     continue;
                 }
                 // Generate the URL
                 $feUrl = $objParent->getFrontendUrl(\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s');
                 if (strncmp($feUrl, 'http://', 7) !== 0 && strncmp($feUrl, 'https://', 8) !== 0) {
                     $feUrl = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/' . $feUrl;
                 }
                 $arrProcessed[$objFaq->jumpTo] = $feUrl;
             }
             $strUrl = $arrProcessed[$objFaq->jumpTo];
             // Get the items
             $objItems = \FaqModel::findPublishedByPid($objFaq->id);
             if ($objItems !== null) {
                 while ($objItems->next()) {
                     $arrPages[] = sprintf($strUrl, $objItems->alias != '' && !\Config::get('disableAlias') ? $objItems->alias : $objItems->id);
                 }
             }
         }
     }
     return $arrPages;
 }
Пример #11
0
 /**
  * get all news items by page pid
  * @param array
  * @param integer
  * @param boolean
  * @return array
  */
 public static function getAllNews($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = \Database::getInstance()->getChildRecords($intRoot, 'tl_page');
     }
     $time = time();
     $arrProcessed = array();
     // Get all news archives
     $objArchive = \NewsArchiveModel::findByProtected('');
     // Walk through each archive
     if ($objArchive !== null) {
         while ($objArchive->next()) {
             // Skip news archives without target page
             if (!$objArchive->jumpTo) {
                 continue;
             }
             // Skip news archives outside the root nodes
             if (!empty($arrRoot) && !in_array($objArchive->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objArchive->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objArchive->jumpTo);
                 // The target page does not exist
                 if ($objParent === null) {
                     continue;
                 }
                 // The target page has not been published (see #5520)
                 if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop < $time) {
                     continue;
                 }
                 // The target page is exempt from the sitemap (see #6418)
                 if ($blnIsSitemap && $objParent->sitemap == 'map_never') {
                     continue;
                 }
                 // Set the domain (see #6421)
                 // $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/';
                 // Generate the URL
                 // $arrProcessed[$objArchive->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), ((\Config::get('useAutoItem') && !\Config::get('disableAlias')) ?  '/%s' : '/items/%s'), $objParent->language);
             }
             $strUrl = $arrProcessed[$objArchive->jumpTo];
             // Get the items
             $objArticle = \NewsModel::findPublishedDefaultByPid($objArchive->id);
             if ($objArticle !== null) {
                 while ($objArticle->next()) {
                     $arrPages[] = $objArticle->id;
                 }
             }
         }
     }
     return $arrPages;
 }
 /**
  * Generate a link to the relation submission form page
  *
  * @param \PageModel $objPage
  * @param \Model     $objEntity
  * @param array      $arrRelation
  *
  * @return string The url to the relation submission page
  */
 public function getRelationLink(\PageModel $objPage, \Model $objEntity, array $arrRelation)
 {
     $objPage = \PageModel::findWithDetails($objPage->id);
     $strParam = $arrRelation['request_parameter'] ?: $arrRelation['submissionField'];
     if (\Config::get('useAutoItem') && $arrRelation['useAutoItem']) {
         $varPath = !\Config::get('disableAlias') ? '/' : '/' . $strParam . '/';
         $varValue = !\Config::get('disableAlias') && $objEntity->alias ? $objEntity->alias : $objEntity->id;
         return \Controller::generateFrontendUrl($objPage->row(), $varPath . $varValue, $objPage->language, true);
     }
     $strQuery = $strParam . '=' . (!\Config::get('disableAlias') && $objEntity->alias ? $objEntity->alias : $objEntity->id);
     return Url::addQueryString($strQuery, \Controller::generateFrontendUrl($objPage->row(), null, $objPage->language, true));
 }
 /**
  * Generate the canonical link
  *
  * @param $objPage
  * @return string
  */
 private static function generateLink($objPage)
 {
     $strUrl = '';
     $strDomain = \Environment::get('base');
     $objCanonicalPage = \PageModel::findWithDetails($objPage->canonicalJumpTo);
     if ($objCanonicalPage !== null) {
         if ($objCanonicalPage->domain != '') {
             $strDomain = (\Environment::get('ssl') ? 'https://' : 'http://') . $objCanonicalPage->domain . TL_PATH . '/';
         }
         $strUrl = $strDomain . \Controller::generateFrontendUrl($objCanonicalPage->row(), null, $objCanonicalPage->language);
     }
     return $strUrl;
 }
Пример #14
0
 /**
  * Return the payment form
  * @param   IsotopeProductCollection    The order being places
  * @param   Module                      The checkout module instance
  * @return  string
  */
 public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule)
 {
     // get current host and
     $strDescription = \Environment::get('host');
     $objContact = \PageModel::findWithDetails($this->wirecard_contact);
     $arrParams = array('customerId' => $this->wirecard_customer_id, 'language' => $GLOBALS['TL_LANGUAGE'], 'paymentType' => 'SELECT', 'amount' => number_format($objOrder->getTotal(), 2, '.', ''), 'currency' => $objOrder->currency, 'orderDescription' => $strDescription, 'successUrl' => \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder), 'cancelUrl' => \Environment::get('base') . $objModule->generateUrlForStep('process'), 'failureUrl' => \Environment::get('base') . $objModule->generateUrlForStep('failed'), 'serviceUrl' => \Environment::get('base') . \Controller::generateFrontendUrl($objContact->row()), 'confirmUrl' => \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id, 'customerStatement' => $strDescription, 'order_id' => $objOrder->id, 'order_uniqid' => $objOrder->uniqid, 'secret' => $this->wirecard_secret, 'REQUEST_TOKEN' => REQUEST_TOKEN);
     $arrParams['requestFingerprintOrder'] = implode(',', array_keys($arrParams)) . ',requestFingerprintOrder';
     $arrParams['requestFingerprint'] = $this->calcHashArray($arrParams);
     $objTemplate = new \Isotope\Template('iso_payment_wirecard');
     $objTemplate->setData($this->arrData);
     $objTemplate->action = 'https://checkout.wirecard.com/page/init.php';
     $objTemplate->params = array_filter(array_diff_key($arrParams, array('secret' => '')));
     return $objTemplate->parse();
 }
Пример #15
0
 /**
  * Check the news alias for duplicates
  *
  * @param mixed         $varValue
  * @param DataContainer $dc
  *
  * @return string
  *
  * @throws Exception
  */
 public function checkAlias($varValue, DataContainer $dc)
 {
     // check if there is a news article with the same alias
     if (($objNews = \NewsModel::findByAlias($varValue)) !== null) {
         // get the redirect page
         if (($objTarget = \PageModel::findWithDetails($objNews->getRelated('pid')->jumpTo)) !== null) {
             // get the page
             $objPage = \PageModel::findWithDetails($dc->id);
             // check if page is on the same domain and language
             if ($objPage->domain == $objTarget->domain && (\Config::get('addLanguageToUrl') && $objPage->rootLanguage == $objTarget->rootLanguage)) {
                 // append id
                 $varValue .= '-' . $dc->id;
             }
         }
     }
     // return the alias
     return $varValue;
 }
Пример #16
0
 /**
  * Get all articles and return them as array (article teaser)
  * @param \DataContainer
  * @return array
  */
 public function getArticles(DataContainer $dc)
 {
     $arrPids = array();
     $arrArticle = array();
     $arrRoot = array();
     $intPid = $dc->activeRecord->pid;
     if (Input::get('act') == 'overrideAll') {
         $intPid = Input::get('id');
     }
     // Limit pages to the website root
     $objArticle = $this->Database->prepare("SELECT pid FROM tl_article WHERE id=?")->limit(1)->execute($intPid);
     if ($objArticle->numRows) {
         $objPage = PageModel::findWithDetails($objArticle->pid);
         $arrRoot = $this->Database->getChildRecords($objPage->rootId, 'tl_page');
         array_unshift($arrRoot, $objPage->rootId);
     }
     unset($objArticle);
     // Limit pages to the user's pagemounts
     if ($this->User->isAdmin) {
         $objArticle = $this->Database->execute("SELECT a.id, a.pid, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid" . (!empty($arrRoot) ? " WHERE a.pid IN(" . implode(',', array_map('intval', array_unique($arrRoot))) . ")" : "") . " ORDER BY parent, a.sorting");
     } else {
         foreach ($this->User->pagemounts as $id) {
             if (!in_array($id, $arrRoot)) {
                 continue;
             }
             $arrPids[] = $id;
             $arrPids = array_merge($arrPids, $this->Database->getChildRecords($id, 'tl_page'));
         }
         if (empty($arrPids)) {
             return $arrArticle;
         }
         $objArticle = $this->Database->execute("SELECT a.id, a.pid, a.title, a.inColumn, p.title AS parent FROM tl_article a LEFT JOIN tl_page p ON p.id=a.pid WHERE a.pid IN(" . implode(',', array_map('intval', array_unique($arrPids))) . ") ORDER BY parent, a.sorting");
     }
     // Edit the result
     if ($objArticle->numRows) {
         System::loadLanguageFile('tl_article');
         while ($objArticle->next()) {
             $key = $objArticle->parent . ' (ID ' . $objArticle->pid . ')';
             $arrArticle[$key][$objArticle->id] = $objArticle->title . ' (' . ($GLOBALS['TL_LANG']['tl_article'][$objArticle->inColumn] ?: $objArticle->inColumn) . ', ID ' . $objArticle->id . ')';
         }
     }
     return $arrArticle;
 }
 public function languageLabels($row, $label, $dc = null, $imageAttribute = '', $blnReturnImage = false, $blnProtected = false)
 {
     // generate the default label
     $objDcaClass = null;
     if (in_array('cacheicon', ModuleLoader::getActive())) {
         $objDcaClass = new tl_page_cacheicon();
     } elseif (in_array('Avisota', ModuleLoader::getActive())) {
         $objDcaClass = new tl_page_avisota();
     } else {
         $objDcaClass = new tl_page();
     }
     $label = $objDcaClass->addIcon($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected);
     // return the label for root or folder page
     if ($row['type'] == 'root' || $row['type'] == 'folder') {
         return $label;
     }
     // load the current page
     $objPage = PageModel::findWithDetails($row['id']);
     // prepare alternate pages
     $objAlternates = null;
     if ($objPage->languageMain) {
         // get all pages referencing the same fallback page
         $t = \PageModel::getTable();
         $objAlternates = PageModel::findBy(array("{$t}.languageMain = ? OR {$t}.id = ?"), array($objPage->languageMain, $objPage->languageMain));
     } else {
         // get all pages referencing the current page as its fallback
         $objAlternates = PageModel::findByLanguageMain($objPage->id);
     }
     // check if alternates were found
     if ($objAlternates !== null) {
         $label .= '<ul class="tl_page_language_alternates">';
         // go through each page and add link
         while ($objAlternates->next()) {
             if ($objAlternates->id == $objPage->id) {
                 continue;
             }
             $objAlternates->current()->loadDetails();
             $label .= '<li><a href="contao/main.php?do=page&amp;node=' . $objAlternates->id . '&amp;ref=' . TL_REFERER_ID . '">' . $objAlternates->language . '</a></li>';
         }
         $label .= '</ul>';
     }
     return $label;
 }
Пример #18
0
 /**
  * Hook for searchable pages
  *
  * @param array $arrPages
  * @param number $intRoot
  * @param string $blnIsSitemap
  * @return string
  */
 public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $db = Database::getInstance();
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = $db->getChildRecords($intRoot, 'tl_page', true);
     }
     // Read jump to page details
     $objResult = $db->prepare("SELECT jumpTo, company_archiv FROM tl_module WHERE type=?")->execute('company_list');
     $arrModules = $objResult->fetchAllAssoc();
     if (count($arrModules) > 0) {
         $arrPids = array();
         foreach ($arrModules as $arrModule) {
             if (is_array($arrRoot) && count($arrRoot) > 0 && !in_array($arrModule['jumpTo'], $arrRoot)) {
                 continue;
             }
             $objParent = \PageModel::findWithDetails($arrModule['jumpTo']);
             // The target page does not exist
             if ($objParent === null) {
                 continue;
             }
             // The target page has not been published (see #5520)
             if (!$objParent->published) {
                 continue;
             }
             // The target page is exempt from the sitemap (see #6418)
             if ($blnIsSitemap && $objParent->sitemap == 'map_never') {
                 continue;
             }
             // Set the domain (see #6421)
             $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/';
             $arrPids[] = $arrModule['company_archiv'];
             $objCompanies = CompanyModel::findByPids($arrPids, 0, 0, array('order' => 'id ASC'));
             while ($objCompanies->next()) {
                 $arrCompany = $objCompanies->row();
                 $arrPages[] = $domain . $this->generateFrontendUrl($objParent->row(), '/companyID/' . $arrCompany['id'], $objParent->language);
             }
         }
     }
     return $arrPages;
 }
Пример #19
0
 public function parseArticlesHook(&$objTemplate, $arrArticle, $objModule)
 {
     if (!($objModule->useModal && $arrArticle['source'] == 'default')) {
         return false;
     }
     $objJumpTo = \PageModel::findPublishedById($objTemplate->archive->jumpTo);
     if ($objJumpTo === null || !$objJumpTo->linkModal) {
         return false;
     }
     $objModal = ModalModel::findPublishedByIdOrAlias($objJumpTo->modal);
     if ($objModal === null) {
         return false;
     }
     $objJumpTo = \PageModel::findWithDetails($objJumpTo->id);
     $arrConfig = ModalController::getModalConfig($objModal->current(), $objJumpTo->layout);
     $blnAjax = true;
     $blnRedirect = true;
     $objTemplate->link = ModalController::generateModalUrl($arrArticle, $objTemplate->archive->jumpTo, $blnAjax, $blnRedirect);
     $objTemplate->linkHeadline = ModalController::convertLinkToModalLink($objTemplate->linkHeadline, $objTemplate->link, $arrConfig, $blnRedirect);
     $objTemplate->more = ModalController::convertLinkToModalLink($objTemplate->more, $objTemplate->link, $arrConfig, $blnRedirect);
 }
 /**
  * getPageIdFromUrl Hook
  * checks if the URL fragment is a news alias and sets the page alias and auto item accordingly
  * @param array the URL fragments
  */
 public function getPageIdFromUrl($arrFragments)
 {
     // extract alias from fragments
     $alias = null;
     // handle special case with i18nl10n (see #4)
     if (in_array('i18nl10n', \ModuleLoader::getActive()) && count($arrFragments) == 3) {
         if ($arrFragments[0] == null && $arrFragments[1] == 'language') {
             $alias = $arrFragments[2];
         }
     } elseif (count($arrFragments) == 1) {
         $alias = $arrFragments[0];
     }
     // check if an alias was extracted
     if ($alias) {
         // check if news item exists
         if (($objNews = \NewsModel::findByAlias($alias)) !== null) {
             // check if jumpTo page exists
             if (($objTarget = \PageModel::findWithDetails($objNews->getRelated('pid')->jumpTo)) !== null) {
                 // check if target page is in the right language
                 if (\Config::get('addLanguageToUrl') && $objTarget->rootLanguage != \Input::get('language')) {
                     // return fragments without change
                     return $arrFragments;
                 }
                 // check if target page is in the right domain
                 if ($objTarget->domain && stripos(\Environment::get('host'), $objTarget->domain) === false) {
                     // return fragments without change
                     return $arrFragments;
                 }
                 // return changed fragments
                 return array($objTarget->alias, 'auto_item', $objNews->alias);
             }
         }
     }
     // return fragments without change
     return $arrFragments;
 }
Пример #21
0
 /**
  * Load all section label from used page layout.
  *
  * @param string         $value         Active used column.
  * @param \DataContainer $dataContainer Data container driver.
  *
  * @return string
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function loadSectionLabels($value, $dataContainer)
 {
     // Show only active sections
     if ($dataContainer->activeRecord->pid) {
         $page = \PageModel::findWithDetails($dataContainer->activeRecord->pid);
         // Get the layout sections
         foreach (array('layout', 'mobileLayout') as $key) {
             if (!$page->{$key}) {
                 continue;
             }
             $objLayout = \LayoutModel::findByPk($page->{$key});
             if ($objLayout === null) {
                 continue;
             }
             $sections = deserialize($objLayout->flexible_sections, true);
             foreach ($sections as $section) {
                 if (!isset($GLOBALS['TL_LANG']['tl_article'][$section['id']])) {
                     $GLOBALS['TL_LANG']['tl_article'][$section['id']] = $section['label'] ?: $section['id'];
                 }
             }
         }
     }
     return $value;
 }
Пример #22
0
 /**
  * Set the form action from a Contao page ID
  *
  * @param   int $intId The page ID
  *
  * @return   $this
  * @throws  \InvalidArgumentException
  */
 public function setFormActionFromPageId($intId)
 {
     if (($objPage = \PageModel::findWithDetails($intId)) === null) {
         throw new \InvalidArgumentException(sprintf('The page id "%s" does apparently not exist!', $intId));
     }
     $this->strFormAction = \Controller::generateFrontendUrl($objPage->row(), null, $objPage->language);
     return $this;
 }
Пример #23
0
 /**
  * Generate an XML files and save them to the root directory
  * @param array
  */
 protected function generateFiles($arrFeed)
 {
     $arrArchives = deserialize($arrFeed['archives']);
     if (!is_array($arrArchives) || empty($arrArchives)) {
         return;
     }
     $strType = $arrFeed['format'] == 'atom' ? 'generateAtom' : 'generateRss';
     $strLink = $arrFeed['feedBase'] ?: \Environment::get('base');
     $strFile = $arrFeed['feedName'];
     $objFeed = new \Feed($strFile);
     $objFeed->link = $strLink;
     $objFeed->title = $arrFeed['title'];
     $objFeed->description = $arrFeed['description'];
     $objFeed->language = $arrFeed['language'];
     $objFeed->published = $arrFeed['tstamp'];
     $arrCategories = deserialize($arrFeed['categories']);
     // Filter by categories
     if (is_array($arrCategories) && !empty($arrCategories)) {
         $GLOBALS['NEWS_FILTER_CATEGORIES'] = true;
         $GLOBALS['NEWS_FILTER_DEFAULT'] = $arrCategories;
     } else {
         $GLOBALS['NEWS_FILTER_CATEGORIES'] = false;
     }
     // Get the items
     if ($arrFeed['maxItems'] > 0) {
         $objArticle = \NewsModel::findPublishedByPids($arrArchives, null, $arrFeed['maxItems']);
     } else {
         $objArticle = \NewsModel::findPublishedByPids($arrArchives);
     }
     // Parse the items
     if ($objArticle !== null) {
         $arrUrls = array();
         while ($objArticle->next()) {
             $jumpTo = $objArticle->getRelated('pid')->jumpTo;
             // No jumpTo page set (see #4784)
             if (!$jumpTo) {
                 continue;
             }
             // Get the jumpTo URL
             if (!isset($arrUrls[$jumpTo])) {
                 $objParent = \PageModel::findWithDetails($jumpTo);
                 // A jumpTo page is set but does no longer exist (see #5781)
                 if ($objParent === null) {
                     $arrUrls[$jumpTo] = false;
                 } else {
                     $arrUrls[$jumpTo] = $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/%s' : '/items/%s', $objParent->language);
                 }
             }
             // Skip the event if it requires a jumpTo URL but there is none
             if ($arrUrls[$jumpTo] === false && $objArticle->source == 'default') {
                 continue;
             }
             // Get the categories
             if ($arrFeed['categories_show']) {
                 $arrCategories = array();
                 if (($objCategories = NewsCategoryModel::findPublishedByIds(deserialize($objArticle->categories, true))) !== null) {
                     $arrCategories = $objCategories->fetchEach('title');
                 }
             }
             $strUrl = $arrUrls[$jumpTo];
             $objItem = new \FeedItem();
             // Add the categories to the title
             if ($arrFeed['categories_show'] == 'title') {
                 $objItem->title = sprintf('[%s] %s', implode(', ', $arrCategories), $objArticle->headline);
             } else {
                 $objItem->title = $objArticle->headline;
             }
             $objItem->link = $this->getLink($objArticle, $strUrl, $strLink);
             $objItem->published = $objArticle->date;
             $objItem->author = $objArticle->authorName;
             // Prepare the description
             if ($arrFeed['source'] == 'source_text') {
                 $strDescription = '';
                 $objElement = \ContentModel::findPublishedByPidAndTable($objArticle->id, 'tl_news');
                 if ($objElement !== null) {
                     while ($objElement->next()) {
                         $strDescription .= $this->getContentElement($objElement->id);
                     }
                 }
             } else {
                 $strDescription = $objArticle->teaser;
             }
             // Add the categories to the description
             if ($arrFeed['categories_show'] == 'text_before' || $arrFeed['categories_show'] == 'text_after') {
                 $strCategories = '<p>' . $GLOBALS['TL_LANG']['MSC']['newsCategories'] . ' ' . implode(', ', $arrCategories) . '</p>';
                 if ($arrFeed['categories_show'] == 'text_before') {
                     $strDescription = $strCategories . $strDescription;
                 } else {
                     $strDescription .= $strCategories;
                 }
             }
             $strDescription = $this->replaceInsertTags($strDescription, false);
             $objItem->description = $this->convertRelativeUrls($strDescription, $strLink);
             // Add the article image as enclosure
             if ($objArticle->addImage) {
                 $objFile = \FilesModel::findByUuid($objArticle->singleSRC);
                 if ($objFile !== null) {
                     $objItem->addEnclosure($objFile->path);
                 }
             }
             // Enclosures
             if ($objArticle->addEnclosure) {
                 $arrEnclosure = deserialize($objArticle->enclosure, true);
                 if (is_array($arrEnclosure)) {
                     $objFile = \FilesModel::findMultipleByUuids($arrEnclosure);
                     if ($objFile !== null) {
                         while ($objFile->next()) {
                             $objItem->addEnclosure($objFile->path);
                         }
                     }
                 }
             }
             $objFeed->addItem($objItem);
         }
     }
     // Create the file
     \File::putContent('share/' . $strFile . '.xml', $this->replaceInsertTags($objFeed->{$strType}(), false));
 }
Пример #24
0
/**
 * Isotope eCommerce for Contao Open Source CMS
 *
 * Copyright (C) 2009-2014 terminal42 gmbh & Isotope eCommerce Workgroup
 *
 * @package    Isotope
 * @link       http://isotopeecommerce.org
 * @license    http://opensource.org/licenses/lgpl-3.0.html
 */
/**
 * Callbacks
 */
$GLOBALS['TL_DCA']['tl_page']['config']['onload_callback'][] = function (\DataContainer $dc) {
    if (\Input::get('do') == 'page' && \Input::get('table') == 'tl_page' && \Input::get('field') == 'iso_readerJumpTo') {
        if (($objPage = \PageModel::findWithDetails($dc->id)) !== null) {
            $GLOBALS['TL_DCA']['tl_page']['fields']['iso_readerJumpTo']['rootNodes'] = array($objPage->rootId);
        }
    }
};
/**
 * Extend tl_page palettes
 */
$GLOBALS['TL_DCA']['tl_page']['palettes']['root'] = str_replace(';{publish_legend}', ';{isotope_legend},iso_config,iso_store_id;{publish_legend}', $GLOBALS['TL_DCA']['tl_page']['palettes']['root']);
$GLOBALS['TL_DCA']['tl_page']['palettes']['regular'] = str_replace(';{publish_legend}', ';{isotope_legend},iso_setReaderJumpTo;{publish_legend}', $GLOBALS['TL_DCA']['tl_page']['palettes']['regular']);
/**
 * Add a selector to tl_page
 */
$GLOBALS['TL_DCA']['tl_page']['palettes']['__selector__'][] = 'iso_setReaderJumpTo';
/**
 * Add subpalettes to tl_page
Пример #25
0
 /**
  * Add formdata details to the indexer
  * @param array $arrPages Array of URLs
  * @param integer $intRoot ID of root page
  * @return array
  */
 public function getSearchablePages($arrPages, $intRoot = 0)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = \Database::getInstance()->getChildRecords($intRoot, 'tl_page', true);
     }
     $this->getSearchableListingPages();
     $arrProcessed = array();
     if (!empty($this->arrSearchableListingPages)) {
         $this->loadDataContainer('fd_feedback');
         foreach ($this->arrSearchableListingPages as $pageId => $arrParams) {
             if (!empty($arrRoot) && !in_array($pageId, $arrRoot)) {
                 continue;
             }
             // Do not add if list condition contains insert tags
             if (!empty($arrParams['list_where'])) {
                 if (strpos($arrParams['list_where'], '{{') !== false) {
                     continue;
                 }
             }
             // Do not add if no listing details fields are defined
             if (empty($arrParams['list_info'])) {
                 continue;
             }
             if (empty($arrParams['list_formdata'])) {
                 continue;
             }
             if (!isset($arrProcessed[$pageId])) {
                 $arrProcessed[$pageId] = false;
                 $strForm = '';
                 $strFormsKey = substr($arrParams['list_formdata'], strlen('fd_'));
                 if (isset($this->arrFormsDcaKey[$strFormsKey])) {
                     $strForm = $this->arrFormsDcaKey[$strFormsKey];
                 }
                 $pageAlias = !empty($arrParams['alias']) ? $arrParams['alias'] : null;
                 if (!empty($strForm)) {
                     $strFormdataDetailsKey = 'details';
                     if (!empty($arrParams['formdataDetailsKey'])) {
                         $strFormdataDetailsKey = $arrParams['formdataDetailsKey'];
                     }
                     // Determine domain
                     if (intval($pageId) > 0) {
                         $domain = \Environment::get('base');
                         $objParent = \PageModel::findWithDetails($pageId);
                         if (!empty($objParent->domain)) {
                             $domain = (\Environment::get('ssl') ? 'https://' : 'http://') . $objParent->domain . TL_PATH . '/';
                         }
                     }
                     $arrProcessed[$pageId] = $domain . $this->generateFrontendUrl($objParent->row(), '/' . $strFormdataDetailsKey . '/%s', $objParent->language);
                 }
                 if ($arrProcessed[$pageId] === false) {
                     continue;
                 }
                 $strUrl = $arrProcessed[$pageId];
                 // Prepare conditions
                 $strQuery = "SELECT id,alias FROM tl_formdata f";
                 $strWhere = " WHERE form=?";
                 if (!empty($arrParams['list_where'])) {
                     $arrListWhere = array();
                     $arrListConds = preg_split('/(\\sAND\\s|\\sOR\\s)/si', $arrParams['list_where'], -1, PREG_SPLIT_DELIM_CAPTURE);
                     foreach ($arrListConds as $strListCond) {
                         if (preg_match('/\\sAND\\s|\\sOR\\s/si', $strListCond)) {
                             $arrListWhere[] = $strListCond;
                         } else {
                             $arrListCond = preg_split('/([\\s!=><]+)/', $strListCond, -1, PREG_SPLIT_DELIM_CAPTURE);
                             $strCondField = $arrListCond[0];
                             unset($arrListCond[0]);
                             if (in_array($strCondField, $GLOBALS['TL_DCA']['tl_formdata']['tl_formdata']['detailFields'])) {
                                 $arrListWhere[] = '(SELECT value FROM tl_formdata_details WHERE ff_name="' . $strCondField . '" AND pid=f.id ) ' . implode('', $arrListCond);
                             }
                             if (in_array($strCondField, $GLOBALS['TL_DCA']['tl_formdata']['tl_formdata']['baseFields'])) {
                                 $arrListWhere[] = $strCondField . implode('', $arrListCond);
                             }
                         }
                     }
                     $strListWhere = !empty($arrListWhere) ? '(' . implode('', $arrListWhere) . ')' : '';
                     $strWhere .= (strlen($strWhere) ? " AND " : " WHERE ") . $strListWhere;
                 }
                 $strQuery .= $strWhere;
                 // Add details pages to the indexer
                 $objData = \Database::getInstance()->prepare($strQuery)->execute($strForm);
                 while ($objData->next()) {
                     $arrPages[] = sprintf($strUrl, !empty($objData->alias) && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objData->alias : $objData->id);
                 }
             }
         }
     }
     return $arrPages;
 }
Пример #26
0
 /**
  * Generate a particular subpart of the tree and return it as HTML string
  *
  * @param integer $id
  * @param integer $level
  *
  * @return string
  */
 public function ajaxTreeView($id, $level)
 {
     if (!\Environment::get('isAjaxRequest')) {
         return '';
     }
     $return = '';
     $table = $this->strTable;
     $blnPtable = false;
     // Load parent table
     if ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 6) {
         $table = $this->ptable;
         \System::loadLanguageFile($table);
         $this->loadDataContainer($table);
         $blnPtable = true;
     }
     $blnProtected = false;
     // Check protected pages
     if ($table == 'tl_page') {
         $objParent = \PageModel::findWithDetails($id);
         $blnProtected = $objParent->protected ? true : false;
     }
     $margin = $level * 20;
     $hasSorting = $this->Database->fieldExists('sorting', $table);
     $arrIds = array();
     // Get records
     $objRows = $this->Database->prepare("SELECT id FROM " . $table . " WHERE pid=?" . ($hasSorting ? " ORDER BY sorting" : ""))->execute($id);
     while ($objRows->next()) {
         $arrIds[] = $objRows->id;
     }
     $blnClipboard = false;
     $arrClipboard = $this->Session->get('CLIPBOARD');
     // Check clipboard
     if (!empty($arrClipboard[$this->strTable])) {
         $blnClipboard = true;
         $arrClipboard = $arrClipboard[$this->strTable];
     }
     for ($i = 0, $c = count($arrIds); $i < $c; $i++) {
         $return .= ' ' . trim($this->generateTree($table, $arrIds[$i], array('p' => $arrIds[$i - 1], 'n' => $arrIds[$i + 1]), $hasSorting, $margin, $blnClipboard ? $arrClipboard : false, $id == $arrClipboard['id'] || is_array($arrClipboard['id']) && in_array($id, $arrClipboard['id']) || !$blnPtable && !is_array($arrClipboard['id']) && in_array($id, $this->Database->getChildRecords($arrClipboard['id'], $table)), $blnProtected));
     }
     return $return;
 }
Пример #27
0
 /**
  * Return all active layout sections as array
  *
  * @param DataContainer $dc
  *
  * @return array
  */
 public function getActiveLayoutSections(DataContainer $dc)
 {
     // Show only active sections
     if ($dc->activeRecord->pid) {
         $arrSections = array();
         $objPage = PageModel::findWithDetails($dc->activeRecord->pid);
         // Get the layout sections
         foreach (array('layout', 'mobileLayout') as $key) {
             if (!$objPage->{$key}) {
                 continue;
             }
             $objLayout = LayoutModel::findByPk($objPage->{$key});
             if ($objLayout === null) {
                 continue;
             }
             $arrModules = deserialize($objLayout->modules);
             if (empty($arrModules) || !is_array($arrModules)) {
                 continue;
             }
             // Find all sections with an article module (see #6094)
             foreach ($arrModules as $arrModule) {
                 if ($arrModule['mod'] == 0 && $arrModule['enable']) {
                     $arrSections[] = $arrModule['col'];
                 }
             }
         }
     } else {
         $arrSections = array('header', 'left', 'right', 'main', 'footer');
         $objLayout = $this->Database->query("SELECT sections FROM tl_layout WHERE sections!=''");
         while ($objLayout->next()) {
             $arrCustom = trimsplit(',', $objLayout->sections);
             // Add the custom layout sections
             if (!empty($arrCustom) && is_array($arrCustom)) {
                 $arrSections = array_merge($arrSections, $arrCustom);
             }
         }
     }
     return array_values(array_unique($arrSections));
 }
Пример #28
0
 /**
  * Add newsletters to the indexer
  *
  * @param array   $arrPages
  * @param integer $intRoot
  * @param boolean $blnIsSitemap
  *
  * @return array
  */
 public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page');
     }
     $arrProcessed = array();
     $time = \Date::floorToMinute();
     // Get all channels
     $objNewsletter = \NewsletterChannelModel::findAll();
     // Walk through each channel
     if ($objNewsletter !== null) {
         while ($objNewsletter->next()) {
             if (!$objNewsletter->jumpTo) {
                 continue;
             }
             // Skip channels outside the root nodes
             if (!empty($arrRoot) && !in_array($objNewsletter->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objNewsletter->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objNewsletter->jumpTo);
                 // The target page does not exist
                 if ($objParent === null) {
                     continue;
                 }
                 // The target page has not been published (see #5520)
                 if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop <= $time + 60) {
                     continue;
                 }
                 // The target page is exempt from the sitemap (see #6418)
                 if ($blnIsSitemap && $objParent->sitemap == 'map_never') {
                     continue;
                 }
                 // Set the domain (see #6421)
                 $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/';
                 // Generate the URL
                 $arrProcessed[$objNewsletter->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrProcessed[$objNewsletter->jumpTo];
             // Get the items
             $objItem = \NewsletterModel::findSentByPid($objNewsletter->id);
             if ($objItem !== null) {
                 while ($objItem->next()) {
                     $arrPages[] = sprintf($strUrl, $objItem->alias != '' && !\Config::get('disableAlias') ? $objItem->alias : $objItem->id);
                 }
             }
         }
     }
     return $arrPages;
 }
Пример #29
0
 /**
  * Get all allowed pages and return them as string
  *
  * @return string
  */
 public function createPageList()
 {
     $this->import('BackendUser', 'User');
     if ($this->User->isAdmin) {
         return $this->doCreatePageList();
     }
     $return = '';
     $processed = array();
     foreach ($this->eliminateNestedPages($this->User->pagemounts) as $page) {
         $objPage = \PageModel::findWithDetails($page);
         // Root page mounted
         if ($objPage->type == 'root') {
             $title = $objPage->title;
             $start = $objPage->id;
         } else {
             $title = $objPage->rootTitle;
             $start = $objPage->rootId;
         }
         // Do not process twice
         if (in_array($start, $processed)) {
             continue;
         }
         // Skip websites that run under a different domain (see #2387)
         if ($objPage->domain && $objPage->domain != \Environment::get('host')) {
             continue;
         }
         $processed[] = $start;
         $return .= '<optgroup label="' . $title . '">' . $this->doCreatePageList($start) . '</optgroup>';
     }
     return $return;
 }
Пример #30
0
 /**
  * Generate a URL and return it as string
  *
  * @param \NewsModel $objItem
  * @param boolean    $blnAddArchive
  *
  * @return string
  */
 protected function generateNewsUrl($objItem, $blnAddArchive = false)
 {
     $strCacheKey = 'id_' . $objItem->id;
     // Load the URL from cache
     if (isset(self::$arrUrlCache[$strCacheKey])) {
         return self::$arrUrlCache[$strCacheKey];
     }
     // Initialize the cache
     self::$arrUrlCache[$strCacheKey] = null;
     switch ($objItem->source) {
         // Link to an external page
         case 'external':
             if (substr($objItem->url, 0, 7) == 'mailto:') {
                 self::$arrUrlCache[$strCacheKey] = \StringUtil::encodeEmail($objItem->url);
             } else {
                 self::$arrUrlCache[$strCacheKey] = ampersand($objItem->url);
             }
             break;
             // Link to an internal page
         // Link to an internal page
         case 'internal':
             if (($objTarget = $objItem->getRelated('jumpTo')) !== null) {
                 /** @var \PageModel $objTarget */
                 self::$arrUrlCache[$strCacheKey] = ampersand($objTarget->getFrontendUrl());
             }
             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) {
                 /** @var \PageModel $objPid */
                 self::$arrUrlCache[$strCacheKey] = ampersand($objPid->getFrontendUrl('/articles/' . (!\Config::get('disableAlias') && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id)));
             }
             break;
     }
     // Link to the default page
     if (self::$arrUrlCache[$strCacheKey] === null) {
         $objPage = \PageModel::findWithDetails($objItem->getRelated('pid')->jumpTo);
         if ($objPage === null) {
             self::$arrUrlCache[$strCacheKey] = ampersand(\Environment::get('request'), true);
         } else {
             self::$arrUrlCache[$strCacheKey] = ampersand($objPage->getFrontendUrl((\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objItem->alias != '' ? $objItem->alias : $objItem->id)));
         }
         // Add the current archive parameter (news archive)
         if ($blnAddArchive && \Input::get('month') != '') {
             self::$arrUrlCache[$strCacheKey] .= (\Config::get('disableAlias') ? '&amp;' : '?') . 'month=' . \Input::get('month');
         }
     }
     return self::$arrUrlCache[$strCacheKey];
 }