Changeset feac485 in github


Ignore:
Timestamp:
Jun 15, 2011 7:34:51 AM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
3f3ec14
Parents:
ca7dda4
Message:
  • Added html_table::get_row_attribs(), extended html_table::set_row_attribs()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/include/html.php

    r7fc056c3 rfeac485  
    563563    protected $tagname = 'table'; 
    564564    protected $allowed = array('id','class','style','width','summary', 
    565         'cellpadding','cellspacing','border'); 
     565            'cellpadding','cellspacing','border'); 
    566566 
    567567    private $header = array(); 
     
    630630    { 
    631631        // Remove the header 
    632         foreach($this->header as $index=>$header){ 
    633             if($header->attrib['class'] == $class){ 
     632        foreach ($this->header as $index=>$header){ 
     633            if ($header->attrib['class'] == $class){ 
    634634                unset($this->header[$index]); 
    635635                break; 
     
    638638 
    639639        // Remove cells from rows 
    640         foreach($this->rows as $i=>$row){ 
    641             foreach($row->cells as $j=>$cell){ 
    642                 if($cell->attrib['class'] == $class){ 
     640        foreach ($this->rows as $i=>$row){ 
     641            foreach ($row->cells as $j=>$cell){ 
     642                if ($cell->attrib['class'] == $class){ 
    643643                    unset($this->rows[$i]->cells[$j]); 
    644644                    break; 
     
    663663 
    664664    /** 
    665      * Set current row attrib 
    666      * 
    667      * @param array $attr Row attributes 
    668      */ 
    669     public function set_row_attribs($attr = array()) 
     665     * Set row attributes 
     666     * 
     667     * @param array $attr  Row attributes 
     668     * @param int   $index Optional row index (default current row index) 
     669     */ 
     670    public function set_row_attribs($attr = array(), $index = null) 
    670671    { 
    671672        if (is_string($attr)) 
    672673            $attr = array('class' => $attr); 
    673674 
    674         $this->rows[$this->rowindex]->attrib = $attr; 
     675        if ($index === null) 
     676            $index = $this->rowindex; 
     677 
     678        if ($this->rows[$index]) 
     679            $this->rows[$index]->attrib = $attr; 
     680    } 
     681 
     682    /** 
     683     * Get row attributes 
     684     * 
     685     * @param int $index Row index 
     686     * 
     687     * @return array Row attributes 
     688     */ 
     689    public function get_row_attribs($index = null) 
     690    { 
     691        if ($index === null) 
     692            $index = $this->rowindex; 
     693 
     694        return $this->rows[$index] ? $this->rows[$index]->attrib : null; 
    675695    } 
    676696 
     
    685705        if (is_array($attrib)) 
    686706            $this->attrib = array_merge($this->attrib, $attrib); 
    687          
     707 
    688708        $thead = $tbody = ""; 
    689709 
     
    718738        return parent::show(); 
    719739    } 
    720      
     740 
    721741    /** 
    722742     * Count number of rows 
Note: See TracChangeset for help on using the changeset viewer.