@@ -18,7 +18,7 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * @var array |
| 20 | 20 | */ |
| 21 | - public $categories = []; |
|
| 21 | + public $categories = [ ]; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @var bool |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | if (!$this->property('disableUrlMapping') && \Request::isMethod('get') && $searchTerm) { |
| 215 | 215 | // add ?cats[] query string |
| 216 | 216 | $cats = Input::get('cat'); |
| 217 | - $query = http_build_query(['cat' => $cats]); |
|
| 217 | + $query = http_build_query([ 'cat' => $cats ]); |
|
| 218 | 218 | $query = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $query); |
| 219 | - $query = !empty($query) ? '?' . $query : ''; |
|
| 219 | + $query = !empty($query) ? '?'.$query : ''; |
|
| 220 | 220 | |
| 221 | 221 | return Redirect::to( |
| 222 | 222 | $this->currentPageUrl([ |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $currentPage = $this->property('pageNumber'); |
| 237 | 237 | |
| 238 | 238 | if ($currentPage > ($lastPage = $this->posts->lastPage()) && $currentPage > 1) { |
| 239 | - return Redirect::to($this->currentPageUrl([$pageNumberParam => $lastPage])); |
|
| 239 | + return Redirect::to($this->currentPageUrl([ $pageNumberParam => $lastPage ])); |
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | { |
| 271 | 271 | // Filter posts |
| 272 | 272 | $posts = BlogPost::with([ |
| 273 | - 'categories' => function ($q) { |
|
| 273 | + 'categories' => function($q) { |
|
| 274 | 274 | if (!is_null($this->property('excludeCategories'))) { |
| 275 | 275 | $q->whereNotIn('id', $this->property('excludeCategories')); |
| 276 | 276 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | ]) |
| 282 | - ->where(function ($q) { |
|
| 282 | + ->where(function($q) { |
|
| 283 | 283 | $q->where('title', 'LIKE', "%{$this->searchTerm}%") |
| 284 | 284 | ->orWhere('content', 'LIKE', "%{$this->searchTerm}%") |
| 285 | 285 | ->orWhere('excerpt', 'LIKE', "%{$this->searchTerm}%"); |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | // filter categories |
| 289 | 289 | $cat = Input::get('cat'); |
| 290 | 290 | if ($cat) { |
| 291 | - $cat = is_array($cat) ? $cat : [$cat]; |
|
| 291 | + $cat = is_array($cat) ? $cat : [ $cat ]; |
|
| 292 | 292 | $posts->filterCategories($cat); |
| 293 | 293 | } |
| 294 | 294 | |
@@ -314,10 +314,10 @@ discard block |
||
| 314 | 314 | /* |
| 315 | 315 | * Add a "url" helper attribute for linking to each post and category |
| 316 | 316 | */ |
| 317 | - $posts->each(function ($post) { |
|
| 317 | + $posts->each(function($post) { |
|
| 318 | 318 | $post->setUrl($this->postPage, $this->controller); |
| 319 | 319 | |
| 320 | - $post->categories->each(function ($category) { |
|
| 320 | + $post->categories->each(function($category) { |
|
| 321 | 321 | $category->setUrl($this->categoryPage, $this->controller); |
| 322 | 322 | }); |
| 323 | 323 | |
@@ -336,19 +336,19 @@ discard block |
||
| 336 | 336 | protected function getPostIdsByCategories($ids = null) |
| 337 | 337 | { |
| 338 | 338 | if (is_null($ids) || !is_array($ids)) { |
| 339 | - return []; |
|
| 339 | + return [ ]; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $posts = []; |
|
| 343 | - $categories = BlogCategory::with(['posts' => function ($q) { |
|
| 342 | + $posts = [ ]; |
|
| 343 | + $categories = BlogCategory::with([ 'posts' => function($q) { |
|
| 344 | 344 | $q->select('post_id'); |
| 345 | - }]) |
|
| 345 | + } ]) |
|
| 346 | 346 | ->whereIn('id', $ids) |
| 347 | 347 | ->get(); |
| 348 | 348 | |
| 349 | - $categories->each(function ($item) use (&$posts) { |
|
| 350 | - $item->posts->each(function ($item) use (&$posts) { |
|
| 351 | - $posts[] = $item->post_id; |
|
| 349 | + $categories->each(function($item) use (&$posts) { |
|
| 350 | + $item->posts->each(function($item) use (&$posts) { |
|
| 351 | + $posts[ ] = $item->post_id; |
|
| 352 | 352 | }); |
| 353 | 353 | }); |
| 354 | 354 | |
@@ -364,11 +364,11 @@ discard block |
||
| 364 | 364 | $searchTerm = preg_quote($this->searchTerm, '|'); |
| 365 | 365 | |
| 366 | 366 | // apply highlight |
| 367 | - $post->title = preg_replace('|(' . $searchTerm . ')|iu', '<mark>$1</mark>', $post->title); |
|
| 368 | - $post->excerpt = preg_replace('|(' . $searchTerm . ')|iu', '<mark>$1</mark>', $post->excerpt); |
|
| 367 | + $post->title = preg_replace('|('.$searchTerm.')|iu', '<mark>$1</mark>', $post->title); |
|
| 368 | + $post->excerpt = preg_replace('|('.$searchTerm.')|iu', '<mark>$1</mark>', $post->excerpt); |
|
| 369 | 369 | |
| 370 | 370 | $post->content_html = preg_replace( |
| 371 | - '~(?![^<>]*>)(' . $searchTerm . ')~ismu', |
|
| 371 | + '~(?![^<>]*>)('.$searchTerm.')~ismu', |
|
| 372 | 372 | '<mark>$1</mark>', |
| 373 | 373 | $post->content_html |
| 374 | 374 | ); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | * @var array Plugin dependencies |
| 12 | 12 | */ |
| 13 | - public $require = ['RainLab.Blog']; |
|
| 13 | + public $require = [ 'RainLab.Blog' ]; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Returns information about this plugin. |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | // Check the translate plugin is installed |
| 49 | 49 | if (class_exists('RainLab\Translate\Behaviors\TranslatableModel')) { |
| 50 | - return []; |
|
| 50 | + return [ ]; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | return [ |
| 54 | 54 | 'filters' => [ |
| 55 | - '_' => ['Lang', 'get'], |
|
| 56 | - '__' => ['Lang', 'choice'] |
|
| 55 | + '_' => [ 'Lang', 'get' ], |
|
| 56 | + '__' => [ 'Lang', 'choice' ] |
|
| 57 | 57 | ] |
| 58 | 58 | ]; |
| 59 | 59 | } |