Rev 29 | Rev 43 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 29 | Rev 30 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | * @var string
|
32 | * @var string
|
33 | */
|
33 | */
|
34 | protected $_defaultAction = 'index'; |
34 | protected $_defaultAction = 'index'; |
35 | 35 | ||
36 | /**
|
36 | /**
|
37 | * The {@link View} used by this controller
|
37 | * If an array, maps an action name to an action method of the controller.
|
- | 38 | *
|
|
- | 39 | * Fallback for IE 7 where the content of a <code>button</code> element
|
|
- | 40 | * is submitted as value.
|
|
38 | *
|
41 | *
|
- | 42 | * @var array
|
|
- | 43 | */
|
|
- | 44 | protected $_actionMap = null; |
|
- | 45 | ||
- | 46 | /**
|
|
- | 47 | * The {@link View} used by this controller
|
|
39 | * @var View
|
48 | * @var View
|
40 | */
|
49 | */
|
41 | protected $_view = null; |
50 | protected $_view = null; |
42 | 51 | ||
43 | /**
|
52 | /**
|
Line 48... | Line 57... | ||
48 | * View class. The default is <code>'View'</code>.
|
57 | * View class. The default is <code>'View'</code>.
|
49 | * @param string $template
|
58 | * @param string $template
|
50 | * Resource path of the template for the view. The default
|
59 | * Resource path of the template for the view. The default
|
51 | * is the empty string.
|
60 | * is the empty string.
|
52 | */
|
61 | */
|
53 | protected function __construct($viewClass = 'View', |
62 | protected function __construct($viewClass = 'View', $template = null) |
54 | $template = null) |
- | |
55 | {
|
63 | {
|
56 | $this->_view = new $viewClass($template); |
64 | $this->_view = new $viewClass($template); |
57 | 65 | ||
58 | Application::getInstance()->setCurrentController($this); |
66 | Application::getInstance()->setCurrentController($this); |
59 | 67 | ||
Line 63... | Line 71... | ||
63 | if ($action == null) |
71 | if ($action == null) |
64 | {
|
72 | {
|
65 | $action = $this->_defaultAction; |
73 | $action = $this->_defaultAction; |
66 | }
|
74 | }
|
67 | 75 | ||
68 | $this->{lcfirst($action) . 'Action'}(); |
76 | $actionMethod = lcfirst($action) . 'Action'; |
- | 77 | ||
- | 78 | /* Fallback for IE 7 where the content of a `button' element is submitted as value */
|
|
- | 79 | if (!method_exists($this, $actionMethod)) |
|
- | 80 | {
|
|
- | 81 | if (is_array($this->_actionMap) && array_key_exists($action, $this->_actionMap)) |
|
- | 82 | {
|
|
- | 83 | $actionMethod = $this->_actionMap[$action]; |
|
- | 84 | }
|
|
- | 85 | }
|
|
- | 86 | ||
- | 87 | $this->$actionMethod(); |
|
69 | }
|
88 | }
|
70 | 89 | ||
71 | /**
|
90 | /**
|
72 | * Assigns a value to a template variable (after this,
|
91 | * Assigns a value to a template variable (after this,
|
73 | * <var>$value</var> is available through
|
92 | * <var>$value</var> is available through
|