Rinza_IE
[ class tree: Rinza_IE ] [ index: Rinza_IE ] [ all elements ]

Source for file Util.php

Documentation is available at Util.php

  1. <?php
  2.  
  3. /**
  4.  * Rinza/IE/Util.php
  5.  * 
  6.  * <p>Rinza_IEパッケージで共通に使用するメソッドを提供するクラスを定義しています。</p>
  7.  * @author Y. Kurei
  8.  * @copyright Copyright (c) 2006-2007, Nihon Unisys, Ltd.
  9.  * @version 1.1.4
  10.  * @package Rinza_IE
  11.  * @filesource
  12.  * @license http://www.tyzoh.jp/rinza/licenses/LICENSE-1.0.txt Rinza Public License
  13.  */
  14. /**
  15.  * Rinza_IE_Util Class
  16.  * 
  17.  * @author Y. Kurei
  18.  * @package Rinza_IE
  19.  */ 
  20. class Rinza_IE_Util {
  21.  
  22.     /**
  23.      * コンストラクタ
  24.      * 
  25.      * オブジェクトの設定
  26.      * @access  public
  27.      */
  28.     function __construct({
  29.         
  30.     }
  31.     
  32.     /**
  33.      * ページURLとページ内リンクURLからリンクの絶対URLを取得
  34.      * 
  35.      * @param   string $pageURL  ページのURL
  36.      * @param   string $linkURL  ページ内のリンクのURL
  37.      * @return  string  ページ内リンクの絶対URL
  38.      * @access   public
  39.      * @static
  40.      */    
  41.     function getAbsoluteURL($pageURL$linkURL{
  42.         
  43.         $absURL NULL;
  44.         $rAbsURL NULL;
  45.         
  46.         $pageURL preg_replace("/(\/)$/"""$pageURL);
  47.  
  48.         if (preg_match("/^(https?:|mailto:)/i"$linkURL)) // リンクURLが "http(s):" or "mailto:" で始まる
  49.             $absURL $linkURL;
  50.         elseif (preg_match("/^#/"$linkURL)) // リンクURLが "#" で始まる
  51.             $absURL $pageURL $linkURL;
  52.         else // リンクURLが "http(s):"  or "mailto:" or "#" 以外で始まる
  53.             $url_dirname dirname($pageURL);
  54.             $url_basename basename($pageURL);
  55.             if (preg_match("/^(\/)/"$linkURL)) // リンクURLが "/" で始まる
  56.                 if (preg_match("/^(https?:)$/i"$url_dirname)) // ページURLのdirnameが "http(s):" である
  57.                     $absURL $pageURL $linkURL;
  58.                 else // ページURLのdirnameが "http(s):" ではない
  59.                     $checkURL $url_dirname;
  60.                     while (preg_match("/^(https?:)$/i"$checkURL== 0{
  61.                         $rootURL $checkURL;
  62.                         $checkURL dirname($checkURL);
  63.                     }
  64.                     $absURL $rootURL $linkURL;
  65.                 }
  66.             else // リンクURL "/" 以外で始まる
  67.                 if (preg_match("/^([^(\.)]+(\.)[^(\.)]+)$/"$url_basename)) {
  68.                     $absURL $url_dirname '/' preg_replace("/^(\.\/)/"""$linkURL);
  69.                 else {
  70.                     $absURL $pageURL '/' preg_replace("/^(\.\/)/"""$linkURL);
  71.                 }
  72.             }
  73.         }
  74.         
  75.         // URL正規化 パス内に "../" がある場合にこれを解決したURLに修正する
  76.         $urlinfo explode('../'$absURL);
  77.         if (($info count($urlinfo)) 1{
  78.             $tmpURL $urlinfo[0];
  79.             for ($i 0$i $info 1$i++{
  80.                 $backupURL $tmpURL;
  81.                 $tmpURL dirname($tmpURL);
  82.                 if (preg_match("/^(https?:)$/i"$tmpURL)) {
  83.                     $tmpURL $backupURL;
  84.                     break;
  85.                 }
  86.             }
  87.             if (preg_match("/(\/)$/"$tmpURL)) {
  88.                 $rAbsURL $tmpURL $urlinfo[$info 1];
  89.             else {
  90.                 $rAbsURL $tmpURL "/" $urlinfo[$info 1];
  91.             }
  92.         else {
  93.             $rAbsURL $absURL;
  94.         }
  95.         
  96.         return str_replace(' ''%20'$rAbsURL);
  97.         
  98.     }
  99.     
  100.     
  101. }
  102.  
  103. /** 
  104.  * This Program is distributed under version 1.0 of the Rinza Public
  105.  * License Agreement, that is bundled with this package in the file
  106.  * LICENSE, and is available through the website at the following URL:
  107.  * http://www.tyzoh.jp/rinza/licenses/LICENSE-1.0.txt.
  108.  * 
  109.  * This is the Original Program.
  110.  * The Initial Developer of the Original Program is Nihon Unisys, Ltd.
  111.  * The Original Program is copyrighted (C) 2006-2007 by Nihon Unisys, Ltd. with
  112.  * all rights reserved.
  113.  * There is NO WARRANTY OF ANY KIND by the Initial Developer of the
  114.  * Original Program.
  115.  */
  116.  
  117. ?>

Documentation generated on Fri, 09 Nov 2007 14:01:45 +0900 by phpDocumentor 1.4.0