/** * Return the special URI array or just one special URI args array. * * /application/config/ionize.php defines the special URIs and the corresponding user's chosen URIs : * $config['special_uri'] = array( * 'user_chosen_uri' => 'internal_uri' * ); * * This method checks the URL segments, looks for "user_chosen_uri" and returns one array containing, * for each "internal_uri", the asked args. * Example of return : * array( * 'internal_uri' => array( * 0 => 'foo' * 1 => 5 * ) * ); * * @param null|string If set, return the args array of the given "internal_uri" * * @return array|null * */ public static function get_special_uri_array($key = NULL) { if (is_null(self::$special_uri_array)) { $uri_config = self::$ci->config->item('special_uri'); $segments = self::get_uri_segments(); $segment_index = count($segments) - 1; $found_uri_segments = array(); while (!empty($segments)) { $segment = array_pop($segments); if (array_key_exists($segment, $uri_config)) { if (is_null(self::$special_uri_array)) { self::$special_uri_array = array(); } self::$special_uri_array[$uri_config[$segment]] = array_reverse($found_uri_segments); $found_uri_segments = array(); } else { $found_uri_segments[] = $segment; } $segment_index--; } if (is_array(self::$special_uri_array)) { self::$special_uri_array = array_reverse(self::$special_uri_array); } } if (!is_null($key) && is_array(self::$special_uri_array) && array_key_exists($key, self::$special_uri_array)) { return self::$special_uri_array[$key]; } return self::$special_uri_array; }