$dbs = [];
$name = self::p('name','');
$type = self::p('type','');
+ $has_order = false;
foreach ($this->conf as $id => $attr) {
$attr['_no_connect'] = true;
$attr['id'] = $id;
+ if (isset($attr['id'])) $has_order = true;
$d = new Db($attr);
$db = [];
$dbs[] = $db;
}
+ if ($has_order) foreach ($dbs as $i=>$db) if (!isset($db['order'])) $dbs[$i]['order'] = '';
return $dbs;
}
$Page = new Page([
#'title' => 'Test',
- 'content_type' => ((Page::php_cli() and !Page::p('web') )? 'text/plain' : 'text/html'),
+ 'content_type' => Page::content_type_and_set_format(),
+ #'content_type' => ((Page::php_cli() and !Page::p('web') )? 'text/plain' : 'text/html'),
'call' => array(
'begin',
['out', "Hello World !!!\n"],
#bye($type);
$page->pdef('format','csv');
}
+ #echo Page::p('db')."\n"; return;
+#echo 'zaza'; return;
if ($page->action()) 1;
else require_once(dirname(__FILE__).'/index.php');
#else if (!empty($page->db)) $page->db->action($page->db->p('action'),empty($Table) ? null : $Table);
},
+/*
+*/
#array('out', print_r($_SERVER,true)),
'end',
),
}
$new_argv = array();
-
for ($i=1;$i<count($argv);$i++) {
if (preg_match('/^([\w_\-\.]+)=(.+)\s*$/',$argv[$i],$f)) {
debug($CONF);
}
+ /*
+ * Function client_content_type
+ * Return the head Accept from the client
+ */
+ public static function client_content_type() {
+ $headers = self::client_header();
+ if (0
+ or !isset($headers['Accept'])
+ or $headers['Accept'] == '*/*'
+ ) return '';
+ $v = explode(',', $headers['Accept']);
+ return $v ? $v[0] : '';
+ }
+
} # < Class
?>
if (isset($opt['content_type'])) $this->content_type($opt['content_type']);
#elseif($this->php_cli()) $this->content_type('text/html');
unset($opt['content_type']);
+ if (!$this->content_type()) $this->content_type($this->client_content_type());
// Statics
foreach ([
// Opt
parent::__construct($opt);
-
+
// Defaults
if ( empty($this->title) ) $this->title = !empty($title) ? join($this->sep,$title) : $this->filename2title();
if ( empty($this->h1) ) $this->h1 = !empty($nav) ? join($this->sep,$nav) : $this->title;
}
- /*
- * Function client_content_type
- * Return the head Accept from the client
- */
- public static function client_content_type() {
- $headers = getallheaders();
- if (0
- or !isset($headers['Accept'])
- or $headers['Accept'] == '*/*'
- ) return '';
- $v = explode(',', $headers['Accept']);
- return $v ? $v[0] : '';
- }
-
public static function headers_no_cache() {
$ts = gmdate("D, d M Y H:i:s") . " GMT";
header("Expires: $ts");
return preg_replace('/\?.*$/','',$_SERVER['REQUEST_URI']);
}
- public static function files_concat($files) {
-
- }
-
public static function nav_parse($array) {
#$v = &$sep;
foreach ($array as $k => $v) {
return self::$content_type;
}
+ public static function content_type_and_set_format() {
+ $format = self::p('format');
+ $content_type = self::p('content_type');
+
+ if (!$format and $content_type) {
+ self::p('format',self::mime2ext($content_type));
+ } elseif (!$format and ($client_type = self::client_content_type())) {
+ self::p('format',self::mime2ext($client_type));
+ }
+
+ if (!$content_type and $format) $content_type = self::ext2mime($format);
+ if (!$content_type and self::php_cli()) $content_type = 'text/plain';
+ if ($content_type) return $content_type;
+ }
+
} return; # < Class
?>