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


PHP ArticleModel::findPublishedByPidAndColumn方法代码示例

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


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

示例1: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     if (!strlen($this->inColumn)) {
         $this->inColumn = 'main';
     }
     $intCount = 0;
     $articles = array();
     $id = $objPage->id;
     $this->Template->request = \Environment::get('request');
     // Show the articles of a different page
     if ($this->defineRoot && $this->rootPage > 0) {
         if (($objTarget = $this->objModel->getRelated('rootPage')) !== null) {
             $id = $objTarget->id;
             /** @var \PageModel $objTarget */
             $this->Template->request = $objTarget->getFrontendUrl();
         }
     }
     // Get published articles
     $objArticles = \ArticleModel::findPublishedByPidAndColumn($id, $this->inColumn);
     if ($objArticles === null) {
         return;
     }
     while ($objArticles->next()) {
         // Skip first article
         if (++$intCount <= intval($this->skipFirst)) {
             continue;
         }
         $cssID = deserialize($objArticles->cssID, true);
         $alias = $objArticles->alias ?: $objArticles->title;
         $articles[] = array('link' => $objArticles->title, 'title' => specialchars($objArticles->title), 'id' => $cssID[0] ?: standardize($alias), 'articleId' => $objArticles->id);
     }
     $this->Template->articles = $articles;
 }
开发者ID:bytehead,项目名称:contao-core,代码行数:38,代码来源:ModuleArticleList.php

