本文整理汇总了PHP中NewsModel::findByPk方法的典型用法代码示例。如果您正苦于以下问题:PHP NewsModel::findByPk方法的具体用法?PHP NewsModel::findByPk怎么用?PHP NewsModel::findByPk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NewsModel
的用法示例。
在下文中一共展示了NewsModel::findByPk方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modifyPalette
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']);
}
}
示例2: generateAlias
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();
}
}
}
示例3: addMediaToTemplate
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();
}
示例4: sendNewsMessage
/**
* 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;
}
示例5: findRelatedNewsEntity
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));
}
示例6: getComment
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;
}
示例7: findRelatedByCredit
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;
}