<?php
/**
* @see Zend_Controller_Action
*/
require_once 'Zend/Controller/Action.php';
abstract class Zend_Controller_Action_Helper_Abstract
{
/**
* $_actionController
*
* @var Zend_Controller_Action $_actionController
*/
protected $_actionController = null;
/**
* @var mixed $_frontController
*/
protected $_frontController = null;
/**
* setActionController()
*
* @param Zend_Controller_Action $actionController
* @return Zend_Controller_ActionHelper_Abstract Provides a fluent interface
*/
public function setActionController(Zend_Controller_Action $actionController = null)
{
$this->_actionController = $actionController;
return $this;
}
/**
* Retrieve current action controller
*
* @return Zend_Controller_Action
*/
public function getActionController()
{
return $this->_actionController;
}
/**
* Retrieve front controller instance
*
* @return Zend_Controller_Front
*/
public function getFrontController()
{
return Zend_Controller_Front::getInstance();
}
/**
* Hook into action controller initialization
*
* @return void
*/
public function init()
{
}
/**
* Hook into action controller preDispatch() workflow
*
* @return void
*/
public function preDispatch()
{
}
/**
* Hook into action controller postDispatch() workflow
*
* @return void
*/
public function postDispatch()
{
}
/**
* getRequest() -
*
* @return Zend_Controller_Request_Abstract $request
*/
public function getRequest()
{
$controller = $this->getActionController();
if (null === $controller) {
$controller = $this->getFrontController();
}
return $controller->getRequest();
}
/**
* getResponse() -
*
* @return Zend_Controller_Response_Abstract $response
*/
public function getResponse()
{
$controller = $this->getActionController();
if (null === $controller) {
$controller = $this->getFrontController();
}
return $controller->getResponse();
}
/**
* getName()
*
* @return string
*/
public function getName()
{
$fullClassName = get_class($this);
if (strpos($fullClassName, '_') !== false) {
$helperName = strrchr($fullClassName, '_');
return ltrim($helperName, '_');
} elseif (strpos($fullClassName, '\\') !== false) {
$helperName = strrchr($fullClassName, '\\');
return ltrim($helperName, '\\');
} else {
return $fullClassName;
}
}
}
<?php
require_once 'Zend/Controller/Action/Helper/Abstract.php';
class Application_Controller_Action_Helpers_UrlParser extends Zend_Controller_Action_Helper_Abstract
{
public function __construct()
{
}
/**
* Parse url
*
* @param String $url
* @return Array part of url
*/
public function parse($url)
{
return parse_url($url);
}
}
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace(array('Application_'));
}
protected function _initActionHelpers() {
//用前缀形式
//Zend_Controller_Action_HelperBroker::addPrefix('Application_Controller_Action_Helpers');
//指定目录和前缀
//Zend_Controller_Action_HelperBroker::addPath('/www/helper_demo1/library/Application/Controller/Action/Helpers',
// 'Application_Controller_Action_Helpers');
//new一个助手类传入
Zend_Controller_Action_HelperBroker::addHelper(new Application_Controller_Action_Helpers_UrlParser);
}
}
<?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$urlParser = $this->_helper->getHelper('UrlParser');
var_dump($urlParser->parse('http://www.1sucai.cn/article/80479.htm'));
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有