forked from croogo/croogo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_controller.php
143 lines (137 loc) · 3.04 KB
/
app_controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/**
* Application controller
*
* This file is the base controller of all other controllers
*
* PHP version 5
*
* @category Controllers
* @package Croogo
* @version 1.0
* @author Fahad Ibnay Heylaal <contact@fahad19.com>
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @link http://www.croogo.org
*/
class AppController extends Controller {
/**
* Components
*
* @var array
* @access public
*/
public $components = array(
'Croogo',
'Security',
'Acl',
'Auth',
'Acl.AclFilter',
'Session',
'RequestHandler',
);
/**
* Helpers
*
* @var array
* @access public
*/
public $helpers = array(
'Html',
'Form',
'Session',
'Text',
'Js',
'Time',
'Layout',
'Custom',
);
/**
* Models
*
* @var array
* @access public
*/
public $uses = array(
'Block',
'Link',
'Setting',
'Node',
);
/**
* Cache pagination results
*
* @var boolean
* @access public
*/
public $usePaginationCache = true;
/**
* View
*
* @var string
* @access public
*/
public $view = 'Theme';
/**
* Theme
*
* @var string
* @access public
*/
public $theme;
/**
* Constructor
*
* @access public
*/
public function __construct() {
Croogo::applyHookProperties('Hook.controller_properties');
parent::__construct();
if ($this->name == 'CakeError') {
$this->_set(Router::getPaths());
$this->params = Router::getParams();
$this->constructClasses();
$this->Component->initialize($this);
$this->beforeFilter();
$this->Component->triggerCallback('startup', $this);
}
}
/**
* beforeFilter
*
* @return void
*/
public function beforeFilter() {
$this->AclFilter->auth();
$this->RequestHandler->setContent('json', 'text/x-json');
$this->Security->blackHoleCallback = '__securityError';
if (isset($this->params['admin'])) {
$this->layout = 'admin';
}
if ($this->RequestHandler->isAjax()) {
$this->layout = 'ajax';
}
if (Configure::read('Site.theme') && !isset($this->params['admin'])) {
$this->theme = Configure::read('Site.theme');
} elseif (Configure::read('Site.admin_theme') && isset($this->params['admin'])) {
$this->theme = Configure::read('Site.admin_theme');
}
if (!isset($this->params['admin']) &&
Configure::read('Site.status') == 0) {
$this->layout = 'maintenance';
$this->set('title_for_layout', __('Site down for maintenance', true));
$this->render('../elements/blank');
}
if (isset($this->params['locale'])) {
Configure::write('Config.language', $this->params['locale']);
}
}
/**
* blackHoleCallback for SecurityComponent
*
* @return void
*/
public function __securityError() {
$this->cakeError('securityError');
}
}
?>