示例2: parseArticle

 /**
  * Parse an item and return it as string
  * @param object
  * @param boolean
  * @param string
  * @param integer
  * @return string
  */
 protected function parseArticle($objArticle, $blnAddArchive = false, $strClass = '', $intCount = 0)
 {
     global $objPage;
     $arrCategories = deserialize($objArticle->categories, true);
     $objTemplate = new \FrontendTemplate($this->news_template);
     $objTemplate->setData($objArticle->row());
     $objTemplate->class = ($objArticle->cssClass != '' ? ' ' . $objArticle->cssClass : '') . $strClass;
     $objTemplate->newsHeadline = $objArticle->headline;
     $objTemplate->subHeadline = $objArticle->subheadline;
     $objTemplate->hasSubHeadline = $objArticle->subheadline ? true : false;
     $objTemplate->linkHeadline = $this->generateLink($objArticle->headline, $objArticle, $blnAddArchive);
     $objTemplate->more = $this->generateLink($GLOBALS['TL_LANG']['MSC']['more'], $objArticle, $blnAddArchive, true);
     $objTemplate->link = $this->generateNewsUrl($objArticle, $blnAddArchive);
     $objTemplate->linkTarget = $objArticle->target ? $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"' : '';
     $objTemplate->linkTitle = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->headline), true);
     $objTemplate->count = $intCount;
     // see #5708
     $objTemplate->text = '';
     $objTemplate->hasText = false;
     $objTemplate->hasTeaser = false;
     // print pdf
     if ($this->news_pdfJumpTo) {
         $objTemplate->showPdfButton = true;
         $pdfPage = \PageModel::findByPk($this->news_pdfJumpTo);
         $pdfArticle = \ArticleModel::findPublishedByPidAndColumn($this->news_pdfJumpTo, 'main');
         $options = deserialize($pdfArticle->printable);
         if (in_array('pdf', $options)) {
             $objTemplate->pdfArticleId = $pdfArticle->id;
         }
         $strUrl = \Controller::generateFrontendUrl($pdfPage->row());
         $objTemplate->pdfJumpTo = $strUrl;
     }
     $objArchive = \NewsArchiveModel::findByPk($objArticle->pid);
     $objTemplate->archive = $objArchive;
     $objTemplate->archive->title = $objTemplate->archive->displayTitle ? $objTemplate->archive->displayTitle : $objTemplate->archive->title;
     $objTemplate->archive->class = ModuleNewsListPlus::getArchiveClassFromTitle($objTemplate->archive->title, true);
     $objTemplate->archiveTitle = $objTemplate->archive->title;
     $arrCategoryTitles = array();
     if ($this->news_archiveTitleAppendCategories && !empty($arrCategories)) {
         $arrTitleCategories = array_intersect($arrCategories, deserialize($this->news_archiveTitleCategories, true));
         if (!empty($arrTitleCategories)) {
             $objTitleCategories = NewsCategoryModel::findPublishedByIds($arrTitleCategories);
             if ($objTitleCategories !== null) {
                 while ($objTitleCategories->next()) {
                     if ($objTitleCategories->frontendTitle) {
                         $arrCategoryTitles[$objTitleCategories->id] = $objTitleCategories->frontendTitle;
                         continue;
                     }
                     $arrCategoryTitles[$objTitleCategories->id] = $objTitleCategories->title;
                 }
                 $objTemplate->archiveTitle .= ' : ' . implode(' : ', $arrCategoryTitles);
             }
         }
     }
     // add tags
     $objTemplate->showTags = $this->news_showtags;
     if ($this->news_showtags && $this->news_template_modal && $this->Environment->isAjaxRequest) {
         $helper = new NewsPlusTagHelper();
         $tagsandlist = $helper->getTagsAndTaglistForIdAndTable($objArticle->id, 'tl_news', $this->tag_jumpTo);
         $tags = $tagsandlist['tags'];
         $taglist = $tagsandlist['taglist'];
         $objTemplate->showTagClass = $this->tag_named_class;
         $objTemplate->tags = $tags;
         $objTemplate->taglist = $taglist;
         $objTemplate->news = 'IN';
     }
     // nav
     $strUrl = '';
     $objArchive = \NewsArchiveModel::findByPk($objArticle->pid);
     if ($objArchive !== null && $objArchive->jumpTo && ($objTarget = $objArchive->getRelated('jumpTo')) !== null) {
         $strUrl = $this->generateFrontendUrl($objTarget->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/news/%s');
     }
     $objTemplate->nav = static::generateArrowNavigation($objArticle, $strUrl, $this->news_readerModule);
     // Clean the RTE output
     if ($objArticle->teaser != '') {
         $objTemplate->hasTeaser = true;
         if ($objPage->outputFormat == 'xhtml') {
             $objTemplate->teaser = \String::toXhtml($objArticle->teaser);
         } else {
             $objTemplate->teaser = \String::toHtml5($objArticle->teaser);
         }
         $objTemplate->teaser = \String::encodeEmail($objTemplate->teaser);
     }
     // Display the "read more" button for external/article links
     if ($objArticle->source != 'default') {
         $objTemplate->text = true;
         $objTemplate->hasText = true;
     } else {
         $id = $objArticle->id;
         $objTemplate->text = function () use($id) {
             $strText = '';
             $objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_news');
//.........这里部分代码省略.........
开发者ID:heimrichhannot,项目名称:contao-news_plus,代码行数:101,代码来源:ModuleNewsPlus.php

示例3: getFrontendModule

 /**
  * Generate a front end module and return it as string
  * 
  * @param mixed  $intId     A module ID or a Model object
  * @param string $strColumn The name of the column
  * 
  * @return string The module HTML markup
  */
 protected function getFrontendModule($intId, $strColumn = 'main')
 {
     if (!is_object($intId) && !strlen($intId)) {
         return '';
     }
     global $objPage;
     // Articles
     if ($intId == 0) {
         // Show a particular article only
         if (\Input::get('articles') && $objPage->type == 'regular') {
             list($strSection, $strArticle) = explode(':', \Input::get('articles'));
             if ($strArticle === null) {
                 $strArticle = $strSection;
                 $strSection = 'main';
             }
             if ($strSection == $strColumn) {
                 $strBuffer = $this->getArticle($strArticle);
                 // Send a 404 header if the article does not exist
                 if ($strBuffer === false) {
                     // Do not index the page
                     $objPage->noSearch = 1;
                     $objPage->cache = 0;
                     header('HTTP/1.1 404 Not Found');
                     return '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], $strArticle) . '</p>';
                 }
                 return $strBuffer;
             }
         } elseif (in_array('article_raster_designer', $this->Config->getActiveModules())) {
             return \RasterDesigner::load($objPage->id, $strColumn);
         } else {
             $objArticles = \ArticleModel::findPublishedByPidAndColumn($objPage->id, $strColumn);
             if ($objArticles === null) {
                 return '';
             }
             $return = '';
             $blnMultiMode = $objArticles->count() > 1;
             while ($objArticles->next()) {
                 $return .= $this->getArticle($objArticles, $blnMultiMode, false, $strColumn);
             }
             return $return;
         }
     } else {
         if (is_object($intId)) {
             $objRow = $intId;
         } else {
             $objRow = \ModuleModel::findByPk($intId);
         }
         if ($objRow === null) {
             return '';
         }
         // Show to guests only
         if ($objRow->guests && FE_USER_LOGGED_IN && !BE_USER_LOGGED_IN && !$objRow->protected) {
             return '';
         }
         // Protected element
         if (!BE_USER_LOGGED_IN && $objRow->protected) {
             if (!FE_USER_LOGGED_IN) {
                 return '';
             }
             $this->import('FrontendUser', 'User');
             $groups = deserialize($objRow->groups);
             if (!is_array($groups) || empty($groups) || !count(array_intersect($groups, $this->User->groups))) {
                 return '';
             }
         }
         $strClass = $this->findFrontendModule($objRow->type);
         // Return if the class does not exist
         if (!$this->classFileExists($strClass)) {
             $this->log('Module class "' . $GLOBALS['FE_MOD'][$objRow->type] . '" (module "' . $objRow->type . '") does not exist', 'Controller getFrontendModule()', TL_ERROR);
             return '';
         }
         $objRow->typePrefix = 'mod_';
         $objModule = new $strClass($objRow, $strColumn);
         $strBuffer = $objModule->generate();
         // HOOK: add custom logic
         if (isset($GLOBALS['TL_HOOKS']['getFrontendModule']) && is_array($GLOBALS['TL_HOOKS']['getFrontendModule'])) {
             foreach ($GLOBALS['TL_HOOKS']['getFrontendModule'] as $callback) {
                 $this->import($callback[0]);
                 $strBuffer = $this->{$callback}[0]->{$callback}[1]($objRow, $strBuffer);
             }
         }
         // Disable indexing if protected
         if ($objModule->protected && !preg_match('/^\\s*<!-- indexer::stop/i', $strBuffer)) {
             $strBuffer = "\n<!-- indexer::stop -->" . $strBuffer . "<!-- indexer::continue -->\n";
         }
         return $strBuffer;
     }
     return '';
 }
开发者ID:rikaix,项目名称:core,代码行数:97,代码来源:Controller.php

示例4: getFrontendModule

 /**
  * Generate a front end module and return it as string
  *
  * @param mixed  $intId     A module ID or a Model object
  * @param string $strColumn The name of the column
  *
  * @return string The module HTML markup
  */
 public static function getFrontendModule($intId, $strColumn = 'main')
 {
     if (!is_object($intId) && !strlen($intId)) {
         return '';
     }
     /** @var \PageModel $objPage */
     global $objPage;
     // Articles
     if (!is_object($intId) && $intId == 0) {
         // Show a particular article only
         if ($objPage->type == 'regular' && \Input::get('articles')) {
             list($strSection, $strArticle) = explode(':', \Input::get('articles'));
             if ($strArticle === null) {
                 $strArticle = $strSection;
                 $strSection = 'main';
             }
             if ($strSection == $strColumn) {
                 $objArticle = \ArticleModel::findByIdOrAliasAndPid($strArticle, $objPage->id);
                 // Send a 404 header if the article does not exist
                 if (null === $objArticle) {
                     /** @var \PageError404 $objHandler */
                     $objHandler = new $GLOBALS['TL_PTY']['error_404']();
                     $objHandler->generate($objPage->id);
                 }
                 // Add the "first" and "last" classes (see #2583)
                 $objArticle->classes = array('first', 'last');
                 return static::getArticle($objArticle);
             }
         }
         // HOOK: trigger the article_raster_designer extension
         if (in_array('article_raster_designer', \ModuleLoader::getActive())) {
             return \RasterDesigner::load($objPage->id, $strColumn);
         }
         // Show all articles (no else block here, see #4740)
         $objArticles = \ArticleModel::findPublishedByPidAndColumn($objPage->id, $strColumn);
         if ($objArticles === null) {
             return '';
         }
         $return = '';
         $intCount = 0;
         $blnMultiMode = $objArticles->count() > 1;
         $intLast = $objArticles->count() - 1;
         while ($objArticles->next()) {
             /** @var \ArticleModel $objRow */
             $objRow = $objArticles->current();
             // Add the "first" and "last" classes (see #2583)
             if ($intCount == 0 || $intCount == $intLast) {
                 $arrCss = array();
                 if ($intCount == 0) {
                     $arrCss[] = 'first';
                 }
                 if ($intCount == $intLast) {
                     $arrCss[] = 'last';
                 }
                 $objRow->classes = $arrCss;
             }
             $return .= static::getArticle($objRow, $blnMultiMode, false, $strColumn);
             ++$intCount;
         }
         return $return;
     } else {
         if (is_object($intId)) {
             $objRow = $intId;
         } else {
             $objRow = \ModuleModel::findByPk($intId);
             if ($objRow === null) {
                 return '';
             }
         }
         // Check the visibility (see #6311)
         if (!static::isVisibleElement($objRow)) {
             return '';
         }
         $strClass = \Module::findClass($objRow->type);
         // Return if the class does not exist
         if (!class_exists($strClass)) {
             static::log('Module class "' . $strClass . '" (module "' . $objRow->type . '") does not exist', __METHOD__, TL_ERROR);
             return '';
         }
         $objRow->typePrefix = 'mod_';
         /** @var \Module $objModule */
         $objModule = new $strClass($objRow, $strColumn);
         $strBuffer = $objModule->generate();
         // HOOK: add custom logic
         if (isset($GLOBALS['TL_HOOKS']['getFrontendModule']) && is_array($GLOBALS['TL_HOOKS']['getFrontendModule'])) {
             foreach ($GLOBALS['TL_HOOKS']['getFrontendModule'] as $callback) {
                 $strBuffer = static::importStatic($callback[0])->{$callback[1]}($objRow, $strBuffer, $objModule);
             }
         }
         // Disable indexing if protected
         if ($objModule->protected && !preg_match('/^\\s*<!-- indexer::stop/', $strBuffer)) {
             $strBuffer = "\n<!-- indexer::stop -->" . $strBuffer . "<!-- indexer::continue -->\n";
//.........这里部分代码省略.........
开发者ID:StephenGWills,项目名称:sample-contao-app,代码行数:101,代码来源:Controller.php

示例5: getPageFrontendModule

 /**
  * Generate a front end module and return it as HTML string.
  *
  * @param int
  * @param string
  *
  * @return string
  */
 protected function getPageFrontendModule($page, $moduleId, $columnName = 'main', $inheritableOnly = false)
 {
     if (!is_object($moduleId) && !strlen($moduleId)) {
         return '';
     }
     // Articles
     if ($moduleId == 0) {
         // Show a particular article only
         if ($page->type == 'regular' && \Input::get('articles')) {
             list($sectionName, $articleName) = explode(':', \Input::get('articles'));
             if ($articleName === null) {
                 $articleName = $sectionName;
                 $sectionName = 'main';
             }
             if ($sectionName == $columnName) {
                 $article = \ArticleModel::findByIdOrAliasAndPid($articleName, $page->id);
                 // Send a 404 header if the article does not exist
                 if ($article === null) {
                     // Do not index the page
                     $page->noSearch = 1;
                     $page->cache = 0;
                     header('HTTP/1.1 404 Not Found');
                     return '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], $articleName) . '</p>';
                 }
                 if (!$inheritableOnly || $article->inheritable) {
                     // Add the "first" and "last" classes (see #2583)
                     $article->classes = array('first', 'last');
                     return $this->getArticle($article);
                 }
                 return '';
             }
         }
         // HOOK: trigger the article_raster_designer extension
         if (in_array('article_raster_designer', \ModuleLoader::getActive())) {
             return \RasterDesigner::load($page->id, $columnName);
         }
         // Show all articles (no else block here, see #4740)
         $articleCollection = \ArticleModel::findPublishedByPidAndColumn($page->id, $columnName);
         if ($articleCollection === null) {
             return '';
         }
         $return = '';
         $intCount = 0;
         $blnMultiMode = $articleCollection->count() > 1;
         $intLast = $articleCollection->count() - 1;
         while ($articleCollection->next()) {
             if ($inheritableOnly && !$articleCollection->inheritable) {
                 continue;
             }
             $articleRow = $articleCollection->current();
             // Add the "first" and "last" classes (see #2583)
             if ($intCount == 0 || $intCount == $intLast) {
                 $cssClasses = array();
                 if ($intCount == 0) {
                     $cssClasses[] = 'first';
                 }
                 if ($intCount == $intLast) {
                     $cssClasses[] = 'last';
                 }
                 $articleRow->classes = $cssClasses;
             }
             $return .= $this->getArticle($articleRow, $blnMultiMode, false, $columnName);
             ++$intCount;
         }
         return $return;
     } else {
         if (is_object($moduleId)) {
             $articleRow = $moduleId;
         } else {
             $articleRow = \ModuleModel::findByPk($moduleId);
             if ($articleRow === null) {
                 return '';
             }
         }
         // Check the visibility (see #6311)
         if (!static::isVisibleElement($articleRow)) {
             return '';
         }
         $moduleClassName = \Module::findClass($articleRow->type);
         // Return if the class does not exist
         if (!class_exists($moduleClassName)) {
             $this->log('Module class "' . $moduleClassName . '" (module "' . $articleRow->type . '") does not exist', __METHOD__, TL_ERROR);
             return '';
         }
         $articleRow->typePrefix = 'mod_';
         /** @var \Module $module */
         $module = new $moduleClassName($articleRow, $columnName);
         $buffer = $module->generate();
         // HOOK: add custom logic
         if (isset($GLOBALS['TL_HOOKS']['getFrontendModule']) && is_array($GLOBALS['TL_HOOKS']['getFrontendModule'])) {
             foreach ($GLOBALS['TL_HOOKS']['getFrontendModule'] as $callback) {
                 $this->import($callback[0]);
//.........这里部分代码省略.........
开发者ID:bit3,项目名称:contao-merger2,代码行数:101,代码来源:ModuleMerger2.php

示例6: parseCustomizeFrontendTemplate


//.........这里部分代码省略.........
                 if ($objAllArticles) {
                     $isActive = false;
                     $setNext = false;
                     while ($objAllArticles->next()) {
                         $objCurrentArticle = $objAllArticles->current();
                         if ($objCurrentArticle->id == $objArticle->id) {
                             $isActive = true;
                         } else {
                             if (!$isActive) {
                                 $prevArticle = $objCurrentArticle;
                             } else {
                                 if (!$setNext) {
                                     $nextArticle = $objCurrentArticle;
                                     $setNext = true;
                                     break;
                                 }
                             }
                         }
                     }
                 }
                 //					if( $objArticle->navNext && $nextArticle )
                 if ($objArticle->navNext) {
                     //						$nextAlias = $nextArticle->alias;
                     $nextAlias = $objArticle->alias;
                     $articleNavigationTag .= '<div class="nav-item nav-next"><a href="javascript:void(0);" data-anker="' . $nextAlias . '" onclick="DPS.Content.scrollTo(this)"></a></div>';
                 }
                 if ($objArticle->navPrev && $prevArticle) {
                     $prevAlias = $prevArticle->alias;
                     $articleNavigationTag .= '<div class="nav-item nav-prev"><a href="javascript:void(0);" data-anker="' . $prevAlias . '" onclick="DPS.Content.scrollTo(this)"></a></div>';
                 }
                 $articleNavigationTag .= '</div>';
                 $strContent = preg_replace('/<\\/div>$/', $articleNavigationTag . '</div>', $strContent);
             }
             $objArticles = \ArticleModel::findPublishedByPidAndColumn($objPage->id, "main");
             if ($objArticles) {
                 $index = 0;
                 while ($objArticles->next()) {
                     if ($objArticle->id == $objArticles->id) {
                         break;
                     }
                     $index++;
                 }
                 if ($index == 1) {
                     $articleClass[] = 'secondArticle';
                 }
                 $articleClass[] = 'article-' . ($index + 1);
                 if ($objArticles->count() > 1) {
                     $strContent = preg_replace($articlePattern, '<div$1class="mod_article$2"$3 data-index="' . $index . '">', $strContent);
                 }
             }
         }
         if (is_array($articleClass) && count($articleClass) > 0) {
             $strContent = preg_replace('/class="mod_article/', 'class="mod_article ' . implode(" ", $articleClass), $strContent);
         }
         $addAroundDivStart = "";
         $addAroundDivEnd = "";
         $articleClasses = deserialize($objArticle->cssID, true);
         if (preg_match('/add-bg/', $articleClasses[1])) {
             $addAroundDivStart = '<div class="background-outer bg-image bg-cover bg-scroll" data-0="background-position:0px 0px;"><div class="background-inner bg-image bg-cover bg-scroll" data-0="background-position:0px 0px;">';
             $addAroundDivEnd = '</div></div>';
         }
         $strContent = preg_replace('/<div([A-Za-z0-9\\s\\-_="\'.,;:\\(\\)\\/#]{0,})class="mod_article([A-Za-z0-9\\s\\-_\\{\\}\\(\\)\']{0,})"([A-Za-z0-9\\s\\-_="\'.,;:\\(\\)\\/#%]{0,})>/', '<div$1class="mod_article$2"$3>' . $addAroundDivStart . '<div class="article-inside">', $strContent);
         $strContent = preg_replace('/<\\/div>$/', '</div></div>' . $addAroundDivEnd, $strContent);
     } elseif ($strTemplate == "ce_image") {
         preg_match_all('/class="ce_image([a-zA-Z0-9\\s\\-_]{0,})"/', $strContent, $classMatches);
         if (is_array($classMatches) && count($classMatches[0]) > 0) {
开发者ID:pressi,项目名称:zdps_customize,代码行数:67,代码来源:Template.php


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