| Index
» Projekty
» phpMyEdit
» Fórum
» [strftimemask] support timestamp UNIX in addition to MySql |
 |
Sab
Založený: 26.12.2004
Príspevky: 5
Zaslal: 2005-03-05 19:26
Návrat hore
Odpovedať s citátom
|
I'm not using anymore MySql timestamp for a long time but directly the php one. Ok this is my choice and it is not the question here but how to made phpMyEdit support it natively in addition to MySql one with option
strftimemask
.
To enable this I've inherited the phpMyEdit class and rewrite the cellDisplay method just adding one single line.
| Kód: |
function cellDisplay($k, $row, $css) /* {{{ */
{
$escape = isset($this->fdd[$k]['escape']) ? $this->fdd[$k]['escape'] : true;
$key_rec = $row['qf'.$this->key_num];
if (@$this->fdd[$k]['datemask']) {
$value = intval($row["qf$k".'_timestamp']);
$value = $value ? @date($this->fdd[$k]['datemask'], $value) : '';
} else if (@$this->fdd[$k]['strftimemask']) {
$value = intval($row["qf$k".'_timestamp']);
[BEGIN]//Addition : Sab 08/11/2004 - manage php/unix timestamps declared as INT as of MySql
if ($value == '')$value = $row["qf$k"];[/END]
$value = $value ? @strftime($this->fdd[$k]['strftimemask'], $value) : '';
} else if ($this->is_values2($k, $row["qf$k"])) {
$value = $row['qf'.$k.'_idx'];
if ($this->fdd[$k]['select'] == 'M') {
$value_ar = explode(',', $value);
$value_ar2 = array();
foreach ($value_ar as $value_key) {
if (isset($this->fdd[$k]['values2'][$value_key])) {
$value_ar2[$value_key] = $this->fdd[$k]['values2'][$value_key];
$escape = false;
}
}
$value = join(', ', $value_ar2);
} else {
if (isset($this->fdd[$k]['values2'][$value])) {
$value = $this->fdd[$k]['values2'][$value];
$escape = false;
}
}
} else {
$value = $row["qf$k"];
}
$original_value = $value;
if (@$this->fdd[$k]['strip_tags']) {
$value = strip_tags($value);
}
if (intval($this->fdd[$k]['trimlen']) > 0 && strlen($value) > $this->fdd[$k]['trimlen']) {
$value = ereg_replace("[\r\n\t ]+",' ',$value);
$value = substr($value, 0, $this->fdd[$k]['trimlen'] - 3).'...';
}
if (@$this->fdd[$k]['mask']) {
$value = sprintf($this->fdd[$k]['mask'], $value);
}
if ($this->col_has_URL($k)) {
return $this->urlDisplay($k, $original_value, $value, $css, $key_rec);
}
if (strlen($value) <= 0) {
return ' ';
}
if ($escape) {
$value = htmlspecialchars($value);
}
return nl2br($value);
} /* }}} */
|
I didn't found any other ways to made it work nor I test side effects of the modification using non timestamp fields.
Well if you found it cool and by chance robust would be cool that you integrate it on future version ;).
|
Mescalito
Založený: 15.03.2004
Príspevky: 3
Zaslal: 2005-03-15 20:12
Návrat hore
Odpovedať s citátom
|
Thank you Sab,
I also prefer PHP timestamp, and your add is very useful.
M.
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|