/** * Get the list of articles to show in admin paneel , with optional sorting and filter search * @param string $type type of filter (index/draft/published) * @param string $id type of values we want search (all|0|1) * @param string $sorter type of order that we it will display results * @return array $articles and $count where $articles have all info about the articles we will show. And the $count it will display how many items we get */ public function get_index($type = "index", $id = "all", $sorter = "ns") { $title = "List of articles"; //sorter and searcher for table if ($type == "index" && $id == "all" && preg_match("/^(title|created_at|author_id|draft|published)/", $sorter)) { $articles = Article::order_by($sorter, 'asc')->get(); $count = Article::count(); } elseif (preg_match("/^(draft|published)/", $type) && preg_match("/^(1|0)/", $id) && $sorter == "ns") { $articles = Article::get_query($type, $id); $count = Article::get_totals($type, $id); } elseif (preg_match("/^(index|draft|published)/", $type) && preg_match("/^(1|0)/", $id) && preg_match("/^(title|published|author_id|draft|created_at|ns)/", $sorter)) { $articles = Article::get_order($sorter, $type, $id); $count = Article::get_totals($type, $id); } else { $articles = Article::all(); $count = Article::count(); } $this->layout->nest('content', 'dojo::articles.index', array('articles' => $articles, 'count' => $count)); }