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


PHP ArticleModel::findBy方法代码示例

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


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

示例1: compile

 protected function compile()
 {
     // create local event dispatcher and provider
     $eventDispatcher = new EventDispatcher();
     $eventDispatcher->addSubscriber(new ArticleProvider());
     $eventDispatcher->addSubscriber(new ContentProvider());
     // create the event driven menu
     $eventDrivenItemFactory = new EventDrivenItemFactory($eventDispatcher, XNavigationEvents::CREATE_ITEM, XNavigationEvents::COLLECT_ITEMS);
     $item = new Item();
     $items = $item->getChildren();
     if ($this->toc_source == 'sections') {
         global $objPage;
         $sections = deserialize($this->toc_sections, true);
         $where = array();
         $where[] = '(' . implode(' OR ', array_fill(0, count($sections), 'inColumn=?')) . ')';
         $where[] = 'pid=?';
         $args = array_merge($sections, array($objPage->id), $sections);
         $order = 'FIELD(tl_article.inColumn,' . implode(',', array_fill(0, count($sections), '?')) . ')';
         $articles = \ArticleModel::findBy($where, $args, array('order' => $order));
         if ($articles) {
             foreach ($articles as $article) {
                 /** @var \ArticleModel $article */
                 $item = $eventDrivenItemFactory->createItem('article', $article->id);
                 if ($this->toc_include_articles) {
                     $items->add($item);
                 } else {
                     $items->addAll($item->getChildren()->toArray());
                 }
             }
         }
     }
     if ($this->toc_source == 'articles') {
         $articleIds = deserialize($this->toc_articles, true);
         foreach ($articleIds as $articleId) {
             $item = $eventDrivenItemFactory->createItem('article', $articleId);
             if ($this->toc_include_articles) {
                 $items->add($item);
             } else {
                 $items->addAll($item->getChildren()->toArray());
             }
         }
     }
     $this->Template->xnav_template = $this->xnavigation_template;
     $this->Template->items = $items;
     $this->Template->item_condition = $this->createItemCondition();
     $this->Template->link_condition = $this->createLinkCondition();
 }
开发者ID:bit3,项目名称:contao-toc-element,代码行数:47,代码来源:TableOfContentsElement.php

示例2: collectItems

 public function collectItems(CollectItemsEvent $event)
 {
     $item = $event->getParentItem();
     if ($item->getType() == 'page') {
         if (empty($this->columns)) {
             return;
         }
         $columnWildcards = array_fill(0, count($this->columns), '?');
         $columnWildcards = implode(',', $columnWildcards);
         $t = \ArticleModel::getTable();
         $arrColumns = array("{$t}.pid=?", "{$t}.inColumn IN ({$columnWildcards})");
         if (!BE_USER_LOGGED_IN) {
             $time = time();
             $arrColumns[] = "({$t}.start='' OR {$t}.start<{$time}) AND ({$t}.stop='' OR {$t}.stop>{$time}) AND {$t}.published=1";
         }
         $articles = \ArticleModel::findBy($arrColumns, array_merge(array($item->getName()), $this->columns), array('order' => 'sorting'));
         if ($articles) {
             $factory = $event->getFactory();
             foreach ($articles as $article) {
                 $factory->createItem('article', $article->id, $item);
             }
         }
     }
 }
开发者ID:bit3,项目名称:contao-xnavigation-article,代码行数:24,代码来源:ArticleProvider.php

