[geeklog-cvs] MVCnPHP Controller.class.php,1.1.1.1,1.2
geeklog-cvs-admin at lists.geeklog.net
geeklog-cvs-admin at lists.geeklog.net
Wed Apr 9 11:28:53 EDT 2003
Update of /usr/cvs/geeklog/MVCnPHP
In directory internal.geeklog.net:/tmp/cvs-serv20973
Modified Files:
Controller.class.php
Log Message:
Updated some documentation and added _clearMessages() method.
Index: Controller.class.php
===================================================================
RCS file: /usr/cvs/geeklog/MVCnPHP/Controller.class.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Controller.class.php 5 Apr 2003 20:00:52 -0000 1.1.1.1
--- Controller.class.php 9 Apr 2003 15:28:51 -0000 1.2
***************
*** 45,49 ****
* This class controls processing for the program
* indiscriminately. The focus is always on the underlying
! * views or commands
*
* @author Tony Bibbs <tony at geeklog.net>
--- 45,56 ----
* This class controls processing for the program
* indiscriminately. The focus is always on the underlying
! * views or commands. This class allows you to store application
! * messages such as status messages (e.g. something was saved
! * successfully) or error messages from failed validation or
! * security reasons. By default these are stored in the $_SESSION
! * superglobal in $_SESSION['MVC_MESSAGE'] and $_SESSION['MVC_ERRORS']
! * respectively (note: the later is an array). If your application is
! * not using PHP4 sessions you will want to follow the directions given
! * in the documentation for Controller::_clearMessages
*
* @author Tony Bibbs <tony at geeklog.net>
***************
*** 134,139 ****
function Controller($configData, $configType = MVC_XML, $allowedFormMethod = MVC_BOTH)
{
! unset($_SESSION[MVC_MESSAGE]);
! unset($_SESSION[MVC_ERRORS]);
switch ($allowedFormMethod) {
case MVC_GET:
--- 141,146 ----
function Controller($configData, $configType = MVC_XML, $allowedFormMethod = MVC_BOTH)
{
! $this->_clearMessages();
!
switch ($allowedFormMethod) {
case MVC_GET:
***************
*** 169,173 ****
{
if (!is_dir($path)) {
! echo 'bad path in Controller::setMVCBase';
exit;
}
--- 176,180 ----
{
if (!is_dir($path)) {
! trigger_error('bad path in Controller::setMVCBase');
exit;
}
***************
*** 245,249 ****
}
if ($this->_mapping->getType() == 'view') {
! require_once('ViewFactory.class.php');
$view = &ViewFactory::getView($this->_mapping->getPath(), $this->_mapping->getName());
$retval = $view->getView();
--- 252,256 ----
}
if ($this->_mapping->getType() == 'view') {
! require_once 'ViewFactory.class.php';
$view = &ViewFactory::getView($this->_mapping->getPath(), $this->_mapping->getName());
$retval = $view->getView();
***************
*** 255,259 ****
}
} else {
! require_once('CommandFactory.class.php');
$tmp = &CommandFactory::getCommand($this->_mapping->getPath(), $this->_mapping->getName());
$strForward = $tmp->execute();
--- 262,266 ----
}
} else {
! require_once 'CommandFactory.class.php';
$tmp = &CommandFactory::getCommand($this->_mapping->getPath(), $this->_mapping->getName());
$strForward = $tmp->execute();
***************
*** 263,269 ****
/**
* Ensures only supported methods are used
*
! * @author Tony Bibbs
* @access private
*
--- 270,295 ----
/**
+ * Clears any existing errors or messages
+ *
+ * This method assumes the application is using PHP4 sessions
+ * to store MVC errors and messages. If that is not the case,
+ * the application should create a new class that extends this
+ * controller and override this function to clear the messages
+ * in the way desired.
+ *
+ * @author Tony Bibs <tony at geeklog.net>
+ * @access private
+ *
+ */
+ function _clearMessages()
+ {
+ unset($_SESSION[MVC_MESSAGE]);
+ unset($_SESSION[MVC_ERRORS]);
+ }
+
+ /**
* Ensures only supported methods are used
*
! * @author Tony Bibbs <tony at geeklog.net>
* @access private
*
***************
*** 275,284 ****
case MVC_GET:
if (count($_POST) > 0) {
! echo 'POST method is not supported by this controller';
exit;
}
case MVC_POST:
if (count($_GET) > 0) {
! echo 'GET method is not supported by this controller';
exit;
}
--- 301,310 ----
case MVC_GET:
if (count($_POST) > 0) {
! trigger_error('POST method is not supported by this controller');
exit;
}
case MVC_POST:
if (count($_GET) > 0) {
! trigger_error('GET method is not supported by this controller');
exit;
}
More information about the geeklog-cvs
mailing list