/** * @copydoc PKPRouter::url() */ function url($request, $newContext = null, $component = null, $op = null, $path = null, $params = null, $anchor = null, $escape = false) { assert(is_null($path)); $pathInfoEnabled = $request->isPathInfoEnabled(); // // Base URL and Context // $baseUrlAndContext = $this->_urlGetBaseAndContext($request, $this->_urlCanonicalizeNewContext($newContext)); $baseUrl = array_shift($baseUrlAndContext); $context = $baseUrlAndContext; // // Component and Operation // // We only support component/op retrieval from the request // if this request is a component request. $currentRequestIsAComponentRequest = is_a($request->getRouter(), 'PKPComponentRouter'); if ($currentRequestIsAComponentRequest) { if (empty($component)) { $component = $this->getRequestedComponent($request); } if (empty($op)) { $op = $this->getRequestedOp($request); } } assert(!empty($component) && !empty($op)); // Encode the component and operation $componentParts = explode('.', $component); $componentName = array_pop($componentParts); assert(substr($componentName, -7) == 'Handler'); $componentName = PKPString::uncamelize(substr($componentName, 0, -7)); // uncamelize the component parts $uncamelizedComponentParts = array(); foreach ($componentParts as $part) { $uncamelizedComponentParts[] = PKPString::uncamelize($part); } array_push($uncamelizedComponentParts, $componentName); $opName = PKPString::uncamelize($op); // // Additional query parameters // $additionalParameters = $this->_urlGetAdditionalParameters($request, $params, $escape); // // Anchor // $anchor = empty($anchor) ? '' : '#' . rawurlencode($anchor); // // Assemble URL // if ($pathInfoEnabled) { // If path info is enabled then context, page, // operation and additional path go into the // path info. $pathInfoArray = array_merge($context, array(COMPONENT_ROUTER_PATHINFO_MARKER), $uncamelizedComponentParts, array($opName)); // Query parameters $queryParametersArray = $additionalParameters; } else { // If path info is disabled then context, page, // operation and additional path are encoded as // query parameters. $pathInfoArray = array(); // Query parameters $queryParametersArray = array_merge($context, array(COMPONENT_ROUTER_PARAMETER_MARKER . '=' . implode('.', $uncamelizedComponentParts), "op={$opName}"), $additionalParameters); } return $this->_urlFromParts($baseUrl, $pathInfoArray, $queryParametersArray, $anchor, $escape); }