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


PHP ArticleModel::findByIdOrAliasAndPid方法代码示例

本文整理汇总了PHP中ArticleModel::findByIdOrAliasAndPid方法的典型用法代码示例。如果您正苦于以下问题:PHP ArticleModel::findByIdOrAliasAndPid方法的具体用法?PHP ArticleModel::findByIdOrAliasAndPid怎么用?PHP ArticleModel::findByIdOrAliasAndPid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArticleModel的用法示例。


在下文中一共展示了ArticleModel::findByIdOrAliasAndPid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getArticle

 /**
  * Generate an article and return it as string
  * 
  * @param mixed   $varId          The article ID or a Model object
  * @param boolean $blnMultiMode   If true, only teasers will be shown
  * @param boolean $blnIsInsertTag If true, there will be no page relation
  * @param string  $strColumn      The name of the column
  * 
  * @return string|boolean The article HTML markup or false 
  */
 protected function getArticle($varId, $blnMultiMode = false, $blnIsInsertTag = false, $strColumn = 'main')
 {
     global $objPage;
     if (is_object($varId)) {
         $objRow = $varId;
     } else {
         if (!$varId) {
             return '';
         }
         $objRow = \ArticleModel::findByIdOrAliasAndPid($varId, !$blnIsInsertTag ? $objPage->id : null);
     }
     // Return if the article does not exist
     if ($objRow === null) {
         return false;
     }
     // Print the article as PDF
     if (\Input::get('pdf') == $objRow->id) {
         // Backwards compatibility
         if ($objRow->printable == 1) {
             $this->printArticleAsPdf($objRow);
         } elseif ($objRow->printable != '') {
             $options = deserialize($objRow->printable);
             if (is_array($options) && in_array('pdf', $options)) {
                 $this->printArticleAsPdf($objRow);
             }
         }
     }
     $objRow->headline = $objRow->title;
     $objRow->multiMode = $blnMultiMode;
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['getArticle']) && is_array($GLOBALS['TL_HOOKS']['getArticle'])) {
         foreach ($GLOBALS['TL_HOOKS']['getArticle'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($objRow);
         }
     }
     $objArticle = new \ModuleArticle($objRow, $strColumn);
     return $objArticle->generate($blnIsInsertTag);
 }
开发者ID:rikaix,项目名称:core,代码行数:49,代码来源:Controller.php

