當前位置: 首頁>>代碼示例>>PHP>>正文


PHP URI::getPart方法代碼示例

本文整理匯總了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;
 }
開發者ID:KICHIRO20,項目名稱:-Myproject_part1-,代碼行數:20,代碼來源:error_document_api.php

示例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;
//.........這裏部分代碼省略.........
開發者ID:KICHIRO20,項目名稱:-Myproject_part1-,代碼行數:101,代碼來源:mod_rewrite_api.php

示例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");
 }
開發者ID:KICHIRO20,項目名稱:-Myproject_part1-,代碼行數:14,代碼來源:bouncer.php


注:本文中的URI::getPart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。