/** * {@inheritdoc} */ public function onRun() { $this->category_page = $this->property('categoryPage'); $this->wide = $this->property('wide') == true; $this->type = $this->property('type'); $this->limit = $this->property('limit'); $this->subcategories = $this->property('subcategories'); $this->random = $this->property('random'); $this->is_promoted = $this->property('is_promoted'); $this->templates = $this->property('template'); $this->partial = BoxSetting::find($this->type); $this->category = Category::loadCategory($this->category_page); $this->posts = BlogPost::getPosts(['post_id' => isset($this->page['post']) ? $this->page['post']->id : null, 'category' => $this->category, 'categories_id' => $this->property('categories_id'), 'limit' => $this->limit, 'template_id' => $this->templates, 'promoted' => $this->is_promoted, 'random' => $this->random, 'subcategories' => $this->subcategories]); }
protected function prepareVars() { $this->pageParam = $this->paramName('pageNumber'); $this->noPostsMessage = $this->property('noPostsMessage'); $this->postPage = $this->property('postPage'); $this->categoryPage = $this->property('categoryPage'); $this->categoryParent = $this->property('categoryParent'); $this->category = BlogCategory::loadCategory($this->categoryPage, $this->categoryParent); $this->template = $this->property('template') ?: (empty($this->category->template->partial_category) ? null : $this->category->template->partial_category); if (empty($this->category->id) || empty($this->category->template->id) && empty($this->template->id)) { return \Response::make($this->controller->run('404'), 404); } // paginacja domyślnie włączona; 'false' wyłącza $this->paginationActive = $this->category->pagination !== 'false' || $this->property('postsPerPage') > 0; $this->posts = BlogPost::getPosts(['category' => $this->category, 'categories_id' => $this->property('categories_id'), 'template_id' => $this->property('template_id') ?: $this->category->template_id, 'pagination' => $this->paginationActive, 'posts_per_page' => (int) $this->category->pagination > 0 ? $this->category->pagination : $this->property('postsPerPage'), 'page' => $this->property('pageNumber'), 'subcategories' => $this->property('subcategories'), 'order' => "NULLIF(regexp_replace(additional->>'order', E'\\D', '', 'g'), '')::int NULLS LAST, published_at DESC"]); $this->setMeta(); }
/** * Doczytanie powiązanych postów * @return void */ protected function loadRelated() { if (empty($this->post->template->related) === false) { $this->post->categories_id = $this->post->categories->getSubcategoriesId(); foreach (Yaml::parse($this->post->template->related) as $key => $value) { // sprawdzanie czy istnieje wymagany atrybut if (isset($value['require']) && !$this->post->{$value['require']}) { continue; } // przypisanie wartości z posta if (isset($value['variable']) && isset($this->post->{$value['variable']})) { $value[$value['variable']] = $this->post->{$value['variable']}; } $this->post->{$key} = isset($value['run']) ? $this->{$value['run']}($this->post, $this->category, $value) : BlogPost::getPosts(['post_id' => $this->post->id, 'categories_id' => empty($this->post->category) ? empty($this->post->communication->id) ? $this->post->categories_id : $this->post->communication->id : $this->post->category, 'tags' => $this->post->tags] + $value); } } }