]> git.mjollnir.org Git - s9y.git/commitdiff
Fix bugs in the new backend templates
authorgarvinhicking <garvinhicking>
Mon, 11 Jun 2007 14:32:32 +0000 (14:32 +0000)
committergarvinhicking <garvinhicking>
Mon, 11 Jun 2007 14:32:32 +0000 (14:32 +0000)
include/functions.inc.php
include/functions_entries_admin.inc.php
include/functions_smarty.inc.php
templates/default/admin/category_selector.js
templates/default/admin/entries.tpl

index 7829cb6495f4711e1b72930463146ec2db8da968..410a3a326e337703a6852b74fbce1a232507cd12 100644 (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));
 }
 
 /**
index 4fbc12f4f9fec70f6cfa2c2478e4ce4fbfed1cdd..9d61d46d4f19e6b339c5f6d67e30d4585e680c90 100644 (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');
index fcd60e4e91ba17519e7e97d709a54342657076ec..a625b165283141bb3d39952623e554678f32ffb5 100644 (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);
     }
 }
 
index 447460ebe1ec41a4ee2da731dd879aaa26d628b6..96e39d0ca96f1e13cef3dbb2919d3d12375e6729 100644 (file)
@@ -15,8 +15,8 @@ function toggle_extended(setCookie) {
         button.src = plus_img;
         if (setCookie == true) {
             document.cookie = 'serendipity[toggle_extended]=;';
-        }}
-    }}
+        }
+    }
 }
 
 function showItem(id) {
index 23a2ecd66ba86451d550b02ed6d9e534c7544a07..2d9f688ff0567bb2688483b8ce3ab4fbf4d62a5e 100644 (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}
             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 ***}
             <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%">
     {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 ***}