예제 #1
0
 /**
  * ajax filter function - takes the incoming string, matches against columns 
  * and outputs view of the matching data
  */
 public function filters()
 {
     $this->use_layout = false;
     $sect = new CmsSection();
     $this->all_sections = $sect->filter("title LIKE '%{$fil}%'")->tree();
     $this->use_view = "_section_list";
     $this->all_sections_partial = $this->render_partial("section_list");
 }
예제 #2
0
 public function allowed_sections_model()
 {
     $sections = new CmsSection();
     if ($ids = $this->allowed_sections_ids()) {
         $sections->filter(array("id" => $ids));
     }
     return $sections;
 }
 /** SECTIONS **/
 private function section($index)
 {
     if ($this->cms_section && $this->cms_section->primval && $this->section_stack[$index]) {
         $section = new CmsSection();
         return $section->filter("url", $this->section_stack[$index])->first();
     } else {
         return false;
     }
 }
예제 #4
0
 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);
             }
         }
     }
 }
예제 #5
0
 public function find_most_commented($section = "1", $since = "7", $limit = "10")
 {
     $content = new CmsContent();
     $sections = new CmsSection();
     if ($section && !is_numeric($section)) {
         $section = $sections->filter(array('url' => $section))->first()->id;
     }
     $sql = "SELECT *, count(attached_id) as counter FROM `cms_comment` RIGHT JOIN cms_content ON attached_id=cms_content.id WHERE cms_comment.status=1 AND `time` > date_sub(now(), INTERVAL '{$since}' DAY)";
     if ($section) {
         $sql .= " AND cms_section_id={$section}";
     }
     $sql .= " GROUP BY attached_id ORDER BY counter DESC LIMIT {$limit}";
     return $content->find_by_sql($sql);
 }
예제 #6
0
 /**
  * Takes the url passed in and tries to find a section with a matching url
  * - if finds one, set the cms_section & return true
  * - if it finds more than one, then reverse stack, traverse back looking for matching parents & return true
  * - return false 
  * @param String $url 
  * @return Boolean
  */
 protected function find_section($url, $parent = false)
 {
     $section = new CmsSection();
     if ($parent) {
         $section->filter(array('parent_id' => $parent));
     }
     $res = $section->filter(array('url' => $url))->all();
     if (count($res) == 1) {
         $this->cms_section = $res[0];
         return true;
     } elseif (count($res) > 1) {
         $stack = array_reverse($this->section_stack);
         //if empty, add home section
         if (!count($stack)) {
             $stack[] = "home";
         }
         foreach ($res as $result) {
             if ($result->parent->url == $stack[0]) {
                 $this->cms_section = $result;
             }
         }
         return true;
     } else {
         return false;
     }
 }