public static function modifyPalette() { $arrDca =& $GLOBALS['TL_DCA']['tl_news']; if (($objNews = \NewsModel::findByPk(\Input::get('id'))) !== null && $objNews->useMemberAuthor) { $arrDca['palettes']['default'] = str_replace(',author', ',', $arrDca['palettes']['default']); } else { $arrDca['palettes']['default'] = str_replace(',memberAuthor', ',', $arrDca['palettes']['default']); } }
public static function generateAlias() { if (TL_MODE == 'FE') { if (($objNews = \NewsModel::findByPk(\Input::get('id'))) !== null && $objNews->type == 'pinboard') { $objNews->alias = \HeimrichHannot\Haste\Dca\General::generateAlias($objNews->alias, $objNews->id, 'tl_news', $objNews->headline); $objNews->save(); } } }
public static function addMediaToTemplate($objTemplate, $arrData, $objConfig) { $objItem = (object) $arrData; $objModel = \NewsModel::findByPk($objItem->id); if ($objModel === null) { return ''; } $objModel->customTpl = $objConfig->media_template ? $objConfig->media_template : static::$strTemplate; $objModel->imgSize = $objConfig->imgSize; $objModel->media_posterSRC = $objConfig->media_posterSRC; $objElement = new ContentNewsMedia($objModel); $objTemplate->mediaPlayer = $objElement->generate(); }
/** * Send the news message * @param integer * @return boolean */ public function sendNewsMessage($intId) { $objNews = \NewsModel::findByPk($intId); if ($objNews === null) { return false; } $objArchive = $objNews->getRelated('pid'); if ($objArchive === null || !$objArchive->newsletter || !$objArchive->newsletter_channel || !$objArchive->nc_notification) { return false; } $objNotification = \NotificationCenter\Model\Notification::findByPk($objArchive->nc_notification); if ($objNotification === null) { return false; } $objRecipients = \NewsletterRecipientsModel::findBy(array("pid=? AND active=1"), $objArchive->newsletter_channel); if ($objRecipients === null) { return false; } $arrTokens = array(); // Generate news archive tokens foreach ($objArchive->row() as $k => $v) { $arrTokens['news_archive_' . $k] = \Haste\Util\Format::dcaValue('tl_news_archive', $k, $v); } // Generate news tokens foreach ($objNews->row() as $k => $v) { $arrTokens['news_' . $k] = \Haste\Util\Format::dcaValue('tl_news', $k, $v); } $arrTokens['news_text'] = ''; $objElement = \ContentModel::findPublishedByPidAndTable($objNews->id, 'tl_news'); // Generate news text if ($objElement !== null) { while ($objElement->next()) { $arrTokens['news_text'] .= $this->getContentElement($objElement->id); } } // Generate news URL $objPage = \PageModel::findWithDetails($objNews->getRelated('pid')->jumpTo); $arrTokens['news_url'] = ($objPage->rootUseSSL ? 'https://' : 'http://') . ($objPage->domain ?: \Environment::get('host')) . TL_PATH . '/' . $objPage->getFrontendUrl(($GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/' : '/items/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objNews->alias != '' ? $objNews->alias : $objNews->id), $objPage->language); // Administrator e-mail $arrTokens['admin_email'] = $GLOBALS['TL_ADMIN_EMAIL']; while ($objRecipients->next()) { $arrTokens['recipient_email'] = $objRecipients->email; $objNotification->send($arrTokens); } // Set the newsletter flag $objNews->newsletter = 1; $objNews->save(); return true; }
public static function findRelatedNewsEntity($varId, array $arrRelation, \ModuleModel $objModule = null) { if (!isset($arrRelation['table'])) { return null; } $strModelClass = \Model::getClassFromTable($arrRelation['table']); if (!class_exists($strModelClass)) { return null; } if ($objModule === null) { return \NewsModel::findByPk($varId); } return \NewsModel::findPublishedByParentAndIdOrAlias($varId, deserialize($objModule->news_archives)); }
protected function getComment($id) { $tmpArr = array(); $news = \NewsModel::findByPk($id); if ($news->noComments) { $tmpArr['commentStatus'] = "closed"; } else { $result = \CommentsModel::findPublishedBySourceAndParent("tl_news", $id); $tmpArr['commentStatus'] = "open"; $tmpArr['commentsCount'] = count($result); if (count($result) > 0) { while ($result->next()) { $tmpArr['items'] = $result; } } } return $tmpArr; }
public function findRelatedByCredit($objCredit, $arrPids) { $this->result = $objCredit; $objFile = \FilesModel::findByPk($objCredit->id); if ($objFile === null) { return null; } $this->file = $objFile; switch ($objCredit->ptable) { case 'tl_article': $objArticle = \ArticleModel::findPublishedById($objCredit->parent); if ($objArticle === null) { return null; } $this->parent = $objArticle; $objJumpTo = $objArticle->getRelated('pid'); if ($objJumpTo == null) { return null; } if (!in_array($objJumpTo->id, $arrPids)) { return null; } $this->page = $objJumpTo; break; case 'tl_news': $objNews = \NewsModel::findByPk($objCredit->parent); if ($objNews === null) { return null; } $this->parent = $objNews->current(); $objNewsArchive = \NewsArchiveModel::findByPk($objNews->pid); $objJumpTo = \PageModel::findPublishedById($objNewsArchive->jumpTo); if ($objJumpTo == null) { return null; } if (!in_array($objJumpTo->id, $arrPids)) { return null; } $this->page = $objJumpTo; break; default: $this->parent = null; $this->page = null; // TODO refactor if (isset($GLOBALS['TL_FILECREDIT_MODELS'][$objCredit->ptable])) { $strClass = $GLOBALS['TL_MODELS'][$objCredit->ptable]; if (!$this->classFileExists($strClass)) { return null; } $this->loadDataContainer($objCredit->ptable); $archiveTable = $GLOBALS['TL_DCA'][$objCredit->ptable]['config']['ptable']; if (!$archiveTable || !isset($GLOBALS['TL_MODELS'][$archiveTable])) { return null; } $strArchiveClass = $GLOBALS['TL_MODELS'][$archiveTable]; if (!$this->classFileExists($strArchiveClass)) { return null; } $objItem = $strClass::findByPk($objCredit->parent); if ($objItem === null) { return null; } $this->parent = $objItem->current(); $objItemArchive = $strArchiveClass::findByPk($objItem->pid); $objJumpTo = \PageModel::findPublishedById($objItemArchive->jumpTo); if ($objJumpTo == null) { return null; } if (!in_array($objJumpTo->id, $arrPids)) { return null; } $this->page = $objJumpTo; } } return $this; }