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 21ff681015
commit 22c02491e6
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);
}
}

View File

@ -15,8 +15,8 @@ function toggle_extended(setCookie) {
button.src = plus_img;
if (setCookie == true) {
document.cookie = 'serendipity[toggle_extended]=;';
}}
}}
}
}
}
function showItem(id) {

View File

@ -6,7 +6,7 @@
{*** POSSIBLE ERROR MESSAGES END ***}
{*** MAIN ENTRY FORM START ***}
<form {$entry_vars.entry.entry_form action="{$entry_vars.targetURL}" method="post" id="serendipityEntry" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px">
<form {$entry_vars.entry.entry_form} action="{$entry_vars.targetURL}" method="post" id="serendipityEntry" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px">
{$entry_vars.hidden}
<table class="serendipityEntryEdit" border="0" width="100%">
@ -23,7 +23,7 @@
<td align="right">
<select name="serendipity[isdraft]">
{if $entry_vars.serendipityRightPublish}
<option value="false" {if $entry_vars.draft_mode == 'publish'}selected="selected"{/if}>{CONST.PUBLISH}</option>
<option value="false" {if $entry_vars.draft_mode == 'publish'}selected="selected"{/if}>{$CONST.PUBLISH}</option>
{/if}
<option value="true" {if $entry_vars.draft_mode == 'draft'}selected="selected"{/if}>{$CONST.DRAFT}</option>
</select>
@ -43,8 +43,8 @@
</td>
<td>
<input type="hidden" name="serendipity[chk_timestamp]" value="{$entry_vars.timestamp}" />
<input type="text" name="serendipity[new_timestamp]" id="serendipityNewTimestamp" value="{$entry_vars.timestamp|@formatTime:DATE_FORMAT_2}" />
<a href="#" onclick="document.getElementById('serendipityNewTimestamp').value = '{$entry_vars.reset_timestamp|@formatTime:DATE_FORMAT_2}'; return false;" title="{$CONST.RESET_DATE_DESC}"><img src="{serendipity_getFile file='admin/img/clock.png'}" border="0" style="vertical-align: text-top;" alt="{$CONST.RESET_DATE}" /></a>
<input type="text" name="serendipity[new_timestamp]" id="serendipityNewTimestamp" value="{$entry_vars.timestamp|@formatTime:DATE_FORMAT_2:true:false:true}" />
<a href="#" onclick="document.getElementById('serendipityNewTimestamp').value = '{$entry_vars.reset_timestamp|@formatTime:DATE_FORMAT_2:true:false:true}'; return false;" title="{$CONST.RESET_DATE_DESC}"><img src="{serendipity_getFile file='admin/img/clock.png'}" border="0" style="vertical-align: text-top;" alt="{$CONST.RESET_DATE}" /></a>
</td>
<td align="right">
{else}
@ -67,15 +67,17 @@
var selector_store = new Array();
var selector_restore = new Array();
function checkSave() {
function checkSave() {ldelim}
{serendipity_hookPlugin hook='backend_entry_checkSave' hookAll='true'}
return true;
}
{rdelim}
selector_toggle['categoryselector'] = '{$entry_vars.cat_state}';
addLoadEvent(showItem);
</script>
<script type="text/javascript" language="JavaScript" src="{serendipity_getFile file='admin/category_selector.js'}">
<script type="text/javascript" language="JavaScript" src="{serendipity_getFile file='admin/category_selector.js'}"></script>
<script type="text/javascript" language="JavaScript">
addLoadEvent(showItem);
</script>
</td>
</tr>
{*** ENTRY DATE,CATEGORY END ***}
@ -128,7 +130,7 @@
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="left" width="70%">
<input id="checkbox_allow_comments" type="checkbox" name="serendipity[allow_comments]" value="true" {if $entry_vars.allow_comments}checked="checked"{/if} /><label for="checkbox_allow_comments">{$CONST.COMMENTS_ENABLE; ?></label><br />
<input id="checkbox_allow_comments" type="checkbox" name="serendipity[allow_comments]" value="true" {if $entry_vars.allow_comments}checked="checked"{/if} /><label for="checkbox_allow_comments">{$CONST.COMMENTS_ENABLE}</label><br />
<input id="checkbox_moderate_comments" type="checkbox" name="serendipity[moderate_comments]" value="true" {if $entry_vars.moderate_comments}checked="checked"{/if} /><label for="checkbox_moderate_comments">{$CONST.COMMENTS_MODERATE}</label>
</td>
<td align="right" rowspan="2" valign="middle" width="30%">
@ -218,7 +220,7 @@
{foreach from=$entry_vars.wysiwyg_blocks item="wysiwyg_block_item" key="wysiwyg_block_jsname"}
{$wysiwyg_block_item|emit_htmlarea_code:$wysiwyg_block_jsname}
{/foreach}
{serendipity_refhookPlugin hook="backend_wysiwyg_finish" data=$entry_vars.wysiwyg_blocks}
{$entry_vars.wysiwyg_blocks|@serendipity_refhookPlugin:'backend_wysiwyg_finish'}
{/if}
{*** SPAWN WYSIWYG EDITORS END ***}