"/models/request_request.php", 'RegistrationUsers' => "/models/registration_users.php", 'AdminLanguages' => '/models/admin_languages.php', 'NewsListNews' => '/models/news_list_news.php', 'GlobalAccess' => '/models/global_access.php', 'AdminPopup' => '/models/admin_popup.php', 'AdminHistoryLog' => '/models/admin_history_log.php', 'AdminLanguages' => '/models/admin_languages.php', 'MedicationForms' => '/models/medication_forms.php' ); static public function loadIfDefine($class_name) { if (isset(self::$C_F_LIST[$class_name])) { include_once ROOT_PATH.AutoLoadClassFiles::$C_F_LIST[$class_name]; } } } function __autoload($class_name) { AutoLoadClassFiles::loadIfDefine($class_name); } class Commun_type { public static $ID_BY_NAME_ARR = array( 'video' => COMMUN_VIDEO_ID, 'chat' => COMMUN_CHAT_ID, 'email' => COMMUN_EMAIL_ID, 'person' => COMMUN_PERSON_ID ); public static $ICON_BY_ID = array( COMMUN_CHAT_ID => 'chat.jpg', COMMUN_VIDEO_ID => 'video.jpg', COMMUN_EMAIL_ID => 'email.jpg', COMMUN_PERSON_ID=> 'person.jpg', ); public static $ENUM_TYPE_BY_ID = array( COMMUN_CHAT_ID => 'chat', COMMUN_VIDEO_ID => 'video', COMMUN_EMAIL_ID => 'question', COMMUN_PERSON_ID=> 'person', ); public static $STATUS_R = array( 'communicated' => 'communicated', 'closed' => 'closed' ); function ID_BY_NAME($name) { $ID_BY_NAME = self::$ID_BY_NAME_ARR; return $ID_BY_NAME[$name]; } function NAME_BY_ID($id) { $NAME_BY_ID = array_flip(self::$ID_BY_NAME_ARR); return $NAME_BY_ID[$id]; } function ID_BY_ENUM_TYPE($type) { $ID_BY_ENUM_TYPE = array_flip(self::$ENUM_TYPE_BY_ID); return $ID_BY_ENUM_TYPE[$type]; } } class TransDate { static public $MONTHS = array( '1' => array('full' => 'January', 'short' => 'sJanuary'), '2' => array('full' => 'February', 'short' => 'sFebruary'), '3' => array('full' => 'March', 'short' => 'sMarch'), '4' => array('full' => 'April', 'short' => 'sApril'), '5' => array('full' => 'May', 'short' => 'sMay'), '6' => array('full' => 'June', 'short' => 'sJune'), '7' => array('full' => 'July', 'short' => 'sJuly'), '8' => array('full' => 'August', 'short' => 'sAugust'), '9' => array('full' => 'September', 'short' => 'sSeptember'), '10' => array('full' => 'October', 'short' => 'sOctober'), '11' => array('full' => 'November', 'short' => 'sNovember'), '12' => array('full' => 'December', 'short' => 'sDecember'), ); static public $DAYS_OF_WEEK = array( '0' => 'Sunday', '1' => 'Monday', '2' => 'Tuesday', '3' => 'Wednesday', '4' => 'Thursday', '5' => 'Friday', '6' => 'Saturday', ); public static function getMonthsTrans($trans, $type = 'full') { $result = array(); foreach (self::$MONTHS as $i => $m) $result[$i] = $trans[$m[$type]]; return $result; } public static function getMonthTrans($trans, $month_num, $type = 'full') { $month_num = intval($month_num); if ($month_num == 0) $month_num = 1; $month_name = self::$MONTHS[$month_num]; return $trans[$month_name[$type]]; } public static function getDaysOfWeekTrans($trans) { $result = array(); foreach (self::$DAYS_OF_WEEK as $i => $dw) $result[$i] = $trans[$dw]; return $result; } public static function getDayOfWeekTrans($trans, $day_num) { $day_name = self::$DAYS_OF_WEEK[$day_num]; return $trans[$day_name]; } public static function substitute_month($date, $trans, $type = 'short', $explode_symbol = '-', $cancat_symbol = '. ') { $date_part = explode($explode_symbol, $date); return $date_part[0].$cancat_symbol.self::getMonthTrans($trans, $date_part[1], $type).$cancat_symbol.$date_part[2]; } } class ExtDateTime { public static $SHORT_MONTH_TO_NUM = array( 'Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12', ); } class ExtUtf8 { public static function ucfirst($string, $e ='utf-8') { if (function_exists('mb_strtoupper') && function_exists('mb_substr') && !empty($string)) { $string = mb_strtolower($string, $e); $upper = mb_strtoupper($string, $e); preg_match('#(.)#us', $upper, $matches); $string = $matches[1] . mb_substr($string, 1, mb_strlen($string, $e), $e); } else { $string = ucfirst($string); } return $string; } } abstract class DTZ { /** * @var string */ protected $format; /** * @var string */ protected $sql_format; /** * @var int sec */ protected $time; /** * @var int min */ protected $user_zone;//min protected function __construct() { $this->format = '%d.%m.%Y %H:%M'; $this->sql_format = '%Y-%m-%d %H:%i:%s'; $this->user_zone = (isset($_SESSION['zone']))? (int)$_SESSION['zone'] : 0; } /** * Set format prop * * @param string $format */ public function setFormat($format) { $this->format = $format; } /** * Set date format for sql * * @param string $sql_format */ public function setSqlFormat($sql_format) { $this->sql_format = $sql_format; } /** * Return current date * * @param string $format if this value is null use def class format * @return string */ public function getCurDate($format = null) { if (!$format) $format = $this->format; return strftime($format, $this->time); } /** * Return time zone offset * * @return int in seconds */ public function getZoneOffset() { return $this->user_zone * 60; } /** * Returns the date x days ago or x days in advance * * @param int $days * @return string */ public function getXDaysFromNow($days, $format = null) { if (!$format) $format = $this->format; return strftime($format, $this->time + ($days * 24 * 60 * 60)); } /** * Return unix timestamp from date time * * @param string $date_time * @param array $date_format * @param string $separator * @return int */ protected function getMkTime($date_time, $date_format, $seporator) { if (!empty($time_format) && ($seporator == ' ' || !empty($seporator))) { $parts = explode($seporator, $date_time); $date_parts = explode($date_format['dsep'], $parts[0]); $time_parts = explode($time_format['tsep'], $parts[1]); } else { $date_parts = explode($date_format['dsep'], $date_time); $time_parts = array(0,0,0); } $year = $date_parts[$date_format['Y']]; $month = $date_parts[$date_format['m']]; $day = $date_parts[$date_format['d']]; return mktime($time_parts[0], $time_parts[1], $time_parts[2], $month, $day, $year); } } /** * Singleton User Date time class */ class UserDtz extends DTZ { static private $instance; protected function __construct() { parent::__construct(); $this->time = time() + ((isset($_SESSION['zone']))? $_SESSION['zone'] * 60 : 0); } private function __clone() { } /** * Return instance */ static public function getI() { if (self::$instance === null) self::$instance = new self(); return self::$instance; } /** * Return sql fragment which returns the date in the format user * * @param string $sql_field * @param string $alias_fname * @param string $sql_format if format not defined use defaul class sql format * @return string */ public function getSqlDateFragment($sql_field, $alias_fname, $sql_format = null) { if (!$sql_format) $sql_format = $this->sql_format; $zone = $this->user_zone; $sql_date_fragment = "DATE_FORMAT(DATE_ADD({$sql_field}, INTERVAL {$zone} MINUTE), '{$sql_format}') AS {$alias_fname}"; return $sql_date_fragment; } /** * Return server date time from user date time * * @param string $user_date_time * @param array $date_format * @param $separator */ public function convertToServer($user_date_time, array $date_format = array(), $separator = '') { if (!empty($date_format)) { $mk_time_from_date = $this->getMkTime($user_date_time, $date_format, $separator); } else $mk_time_from_date = $user_date_time; if (isset($date_format['format'])) $format = $date_format['format']; else $format = $this->format; return strftime($format, $mk_time_from_date - $this->getZoneOffset()); } } class ServerDtz extends DTZ { static private $instance; static private $DF_KEY = 'date_format:'; protected function __construct() { parent::__construct(); $this->time = time(); } private function __clone() { } /** * Return instance */ static public function getI() { if (self::$instance === null) self::$instance = new self(); return self::$instance; } /** * Return user date time from server date time * * @param string $serv_date_time * @param array $date_format * @param string $separator */ public function convertToUserDate($serv_date_time, array $date_format = array(), $separator = '') { if (!empty($date_format)) { $mk_time_from_date = $this->getMkTime($serv_date_time, $date_format, $separator); } else $mk_time_from_date = $serv_date_time; if (isset($date_format['format'])) $format = $date_format['format']; else $format = $this->format; return strftime($format, $mk_time_from_date + $this->getZoneOffset()); } } ?>'; foreach ($arg_list as $val) { print_r($val); echo "\n"; } echo ''; } /** * Функция для вывода отладочной информации. Работает только в отладочной версии * * @param mixed $variable * @uses dBug */ function _p($variable) { if (_isSQL($variable)) { _q($variable); } else { if (require_once(ROOT_PATH.'/debug/dBug/dBug.php')) { new dBug($variable); } else { var_dump($variable); } } } /** * Функция для отладочного вывода SQL запроса. Работает только в отладочной версии * * @param string $query * * @uses phpDump */ function _q($query) { if (require_once(ROOT_PATH.'/debug/phpDump/phpDump.php')) { $dump = new phpDump(); if ($dump AND is_a ($dump, 'phpDump')) { $output = $dump->dumpq($query, false, 4); } } else { $output = $query; } echo $output; } ?>