function __construct() { $object_class_name = get_class($this); $this->_name = strtolower(str_replace('EventInfo_', '', $object_class_name)); $t = new CStoreDatetime(); $this->_time = $t->getTimestamp(); }
function outputTimelineItems() { $items_list = modApiFunc('Timeline', 'getTimelineHeaders'); $html = ''; $group = ''; foreach ($items_list as $item) { $time_obj = new CStoreDatetime(strtotime($item['datetime'])); // $time = date('H:i:s', $time_obj->getTimestamp()); $date = modApiFunc('Localization', 'date_format', $time_obj->getTimestamp(), false); // false - // - if ($group !== $date) { $html .= $this->_TmplFiller->fill("", "group.tpl.html", array('GROUP' => $date)); $group = $date; } $details = ''; if ($item['is_body_empty'] == 0) { $details = ' '; } else { $params = array('LINK_TITLE' => getMsg('TL', 'DETAILS'), 'ID' => $item['id']); $details = $this->_TmplFiller->fill("", "link.tpl.html", $params); } $params = array('ID' => $item['id'], 'TIME' => $time, 'TYPE' => $item['type'], 'HEADER' => $item['header'], 'DETAILS' => $details); $html .= $this->_TmplFiller->fill("", "line.tpl.html", $params); } return $html; }
function outputTimelineHeader($item_id) { $item = modApiFunc('Timeline', 'getTimelineItemById', $item_id); $html = ''; $date = modApiFunc('Localization', 'date_format', $item['datetime']); // $time_obj = new CStoreDatetime(strtotime($item['datetime'])); // $time = date('H:i:s', $time_obj->getTimestamp()); $params = array('TIME' => $date . ' ' . $time, 'TYPE' => $item['type'], 'HEADER' => $item['header']); return $date . ' ' . $time . ' ' . $item['type'] . '<br>' . $item['header']; }
function onAction() { global $application; $request =& $application->getInstance('Request'); $sub_action = $request->getValueByKey('sub_action'); $out_file_path = $application->getAppIni('PATH_CACHE_DIR') . '__orders.csv'; global $_RESULT; switch ($sub_action) { case 'init': $sets = array(); $sets['orders_ids'] = $request->getValueByKey('orders_ids'); $sets['out_file'] = $out_file_path; $sets['csv_delimiter'] = ';'; $sets['script_code'] = 'Orders_DB_CSV'; $sets['script_step'] = 1; modApiFunc('Data_Converter', 'initDataConvert', $sets); $_RESULT["errors"] = modApiFunc('Data_Converter', 'getErrors'); $_RESULT["warnings"] = modApiFunc('Data_Converter', 'getWarnings'); $_RESULT["messages"] = modApiFunc('Data_Converter', 'getMessages'); $_RESULT["process_info"] = modApiFunc('Data_Converter', 'getProcessInfo'); break; case 'do': modApiFunc('Data_Converter', 'doDataConvert'); $_RESULT["errors"] = modApiFunc('Data_Converter', 'getErrors'); $_RESULT["warnings"] = modApiFunc('Data_Converter', 'getWarnings'); $_RESULT["messages"] = modApiFunc('Data_Converter', 'getMessages'); $_RESULT["process_info"] = modApiFunc('Data_Converter', 'getProcessInfo'); break; case 'get': $d = new CStoreDatetime(); $datetime = date('Y-m-d-H-i-s', $d->getTimestamp()); header("Pragma: no-cache"); header("Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/csv"); header("Content-Length: " . filesize($out_file_path)); header("Content-Disposition: attachment; filename=\"orders-" . $datetime . ".csv\""); $iif_file = fopen($out_file_path, 'r'); while (!feof($iif_file)) { echo fread($iif_file, 4096); } fclose($iif_file); unlink($out_file_path); die; break; } }
/** * : , * . */ function __addZeroItems($data, $zero_item) { // MySQL format $from = $this->__params['from']; $to = $this->__params['to']; if ($from == null or $to == null) { $store_time = new CStoreDatetime(); $to = $store_time->getTimestamp(); // shifted now() // , $first_item = isset($data[0]) ? $data[0] : array('datetime_year' => 2007); // $first_year = $first_item['datetime_year']; $first_month = isset($first_item['datetime_month']) ? $first_item['datetime_month'] : 1; $first_day = isset($first_item['datetime_day']) ? $first_item['datetime_day'] : 1; $from = mktime(0, 0, 1, $first_month, $first_day, $first_year); } else { $from = strtotime($from); $to = strtotime($to); } $discontinuity = $this->__params['discontinuity']; $full_data_list = $this->__getCalendar($from, $to, $discontinuity); // ( ) $__keys = array('datetime_year', 'datetime_month', 'datetime_day'); // $to_merge = array($full_data_list, $data); // ( $to_merge) $empty_items = array(array(), $zero_item); return $this->__margeArrays($to_merge, $empty_items, $__keys); }
function output() { $params['from'] = null; $params['to'] = null; $params['visit_deadline'] = null; $store_time = new CStoreDatetime(); $now = $store_time->getTimestamp(); # get the earliet visit time $r = execQuery("SELECT_EARLIEST_VISIT_TIME", $params); $fv = $r[0]['first_visit']; if ($fv == null) { return '0'; } # calculation of numbner online visitors per each day since the beginning preg_match("/([0-9]*)-([0-9]*)-([0-9]*) ([0-9]*):([0-9]*):([0-9]*)/", $fv, $m); $earliest_visit = mktime($m[4], $m[5], $m[6], $m[2], $m[3], $m[1]); $visits = array(); $days = 0; while ($earliest_visit <= $now) { $from = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m", $earliest_visit), date("d", $earliest_visit), date("Y", $earliest_visit))); $to = date("Y-m-d H:i:s", mktime(23, 59, 59, date("m", $earliest_visit), date("d", $earliest_visit), date("Y", $earliest_visit))); $params = array('from' => $from, 'to' => $to); $r = execQuery("SELECT_VISITORS_STATISTICS_BY_PERIOD", $params); $visits[] = array("date" => $earliest_visit, "online" => count($r)); $earliest_visit += 3600 * 24; //next day $days++; } $all = 0; if (count($visits) != 0) { foreach ($visits as $i => $s) { $all += $s['online']; } } if ($days == 0) { return '0'; } $res = $all / $days; //total number or unique visitors by number of days if ($res != 0) { return modApiFunc("Localization", "num_format", $res); } else { return '0'; } }
function getTimestamp() { $store_time = new CStoreDatetime(); $vd = $store_time->getTimestamp(); return $vd; }
function onAction() { global $application; $request =& $application->getInstance('Request'); $sub_action = $request->getValueByKey('sub_action'); $topics_ids = explode(',', $request->getValueByKey('topics')); $is_csv = $request->getValueByKey('export_format') == 'csv'; $ext = $is_csv ? 'csv' : 'txt'; $out_file_path = $application->getAppIni('PATH_CACHE_DIR') . '__emails.' . $ext; global $_RESULT; switch ($sub_action) { case 'get': $d = new CStoreDatetime(); $datetime = date('Y-m-d-H-i-s', $d->getTimestamp()); header('Pragma: no-cache'); header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Type: application/' . ($is_csv ? 'csv' : 'force-download')); header('Content-Disposition: attachment; filename="emails-' . $datetime . '.' . $ext . '"'); if ($is_csv) { $this->getTopicsEmails($topics_ids); } else { $this->getEmails($topics_ids); } exit; } }