本文整理汇总了PHP中_api_get_timezone函数的典型用法代码示例。如果您正苦于以下问题:PHP _api_get_timezone函数的具体用法?PHP _api_get_timezone怎么用?PHP _api_get_timezone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_api_get_timezone函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importEventFile
/**
* @param array $courseInfo
* @param $file
* @return array|bool|string
*/
public function importEventFile($courseInfo, $file)
{
$charset = api_get_system_encoding();
$filepath = api_get_path(SYS_ARCHIVE_PATH) . $file['name'];
$messages = array();
if (!@move_uploaded_file($file['tmp_name'], $filepath)) {
error_log('Problem moving uploaded file: ' . $file['error'] . ' in ' . __FILE__ . ' line ' . __LINE__);
return false;
}
$data = file_get_contents($filepath);
$trans = array('DAILY' => 'daily', 'WEEKLY' => 'weekly', 'MONTHLY' => 'monthlyByDate', 'YEARLY' => 'yearly');
$sentTo = array('everyone' => true);
$calendar = Sabre\VObject\Reader::read($data);
$currentTimeZone = _api_get_timezone();
if (!empty($calendar->VEVENT)) {
foreach ($calendar->VEVENT as $event) {
$start = $event->DTSTART->getDateTime();
$end = $event->DTEND->getDateTime();
//Sabre\VObject\DateTimeParser::parseDateTime(string $dt, \Sabre\VObject\DateTimeZone $tz)
$startDateTime = api_get_local_time($start->format('Y-m-d H:i:s'), $currentTimeZone, $start->format('e'));
$endDateTime = api_get_local_time($end->format('Y-m-d H:i'), $currentTimeZone, $end->format('e'));
$title = api_convert_encoding((string) $event->summary, $charset, 'UTF-8');
$description = api_convert_encoding((string) $event->description, $charset, 'UTF-8');
$id = $this->addEvent($startDateTime, $endDateTime, 'false', $title, $description, $sentTo);
$messages[] = " {$title} - " . $startDateTime . " - " . $endDateTime;
//$attendee = (string)$event->attendee;
/** @var Sabre\VObject\Property\ICalendar\Recur $repeat */
$repeat = $event->RRULE;
if ($id && !empty($repeat)) {
$repeat = $repeat->getParts();
$freq = $trans[$repeat['FREQ']];
if (isset($repeat['UNTIL']) && !empty($repeat['UNTIL'])) {
// Check if datetime or just date (strlen == 8)
if (strlen($repeat['UNTIL']) == 8) {
// Fix the datetime format to avoid exception in the next step
$repeat['UNTIL'] .= 'T000000';
}
$until = Sabre\VObject\DateTimeParser::parseDateTime($repeat['UNTIL'], new DateTimeZone($currentTimeZone));
$until = $until->format('Y-m-d H:i');
//$res = agenda_add_repeat_item($courseInfo, $id, $freq, $until, $attendee);
$this->addRepeatedItem($id, $freq, $until, $sentTo);
}
if (!empty($repeat['COUNT'])) {
/*$count = $repeat['COUNT'];
$interval = $repeat['INTERVAL'];
$endDate = null;
switch($freq) {
case 'daily':
$start = api_strtotime($startDateTime);
$date = new DateTime($startDateTime);
$days = $count * $interval;
var_dump($days);
$date->add(new DateInterval("P".$days."D"));
$endDate = $date->format('Y-m-d H:i');
//$endDate = $count *
for ($i = 0; $i < $count; $i++) {
$days = 86400 * 7
}
}
}*/
//$res = agenda_add_repeat_item($courseInfo, $id, $freq, $count, $attendee);
/*$this->addRepeatedItem(
$id,
$freq,
$endDate,
$sentTo
);*/
}
}
}
}
if (!empty($messages)) {
$messages = implode('<br /> ', $messages);
} else {
$messages = get_lang('NoAgendaItems');
}
return $messages;
}
示例2: date_to_str_ago
/**
* Returns the difference between the current date (date(now)) with the parameter $date in a string format like "2 days, 1 hour"
* Example: $date = '2008-03-07 15:44:08';
* date_to_str($date) it will return 3 days, 20 hours
* The given date should be in the timezone chosen by the user or administrator. Use api_get_local_time() to get it...
*
* @param string The string has to be the result of a date function in this format -> date('Y-m-d H:i:s', time());
* @return string The difference between the current date and the parameter in a literal way "3 days, 2 hour" *
* @author Julio Montoya
*/
function date_to_str_ago($date)
{
static $initialized = false;
static $today, $yesterday;
static $min_decade, $min_year, $min_month, $min_week, $min_day, $min_hour, $min_minute;
static $min_decades, $min_years, $min_months, $min_weeks, $min_days, $min_hours, $min_minutes;
static $sec_time_time, $sec_time_sing, $sec_time_plu;
$system_timezone = date_default_timezone_get();
date_default_timezone_set(_api_get_timezone());
if (!$initialized) {
$today = get_lang('Today');
$yesterday = get_lang('Yesterday');
$min_decade = get_lang('MinDecade');
$min_year = get_lang('MinYear');
$min_month = get_lang('MinMonth');
$min_week = get_lang('MinWeek');
$min_day = get_lang('MinDay');
$min_hour = get_lang('MinHour');
$min_minute = get_lang('MinMinute');
$min_decades = get_lang('MinDecades');
$min_years = get_lang('MinYears');
$min_months = get_lang('MinMonths');
$min_weeks = get_lang('MinWeeks');
$min_days = get_lang('MinDays');
$min_hours = get_lang('MinHours');
$min_minutes = get_lang('MinMinutes');
$sec_time_time = array(315569260, 31556926, 2629743.83, 604800, 86400, 3600, 60);
$sec_time_sing = array($min_decade, $min_year, $min_month, $min_week, $min_day, $min_hour, $min_minute);
$sec_time_plu = array($min_decades, $min_years, $min_months, $min_weeks, $min_days, $min_hours, $min_minutes);
$initialized = true;
}
$dst_date = is_string($date) ? strtotime($date) : $date;
// For avoiding calling date() several times
$date_array = date('s/i/G/j/n/Y', $dst_date);
$date_split = explode('/', $date_array);
$dst_s = $date_split[0];
$dst_m = $date_split[1];
$dst_h = $date_split[2];
$dst_day = $date_split[3];
$dst_mth = $date_split[4];
$dst_yr = $date_split[5];
$dst_date = mktime($dst_h, $dst_m, $dst_s, $dst_mth, $dst_day, $dst_yr);
$time = $offset = time() - $dst_date;
// Seconds between current days and today.
// Here start the functions sec_to_str()
$act_day = date('d');
$act_mth = date('n');
$act_yr = date('Y');
if ($dst_day == $act_day && $dst_mth == $act_mth && $dst_yr == $act_yr) {
return $today;
}
if ($dst_day == $act_day - 1 && $dst_mth == $act_mth && $dst_yr == $act_yr) {
return $yesterday;
}
$str_result = array();
$time_result = array();
$key_result = array();
$str = '';
$i = 0;
for ($i = 0; $i < count($sec_time_time); $i++) {
$seconds = $sec_time_time[$i];
if ($seconds > $time) {
continue;
}
$current_value = intval($time / $seconds);
if ($current_value != 1) {
$date_str = $sec_time_plu[$i];
} else {
$date_str = $sec_time_sing[$i];
}
$key_result[] = $sec_time_sing[$i];
$str_result[] = $current_value . ' ' . $date_str;
$time_result[] = $current_value;
$str .= $current_value . $date_str;
$time %= $seconds;
}
if ($key_result[0] == $min_day && $key_result[1] == $min_minute) {
$key_result[1] = ' 0 ' . $min_hours;
$str_result[0] = $time_result[0] . ' ' . $key_result[0];
$str_result[1] = $key_result[1];
}
if ($key_result[0] == $min_year && ($key_result[1] == $min_day || $key_result[1] == $min_week)) {
$key_result[1] = ' 0 ' . $min_months;
$str_result[0] = $time_result[0] . ' ' . $key_result[0];
$str_result[1] = $key_result[1];
}
if (!empty($str_result[1])) {
$str = $str_result[0] . ', ' . $str_result[1];
} else {
$str = $str_result[0];
//.........这里部分代码省略.........
示例3: set_system_parameters
/**
* Set system parameters
*/
private function set_system_parameters()
{
global $_configuration;
$this->theme = api_get_visual_theme();
//Setting app paths/URLs
$_p = array('web' => api_get_path(WEB_PATH), 'web_relative' => api_get_path(REL_PATH), 'web_course' => api_get_path(WEB_COURSE_PATH), 'web_main' => api_get_path(WEB_CODE_PATH), 'web_css' => api_get_path(WEB_CSS_PATH), 'web_css_theme' => api_get_path(WEB_CSS_PATH) . 'themes/' . $this->theme . '/', 'web_ajax' => api_get_path(WEB_AJAX_PATH), 'web_img' => api_get_path(WEB_IMG_PATH), 'web_plugin' => api_get_path(WEB_PLUGIN_PATH), 'web_lib' => api_get_path(WEB_LIBRARY_PATH), 'web_upload' => api_get_path(WEB_UPLOAD_PATH), 'web_self' => api_get_self(), 'web_query_vars' => api_htmlentities($_SERVER['QUERY_STRING']), 'web_self_query_vars' => api_htmlentities($_SERVER['REQUEST_URI']), 'web_cid_query' => api_get_cidreq());
$this->assign('_p', $_p);
//Here we can add system parameters that can be use in any template
$_s = array('software_name' => $_configuration['software_name'], 'system_version' => $_configuration['system_version'], 'site_name' => api_get_setting('platform.site_name'), 'institution' => api_get_setting('platform.institution'), 'date' => api_format_date('now', DATE_FORMAT_LONG), 'timezone' => _api_get_timezone(), 'gamification_mode' => api_get_setting('platform.gamification_mode'));
$this->assign('_s', $_s);
}
示例4: get_assign_log
/**
* @param $ticket_id
* @return array
*/
public static function get_assign_log($ticket_id)
{
$table_support_assigned_log = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
$ticket_id = intval($ticket_id);
$sql = "SELECT log.* FROM $table_support_assigned_log log
WHERE log.ticket_id = '$ticket_id'
ORDER BY log.assigned_date";
$result = Database::query($sql);
$history = array();
$webpath = api_get_path(WEB_PATH);
while ($row = Database::fetch_assoc($result)) {
if ($row['user_id'] != 0) {
$assignuser = api_get_user_info(
$row['user_id']
);
}
$insertuser = api_get_user_info($row['sys_insert_user_id']);
$row['assigned_date'] = api_convert_and_format_date(
api_get_local_time($row['assigned_date']), '%d/%m/%y-%H:%M:%S', _api_get_timezone()
);
$row['assignuser'] = ($row['user_id'] != 0) ? ('<a href="' . $webpath . 'main/admin/user_information.php?user_id=' . $row['user_id'] . '" target="_blank">' . $assignuser['username'] . '</a>') : get_lang('Unassign');
$row['insertuser'] = '<a href="' . $webpath . 'main/admin/user_information.php?user_id=' . $row['sys_insert_user_id'] . '" target="_blank">' . $insertuser['username'] . '</a>';
$history[] = $row;
}
return $history;
}
示例5: generate_settings_form
//.........这里部分代码省略.........
break;
case 'radio':
$values = api_get_settings_options($row['variable']);
$group = array();
if (is_array($values)) {
foreach ($values as $key => $value) {
$element =& $form->createElement('radio', $row['variable'], '', get_lang($value['display_text']), $value['value']);
if ($hide_element) {
$element->freeze();
}
$group[] = $element;
}
}
$form->addGroup($group, $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), '', false);
$default_values[$row['variable']] = $row['selected_value'];
break;
case 'checkbox':
// 1. We collect all the options of this variable.
$sql = "SELECT * FROM {$table_settings_current}\n WHERE variable='" . $row['variable'] . "' AND access_url = 1";
$result = Database::query($sql);
$group = array();
while ($rowkeys = Database::fetch_array($result)) {
// Profile tab option should be hidden when the social tool is enabled.
if (api_get_setting('social.allow_social_tool') == 'true') {
if ($rowkeys['variable'] == 'show_tabs' && $rowkeys['subkey'] == 'my_profile') {
continue;
}
}
// Hiding the gradebook option.
if ($rowkeys['variable'] == 'show_tabs' && $rowkeys['subkey'] == 'my_gradebook') {
continue;
}
$element =& $form->createElement('checkbox', $rowkeys['subkey'], '', get_lang($rowkeys['subkeytext']));
if ($row['access_url_changeable'] == 1) {
// 2. We look into the DB if there is a setting for a specific access_url.
$access_url = $_configuration['access_url'];
if (empty($access_url)) {
$access_url = 1;
}
$sql = "SELECT selected_value FROM {$table_settings_current}\n WHERE\n variable='" . $rowkeys['variable'] . "' AND\n subkey='" . $rowkeys['subkey'] . "' AND\n subkeytext='" . $rowkeys['subkeytext'] . "' AND\n access_url = {$access_url}";
$result_access = Database::query($sql);
$row_access = Database::fetch_array($result_access);
if ($row_access['selected_value'] == 'true' && !$form->isSubmitted()) {
$element->setChecked(true);
}
} else {
if ($rowkeys['selected_value'] == 'true' && !$form->isSubmitted()) {
$element->setChecked(true);
}
}
if ($hide_element) {
$element->freeze();
}
$group[] = $element;
}
$form->addGroup($group, $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), '');
break;
case 'link':
$form->addElement('static', null, array(get_lang($row['title']), get_lang($row['comment'])), get_lang('CurrentValue') . ' : ' . $row['selected_value'], $hideme);
break;
case 'select':
/*
* To populate the list of options, the select type dynamically calls a function that must be called select_ + the name of the variable being displayed.
* The functions being called must be added to the file settings.lib.php.
*/
$form->addElement('select', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), call_user_func('select_' . $row['variable']), $hideme);
$default_values[$row['variable']] = $row['selected_value'];
break;
case 'custom':
break;
}
switch ($row['variable']) {
case 'pdf_export_watermark_enable':
$url = PDF::get_watermark(null);
if ($url != false) {
$delete_url = '<a href="?delete_watermark">' . get_lang('DelImage') . ' ' . Display::return_icon('delete.png', get_lang('DelImage')) . '</a>';
$form->addElement('html', '<div style="max-height:100px; max-width:100px; margin-left:162px; margin-bottom:10px; clear:both;"><img src="' . $url . '" style="margin-bottom:10px;" />' . $delete_url . '</div>');
}
$form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
$allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
$form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
break;
case 'timezone_value':
$timezone = $row['selected_value'];
if (empty($timezone)) {
$timezone = _api_get_timezone();
}
$form->addElement('html', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'), $timezone, api_get_local_time()));
break;
}
}
// end for
if (!empty($settings)) {
$form->setDefaults($default_values);
}
$form->addHtml('<div class="bottom_actions">');
$form->addButtonSave(get_lang('SaveSettings'));
$form->addHtml('</div>');
return $form;
}
示例6: DateTime
$updatedAt = new DateTime(api_get_utc_datetime(), new DateTimeZone(_api_get_timezone()));
$skill->setStatus(1);
$skill->setUpdatedAt($updatedAt);
$entityManager->persist($skill);
$entityManager->flush();
Display::addFlash(Display::return_message(sprintf(get_lang('SkillXEnabled'), $skill->getName()), 'success'));
}
header('Location: ' . api_get_self());
exit;
break;
case 'disable':
$skill = $entityManager->find('ChamiloCoreBundle:Skill', $skillId);
if (is_null($skill)) {
Display::addFlash(Display::return_message(get_lang('SkillNotFound'), 'error'));
} else {
$updatedAt = new DateTime(api_get_utc_datetime(), new DateTimeZone(_api_get_timezone()));
$skill->setStatus(0);
$skill->setUpdatedAt($updatedAt);
$entityManager->persist($skill);
$skillObj = new Skill();
$childrens = $skillObj->get_children($skill->getId());
foreach ($childrens as $children) {
$skill = $entityManager->find('ChamiloCoreBundle:Skill', $children['id']);
if (empty($skill)) {
continue;
}
$skill->setStatus(0);
$skill->setUpdatedAt($updatedAt);
$entityManager->persist($skill);
}
$entityManager->flush();
示例7: foreach
</div>
</form>';
echo '</div>';
echo '</table></div>';
$messages = $ticket['messages'];
echo "<div class='row'>";
echo "<div class='span8 offset2'>";
foreach ($messages as $message) {
$type = "success";
if ($message['admin']) {
$type = "normal";
if ($isAdmin) {
$message['message'] .= '<br/><b>' . $plugin->get_lang('AttendedBy') . ': ' . $message['user_created'] . " - " . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>";
}
} else {
$message['message'] .= '<b>' . get_lang('Sent') . ': ' . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>";
}
$receivedMessage = '<b>' . get_lang('Subject') . ': </b> ' . $message['subject'] . '<br/> <b>' . get_lang('Message') . ':</b>' . $message['message'] . '<br/>';
$attachementLinks = "";
if (isset($message['atachments'])) {
$attributeClass = array('class' => 'attachment-link');
foreach ($message['atachments'] as $attach) {
$attachementLinks .= Display::tag('div', $attach['attachment_link'], $attributeClass);
}
}
$entireMessage = $receivedMessage . $attachementLinks;
echo Display::return_message($entireMessage, $type, false);
}
echo "</div>";
echo "</div>";
$subject = get_lang('ReplyShort') . ": " . $message['subject'];
示例8: foreach
<div class="label">Responsable:</div>
<div class="formw">' . $select_admins . '</div>
</div>
</form>';
echo '</div>';
echo '</table></div>';
$messages = $ticket['messages'];
foreach ($messages as $message) {
$class = "messageuser";
if ($message['admin']) {
$class = "messagesupport";
if ($isAdmin) {
$message['message'] .= "<br/><b>Atendido por: " . $message['user_created'] . " - " . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>";
}
} else {
$message['message'] .= "<b>Enviado: " . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>";
}
echo '<div class="' . $class . '" ><b>Asunto: </b> ' . $message['subject'] . '<br/> <b> Mensaje:</b>' . $message['message'] . '<br/>';
if (isset($message['atachments'])) {
foreach ($message['atachments'] as $attach) {
echo $attach['attachment_link'];
}
}
echo '</div>';
}
$asunto = "RE: " . $message['subject'];
$user_admin = api_is_platform_admin();
if ($ticket['ticket']['status_id'] != 'REE' and $ticket['ticket']['status_id'] != 'CLS') {
if (!$isAdmin && $ticket['ticket']['status_id'] != 'XCF') {
show_form_send_message();
} else {