当前位置: 首页>>代码示例>>PHP>>正文


PHP NewsModel::findByPk方法代码示例

本文整理汇总了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']);
     }
 }
开发者ID:heimrichhannot,项目名称:contao-frontendedit,代码行数:9,代码来源:tl_news.php

示例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();
         }
     }
 }
开发者ID:heimrichhannot,项目名称:contao-pinboard,代码行数:9,代码来源:tl_news.php

示例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();
 }
开发者ID:heimrichhannot,项目名称:contao-news_media,代码行数:13,代码来源:NewsMedia.php

示例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;
 }
开发者ID:terminal42,项目名称:contao-news_newsletter,代码行数:54,代码来源:tl_news.php

示例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));
 }
开发者ID:heimrichhannot,项目名称:contao-submissions_creator,代码行数:14,代码来源:SubmissionCreator.php

示例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;
 }
开发者ID:contao2app,项目名称:contao2app,代码行数:18,代码来源:c2aFrontend.php

示例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;
 }
开发者ID:pandroid,项目名称:contao-filecredits,代码行数:76,代码来源:FileCreditHybridModel.php


注:本文中的NewsModel::findByPk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。