if (strpos($this->type,'date') !== false) return 'date';
}
- private function htmlYesNo($checked_value) {
+ public function htmlValue($value) {
+
+ if (strpos($this->type,'bool') !== false) {
+ return preg_match('/^(1|yes|on|true)/i',$value) ? 'Yes' : 'No';
+ }
+
+ return $value;
+ }
+
+ public function htmlYesNo($checked_value) {
$s_no = $checked = ' checked="checked"';
if ( ( $s_yes = preg_match('/^(1|yes|on|true)/i',$checked_value) ? $checked : '' ) != '' ) $s_no = '';
}
public function rows(&$opt=[],$opt_by_val=null) {
+ $opt['TABLE'] = $this;
+
#
# Run query
#
$html = '';
$html .= '<table class="rows wp-list-table widefat striped">'.NB_EOL;
- #if (!empty($opt)) $html .= '<caption>' . $this->nav($opt['count'],$opt['tot'],$opt['limit']) . '</caption>' .NB_EOL;
$this->__rows_table_attr = [];
-# NB 27.12.16 $this->__rows_table_keys = [];
foreach ($fields as $name => $f) {
$this->__rows_table_attr[$name] = ''
. ' class="' . $name . ($f->key?' key':'') . (isset($this->extras[$name])?' extra':'') . ' ' . preg_replace('/\W.*$/','',$f->type).'"'
;
-# NB 27.12.16 if ($f->key) $this->__rows_table_keys[] = $name;
}
-# NB 27.12.16 if (empty($this->__rows_table_keys)) $this->__rows_table_keys = array_keys($fields);
if ($this->show_header) {
$html .= '<thead>'.NB_EOL;
return $html;
}
- public function rows_rec_table(&$row) {
+ public function rows_rec_table(&$row,&$opt) {
$buttons = $this->html_row_buttons($row);
-# NB 27.12.16 $id = [];
-# NB 27.12.16 foreach ($this->__rows_table_keys as $k) {
-# NB 27.12.16 $id[] = $row[$k];
-# NB 27.12.16 }
-# NB 27.12.16 $id = empty($id) ? '' : ' '.'__'.join('__',$id).'__';
-# NB 27.12.16 $html = '<tr class="row'.$id.'">'.NB_EOL;
$html = '<tr class="row">'.NB_EOL;
if ($this->buttons() and !empty($buttons[0])) $html .= '<td class="action">'.$buttons[0].'</td>'.NB_EOL;
foreach ($row as $k => $v) {
+ if ( !empty($opt['TABLE']) and !empty($opt['TABLE']->field($k)) ) {
+ $v = $opt['TABLE']->field($k)->htmlValue($v);
+ }
$html .= '<td'.$this->__rows_table_attr[$k].'>'.$v.'</td>'.NB_EOL;
}
public function rows_end_table() {
unset($this->__rows_table_attr);
-# NB 27.12.16 unset($this->__rows_table_keys);
$html = '';
$html .= '</tbody>'.NB_EOL;
$html .= '</table>'.NB_EOL;