Speed-up again. Need tests
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Sun, 6 May 2007 17:24:25 +0000 (17:24 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:35:41 +0000 (00:35 +0100)
 page.inc.php                        |   14 ++++++++------
 spool.inc.php                       |    6 +++---
 templates/banana-base.tpl           |    4 ++--
 templates/banana-message.inc.tpl    |    6 +++---
 templates/banana-newmessage.inc.tpl |    4 ++--
 templates/banana-thread.inc.tpl     |   24 ++++++++----------------
 text.func.inc.php                   |    9 +++++++++
 7 files changed, 35 insertions(+), 32 deletions(-)

git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@249 9869982d-c50d-0410-be91-f2a2ec7c7c7b

banana/page.inc.php
banana/spool.inc.php
banana/templates/banana-base.tpl
banana/templates/banana-message.inc.tpl
banana/templates/banana-newmessage.inc.tpl
banana/templates/banana-thread.inc.tpl
banana/text.func.inc.php

index f6dc977..bec3f72 100644 (file)
@@ -184,20 +184,22 @@ class BananaPage extends Smarty
         $this->register_function('imglink', array($this, 'makeImgLink'));
         $this->register_function('img',     array($this, 'makeImg'));
         $this->register_modifier('b',       '_b_');
         $this->register_function('imglink', array($this, 'makeImgLink'));
         $this->register_function('img',     array($this, 'makeImg'));
         $this->register_modifier('b',       '_b_');
-        $this->register_modifier('htmlentities', 'banana_htmlentities');
 
         $this->assign('errors',    $this->error);
         $this->assign('page',      $this->page);
         $this->assign('pages',     $this->pages);
         $this->assign('actions',   $this->actions);
 
         $this->assign('errors',    $this->error);
         $this->assign('page',      $this->page);
         $this->assign('pages',     $this->pages);
         $this->assign('actions',   $this->actions);
+        $this->register_modifier('banana_utf8entities', 'banana_utf8entities');
+        $this->register_modifier('banana_entities', 'banana_entities');
+
+        if ($ent) {
+            $this->default_modifiers = Array('@banana_entities');
+        }
 
         if (!Banana::$debug_smarty) {
             $error_level = error_reporting(0);
         }
         $text = $this->fetch($tpl);
 
         if (!Banana::$debug_smarty) {
             $error_level = error_reporting(0);
         }
         $text = $this->fetch($tpl);
-        if ($ent) {
-            $text = banana_utf8entities($text);
-        }
         if (!Banana::$debug_smarty) {
             error_reporting($error_level);
         }
         if (!Banana::$debug_smarty) {
             error_reporting($error_level);
         }
@@ -272,7 +274,7 @@ class BananaPage extends Smarty
             $popup .= ' (raccourci : ' . $accesskey . ')';
         }
         if (!is_null($popup)) {
             $popup .= ' (raccourci : ' . $accesskey . ')';
         }
         if (!is_null($popup)) {
-            $popup = ' title="' . banana_htmlentities($popup) . '"';
+            $popup = ' title="' . banana_entities($popup) . '"';
         }
         if (!is_null($class)) {
             $class = ' class="' . $class . '"';
         }
         if (!is_null($class)) {
             $class = ' class="' . $class . '"';
@@ -280,7 +282,7 @@ class BananaPage extends Smarty
         if (!is_null($accesskey)) {
             $accesskey = ' accesskey="' . $accesskey . '"';
         }
         if (!is_null($accesskey)) {
             $accesskey = ' accesskey="' . $accesskey . '"';
         }
-        return '<a href="' . banana_htmlentities($link) . '"'
+        return '<a href="' . banana_entities($link) . '"'
               . $popup . $class . $accesskey
               . '>' . $text . '</a>';
     }
               . $popup . $class . $accesskey
               . '>' . $text . '</a>';
     }
index 1dfe3a3..ca2c426 100644 (file)
@@ -453,11 +453,11 @@ class BananaSpool
             $res .= '<td class="subj' . ($_index == $_ref ? ' cur' : '') . '"><div class="tree">'
                 . $_pfx_node .($hc ? ($_head ? $spfx_f : ($overview->parent_direct ? $spfx_s : $spfx_snd)) : $spfx_n)
                 . '</div>';
             $res .= '<td class="subj' . ($_index == $_ref ? ' cur' : '') . '"><div class="tree">'
                 . $_pfx_node .($hc ? ($_head ? $spfx_f : ($overview->parent_direct ? $spfx_s : $spfx_snd)) : $spfx_n)
                 . '</div>';
