$doctype = '<?xml version="1.0" encoding="'.strtoupper(self::$charset).'"?>'.NB_EOL; //<?
} elseif (self::$html5) {
# See: http://www.w3.org/TR/html-markup/elements.html
- $doctype = '<!DOCTYPE html>';
+ $doctype = '<!DOCTYPE html>'.NB_EOL;
} else {
$doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.NB_EOL;
}
const WRITE = 3;
const VIEW = 1;
public $perm = self::ADMIN;
+ public $perms = [
+ 'admin' => self::ADMIN,
+ 'delete' => self::DELETE,
+ 'write' => self::WRITE,
+ 'view' => self::VIEW,
+ ];
public $title = 'Dbq';
public $sep_title = ' / ';
$this->json = [
'db.base' => ( empty($this->db) ? '' : $this->db->base ),
'table.base' => ( empty($this->table) ? '' : $this->table->base ),
- 'table.rw' => $this->table_rw(),
'default.format' => $this->format_html,
'default.limit' => $this->default_limit,
'param.format' => $this->params['format'],
'param.deep' => $this->params_deep,
'text.add' => 'Add',
'text.clear' => 'Clear',
+ 'perm' => $this->perm,
+ 'perms' => $this->perms,
];
$this->page->js_code = 'window._dbq = '.json_encode($this->json);
$opt = ($this->page->is('html')
and $this->table_rw()
- #and ($this->perm >= self::VIEW)
- #and strpos('table view',$this->table->type()) !== false
) ? [
'row_parse_pre' => function(&$r){
$GLOBALS['dbq_args'] = urlencode( join($this->param_args_sep,$this->table->fields_keys_values($r)) );
}
});
+ if ( window._dbq['perm'] < window._dbq['perms']['write']) {
+ document.querySelectorAll("form.edit").forEach(function(e) {
+ e.setAttribute('onsubmit','return false');
+ });
+ document.querySelectorAll("form.edit input[type=submit],form.edit input[type=reset]").forEach(function(e) {
+ e.setAttribute('style','display:none');
+ });
+ }
+
document.querySelectorAll("form.menu input[type=submit]").forEach(function(e) {
e.insertAdjacentHTML("afterend",''
+' <input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)"'
+' value="'+window._dbq['text.clear']+'"'
+' />'
- +( window._dbq['table.rw']
+ +( window._dbq['perm'] >= window._dbq['perms']['write']
? ' <input type="button" class="add '+e.className+'"'
+' onclick="window.location=\''+window._dbq['table.base']+'/add/\'"'
- //+' onclick="window.location=\''+window._dbq['table.base']+'add/\'"'
- //+' onclick="this.setAttribute(\'name\',\'add\'); this.form.submit()"'
+' value="'+window._dbq['text.add']+'"/>'
: ''
)