Exemple #1
0
 public function action_edit()
 {
     $catalog_id = $this->request->param('id');
     $this->template->show_logout = TRUE;
     $this->template->title = 'Catalog::Edit';
     $catalog = Model_Catalogs::getCatalogById($catalog_id);
     $view = $this->template->content = View::factory('catalog/edit')->set('catalog', $catalog);
     $this->response->body($view);
 }
Exemple #2
0
 public static function getAllLinks($category_id, $source_id = false, $catalog_id = false, $language_id = false)
 {
     $links = DB::select('links.link_id', 'links.url', 'links.source_id', 'links.title', 'links.catalog_id', 'links.image_name', 'links.language_id', 'links.agegroup_id', 'links.date_added', 'links.is_public')->from('links')->join('catalogs', 'left')->on('links.catalog_id', '=', 'catalogs.catalog_id')->join('categories', 'left')->on('categories.category_id', '=', 'catalogs.category_id')->where('categories.category_id', '=', $category_id);
     //
     if ($source_id) {
         $links = $links->and_where_open();
         $links = $links->where('source_id', '=', $source_id);
         $links = $links->or_where_close();
     }
     if ($catalog_id) {
         $links = $links->and_where_open();
         $links = $links->where('catalog_id', '=', $catalog_id);
         $links = $links->or_where_close();
     }
     //
     if ($language_id) {
         $links = $links->and_where_open();
         $links = $links->where('language_id', '=', $language_id);
         $links = $links->or_where_close();
     }
     $links = $links->order_by('links.date_added', 'DESC');
     $links = $links->execute();
     $categoryName = Model_Categories::getNameById($category_id);
     $final = array();
     foreach ($links as $key => $val) {
         $final[$key] = $val;
         $source = Model_Sources::getProvider($val['source_id']);
         $final[$key]['source_id'] = $source['name'];
         $catalog = Model_Catalogs::getCatalogById($val['catalog_id']);
         $final[$key]['catalog'] = $catalog[0]['name'];
         $final[$key]['language_id'] = Model_Languages::getLangIconById($val['language_id']);
         if (!empty($val['date_added'])) {
             $final[$key]['date_added'] = date('d.m.Y', $val['date_added']);
         }
         $final[$key]['actions'] = '<a href="' . URL::base() . 'dashboard/edit' . $categoryName . '/' . $val['link_id'] . '" class="btn btn-primary btn-circle Edit' . $categoryName . '" type="button"><i class="fa fa-edit"></i></a>&nbsp;<button data-id="' . $val['link_id'] . '" class="btn btn-danger btn-circle Delete' . $categoryName . '" type="button"><i class="fa fa-remove"></i></button>';
     }
     return $final;
 }