Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new Zend_Controller_Router_Route('index/*',
- array('controller' => 'index', 'action' => 'custom', 'module'=>'index')
- $this->_helper->layout()->disableLayout();
- $this->_helper->viewRenderer->setNoRender(true);
- class UDC_Controller_Router_Route_Catchall extends Zend_Controller_Router_Route_Module
- {
- private $_catchallController = 'page';
- private $_catchallAction = 'index';
- private $_paramName = 'name';
- //-------------------------------------------------------------------------
- /*! brief takes most of the default behaviour from Zend_Controller_Router_Route_Module
- with the following changes:
- - if the path includes a valid module, then use it
- - if the path includes a valid controller (file_exists) then use that
- - otherwise use the catchall
- */
- public function match($path, $partial = false)
- {
- $this->_setRequestKeys();
- $values = array();
- $params = array();
- if (!$partial) {
- $path = trim($path, self::URI_DELIMITER);
- } else {
- $matchedPath = $path;
- }
- if ($path != '') {
- $path = explode(self::URI_DELIMITER, $path);
- if ($this->_dispatcher && $this->_dispatcher->isValidModule($path[0])) {
- $values[$this->_moduleKey] = array_shift($path);
- $this->_moduleValid = true;
- }
- if (count($path) && !empty($path[0])) {
- $module = $this->_moduleValid ? $values[$this->_moduleKey] : $this->_defaults[$this->_moduleKey];
- $file = $this->_dispatcher->getControllerDirectory( $module ) . '/' . $this->_dispatcher->formatControllerName( $path[0] ) . '.php';
- if (file_exists( $file ))
- {
- $values[$this->_controllerKey] = array_shift($path);
- }
- else
- {
- $values[$this->_controllerKey] = $this->_catchallController;
- $values[$this->_actionKey] = $this->_catchallAction;
- $params[$this->_paramName] = join( self::URI_DELIMITER, $path );
- $path = array();
- }
- }
- if (count($path) && !empty($path[0])) {
- $values[$this->_actionKey] = array_shift($path);
- }
- if ($numSegs = count($path)) {
- for ($i = 0; $i < $numSegs; $i = $i + 2) {
- $key = urldecode($path[$i]);
- $val = isset($path[$i + 1]) ? urldecode($path[$i + 1]) : null;
- $params[$key] = (isset($params[$key]) ? (array_merge((array) $params[$key], array($val))): $val);
- }
- }
- }
- if ($partial) {
- $this->setMatchedPath($matchedPath);
- }
- $this->_values = $values + $params;
- return $this->_values + $this->_defaults;
- }
- }
- public function __call($name, $arguments)
- {
- // Render Simple HTML View
- }
- // 1. Catch & process overloaded actions.
- public function __call($name, $arguments)
- {
- // 2. Provide an appropriate renderer.
- $this->_helper->viewRenderer->setRender('overload');
- // 3. Bonus: give your view script a clue about what "action" was requested.
- $this->view->action = $this->getFrontController()->getRequest()->getActionName();
- }
Add Comment
Please, Sign In to add comment