/** * Parse the segments of a URL. * * @param array The segments of the URL to parse. * @return array The URL attributes to be used by the application. */ public function parse(&$segments) { $path = implode('/', $segments); $vars = array(); $matches = array(); if (preg_match('/(\\d+)-([^\\/]+)/', $path, $matches)) { $vars['alias'] = $matches[2]; $path = str_replace($matches[0], $matches[1], $path); $segments = array_filter(explode('/', $path)); } $path = implode('/', $segments); $matches = array(); if (preg_match('/@(\\w+)/', $path, $matches)) { $vars['oid'] = $matches[1]; if (isset($matches[2])) { $vars['view'] = $matches[2]; } $path = ltrim(str_replace($matches[0], '', $path), '/'); $segments = array_filter(explode('/', $path)); } $vars = array_merge($vars, parent::parse($segments)); if (isset($vars['id']) && current($segments)) { $vars['alias'] = array_shift($segments); } return $vars; }
/** * Parse the segments of a URL. * * @param array The segments of the URL to parse. * * @return array The URL attributes to be used by the application. */ public function parse(&$segments) { $query = array(); if (!count($segments)) { $query['view'] = 'packages'; } else { $query = parent::parse($segments); } return $query; }
/** * (non-PHPdoc). * * @see ComBaseRouterAbstract::parse() */ public function parse(&$segments) { $query = array(); $path = implode('/', $segments); if ($path == 'new') { array_pop($segments); $query = array_merge(parent::parse($segments), array('new' => true)); } else { return parent::parse($segments); } return $query; }
/** * Parse the segments of a URL. * * @param array The segments of the URL to parse. * @return array The URL attributes to be used by the application. */ public function parse(&$segments) { $path = implode('/', $segments); $vars = array(); $matches = array(); if (preg_match('/(\\d+)-([^\\/]+)/', $path, $matches)) { $vars['alias'] = $matches[2]; $path = str_replace($matches[0], $matches[1], $path); $segments = array_filter(explode('/', $path)); } $last = AnHelperArray::getValueAtIndex($segments, AnHelperArray::LAST_INDEX); if (preg_match('/@\\w+/', $last)) { $vars['oid'] = str_replace('@', '', array_pop($segments)); } $vars = array_merge($vars, parent::parse($segments)); if (isset($vars['get']) && $vars['get'] == 'graph') { $vars['type'] = count($segments) ? array_shift($segments) : 'followers'; } return $vars; }