public static function instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
public static function getInstance() { if (self::$instance === NULL) { return self::$instance = new self(); } else { return self::$instance; } }
static function initate() { $class = __CLASS__; if (!isset(self::$instance)) { self::$instance = new $class(); } return self::$instance; }
/** * Инициализируем Lang. */ public static function init() { if (!isset($_SESSION['lang'])) { self::setLang(); } if (empty(self::$instance)) { self::$instance = new static(); } }
public static function getInstance() { if (self::$instance == null) { if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { self::$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); } self::$instance = new Lang(); } return self::$instance; }
/** * @static * @param $taskid integer * @param $time integer */ public static function trackTime($taskid, $time, $date = null) { $current_user_id = (int) $_SESSION['userid']; $db = DBConnection::instance(); $lang = Lang::instance(); if (empty($date) || $date == $lang->get('today')) { $date = date("Y-m-d H:i"); } else { $date = date("Y-m-d 00:00", strtotime($date)); } $db->dq("INSERT INTO {$db->prefix}time_tracker (task_id, user_id, minutes, created) VALUES (?, ?, ?, ?)", array($taskid, $current_user_id, $time, $date)); }
<?php /* This file is part of myTinyTodo. (C) Copyright 2009-2010 Max Pozdeev <*****@*****.**> Licensed under the GNU GPL v2 license. See file COPYRIGHT for details. */ $dontStartSession = 1; require_once './init.php'; $lang = Lang::instance(); $listId = (int) _get('list'); $listData = $db->sqa("SELECT * FROM {$db->prefix}lists WHERE id={$listId}"); if ($needAuth && (!$listData || !$listData['published'])) { die("Access denied!<br> List is not published."); } if (!$listData) { die("No such list"); } $feedType = _get('feed'); $sqlWhere = ''; if ($feedType == 'completed') { $listData['_uid_field'] = 'd_completed'; $listData['_feed_descr'] = $lang->get('feed_completed_tasks'); $sqlWhere = 'AND compl=1'; } elseif ($feedType == 'modified') { $listData['_uid_field'] = 'd_edited'; $listData['_feed_descr'] = $lang->get('feed_modified_tasks'); } elseif ($feedType == 'current') { $listData['_uid_field'] = 'd_created'; $listData['_feed_descr'] = $lang->get('feed_new_tasks'); $sqlWhere = 'AND compl=0';
function printICal($listData, $data) { $mttToIcalPrio = array("1" => 5, "2" => 1); $s = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nMETHOD:PUBLISH\r\nCALSCALE:GREGORIAN\r\nPRODID:-//myTinyTodo//iCalendar Export v1.4//EN\r\n" . "X-WR-CALNAME:" . $listData['name'] . "\r\nX-MTT-TIMEZONE:" . Config::get('timezone') . "\r\n"; # to-do foreach ($data as $r) { $a = array(); $a[] = "BEGIN:VTODO"; $a[] = "UID:" . $r['uuid']; $a[] = "CREATED:" . gmdate('Ymd\\THis\\Z', $r['d_created']); $a[] = "DTSTAMP:" . gmdate('Ymd\\THis\\Z', $r['d_edited']); $a[] = "LAST-MODIFIED:" . gmdate('Ymd\\THis\\Z', $r['d_edited']); $a[] = utf8chunks("SUMMARY:" . $r['title']); if ($r['duedate']) { $dda = explode('-', $r['duedate']); $a[] = "DUE;VALUE=DATE:" . sprintf("%u%02u%02u", $dda[0], $dda[1], $dda[2]); } # Apple's iCal priorities: low-9, medium-5, high-1 if ($r['prio'] > 0 && isset($mttToIcalPrio[$r['prio']])) { $a[] = "PRIORITY:" . $mttToIcalPrio[$r['prio']]; } $a[] = "X-MTT-PRIORITY:" . $r['prio']; $descr = array(); if ($r['tags'] != '') { $descr[] = Lang::instance()->get('tags') . ": " . str_replace(',', ', ', $r['tags']); } if ($r['note'] != '') { $descr[] = Lang::instance()->get('note') . ": " . $r['note']; } if ($descr) { $a[] = utf8chunks("DESCRIPTION:" . str_replace("\n", '\\n', implode("\n", $descr))); } if ($r['compl']) { $a[] = "STATUS:COMPLETED"; #used in Sunbird $a[] = "COMPLETED:" . gmdate('Ymd\\THis\\Z', $r['d_completed']); #$a[] = "PERCENT-COMPLETE:100"; #used in Sunbird } if ($r['tags'] != '') { $a[] = utf8chunks("X-MTT-TAGS:" . $r['tags']); } $a[] = "END:VTODO\r\n"; $s .= implode("\r\n", $a); } # events foreach ($data as $r) { if (!$r['duedate'] || $r['compl']) { continue; } # skip tasks completed and without duedate $a = array(); $a[] = "BEGIN:VEVENT"; $a[] = "UID:_" . $r['uuid']; # do not duplicate VTODO UID $a[] = "CREATED:" . gmdate('Ymd\\THis\\Z', $r['d_created']); $a[] = "DTSTAMP:" . gmdate('Ymd\\THis\\Z', $r['d_edited']); $a[] = "LAST-MODIFIED:" . gmdate('Ymd\\THis\\Z', $r['d_edited']); $a[] = utf8chunks("SUMMARY:" . $r['title']); if ($r['prio'] > 0 && isset($mttToIcalPrio[$r['prio']])) { $a[] = "PRIORITY:" . $mttToIcalPrio[$r['prio']]; } $dda = explode('-', $r['duedate']); $a[] = "DTSTART;VALUE=DATE:" . sprintf("%u%02u%02u", $dda[0], $dda[1], $dda[2]); $a[] = "DTEND;VALUE=DATE:" . date('Ymd', mktime(1, 1, 1, $dda[1], $dda[2], $dda[0]) + 86400); $descr = array(); if ($r['tags'] != '') { $descr[] = Lang::instance()->get('tags') . ": " . str_replace(',', ', ', $r['tags']); } if ($r['note'] != '') { $descr[] = Lang::instance()->get('note') . ": " . $r['note']; } if ($r['c_contact'] != '') { $descr[] = "contact: " . $r['c_contact']; } if ($r['c_date'] != '') { $descr[] = "contact Date: " . $r['c_date']; } if ($r['c_type'] != '') { $descr[] = "contact Type: " . $r['c_type']; } if ($descr) { $a[] = utf8chunks("DESCRIPTION:" . str_replace("\n", '\\n', implode("\n", $descr))); } $a[] = "END:VEVENT\r\n"; $s .= implode("\r\n", $a); } $s .= "END:VCALENDAR\r\n"; header('Content-type: text/calendar; charset=utf-8'); header('Content-disposition: attachment; filename=list_' . $listData['id'] . '.ics'); print $s; }
function __($s) { return Lang::instance()->get($s); }
/** * Стаандартное получение инстанса * @return Lang */ public static function getInstance() { return self::$instance === null ? self::$instance = new self('Auth', false) : self::$instance; }
function prepare_duedate($duedate) { $lang = Lang::instance(); $a = array('class' => '', 'str' => '', 'formatted' => '', 'timestamp' => 0); if ($duedate == '' || $duedate == 0) { return $a; } $ad = explode('-', $duedate); $at = explode('-', date('Y-m-d')); $a['timestamp'] = mktime(0, 0, 0, $ad[1], $ad[2], $ad[0]); $diff = mktime(0, 0, 0, $ad[1], $ad[2], $ad[0]) - mktime(0, 0, 0, $at[1], $at[2], $at[0]); if ($diff < -604800 && $ad[0] == $at[0]) { $a['class'] = 'past'; $a['str'] = formatDate3(Config::get('dateformatshort'), (int) $ad[0], (int) $ad[1], (int) $ad[2], $lang); } elseif ($diff < -604800) { $a['class'] = 'past'; $a['str'] = formatDate3(Config::get('dateformat2'), (int) $ad[0], (int) $ad[1], (int) $ad[2], $lang); } elseif ($diff < -86400) { $a['class'] = 'past'; $a['str'] = sprintf($lang->get('daysago'), ceil(abs($diff) / 86400)); } elseif ($diff < 0) { $a['class'] = 'past'; $a['str'] = $lang->get('yesterday'); } elseif ($diff < 86400) { $a['class'] = 'today'; $a['str'] = $lang->get('today'); } elseif ($diff < 172800) { $a['class'] = 'today'; $a['str'] = $lang->get('tomorrow'); } elseif ($diff < 691200) { $a['class'] = 'soon'; $a['str'] = sprintf($lang->get('indays'), ceil($diff / 86400)); } elseif ($ad[0] == $at[0]) { $a['class'] = 'future'; $a['str'] = formatDate3(Config::get('dateformatshort'), (int) $ad[0], (int) $ad[1], (int) $ad[2], $lang); } else { $a['class'] = 'future'; $a['str'] = formatDate3(Config::get('dateformat2'), (int) $ad[0], (int) $ad[1], (int) $ad[2], $lang); } $a['formatted'] = formatTime(Config::get('dateformat2'), $a['timestamp']); return $a; }
<?php header('Content-type: text/javascript; charset=utf-8'); echo "mytinytodo.lang.init(" . Lang::instance()->makeJS() . ");";
function _r($s, $params) { if (is_array($params)) { return vsprintf(Lang::instance()->get($s), $params); } else { return vsprintf(Lang::instance()->get($s), array($params)); } }
function formatTime($format, $timestamp = 0) { $lang = Lang::instance(); if ($timestamp == 0) { $timestamp = time(); } $newformat = strtr($format, array('F' => '%1', 'M' => '%2')); $adate = explode(',', date('n,' . $newformat, $timestamp), 2); $s = $adate[1]; if ($newformat != $format) { $am = (int) $adate[0]; $ml = $lang->get('months_long'); $ms = $lang->get('months_short'); $F = $ml[$am - 1]; $M = $ms[$am - 1]; $s = strtr($s, array('%1' => $F, '%2' => $M)); } return $s; }
<?php /* This file is part of yourTinyTodo by the yourTinyTodo community. Copyrights for portions of this file are retained by their owners. Based on myTinyTodo by Max Pozdeev (C) Copyright 2009-2010 Max Pozdeev <*****@*****.**> Licensed under the GNU GPL v3 license. See file COPYRIGHT for details. */ if (!defined('YTTPATH')) { define('YTTPATH', dirname(__FILE__) . '/'); } require_once YTTPATH . 'db/config.php'; require_once YTTPATH . 'core/Lang.class.php'; require_once YTTPATH . 'lang/' . $config['lang'] . '.php'; header('Content-type: text/javascript; charset=utf-8'); ?> yourtinytodo.lang.init(<?php echo Lang::instance()->makeJS(); ?> );