本文整理汇总了PHP中Fisharebest\Webtrees\I18N::dateFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP I18N::dateFormat方法的具体用法?PHP I18N::dateFormat怎么用?PHP I18N::dateFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\I18N
的用法示例。
在下文中一共展示了I18N::dateFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SimpleController
/**
* Defined in session.php
*
* @global Tree $WT_TREE
*/
global $WT_TREE;
use Fisharebest\Webtrees\Controller\SimpleController;
use Fisharebest\Webtrees\Functions\FunctionsEdit;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
use Fisharebest\Webtrees\GedcomCode\GedcomCodePedi;
define('WT_SCRIPT_NAME', 'edit_interface.php');
require './includes/session.php';
$action = Filter::post('action', null, Filter::get('action'));
$controller = new SimpleController();
$controller->restrictAccess(Auth::isEditor($WT_TREE))->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();')->addInlineJavascript('var locale_date_format="' . preg_replace('/[^DMY]/', '', str_replace(array('J', 'F'), array('D', 'M'), I18N::dateFormat())) . '";');
switch ($action) {
////////////////////////////////////////////////////////////////////////////////
case 'editraw':
$xref = Filter::get('xref', WT_REGEX_XREF);
$record = GedcomRecord::getInstance($xref, $WT_TREE);
check_record_access($record);
$controller->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit raw GEDCOM'))->pageHeader()->addInlineJavascript('jQuery("#raw-gedcom-list").sortable({opacity: 0.7, cursor: "move", axis: "y"});');
?>
<div id="edit_interface-page">
<h4>
<?php
echo $controller->getPageTitle();
?>
<?php
echo FunctionsPrint::helpLink('edit_edit_raw');
示例2: display
/**
* Convert a date to the preferred format and calendar(s) display.
*
* @param bool|null $url Wrap the date in a link to calendar.php
* @param string|null $date_format Override the default date format
* @param bool|null $convert_calendars Convert the date into other calendars
*
* @return string
*/
public function display($url = false, $date_format = null, $convert_calendars = true)
{
global $WT_TREE;
$CALENDAR_FORMAT = $WT_TREE->getPreference('CALENDAR_FORMAT');
if ($date_format === null) {
$date_format = I18N::dateFormat();
}
if ($convert_calendars) {
$calendar_format = explode('_and_', $CALENDAR_FORMAT);
} else {
$calendar_format = array();
}
// Two dates with text before, between and after
$q1 = $this->qual1;
$d1 = $this->date1->format($date_format, $this->qual1);
$q2 = $this->qual2;
if (is_null($this->date2)) {
$d2 = '';
} else {
$d2 = $this->date2->format($date_format, $this->qual2);
}
// Con vert to other calendars, if requested
$conv1 = '';
$conv2 = '';
foreach ($calendar_format as $cal_fmt) {
if ($cal_fmt != 'none') {
$d1conv = $this->date1->convertToCalendar($cal_fmt);
if ($d1conv->inValidRange()) {
$d1tmp = $d1conv->format($date_format, $this->qual1);
} else {
$d1tmp = '';
}
if (is_null($this->date2)) {
$d2conv = null;
$d2tmp = '';
} else {
$d2conv = $this->date2->convertToCalendar($cal_fmt);
if ($d2conv->inValidRange()) {
$d2tmp = $d2conv->format($date_format, $this->qual2);
} else {
$d2tmp = '';
}
}
// If the date is different from the unconverted date, add it to the date string.
if ($d1 != $d1tmp && $d1tmp !== '') {
if ($url) {
if ($CALENDAR_FORMAT !== 'none') {
$conv1 .= ' <span dir="' . I18N::direction() . '">(<a href="' . $d1conv->calendarUrl($date_format) . '" rel="nofollow">' . $d1tmp . '</a>)</span>';
} else {
$conv1 .= ' <span dir="' . I18N::direction() . '"><br><a href="' . $d1conv->calendarUrl($date_format) . '" rel="nofollow">' . $d1tmp . '</a></span>';
}
} else {
$conv1 .= ' <span dir="' . I18N::direction() . '">(' . $d1tmp . ')</span>';
}
}
if (!is_null($this->date2) && $d2 != $d2tmp && $d1tmp != '') {
if ($url) {
$conv2 .= ' <span dir="' . I18N::direction() . '">(<a href="' . $d2conv->calendarUrl($date_format) . '" rel="nofollow">' . $d2tmp . '</a>)</span>';
} else {
$conv2 .= ' <span dir="' . I18N::direction() . '">(' . $d2tmp . ')</span>';
}
}
}
}
// Add URLs, if requested
if ($url) {
$d1 = '<a href="' . $this->date1->calendarUrl($date_format) . '" rel="nofollow">' . $d1 . '</a>';
if (!is_null($this->date2)) {
$d2 = '<a href="' . $this->date2->calendarUrl($date_format) . '" rel="nofollow">' . $d2 . '</a>';
}
}
// Localise the date
switch ($q1 . $q2) {
case '':
$tmp = $d1 . $conv1;
break;
case 'ABT':
$tmp = I18N::translate('about %s', $d1 . $conv1);
break;
case 'CAL':
$tmp = I18N::translate('calculated %s', $d1 . $conv1);
break;
case 'EST':
$tmp = I18N::translate('estimated %s', $d1 . $conv1);
break;
case 'INT':
$tmp = I18N::translate('interpreted %s (%s)', $d1 . $conv1, $this->text);
break;
case 'BEF':
$tmp = I18N::translate('before %s', $d1 . $conv1);
break;
//.........这里部分代码省略.........
示例3: getLatestUserData
/**
* Get the newest registered user.
*
* @param string $type
* @param string[] $params
*
* @return string
*/
private function getLatestUserData($type = 'userid', $params = array())
{
static $user_id = null;
if ($user_id === null) {
$user = User::findLatestToRegister();
} else {
$user = User::find($user_id);
}
switch ($type) {
default:
case 'userid':
return $user->getUserId();
case 'username':
return Filter::escapeHtml($user->getUserName());
case 'fullname':
return $user->getRealNameHtml();
case 'regdate':
if (is_array($params) && isset($params[0]) && $params[0] != '') {
$datestamp = $params[0];
} else {
$datestamp = I18N::dateFormat();
}
return FunctionsDate::timestampToGedcomDate($user->getPreference('reg_timestamp'))->display(false, $datestamp);
case 'regtime':
if (is_array($params) && isset($params[0]) && $params[0] != '') {
$datestamp = $params[0];
} else {
$datestamp = str_replace('%', '', I18N::timeFormat());
}
return date($datestamp, $user->getPreference('reg_timestamp'));
case 'loggedin':
if (is_array($params) && isset($params[0]) && $params[0] != '') {
$yes = $params[0];
} else {
$yes = I18N::translate('yes');
}
if (is_array($params) && isset($params[1]) && $params[1] != '') {
$no = $params[1];
} else {
$no = I18N::translate('no');
}
return Database::prepare("SELECT SQL_NO_CACHE 1 FROM `##session` WHERE user_id=? LIMIT 1")->execute(array($user->getUserId()))->fetchOne() ? $yes : $no;
}
}
示例4: jsonTasksList
/**
* AdminConfig@jsonTasksList
*/
public function jsonTasksList()
{
global $WT_TREE;
$controller = new JsonController();
$controller->restrictAccess(Auth::isAdmin());
// Generate an AJAX/JSON response for datatables to load a block of rows
$search = Filter::postArray('search');
if ($search) {
$search = $search['value'];
}
$start = Filter::postInteger('start');
$length = Filter::postInteger('length');
$order = Filter::postArray('order');
$order_by_name = false;
foreach ($order as $key => &$value) {
switch ($value['column']) {
case 3:
$order_by_name = true;
unset($order[$key]);
break;
case 4:
$value['column'] = 'majat_last_run';
break;
case 4:
$value['column'] = 'majat_last_result';
break;
default:
unset($order[$key]);
}
}
$list = $this->provider->getFilteredTasksList($search, $order, $start, $length);
if ($order_by_name) {
usort($list, function (AbstractTask $a, AbstractTask $b) {
return I18N::strcasecmp($a->getTitle(), $b->getTitle());
});
}
$recordsFiltered = count($list);
$recordsTotal = $this->provider->getTasksCount();
$data = array();
foreach ($list as $task) {
$datum = array();
$datum[0] = '
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<i class="fa fa-pencil"></i><span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a href="#" onclick="return set_admintask_status(\'' . $task->getName() . '\', ' . ($task->isEnabled() ? 'false' : 'true') . ');">
<i class="fa fa-fw ' . ($task->isEnabled() ? 'fa-times' : 'fa-check') . '"></i> ' . ($task->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . '
</a>
</li>
<li>
<a href="module.php?mod=' . $this->module->getName() . '&mod_action=Task@edit&task=' . $task->getName() . '">
<i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . '
</a>
</li>
</ul>
</div>';
$datum[1] = $task->getName();
$datum[2] = $task->isEnabled() ? '<i class="fa fa-check"></i><span class="sr-only">' . I18N::translate('Enabled') . '</span>' : '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('Disabled') . '</span>';
$datum[3] = $task->getTitle();
$date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s';
$datum[4] = $task->getLastUpdated()->format($date_format);
$datum[5] = $task->isLastRunSuccess() ? '<i class="fa fa-check"></i><span class="sr-only">' . I18N::translate('Yes') . '</span>' : '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('No') . '</span>';
$dtF = new \DateTime('@0');
$dtT = new \DateTime('@' . $task->getFrequency() * 60);
$datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m'));
$datum[7] = $task->getRemainingOccurrences() > 0 ? I18N::number($task->getRemainingOccurrences()) : I18N::translate('Unlimited');
$datum[8] = $task->isRunning() ? '<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">' . I18N::translate('Running') . '</span>' : '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('Not running') . '</span>';
if ($task->isEnabled() && !$task->isRunning()) {
$datum[9] = '
<button id="bt_runtask_' . $task->getName() . '" class="btn btn-primary" href="#" onclick="return run_admintask(\'' . $task->getName() . '\')">
<div id="bt_runtasktext_' . $task->getName() . '"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div>
</button>';
} else {
$datum[9] = '';
}
$data[] = $datum;
}
$controller->pageHeader();
$controller->encode(array('draw' => Filter::getInteger('draw'), 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered, 'data' => $data));
}