Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
13532 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
 
4
/**
5
 * Static content controller
6
 *
7
 * Override this controller by placing a copy in controllers directory of an application
8
 *
9
 * @package       app.Controller
10
 * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
11
 */
12
class PagesController extends AppController {
13
 
14
/**
15
 * This controller does not use a model
16
 *
17
 * @var array
18
 */
13565 anikendra 19
	public $uses = array('Api');
13567 anikendra 20
	public $helpers = array('Text');
13532 anikendra 21
 
22
	public $components = array('Paginator','RequestHandler');
23
/**
24
 * Displays a view
25
 *
26
 * @param mixed What page to display
27
 * @return void
28
 * @throws NotFoundException When the view file could not be found
29
 *	or MissingViewException in debug mode.
30
 */
31
	public function display() {
13570 anikendra 32
		$page = isset($this->request->query('page'))?$this->request->query('page'):1;
13532 anikendra 33
		if($this->request->is('ajax')){
34
			$this->layout = 'ajax';
35
		}
36
		$path = func_get_args();
37
 
38
		$count = count($path);
39
		if (!$count) {
40
			return $this->redirect('/');
41
		}
42
		$page = $subpage = $title_for_layout = null;
43
 
44
		if (!empty($path[0])) {
45
			$page = $path[0];
46
		}
47
		if (!empty($path[1])) {
48
			$subpage = $path[1];
49
		}
50
		if (!empty($path[$count - 1])) {
51
			$title_for_layout = Inflector::humanize($path[$count - 1]);
52
		}
53
		$title_for_layout = "Get Cashback on favourite";
54
		$description = "Get cashback on your favourite products.Mouth watering deals";
13565 anikendra 55
		$apideals = $this->Api->getDeals();
56
		$deals = $apideals['products'];
13532 anikendra 57
		//Load the most viewed videos
13565 anikendra 58
		$this->set(compact('page', 'subpage', 'title_for_layout', 'description', 'deals'));
13532 anikendra 59
		try {
60
			$this->render(implode('/', $path));
61
		} catch (MissingViewException $e) {
62
			if (Configure::read('debug')) {
63
				throw $e;
64
			}
65
			throw new NotFoundException();
66
		}
67
	}
68
}