first commit
This commit is contained in:
126
ZeedFramework/library/Fit/Controller/Action.php
Normal file
126
ZeedFramework/library/Fit/Controller/Action.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* Playcool Project
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* http://www.playcool.com/license/ice
|
||||
*
|
||||
* @category ICE
|
||||
* @package ChangeMe
|
||||
* @subpackage ChangeMe
|
||||
* @copyright Copyright (c) 2008 Zeed Technologies PRC Inc. (http://www.inews.com.cn)
|
||||
* @author xSharp ( GTalk: xSharp@gmail.com )
|
||||
* @since 2009-8-5
|
||||
* @version SVN: $Id$
|
||||
*/
|
||||
|
||||
class Fit_Controller_Action extends Zend_Controller_Action implements Zeed_Controller_Action_Interface
|
||||
{
|
||||
|
||||
protected $_allowedResultType = array(
|
||||
'default' => 'Fit_View_Default',
|
||||
'php' => 'Fit_View_Php',
|
||||
'redirector' => 'Fit_View_Redirector',
|
||||
'json' => 'Fit_View_Json',
|
||||
'xml' => 'Fit_View_Xml');
|
||||
|
||||
protected $_resultType = array();
|
||||
|
||||
public function addResult($result, $resultType = null, $resource = null)
|
||||
{
|
||||
if (is_null($resultType)) {
|
||||
$resultType = 'default';
|
||||
}
|
||||
$resultType = strtolower($resultType);
|
||||
|
||||
if (! in_array($resultType, array_keys($this->_allowedResultType))) {
|
||||
Zeed_Loader::loadClass('Zeed_Exception');
|
||||
throw new Zeed_Exception('视图类型不被允许. 允许的视图类型:<code>' . implode(',', $this->_allowedResultType) . '</code>');
|
||||
}
|
||||
|
||||
$this->_resultType[$result] = array(
|
||||
'type' => $resultType,
|
||||
'resource' => $resource);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取RESULT配置
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->_resultType;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo '<h2>Default Method. Overwrite me plz!</h2> (<code>' . __METHOD__ . '</code>)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @param string $name
|
||||
* @return Zeed_View
|
||||
*/
|
||||
public function getResultType($name)
|
||||
{
|
||||
$_resultClass = 'Fit_View_' . ucfirst($name);
|
||||
|
||||
return new $_resultClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Fit_Controller_Action $action
|
||||
* @see Controller/Zend_Controller_Action#dispatch($action)
|
||||
*/
|
||||
public function dispatch($action)
|
||||
{
|
||||
$result = $this->_dispatch($action);
|
||||
$actionConfiguration = $this->getConfig();
|
||||
if (isset($actionConfiguration[$result])) {
|
||||
$processor = $this->getResultType($actionConfiguration[$result]['type']);
|
||||
$processor->process($result, $this);
|
||||
} else {
|
||||
$processor = $this->getResultType("Default");
|
||||
$processor->process($result, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function _dispatch($action)
|
||||
{
|
||||
// Notify helpers of action preDispatch state
|
||||
$this->_helper->notifyPreDispatch();
|
||||
|
||||
$this->preDispatch();
|
||||
if ($this->getRequest()->isDispatched()) {
|
||||
if (null === $this->_classMethods) {
|
||||
$this->_classMethods = get_class_methods($this);
|
||||
}
|
||||
|
||||
// preDispatch() didn't change the action, so we can continue
|
||||
if ($this->getInvokeArg('useCaseSensitiveActions') || in_array($action, $this->_classMethods)) {
|
||||
if ($this->getInvokeArg('useCaseSensitiveActions')) {
|
||||
trigger_error('Using case sensitive actions without word separators is deprecated; please do not rely on this "feature"');
|
||||
}
|
||||
$return = $this->$action();
|
||||
} else {
|
||||
$this->__call($action, array());
|
||||
}
|
||||
$this->postDispatch();
|
||||
}
|
||||
|
||||
// whats actually important here is that this action controller is
|
||||
// shutting down, regardless of dispatching; notify the helpers of this
|
||||
// state
|
||||
$this->_helper->notifyPostDispatch();
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
// End ^ LF ^ encoding
|
||||
36
ZeedFramework/library/Fit/Controller/Dispatcher.php
Normal file
36
ZeedFramework/library/Fit/Controller/Dispatcher.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Playcool Project
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* http://www.playcool.com/license/ice
|
||||
*
|
||||
* @category ICE
|
||||
* @package ChangeMe
|
||||
* @subpackage ChangeMe
|
||||
* @copyright Copyright (c) 2008 Zeed Technologies PRC Inc. (http://www.inews.com.cn)
|
||||
* @author xSharp ( GTalk: xSharp@gmail.com )
|
||||
* @since 2009-8-11
|
||||
* @version SVN: $Id$
|
||||
*/
|
||||
|
||||
class Fit_Controller_Dispatcher extends Zend_Controller_Dispatcher_Standard
|
||||
{
|
||||
/**
|
||||
* Formats a string into an action name. This is used to take a raw
|
||||
* action name, such as one that would be stored inside a Zend_Controller_Request_Abstract
|
||||
* object, and reformat into a proper method name that would be found
|
||||
* inside a class extending Zend_Controller_Action.
|
||||
*
|
||||
* @param string $unformatted
|
||||
* @return string
|
||||
*/
|
||||
public function formatActionName($unformatted)
|
||||
{
|
||||
$formatted = $this->_formatName($unformatted, true);
|
||||
return strtolower(substr($formatted, 0, 1)) . substr($formatted, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// End ^ LF ^ UTF-8
|
||||
37
ZeedFramework/library/Fit/Controller/Front.php
Normal file
37
ZeedFramework/library/Fit/Controller/Front.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Playcool Project
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* http://www.playcool.com/license/ice
|
||||
*
|
||||
* @category ICE
|
||||
* @package ChangeMe
|
||||
* @subpackage ChangeMe
|
||||
* @copyright Copyright (c) 2008 Zeed Technologies PRC Inc. (http://www.inews.com.cn)
|
||||
* @author xSharp ( GTalk: xSharp@gmail.com )
|
||||
* @since 2009-8-5
|
||||
* @version SVN: $Id$
|
||||
*/
|
||||
|
||||
class Fit_Controller_Front extends Zend_Controller_Front
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Fit_Controller_Front
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (null === self::$_instance) {
|
||||
self::$_instance = new self();
|
||||
self::$_instance->setDispatcher(new Fit_Controller_Dispatcher());
|
||||
self::$_instance->setRouter(new Fit_Controller_Router());
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
}
|
||||
|
||||
// End ^ LF ^ encoding
|
||||
23
ZeedFramework/library/Fit/Controller/Router.php
Normal file
23
ZeedFramework/library/Fit/Controller/Router.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Playcool Project
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* http://www.playcool.com/license/ice
|
||||
*
|
||||
* @category ICE
|
||||
* @package ChangeMe
|
||||
* @subpackage ChangeMe
|
||||
* @copyright Copyright (c) 2008 Zeed Technologies PRC Inc. (http://www.inews.com.cn)
|
||||
* @author xSharp ( GTalk: xSharp@gmail.com )
|
||||
* @since 2009-8-11
|
||||
* @version SVN: $Id$
|
||||
*/
|
||||
|
||||
class Fit_Controller_Router extends Zend_Controller_Router_Rewrite
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// End ^ LF ^ encoding
|
||||
Reference in New Issue
Block a user