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


       1                 : <?php                                                                                                                           
       2                 : require_once "JetPager.class.php";                                                                                              
       3                 : require_once "JetAttribute.class.php";                                                                                          
       4                 : require_once "JetAttributeColumn.class.php";                                                                                    
       5                 : require_once "JetAttributeColumnEreg.class.php";                                                                                
       6                 : require_once "JetRadioButtonDataCell.class.php";                                                                                
       7                 : require_once "JetCheckBoxDataCell.class.php";                                                                                   
       8                 : require_once "JetSelectBoxDataCell.class.php";                                                                                  
       9                 : require_once "JetTextBoxDataCell.class.php";                                                                                    
      10                 : require_once "JetTextAreaDataCell.class.php";                                                                                   
      11                 : require_once "JetLabelDataCell.class.php";                                                                                      
      12                 : require_once "JetHtmlUtil.class.php";                                                                                           
      13                 : require_once "JetCsvDownload.class.php";                                                                                        
      14                 : require_once "JetExcelDownload.class.php";                                                                                      
      15                 : require_once "JetDateFormatter.class.php";                                                                                      
      16                 :                                                                                                                                 
      17                 :                                                                                                                                 
      18                 : /**                                                                                                                             
      19                 :  * テーブル出力クラス<br>                                                                                                       
      20                 :  * テーブル出力のためのメインクラス。                                                                                           
      21                 :  *                                                                                                                              
      22                 :  * @package    jettable.framework                                                                                               
      23                 :  * @author     rds <tk@rasign.jp>                                                                                               
      24                 :  * @license     http://www.opensource.org/licenses/mit-license.php The MIT License                                              
      25                 :  * @version    $Revision: 1.4 $ $Date: 2006/12/01 13:41:52 $                                                                    
      26                 :  * @link       http://jettable.rasign.jp/                                                                                       
      27                 :  */                                                                                                                             
      28                 : class JetTable{                                                                                                                 
      29                 :     private $header;                                                                                                               
      30                 :     private $records;                                                                                                              
      31                 :     private $attribute;                                                                                                            
      32                 :     private $attributeRow;                                                                                                         
      33                 :     private $attributeColumn;                                                                                                      
      34                 :     private $attributeHeaderRow;                                                                                                   
      35                 :     private $attributeHeaderColumn;                                                                                                
      36                 :     private $attributeColumnEreg;                                                                                                  
      37                 :     private $attributeRowEreg;                                                                                                     
      38                 :                                                                                                                                 
      39                 :     private $formatter;                                                                                                            
      40                 :                                                                                                                                 
      41                 :     private $margeHeaderColumn;                                                                                                    
      42                 :     private $margeColumnRow;                                                                                                       
      43                 :                                                                                                                                 
      44                 :     private $attributeColumnAll;                                                                                                   
      45                 :     private $attributeHeaderColumnAll;                                                                                             
      46                 :                                                                                                                                 
      47                 :     private $useSort;                                                                                                              
      48                 :     private $sortKey;                                                                                                              
      49                 :     private $sortType;                                                                                                             
      50                 :     private $sortableHeaderKeys;                                                                                                   
      51                 :                                                                                                                                 
      52                 :     private $usePager;                                                                                                             
      53                 :     private $pager;                                                                                                                
      54                 :                                                                                                                                 
      55                 :     private $usePlugin;                                                                                                            
      56                 :                                                                                                                                 
      57                 :     private $scriptName;                                                                                                           
      58                 :                                                                                                                                 
      59                 :     private $plugin;                                                                                                               
      60                 :                                                                                                                                 
      61                 :     private $outputForm;                                                                                                           
      62                 :                                                                                                                                 
      63                 :     private $parameterPageString = "page";                                                                                         
      64                 :     private $parameterPageParString = "pagePar";                                                                                   
      65                 :     private $parameterSortKeyString = "sortKey";                                                                                   
      66                 :     private $parameterSortTypeString = "sortType";                                                                                 
      67                 :     private $parameterSortTypeAsc = "asc";                                                                                         
      68                 :     private $parameterSortTypeDesc = "desc";                                                                                       
      69                 :     private $sortTypeAscMarkString = "▲";                                                                                         
      70                 :     private $sortTypeDescMarkString = "▼";                                                                                        
      71                 :     private $rowidName = "rowidentifier";                                                                                          
      72                 :                                                                                                                                 
      73                 :     private $roundBackgroundColors;                                                                                                
      74                 :                                                                                                                                 
      75                 :     /**                                                                                                                         
      76                 :      * デフォルトコンストラクタ<br>                                                                                             
      77                 :      * 各変数の初期化を行います。<br>                                                                                           
      78                 :      *                                                                                                                          
      79                 :      * @access public                                                                                                           
      80                 :      */                                                                                                                         
      81                 :     public function __construct(){                                                                                                 
      82              26 :         $this->header = array();                                                                                                      
      83              26 :         $this->records = array();                                                                                                     
      84              26 :         $this->attribute = array();                                                                                                   
      85              26 :         $this->attributeRow = array();                                                                                                
      86              26 :         $this->attributeColumn = array();                                                                                             
      87              26 :         $this->attributeColumnAll = array();                                                                                          
      88              26 :         $this->attributeHeaderRow = array();                                                                                          
      89              26 :         $this->attributeHeaderColumn = array();                                                                                       
      90              26 :         $this->attributeHeaderColumnAll = array();                                                                                    
      91              26 :         $this->attributeColumnEreg = array();                                                                                         
      92              26 :         $this->attributeRowEreg = array();                                                                                            
      93              26 :         $this->sortableHeaderKeys = array();                                                                                          
      94              26 :         $this->plugin = array();                                                                                                      
      95              26 :         $this->margeHeaderColumn = array();                                                                                           
      96              26 :         $this->margeColumnRow = array();                                                                                              
      97              26 :         $this->roundBackgroundColors = array();                                                                                       
      98              26 :         $this->outputForm = array();                                                                                                  
      99              26 :         $this->formatter = array();                                                                                                   
     100                 :                                                                                                                                 
     101              26 :         $this->useSort = false;                                                                                                       
     102              26 :         $this->usePager = false;                                                                                                      
     103              26 :         $this->usePlugin = false;                                                                                                     
     104                 :                                                                                                                                 
     105              26 :          $this->scriptName = "";                                                                                                      
     106                 :                                                                                                                                 
     107              26 :         $this->pager = new JetPager();                                                                                                
     108              26 :     }                                                                                                                              
     109                 :                                                                                                                                 
     110                 :     /**                                                                                                                         
     111                 :      * テーブルに対する属性の追加<br>                                                                                           
     112                 :      * Tableタグに対して属性を追加します。<br>                                                                                  
     113                 :      *                                                                                                                          
     114                 :      * @param $key 属性のキーとなる文字列                                                                                       
     115                 :      * @param $value 属性値                                                                                                     
     116                 :      * @access public                                                                                                           
     117                 :      */                                                                                                                         
     118                 :     public function appendAttribute($key, $value){                                                                                 
     119               1 :         $attribute = new JetAttribute();                                                                                              
     120               1 :         $attribute->key = $key;                                                                                                       
     121               1 :         $attribute->value = $value;                                                                                                   
     122               1 :         $this->attribute[] = $attribute;                                                                                              
     123               1 :     }                                                                                                                              
     124                 :                                                                                                                                 
     125                 :     /**                                                                                                                         
     126                 :      * ヘッダ行に対する属性の追加<br>                                                                                           
     127                 :      * ヘッダのTRタグに対して属性を追加します。<br>                                                                             
     128                 :      *                                                                                                                          
     129                 :      * @param $key 属性のキーとなる文字列                                                                                       
     130                 :      * @param $value 属性値                                                                                                     
     131                 :      * @access public                                                                                                           
     132                 :      */                                                                                                                         
     133                 :     public function appendAttributeHeaderRow($key, $value){                                                                        
     134               1 :         $attributeHeaderRow = new JetAttribute();                                                                                     
     135               1 :         $attributeHeaderRow->key = $key;                                                                                              
     136               1 :         $attributeHeaderRow->value = $value;                                                                                          
     137               1 :         $this->attributeHeaderRow[] = $attributeHeaderRow;                                                                            
     138               1 :     }                                                                                                                              
     139                 :                                                                                                                                 
     140                 :     /**                                                                                                                         
     141                 :      * ヘッダのデータセルに対する属性の追加<br>                                                                                 
     142                 :      * ヘッダのTDタグに対して属性を追加します。<br>                                                                             
     143                 :      *                                                                                                                          
     144                 :      * @param $columnName 属性を付与する列名                                                                                    
     145                 :      * @param $key 属性のキーとなる文字列                                                                                       
     146                 :      * @param $value 属性値                                                                                                     
     147                 :      * @access public                                                                                                           
     148                 :      */                                                                                                                         
     149                 :     public function appendAttributeHeaderColumn($columnName, $key, $value){                                                        
     150               1 :         $attributeHeaderColumn = new JetAttributeColumn();                                                                            
     151               1 :         $attributeHeaderColumn->columnName = $columnName;                                                                             
     152               1 :         $attributeHeaderColumn->key = $key;                                                                                           
     153               1 :         $attributeHeaderColumn->value = $value;                                                                                       
     154               1 :         $this->attributeHeaderColumn[] = $attributeHeaderColumn;                                                                      
     155               1 :     }                                                                                                                              
     156                 :                                                                                                                                 
     157                 :     /**                                                                                                                         
     158                 :      * データ行に対する属性の追加<br>                                                                                           
     159                 :      * データ行のTRタグに対して属性を追加します。<br>                                                                           
     160                 :      *                                                                                                                          
     161                 :      * @param $key 属性のキーとなる文字列                                                                                       
     162                 :      * @param $value 属性値                                                                                                     
     163                 :      * @access public                                                                                                           
     164                 :      */                                                                                                                         
     165                 :     public function appendAttributeRow($key, $value){                                                                              
     166               1 :         $attributeRow = new JetAttribute();                                                                                           
     167               1 :         $attributeRow->key = $key;                                                                                                    
     168               1 :         $attributeRow->value = $value;                                                                                                
     169               1 :         $this->attributeRow[] = $attributeRow;                                                                                        
     170               1 :     }                                                                                                                              
     171                 :                                                                                                                                 
     172                 :     /**                                                                                                                         
     173                 :      * データセルに対する属性の追加<br>                                                                                         
     174                 :      * データ行のTDタグに対して属性を追加します。<br>                                                                           
     175                 :      *                                                                                                                          
     176                 :      * @param $columnName 属性を付与する列名                                                                                    
     177                 :      * @param $key 属性のキーとなる文字列                                                                                       
     178                 :      * @param $value 属性値                                                                                                     
     179                 :      * @access public                                                                                                           
     180                 :      */                                                                                                                         
     181                 :     public function appendAttributeColumn($columnName, $key, $value){                                                              
     182               1 :         $attributeColumn = new JetAttributeColumn();                                                                                  
     183               1 :         $attributeColumn->columnName = $columnName;                                                                                   
     184               1 :         $attributeColumn->key = $key;                                                                                                 
     185               1 :         $attributeColumn->value = $value;                                                                                             
     186               1 :         $this->attributeColumn[] = $attributeColumn;                                                                                  
     187               1 :     }                                                                                                                              
     188                 :                                                                                                                                 
     189                 :     /**                                                                                                                         
     190                 :      * データ行に対する属性の追加<br>                                                                                           
     191                 :      * 指定した正規表現と対象列の値が一致した場合、                                                                             
     192                 :      * データ行のTRタグに対して属性を追加します。<br>                                                                           
     193                 :      *                                                                                                                          
     194                 :      * @param $columnName 属性を付与する列名                                                                                    
     195                 :      * @param $ereg 正規表現                                                                                                    
     196                 :      * @param $key 属性のキーとなる文字列                                                                                       
     197                 :      * @param $value 属性値                                                                                                     
     198                 :      * @access public                                                                                                           
     199                 :      */                                                                                                                         
     200                 :     public function appendAttributeRowEreg($columnName, $ereg, $key, $value){                                                      
     201               1 :         $attributeRowEreg = new JetAttributeColumnEreg();                                                                             
     202               1 :         $attributeRowEreg->columnName = $columnName;                                                                                  
     203               1 :         $attributeRowEreg->key = $key;                                                                                                
     204               1 :         $attributeRowEreg->value = $value;                                                                                            
     205               1 :         $attributeRowEreg->ereg = $ereg;                                                                                              
     206               1 :         $this->attributeRowEreg[] = $attributeRowEreg;                                                                                
     207               1 :     }                                                                                                                              
     208                 :                                                                                                                                 
     209                 :     /**                                                                                                                         
     210                 :      * データセルに対する属性の追加<br>                                                                                         
     211                 :      * 指定した正規表現と対象列の値が一致した場合、                                                                             
     212                 :      * データ行のTDタグに対して属性を追加します。<br>                                                                           
     213                 :      *                                                                                                                          
     214                 :      * @param $columnName 属性を付与する列名                                                                                    
     215                 :      * @param $ereg 正規表現                                                                                                    
     216                 :      * @param $key 属性のキーとなる文字列                                                                                       
     217                 :      * @param $value 属性値                                                                                                     
     218                 :      * @access public                                                                                                           
     219                 :      */                                                                                                                         
     220                 :     public function appendAttributeColumnEreg($columnName, $ereg, $key, $value){                                                   
     221               1 :         $attributeColumnEreg = new JetAttributeColumnEreg();                                                                          
     222               1 :         $attributeColumnEreg->columnName = $columnName;                                                                               
     223               1 :         $attributeColumnEreg->key = $key;                                                                                             
     224               1 :         $attributeColumnEreg->value = $value;                                                                                         
     225               1 :         $attributeColumnEreg->ereg = $ereg;                                                                                           
     226               1 :         $this->attributeColumnEreg[] = $attributeColumnEreg;                                                                          
     227               1 :     }                                                                                                                              
     228                 :                                                                                                                                 
     229                 :     /**                                                                                                                         
     230                 :      * データセルに対する属性の追加<br>                                                                                         
     231                 :      * 指定した属性をすべてのデータセルに対して付与します。                                                                     
     232                 :      *                                                                                                                          
     233                 :      * @param $key 属性のキーとなる文字列                                                                                       
     234                 :      * @param $value 属性値                                                                                                     
     235                 :      * @access public                                                                                                           
     236                 :      */                                                                                                                         
     237                 :     public function appendAttributeColumnAll($key, $value){                                                                        
     238               1 :         $attribute = new JetAttribute();                                                                                              
     239               1 :         $attribute->key = $key;                                                                                                       
     240               1 :         $attribute->value = $value;                                                                                                   
     241               1 :         $this->attributeColumnAll[] = $attribute;                                                                                     
     242               1 :     }                                                                                                                              
     243                 :                                                                                                                                 
     244                 :     /**                                                                                                                         
     245                 :      * ヘッダ行のデータセルに対する属性の追加<br>                                                                               
     246                 :      * 指定した属性をヘッダ行のすべてのデータセルに対して付与します。                                                           
     247                 :      *                                                                                                                          
     248                 :      * @param $key 属性のキーとなる文字列                                                                                       
     249                 :      * @param $value 属性値                                                                                                     
     250                 :      * @access public                                                                                                           
     251                 :      */                                                                                                                         
     252                 :     public function appendAttributeHeaderColumnAll($key, $value){                                                                  
     253               1 :         $attribute = new JetAttribute();                                                                                              
     254               1 :         $attribute->key = $key;                                                                                                       
     255               1 :         $attribute->value = $value;                                                                                                   
     256               1 :         $this->attributeHeaderColumnAll[] = $attribute;                                                                               
     257               1 :     }                                                                                                                              
     258                 :                                                                                                                                 
     259                 :     /**                                                                                                                         
     260                 :      * ソート機能出力の有無を指定<br>                                                                                           
     261                 :      * ソート機能の利用有無を指定します。                                                                                       
     262                 :      *                                                                                                                          
     263                 :      * @param $useSort trueを指定するとソート機能が利用可能になります。                                                         
     264                 :      * @access public                                                                                                           
     265                 :      */                                                                                                                         
     266                 :     public function useSort($useSort){                                                                                             
     267               5 :         $this->useSort = $useSort;                                                                                                    
     268               5 :     }                                                                                                                              
     269                 :                                                                                                                                 
     270                 :     /**                                                                                                                         
     271                 :      * プラグインの利用有無を指定<br>                                                                                           
     272                 :      * プラグインの利用有無を指定します。                                                                                       
     273                 :      *                                                                                                                          
     274                 :      * @param $useSort trueを指定するとプラグインが利用可能になります。                                                         
     275                 :      * @access public                                                                                                           
     276                 :      */                                                                                                                         
     277                 :     public function usePlugin($usePlugin){                                                                                         
     278               3 :         $this->usePlugin = $usePlugin;                                                                                                
     279               3 :     }                                                                                                                              
     280                 :                                                                                                                                 
     281                 :     /**                                                                                                                         
     282                 :      * ページング機能の利用有無を指定<br>                                                                                       
     283                 :      * ページング機能の利用有無を指定します。                                                                                   
     284                 :      *                                                                                                                          
     285                 :      * @param $usePager trueを指定するとページング機能が利用可能になります。                                                    
     286                 :      * @access public                                                                                                           
     287                 :      */                                                                                                                         
     288                 :     public function usePager($usePager){                                                                                           
     289               3 :         $this->usePager = $usePager;                                                                                                  
     290               3 :     }                                                                                                                              
     291                 :                                                                                                                                 
     292                 :     /**                                                                                                                         
     293                 :      * ソート列の指定<br>                                                                                                       
     294                 :      * テーブルの一分の列のみソート機能を有効にしたい場合に利用します。                                                         
     295                 :      *                                                                                                                          
     296                 :      * @param $headerKeys ソート機能を利用する列名の配列。                                                                      
     297                 :      * @access public                                                                                                           
     298                 :      */                                                                                                                         
     299                 :     public function setSortableHeader($headerKeys){                                                                                
     300               1 :         if(is_array($headerKeys)){                                                                                                    
     301               1 :             foreach($headerKeys as $headerKey){                                                                                          
     302               1 :                 $this->sortableHeaderKeys[] = $headerKey;                                                                                   
     303               1 :             }                                                                                                                            
     304               1 :         }else{                                                                                                                        
     305               0 :             $this->sortableHeaderKeys[] = $headerKeys;                                                                                   
     306                 :         }                                                                                                                             
     307               1 :     }                                                                                                                              
     308                 :                                                                                                                                 
     309                 :     private function sort(){                                                                                                       
     310               5 :         $sortKey = $this->sortKey;                                                                                                    
     311               5 :         if(!empty($sortKey)){                                                                                                         
     312               3 :             $recordCount = count($this->records);                                                                                        
     313               3 :             for($i = 0; $i < $recordCount; $i++){                                                                                        
     314               3 :                 $this->records[$i][$this->rowidName] = $i;                                                                                  
     315               3 :             }                                                                                                                            
     316               3 :             $sortArray = array();                                                                                                        
     317               3 :             foreach($this->records as $record){                                                                                          
     318               3 :                 $sortArray[$record[$this->rowidName]] = $record[$sortKey];                                                                  
     319               3 :             }                                                                                                                            
     320               3 :             if($this->sortType == $this->parameterSortTypeAsc){                                                                          
     321               2 :                 asort($sortArray);                                                                                                          
     322               2 :             }else{                                                                                                                       
     323               1 :                 arsort($sortArray);                                                                                                         
     324                 :             }                                                                                                                            
     325               3 :             $sortRecords = array();                                                                                                      
     326               3 :             foreach($sortArray as $sortKey=>$sortValue){                                                                                 
     327               3 :                 foreach($this->records as $record){                                                                                         
     328               3 :                     if($record[$this->rowidName] == $sortKey){                                                                                 
     329               3 :                         unset($record[$this->rowidName]);                                                                                         
     330               3 :                         $sortRecords[] = $record;                                                                                                 
     331               3 :                         break;                                                                                                                    
     332                 :                     }                                                                                                                          
     333               0 :                 }                                                                                                                           
     334               3 :             }                                                                                                                            
     335               3 :             $this->records = $sortRecords;                                                                                               
     336                 :         }                                                                                                                             
     337               5 :     }                                                                                                                              
     338                 :                                                                                                                                 
     339                 :     /**                                                                                                                         
     340                 :      * テーブルのデータを設定<br>                                                                                               
     341                 :      * テーブルに出力するためのデータを設定する。                                                                               
     342                 :      *                                                                                                                          
     343                 :      * @param $records データ配列                                                                                               
     344                 :      * @access public                                                                                                           
     345                 :      */                                                                                                                         
     346                 :     public function setData($records){                                                                                             
     347              25 :         $this->records = $records;                                                                                                    
     348              25 :         $this->pager->setTotalItemCount(count($records));                                                                             
     349              25 :     }                                                                                                                              
     350                 :                                                                                                                                 
     351                 :     /**                                                                                                                         
     352                 :      * テーブルのヘッダを設定<br>                                                                                               
     353                 :      * テーブルのヘッダを自由に設定する。                                                                                       
     354                 :      *                                                                                                                          
     355                 :      * @param $header 出力するヘッダ配列。                                                                                      
     356                 :      * @access public                                                                                                           
     357                 :      */                                                                                                                         
     358                 :     public function setHeader($header){                                                                                            
     359               1 :         $this->header = $header;                                                                                                      
     360               1 :     }                                                                                                                              
     361                 :                                                                                                                                 
     362                 :     /**                                                                                                                         
     363                 :      * ソート状態の設定<br>                                                                                                     
     364                 :      * 出力時のソート状態を指定する。                                                                                           
     365                 :      *                                                                                                                          
     366                 :      * @param $sortKey ソートキーとして利用されている列名。                                                                     
     367                 :      * @param $sortType ソート順(asc,desc,null)                                                                                 
     368                 :      * @access public                                                                                                           
     369                 :      */                                                                                                                         
     370                 :     public function initializeSort($sortKey, $sortType){                                                                           
     371               3 :         $this->sortKey = $sortKey;                                                                                                    
     372               3 :         $this->sortType = $sortType;                                                                                                  
     373               3 :     }                                                                                                                              
     374                 :                                                                                                                                 
     375                 :     /**                                                                                                                         
     376                 :      * ページング状態の設定<br>                                                                                                 
     377                 :      * 出力時のページング状態を指定する。                                                                                       
     378                 :      *                                                                                                                          
     379                 :      * @param $currentPageNumber 表示するページ番号。                                                                           
     380                 :      * @param $pageParItems 1ページに表示する列数                                                                              
     381                 :      * @access public                                                                                                           
     382                 :      */                                                                                                                         
     383                 :     public function initializePager($currentPageNumber, $pageParItems){                                                            
     384               3 :         if(!empty($currentPageNumber)){                                                                                               
     385               3 :             $this->pager->setCurrentPageNumber($currentPageNumber);                                                                      
     386                 :         }                                                                                                                             
     387               3 :         if(!empty($pageParItems)){                                                                                                    
     388               3 :             $this->pager->setPageParItems($pageParItems);                                                                                
     389                 :         }                                                                                                                             
     390               3 :     }                                                                                                                              
     391                 :                                                                                                                                 
     392                 :     /**                                                                                                                         
     393                 :      * フォーム部品出力設定<br>                                                                                                 
     394                 :      * 列に対してフォーム部品として出力する設定を行う。                                                                         
     395                 :      *                                                                                                                          
     396                 :      * @param $column 対象の列名                                                                                                
     397                 :      * @param $type 部品の種類(text|textarea|select)                                                                            
     398                 :      * @param $attribute 部品に付加する属性                                                                                     
     399                 :      * @access public                                                                                                           
     400                 :      */                                                                                                                         
     401                 :     public function setOutputForm($column, $type, $attribute = array()){                                                           
     402               1 :         $this->outputForm[$column] = $type;                                                                                           
     403               1 :         $this->outputForm[$column . "Attribute"] = $attribute;                                                                        
     404               1 :     }                                                                                                                              
     405                 :                                                                                                                                 
     406                 :     /**                                                                                                                         
     407                 :      * 日付フォーマット出力設定<br>                                                                                             
     408                 :      * 列の値に対して日付フォーマットを指定する。                                                                               
     409                 :      *                                                                                                                          
     410                 :      * @param $column 対象の列名                                                                                                
     411                 :      * @param $formatString フォーマット                                                                                        
     412                 :      * @see PHPマニュアル http://au3.php.net/date                                                                                  
     413                 :      * @access public                                                                                                           
     414                 :      */                                                                                                                         
     415                 :     public function setDateFormatColumn($column, $format){                                                                         
     416               1 :         if(empty($column)){                                                                                                           
     417               0 :             return;                                                                                                                      
     418                 :         }                                                                                                                             
     419                 :                                                                                                                                 
     420               1 :         $formatter = new JetDateFormatter($format);                                                                                   
     421               1 :         $this->formatter[$column] = $formatter;                                                                                       
     422               1 :     }                                                                                                                              
     423                 :                                                                                                                                 
     424                 :     /**                                                                                                                         
     425                 :      * テキストテーブル出力<br>                                                                                                 
     426                 :      * テーブルをタブ区切りテキストとして表示します。                                                                           
     427                 :      *                                                                                                                          
     428                 :      * @access public                                                                                                           
     429                 :      */                                                                                                                         
     430                 :     public function getTableText(){                                                                                                
     431               2 :         $records = $this->getRecords();                                                                                               
     432               2 :         if(empty($records)){                                                                                                          
     433               1 :             return null;                                                                                                                 
     434                 :         }                                                                                                                             
     435               1 :         $headerArray = $this->getHeaderArray($records);                                                                               
     436                 :                                                                                                                                 
     437               1 :         $text .= implode("\t", $headerArray);                                                                                         
     438               1 :         $text .= "\r\n";                                                                                                              
     439                 :                                                                                                                                 
     440               1 :         if($this->usePager){                                                                                                          
     441               0 :             $records = $this->getViewRecords();                                                                                          
     442                 :         }                                                                                                                             
     443                 :                                                                                                                                 
     444               1 :         foreach($records as $record){                                                                                                 
     445               1 :             foreach($headerArray as $headerKey=>$headerValue){                                                                           
     446               1 :                 $text .= $record[$headerKey];                                                                                               
     447               1 :                 $text .= "\t";                                                                                                              
     448               1 :             }                                                                                                                            
     449               1 :             $text .= "\r\n";                                                                                                             
     450               1 :         }                                                                                                                             
     451                 :                                                                                                                                 
     452               1 :         return $text;                                                                                                                 
     453                 :     }                                                                                                                              
     454                 :                                                                                                                                 
     455                 :     private function getHeaderArray($records){                                                                                     
     456              25 :         if(empty($this->header)){                                                                                                     
     457              24 :             $headerArray = array();                                                                                                      
     458              24 :             foreach($records as $record){                                                                                                
     459              24 :                 if(count($headerArray) < count($record)){                                                                                   
     460              24 :                     $workHeaderArray = array();                                                                                                
     461              24 :                     foreach($record as $itemKey=>$itemValue){                                                                                  
     462              24 :                         $workHeaderArray[$itemKey] = $itemKey;                                                                                    
     463              24 :                     }                                                                                                                          
     464              24 :                     $headerArray = $workHeaderArray;                                                                                           
     465                 :                 }                                                                                                                           
     466              24 :             }                                                                                                                            
     467              24 :         }else{                                                                                                                        
     468               1 :             $headerArray = $this->header;                                                                                                
     469                 :         }                                                                                                                             
     470                 :                                                                                                                                 
     471              25 :         return $headerArray;                                                                                                          
     472                 :     }                                                                                                                              
     473                 :                                                                                                                                 
     474                 :     private function getUrlAttributeString(){                                                                                      
     475               1 :         $attributeArray = $this->getUrlAttribute();                                                                                   
     476               1 :         if(!empty($attributeArray)){                                                                                                  
     477               1 :             foreach($attributeArray as $attribute){                                                                                      
     478               1 :                 $attributeString .= "&" . $attribute->key . "=" . urlencode($attribute->value);                                             
     479               1 :             }                                                                                                                            
     480                 :         }                                                                                                                             
     481               1 :         return $attributeString;                                                                                                      
     482                 :     }                                                                                                                              
     483                 :                                                                                                                                 
     484                 :     private function getUrlAttribute(){                                                                                            
     485               3 :         $attributeArray = array();                                                                                                    
     486               3 :         if($this->useSort){                                                                                                           
     487               1 :             if(!empty($this->sortKey)){                                                                                                  
     488               1 :                 $attribute = new JetAttribute();                                                                                            
     489               1 :                 $attribute->key = $this->parameterSortKeyString;                                                                            
     490               1 :                 $attribute->value = $this->sortKey;                                                                                         
     491               1 :                 $attributeArray[] = $attribute;                                                                                             
     492                 :             }                                                                                                                            
     493               1 :             if(!empty($this->sortType)){                                                                                                 
     494               1 :                 $attribute = new JetAttribute();                                                                                            
     495               1 :                 $attribute->key = $this->parameterSortTypeString;                                                                           
     496               1 :                 $attribute->value = $this->sortType;                                                                                        
     497               1 :                 $attributeArray[] = $attribute;                                                                                             
     498                 :             }                                                                                                                            
     499                 :         }                                                                                                                             
     500               3 :         if($this->usePager){                                                                                                          
     501               2 :             $attribute = new JetAttribute();                                                                                             
     502               2 :             $attribute->key = $this->parameterPageString;                                                                                
     503               2 :             $attribute->value = $this->pager->getCurrentPageNumber();                                                                    
     504               2 :             $attributeArray[] = $attribute;                                                                                              
     505                 :                                                                                                                                 
     506               2 :             $attribute = new JetAttribute();                                                                                             
     507               2 :             $attribute->key = $this->parameterPageParString;                                                                             
     508               2 :             $attribute->value = $this->pager->getPageParItems();                                                                         
     509               2 :             $attributeArray[] = $attribute;                                                                                              
     510                 :         }                                                                                                                             
     511               3 :         return $attributeArray;                                                                                                       
     512                 :     }                                                                                                                              
     513                 :                                                                                                                                 
     514                 :     /**                                                                                                                         
     515                 :      * ページングリンクの取得<br>                                                                                               
     516                 :      * ページングリンクを初期化して返します。                                                                                   
     517                 :      *                                                                                                                          
     518                 :      * @access public                                                                                                           
     519                 :      */                                                                                                                         
     520                 :     public function getPagerHtml(){                                                                                                
     521               3 :         return $this->pager->getBasicPagerHtml($this->getUrlAttribute());                                                             
     522                 :     }                                                                                                                              
     523                 :                                                                                                                                 
     524                 :     private function getRecords(){                                                                                                 
     525              26 :         if(empty($this->records)){                                                                                                    
     526               2 :             return array();                                                                                                              
     527                 :         }                                                                                                                             
     528                 :                                                                                                                                 
     529              25 :         if($this->useSort){                                                                                                           
     530               5 :             $this->sort();                                                                                                               
     531                 :         }                                                                                                                             
     532                 :                                                                                                                                 
     533              25 :         return $this->records;                                                                                                        
     534                 :     }                                                                                                                              
     535                 :                                                                                                                                 
     536                 :     private function getViewRecords(){                                                                                             
     537               3 :         $records = $this->getRecords();                                                                                               
     538                 :                                                                                                                                 
     539               3 :         if(empty($records)){                                                                                                          
     540               0 :             return null;                                                                                                                 
     541                 :         }                                                                                                                             
     542                 :                                                                                                                                 
     543               3 :         if($this->usePager){                                                                                                          
     544               3 :             $page = $this->pager->getCurrentPageNumber();                                                                                
     545               3 :             $pageitem = $this->pager->getPageParItems();                                                                                 
     546               3 :             $startIndex = ($page - 1) * $pageitem;                                                                                       
     547               3 :             $endIndex = ($page - 1) * $pageitem + $pageitem - 1;                                                                         
     548               3 :         }else{                                                                                                                        
     549               0 :             $endIndex = 999999;                                                                                                          
     550                 :         }                                                                                                                             
     551                 :                                                                                                                                 
     552               3 :         $viewRecordArray = array();                                                                                                   
     553               3 :         $i = 0;                                                                                                                       
     554               3 :         foreach($records as $record){                                                                                                 
     555               3 :             if($i >= $startIndex && $i <= $endIndex){                                                                                    
     556               3 :                 $viewRecordArray[] = $record;                                                                                               
     557                 :             }                                                                                                                            
     558               3 :             $i = $i + 1;                                                                                                                 
     559               3 :         }                                                                                                                             
     560               3 :         return $viewRecordArray;                                                                                                      
     561                 :     }                                                                                                                              
     562                 :                                                                                                                                 
     563                 :     /**                                                                                                                         
     564                 :      * テーブルHTMLコードの取得<br>                                                                                             
     565                 :      * 現在の状態でテーブル出力用のHTMLコードを返します。                                                                       
     566                 :      *                                                                                                                          
     567                 :      * @access public                                                                                                           
     568                 :      */                                                                                                                         
     569                 :     public function getTableHtml(){                                                                                                
     570              25 :         $records = $this->getRecords();                                                                                               
     571              25 :         if(empty($records)){                                                                                                          
     572               2 :             return null;                                                                                                                 
     573                 :         }                                                                                                                             
     574                 :                                                                                                                                 
     575              24 :         $tableTag .= "<table>";                                                                                                       
     576              24 :         foreach($this->attribute as $attributeClass){                                                                                 
     577               1 :             $tableTag = JetHtmlUtil::joinTagAttribute($tableTag, $attributeClass->key, $attributeClass->value);                          
     578               1 :         }                                                                                                                             
     579              24 :         $text .= $tableTag;                                                                                                           
     580                 :                                                                                                                                 
     581              24 :         $trTag .= "<tr>";                                                                                                             
     582              24 :         foreach($this->attributeHeaderRow as $attributeHeaderRowClass){                                                               
     583               1 :             $trTag = JetHtmlUtil::joinTagAttribute($trTag, $attributeHeaderRowClass->key, $attributeHeaderRowClass->value);              
     584               1 :         }                                                                                                                             
     585              24 :         $text .= $trTag;                                                                                                              
     586                 :                                                                                                                                 
     587              24 :         $headerArray = $this->getHeaderArray($records);                                                                               
     588                 :                                                                                                                                 
     589              24 :         $margeCount = 0;                                                                                                              
     590              24 :         foreach($headerArray as $headerKey=>$headerValue){                                                                            
     591              24 :             if($margeCount > 0){                                                                                                         
     592               1 :                 $margeCount = $margeCount - 1;                                                                                              
     593               1 :                 continue;                                                                                                                   
     594                 :             }                                                                                                                            
     595                 :                                                                                                                                 
     596              24 :             $tdTag = "<th>";                                                                                                             
     597              24 :             if(!empty($this->margeHeaderColumn)){                                                                                        
     598               1 :                 foreach($this->margeHeaderColumn as $margeHeaderColumnName=>$margeHeaderColumnCount){                                       
     599               1 :                     if($margeHeaderColumnName == $headerKey){                                                                                  
     600               1 :                         $tdTag = JetHtmlUtil::joinTagAttribute($tdTag, "colspan", $margeHeaderColumnCount);                                       
     601               1 :                         $margeCount = $margeHeaderColumnCount - 1;                                                                                
     602                 :                     }                                                                                                                          
     603               1 :                 }                                                                                                                           
     604                 :             }                                                                                                                            
     605                 :                                                                                                                                 
     606              24 :             foreach($this->attributeHeaderColumnAll as $attributeHeaderColumnAllClass){                                                  
     607               1 :                 $tdTag = JetHtmlUtil::joinTagAttribute($tdTag, $attributeHeaderColumnAllClass->key, $attributeHeaderColumnAllClass->value); 
     608               1 :             }                                                                                                                            
     609                 :                                                                                                                                 
     610              24 :             foreach($this->attributeHeaderColumn as $attributeHeaderColumnClass){                                                        
     611               1 :                 if($headerKey == $attributeHeaderColumnClass->columnName){                                                                  
     612               1 :                     $tdTag = JetHtmlUtil::joinTagAttribute($tdTag, $attributeHeaderColumnClass->key, $attributeHeaderColumnClass->value);      
     613                 :                 }                                                                                                                           
     614               1 :             }                                                                                                                            
     615                 :                                                                                                                                 
     616              24 :             if($this->useSort){                                                                                                          
     617               5 :                 if(!empty($this->sortableHeaderKeys) && !in_array($headerKey, $this->sortableHeaderKeys)){                                  
     618               1 :                     $text .= $tdTag;                                                                                                           
     619               1 :                     $text .= $headerValue;                                                                                                     
     620               1 :                     continue;                                                                                                                  
     621                 :                 }                                                                                                                           
     622                 :                                                                                                                                 
     623               5 :                 $outputFormKey = array_keys($this->outputForm);                                                                             
     624               5 :                 if(in_array($headerKey, $outputFormKey)){                                                                                   
     625               0 :                     $text .= $tdTag;                                                                                                           
     626               0 :                     $text .= $headerValue;                                                                                                     
     627               0 :                     continue;                                                                                                                  
     628                 :                 }                                                                                                                           
     629                 :                                                                                                                                 
     630               5 :                 $urlSortKey = urlencode($headerValue);                                                                                      
     631               5 :                 if($headerValue == $this->sortKey){                                                                                         
     632               3 :                     if($this->sortType == $this->parameterSortTypeAsc){                                                                        
     633               2 :                         $urlSortType = $this->parameterSortTypeDesc;                                                                              
     634               3 :                     }else if($this->sortType == $this->parameterSortTypeDesc){                                                                 
     635               1 :                         $urlSortType = "";                                                                                                        
     636               1 :                         $urlSortKey = "";                                                                                                         
     637               1 :                     }else{                                                                                                                     
     638               0 :                         $urlSortType = $this->parameterSortTypeAsc;                                                                               
     639                 :                     }                                                                                                                          
     640               0 :                 }else{                                                                                                                      
     641               5 :                         $urlSortType = $this->parameterSortTypeAsc;                                                                               
     642                 :                 }                                                                                                                           
     643               5 :                 $text .= $tdTag . "<a href=\"" . $this->scriptName . "?";                                                                   
     644               5 :                 if($this->usePager){                                                                                                        
     645               2 :                     $text .= "&" . $this->parameterPageString . "=" . $this->pager->getCurrentPageNumber();                                    
     646               2 :                     $text .= "&" . $this->parameterPageParString . "=" . $this->pager->getPageParItems();                                      
     647                 :                 }                                                                                                                           
     648               5 :                 if(!empty($urlSortKey)){                                                                                                    
     649               5 :                     $text .= "&" . $this->parameterSortKeyString . "=" . $urlSortKey;                                                          
     650                 :                 }                                                                                                                           
     651               5 :                 if(!empty($urlSortType)){                                                                                                   
     652               5 :                     $text .= "&" . $this->parameterSortTypeString . "=" . $urlSortType;                                                        
     653                 :                 }                                                                                                                           
     654               5 :                 $text .= "\">";                                                                                                             
     655               5 :                 $text .= $headerValue;                                                                                                      
     656               5 :                 $text .= "</a>";                                                                                                            
     657                 :                                                                                                                                 
     658               5 :                 if($headerValue == $this->sortKey){                                                                                         
     659               3 :                     if(empty($this->sortType) || $this->sortType == $this->parameterSortTypeAsc){                                              
     660               2 :                         $text .= "&nbsp;" . $this->sortTypeAscMarkString;                                                                         
     661               3 :                     }else if($this->sortType == $this->parameterSortTypeDesc){                                                                 
     662               1 :                         $text .= "&nbsp;" . $this->sortTypeDescMarkString;                                                                        
     663                 :                     }                                                                                                                          
     664                 :                 }                                                                                                                           
     665                 :                                                                                                                                 
     666               1 :             }else{                                                                                                                       
     667              20 :                 $text .= $tdTag;                                                                                                            
     668              20 :                 $text .= $headerValue;                                                                                                      
     669                 :             }                                                                                                                            
     670              24 :             $text .= "</th>";                                                                                                            
     671              24 :         }                                                                                                                             
     672              24 :         $text .= "</tr>";                                                                                                             
     673              24 :         if($this->usePager){                                                                                                          
     674               3 :             $records = $this->getViewRecords();                                                                                          
     675                 :         }                                                                                                                             
     676                 :                                                                                                                                 
     677              24 :         $rowColorIndex = 0;                                                                                                           
     678              24 :         $rowspanWorkArray = array();                                                                                                  
     679              24 :         $rowId = 0;                                                                                                                   
     680              24 :         foreach($records as $record){                                                                                                 
     681              24 :             $rowId++;                                                                                                                    
     682              24 :             $trTag = "<tr>";                                                                                                             
     683                 :                                                                                                                                 
     684              24 :             if(!empty($this->roundBackgroundColors)){                                                                                    
     685               1 :                 $trTag = JetHtmlUtil::joinTagAttribute($trTag, "style", "background-color:" . $this->roundBackgroundColors[$rowColorIndex]);
     686               1 :                 $rowColorIndex++;                                                                                                           
     687               1 :                 if($rowColorIndex >= count($this->roundBackgroundColors)){                                                                  
     688               1 :                     $rowColorIndex = 0;                                                                                                        
     689                 :                 }                                                                                                                           
     690                 :             }                                                                                                                            
     691                 :                                                                                                                                             
     692              24 :             foreach($this->attributeRowEreg as $attributeRowEregClass){                                                                  
     693               1 :                 foreach($headerArray as $headerKey=>$headerValue){                                                                          
     694               1 :                     if($headerKey == $attributeRowEregClass->columnName){                                                                      
     695               1 :                         if(mbereg($attributeRowEregClass->ereg, $record[$headerKey])){                                                            
     696               1 :                             $trTag = JetHtmlUtil::joinTagAttribute($trTag, $attributeRowEregClass->key, $attributeRowEregClass->value);              
     697                 :                         }                                                                                                                         
     698                 :                     }                                                                                                                          
     699               1 :                 }                                                                                                                           
     700               1 :             }                                                                                                                            
     701                 :                                                                                                                                 
     702              24 :             foreach($this->attributeRow as $attributeRowClass){                                                                          
     703               1 :                 $trTag = JetHtmlUtil::joinTagAttribute($trTag, $attributeRowClass->key, $attributeRowClass->value);                         
     704               1 :             }                                                                                                                            
     705              24 :             $text .= $trTag;                                                                                                             
     706                 :                                                                                                                                 
     707              24 :             foreach($headerArray as $headerKey=>$headerValue){                                                                           
     708              24 :                 $tdTag = "<td>";                                                                                                            
     709              24 :                 foreach($this->attributeColumnAll as $attributeColumnAllClass){                                                             
     710               1 :                     $tdTag = JetHtmlUtil::joinTagAttribute($tdTag, $attributeColumnAllClass->key, $attributeColumnAllClass->value);            
     711               1 :                 }                                                                                                                           
     712                 :                                                                                                                                                 
     713              24 :                 foreach($this->attributeColumnEreg as $attributeColumnEregClass){                                                           
     714               1 :                     if($headerKey == $attributeColumnEregClass->columnName){                                                                   
     715               1 :                         if(mbereg($attributeColumnEregClass->ereg,     $record[$headerKey])){                                                        
     716               1 :                             $tdTag = JetHtmlUtil::joinTagAttribute($tdTag, $attributeColumnEregClass->key, $attributeColumnEregClass->value);        
     717                 :                         }                                                                                                                         
     718                 :                     }                                                                                                                          
     719               1 :                 }                                                                                                                           
     720              24 :                 foreach($this->attributeColumn as $attributeColumnClass){                                                                   
     721               1 :                     if($headerKey == $attributeColumnClass->columnName){                                                                       
     722               1 :                         $tdTag = JetHtmlUtil::joinTagAttribute($tdTag, $attributeColumnClass->key, $attributeColumnClass->value);                 
     723                 :                     }                                                                                                                          
     724               1 :                 }                                                                                                                           
     725                 :                                                                                                                                 
     726              24 :                 if($rowspanWorkArray[$headerKey] < 2){                                                                                      
     727              24 :                     $margeColumnKey = array_keys($this->margeColumnRow);                                                                       
     728              24 :                     if(in_array($headerKey, $margeColumnKey)){                                                                                 
     729               1 :                         $rowspanWorkArray[$headerKey] = $this->margeColumnRow[$headerKey];                                                        
     730               1 :                         $tdTag = JetHtmlUtil::joinTagAttribute($tdTag, "rowspan", $rowspanWorkArray[$headerKey]);                                 
     731                 :                     }                                                                                                                          
     732                 :                                                                                                                                 
     733              24 :                     $text .= $tdTag;                                                                                                           
     734                 :                                                                                                                                 
     735              24 :                     $outputForm = $this->outputForm[$headerKey];                                                                               
     736              24 :                     $outputFormAttribute = $this->outputForm[$headerKey . "Attribute"];                                                        
     737              24 :                     if(empty($outputFormAttribute)){                                                                                           
     738              24 :                         $outputFormAttribute = array();                                                                                           
     739                 :                     }                                                                                                                          
     740              24 :                     $dataCellValue = $this->formatValue($headerKey, $record[$headerKey]);                                                      
     741              24 :                     $text .= $this->outputDataCell($outputForm, $dataCellValue, $outputFormAttribute, $headerKey);                             
     742                 :                                                                                                                                 
     743              24 :                 }else{                                                                                                                      
     744               1 :                     $rowspanWorkArray[$headerKey] = $rowspanWorkArray[$headerKey] - 1;                                                         
     745                 :                 }                                                                                                                           
     746               1 :             }                                                                                                                            
     747              24 :             $text .= "</tr>";                                                                                                            
     748              24 :         }                                                                                                                             
     749              24 :         $text .= "</table>";                                                                                                          
     750                 :                                                                                                                                 
     751              24 :         return $text;                                                                                                                 
     752                 :     }                                                                                                                              
     753                 :                                                                                                                                 
     754                 :     private function formatValue($key, $value){                                                                                    
     755              24 :         if(empty($value)){                                                                                                            
     756               1 :             return null;                                                                                                                 
     757                 :         }                                                                                                                             
     758              24 :         if(empty($key)){                                                                                                              
     759               0 :             return $value;                                                                                                               
     760                 :         }                                                                                                                             
     761                 :                                                                                                                                 
     762              24 :         $formatter = $this->formatter[$key];                                                                                          
     763              24 :         if(empty($formatter)){                                                                                                        
     764              24 :             return $value;                                                                                                               
     765                 :         }                                                                                                                             
     766                 :                                                                                                                                 
     767               1 :         return $formatter->format($value);                                                                                            
     768                 :     }                                                                                                                              
     769                 :                                                                                                                                 
     770                 :     /**                                                                                                                         
     771                 :      * 列リストの取得<br>                                                                                                       
     772                 :      * レコードから指定した列を抜き出して、配列を返します。<br>                                                                 
     773                 :      *                                                                                                                          
     774                 :      * @param $columnName 対象の列名                                                                                            
     775                 :      * @return 指定した列の配列                                                                                                 
     776                 :      * @access public                                                                                                           
     777                 :      */                                                                                                                         
     778                 :     private function getColulmnList($columnName){                                                                                  
     779               1 :         if(empty($columnName)){                                                                                                       
     780               0 :             return null;                                                                                                                 
     781                 :         }                                                                                                                             
     782               1 :         $records = $this->getRecords();                                                                                               
     783               1 :         if(empty($records)){                                                                                                          
     784               0 :             return null;                                                                                                                 
     785                 :         }                                                                                                                             
     786                 :                                                                                                                                 
     787               1 :         $list = array();                                                                                                              
     788               1 :         foreach($records as $record){                                                                                                 
     789               1 :             if(empty($record[$columnName])){                                                                                             
     790               0 :                 continue;                                                                                                                   
     791                 :             }                                                                                                                            
     792               1 :             $list[$record[$columnName]] = $record[$columnName];                                                                          
     793               1 :         }                                                                                                                             
     794               1 :         return $list;                                                                                                                 
     795                 :     }                                                                                                                              
     796                 :                                                                                                                                 
     797                 :     /**                                                                                                                         
     798                 :      * フォーム出力用HTMLコードの取得<br>                                                                                       
     799                 :      * 渡されたキーに対応したフォーム出力用のHTMLコードを返します。<br>                                                         
     800                 :      *                                                                                                                          
     801                 :      * @param $key 出力タイプ(text,textarea,select等)                                                                           
     802                 :      * @param $value 出力する値                                                                                                 
     803                 :      * @param $attribute タグに付加する属性の連想配列                                                                           
     804                 :      * @param $columnName 対象の列名                                                                                            
     805                 :      * @access public                                                                                                           
     806                 :      */                                                                                                                         
     807                 :     private function outputDataCell($key, $value, $attribute = array(), $columnName = null){                                       
     808              24 :         if($key == "text"){                                                                                                           
     809               1 :             $dataCell = new JetTextBoxDataCell($value, $attribute);                                                                      
     810                 :                                                                                                                                 
     811              24 :         }else if($key == "textarea"){                                                                                                 
     812               1 :             $dataCell = new JetTextAreaDataCell($value, $attribute);                                                                     
     813                 :                                                                                                                                 
     814              24 :         }else if($key == "select"){                                                                                                   
     815               1 :             $dataCell = new JetSelectBoxDataCell($value, $attribute, $this->getColulmnList($columnName));                                
     816                 :                                                                                                                                 
     817              24 :         }else if($key == "checkbox"){                                                                                                 
     818               1 :             $dataCell = new JetCheckBoxDataCell($value, $attribute);                                                                     
     819                 :                                                                                                                                 
     820              24 :         }else if($key == "radio"){                                                                                                    
     821               1 :             $dataCell = new JetRadioButtonDataCell($value, $attribute);                                                                  
     822                 :                                                                                                                                 
     823               1 :         }else{                                                                                                                        
     824              24 :             $dataCell = new JetLabelDataCell($value);                                                                                    
     825                 :         }                                                                                                                             
     826                 :                                                                                                                                 
     827              24 :         return $dataCell->getHtml();                                                                                                  
     828                 :     }                                                                                                                              
     829                 :                                                                                                                                 
     830                 :     /**                                                                                                                         
     831                 :      * テーブルHTMLコードの取得<br>                                                                                             
     832                 :      * すべての機能を利用したテーブル出力用のHTMLコードを返します。<br>                                                         
     833                 :      * 出力される機能<br>                                                                                                       
     834                 :      * ・ページング<br>                                                                                                         
     835                 :      * ・ソート<br>                                                                                                             
     836                 :      * ・プラグイン<br>                                                                                                         
     837                 :      * 各機能は利用フラグの状態に依存します。                                                                                   
     838                 :      *                                                                                                                          
     839                 :      * @access public                                                                                                           
     840                 :      */                                                                                                                         
     841                 :     public function getFullStackTableHtml(){                                                                                       
     842               4 :         $records = $this->getRecords();                                                                                               
     843               4 :         if(empty($records)){                                                                                                          
     844               1 :             return null;                                                                                                                 
     845                 :         }                                                                                                                             
     846                 :                                                                                                                                 
     847               3 :         if($this->usePager){                                                                                                          
     848               2 :             $text .= $this->getPagerHtml();                                                                                              
     849                 :         }                                                                                                                             
     850                 :                                                                                                                                 
     851               3 :         if($this->usePlugin){                                                                                                         
     852               2 :             $text .= "&nbsp;";                                                                                                           
     853               2 :             $text .= "&nbsp;";                                                                                                           
     854               2 :             $text .= "&nbsp;";                                                                                                           
     855               2 :             $text .= "Plugin:";                                                                                                          
     856                 :         }                                                                                                                             
     857               3 :         foreach($this->plugin as $plugin){                                                                                            
     858               1 :             $text .= "&nbsp;";                                                                                                           
     859               1 :             $text .= $plugin->getLinkTag($this->getUrlAttributeString(), $this->scriptName);                                             
     860               1 :         }                                                                                                                             
     861                 :                                                                                                                                 
     862               3 :         $text .= $this->getTableHtml();                                                                                               
     863                 :                                                                                                                                 
     864               3 :         return $text;                                                                                                                 
     865                 :     }                                                                                                                              
     866                 :                                                                                                                                 
     867                 :     /**                                                                                                                         
     868                 :      * 初期化メソッド<br>                                                                                                       
     869                 :      * リクエストパラメータを利用してオブジェクトを初期化します。                                                                  
     870                 :      *                                                                                                                          
     871                 :      * @param request 必要なパラメータを含む配列。またはphpの$_REQUEST.                                                         
     872                 :      * @access public                                                                                                           
     873                 :      */                                                                                                                         
     874                 :      public function initialize($request){                                                                                      
     875               1 :         $this->scriptName = basename($_SERVER["SCRIPT_NAME"]);                                                                        
     876                 :                                                                                                                                 
     877               1 :         if($this->usePager){                                                                                                          
     878               1 :             $currentPage = $request{$this->parameterPageString};                                                                         
     879               1 :             $pagePar = $request{$this->parameterPageParString};                                                                          
     880               1 :             $this->initializePager($currentPage, $pagePar);                                                                              
     881                 :         }                                                                                                                             
     882                 :                                                                                                                                 
     883               1 :         if($this->useSort){                                                                                                           
     884               1 :             $urlencodeSortKey = $request{$this->parameterSortKeyString};                                                                 
     885               1 :             $sortKey = urldecode($urlencodeSortKey);                                                                                     
     886               1 :             $sortType = $request{$this->parameterSortTypeString};                                                                        
     887               1 :             if(!empty($sortKey)){                                                                                                        
     888               1 :                 $this->initializeSort($sortKey, $sortType);                                                                                 
     889                 :             }                                                                                                                            
     890                 :         }                                                                                                                             
     891                 :                                                                                                                                 
     892               1 :         if($this->usePlugin){                                                                                                         
     893               1 :             $this->plugin = $this->initializePlugin();                                                                                   
     894               1 :             $this->doPlugin($request{"logic"});                                                                                          
     895                 :         }                                                                                                                             
     896               1 :     }                                                                                                                              
     897                 :                                                                                                                                 
     898                 :     /**                                                                                                                         
     899                 :      * 初期化メソッド<br>                                                                                                       
     900                 :      * リクエストパラメータを利用してオブジェクトを初期化します。<br>                                                              
     901                 :      * 一括してすべての機能を初期化します。                                                                                        
     902                 :      *                                                                                                                          
     903                 :      * @param request 必要なパラメータを含む配列。またはphpの$_REQUEST.                                                         
     904                 :      * @access public                                                                                                           
     905                 :      */                                                                                                                         
     906                 :     public function fullStackInitialize($request){                                                                                 
     907               1 :         $this->scriptName = basename($_SERVER["SCRIPT_NAME"]);                                                                        
     908                 :                                                                                                                                 
     909               1 :         $currentPage = $request{$this->parameterPageString};                                                                          
     910               1 :         $pagePar = $request{$this->parameterPageParString};                                                                           
     911                 :                                                                                                                                 
     912               1 :         $urlencodeSortKey = $request{$this->parameterSortKeyString};                                                                  
     913               1 :         $sortKey = urldecode($urlencodeSortKey);                                                                                      
     914               1 :         $sortType = $request{$this->parameterSortTypeString};                                                                         
     915                 :                                                                                                                                 
     916               1 :         $this->useSort(true);                                                                                                         
     917               1 :         $this->usePager(true);                                                                                                        
     918               1 :         $this->usePlugin(true);                                                                                                       
     919                 :                                                                                                                                 
     920               1 :         $this->initializePager($currentPage, $pagePar);                                                                               
     921                 :                                                                                                                                 
     922               1 :         if(!empty($sortKey)){                                                                                                         
     923               1 :             $this->initializeSort($sortKey, $sortType);                                                                                  
     924                 :         }                                                                                                                             
     925                 :                                                                                                                                 
     926               1 :         if($this->usePlugin){                                                                                                         
     927               1 :             $this->plugin = $this->initializePlugin();                                                                                   
     928               1 :             $this->doPlugin($request{"logic"});                                                                                          
     929                 :         }                                                                                                                             
     930               1 :     }                                                                                                                              
     931                 :                                                                                                                                 
     932                 :     // @todo                                                                                                                       
     933                 :     private function initializePlugin(){                                                                                           
     934               2 :         $plugin = array();                                                                                                            
     935                 :                                                                                                                                 
     936               2 :         $plugin[] = new JetCsvDownload();                                                                                             
     937               2 :         $plugin[] = new JetExcelDownload();                                                                                           
     938                 :                                                                                                                                 
     939               2 :         return $plugin;                                                                                                               
     940                 :     }                                                                                                                              
     941                 :                                                                                                                                     
     942                 :     /**                                                                                                                         
     943                 :      * ヘッダ列の結合を行う。<br>                                                                                               
     944                 :      * 指定したヘッダから、指定したカラム数の結合を行います。<br>                                                                  
     945                 :      *                                                                                                                          
     946                 :      * @param $columnName 列名                                                                                                  
     947                 :      * @param $margeCount 結合する列数                                                                                          
     948                 :      * @access public                                                                                                           
     949                 :      */                                                                                                                         
     950                 :     public function margeHeaderColumn($columnName, $margeCount){                                                                   
     951               1 :         if(empty($columnName)){                                                                                                       
     952               1 :             return;                                                                                                                      
     953                 :         }                                                                                                                             
     954                 :                                                                                                                                 
     955               1 :         if(empty($margeCount)){                                                                                                       
     956               1 :             return;                                                                                                                      
     957                 :         }                                                                                                                             
     958                 :                                                                                                                                 
     959               1 :         if($margeCount < 2){                                                                                                          
     960               1 :             return;                                                                                                                      
     961                 :         }                                                                                                                             
     962                 :                                                                                                                                 
     963               1 :         if(!is_numeric($margeCount)){                                                                                                 
     964               0 :             return;                                                                                                                      
     965                 :         }                                                                                                                             
     966                 :                                                                                                                                 
     967               1 :         $this->margeHeaderColumn[$columnName] = $margeCount;                                                                          
     968               1 :     }                                                                                                                              
     969                 :                                                                                                                                 
     970                 :     /**                                                                                                                         
     971                 :      * ヘッダ列の結合を行う。<br>                                                                                               
     972                 :      * 指定したヘッダから、指定したカラム数の結合を行います。<br>                                                                  
     973                 :      *                                                                                                                          
     974                 :      * @param $columnName 列名                                                                                                  
     975                 :      * @param $margeCount 結合する列数                                                                                          
     976                 :      * @access public                                                                                                           
     977                 :      */                                                                                                                         
     978                 :     public function margeColumnRow($columnName, $margeCount){                                                                      
     979               1 :         if(empty($columnName)){                                                                                                       
     980               1 :             return;                                                                                                                      
     981                 :         }                                                                                                                             
     982                 :                                                                                                                                 
     983               1 :         if(empty($margeCount)){                                                                                                       
     984               1 :             return;                                                                                                                      
     985                 :         }                                                                                                                             
     986                 :                                                                                                                                 
     987               1 :         if($margeCount < 2){                                                                                                          
     988               1 :             return;                                                                                                                      
     989                 :         }                                                                                                                             
     990                 :                                                                                                                                 
     991               1 :         if(!is_numeric($margeCount)){                                                                                                 
     992               0 :             return;                                                                                                                      
     993                 :         }                                                                                                                             
     994                 :                                                                                                                                 
     995               1 :         $this->margeColumnRow[$columnName] = $margeCount;                                                                             
     996               1 :     }                                                                                                                              
     997                 :                                                                                                                                 
     998                 :     private function doPlugin($logic){                                                                                             
     999               2 :         if(empty($logic)){                                                                                                            
    1000               2 :             return;                                                                                                                      
    1001                 :         }                                                                                                                             
    1002                 :                                                                                                                                 
    1003               0 :         foreach($this->plugin as $plugin){                                                                                            
    1004               0 :             if($plugin->key == $logic){                                                                                                  
    1005               0 :                 $records = $this->getRecords();                                                                                             
    1006               0 :                 $header = $this->getHeaderArray($records);                                                                                  
    1007               0 :                 $plugin->action($header, $records);                                                                                         
    1008               0 :                 return;                                                                                                                     
    1009                 :             }                                                                                                                            
    1010               0 :         }                                                                                                                             
    1011               0 :     }                                                                                                                              
    1012                 :                                                                                                                                 
    1013                 :     /**                                                                                                                         
    1014                 :      * データ行の背景色設定<br>                                                                                                 
    1015                 :      * テーブルのデータ行に対して背景色を設定します。<br>                                                                       
    1016                 :      * 指定された色を行を出力するために繰り返し設定します。<br>                                                                 
    1017                 :      *                                                                                                                          
    1018                 :      * @param $roundBackgroundColors 16進文字コードの配列                                                                     
    1019                 :      * @access public                                                                                                           
    1020                 :      */                                                                                                                         
    1021                 :     public function setRoundBackgroundColor($roundBackgroundColors){                                                               
    1022               1 :         $this->roundBackgroundColors = $roundBackgroundColors;                                                                        
    1023               1 :     }                                                                                                                              
    1024                 : }                                                                                                                               
    1025                 : ?>                                                                                                                              

Generated by: PHPUnit 3.0.0 and Xdebug 2.0.0RC1.