本文整理汇总了PHP中URI::getPart方法的典型用法代码示例。如果您正苦于以下问题:PHP URI::getPart方法的具体用法?PHP URI::getPart怎么用?PHP URI::getPart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URI
的用法示例。
在下文中一共展示了URI::getPart方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareHtaccessCode
function prepareHtaccessCode($arr_err_code)
{
global $application;
loadCoreFile('URI.class.php');
$uriObj = new URI($application->getAppIni('HTTP_URL'));
$url_dir = $uriObj->getPart('dir') . (_ml_substr($uriObj->getPart('dir'), -1) != '/' ? '/' : '');
$hta_content = ERRDOC_BLOCK_IDENT_BEGIN . "\n";
/* ignore list htaccess code - starts */
$hta_content .= str_replace('%files_to_ignore%', FILES_TO_IGNORE, file_get_contents(dirname(__FILE__) . '/includes/errdoc_ignore_list_block_first_strings'));
foreach ($arr_err_code as $error_code => $error_page) {
$hta_content .= str_replace('%error_code%', $error_code, file_get_contents(dirname(__FILE__) . '/includes/errdoc_block_for_ignore_list'));
}
$hta_content .= file_get_contents(dirname(__FILE__) . '/includes/errdoc_ignore_list_block_last_strings');
/* ignore list htaccess code - ends */
foreach ($arr_err_code as $error_code => $error_page) {
$hta_content .= str_replace(array('%error_code%', '%url_dir%', '%error_code_file%'), array($error_code, $url_dir, $error_page), file_get_contents(dirname(__FILE__) . '/includes/errdoc_block_for_all_files'));
}
$hta_content .= ERRDOC_BLOCK_IDENT_END;
return $hta_content;
}
示例2: encodeURL
/**
* URL URL
* mod_rewrite
* @param string $url - URL
* @return string - URL
*/
function encodeURL($url)
{
global $application;
if ($application->row_layout_ini_array === null) {
return $url;
}
$row_layout_ini_array = $application->row_layout_ini_array;
loadCoreFile('URI.class.php');
$uriObj = new URI($url);
if ($uriObj->getPart('scheme') == 'http://') {
$r_string = str_replace($row_layout_ini_array['Site']['SiteURL'], '', $url);
} elseif ($uriObj->getPart('scheme') == 'https://') {
$r_string = str_replace($row_layout_ini_array['Site']['SiteHTTPSURL'], '', $url);
} else {
return $url;
}
$rel_script_path = str_replace($uriObj->getPart('query'), '', $r_string);
$query_string = str_replace('?', '', $uriObj->getPart('query'));
if (strstr($query_string, 'asc_action=SetCurrentProduct') !== false) {
# URL .
preg_match("/prod_id=(\\d+)/i", $query_string, $matches);
$product_id = $matches[1];
# ProductInfo
$founded_keys = array();
foreach ($row_layout_ini_array['ProductInfo'] as $layout_key => $layout_script) {
if ($layout_script == $rel_script_path) {
$founded_keys[] = $layout_key;
}
}
$prodObj =& $application->getInstance('CProductInfo', $product_id);
$seo_html_name = $prodObj->getProductTagValue('SEOPrefix');
if ($seo_html_name == '' or $seo_html_name == null) {
$seo_html_name = 'info';
//: move to config
}
$encode_rule = array('type' => 'default', 'prod_id' => $product_id, 'cat_id' => null);
# 1. Products {x}
foreach ($founded_keys as $lkey) {
if (preg_match("/^products/i", $lkey)) {
$encode_rule['type'] = 'product';
break;
}
}
# 2. Categories {x}
if ($encode_rule['type'] == 'default') {
$choosen_cat = $prodObj->chooseCategoryID();
reset($founded_keys);
$parent_cat = null;
foreach ($founded_keys as $lkey) {
if (preg_match("/^categories\\s*\\{([0-9\\,\\+]+)\\}/i", $lkey, $matches)) {
$row_cats_ids = array_map("trim", explode(",", $matches[1]));
if (in_array($choosen_cat, $row_cats_ids)) {
$encode_rule['type'] = 'category';
$encode_rule['cat_id'] = $choosen_cat;
break;
} else {
foreach ($row_cats_ids as $cat_id_str) {
if (strstr($cat_id_str, '+') !== false) {
$parent_cat = str_replace('+', '', $cat_id_str);
if ($parent_cat == $choosen_cat) {
$encode_rule['type'] = 'category';
$encode_rule['cate_id'] = $cat_id_str;
break;
}
$parent_cat = $cat_id_str;
}
}
}
}
}
if ($encode_rule['type'] == 'default' and $parent_cat !== null) {
$encode_rule['type'] = 'category';
$encode_rule['cat_id'] = $parent_cat;
}
}
# URL
$encoded_url = '';
if ($uriObj->getPart('scheme') == 'https://') {
$encoded_url .= $row_layout_ini_array['Site']['SiteHTTPSURL'];
} else {
$encoded_url .= $row_layout_ini_array['Site']['SiteURL'];
}
switch ($encode_rule['type']) {
case 'category':
$encoded_url .= str_replace(array('%product_id%', '%parent_cid%', '%query_prod_prefix%', '%seo_prod_prefix%'), array($encode_rule['prod_id'], '-' . $encode_rule['cat_id'], $this->queries_prefixes['product'], $seo_html_name), $this->encode_scheme['product']);
# .
//$encoded_url .= $this->queries_prefixes['product'].'/'.$encode_rule['prod_id'].'/'.$encode_rule['cat_id'].'/'.$seo_html_name.'.html';
break;
case 'product':
case 'default':
$encoded_url .= str_replace(array('%product_id%', '%parent_cid%', '%query_prod_prefix%', '%seo_prod_prefix%'), array($encode_rule['prod_id'], '', $this->queries_prefixes['product'], $seo_html_name), $this->encode_scheme['product']);
# .
//$encoded_url .= $this->queries_prefixes['product'].'/'.$encode_rule['prod_id'].'/'.$seo_html_name.'.html';
break;
//.........这里部分代码省略.........
示例3: setURL
/**
* Sets the request URL.
*
* @param $url URL
*/
function setURL($url)
{
loadCoreFile('URI.class.php');
$_uri = new URI($url);
$this->proto = _ml_strtoupper(str_replace('://', '', $_uri->getPart('scheme')));
$this->host = $_uri->getPart("host");
$this->port = $_uri->getPart("port");
$this->url = $this->__urlencode($_uri->getPart("path")) . $_uri->getPart("query");
}