Example #1
0
 public function action_edit($img_id = 0)
 {
     $this->template->title = __("Thêm hình ảnh slide");
     $this->template->section_title = __("Thêm hình ảnh slide");
     $data = array();
     $img = ImageSlide::BLL()->find($img_id);
     if (!$img) {
         Message::error('Không tìm thấy hình ảnh');
         Request::instance()->redirect('/admin/slide/index');
     }
     if (Request::$method == "POST") {
         $post = $img->validate_update($_POST);
         if ($post->check()) {
             $post = $post->as_array();
             $img->src = $post['src'];
             $img->slide_position = $post['slide_position'];
             $img->url = $post['url'];
             $img->order = intval($post['order']);
             $img->User = Auth::instance()->get_user();
             $img->description = $post['description'];
             $img->save();
             Message::success('Cập nhập thông tin hình ảnh slide thành công!');
             Request::instance()->redirect('/admin/slide/by_pos/' . $img->slide_position . '.html');
         } else {
             $data['errors'] = $post->errors('admin/slide');
             $_POST = $post->as_array();
         }
     }
     $data['image'] = $img->toArray();
     $this->template->content = View::factory('admin/slide/edit', $data);
 }
Example #2
0
 public function action_slider_json($position = 0)
 {
     $this->auto_render = false;
     $img = ImageSlide::BLL()->get_all_front_by_pos($position);
     //echo $position;
     //print_r($img);
     $result = false;
     $data = array();
     if ($img) {
         $result = true;
         foreach ($img as $image) {
             if ($image['url'] != '#') {
                 $data['items'][] = '<a href="' . $image['url'] . '"><img src="' . $image['src'] . '"  width="350" height="210" alt="" title="' . $image['description'] . '"/></a>';
             } else {
                 $data['items'][] = '<img src="' . $image['src'] . '" width="350" height="210" alt="" title="' . $image['description'] . '"/>';
             }
         }
     }
     $data['result'] = $result;
     echo json_encode($data);
 }