示例3: generateUrl

 public function generateUrl($arrPages)
 {
     $arrPages = array();
     $News = \NewsModel::findAll();
     if (empty($News)) {
         return array();
     }
     $arrNews = array();
     while ($News->next()) {
         if (!empty($News)) {
             $arrNews[$News->pid][] = $this->generateNewsUrl($News);
         }
     }
     $InactiveArchives = \GlossarNewsArchiveModel::findByPidsAndInactiveGlossar(array_keys($arrNews));
     if (!empty($InactiveArchives)) {
         while ($InactiveArchives->next()) {
             unset($arrNews[$InactiveArchives->id]);
         }
     }
     if (empty($arrNews)) {
         return array();
     }
     $NewsReader = \ModuleModel::findByType('newsreader');
     if (empty($NewsReader)) {
         return array();
     }
     $arrReader = array();
     while ($NewsReader->next()) {
         $arrReader[$NewsReader->id] = deserialize($NewsReader->news_archives);
     }
     $Content = \ContentModel::findBy(array("module IN ('" . implode("','", array_keys($arrReader)) . "')"), array());
     if (empty($Content)) {
         return array();
     }
     $arrContent = array();
     while ($Content->next()) {
         $arrContent[$Content->module] = $Content->pid;
     }
     $Article = \ArticleModel::findBy(array("tl_article.id IN ('" . implode("','", $arrContent) . "')"), array());
     if (empty($Article)) {
         return array();
     }
     $finishedIDs = $arrPages = array();
     while ($Article->next()) {
         // $root = $this->getRootPage($Article->pid);
         $domain = \Environment::get('base');
         $strLanguage = 'de';
         $objPages = $Article->getRelated('pid');
         $ReaderId = false;
         foreach ($arrContent as $module => $mid) {
             if ($mid == $Article->id) {
                 $ReaderId = $module;
             }
         }
         foreach ($arrReader[$ReaderId] as $news_id) {
             if (in_array($news_id, $finishedIDs)) {
                 continue;
             }
             if (!empty($arrNews[$news_id])) {
                 foreach ($arrNews[$news_id] as $news_domain) {
                     $news_domain = str_replace('.html', '', $news_domain);
                     $arrPages['de'][] = $domain . static::generateFrontendUrl($objPages->row(), substr($news_domain, strpos($news_domain, '/')), $strLanguage);
                 }
             }
             $finishedIDs[] = $news_id;
         }
     }
     return $arrPages;
 }
开发者ID:kbits,项目名称:SWGlossar,代码行数:69,代码来源:GlossarNews.php

