[geeklog-cvs] MVCnPHP mvcconfig-sample.xml,NONE,1.1 ArrayLoader.php,1.3,1.4 BaseLoader.php,1.3,1.4 BaseView.php,1.3,1.4 CommandFactory.php,1.3,1.4 CommandInterface.php,1.3,1.4 Constants.php,1.3,1.4 Controller.php,1.3,1.4 Form.php,1.3,1.4 LoaderFactory.php,1.3,1.4 Mapping.php,1.3,1.4 Validator.php,1.3,1.4 ViewFactory.php,1.3,1.4 ViewInterface.php,1.3,1.4 XMLLoader.php,1.3,1.4

tony at iowaoutdoors.org tony at iowaoutdoors.org
Thu Mar 17 00:08:40 EST 2005


Update of /var/cvs/MVCnPHP
In directory www:/tmp/cvs-serv8758

Modified Files:
	ArrayLoader.php BaseLoader.php BaseView.php CommandFactory.php 
	CommandInterface.php Constants.php Controller.php Form.php 
	LoaderFactory.php Mapping.php Validator.php ViewFactory.php 
	ViewInterface.php XMLLoader.php 
Added Files:
	mvcconfig-sample.xml 
Log Message:
Minor bug fixes, added .xsd support and added a sample mvc xml config


Index: BaseView.php
===================================================================
RCS file: /var/cvs/MVCnPHP/BaseView.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** BaseView.php	8 Mar 2005 05:12:27 -0000	1.3
--- BaseView.php	17 Mar 2005 05:08:37 -0000	1.4
***************
*** 19,26 ****
  */
  
  require_once 'ViewInterface.php';
  
  /**
! * Interface class for views
  *
  * @author Tony Bibbs <tony at geeklog.net>
--- 19,29 ----
  */
  
+ /**
+  * Defines the interface all views must implement
+  */
  require_once 'ViewInterface.php';
  
  /**
! * Abstract class for views
  *
  * @author Tony Bibbs <tony at geeklog.net>
***************
*** 36,39 ****
--- 39,94 ----
      
      /**
+      * Indicates if a view requires it is run under SSL
+      * @var boolean
+      * @access private
+      */
+     private $requiresSSL = false;
+     
+     /**
+      * Constructor
+      *
+      * Checks if SSL is required and if it is but fails the check it will throw an exception
+      *
+      * @author Tony Bibbs <tony at geeklog.net>
+      * @access public
+      * @throws Exception Throws an exception if the view fails the SSL check
+      *
+      */
+     public function __construct()    
+     {
+         if ($this->requiresSSL) {
+             if (!stristr($_ENV['SERVER_PROTOCOL'],'https')) {
+                 throw new Exception('View requires SSL');
+             }
+         }
+     }
+     
+     /**
+      * Sets whether or not SSL is required by the view
+      * 
+      * @author Tony Bibbs <tony at geeklog.net>
+      * @access public
+      * @param boolean $switch Indicator of whether or not SSL is required
+      * 
+      */
+     public function setSSLRequired($switch)
+     {
+         $this->requiresSSL = $switch;
+     }
+     
+     /**
+      * Gets whether or not SSL is required
+      *
+      * @author Tony Bibbs <tony at geeklog.net>
+      * @access public
+      * @return boolean Whether or note the view requires SSL
+      *
+      */
+     public function getSSLRequired()
+     {
+         return $this->requiresSSL;
+     }
+     
+     /**
      * Returns if view should be printed
      *

--- NEW FILE: mvcconfig-sample.xml ---
<?xml version="1.0" encoding="UTF-8"?>
<mvc_configuration compile="true">
	<view id="login" name="Geeklog_LoginView" default="true"/>
	<view id="home" name="Geeklog_HomeView"/>
    <command id="doLogin" name="Geeklog_LoginCommand">
        <forward id="backToLogin" type="view">login</forward>
        <forward id="goHome" type="view">home</forward>
    </command>
    <command id="logout" name="Geeklg_LogoutCommand">
        <forward id="success" type="view">login</forward>
    </command>
</mvc_configuration>


Index: ArrayLoader.php
===================================================================
RCS file: /var/cvs/MVCnPHP/ArrayLoader.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ArrayLoader.php	8 Mar 2005 05:12:27 -0000	1.3
--- ArrayLoader.php	17 Mar 2005 05:08:37 -0000	1.4
***************
*** 22,26 ****
  * Base Loader class which does most of the work
  */
! require_once 'BaseLoader.class.php';
  
  /**
--- 22,26 ----
  * Base Loader class which does most of the work
  */
! require_once 'BaseLoader.php';
  
  /**
***************
*** 48,52 ****
      *
      */
