Subversion Repositories SmartDukaan

Rev

Rev 13570 | 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() {
13571 anikendra 32
		$page = $this->request->query('page');
33
		if(!isset($page)){
34
			$page = 1;
35
		}
13532 anikendra 36
		if($this->request->is('ajax')){
37
			$this->layout = 'ajax';
38
		}
39
		$path = func_get_args();
40
 
41
		$count = count($path);
42
		if (!$count) {
43
			return $this->redirect('/');
44
		}
45
		$page = $subpage = $title_for_layout = null;
46
 
47
		if (!empty($path[0])) {
48
			$page = $path[0];
49
		}
50
		if (!empty($path[1])) {
51
			$subpage = $path[1];
52
		}
53
		if (!empty($path[$count - 1])) {
54
			$title_for_layout = Inflector::humanize($path[$count - 1]);
55
		}
56
		$title_for_layout = "Get Cashback on favourite";
57
		$description = "Get cashback on your favourite products.Mouth watering deals";
13565 anikendra 58
		$apideals = $this->Api->getDeals();
59
		$deals = $apideals['products'];
13532 anikendra 60
		//Load the most viewed videos
13565 anikendra 61
		$this->set(compact('page', 'subpage', 'title_for_layout', 'description', 'deals'));
13532 anikendra 62
		try {
63
			$this->render(implode('/', $path));
64
		} catch (MissingViewException $e) {
65
			if (Configure::read('debug')) {
66
				throw $e;
67
			}
68
			throw new NotFoundException();
69
		}
70
	}
71
}