public function checkLog($ptable, $tstamp, $item) { switch ($ptable) { case 'tl_article': $objArticle = \ArticleModel::findById($item['pid']); $objPage = \PageModel::findById($objArticle->pid); $item['page'] = $objPage->title; $item['showUrl'] = $this->generateFrontendUrl($objPage->row(), ''); break; case 'tl_news': $objNews = \NewsModel::findById($item['pid']); $objArchive = \NewsArchiveModel::findById($objNews->pid); $objPage = \PageModel::findById($objArchive->jumpTo); $item['page'] = $objNews->headline; $item['showUrl'] = ampersand($this->generateFrontendUrl($objPage->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objNews->alias != '' ? $objNews->alias : $objNews->id))); break; case 'tl_calendar': break; case 'tl_faq': $objFAQ = \FaqModel::findById($item['id']); $objCategory = \FaqCategoryModel::findById($item['pid']); $objPage = \PageModel::findById($objCategory->jumpTo); $item['htmlElement'] = '<div class="ce_faq"><h1>' . $objFAQ->question . '</h1>' . $objFAQ->answer . '</div>'; $item['page'] = $objCategory->title; $item['title'] = $objFAQ->question; $item['showUrl'] = ampersand($this->generateFrontendUrl($objPage->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objFAQ->alias != '' ? $objFAQ->alias : $objFAQ->id))); break; } return $item; }
/** * Check the news alias for duplicates * * @param mixed $varValue * @param DataContainer $dc * * @return string * * @throws Exception */ public function checkAlias($varValue, DataContainer $dc) { // get the news archive first if (($objArchive = \NewsArchiveModel::findById($dc->activeRecord->pid)) !== null) { // get the redirect page if (($objTarget = \PageModel::findById($objArchive->jumpTo)) !== null) { // check if there is a page with the same alias if (($objPage = \PageModel::findByAlias($varValue)) !== null) { // load the details $objTarget->current()->loadDetails(); $objPage->current()->loadDetails(); // 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; }
/** * parseArticles hook for news * * @param \Template $objTemplate * @param array $arrData * @param \Module $objModule */ public function parseArticles(\Template $objTemplate, $arrData, \Module $objModule) { // check for news module if (strpos(get_class($objModule), 'ModuleNews') === false) { return; } // get the news archive $objArchive = \NewsArchiveModel::findById($arrData['pid']); // get the networks for the archive $networksArchive = deserialize($objArchive->sharebuttons_networks); // get the networks for the article $networksArticle = deserialize($arrData['sharebuttons_networks']); // create merged networks $networksMerged = array(); if (is_array($networksArchive) && is_array($networksArticle)) { $networksMerged = array_unique(array_merge($networksArchive, $networksArticle)); } else { $networksMerged = is_array($networksArchive) ? $networksArchive : (is_array($networksArticle) ? $networksArticle : array()); } // prepare sharebuttons string $strSharebuttons = ''; // check if there are any networks if (count($networksMerged) > 0) { // set data $networks = $networksMerged; $theme = $arrData['sharebuttons_theme'] ?: $objArchive->sharebuttons_theme; $template = $arrData['sharebuttons_template'] && $arrData['sharebuttons_template'] != 'sharebuttons_default' ? $arrData['sharebuttons_template'] : $objArchive->sharebuttons_template; $url = ($arrData['source'] != 'external' ? \Environment::get('base') : '') . $objTemplate->link; $title = $arrData['headline']; $description = $arrData['teaser']; $image = $objTemplate->addImage && $objTemplate->singleSRC ? \Environment::get('base') . $objTemplate->singleSRC : null; // create the share buttons $strSharebuttons = self::createShareButtons($networks, $theme, $template, $url, $title, $description, $image); } // set sharebuttons string $objTemplate->sharebuttons = $strSharebuttons; }