Public Member Functions | |
| __construct (mosRequest &$request, mosRenderer &$renderer, $commandname='command') | |
| run () | |
| forward ($command) | |
| setCommand ($command) | |
| setView ($viewname) | |
| redirect ($url) | |
Private Attributes | |
| $commandname | |
| $command | |
| $view | |
| $request | |
| $renderer | |
Definition at line 9 of file mosRenderer.php.
| mosController::__construct | ( | mosRequest &$ | request, | |
| mosRenderer &$ | renderer, | |||
| $ | commandname = 'command' | |||
| ) |
Constructor.
| object | $request - A reference to a request object | |
| object | $renderer - A reference to a renderer object | |
| string | $commandname - the name of the $_REQUEST variable containing the command name |
Definition at line 50 of file mosRenderer.php.
References $commandname.
00051 { 00052 $this->request =& $request; 00053 $this->renderer =& $renderer; 00054 $this->commandname = $commandname; 00055 }
| mosController::run | ( | ) |
Forwards the request to the correct command from the request or the default command, Then forwards to a view.
Definition at line 62 of file mosRenderer.php.
References $_REQUEST, $command, forward(), and setView().
00063 { 00064 $command = $this->request->getParam($_REQUEST, $this->commandname, 'default'); 00065 $this->forward($command); 00066 // get the view from the command 00067 $this->setView($this->command->getView()); 00068 $this->view->render($this->request, $this->renderer); 00069 }
| mosController::forward | ( | $ | command | ) |
sets the current command object and calls its execute method
| unknown_type | $command |
Definition at line 76 of file mosRenderer.php.
References $command, and setCommand().
Referenced by run().
00077 { 00078 $this->setCommand($command); 00079 $this->command->execute($this, $this->request); 00080 }
| mosController::setCommand | ( | $ | command | ) |
Instantiates the command class and sets the current command property. The command classes must extend the Command class and must follow a naming convention. eg. the 'addUser' command class must be named 'addUserCommand'
| string | $command |
Definition at line 90 of file mosRenderer.php.
References $command.
Referenced by forward().
00091 { 00092 $commandclass = $command.'Command'; 00093 // instantiate the command class 00094 if (class_exists($commandclass)) { 00095 $this->command = new $commandclass(); 00096 } else { 00097 return trigger_error("Command class '$commandclass' not found.", E_USER_ERROR); 00098 } 00099 }
| mosController::setView | ( | $ | viewname | ) |
Instantiates the view class and sets the current view property The view classes must extend the View class and must follow a naming convention. The view is also associated to the command that sets it. eg. the form view for the 'addUser' command class must be named 'form_addUserView'
| string | $viewname - the view name st by the command |
Definition at line 109 of file mosRenderer.php.
References $commandname.
Referenced by run().
00110 { 00111 $commandname = substr(get_class($this->command), 0, -7); 00112 $viewclass = $viewname.'View'; 00113 if (class_exists($viewclass)) { 00114 $this->view = new $viewclass(); 00115 } else { 00116 return trigger_error("View class '$viewclass' not found.", E_USER_ERROR); 00117 } 00118 }
| mosController::redirect | ( | $ | url | ) |
Helper function to redirect the user request. useful for cases where we don't want the user to resend a form
| unknown_type | $url |
Definition at line 125 of file mosRenderer.php.
00126 { 00127 if (headers_sent()) { 00128 echo "<script>document.location.href='$url';</script>"; 00129 } else { 00130 if (ob_get_contents()) while (@ob_end_clean()); // clear output buffer if one exists 00131 header( "Location: $url" ); 00132 } 00133 exit; 00134 }
mosController::$commandname [private] |
mosController::$command [private] |
mosController::$view [private] |
Definition at line 28 of file mosRenderer.php.
mosController::$request [private] |
Definition at line 34 of file mosRenderer.php.
mosController::$renderer [private] |
Definition at line 40 of file mosRenderer.php.
1.5.5