Exemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     $this->context = Context::getContext();
     $aResponse['error'] = false;
     $aResponse['message'] = '';
     if (isset($_POST['action'])) {
         $id_video = $_POST['idBox'];
         $ratting = $_POST['rate'];
         if (VideosRatting::checkRatting($id_video)) {
             $videosRatting = new VideosRatting();
             $videosRatting->add(array('id_video' => $id_video, 'ratting' => $ratting));
             $aResponse['error'] = FALSE;
             $aResponse['message'] = 'Your rate has been successfuly recorded. Thanks for your rate';
         } else {
             $aResponse['error'] = true;
             $aResponse['message'] = 'Your have rated for images';
         }
     } else {
         $aResponse['error'] = true;
         $aResponse['message'] = 'An error occured during the request. Please retry';
     }
     echo json_encode($aResponse);
     die;
 }
Exemplo n.º 2
0
 public function displayList()
 {
     $id_lang = $this->context->language->id;
     $id_shop = $this->context->shop->id;
     $limit_per_page = intval($this->conf['list_limit_page']);
     $current_page = isset($_GET['p']) && is_numeric($_GET['p']) ? intval($_GET['p']) : 1;
     $start = ($current_page - 1) * $limit_per_page;
     $list = VideoCategory::getCategories();
     $listCategories = array();
     if (isset($list) && is_array($list) && count($list)) {
         /** pagination * */
         //            $nb_pages = ceil($nb_articles / $limit_per_page);
         //            $next = $current_page > 1 ? true : false; //articles plus recents
         //            $back = $current_page >= 1 && ($current_page < $nb_pages) ? true : false; //articles precedents
         $i = 0;
         foreach ($list as $cat) {
             $videos = Videos::getVideoByCategory($cat['id_video_cat']);
             $list_video = array();
             foreach ($videos as $key => $val) {
                 $video = $val;
                 $video['average'] = VideosRatting::getAverage($val['id_video']);
                 $list_video[] = $video;
             }
             $cat['videos'] = $list_video;
             $listCategories[] = $cat;
         }
         //            echo '<pre>';
         //            print_r($listCategories);
         //            echo '</pre>';
         $this->context->smarty->assign(array('list_categories' => $listCategories, 'img_video_dir' => _THEME_VIDEO_DIR_, 'customer' => $this->context->customer->id));
     }
     $this->setTemplate('list.tpl');
 }