<?php
require_once(realpath(dirname(__FILE__).'/../../lib/php/maps.php'));
-function pub_map(&$r) {
- debug($r);
- if (empty($r['latitude'])) return;
- if (empty($r['longiture'])) return;
- $r['maps'] = '<a href="'.Maps::link($r['latitude'],$r['latitude']).'">'
- .Maps::img($r['latitude'],$r['latitude'])
- .'</a>';
-}
+$nohtml = (bool)( self::php_cli() or self::client_content_type('text/plain') != 'text/html' );
$DBQ['pub'] = [
- 'row_parse_post' => function(&$r,&$t) {
- #debug('zaza');
- #pub_map($r);
- },
+ 'row_parse_post' => $nohtml ? null : function(&$r,&$t) { Maps::html($r); },
];
?>
// Post
//
if ($parser and !empty($this->row_parse_post)) {
- $call = $this->row_parse_post;
- $call($row,$this);
+ $fct = $this->row_parse_post;
+ $fct($row,$this);
}
if ($parser and !empty($this->db()->row_parse_post)) {
- $call = $this->db()->row_parse_post;
- $call($row,$this);
+ $fct = $this->db()->row_parse_post;
+ $fct($row,$this);
}
# Passed param on rows()
return 'http://maps.google.com/?q='.$longitude.','.$latitude;
}
+ public static function html(&$r) {
+ if (empty($r['latitude'])) return;
+ if (empty($r['longitude'])) return;
+ $r['maps'] = '<a href="'.Maps::link($r['latitude'],$r['latitude']).'">'
+ .'<img src="'.Maps::img($r['latitude'],$r['latitude']).'" />'
+ .'</a>';
+ }
+
}
?>
);
}
+ private function row_parse_pre(&$r=[]) {
+ static $row_parse_pre;
+ if (empty($r)) {
+ $row_parse_pre = $this->db()->row_parse_pre;
+ return;
+ }
+ if (empty($row_parse_pre)) return;
+ $row_parse_pre($r,$this->table);
+ }
+
+ private function row_parse_post(&$r=[]) {
+ static $row_parse_post;
+ if (empty($r)) {
+ $row_parse_post = $this->db()->row_parse_post;
+ return;
+ }
+ if (empty($row_parse_post)) return;
+ $row_parse_post($r,$this->table);
+ }
+
public function table_rows($fct=null) {
$this->db->limit = $this->limit();
- if (!empty($this->db()->row_parse_pre)) {
- $row_parse_pre = $this->db()->row_parse_pre;
- }
-
- if (!empty($this->db()->row_parse_post)) {
- $row_parse_post = $this->db()->row_parse_post;
- }
+ $this->row_parse_pre();
+ $this->row_parse_post();
$opt = ($this->page->is('html')
and $this->table_rw()
) ? [
'row_parse_pre' => function(&$r){
- if (!empty($row_parse_pre)) $row_parse_pre($r,$this);
+ $this->row_parse_pre($r);
$GLOBALS['dbq_args'] = urlencode( join($this->param_args_sep,$this->table->fields_keys_values($r)) );
},
'row_parse_post' => function(&$r){
- if (!empty($row_parse_post)) $row_parse_post($r,$this);
+ $this->row_parse_post($r);
$args = $GLOBALS['dbq_args'];
$hidden = $this->form_hidden($r);