-            $subject = $overview->subject;
+            $popup = $subject = $overview->subject;
             if (function_exists('hook_formatDisplayHeader')) {
                 list($subject, $link) = hook_formatDisplayHeader('subject', $subject, true);
             } else {
             if (function_exists('hook_formatDisplayHeader')) {
                 list($subject, $link) = hook_formatDisplayHeader('subject', $subject, true);
             } else {
-                $subject = banana_catchFormats(banana_htmlentities(stripslashes($subject)));
+                $subject = banana_catchFormats(banana_entities(stripslashes($subject)));
                 $link = null;
             }
             if (empty($subject)) {
                 $link = null;
             }
             if (empty($subject)) {
@@ -465,7 +465,7 @@ class BananaSpool
             }
             if ($_index != $_ref) {
                 $subject = Banana::$page->makeLink(Array('group' => $this->group, 'artid' => $_id,
             }
             if ($_index != $_ref) {
                 $subject = Banana::$page->makeLink(Array('group' => $this->group, 'artid' => $_id,
-                                                    'text'  => $subject, 'popup' => $subject));
+                                                    'text'  => $subject, 'popup' => $popup));
             }
             $res .= '&nbsp;' . $subject . $link;
             $res .= "</td>\n<td class='from'>" . BananaMessage::formatFrom($overview->from) . "</td>\n</tr>";
             }
             $res .= '&nbsp;' . $subject . $link;
             $res .= "</td>\n<td class='from'>" . BananaMessage::formatFrom($overview->from) . "</td>\n</tr>";
index 48d2387..5d3e8bd 100644 (file)
 <div class="banana">
 {/if}
       {foreach from=$errors item=error}
 <div class="banana">
 {/if}
       {foreach from=$errors item=error}
-      <p class="error">{$error}</p>
+      <p class="error">{$error|smarty:nodefaults}</p>
       {/foreach}
       {if !$killed}
       {foreach from=$actions item=act}
       {/foreach}
       {if !$killed}
       {foreach from=$actions item=act}
-      <p class="center" style="padding: 0; margin: 0 0 1em 0">{$act.text}</p>
+      <p class="center" style="padding: 0; margin: 0 0 1em 0">{$act.text|smarty:nodefaults}</p>
       {/foreach}
       {if $page eq 'forums'}
         {include file="banana-boxlist.inc.tpl" grouplist=$groups withstats=true withfeed=$feed_active}
       {/foreach}
       {if $page eq 'forums'}
         {include file="banana-boxlist.inc.tpl" grouplist=$groups withstats=true withfeed=$feed_active}
index 6fe2479..b55bc3e 100644 (file)
         {/if}
       </div>
       {/if}
         {/if}
       </div>
       {/if}
-      {$message->translateHeaderValue('subject')}
+      {$message->translateHeaderValue('subject')|smarty:nodefaults}
     </th>
   </tr>
   {foreach from=$headers name=headers item=hdr}
   <tr class="pair">
     <td class="hdr">{$message->translateHeaderName($hdr)}</td>
     </th>
   </tr>
   {foreach from=$headers name=headers item=hdr}
   <tr class="pair">
     <td class="hdr">{$message->translateHeaderName($hdr)}</td>
-    <td>{$message->translateHeaderValue($hdr)}</td>
+    <td>{$message->translateHeaderValue($hdr)|smarty:nodefaults}</td>
     {if $smarty.foreach.headers.first}
     <td class="xface" rowspan="{$headers|@count}">
       {if $message->hasXFace()}
     {if $smarty.foreach.headers.first}
     <td class="xface" rowspan="{$headers|@count}">
       {if $message->hasXFace()}
@@ -70,7 +70,7 @@
   {/if}
   <tr>
     <td colspan="3" class="body">
   {/if}
   <tr>
     <td colspan="3" class="body">
-      {$body}
+      {$body|banana_utf8entities|smarty:nodefaults}
     </td>
   </tr>
 </table>
     </td>
   </tr>
 </table>
