getRequest(); if (null === $controller) { $controller = $request->getControllerName(); } if (null === $module) { $module = $request->getModuleName(); } $url = $controller . '/' . $action; if ($module != Zend_Controller_Front::getInstance()->getDispatcher()->getDefaultModule()) { $url = $module . '/' . $url; } if (null !== $params) { $paramPairs = array(); foreach ($params as $key => $value) { $paramPairs[] = urlencode($key) . '/' . urlencode($value); } $paramString = implode('/', $paramPairs); $url .= '/' . $paramString; } return $url; } /** * Assembles a URL based on a given route * * This method will typically be used for more complex operations, as it * ties into the route objects registered with the router. * * @param array $urlOptions Options passed to the assemble method of the Route object. * @param mixed $name The name of a Route to use. If null it will use the current Route * @return string Url for the link href attribute. */ public function url($urlOptions = array(), $name = null, $reset = false) { $front = Zend_Controller_Front::getInstance(); $router = $front->getRouter(); if (empty($name)) { try { $name = $router->getCurrentRouteName(); } catch (Zend_Controller_Router_Exception $e) { if ($router->hasRoute('default')) { $name = 'default'; } } } $route = $router->getRoute($name); $request = $this->getRequest(); $url = rtrim($request->getBaseUrl(), '/') . '/'; $url .= $route->assemble($urlOptions, $reset); return $url; } /** * Perform helper when called as $this->_helper->url() from an action controller * * Proxies to {@link simple()} * * @param string $action * @param string $controller * @param string $module * @param array $params * @return string */ public function direct($action, $controller = null, $module = null, array $params = null) { return $this->simple($action, $controller, $module, $params); } }