JetTableAllClasses
Current view: C:\xampp\htdocs\table\jettable\JetHtmlUtil.class.php
Date: Fri Dec 1 17:20:38 JST 2006 Executable lines: 25
Code covered: 96.00% Executed lines: 24
Legend: executed not executed dead code


       1                 : <?php                                                                             
       2                 : /**                                                                               
       3                 :  * HTMLユーティリティークラス<br>                                                 
       4                 :  * HTMLを操作するユーティリティーメソッドを保持するクラス                         
       5                 :  *                                                                                
       6                 :  * @package    jettable.framework.util                                            
       7                 :  * @author     rds <tk@rasign.jp>                                                 
       8                 :  * @license     http://www.opensource.org/licenses/mit-license.php The MIT License
       9                 :  * @version    $Revision: 1.4 $ $Date: 2006/12/01 13:41:52 $                      
      10                 :  * @link       http://jettable.rasign.jp/                                         
      11                 :  */                                                                               
      12                 : class JetHtmlUtil{                                                                
      13                 :     /**                                                                           
      14                 :      * 属性の付加<br>                                                             
      15                 :      * 指定されたタグに属性を付加した文字列を返す。                               
      16                 :      *                                                                            
      17                 :      * @param $baseTag タグ                                                       
      18                 :      * @param $key 属性のキー                                                     
      19                 :      * @param $value 属性の値                                                     
      20                 :      * @access public                                                             
      21                 :      */                                                                           
      22                 :     static public function joinTagAttribute($baseTag, $key, $value){                 
      23              18 :         if(empty($baseTag)){                                                            
      24               1 :             return $baseTag;                                                               
      25                 :         }                                                                               
      26              18 :         if(empty($key)){                                                                
      27               1 :             return $baseTag;                                                               
      28                 :         }                                                                               
      29              18 :         if(empty($value)){                                                              
      30               0 :             return $baseTag;                                                               
      31                 :         }                                                                               
      32                 :                                                                                   
      33              18 :         $createTag = str_replace(">", " " . $key . "=\"" . $value . "\">", $baseTag);   
      34              18 :         return $createTag;                                                              
      35                 :     }                                                                                
      36                 :                                                                                   
      37                 :     /**                                                                           
      38                 :      * セレクトボックスの取得<br>                                                 
      39                 :      * 渡された配列からセレクトボックスを生成する。                               
      40                 :      *                                                                            
      41                 :      * @param $data データ配列                                                    
      42                 :      * @param $selected 初期選択値                                                
      43                 :      * @param $attribute 属性                                                     
      44                 :      * @access public                                                             
      45                 :      */                                                                           
      46                 :     static public function createSelectBox($data, $selected, $attribute = array()){  
      47               7 :         if(empty($data)){                                                               
      48               3 :             return null;                                                                   
      49                 :         }                                                                               
      50               4 :         $html .= "<select>";                                                            
      51               4 :         foreach($attribute as $attributeKey=>$attributeValue){                          
      52               3 :             $html = JetHtmlUtil::joinTagAttribute($html, $attributeKey, $attributeValue);  
      53               3 :         }                                                                               
      54                 :                                                                                   
      55               4 :         $html .= "<option value=\"0\"></option>";                                       
      56                 :                                                                                   
      57               4 :         $i = 1;                                                                         
      58               4 :         foreach($data as $dataKey=>$dataValue){                                         
      59               4 :             $html .= "<option value=\"" . $i . "\"";                                       
      60               4 :             if($dataValue == $selected){                                                   
      61               3 :                 $html .= " selected ";                                                        
      62                 :             }                                                                              
      63               4 :             $html .= ">" . $dataValue . "</option>";                                       
      64               4 :             $i++;                                                                          
      65               4 :         }                                                                               
      66                 :                                                                                   
      67               4 :         $html .= "</select>";                                                           
      68               4 :         return $html;                                                                   
      69                 :     }                                                                                
      70                 : }                                                                                 
      71                 : ?>                                                                                

Generated by: PHPUnit 3.0.0 and Xdebug 2.0.0RC1.