$r .= '<div class="options">';
// Hiddens
- #if ($this->show_hidden_params)
+ if ($this->show_hidden_params)
$r .= ''#.print_r(self::$params,true)
.self::form_hidden(['db','table','format','limit','download'])
// Embed for no html format (rent)
public static function client_content_type($default='') {
$v = explode(',', self::client_header('Accept'));
return ( ($v and $v[0] != '*/*') ? $v[0] : $default );
-# NB 19.12.16 $headers = self::client_header();
-# NB 19.12.16 if (0
-# NB 19.12.16 or !isset($headers['Accept'])
-# NB 19.12.16 or $headers['Accept'] == '*/*'
-# NB 19.12.16 ) return '';
-# NB 19.12.16 $v = explode(',', $headers['Accept']);
-# NB 19.12.16 return $v ? $v[0] : '';
}
- public static function array_fill_assoc($rows) {
- $keys = [];
-
- foreach($rows as $k=>$v) {
- $keys = array_merge_recursive(array_keys($v),$keys);
+ public static function array_fill_assoc($rows,$keys=null) {
+ if ($keys === null) {
+ $keys = [];
+ foreach(array_reverse($rows) as $v) {
+ foreach ($v as $k=>$vv) $keys[$k] = 1;
+ }
+ $keys = array_keys($keys);
}
+ # NB 21.12.16: to keep order we need a new array
+ $new = [];
foreach($rows as $k=>$v) {
foreach ($keys as $key) {
- if (empty($v[$key])) $rows[$k][$key] = '';
+ $new[$k][$key] = isset($v[$key]) ? $v[$key] : '';
+ if (!isset($v[$key])) $rows[$k][$key] = '';
}
}
+ return $new;
return $rows;
}
e.value = ""
}
}
+function form_submit_clean(f) {
+ var i = 0;
+ var url = "";
+ var action = f.getAttribute("action");
+ var method = f.getAttribute("method");
+ if (method != "get") return true;
+
+ //if (typeof(action) == "undefined") action = "";
+
+ for(i=0;i<f.length;i++) {
+ var p = f[i];
+ if (!p.name) continue;
+ if (p.value=="") continue;
+ if (p.value=="undefined") continue;
+// NB 02.09.13 url += (url ? "&" : "?") + escape(p.name) + "=" + escape(p.value);
+ url += (url ? "&" : "?") + encodeURI(p.name) + "=" + encodeURI(p.value);
+ }
+
+ url = (action == "?" ? "" : action) + url;
+
+ //document.location = url;
+
+ //if (url == window.location) return false;
+ window.location = url;
+ return false;
+}
document.addEventListener("DOMContentLoaded", function() {
+ for (var e of document.querySelectorAll("form")) {
+ e.onsubmit = function() {
+ form_submit_clean(this);
+ return false;
+ };
+ }
+
for (var e of document.querySelectorAll(".menu select.limit")) {
e.onchange = function() {
this.form.submit();
return false;
};
}
+ document.getElementById("table").removeAttribute("name");
+ document.getElementById("format").removeAttribute("name");
for (var e of document.querySelectorAll(".menu select.tables, .menu select.format")) {
e.onchange = function() {
- window.location = "./" + this.form.elements["table"].value + "." + this.form.elements["format"].value;
+ window.location = "./" + document.getElementById("table").value + "." + document.getElementById("format").value;
return false;
};
}
public function table_rows($fct=null) {
- if ($this->page->is('html')) {
- #debug($this->page->content_type());
- }
$opt = ($this->page->is('html')
and ($this->perm >= self::VIEW)
and $this->table->type() != 'sql'
'<input type="button" class="button button-small" onclick="form_clean(this.form)" value="X"/>',
]),
'row_parse_pre' => function(&$r){
-
$GLOBALS['dbq_args'] = urlencode( join(self::PARAM_ARGS_SEP,$this->table->fields_keys_values($r)) );
},
'row_parse_post' => function(&$r){