#'userPKCS12',
],
],
+ 'posixAccount' => [
+ 'type' => 'table',
+ 'sql' => 'objectClass=posixAccount',
+ 'fields' => ['!dn', 'cn', 'uid', 'gidNumber', 'homeDirectory','loginShell', 'description', 'userPassword'],
+ ],
+ 'posixGroup' => [
+ 'type' => 'table',
+ 'sql' => 'objectClass=posixGroup',
+ 'fields' => ['!dn', 'cn', 'gidNumber', 'memberUid', 'description', 'userPassword'],
+ ],
],
'default_table' => 'me',
];
if (strpos($this->type,'date') !== false) return 'date';
}
- public function htmlValue($value) {
+ public function htmlValue($value,&$mime=null) {
if (strpos($this->type,'bool') !== false) {
return preg_match('/^(1|yes|on|true)/i',$value) ? 'Yes' : 'No';
}
- $value = Mime::html($value);
+ $value = Mime::html($value,$value,$mime);
return $value;
}
if ($type === null) $type = $this->html_type();
foreach ((array)$values as $value) {
- $html .= '<div class="label '.$this->name.'">'
- .'<label for="'.$this->name.'">'.htmlspecialchars(prettyText($this->name)).'</label>'
- ;
+
+ $h = '';
+ $class = [ 'label', $this->name ];
+ $mime = Mime::getContent($value);
+ if ($mime) $class[] = $mime;
if ($this->extras) {
- $html .= '<span class="extra '.$this->name.'">'.$this->out($value).'</span>';
+ $h .= '<span class="extra '.$this->name.'">'.$this->out($value).'</span>';
} elseif (strpos($this->type,'bool') !== false) {
- $html .= $this->htmlYesNo($value);
+ $h .= $this->htmlYesNo($value);
} else {
# NB 09.02.18: needed ?
if ($tag == 'textarea' and $type != 'text') $tag = 'input';
- if ($media = Mime::html($value,'')) {
+ if ($media = Mime::html($value,'',$mime)) {
$tag = 'input';
$type = 'hidden';
- $html .= $media;
+ $h .= $media;
}
- $html .= '<'.$tag
+ $h .= '<'.$tag
.' name="'.$this->preffix.$this->name . ($multi ? '[]' : '') . '"'
.( ($size and $tag != 'textarea') ? ' size="'.$size.'"' : '')
.($tag == 'textarea' ? '>'.$value.'</textarea>' : ' type="'.$type.'" value="'.htmlspecialchars($value).'" />')
}
- # If more than one value, add js code to add more values
+ $html .= '<div class="'.join(' ',$class).'">'
+ .'<label for="'.$this->name.'">'.htmlspecialchars(prettyText($this->name)).'</label>'
+ ;
+ $html .= $h;
+
+ # If more than one value, add js code to add more fields
if ($multi) $html .= '<a href="#" onclick="var i=this.parentNode;var j=i.cloneNode(true);j.querySelectorAll(\'input, textarea, select\').forEach(function(e) {e.value=\'\';}); i.parentNode.insertBefore(j, i.nextSibling);console.log(i.className); return false;">+</a>';
$html .= '</div>'.NB_EOL;
};
}
$row = $fct($this,$values,$add);
- $table = $this;
}
// Params
/*-----------------------------------------------------------------
Html Table
-----------------------------------------------------------------*/
+ private function _rows_table_class($f,$add_class=[]) {
+ if (!$f) return '';
+ $class = [];
+
+ $class[] = $f->name;
+ $type = preg_replace('/\W.*$/','',$f->type);
+ if ($type != 'text') $class[] = $type;
+ if ($f->key) $class[] = 'key';
+ if (isset($this->extras[$f->name])) $class[] = 'extra';
+ $class = $class + $add_class;
+
+ return $class ? ' class="'.join(' ',$class).'"' : '';
+ }
+
private function rows_begin_table($fields) {
$html = '';
$html .= '<table class="rows wp-list-table widefat striped">'.NB_EOL;
- $this->__rows_table_attr = [];
- 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)
- .'"'
- ;
- }
-
if ($this->show_header) {
$html .= '<thead>'.NB_EOL;
$html .= '<tr class="head">'.NB_EOL;
if ($this->buttons() and DB_HTML_EDIT) $html .= '<th class="edit"></th>'.NB_EOL;
foreach ($fields as $name => $f) {
- $html .= '<th'.$this->__rows_table_attr[$name].'>'.$this->url_sort($name).'</th>'.NB_EOL;
+ $html .= '<th'.$this->_rows_table_class($f).'>'.$this->url_sort($name).'</th>'.NB_EOL;
}
if ($this->buttons() and DB_HTML_DELETE) $html .= '<th class="delete"></th>'.NB_EOL;
$html .= '</tr>'.NB_EOL;
if ($this->buttons() and !empty($buttons[0])) $html .= '<td class="action">'.$buttons[0].'</td>'.NB_EOL;
foreach ($row as $k => $v) {
+ $mime = '';
if ( !empty($this->field($k)) ) {
- $v = $this->field($k)->htmlValue($v);
+ $v = $this->field($k)->htmlValue($v,$mime);
}
- $html .= '<td'.$this->__rows_table_attr[$k].'>'.$v.'</td>'.NB_EOL;
+ $html .= '<td'.$this->_rows_table_class($this->field($k)).'>'.$v.'</td>'.NB_EOL;
}
if ($this->buttons() and !empty($buttons[1])) $html .= '<td class="action">'.$buttons[1].'</td>'.NB_EOL;
}
private function rows_end_table() {
- unset($this->__rows_table_attr);
$html = '';
$html .= '</tbody>'.NB_EOL;
$html .= '</table>'.NB_EOL;
return $r;
},
'html_edit_row' => function(&$table,&$values,$add) {
+ bye($add);
$table->db()->ldap->prepare([
'base' => $values['dn'],
]);
return $m[1];
}
- public static function html(&$str,$default=null) {
+ public static function html(&$str,$default=null,&$mime=null) {
if (!$str) return $str;
return $str;
}
- $mime = self::getContent($str);
+ if ($mime === null) $mime = self::getContent($str);
if (preg_match('@^image/@',$mime)) {
$v = self::is_base64($str) ? $v : base64_encode($str);