Subversion Repositories SmartDukaan

Rev

Rev 13567 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
App::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 = isset($this->request->query('page'))?$this->request->query('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 = "Get Cashback on favourite";
                $description = "Get cashback on your favourite products.Mouth watering deals";
                $apideals = $this->Api->getDeals();
                $deals = $apideals['products'];
                //Load the most viewed videos
                $this->set(compact('page', 'subpage', 'title_for_layout', 'description', 'deals'));
                try {
                        $this->render(implode('/', $path));
                } catch (MissingViewException $e) {
                        if (Configure::read('debug')) {
                                throw $e;
                        }
                        throw new NotFoundException();
                }
        }
}