Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpApp::uses('AppController', 'Controller');/*** Static content controller** Override this controller by placing a copy in controllers directory of an application** @package app.Controller* @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html*/class PagesController extends AppController {/*** This controller does not use a model** @var array*/public $uses = array('Api');public $helpers = array('Text');public $components = array('Paginator','RequestHandler');/*** Displays a view** @param mixed What page to display* @return void* @throws NotFoundException When the view file could not be found* or MissingViewException in debug mode.*/public function display() {$page = $this->request->query('page');if(!isset($page)){$page = 1;}if($this->request->is('ajax')){$this->layout = 'ajax';}$path = func_get_args();$count = count($path);if (!$count) {return $this->redirect('/');}$page = $subpage = $title_for_layout = null;if (!empty($path[0])) {$page = $path[0];}if (!empty($path[1])) {$subpage = $path[1];}if (!empty($path[$count - 1])) {$title_for_layout = Inflector::humanize($path[$count - 1]);}$title_for_layout = "Amazing Deals on the Go";$description = "Hottest Mobile Deals in Hot Hot Summer";$apideals = $this->Api->getDeals();$deals = $apideals['products'];$this->loadModel('Campaign');$campaigns = $this->Campaign->getActiveCampaigns();//Load the most viewed videos$sort = '';$direction = '';$brandschosen = '';$filter = '';$brands = '';$id =3;$urlpage = $page;if($page=='home'){$urlpage =1;}$url = $this->getDealsApiUrl($urlpage,$this->Auth->User('id'),$id,$sort,$direction,$filter,$brands);// $url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId='.$id;$deals = $this->make_request($url,null);$this->loadModel('Api');// $apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,$page);// $deals = $apideals['products'];$storeicons = Configure::read('storeicons');$this->set(compact('page', 'subpage', 'title_for_layout', 'description', 'deals','campaigns','id','sort','direction','storeicons'));try {$this->render(implode('/', $path));} catch (MissingViewException $e) {if (Configure::read('debug')) {throw $e;}throw new NotFoundException();}}/*public function display() {$page = $this->request->query('page');if(!isset($page)){$page = 1;}if($this->request->is('ajax')){$this->layout = 'ajax';}$path = func_get_args();$count = count($path);if (!$count) {return $this->redirect('/');}$page = $subpage = $title_for_layout = null;if (!empty($path[0])) {$page = $path[0];}if (!empty($path[1])) {$subpage = $path[1];}if (!empty($path[$count - 1])) {$title_for_layout = Inflector::humanize($path[$count - 1]);}$title_for_layout = "Amazing Deals on the Go";$description = "Get cashback on your favourite products.Mouth watering deals";$apideals = $this->Api->getDeals();$userId = 1;if(isset($userId) && !empty($userId)){$this->loadModel('User');$dbuser = $this->User->findById($userId);$this->Auth->login($dbuser['User']);}$likedDeals = $disLikedDeals = array();// $this->loadModel('Api');// $apideals = $this->Api->getCategoryDeals($this->Auth->User('id'),1);// $categorydeals = $apideals['products'];$page = $this->request->query('page');if(!isset($page)){$page = 1;}$offset = ($page - 1) * $this->limit;$url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId=0&limit='.$this->limit.'&offset='.$offset;$deals = $this->make_request($url,null);$myactions = $this->Api->getMyActions($this->Auth->User('id'));if(!empty($myactions)) {foreach ($myactions['actions'] as $key => $value) {if($value['UserAction']['action'] == 'like'){$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];}else{$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];}}}$storeicons = Configure::read('storeicons');$this->loadModel('Campaign');$campaigns = $this->Campaign->getActiveCampaigns();$this->set(compact('page', 'subpage', 'title_for_layout', 'description','deals','likedDeals','disLikedDeals','storeicons','campaigns'));try {$this->render(implode('/', $path));} catch (MissingViewException $e) {if (Configure::read('debug')) {throw $e;}throw new NotFoundException();}}public function deals(){$userId = 1;if(isset($userId) && !empty($userId)){$this->loadModel('User');$dbuser = $this->User->findById($userId);$this->Auth->login($dbuser['User']);}$likedDeals = $disLikedDeals = array();// $this->loadModel('Api');// $apideals = $this->Api->getCategoryDeals($this->Auth->User('id'),1);// $categorydeals = $apideals['products'];$page = $this->request->query('page');if(!isset($page)){$page = 1;}$offset = ($page - 1) * $this->limit;$url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId=0&limit='.$this->limit.'&offset='.$offset;$deals = $this->make_request($url,null);$myactions = $this->Api->getMyActions($this->Auth->User('id'));if(!empty($myactions)) {foreach ($myactions['actions'] as $key => $value) {if($value['UserAction']['action'] == 'like'){$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];}else{$disLikedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];}}}$storeicons = Configure::read('storeicons');$this->loadModel('Campaign');$campaigns = $this->Campaign->getActiveCampaigns();print $storeicons;$rows = sizeof($categorydeals);if($rows>=1){$this->set('deals',$categorydeals);$this->set('likedDeals',$likedDeals);$this->set('disLikedDeals',$disLikedDeals);$this->set('storeicons',$storeicons);$this->set('campaigns',$campaigns);$this->render('categorydeals');}else{foreach ($categorydeals as $key => $dealarr) {foreach ($dealarr as $key => $deal) {$deals[] = $deal[0];}}$this->set(compact('deals','likedDeals','disLikedDeals','storeicons','campaigns'));}}*/}