1
0

Fix bugs in the new backend templates

This commit is contained in:
Garvin Hicking
2007-06-11 14:32:32 +00:00
parent 4edcca9ce4
commit 99a34f193e
5 changed files with 56 additions and 39 deletions

View File

@@ -132,9 +132,10 @@ function &serendipity_convertToTimestamp($in) {
* @param string Output format for the timestamp
* @param int Timestamp to use for displaying
* @param boolean Indicates, if timezone calculations shall be used.
* @param boolean Whether to use strftime or simply date
* @return string The formatted timestamp
*/
function serendipity_strftime($format, $timestamp = null, $useOffset = true) {
function serendipity_strftime($format, $timestamp = null, $useOffset = true, $useDate = false) {
global $serendipity;
static $is_win_utf = null;
@@ -143,27 +144,31 @@ function serendipity_strftime($format, $timestamp = null, $useOffset = true) {
$is_win_utf = (LANG_CHARSET == 'UTF-8' && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? true : false);
}
switch($serendipity['calendar']) {
default:
case 'gregorian':
if ($timestamp == null) {
$timestamp = serendipity_serverOffsetHour();
} elseif ($useOffset) {
$timestamp = serendipity_serverOffsetHour($timestamp);
}
$out = strftime($format, $timestamp);
break;
case 'persian-utf8':
if ($timestamp == null) {
$timestamp = serendipity_serverOffsetHour();
} elseif ($useOffset) {
$timestamp = serendipity_serverOffsetHour($timestamp);
}
require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
$out = persian_strftime_utf($format, $timestamp);
break;
if ($useDate) {
$out = date($format, $timestamp);
} else {
switch($serendipity['calendar']) {
default:
case 'gregorian':
if ($timestamp == null) {
$timestamp = serendipity_serverOffsetHour();
} elseif ($useOffset) {
$timestamp = serendipity_serverOffsetHour($timestamp);
}
$out = strftime($format, $timestamp);
break;
case 'persian-utf8':
if ($timestamp == null) {
$timestamp = serendipity_serverOffsetHour();
} elseif ($useOffset) {
$timestamp = serendipity_serverOffsetHour($timestamp);
}
require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
$out = persian_strftime_utf($format, $timestamp);
break;
}
}
if ($is_win_utf && (empty($serendipity['calendar']) || $serendipity['calendar'] == 'gregorian')) {
@@ -182,9 +187,10 @@ function serendipity_strftime($format, $timestamp = null, $useOffset = true) {
* @param string Output format for the timestamp
* @param int Timestamp to use for displaying
* @param boolean Indicates, if timezone calculations shall be used.
* @param boolean Whether to use strftime or simply date
* @return string The formatted timestamp
*/
function serendipity_formatTime($format, $time, $useOffset = true) {
function serendipity_formatTime($format, $time, $useOffset = true, $useDate = false) {
static $cache;
if (!isset($cache)) {
$cache = array();
@@ -196,7 +202,8 @@ function serendipity_formatTime($format, $time, $useOffset = true) {
$cache[$format] = str_replace('%e', '%d', $cache[$format]);
}
}
return serendipity_mb('ucfirst', serendipity_strftime($cache[$format], (int)$time, $useOffset));
return serendipity_mb('ucfirst', serendipity_strftime($cache[$format], (int)$time, $useOffset, $useDate));
}
/**

View File

@@ -140,6 +140,12 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
$hidden .= ' <input type="hidden" name="serendipity[preview]" value="false" />';
$hidden .= ' ' . serendipity_setFormToken();
if (is_object($serendipity['smarty']) || (!$_SESSION['no_smarty'] && serendipity_smarty_init())) {
$use_smarty = true;
} else {
$use_smarty = false;
}
if (is_object($serendipity['smarty'])) {
if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) {
$template_vars['allowDateManipulation'] = true;
@@ -167,6 +173,7 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
'body' => 'serendipity[body]',
'extended' => 'serendipity[extended]'
);
$template_vars['entry_template'] = serendipity_getTemplateFile('admin/entries.tpl', 'serendipityPath');
$serendipity['smarty']->register_modifier('emit_htmlarea_code', 'serendipity_emit_htmlarea_code');

View File

@@ -625,17 +625,18 @@ function serendipity_smarty_rss_getguid($params, &$smarty) {
* @param string The strftime() format options on how to format this string
* @param boolean Shall timezone conversions be applied?
* @param boolean Try to detect a valid timestamp?
* @param boolean Use strftime or date?
* @return
*/
function serendipity_smarty_formatTime($timestamp, $format, $useOffset = true, $detectTimestamp = false) {
function serendipity_smarty_formatTime($timestamp, $format, $useOffset = true, $detectTimestamp = false, $useDate = false) {
if ($detectTimestamp !== false && stristr($detectTimestamp, 'date') === false) {
return $timestamp;
}
if (defined($format)) {
return serendipity_formatTime(constant($format), $timestamp, $useOffset);
return serendipity_formatTime(constant($format), $timestamp, $useOffset, $useDate);
} else {
return serendipity_formatTime($format, $timestamp, $useOffset);
return serendipity_formatTime($format, $timestamp, $useOffset, $useDate);
}
}