public $fields = [];
public $indexes;
- public $itemplate_id;
+ public $idtemplate;
# hidden, sort, ... fields
public $show_hidden_params = true;
Template
-----------------------------------------------------------------*/
public function rows_begin_template($fields,&$o) {
- $id = $this->template_id();
+ $id = $this->idtemplate();
$id = preg_replace('/[^\w\._-]/','',$id);
return $this->status;
}
- private function template_id($id=null) {
+ private function idtemplate($id=null) {
if (empty($id)
- and !( $id=$this->p('table.template.id') )
and !( $id=$this->p('idtemplate') )
- and !( $id = $this->template_id )
+ and !( $id = $this->idtemplate )
) $this->bye('Wrong parameter!');
return $id;
}
public function template($id=null) {
- $id = $this->template_id($id);
+ $id = $this->idtemplate($id);
$id = preg_replace('/[^\w\._-]/','',$id);
public $table;
public $db;
- protected $idtemplate;
-
public function __construct($opt=[]) {
//
// Pre defaults values
}
}
- if ($this->params['format'] == $this->format_cli) $this->db->format = $this->params['format'] = 'txt';
+ if ($this->params['format'] == $this->format_cli) $this->format('txt');
$this->db->out->header($this->p('header',false));
$this->db->out($row);
return;
}
+ public function format($set=null) {
+ if ($set === null) return $this->params['format'];
+ $this->db->format = $this->params['format'] = $set;
+ }
+
public function table($param=[]) {
+# NB 08.12.17 if ($this->format() == 'tmpl') {
+ #bye($param);
+ if (preg_match("/^(.*)\.(tmpl)$/",$this->params['table'],$m)) {
+#bye($this->params['table']);
+ $this->params['table'] = $m[1];
+ $param['idtemplate'] = $this->format();
+ $this->format('template');
+# NB 08.12.17 } else {
+# NB 08.12.17 $this->error("Template id is missing");
+# NB 08.12.17 }
+ }
+
if (!in_array($this->params['table'],array_keys($this->db->tables()))) {
# We Allow SELECT only in admin
$this->table->base = $this->db->base.'/'.$this->table->name;
+ if (isset($param['idtemplate'])) {
+ $this->table->base .= '.tmpl.' . $param['idtemplate'];
+ #bye([$this->table,$this->db->format]);
+ }
+
}
public function title_nav() {
// Format first !
if ($this->params['format']) {
$format = $this->params['format'];
-# NB 08.12.17: TODO
-# NB 08.12.17 if (preg_match("/^(.*)\.tmpl/",$format,$m)) {
-# NB 08.12.17 $this->idtemplate = $m[1];
-# NB 08.12.17 $format = 'template';
-# NB 08.12.17 }
} else if ($content_type = self::client_content_type() and ( $format=Mime::toExt($content_type) )) {
#$format = $format;
// Affect values to objects
if ($format == 'html') $format = $this->format_html;
- $this->params['format'] = $format;
- $this->db->format = $format;
+ $this->format($format);
+# NB 08.12.17 $this->params['format'] = $format;
+# NB 08.12.17 $this->db->format = $format;
$this->is_html = strpos($content_type,'html') ? true : false;
$this->db->is_html = $this->is_html;