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


PHP Board::getBoardsForBoardlist方法代码示例

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


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

示例1: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $firstPost = Post::orderBy('post_id', 'asc')->first()->pluck('created_at');
     $nowTime = Carbon::now()->minute(0)->second(0)->timestamp;
     $boards = Board::all();
     $this->comment("Reviewing all records.");
     while ($firstPost->timestamp < $nowTime) {
         $firstPost = $firstPost->addHour();
         $hourCount = 0;
         foreach ($boards as $board) {
             if ($board->posts_total > 0) {
                 $newRows = $board->createStatsSnapshot($firstPost);
                 $hourCount += $newRows->count();
             }
         }
         if ($hourCount > 0) {
             $this->comment("\tAdded {$hourCount} new stat row(s) from " . $firstPost->diffForHumans());
         }
     }
     // Drop boardlist cache.
     Cache::forget('site.boardlist');
     // Generate boardlist again.
     Board::getBoardsForBoardlist();
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:29,代码来源:RecordStatsAll.php

示例2: boardListSearch

 protected function boardListSearch($perPage = 25)
 {
     $input = $this->boardListInput();
     $title = $input['title'];
     $lang = $input['lang'];
     $page = $input['page'];
     $tags = $input['tags'];
     $sfw = $input['sfw'];
     $sort = $input['sort'];
     $sortBy = $input['sortBy'];
     $boards = collect(Board::getBoardsForBoardlist());
     $boards = $boards->filter(function ($item) use($lang, $tags, $sfw, $title) {
         // Are we able to view unindexed boards?
         if (!$item['is_indexed'] && !$this->user->canViewUnindexedBoards()) {
             return false;
         }
         // Are we requesting SFW only?
         if ($sfw && !$item['is_worksafe']) {
             return false;
         }
         // Are we searching by language?
         if ($lang) {
             $boardLang = $item->settings['boardLanguage'];
             if ($lang != $boardLang) {
                 return false;
             }
         }
         // Are we searching tags?
         if ($tags && (!count($item['tags']) || count(array_intersect($tags, array_fetch($item['tags'], 'tag'))) < count($tags))) {
             return false;
         }
         // Are we searching titles and descriptions?
         if ($title && stripos($item['board_uri'], $title) === false && stripos($item['title'], $title) === false && stripos($item['description'], $title) === false) {
             return false;
         }
         return true;
     });
     if ($title || $sort && $sortBy) {
         $sortWeight = $sortBy == "asc" ? -1 : 1;
         $boards = $boards->sort(function ($a, $b) use($title, $sort, $sortWeight) {
             // Sort by active users, then last post time.
             $aw = 0;
             $bw = 0;
             if ($title) {
                 $aw += $a['board_uri'] === $title ? 80 : 0;
                 $aw += stripos($a['board_uri'], $title) !== false ? 40 : 0;
                 $aw += stripos($a['title'], $title) !== false ? 20 : 0;
                 $aw += stripos($a['description'], $title) !== false ? 10 : 0;
                 $bw += $b['board_uri'] === $title ? 80 : 0;
                 $aw += stripos($b['board_uri'], $title) !== false ? 40 : 0;
                 $aw += stripos($b['title'], $title) !== false ? 20 : 0;
                 $aw += stripos($b['description'], $title) !== false ? 10 : 0;
             }
             if ($sort) {
                 if ($a[$sort] > $b[$sort]) {
                     $aw += $sortWeight;
                 } else {
                     if ($a[$sort] < $b[$sort]) {
                         $bw += $sortWeight;
                     }
                 }
             }
             return $bw - $aw;
         });
     }
     $paginator = new LengthAwarePaginator($boards->forPage($page, $perPage), $boards->count(), $perPage, $page);
     $paginator->setPath(url("boards.html"));
     foreach ($input as $inputIndex => $inputValue) {
         if ($inputIndex == "sfw") {
             $inputIndex = (int) (!!$inputValue);
         }
         $paginator->appends($inputIndex, $inputValue);
     }
     return $paginator;
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:75,代码来源:BoardlistController.php

示例3: boardListSearch

 protected function boardListSearch($perPage = 25)
 {
     $input = $this->boardListInput();
     $title = $input['title'];
     $lang = $input['lang'];
     $page = $input['page'];
     $tags = $input['tags'];
     $sfw = $input['sfw'];
     $boards = Board::getBoardsForBoardlist();
     $boards = $boards->filter(function ($item) use($lang, $tags, $sfw, $title) {
         // Are we able to view unindexed boards?
         if (!$item->is_indexed && !$this->user->canViewUnindexedBoards()) {
             return false;
         }
         // Are we requesting SFW only?
         if ($sfw && !$item->is_worksafe) {
             return false;
         }
         // Are we searching by language?
         if ($lang) {
             $boardLang = $item->settings->where('option_name', 'boardLanguage')->pluck('option_value')->first();
             if ($lang != $boardLang) {
                 return false;
             }
         }
         // Are we searching tags?
         if ($tags && count(array_intersect($tags, $item->tags->pluck('tag')->toArray())) < count($tags)) {
             return false;
         }
         // Are we searching titles and descriptions?
         if ($title && stripos($item->board_uri, $title) === false && stripos($item->title, $title) === false && stripos($item->description, $title) === false) {
             return false;
         }
         return true;
     });
     if ($title) {
         $boards = $boards->sort(function ($a, $b) use($title) {
             // Sort by active users, then last post time.
             $aw = 0;
             $bw = 0;
             if ($a->board_uri === $title) {
                 $aw += 8;
             }
             if (stripos($a->board_uri, $title) !== false) {
                 $aw += 4;
             }
             if (stripos($a->title, $title) !== false) {
                 $aw += 2;
             }
             if (stripos($a->description, $title) !== false) {
                 $aw += 1;
             }
             if ($b->board_uri === $title) {
                 $bw += 8;
             }
             if (stripos($b->board_uri, $title) !== false) {
                 $bw += 4;
             }
             if (stripos($b->title, $title) !== false) {
                 $bw += 2;
             }
             if (stripos($b->description, $title) !== false) {
                 $bw += 1;
             }
             return $bw - $aw;
         });
     }
     $paginator = new LengthAwarePaginator($boards->forPage($page, $perPage), $boards->count(), $perPage, $page);
     $paginator->setPath("boards.html");
     foreach ($input as $inputIndex => $inputValue) {
         if ($inputIndex == "sfw") {
             $inputIndex = (int) (!!$inputValue);
         }
         $paginator->appends($inputIndex, $inputValue);
     }
     return $paginator;
 }
开发者ID:JEWSbreaking8chan,项目名称:infinity-next,代码行数:77,代码来源:BoardlistController.php

示例4: getNavigationPrimaryBoards

 /**
  * Returns the primary navigation board list.
  *
  * @return array|false  Returns false if the setting boardListShow is disabled.
  */
 public function getNavigationPrimaryBoards()
 {
     if ($this->hasDB() && $this->get('boardListShow', false)) {
         if (Cache::has("site.boardlist")) {
             return Cache::remember('site.gnav.boards', 1, function () {
                 $popularBoards = collect();
                 $recentBoards = collect();
                 $popularBoardArray = Board::getBoardsForBoardlist(0, 20);
                 foreach ($popularBoardArray as $popularBoard) {
                     $popularBoards->push(new Board($popularBoard));
                 }
                 $recentBoards = Board::where('posts_total', '>', 0)->whereNotNull('last_post_at')->wherePublic()->whereNotIn('board_uri', $popularBoards->pluck('board_uri'))->select('board_uri', 'title')->orderBy('last_post_at', 'desc')->take(20)->get();
                 return ['popular_boards' => $popularBoards, 'recent_boards' => $recentBoards];
             });
         }
         return ['popular_boards' => collect(), 'recent_boards' => collect()];
     }
     return false;
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:24,代码来源:SettingManager.php

示例5: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Generate an activity snapshot.
     Board::createStatsSnapshots();
     Board::getBoardsForBoardlist(0, null, true);
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:11,代码来源:RecordStats.php


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