コード例 #1
0
ファイル: htmlobject.inc.php プロジェクト: kelubo/OpenQRM
/**
* builds html table
* @access public
* @param  $name string
* @param  $value array(array(label=>, value=>, ...)
* @param  $mode enum(object,string)
* @return string
*/
function htmlobject_table($id, $value, $mode = 'object')
{
    $_strReturn = '';
    $table = new htmlobject_table();
    $table->id = $id;
    $table->css = 'htmlobject_table';
    $table->border = 1;
    $table->cellspacing = 0;
    $table->cellpadding = 0;
    $i = 0;
    if ($mode == 'object') {
        foreach ($value as $val) {
            $tr = new htmlobject_tr();
            foreach ($val as $key => $v) {
                $td = new htmlobject_td();
                $td->css = $key;
                $td->text = $v;
                $tr->add($td);
            }
            $table->add($tr);
        }
    }
    if ($mode == 'string') {
        $tr = '';
        foreach ($value as $val) {
            $tr .= $val;
        }
        $table->add($tr);
    }
    return $table->get_string();
}
コード例 #2
0
 function get_string()
 {
     $_strReturn = '';
     // build table
     $this->init_table_builder();
     // build additional table head
     foreach ($this->_headrow as $row) {
         $row->arr_tr[0]->colspan = $this->_num_cols;
         htmlobject_table::add($row);
     }
     // build sort functions
     if ($this->sort != '') {
         $td = new htmlobject_td();
         $td->colspan = $this->_num_cols;
         $td->type = 'td';
         $td->css = $this->css_prefix . 'td pageturn_head';
         $tr = new htmlobject_tr();
         $tr->css = $this->css_prefix . 'tr pageturn_head';
         $tr->id = 'tr_' . uniqid();
         $td->text = $this->get_sort() . $this->get_pageturn();
         $tr->add($td);
         htmlobject_table::add($tr);
     }
     // build table head
     htmlobject_table::add($this->get_table_head());
     // build table body
     $i = 'odd';
     foreach ($this->_body as $key => $value) {
         htmlobject_table::add($this->get_table_body($key, $value, $i));
         if ($i == 'odd') {
             $i = 'even';
         } else {
             $i = 'odd';
         }
     }
     // build table bottom
     htmlobject_table::add($this->get_table_bottom());
     // insert bottom pageturn
     if (count($this->_body) > 9 && $this->limit < $this->max && $this->sort != '') {
         $td = new htmlobject_td();
         $td->colspan = $this->_num_cols;
         $td->type = 'td';
         $td->css = $this->css_prefix . 'td pageturn_bottom';
         $tr = new htmlobject_tr();
         $tr->css = $this->css_prefix . 'tr pageturn_bottom';
         $tr->id = 'tr_' . uniqid();
         $td->text = $this->get_pageturn();
         $tr->add($td);
         htmlobject_table::add($tr);
     }
     foreach ($this->_bottomrow as $row) {
         $row->arr_tr[0]->colspan = $this->_num_cols;
         htmlobject_table::add($row);
     }
     // build form
     $_strReturn = $this->get_js();
     $this->form_action != '' ? $_strReturn .= '<form action="' . $this->form_action . '" method="GET">' : null;
     $_strReturn .= htmlobject_table::get_string();
     $this->form_action != '' ? $_strReturn .= '</form>' : null;
     return $_strReturn;
 }