예제 #1
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;
 }
예제 #2
0
 public static function getAll($limit = 0, $offset = 0, $orderby = 'catalog_id', $ordertype = 'ASC')
 {
     $legsVar = DB::select_array(array('catalog_id', 'category_id', 'name', 'image_name', 'language_id', 'user_id', 'agegroup_id', 'date_added', 'is_public'))->from('catalogs');
     // Limit
     if ($limit != '' and $limit > 0) {
         $legsVar = $legsVar->limit($limit);
     }
     // Offset
     if ($offset != '' and $offset > 0) {
         $legsVar = $legsVar->offset($offset);
     }
     $legsVar = $legsVar->execute();
     //        print '<pre>'; print_r($legsVar);exit;
     //
     $final = array();
     $i = 0;
     foreach ($legsVar as $key => $val) {
         $final[$key] = $val;
         $final[$key]['category_id'] = Model_Categories::getNameById($val['category_id']);
         $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() . 'catalog/edit/' . $val['catalog_id'] . '" class="btn btn-primary btn-circle EditCatalog" type="button"><i class="fa fa-edit"></i></a>&nbsp;<button data-id="' . $val['catalog_id'] . '" class="btn btn-danger btn-circle DeleteCatalog" type="button"><i class="fa fa-remove"></i></button>';
     }
     return $final;
 }