From 4f7c063dc7d439cb927a5f3263e97cad62699c81 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Sun, 6 May 2007 17:24:25 +0000 Subject: [PATCH] Speed-up again. Need tests 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 | 14 ++++++++------ banana/spool.inc.php | 6 +++--- banana/templates/banana-base.tpl | 4 ++-- banana/templates/banana-message.inc.tpl | 6 +++--- banana/templates/banana-newmessage.inc.tpl | 4 ++-- banana/templates/banana-thread.inc.tpl | 24 ++++++++---------------- banana/text.func.inc.php | 9 +++++++++ 7 files changed, 35 insertions(+), 32 deletions(-) diff --git a/banana/page.inc.php b/banana/page.inc.php index f6dc977..bec3f72 100644 --- a/banana/page.inc.php +++ b/banana/page.inc.php @@ -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_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->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 ($ent) { - $text = banana_utf8entities($text); - } if (!Banana::$debug_smarty) { error_reporting($error_level); } @@ -272,7 +274,7 @@ class BananaPage extends Smarty $popup .= ' (raccourci : ' . $accesskey . ')'; } if (!is_null($popup)) { - $popup = ' title="' . banana_htmlentities($popup) . '"'; + $popup = ' title="' . banana_entities($popup) . '"'; } if (!is_null($class)) { $class = ' class="' . $class . '"'; @@ -280,7 +282,7 @@ class BananaPage extends Smarty if (!is_null($accesskey)) { $accesskey = ' accesskey="' . $accesskey . '"'; } - return '' . $text . ''; } diff --git a/banana/spool.inc.php b/banana/spool.inc.php index 1dfe3a3..ca2c426 100644 --- a/banana/spool.inc.php +++ b/banana/spool.inc.php @@ -453,11 +453,11 @@ class BananaSpool $res .= '
' . $_pfx_node .($hc ? ($_head ? $spfx_f : ($overview->parent_direct ? $spfx_s : $spfx_snd)) : $spfx_n) . '
'; - $subject = $overview->subject; + $popup = $subject = $overview->subject; 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)) { @@ -465,7 +465,7 @@ class BananaSpool } if ($_index != $_ref) { $subject = Banana::$page->makeLink(Array('group' => $this->group, 'artid' => $_id, - 'text' => $subject, 'popup' => $subject)); + 'text' => $subject, 'popup' => $popup)); } $res .= ' ' . $subject . $link; $res .= "\n" . BananaMessage::formatFrom($overview->from) . "\n"; diff --git a/banana/templates/banana-base.tpl b/banana/templates/banana-base.tpl index 48d2387..5d3e8bd 100644 --- a/banana/templates/banana-base.tpl +++ b/banana/templates/banana-base.tpl @@ -29,11 +29,11 @@
{/if} {foreach from=$errors item=error} -

{$error}

+

{$error|smarty:nodefaults}

{/foreach} {if !$killed} {foreach from=$actions item=act} -

{$act.text}

+

{$act.text|smarty:nodefaults}

{/foreach} {if $page eq 'forums'} {include file="banana-boxlist.inc.tpl" grouplist=$groups withstats=true withfeed=$feed_active} diff --git a/banana/templates/banana-message.inc.tpl b/banana/templates/banana-message.inc.tpl index 6fe2479..b55bc3e 100644 --- a/banana/templates/banana-message.inc.tpl +++ b/banana/templates/banana-message.inc.tpl @@ -24,13 +24,13 @@ {/if}
{/if} - {$message->translateHeaderValue('subject')} + {$message->translateHeaderValue('subject')|smarty:nodefaults} {foreach from=$headers name=headers item=hdr} {$message->translateHeaderName($hdr)} - {$message->translateHeaderValue($hdr)} + {$message->translateHeaderValue($hdr)|smarty:nodefaults} {if $smarty.foreach.headers.first} {if $message->hasXFace()} @@ -70,7 +70,7 @@ {/if} - {$body} + {$body|banana_utf8entities|smarty:nodefaults} diff --git a/banana/templates/banana-newmessage.inc.tpl b/banana/templates/banana-newmessage.inc.tpl index 67a6e0f..dccdae2 100644 --- a/banana/templates/banana-newmessage.inc.tpl +++ b/banana/templates/banana-newmessage.inc.tpl @@ -6,11 +6,11 @@ {foreach from=$headers key=header item=values} - {$values.name|htmlentities} + {$values.name} {if $values.fixed} - {$values.fixed|htmlentities} + {$values.fixed} {else} {/if} diff --git a/banana/templates/banana-thread.inc.tpl b/banana/templates/banana-thread.inc.tpl index f8fe90b..7fce61b 100644 --- a/banana/templates/banana-thread.inc.tpl +++ b/banana/templates/banana-thread.inc.tpl @@ -1,8 +1,9 @@ +{capture name=pages} {if $withtitle}
-{if $spool->overview|@count > $msgbypage} +{if $spool->overview|@count gt $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} {$smarty.section.pages.iteration} {else} {link group=$group first=$smarty.section.pages.index text=$smarty.section.pages.iteration} @@ -11,6 +12,9 @@ {/if}
{/if} +{/capture} + +{$smarty.capture.pages|smarty:nodefaults} {if $withtitle} @@ -39,7 +43,7 @@ {/if} {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}
@@ -51,18 +55,6 @@ {if $showboxlist} {include file="banana-boxlist.inc.tpl" grouplist=$groups withstats=true} {/if} -{if $withtitle} -
-{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} - {$smarty.section.pages.iteration} - {else} - {link group=$group first=$smarty.section.pages.index text=$smarty.section.pages.iteration} - {/if} -{/section} -{/if} -
-{/if} +{$smarty.capture.pages|smarty:nodefaults} {* vim:set et sw=2 sts=2 ts=2 enc=utf-8: *} diff --git a/banana/text.func.inc.php b/banana/text.func.inc.php index d1a5c30..16b79ab 100644 --- a/banana/text.func.inc.php +++ b/banana/text.func.inc.php @@ -26,6 +26,15 @@ if (!function_exists('is_utf8')) { } } +function banana_entities($source) +{ + if (is_string($source) || is_numeric($source)) { + return banana_htmlentities($source); + } else { + return $source; + } +} + function banana_utf8entities($source) { // array used to figure what number to decrement from character order value -- 2.1.4