index 67a6e0f..dccdae2 100644 (file)
@@ -6,11 +6,11 @@
     {foreach from=$headers key=header item=values}
     <tr class="pair">
       <td>
     {foreach from=$headers key=header item=values}
     <tr class="pair">
       <td>
-        {$values.name|htmlentities}
+        {$values.name}
       </td>
       <td>
         {if $values.fixed}
       </td>
       <td>
         {if $values.fixed}
-        {$values.fixed|htmlentities}
+        {$values.fixed}
         {else}
         <input type="text" name="{$header}" value="{$values.user|default:$smarty.request.$header}" size="50" />
         {/if}
         {else}
         <input type="text" name="{$header}" value="{$values.user|default:$smarty.request.$header}" size="50" />
         {/if}
index f8fe90b..7fce61b 100644 (file)
@@ -1,8 +1,9 @@
+{capture name=pages}
 {if $withtitle}
 <div class="pages">
 {if $withtitle}
 <div class="pages">
-{if $spool->overview|@count > $msgbypage}
+{if $spool->overview|@count gt $msgbypage}
 {section name=pages loop=$spool->overview step=$msgbypage}
 {section name=pages loop=$spool->overview step=$msgbypage}
-  {if $first >= $smarty.section.pages.index && $first < $smarty.section.pages.index_next}
+  {if $first ge $smarty.section.pages.index && $first lt $smarty.section.pages.index_next}
     <strong>{$smarty.section.pages.iteration}</strong>
   {else}
     {link group=$group first=$smarty.section.pages.index text=$smarty.section.pages.iteration}
     <strong>{$smarty.section.pages.iteration}</strong>
   {else}
     {link group=$group first=$smarty.section.pages.index text=$smarty.section.pages.iteration}
@@ -11,6 +12,9 @@
 {/if}
 </div>
 {/if}
 {/if}
 </div>
 {/if}
+{/capture}
+
+{$smarty.capture.pages|smarty:nodefaults}
 <table class="bicol thread">
   <tr>
     {if $withtitle}
 <table class="bicol thread">
   <tr>
     {if $withtitle}
@@ -39,7 +43,7 @@
     {/if}
   </tr>
   {if $spool->overview|@count}
     {/if}
   </tr>
   {if $spool->overview|@count}
-  {if $artid}{$spool->toHtml($artid, true)}{else}{$spool->toHtml($first)}{/if}
+  {if $artid}{$spool->toHtml($artid, true)|smarty:nodefaults}{else}{$spool->toHtml($first)|smarty:nodefaults}{/if}
   {else}
   <tr>
     <td colspan="3">
   {else}
   <tr>
     <td colspan="3">
 {if $showboxlist}
 {include file="banana-boxlist.inc.tpl" grouplist=$groups withstats=true}
 {/if}
 {if $showboxlist}
 {include file="banana-boxlist.inc.tpl" grouplist=$groups withstats=true}
 {/if}
-{if $withtitle}
-<div class="pages">
-{if $spool->overview|@count > $msgbypage}
-{section name=pages loop=$spool->overview step=$msgbypage}
-  {if $first >= $smarty.section.pages.index && $first < $smarty.section.pages.index_next}
-    <strong>{$smarty.section.pages.iteration}</strong>
-  {else}
-    {link group=$group first=$smarty.section.pages.index text=$smarty.section.pages.iteration}
-  {/if}
-{/section}
-{/if}
-</div>
-{/if}
+{$smarty.capture.pages|smarty:nodefaults}
 
 {* vim:set et sw=2 sts=2 ts=2 enc=utf-8: *}
 
 {* vim:set et sw=2 sts=2 ts=2 enc=utf-8: *}
index d1a5c30..16b79ab 100644 (file)
@@ -26,6 +26,15 @@ if (!function_exists('is_utf8')) {
     }\r
 }\r
 \r
     }\r
 }\r
 \r
+function banana_entities($source)\r
+{\r
+    if (is_string($source) || is_numeric($source)) {\r
+        return banana_htmlentities($source);\r
+    } else {\r
+        return $source;\r
+    }\r
+}\r
+\r
 function banana_utf8entities($source)\r
 {\r
    // array used to figure what number to decrement from character order value \r
 function banana_utf8entities($source)\r
 {\r
    // array used to figure what number to decrement from character order value \r