/** * Parse page to internal URI representation * * @param string $page Page URI to parse * * @return array|bool Parsed URI or false on failure */ public function parse($page) { $result = array('base' => '', 'ai1ec' => array(), 'args' => null, 'hash' => null, '_type' => 'args'); if (false === ($parsed = parse_url($page))) { return false; } if (isset($parsed['scheme'])) { if (!isset($parsed['host'])) { return false; } $result['base'] = $parsed['scheme'] . '://' . $parsed['host']; } if (!empty($parsed['path'])) { if (false !== strpos($parsed['path'], self::DIRECTION_SEPARATOR)) { $result['_type'] = 'pretty'; $elements = explode($this->_arguments_separator, $parsed['path']); foreach ($elements as $particle) { $sep = strpos($particle, self::DIRECTION_SEPARATOR); if (false !== $sep) { $key = substr($particle, 0, $sep); $result['ai1ec'][$key] = substr($particle, $sep + 1); } else { $result['base'] .= $this->_arguments_separator . $particle; } } } } $query_pos = array('query' => 'args', 'fragment' => 'hash'); foreach ($query_pos as $source => $destination) { if ('hash' === $destination) { $result['_type'] = $destination; } if (!empty($parsed[$source])) { $result = Ai1ec_Utility_Array::deep_merge($result, $this->parse_query_str($parsed[$source], $destination)); } } return $result; }
/** * convert_to_int_list method * * Convert given input to array of positive integers. * * @param char $separator Value used to separate integers, if any * @param array $input Allegedly list of positive integers * * @return array List of positive integers */ public static function convert_to_int_list($separator, $input) { return self::map_to_integer(Ai1ec_Utility_Array::opt_explode($separator, $input)); }