/** * prepare the data */ public function prepare() { foreach ($this->data as $id => $ds) { $start = strtotime($ds['start']); $end = strtotime($ds['end']); $this->data[$id]['starttime'] = transdate('time', $start); $this->data[$id]['endtime'] = transdate('time', $end); if (date('Y-m-d', $start) == date('Y-m-d', $end)) { $this->data[$id]['period'] = transdate('short', $start) . ' - ' . date('H:i', $end); } else { $this->data[$id]['period'] = transdate('short', $start) . ' - ' . transdate('short', $end); } $this->data[$id]['weekday'] = transdate('l', $start); // content $tags = null; if ($this->data[$id]['icon'] == '') { $this->data[$id]['icon'] = 'pages/base/pics/trans.png'; } preg_match_all('#@(.+?)\\W+(.*)#i', $this->data[$id]['content'], $tags); foreach ($tags[0] as $nr => $hit) { $tag = trim($tags[1][$nr]); if ($tag == 'icon') { if (is_file(const_path . $tags[2][$nr])) { $this->data[$id][$tag] = $tags[2][$nr]; } } elseif ($tag == 'color') { $this->data[$id][$tag] = '#' . trim($tags[2][$nr]); } } } }
/** * Create some data */ public function run() { for ($i = 9; $i > 2; $i--) { $this->data[] = array('pos' => $i, 'dir' => rand(-1, 1), 'date' => transdate('date') . ' 1' . $i . ':' . rand(1, 59) . ':00', 'number' => '0931' . rand(1000000, 9999999), 'name' => 'John Q. Public', 'duration' => '00:00:' . rand(10, 50)); } $this->data[] = array('pos' => '2', 'dir' => '1', 'date' => '01.10.2012 10:00:00', 'number' => '', 'name' => 'no number', 'duration' => '00:00:10'); $this->data[] = array('pos' => '1', 'dir' => '1', 'date' => '01.10.2012 10:00:00', 'number' => '08003007707', 'name' => '', 'duration' => '00:00:10'); $this->debug($this->data, 'data'); }
/** * prepare the data */ public function prepare() { foreach ($this->data as $id => $ds) { if ($ds['number'] != '' or $ds['name'] != '') { // date $ds['date'] = transdate('short', strtotime($ds['date'])); // is there a picture to the caller? if ($ds['number'] != '' and is_file(const_path . 'pics/phone/' . $ds['number'] . '.jpg')) { $ds['pic'] = $ds['number'] . '.jpg'; } elseif ($ds['number'] != '' and is_file(const_path . 'pics/phone/' . $ds['number'] . '.png')) { $ds['pic'] = $ds['number'] . '.png'; } else { $ds['pic'] = '0.jpg'; } $ds['text'] = $ds['name']; // no name? caller unknown if ($ds['name'] == '') { $ds['text'] = trans('phone', 'unknown'); } // combine the infos, if type is present if ($ds['type'] != '') { $ds['text'] = $ds['name'] . ' (' . $ds['type'] . ')'; } // dir == 0 missed $ds['dirpic'] = 'dir.png'; $ds['diralt'] = trans('phone', 'missed'); // dir > 0 incomming if ($ds['dir'] > 0) { $ds['dirpic'] = 'dir_incoming.png'; $ds['diralt'] = trans('phone', 'incoming'); } // dir < 0 outgoing if ($ds['dir'] < 0) { $ds['dirpic'] = 'dir_outgoing.png'; $ds['diralt'] = trans('phone', 'outgoing'); } $ret[] = $ds; } } $this->data = $ret; }
/** * prepare the data */ public function prepare() { foreach ($this->data['forecast'] as $id => $ds) { $this->data['forecast'][$id]['date'] = transdate('D', strtotime($ds['date'])); } }
function twig_smartdate($val, $format = 'date') { return transdate($format, $val); }