1
<?php
2
/*
3
  Belokan Micro Framework
4
  Licensed under GNU GPL
5
  http://gitorious.org/belokan
6
  ---
7
  Belokan/Controller.php:
8
  Controlle system
9
*/
10
11
class Belokan_Controller {
12
13
  public
14
    $_view;
15
16
  private
17
    $_layout,
18
    $_controller,
19
    $_action,
20
    $_data;
21
22
  public function __construct ($controller, $action)
23
  {
24
    $this->_view = new Belokan_View;
25
    $this->_layout = 'default';
26
    $this->_controller = strtolower($controller);
27
    $this->_action = strtolower($action);
28
    $this->_data = array();
29
  }
30
31
  public function __get ($var)
32
  {
33
    if (isset($this->_data[$var])) return $this->_data[$var];
34
    else return null;
35
  }
36
37
  public function __set ($var, $value)
38
  {
39
    return $this->_data[$var] = $value;
40
  }
41
42
  public function __isset ($var)
43
  {
44
    return isset($this->_data[$var]);
45
  }
46
47
  public function __unset ($var)
48
  {
49
    unset($this->_data[$var]);
50
  }
51
52
  public function setLayout ($layout_name)
53
  {
54
    $this->_layout = $layout_name;
55
  }
56
57
  public function getLayout ()
58
  {
59
    return $this->_layout;
60
  }
61
62
  public function setView ($view)
63
  {
64
    $view = strtolower($view);
65
    if (strpos($view, '/')) {
66
      $view = explode('/', $view);
67
      $this->_controller = $view[0];
68
      $this->_action = $view[1];
69
    } else $this->_action = $view;
70
  }
71
72
  public function setFormat ($format)
73
  {
74
    $this->_view->setFormat($format);
75
  }
76
77
  public function getView ()
78
  {
79
    return $this->_controller.'/'.$this->_action;
80
  }
81
82
  public function _pre_action ()
83
  {
84
    return;
85
  }
86
87
  public function _post_action ()
88
  {
89
    return;
90
  }
91
92
  public function _pre_view ()
93
  {
94
    return;
95
  }
96
97
  public function _post_view ()
98
  {
99
    return;
100
  }
101
102
  public function _post_render ()
103
  {
104
    return;
105
  }
106
107
}