Пример #1
0
 /**
  * 
  * @param string $type image type
  * @return orm object
  * 
  * @access public
  * @author Dao Anh Minh
  */
 public static function get_img($type)
 {
     $img = Model_Img::query()->where('type', $type)->where('active', true);
     if ($type == IMG_GALLERY) {
         // return multi images
         return $img->get();
     } else {
         // return one image
         return $img->get_one();
     }
 }
Пример #2
0
 /**
  * Display home index page
  *
  * @access public
  * @author Nguyen Van Hiep
  *
  * @version 1.0
  * @since 1.0
  */
 public function action_index()
 {
     $view = View::forge('customer/home/home');
     $view->cats = Model_Categories::get_cats_home($this->lang);
     $view->pepper_arts = Model_Article::pepper_artilces($this->lang);
     // prepare images
     $this->template->background = Model_Img::get_img(IMG_MAIN_BG);
     $this->template->main_logo = Model_Img::get_img(IMG_LOGO);
     $this->template->circle_logo = Model_Img::get_img(IMG_OLOGO);
     $view->gallery = Model_Img::get_img(IMG_GALLERY);
     $view->cat_id = Input::post('cat_id') ? Input::post('cat_id') : null;
     $this->template->title = __('common.home');
     $this->template->error = array();
     $this->template->contact_data = array('mail_yourname' => '', 'mail_address' => '', 'mail_message' => '');
     $this->template->content = $view;
 }
Пример #3
0
 /**
  * display access denied page
  *
  * @access public
  * @author Dao Anh Minh
  */
 public function action_error()
 {
     $view = View::forge('common/error');
     $this->template->background = Model_Img::get_img(IMG_MAIN_BG);
     $this->template->main_logo = Model_Img::get_img(IMG_LOGO);
     $this->template->circle_logo = Model_Img::get_img(IMG_OLOGO);
     $this->template->title = __('title.page_403');
     $this->template->content = $view;
 }
Пример #4
0
 /**
  * Edit image in gallery
  *
  * @param integer $img_id
  *
  * @access public
  * @author Dao Anh Minh
  */
 public function action_edit($img_id = null)
 {
     $view = View::forge('admin/gallery/edit');
     $view->img_info = Model_Img::find($img_id);
     if (empty($view->img_info)) {
         Session::set_flash('error', 'Hình ảnh không tồn tại');
         Response::redirect('admin/gallery');
     }
     if (Input::method() == 'POST') {
         $view->img_info->info = serialize(array('info' => Input::post('desc', '')));
         $view->img_info->active = Input::post('active', false);
         $view->img_info->save();
         Session::set_flash('success', 'Sửa thành công');
         Response::redirect('admin/gallery');
     }
     $view->desc = unserialize($view->img_info->info)['info'];
     $this->template->content = $view;
 }
Пример #5
0
 /**
  * Register background
  * 
  * @param integer $logo_id
  * 
  * @access public
  * @author Dao Anh Minh
  */
 public function action_register()
 {
     $view = View::forge('admin/mainlogo/register');
     $view->err = array();
     if (Input::method() == 'POST') {
         if (count(Input::file()) == 0) {
             Session::set_flash('error', 'Chưa chọn hình');
             Response::redirect('admin/mainlogo/register');
         }
         Upload::process($this->config);
         if (Upload::is_valid()) {
             Upload::save();
         } else {
             Session::set_flash('error', 'Chỉ chấp nhận file hình');
             Response::redirect('admin/mainlogo/register');
         }
         $file_name = Upload::get_files(0)['saved_as'];
         if (!empty($file_name)) {
             $img = Model_Img::forge();
             $active = Input::post('active', false);
             if ($active != false) {
                 // update all background images to non-active
                 Model_Img::query()->where('type', IMG_LOGO)->set('active', false)->update();
             }
             $img->name = $file_name;
             $img->active = $active;
             $img->type = IMG_LOGO;
             $img->info = null;
             $img->save();
             Session::set_flash('success', 'Đăng ký logo thành công');
             Response::redirect('admin/mainlogo');
         } else {
             Session::set_flash('error', 'Có lỗi xảy ra, vui lòng thử lại');
             Response::redirect('admin/mainlogo');
         }
     }
     $this->template->title = 'Đăng ký logo chính';
     $this->template->content = $view;
 }