Esempio n. 1
0
 public function action_index()
 {
     $language_id = Model_Languages::getLangIdByAbbr($this->current_lang);
     $catalogs = Model_Catalogs::listAll(2, $language_id);
     $view = $this->template->content = View::factory('songs')->set('lang', $this->current_lang)->set('catalogs', $catalogs);
     $this->response->body($view);
 }
Esempio n. 2
0
    public static function selectCatalogs($category_id, $language_id, $catalog_id = null)
    {
        $catalogs = Model_Catalogs::getAllSelect($category_id, $language_id);
        //
        foreach ($catalogs as $catalog) {
            if ($catalog_id == $catalog['catalog_id']) {
                ?>
            <option value="<?php 
                echo $catalog['catalog_id'];
                ?>
" selected><?php 
                echo $catalog['name'];
                ?>
</option>
            <?php 
            } else {
                ?>
            <option value="<?php 
                echo $catalog['catalog_id'];
                ?>
"><?php 
                echo $catalog['name'];
                ?>
</option>
        <?php 
            }
        }
    }
Esempio n. 3
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;
 }
Esempio n. 4
0
 public function action_new()
 {
     $this->template->show_logout = TRUE;
     $this->template->title = 'Catalog::New';
     $view = $this->template->content = View::factory('catalog/new');
     $error_message = NULL;
     $filename = NULL;
     $pk = FALSE;
     if ($this->request->method() == Request::POST) {
         if (isset($_FILES['image_name'])) {
             $filename = $this->_save_image($_FILES['image_name']);
         }
         //
         $catalogArr = array('name' => $_POST['name'], 'category_id' => $_POST['category_id'], 'image_name' => $_FILES['image_name']['name'], 'language_id' => $_POST['category_id'], 'user_id' => Auth::instance()->get_user()->id, 'agegroup_id' => $_POST['agegroup_id'], 'date_added' => time(), 'is_public' => $_POST['is_public']);
         //
         $pk = Model_Catalogs::addCatalog($catalogArr);
     }
     if (!$filename) {
         $error_message = 'There was a problem while uploading the image.
                 Make sure it is uploaded and must be JPG/PNG/GIF file.';
     }
     if ($pk) {
         $this->redirect('catalog/edit/' . $pk);
     }
     $view->uploaded_file = $filename;
     $view->error_message = $error_message;
     $this->response->body($view);
 }