示例#1
0
 /**
  * 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;
 }