!     public function &getMapping($name, $viewsDir, $commandsDir, $baseURL, $arrayData = '')
      {
          if (!is_array($arrayData) AND !is_array($this->arrayData)) {
--- 48,52 ----
      *
      */
!     public function getMapping($name, $viewsDir, $commandsDir, $baseURL, $arrayData = '')
      {
          if (!is_array($arrayData) AND !is_array($this->arrayData)) {


Index: XMLLoader.php
===================================================================
RCS file: /var/cvs/MVCnPHP/XMLLoader.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** XMLLoader.php	8 Mar 2005 05:12:27 -0000	1.3
--- XMLLoader.php	17 Mar 2005 05:08:38 -0000	1.4
***************
*** 46,51 ****
      protected $arrayData = null;
      
!     const VIEWS = 'VIEW';    
!     const COMMANDS = 'COMMAND';
      
      /**
--- 46,52 ----
      protected $arrayData = null;
      
!     const VIEWS = 'view';
!         
!     const COMMANDS = 'command';
      
      /**
***************
*** 97,101 ****
  
              if ($needsCompile) {   
!                 $this->dom->loadXML($xmlData);		
          		if (!empty($xmlData)) {
                      $this->xmlToArray();
--- 98,105 ----
  
              if ($needsCompile) {   
!                 $this->dom->loadXML($xmlData);
!                 if (!$this->dom->schemaValidate('C:/PHP/PEAR/pear/Geeklog/MVCnPHP/mvcConfig.xsd')) {
!                     throw new Exception('MVCnPHP XML configuration file faield XML schema validation');
!                 }                
          		if (!empty($xmlData)) {
                      $this->xmlToArray();
***************
*** 139,154 ****
      {
          $xpath = new DOMXPath($this->dom);
!         $tagList = $xpath->query("/MVC_CONFIGURATION/$section");
          $tagArray = array();
          foreach ($tagList as $curTag) {
!             $tagID = $curTag->getAttribute('ID');
!             $tagName = $curTag->getAttribute('NAME');
!             $tagDefault = $curTag->getAttribute('DEFAULT');
!             $queryStr = sprintf("/MVC_CONFIGURATION/%s[@ID='%s']/FORWARD", $section, $tagID);
              $forwardList = $xpath->query($queryStr);
              $forwardArray = array();
              foreach ($forwardList as $curForward) {
!                 $forwardID = $curForward->getAttribute('ID');
!                 $forwardType = $curForward->getAttribute('TYPE');
                  $forwardTarget = $curForward->textContent;
                  $forwardArray[$forwardID] = array('target'=>$forwardTarget,'type'=>$forwardType);
--- 143,158 ----
      {
          $xpath = new DOMXPath($this->dom);
!         $tagList = $xpath->query("/mvc_configuration/$section");
          $tagArray = array();
          foreach ($tagList as $curTag) {
!             $tagID = $curTag->getAttribute('id');
!             $tagName = $curTag->getAttribute('name');
!             $tagDefault = $curTag->getAttribute('default');
!             $queryStr = sprintf("/mvc_configuration/%s[@id='%s']/forward", $section, $tagID);
              $forwardList = $xpath->query($queryStr);
              $forwardArray = array();
              foreach ($forwardList as $curForward) {
!                 $forwardID = $curForward->getAttribute('id');
!                 $forwardType = $curForward->getAttribute('type');
                  $forwardTarget = $curForward->textContent;
                  $forwardArray[$forwardID] = array('target'=>$forwardTarget,'type'=>$forwardType);




Index: BaseLoader.php
===================================================================
RCS file: /var/cvs/MVCnPHP/BaseLoader.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** BaseLoader.php	8 Mar 2005 05:12:27 -0000	1.3
--- BaseLoader.php	17 Mar 2005 05:08:37 -0000	1.4
***************
*** 53,57 ****
      *
      */
!     public function &getMapping($name, $viewsDir, $commandsDir, $baseURL, $arrayData = '')
      {
      	
--- 53,57 ----
      *
      */
!     public function getMapping($name, $viewsDir, $commandsDir, $baseURL, $arrayData = '')
      {
      	

Index: Controller.php
===================================================================
RCS file: /var/cvs/MVCnPHP/Controller.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Controller.php	8 Mar 2005 05:12:27 -0000	1.3
--- Controller.php	17 Mar 2005 05:08:38 -0000	1.4
***************
*** 2,6 ****
  
  /**
! * MVCnPHP - Controller.class.php
  *
  * This source file is subject to version 2.02 of the PHP license,
--- 2,6 ----
  
  /**
! * MVCnPHP - Controller.php
  *
  * This source file is subject to version 2.02 of the PHP license,
***************
*** 13,17 ****
  *
  * @author Tony Bibbs <tony at geeklog.net>
! * @copyright Tony Bibbs 2003
  * @package net.geeklog.mvc
  * @version $Id$
--- 13,17 ----
  *
  * @author Tony Bibbs <tony at geeklog.net>
! * @copyright Tony Bibbs 2003-2005
  * @package net.geeklog.mvc
  * @version $Id$
***************
*** 41,46 ****
  * 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>
--- 41,57 ----
  * superglobal in $_SESSION['MVC_MESSAGE'] and $_SESSION['MVC_ERRORS']
  * respectively (note: the later is an array).  If your application is
! * not using PHP sessions you will want to follow the directions given
  * in the documentation for Controller::_clearMessages
+ * <p>
+ * Sample usage:
+ * <code>
+ * $configData = '/var/www/htdocs/mvcconfig.xml';
+ * $controller = new MVCnPHP_Controller($configData, MVC_XML);
+ * $controller->setBaseURL('http://www.example.com');
+ * $controller->setViewDir('/var/www/views/');
+ * $controller->setCommandDir('/var/www/commands/');
+ * $controller->processRequest();
+ * </code>
+ * </p>
  *
  * @author Tony Bibbs <tony at geeklog.net>
***************
*** 326,335 ****
                  exit;
              }
-             
-             // OK if we got here then we got an undefined forward of some kind
-             //if (!empty($strForward)) {
-             	//print_r($tmp); print_r($_SESSION['forwards']); $_SESSION['forwards'] = ''; exit;
-             	//throw new Exception('Unexpected return from MVC command or MVC view.  Got ' . $strForward);
-             //}
          }
      }
--- 337,340 ----







More information about the geeklog-cvs mailing list