__construct()
34: function __construct() {
36: $this->detect_iphone();
37:
39: $this->collect_methods(DIR_CONTROLLERS . '/support');
41: $this->controller = $this;
43: $this->controller_name = strtolower(substr(get_class($this), 0, -10));
44:
46: $this->initialize_plugins();
47:
48: }
File: lib/controller/controller.php, #line 34
initialize_plugins()
50: function initialize_plugins() {
51: if (is_dir(DIR_VENDOR . '/plugins')) {
52: $dh = dir(DIR_VENDOR . '/plugins');
54: while ($entry = $dh->read()) {
56: if ($entry == '.' || $entry == '..' || $entry == '.svn')
57: continue;
58: $init = DIR_VENDOR . '/plugins/' . $entry . '/init.php';
59: if (is_file($init)) {
60: require_once $init;
61: }
62: }
63: }
64: }
File: lib/controller/controller.php, #line 50
include_plugin_methods($class)
66: function include_plugin_methods($class) {
67: if (class_exists($class) && $class) {
69: $this->plugin_methods = array_merge($this->plugin_methods, array_fill_keys(get_class_methods($class), "$class"));
70: }
71: }
File: lib/controller/controller.php, #line 66
create_helper()
78: function create_helper() {
79: $helper_file = DIR_APP_HELPERS . '/' . $this->localization . $this->controller_name . '_helper.php';
80: $helper_class = Inflector :: camelize($this->controller_name) . 'Helper';
81:
82: if (file_exists($helper_file)) {
83: require_once ($helper_file);
84: }
85:
86: if (class_exists($helper_class, false)) {
88: $this-> $helper_class = new $helper_class ();
89: }
90:
92: $this->app_methods = array_fill_keys(get_class_methods($helper_class), $helper_class);
93: }
File: lib/controller/controller.php, #line 78
collect_methods($path)
96: function collect_methods($path) {
97: $dh = dir($path);
98: while ($entry = $dh->read()) {
100: if (substr($entry, -4) != '.php')
101: continue;
103: $class = Inflector :: camelize(substr($entry, 0, -4));
105: if (class_exists($class)) {
107: $this->methods = array_merge($this->methods, array_fill_keys(get_class_methods($class), "$class"));
108: }
109: }
110: }
File: lib/controller/controller.php, #line 96
register_helper($class)
117: function register_helper($class) {
118: if (class_exists($class)) {
120: $this->methods = array_merge($this->methods, array_fill_keys(get_class_methods($class), "$class"));
121: }
122: }
File: lib/controller/controller.php, #line 117
page()
124: function page() {
125:
127: $this->create_helper();
128:
132: $this->Page = new PrototypeHelper();
133:
134: ob_start();
135:
137: $this->before_filter();
138:
140: $class_methods = get_class_methods(get_class($this));
141:
143: if (in_array($this->action, $class_methods)) {
144: call_user_func(array (
145: $this,
146: $this->action
147: ));
148: }
149:
151: foreach ($this as $key => $value) {
152: if (!preg_match('/^_/', $key)) {
153: $$key = $value;
154: }
155: }
156:
158: $this->content = ob_get_contents();
159:
160: ob_end_clean();
161:
163: if ($this->load_content) {
164: $this->load_content();
165: }
166:
168: if ($this->layout) {
169: $this->load_layout();
170: }
171:
173: $_SESSION['flash'] = array ();
174: }
File: lib/controller/controller.php, #line 124
load_content()
176: function load_content() {
177: ob_start();
181: foreach ($this as $key => $value) {
182: if (!preg_match('/^_/', $key)) {
183: $$key = $value;
184: }
185: }
186:
187: $ajax_content = $this->Page->get_prototype_content();
189:
191: if (!empty ($ajax_content)) {
192: $this->layout = false;
194: header('Content-Type: text/javascript; charset=utf-8');
195: print $ajax_content;
196: }
197:
199: if ($this->render_action) {
200: if (is_file($file = DIR_APP_VIEWS . '/' . $this->localization . strtolower($this->controller_name) . '/' . $this->action . '.pjs')) {
201: include $file;
202: }
203: elseif (is_file($file = DIR_APP_VIEWS . '/' . $this->localization . strtolower($this->controller_name) . '/' . $this->action . '.phtml')) {
204: include $file;
205: } else {
206: if (empty ($this->content) && empty ($ajax_content)) {
207: trigger_error('view file ' . $file . ' doesn't exist.', E_USER_ERROR);
208: }
209: }
210:
212: $this->content .= ob_get_contents();
213: ob_end_clean();
214:
216: if ($this->inner_layout) {
217: ob_start();
218: $content_for_inner_layout = $this->content;
219: include (DIR_VIEWS . 'layouts/' . $this->inner_layout . '.phtml');
220: $this->content = ob_get_contents();
221: ob_end_clean();
222: }
223: }
224: }
File: lib/controller/controller.php, #line 176
get_content()
246: function get_content() {
247: return $this->content;
248: }
File: lib/controller/controller.php, #line 246
before_filter()
254: function before_filter() {
255: if (isset ($this->before_filter)) {
256: foreach ($this->before_filter as $method => $actions) {
257: if (is_array($actions)) {
258: if (isset ($actions['except'])) {
259: $actions = explode(',', $actions['except']);
260: if (!in_array($this->action, $actions)) {
261: call_user_func(array (
262: $this,
263: $method
264: ));
265: }
266: }
267: elseif (isset ($actions['only'])) {
268: $actions = explode(',', $actions['only']);
269: if (in_array($this->action, $actions)) {
270: call_user_func(array (
271: $this,
272: $method
273: ));
274: }
275: } else {
276: call_user_func(array (
277: $this,
278: $method
279: ));
280: }
281: } else {
282: $actions = explode(',', $actions);
283: foreach ($actions as $method) {
284: call_user_func(array (
285: $this,
286: $method
287: ));
288: }
289: }
290: }
291: }
292: }
File: lib/controller/controller.php, #line 254
field_error($param)
300: public function field_error($param) {
301: $table_name = split('/', $param);
302: if (is_object($this-> $table_name[0])) {
303: return $this-> $table_name[0]->field_error[$param];
304: }
305: }
File: lib/controller/controller.php, #line 300
render($options = array ())
311: function render($options = array ()) {
313: foreach ($this->controller as $key => $value) {
314: if (!preg_match('/^_/', $key)) {
315: $this-> $key = $value;
316: }
317: }
318:
319: if (isset ($options['action'])) {
320: $this->action = $options['action'];
321: }
322: elseif (isset ($options['partial']) && !isset ($options['ajax'])) {
323: include $this->partial_localization($options['partial']);
324: }
325: elseif (isset ($options['partial']) && isset ($options['ajax'])) {
326: return addslashes($this->render_to_string($options['partial']));
327: }
328: elseif ($options['nothing']) {
329: $this->render_action = false;
330: }
331:
332: foreach ($this as $key => $value) {
333: if (!preg_match('/^_/', $key)) {
334: $this->controller-> $key = $value;
335: }
336: }
337: }
File: lib/controller/controller.php, #line 311
render_partial($partial)
342: function render_partial($partial) {
343: return $this->render(array (
344: 'partial' => $partial
345: ));
346: }
File: lib/controller/controller.php, #line 342
render_to_string($partial)
351: function render_to_string($partial) {
352: foreach ($this->controller as $key => $value) {
353: if (!preg_match('/^_/', $key)) {
354: $this-> $key = $value;
355: }
356: }
357:
358: ob_start();
359: include $this->partial_localization($partial);
360: $content = ob_get_contents();
362: ob_end_clean();
363:
364: foreach ($this as $key => $value) {
365: if (!preg_match('/^_/', $key)) {
366: $this->controller-> $key = $value;
367: }
368: }
369:
370: return $content;
371: }
File: lib/controller/controller.php, #line 351
render_component($options = array ())
405: function render_component($options = array ()) {
407: $class_name = ucwords($options['controller']) . 'Controller';
408:
410: $controller = new $class_name;
411: $controller->app_methods = $this->app_methods;
412:
414: $controller->controller_name = $options['controller'];
415:
417: $controller->params = $options;
418:
420: ob_start();
421:
422: # $controller-> {$options['action'] }();
423:
424: $action = $options['action'];
425: $controller-> $action();
426:
427: $content = ob_get_contents();
428: ob_end_clean();
429: return $content;
430: }
File: lib/controller/controller.php, #line 405
detect_iphone()
435: public function detect_iphone() {
437: if (!__config('iphone')) {
438: return;
439: }
440:
441: $container = $_SERVER['HTTP_USER_AGENT'];
442:
443: $browse = array (
444: "iPhone",
445: "iPod"
446: );
447:
448: foreach ($browse as $device) {
449: if (eregi($device, $container)) {
450: $this->iphone = true;
451: }
452: }
453:
454: if ($this->iphone) {
455: define("DIR_APP_VIEWS",APP_ROOT . '/app/iviews');
456: }
457: }
File: lib/controller/controller.php, #line 435