示例2: getContentFromArticle

 protected function getContentFromArticle($id, $type = "")
 {
     $tmpContent = "";
     $thumb = "";
     $sharelink = "";
     $retArr = array();
     $time = time();
     $base = \Environment::get('base');
     $table = "";
     if ($type == 'news') {
         $table = "tl_news";
     } else {
         if ($table == 'event') {
             $table = "tl_calendar_events";
         } else {
             $table = "tl_article";
         }
     }
     $openComment = $type == 'news' ? "open" : "closed";
     $commentCount = 0;
     $result = "";
     $query = "SELECT * FROM `{$table}` WHERE `id` = '" . $id . "' ";
     $articleRes = \Database::getInstance()->query($query)->fetchAssoc();
     if ($type == "news") {
         switch ($articleRes['source']) {
             case 'external':
                 $sharelink = $articleRes['url'];
                 break;
             case 'article':
                 $sharelink = $base . \Controller::replaceInsertTags("{{article_url::" . $articleRes['articleId'] . "}}");
                 break;
             case 'internal':
                 $sharelink = $base . \Controller::replaceInsertTags("{{link_url::" . $articleRes['jumpTo'] . "}}");
                 break;
             default:
                 $sharelink = $base . \Controller::replaceInsertTags("{{news_url::" . $articleRes['id'] . "}}");
                 break;
         }
         $newsModel = \NewsModel::findPublishedByParentAndIdOrAlias($id, array(0 => $articleRes['pid']));
         $result = $this->parseNews($newsModel);
     } else {
         if ($type == "event") {
             $objEvent = \CalendarEventsModel::findPublishedByParentAndIdOrAlias($id, array($this->settings['calendar']));
             $objTemplate = new \FrontendTemplate("event_full");
             $objTemplate->setData($objEvent->row());
             $objTemplate->date = $date;
             $objTemplate->start = $intStartTime;
             $objTemplate->end = $intEndTime;
             $objTemplate->class = $objEvent->cssClass != '' ? ' ' . $objEvent->cssClass : '';
             $objTemplate->recurring = $recurring;
             $objTemplate->until = $until;
             $objTemplate->locationLabel = $GLOBALS['TL_LANG']['MSC']['location'];
             $objTemplate->details = '';
             $objElement = \ContentModel::findPublishedByPidAndTable($objEvent->id, 'tl_calendar_events');
             if ($objElement !== null) {
                 while ($objElement->next()) {
                     $objTemplate->details .= $this->getContentElement($objElement->id);
                 }
             }
             $objTemplate->addImage = false;
             if ($objEvent->addImage && $objEvent->singleSRC != '') {
                 $objModel = \FilesModel::findByUuid($objEvent->singleSRC);
                 if (is_file(TL_ROOT . '/' . $objModel->path)) {
                     $arrEvent = $objEvent->row();
                     $arrEvent['singleSRC'] = $objModel->path;
                     $this->addImageToTemplate($objTemplate, $arrEvent);
                 }
             }
             $objTemplate->enclosure = array();
             if ($objEvent->addEnclosure) {
                 $this->addEnclosuresToTemplate($objTemplate, $objEvent->row());
             }
             $result = $objTemplate->parse();
         } else {
             $result = \ArticleModel::findByIdOrAliasAndPid($id, $articleRes['pid']);
         }
     }
     $sharelink = $sharelink == "" ? $base . \Controller::replaceInsertTags("{{link_url::" . $articleRes['pid'] . "}}") : $sharelink;
     if ($result != "") {
         if ($type != "news" && $type != "event") {
             $pageTitleRes = \Controller::getPageDetails($articleRes['pid']);
             $objArticle = new \ModuleArticle($result);
             $tmpContent = $objArticle->generate(true);
         } else {
             $tmpContent = $result;
         }
         $tmpContent = \Controller::replaceInsertTags($tmpContent);
         $tmpContent = str_replace('src="files/', 'src="' . $base . 'files/', $tmpContent);
         $tmpContent = str_replace('src="assets/', 'src="' . $base . 'assets/', $tmpContent);
         $tmpContent = str_replace('href="index.php/', 'href="' . $base . 'index.php/', $tmpContent);
         if ($pageTitleRes->thumb) {
             $thumb = $this->getFilePath($pageTitleRes->thumb);
         }
         if ($openComment == "open") {
             $commentCount = \CommentsModel::countPublishedBySourceAndParent("tl_news", $id);
         }
         $retArr['tstamp'] = time();
         $retArr['img']['src'] = "";
         $retArr['img']['thumb'] = $thumb;
         $retArr['pid'] = $id;
//.........这里部分代码省略.........
开发者ID:contao2app,项目名称:contao2app,代码行数:101,代码来源:c2aFrontend.php

示例3: getArticle

 /**
  * Generate an article and return it as string
  *
  * @param mixed   $varId          The article ID or a Model object
  * @param boolean $blnMultiMode   If true, only teasers will be shown
  * @param boolean $blnIsInsertTag If true, there will be no page relation
  * @param string  $strColumn      The name of the column
  *
  * @return string|boolean The article HTML markup or false
  */
 public static function getArticle($varId, $blnMultiMode = false, $blnIsInsertTag = false, $strColumn = 'main')
 {
     /** @var \PageModel $objPage */
     global $objPage;
     if (is_object($varId)) {
         $objRow = $varId;
     } else {
         if (!$varId) {
             return '';
         }
         $objRow = \ArticleModel::findByIdOrAliasAndPid($varId, !$blnIsInsertTag ? $objPage->id : null);
         if ($objRow === null) {
             return false;
         }
     }
     // Check the visibility (see #6311)
     if (!static::isVisibleElement($objRow)) {
         return '';
     }
     // Print the article as PDF
     if (isset($_GET['pdf']) && \Input::get('pdf') == $objRow->id) {
         // Backwards compatibility
         if ($objRow->printable == 1) {
             $objArticle = new \ModuleArticle($objRow);
             $objArticle->generatePdf();
         } elseif ($objRow->printable != '') {
             $options = deserialize($objRow->printable);
             if (is_array($options) && in_array('pdf', $options)) {
                 $objArticle = new \ModuleArticle($objRow);
                 $objArticle->generatePdf();
             }
         }
     }
     $objRow->headline = $objRow->title;
     $objRow->multiMode = $blnMultiMode;
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['getArticle']) && is_array($GLOBALS['TL_HOOKS']['getArticle'])) {
         foreach ($GLOBALS['TL_HOOKS']['getArticle'] as $callback) {
             static::importStatic($callback[0])->{$callback[1]}($objRow);
         }
     }
     $objArticle = new \ModuleArticle($objRow, $strColumn);
     $strBuffer = $objArticle->generate($blnIsInsertTag);
     // Disable indexing if protected
     if ($objArticle->protected && !preg_match('/^\\s*<!-- indexer::stop/', $strBuffer)) {
         $strBuffer = "\n<!-- indexer::stop -->" . $strBuffer . "<!-- indexer::continue -->\n";
     }
     return $strBuffer;
 }
开发者ID:StephenGWills,项目名称:sample-contao-app,代码行数:59,代码来源:Controller.php

示例4: getPageArticle

 /**
  * Generate an article and return it as string.
  *
  * @param int
  * @param bool
  * @param bool
  * @param string
  *
  * @return string
  */
 protected function getPageArticle($page, $articleId)
 {
     $article = \ArticleModel::findByIdOrAliasAndPid($articleId, $page->id);
     if ($article === null) {
         return '';
     }
     return $this->getArticle($article);
 }
开发者ID:bit3,项目名称:contao-merger2,代码行数:18,代码来源:ModuleMerger2.php


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