示例4: generateUrl

 public function generateUrl($arrPages)
 {
     $arrPages = array();
     $Event = \CalendarEventsModel::findAll();
     if (empty($Event)) {
         return array();
     }
     $arrEvent = array();
     while ($Event->next()) {
         $objCalendar = \CalendarModel::findByPk($Event->pid);
         if ($objCalendar !== null && $objCalendar->jumpTo && ($objTarget = $objCalendar->getRelated('jumpTo')) !== null) {
             $arrEvent[$Event->pid][] = $this->generateEventUrl($Event, $this->generateFrontendUrl($objTarget->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/events/%s'));
         }
     }
     $InactiveArchives = \GlossarCalendarModel::findByPidsAndInactiveGlossar(array_keys($arrEvent));
     if (!empty($InactiveArchives)) {
         while ($InactiveArchives->next()) {
             unset($arrEvent[$InactiveArchives->id]);
         }
     }
     if (empty($arrEvent)) {
         return array();
     }
     $EventReader = \ModuleModel::findByType('eventreader');
     if (empty($EventReader)) {
         return array();
     }
     $arrReader = array();
     while ($EventReader->next()) {
         $arrReader[$EventReader->id] = deserialize($EventReader->cal_calendar);
     }
     $Content = \ContentModel::findBy(array("module IN ('" . implode("','", array_keys($arrReader)) . "')"), array());
     if (empty($Content)) {
         return array();
     }
     $arrContent = array();
     while ($Content->next()) {
         $arrContent[$Content->module] = $Content->pid;
     }
     $Article = \ArticleModel::findBy(array("tl_article.id IN ('" . implode("','", $arrContent) . "')"), array());
     if (empty($Article)) {
         return array();
     }
     $finishedIDs = $arrPages = array();
     while ($Article->next()) {
         // $root = $this->getRootPage($Article->pid);
         $domain = \Environment::get('base');
         $strLanguage = 'de';
         $objPages = $Article->getRelated('pid');
         $ReaderId = false;
         foreach ($arrContent as $module => $mid) {
             if ($mid == $Article->id) {
                 $ReaderId = $module;
             }
         }
         foreach ($arrReader[$ReaderId] as $event_id) {
             if (in_array($event_id, $finishedIDs)) {
                 continue;
             }
             if (!empty($arrEvent[$event_id])) {
                 foreach ($arrEvent[$event_id] as $event_domain) {
                     $event_domain = str_replace('.html', '', $event_domain);
                     $arrPages['de'][] = $domain . static::generateFrontendUrl($objPages->row(), substr($event_domain, strpos($event_domain, '/')), $strLanguage);
                 }
             }
             $finishedIDs[] = $event_id;
         }
     }
     return $arrPages;
 }
开发者ID:kbits,项目名称:SWGlossar,代码行数:70,代码来源:GlossarEvents.php

示例5: getArticleLabel

 public function getArticleLabel($row, $label)
 {
     $page = \PageModel::findWithDetails($row['pid']);
     $layout = $page->getRelated('layout');
     $callback = $GLOBALS['TL_DCA']['tl_article']['list']['label']['reveal_original_label_callback'];
     if (is_array($callback)) {
         $callback[0] = \System::importStatic($callback[0]);
     }
     $label = call_user_func($callback, $row, $label);
     if ($layout->useRevealJs) {
         if ($row['revealVerticalSlide'] == 'start') {
             $label = '&boxhd; ' . $label;
         } else {
             if ($row['revealVerticalSlide'] == 'stop') {
                 $label = '&boxhu; ' . $label;
             } else {
                 $predecessors = \ArticleModel::findBy(array('pid = ?', 'sorting < ?', 'revealVerticalSlide != ?'), array($row['pid'], $row['sorting'], ''), array('order' => 'sorting DESC', 'limit' => 1));
                 if ($predecessors && $predecessors->revealVerticalSlide == 'start') {
                     $successor = \ArticleModel::findOneBy(array('pid = ?', 'sorting > ?'), array($row['pid'], $row['sorting']), array('order' => 'sorting', 'limit' => 1));
                     if ($successor && $successor->revealVerticalSlide == 'start') {
                         $label = '&boxhu; ' . $label;
                     } else {
                         $label = '&boxv; ' . $label;
                     }
                 }
             }
         }
         $predecessors = \ArticleModel::findBy(array('pid = ?', 'sorting < ?'), array($row['pid'], $row['sorting']), array('order' => 'sorting'));
         if ($predecessors) {
             $slide = $predecessors->count();
             $page = -1;
             $inVertical = false;
             foreach ($predecessors as $predecessor) {
                 if ($predecessor->revealVerticalSlide == 'start') {
                     $inVertical = true;
                 }
                 if ($inVertical && $predecessor->revealVerticalSlide != 'start') {
                     $page += 0.001;
                 } else {
                     $page = (int) ($page + 1);
                 }
                 if ($predecessor->revealVerticalSlide == 'stop') {
                     $inVertical = false;
                 }
             }
             if ($inVertical && $row['revealVerticalSlide'] != 'start') {
                 $page += 0.001;
             } else {
                 $page = (int) ($page + 1);
             }
             if ($inVertical) {
                 $pageMain = (int) $page;
                 $pageSub = (int) (($page - $pageMain) * 1000);
                 $page = sprintf('%d-%d', $pageMain, $pageSub);
             } else {
                 $page = (int) $page;
             }
         } else {
             $slide = 0;
             $page = 0;
         }
         $label .= ' ' . sprintf($GLOBALS['TL_LANG']['tl_article']['revealSlideNumber'], $slide, $page);
     }
     return $label;
 }
开发者ID:bit3,项目名称:contao-theme-reveal-js-basic,代码行数:65,代码来源:Hooks.php

示例6: findGlossarPages

 protected function findGlossarPages()
 {
     $time = time();
     $arrPages = array();
     $objPages = \GlossarPageModel::findActiveAndEnabledGlossarPages();
     if (!empty($objPages)) {
         while ($objPages->next()) {
             if ($objPages->type == 'root') {
                 $strLanguage = $objPages->language;
             }
             $domain = \Environment::get('base');
             if ((!$objPages->start || $objPages->start < $time) && (!$objPages->stop || $objPages->stop > $time)) {
                 $arrPages[$strLanguage][] = $domain . static::generateFrontendUrl($objPages->row(), null, $strLanguage);
                 $objArticle = \ArticleModel::findBy(array("tl_article.pid=? AND (tl_article.start='' OR tl_article.start<{$time}) AND (tl_article.stop='' OR tl_article.stop>{$time}) AND tl_article.published=1 AND tl_article.showTeaser=1"), array($objPages->id), array('order' => 'sorting'));
                 if (!empty($objArticle)) {
                     while ($objArticle->next()) {
                         $arrPages[$strLanguage][] = $domain . static::generateFrontendUrl($objPages->row(), '/articles/' . ($objArticle->alias != '' && !\Config::get('disableAlias') ? $objArticle->alias : $objArticle->id), $strLanguage);
                     }
                 }
             }
         }
     }
     return $arrPages;
 }
开发者ID:kbits,项目名称:SWGlossar,代码行数:24,代码来源:RebuildGlossar.php

示例7: templates

 public function templates($obj)
 {
     $template = $obj->getName();
     switch ($template) {
         case 'fe_page':
         case 'fe_page_multitoggle':
             //custom
             $obj->setName($template . '_gc');
             //gc = grid controll only
             $obj->__get("layout")->__set("gridCSS", (array) $this->getGridArr($obj->layout));
             break;
         case 'form':
             $obj->setName($template . '_' . \Config::get('co_grid_prefix'));
             break;
         default:
     }
     // `-,-´ ContentElements
     if ($obj->__get('typePrefix') == 'ce_' && strpos($template, 'ce_row_start') === FALSE) {
         $strClass = $this->findContentElement($obj->__get('type'));
         if ($strClass !== NULL && $strClass != '') {
             $objModel = \ContentModel::findBy('id', $obj->__get('id'));
             if ($objModel !== NULL) {
                 $objEl = new $strClass($objModel);
                 $objEl = $this->design_elements($objEl);
                 $obj->__set('ftc_classes', $objEl->ftc_classes);
                 $obj->__set('ftcID', $objEl->ftcID);
                 $obj->__set('data_attr', $this->splitArr($objEl->data_attr));
                 $obj->__set('class', $objEl->ftc_classes);
                 $obj->__set('cssID', $objEl->ftcID);
             }
         }
     }
     if (strpos($template, 'ce_row_start') !== FALSE) {
         $obj->__set('row_data_attr_ftc', $this->splitArr($obj->row_data_attr_ftc));
     }
     // `-,-´ Article
     if (strpos($template, 'mod_article') !== FALSE) {
         $objModel = \ArticleModel::findBy('id', $obj->__get('id'));
         if ($objModel !== NULL) {
             $objEl = new \ModuleArticle($objModel);
             $objEl = $this->design_articles($objEl);
             $obj->__set('class', '' . $objEl->ftc_classes);
             $obj->__set('cssID', $objEl->ftcID . ' ');
             //.$objEl->data_attr.' '
         }
     }
     // `-,-´ Module
     if ($obj->__get('typePrefix') == 'mod_') {
         $strClass = \Module::findClass($obj->__get('type'));
         if ($strClass !== NULL && $strClass != '') {
             $objModel = \ModuleModel::findBy('id', $obj->__get('id'));
             if ($objModel !== NULL) {
                 $objEl = new $strClass($objModel);
                 $co_grid = $this->design_modules($objEl);
                 $obj->__set('class', $co_grid['class'] . ' ' . $co_grid['co_grid_classes']);
                 // $obj->__set('cssID',$co_grid['ftcID'].' '.$co_grid['data_attr'].' ');
                 $obj->__set('ftc_classes', $co_grid['class'] . ' ' . $co_grid['co_grid_classes']);
                 $obj->__set('ftcID', $co_grid['ftcID'] . ' ');
                 $obj->__set('ftc_data_attr', $co_grid['data_attr']);
             }
         }
     }
 }
开发者ID:designs2,项目名称:codeowl_grid_control,代码行数:63,代码来源:OutputGridVars.php

示例8: parseCustomizeFrontendTemplate

 /**
  * Edit the Frontend Template
  */
 public function parseCustomizeFrontendTemplate($strContent, $strTemplate)
 {
     global $objPage;
     $isFullpage = $this->isFullPageEnabled($objPage);
     if ($strTemplate == "mod_article") {
         $sectionHeaderID = 3;
         // TODO: verwaltbar machen!!!
         $sectionFooterID = 4;
         $objArticle = NULL;
         $articleClass = array();
         $articlePattern = '/<div([A-Za-z0-9\\s\\-_=;",:\\.\\(\\)\'#\\/%]{0,})class="mod_article([A-Za-z0-9\\s\\-_]{0,})"([A-Za-z0-9\\s\\-_=;",:\\.\\(\\)\'#\\/%]{0,})>/';
         preg_match_all('/id="([A-Za-z0-9\\-_]{0,})"/', $strContent, $idMatches);
         if (is_array($idMatches) && count($idMatches[0]) > 0) {
             $objArticle = \ArticleModel::findByIdOrAlias($idMatches[1][0]);
         }
         if ($isFullpage) {
             if ($objArticle) {
                 if ($objArticle->enableSectionHeader) {
                     $sectionHeaderID = $objArticle->sectionHeaderModule;
                     $strContent = preg_replace($articlePattern, '<div$1class="mod_article$2"$3><div class="header section-header">{{insert_module::' . $sectionHeaderID . '}}</div>', $strContent);
                 }
                 if ($objArticle->enableSectionFooter) {
                     $sectionFooterID = $objArticle->sectionFooterModule;
                     $strContent = preg_replace('/<\\/div>$/', '<div class="footer section-footer">{{insert_module::' . $sectionFooterID . '}}</div></div>', $strContent);
                 }
                 if ($objArticle->enableOverlay) {
                     $strOverlayContent = '';
                     if ($objArticle->showTitleInOverlay) {
                         $strArticleTitle = $objArticle->title;
                         if (strlen($objArticle->alt_title)) {
                             $strArticleTitle = $objArticle->alt_title;
                         }
                         $strOverlayContent = '<div class="overlay-title"><div class="title-inner">' . $strArticleTitle . '</div></div>';
                     }
                     $strClass = "";
                     if ($objArticle->overlayTransparent) {
                         $strClass = " overlay-trans";
                     }
                     $strOverlayTags = '<div class="show-overlay"></div><div class="overlay article-overlay' . $strClass . ' shown"><div class="close"></div>' . $strOverlayContent . '</div>';
                     $strContent = preg_replace($articlePattern, '<div$1class="mod_article has-overlay$2"$3>', $strContent);
                     $strContent = preg_replace('/<\\/div>$/', $strOverlayTags . '</div>', $strContent);
                 }
                 if ($objArticle->enableFullpageNavigation) {
                     $navNext = "";
                     $navPrev = "";
                     if ($objPage->fullpageDirection == "horizontal") {
                         // TODO NAVI RIGHT UND LEFT!!
                     } else {
                         $navNext = '<div class="navigation-top" onClick="DPS.Fullpage.sectionBack(this);"></div>';
                         $navPrev = '<div class="navigation-bottom" onClick="DPS.Fullpage.sectionForward(this);"></div>';
                     }
                     $navigationTags = '<div class="fullpage-navigation">' . $navNext . $navPrev . '</div>';
                     //						$strContent			= preg_replace($articlePattern, '', $strContent);
                     $strContent = preg_replace('/<\\/div>$/', $navigationTags . '</div>', $strContent);
                 }
             }
             if ($objPage->fullpageDirection == "horizontal") {
                 $articleClass[] = 'slide';
             } else {
                 $articleClass[] = 'section';
             }
             //				$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><div class="article-inner">', $strContent);
             //				$strContent = $strContent . '</div>';
         }
         if ($objArticle) {
             if ($objArticle->enableBackgroundImage && $objArticle->singleSRC != "") {
                 $objFile = \FilesModel::findByUuid($objArticle->singleSRC);
                 if ($objFile === null && !\Validator::isUuid($objArticle->singleSRC)) {
                     $strContent = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>' . $strContent;
                 }
                 if ($objFile && is_file(TL_ROOT . '/' . $objFile->path)) {
                     preg_match_all($articlePattern, $strContent, $arrArticleMatches);
                     if (is_array($arrArticleMatches[0]) && count($arrArticleMatches[0]) > 0) {
                         $bgPosition = str_replace('_', ' ', $objArticle->backgroundImagePosition);
                         if (!$bgPosition) {
                             $bgPosition = "center center";
                         }
                         if (preg_match('/style="/', $arrArticleMatches[0][0])) {
                             $styles = 'background-image:url(\'' . $objFile->path . '\');background-position:' . $bgPosition . ';';
                             $replStyles = '';
                             if (preg_match('/style="/', $arrArticleMatches[1][0])) {
                                 $replStyles = str_replace('style="', 'style="' . $styles, $arrArticleMatches[1][0]);
                             } elseif (preg_match('/style="/', $arrArticleMatches[3][0])) {
                                 $replStyles = str_replace('style="', 'style="' . $styles, $arrArticleMatches[3][0]);
                             }
                             $strContent = preg_replace($articlePattern, '<div' . $replStyles . 'class="mod_article$2"$3>', $strContent);
                         } else {
                             $strContent = preg_replace($articlePattern, '<div$1class="mod_article$2" style="background-image:url(\'' . $objFile->path . '\');background-position:' . $bgPosition . ';"$3>', $strContent);
                         }
                         $strContent = preg_replace($articlePattern, '<div$1class="mod_article has-background-image bg-fixed bg-image bg-cover$2"$3">', $strContent);
                     }
                 }
             }
             if ($objArticle->enableNavigation) {
                 $articleNavigationTag = '<div class="navigation-container">';
                 $objAllArticles = \ArticleModel::findBy(array("pid=?", "inColumn=?", "published=?"), array($objArticle->pid, "main", "1"), array("order" => "sorting"));
                 $nextArticle = false;
//.........这里部分代码省略.........
开发者ID:pressi,项目名称:zdps_customize,代码行数:101,代码来源:Template.php


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