| | |
| | | public function decode($record) |
| | | { |
| | | global $conf, $app; |
| | | if(is_array($record)) { |
| | | if(is_array($record) && count($record) > 0 && is_array($this->listDef['item'])) { |
| | | foreach($this->listDef['item'] as $field){ |
| | | $key = $field['field']; |
| | | if(isset($record[$key])) { |
| | |
| | | case 'DATETSTAMP': |
| | | if ($record[$key] > 0) { |
| | | // is value int? |
| | | if (preg_match("/^[0-9]+[.]?[0-9]*$/", $record[$key], $p)) { |
| | | if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record[$key], $p)) { |
| | | $record[$key] = date($this->lng('conf_format_dateshort'), $record[$key]); |
| | | } else { |
| | | $record[$key] = date($this->lng('conf_format_dateshort'), strtotime($record[$key])); |
| | |
| | | case 'DATE': |
| | | if ($record[$key] > 0) { |
| | | // is value int? |
| | | if (preg_match("/^[0-9]+[.]?[0-9]*$/", $record[$key], $p)) { |
| | | if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record[$key], $p)) { |
| | | $record[$key] = date($this->lng('conf_format_dateshort'), $record[$key]); |
| | | } else { |
| | | $record[$key] = date($this->lng('conf_format_dateshort'), strtotime($record[$key])); |
| | |
| | | case 'DATETIME': |
| | | if ($record[$key] > 0) { |
| | | // is value int? |
| | | if (preg_match("/^[0-9]+[.]?[0-9]*$/", $record[$key], $p)) { |
| | | if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record[$key], $p)) { |
| | | $record[$key] = date($this->lng('conf_format_datetime'), $record[$key]); |
| | | } else { |
| | | $record[$key] = date($this->lng('conf_format_datetime'), strtotime($record[$key])); |
| | |
| | | |
| | | public function encode($record) |
| | | { |
| | | global $app; |
| | | if(is_array($record)) { |
| | | foreach($this->listDef['item'] as $field){ |
| | | $key = $field['field']; |
| | |
| | | case 'VARCHAR': |
| | | case 'TEXT': |
| | | if(!is_array($record[$key])) { |
| | | $record[$key] = mysql_real_escape_string($record[$key]); |
| | | $record[$key] = $app->db->quote($record[$key]); |
| | | } else { |
| | | $record[$key] = implode($this->tableDef[$key]['separator'],$record[$key]); |
| | | } |
| | |
| | | break; |
| | | |
| | | case 'DOUBLE': |
| | | $record[$key] = mysql_real_escape_string($record[$key]); |
| | | $record[$key] = $app->db->quote($record[$key]); |
| | | break; |
| | | |
| | | case 'CURRENCY': |
| | |
| | | |
| | | } |
| | | |
| | | ?> |
| | | ?> |