private function _list($section, $limit)
 {
     $this->section = new CmsSection($section);
     $model = new CmsContent("published");
     $this->items = $model->filter("cms_section_id", $section)->limit($limit)->all();
     if (!$this->items->count()) {
         $this->items = array();
     }
 }
 public function related()
 {
     $this->use_layout = false;
     $this->use_view = "_related_list";
     $this->article_offset = 0;
     if (Request::post('page_number') && Request::post('section')) {
         $page = parse_url(Request::post('page_number'));
         $page = str_replace("page=", "", $page['query']);
         if ($page && Request::post('section')) {
             $this->this_page = $page;
             $section = new CmsSection();
             $content = new CmsContent("published");
             $this->cms_section = $section->filter(array('url' => Request::post('section')))->first();
             if ($this->cms_section->id) {
                 $this->cms_section_id = $this->cms_section->id;
                 $this->cms_content = $content->filter(array('cms_section_id' => $this->cms_section_id))->order('published DESC')->page($this->this_page, $this->per_page);
             }
         }
     }
 }
Exemple #3
0
 public function published_content()
 {
     $content = new CmsContent();
     return $content->filter(array($this->get_col("content")->join_field => $this->primval, "status" => array(0, 1)))->all();
 }
Exemple #4
0
 public function avoid_url_clash()
 {
     $test_url = $original_url = $this->url;
     $model = new CmsContent();
     if ($this->primval) {
         $model->filter($this->primary_key . ' <> ' . $this->primval);
     }
     $count = 0;
     while ($model->filter(array('url' => $test_url, 'cms_section_id' => $this->cms_section_id))->filter('status <> 4')->first()) {
         if ($count == 0) {
             $test_url = $original_url . '-' . date("Y-m-d");
         } elseif ($count == 1) {
             $test_url = $original_url . '-' . $this->primval;
         } else {
             $test_url = $original_url . '-' . mt_rand(0, 99);
         }
         $count++;
     }
     return $test_url;
 }
Exemple #5
0
 public function articles()
 {
     $content = new CmsContent("published");
     return $content->filter(array("author_id" => $this->id))->all();
 }