echo ''
.'<div class="db buttons">'
- .'<input type="hidden" name="table" value="'.$this->p('table').'"/>'
- .'<input type="hidden" name="action" value="update"/>'
- .'<input type="hidden" name="db" value="'.$this->p('db').'"/>'
- .'<input type="hidden" name="debug" value="'.$this->p('debug').'"/>'
.( empty($_SERVER['HTTP_REFERER']) ? '' : '<input type="button" onclick="document.location=document.referrer" value="Cancel" />')
.'<input type="reset" />'
.'<input type="submit"/>'
.'</div>'.PHP_EOL
+ .'<input type="hidden" name="table" value="'.$this->name.'"/>'
+ .'<input type="hidden" name="action" value="update"/>'
+ .'<input type="hidden" name="db" value="'.$this->db->name.'"/>'
+ .'<input type="hidden" name="debug" value="'.$this->p('debug').'"/>'
+ .'<input type="hidden" name="referer" value="'.urlencode(@$_SERVER['HTTP_REFERER']).'"/>'
.'</form>'.PHP_EOL;
}
foreach ($fields as $name) {
$field->bindParam($query,$hvalues[$name],":$name");
}
+
foreach ($keys as $name) {
$field->bindParam($query,$hvalues[$name],":key_$name");
}
} elseif ($action == 'insert') {
$this->insert($this->p());
- header('Location: ?table=' . $this->name);
+ if ($this->p('referer')) {
+ header('Location: '.urldecode($this->p('referer')));
+ } else {
+ header('Location: ?table=' . $this->name . ($this->p('db') ? '&db='.$this->db->name : ''));
+ }
#header('Location: '.str_replace('&','&',$this->url_list()));
return true;
} elseif ($action == 'update') {
#$this->bye($this->p());
$this->update($this->p());
- header('Location: ?table=' . $this->name);
+ if ($this->p('referer')) {
+ header('Location: '.urldecode($this->p('referer')));
+ } else {
+ header('Location: ?table=' . $this->name . ($this->p('db') ? '&db='.$this->db->name : ''));
+ }
#header('Location: '.str_replace('&','&',$this->url_list()));
return true;
# Sql: elect type,ext from mime_type where ext in ('json','csv','txt','yaml','xml','html','doc','xls');
public static $content_types = array(
- 'application/json' => 'json',
- 'application/msword' => 'doc',
- 'application/vnd.ms-excel' => 'xls',
- 'application/xml' => 'xml',
- 'text/csv' => 'csv',
- 'text/html' => 'html',
- 'text/plain' => 'txt',
- 'text/yaml' => 'yaml',
+ 'json' => 'application/json',
+ 'doc' => 'application/msword',
+ 'xls' => 'application/vnd.ms-excel',
+ 'xml' => 'application/xml',
+ 'csv' => 'text/csv',
+ 'html' => 'text/html',
+ 'txt' => 'text/plain',
+ 'yaml' => 'text/yaml',
);
function __destruct() {
* Does what it says
*/
static function ext2mime($ext) {
- foreach (self::$content_types as $c => $e) {
+ foreach (self::$content_types as $e => $c) {
if ($ext == $e) return $c;
}
}