smarty syntax change

This commit is contained in:
Garvin Hicking 2016-09-23 10:20:07 +02:00
parent 3f60fa9b21
commit 5ab53029ea
14 changed files with 84 additions and 63 deletions

View file

@ -1,5 +1,23 @@
Version 1.4: 1.6:
* Not stripping comment html tags in code, so the template can decide, how to display comments ----
* Stripping tags before truncating comment in template, else tags will be truncated.
* Set plugin consistencies
* Use load language API - extends required Serendipity version to v.1.6
* Removed old Smarty2 security settings - extends required Serendipity version to v.1.7
* Use native API method parseTemplate()
* Convert plugin template for Smarty3 usage
1.5:
----
* Fixed a remaining old htmlspecialchars usage
1.4:
----
* Not stripping comment html tags in code, so the template can decide, how to display comments
* Stripping tags before truncating comment in template, else tags will be truncated.
latest: Smarty3 forward compatibility latest: Smarty3 forward compatibility

View file

@ -1,7 +1,7 @@
<?php # <?php
/** /**
* @version * @version
* @author Ivan Cenov <jwalker@hotmail.bg> * @author Ivan Cenov <jwalker@hotmail.bg>
* EN-Revision: 1.2 * EN-Revision: 1.2
*/ */
@ -9,3 +9,4 @@
@define('COMMENTSEARCH_TITLE', 'Търси в коментарите при бързо търсене'); @define('COMMENTSEARCH_TITLE', 'Търси в коментарите при бързо търсене');
@define('COMMENTSEARCH_DESC', 'Ако тази приставка е инсталирана, бързото търсене ще се изпълнява и в коментарите'); @define('COMMENTSEARCH_DESC', 'Ако тази приставка е инсталирана, бързото търсене ще се изпълнява и в коментарите');
@define('COMMENT_SEARCHRESULTS', 'Резултати от търсенето в коментарите'); @define('COMMENT_SEARCHRESULTS', 'Резултати от търсенето в коментарите');

View file

@ -7,4 +7,5 @@
@define('COMMENTSEARCH_TITLE', 'Hledání v komentářích'); @define('COMMENTSEARCH_TITLE', 'Hledání v komentářích');
@define('COMMENTSEARCH_DESC', 'Pokud je tento plugin nainstalovaný, rychlé vyhledávání bude prohledávat také komentáře'); @define('COMMENTSEARCH_DESC', 'Pokud je tento plugin nainstalovaný, rychlé vyhledávání bude prohledávat také komentáře');
@define('COMMENT_SEARCHRESULTS', 'Výsledky hledání v komentářích'); @define('COMMENT_SEARCHRESULTS', 'Výsledky hledání v komentářích');

View file

@ -7,4 +7,5 @@
@define('COMMENTSEARCH_TITLE', 'Hledání v komentářích'); @define('COMMENTSEARCH_TITLE', 'Hledání v komentářích');
@define('COMMENTSEARCH_DESC', 'Pokud je tento plugin nainstalovaný, rychlé vyhledávání bude prohledávat také komentáře'); @define('COMMENTSEARCH_DESC', 'Pokud je tento plugin nainstalovaný, rychlé vyhledávání bude prohledávat také komentáře');
@define('COMMENT_SEARCHRESULTS', 'Výsledky hledání v komentářích'); @define('COMMENT_SEARCHRESULTS', 'Výsledky hledání v komentářích');

View file

@ -1,4 +1,4 @@
<?php # lang_de.inc.php 1.0 2009-08-20 10:08:48 VladaAjgl $ <?php
/** /**
* @version 1.0 * @version 1.0
@ -8,4 +8,5 @@
@define('COMMENTSEARCH_TITLE', 'Durchsuche Kommentare mit der Schnellsuche'); @define('COMMENTSEARCH_TITLE', 'Durchsuche Kommentare mit der Schnellsuche');
@define('COMMENTSEARCH_DESC', 'Wenn dieses Plugin installiert ist, durchsucht die Schnellsuche Ihres Blogs auch die Kommentare.'); @define('COMMENTSEARCH_DESC', 'Wenn dieses Plugin installiert ist, durchsucht die Schnellsuche Ihres Blogs auch die Kommentare.');
@define('COMMENT_SEARCHRESULTS', 'Such-Ergebnisse in Kommentaren'); @define('COMMENT_SEARCHRESULTS', 'Such-Ergebnisse in Kommentaren');

View file

@ -1,12 +1,12 @@
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta http-equiv="content-type" content="text/html; charset=windows-1250">
<title>Dokumentace: Hledání v komentářích</title> <title>Dokumentace: Hledání v komentářích</title>
</head> </head>
<body> <body>
<h1>Dokumentace k pluginu 'Hledání v komentáøích'<br /> <h1>Dokumentace k pluginu 'Hledání v komentáøích'<br />
<small>(serendipity_event_commentsearch)</small></h1> <small>(serendipity_event_commentsearch)</small></h1>
<p>Dokumentaci k tomuto pluginu přeložil do češtiny Vladimír Ajgl (vlada [zavinac] ajgl [tecka] cz) a naposledy zkontroloval dne 5.5.2013. Od té doby mohl být plugin pozměněn nebo mohly být rozšířené jeho funkce. Zkontrolujte pro jistotu i <a href="ChangeLog">aktuální anglický ChangeLog</a>. <p>Dokumentaci k tomuto pluginu přeložil do češtiny Vladimír Ajgl (vlada [zavinac] ajgl [tecka] cz) a naposledy zkontroloval dne 5.5.2013. Od té doby mohl být plugin pozměněn nebo mohly být rozšířené jeho funkce. Zkontrolujte pro jistotu i <a href="ChangeLog">aktuální anglický ChangeLog</a>.
</p> </p>
<h2>Popis pluginu</h2> <h2>Popis pluginu</h2>
@ -24,6 +24,6 @@
<ul> <ul>
<li>dopøedná kompatibilita se smarty 3</li> <li>dopøedná kompatibilita se smarty 3</li>
</ul> </ul>
</ul> </ul>
</body> </body>
</html> </html>

View file

@ -1,12 +1,12 @@
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2"> <meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
<title>Dokumentace: Hledání v komentářích</title> <title>Dokumentace: Hledání v komentářích</title>
</head> </head>
<body> <body>
<h1>Dokumentace k pluginu 'Hledání v komentáøích'<br /> <h1>Dokumentace k pluginu 'Hledání v komentáøích'<br />
<small>(serendipity_event_commentsearch)</small></h1> <small>(serendipity_event_commentsearch)</small></h1>
<p>Dokumentaci k tomuto pluginu přeložil do češtiny Vladimír Ajgl (vlada [zavinac] ajgl [tecka] cz) a naposledy zkontroloval dne 5.5.2013. Od té doby mohl být plugin pozměněn nebo mohly být rozšířené jeho funkce. Zkontrolujte pro jistotu i <a href="ChangeLog">aktuální anglický ChangeLog</a>. <p>Dokumentaci k tomuto pluginu přeložil do češtiny Vladimír Ajgl (vlada [zavinac] ajgl [tecka] cz) a naposledy zkontroloval dne 5.5.2013. Od té doby mohl být plugin pozměněn nebo mohly být rozšířené jeho funkce. Zkontrolujte pro jistotu i <a href="ChangeLog">aktuální anglický ChangeLog</a>.
</p> </p>
<h2>Popis pluginu</h2> <h2>Popis pluginu</h2>
@ -24,6 +24,6 @@
<ul> <ul>
<li>dopøedná kompatibilita se smarty 3</li> <li>dopøedná kompatibilita se smarty 3</li>
</ul> </ul>
</ul> </ul>
</body> </body>
</html> </html>

View file

@ -1,7 +1,7 @@
<?php # <?php
/** /**
* @version * @version
* @author Ivan Cenov <jwalker@hotmail.bg> * @author Ivan Cenov <jwalker@hotmail.bg>
* EN-Revision: 1.2 * EN-Revision: 1.2
*/ */
@ -9,3 +9,4 @@
@define('COMMENTSEARCH_TITLE', 'Òúðñè â êîìåíòàðèòå ïðè áúðçî òúðñåíå'); @define('COMMENTSEARCH_TITLE', 'Òúðñè â êîìåíòàðèòå ïðè áúðçî òúðñåíå');
@define('COMMENTSEARCH_DESC', 'Àêî òàçè ïðèñòàâêà å èíñòàëèðàíà, áúðçîòî òúðñåíå ùå ñå èçïúëíÿâà è â êîìåíòàðèòå'); @define('COMMENTSEARCH_DESC', 'Àêî òàçè ïðèñòàâêà å èíñòàëèðàíà, áúðçîòî òúðñåíå ùå ñå èçïúëíÿâà è â êîìåíòàðèòå');
@define('COMMENT_SEARCHRESULTS', 'Ðåçóëòàòè îò òúðñåíåòî â êîìåíòàðèòå'); @define('COMMENT_SEARCHRESULTS', 'Ðåçóëòàòè îò òúðñåíåòî â êîìåíòàðèòå');

View file

@ -7,4 +7,5 @@
@define('COMMENTSEARCH_TITLE', 'Hledání v komentáøích'); @define('COMMENTSEARCH_TITLE', 'Hledání v komentáøích');
@define('COMMENTSEARCH_DESC', 'Pokud je tento plugin nainstalovaný, rychlé vyhledávání bude prohledávat také komentáøe'); @define('COMMENTSEARCH_DESC', 'Pokud je tento plugin nainstalovaný, rychlé vyhledávání bude prohledávat také komentáøe');
@define('COMMENT_SEARCHRESULTS', 'Výsledky hledání v komentáøích'); @define('COMMENT_SEARCHRESULTS', 'Výsledky hledání v komentáøích');

View file

@ -7,4 +7,5 @@
@define('COMMENTSEARCH_TITLE', 'Hledání v komentáøích'); @define('COMMENTSEARCH_TITLE', 'Hledání v komentáøích');
@define('COMMENTSEARCH_DESC', 'Pokud je tento plugin nainstalovaný, rychlé vyhledávání bude prohledávat také komentáøe'); @define('COMMENTSEARCH_DESC', 'Pokud je tento plugin nainstalovaný, rychlé vyhledávání bude prohledávat také komentáøe');
@define('COMMENT_SEARCHRESULTS', 'Výsledky hledání v komentáøích'); @define('COMMENT_SEARCHRESULTS', 'Výsledky hledání v komentáøích');

View file

@ -1,4 +1,4 @@
<?php # lang_de.inc.php 1.0 2009-08-20 10:08:48 VladaAjgl $ <?php
/** /**
* @version 1.0 * @version 1.0
@ -8,4 +8,5 @@
@define('COMMENTSEARCH_TITLE', 'Durchsuche Kommentare mit der Schnellsuche'); @define('COMMENTSEARCH_TITLE', 'Durchsuche Kommentare mit der Schnellsuche');
@define('COMMENTSEARCH_DESC', 'Wenn dieses Plugin installiert ist, durchsucht die Schnellsuche Ihres Blogs auch die Kommentare.'); @define('COMMENTSEARCH_DESC', 'Wenn dieses Plugin installiert ist, durchsucht die Schnellsuche Ihres Blogs auch die Kommentare.');
@define('COMMENT_SEARCHRESULTS', 'Such-Ergebnisse in Kommentaren'); @define('COMMENT_SEARCHRESULTS', 'Such-Ergebnisse in Kommentaren');

View file

@ -1,7 +1,7 @@
<?php # <?php
/** /**
* @version * @version
* @author Translator Name <yourmail@example.com> * @author Translator Name <yourmail@example.com>
* EN-Revision: Revision of lang_en.inc.php * EN-Revision: Revision of lang_en.inc.php
*/ */
@ -9,3 +9,4 @@
@define('COMMENTSEARCH_TITLE', 'Searches comments on quicksearch'); @define('COMMENTSEARCH_TITLE', 'Searches comments on quicksearch');
@define('COMMENTSEARCH_DESC', 'If this plugin is installed, the quicksearch on your blog will also search through comments on your blog'); @define('COMMENTSEARCH_DESC', 'If this plugin is installed, the quicksearch on your blog will also search through comments on your blog');
@define('COMMENT_SEARCHRESULTS', 'Search results for comments'); @define('COMMENT_SEARCHRESULTS', 'Search results for comments');

View file

@ -2,15 +2,16 @@
<p class="comment_result_header">{$CONST.COMMENT_SEARCHRESULTS|sprintf:$comment_searchresults}</p> <p class="comment_result_header">{$CONST.COMMENT_SEARCHRESULTS|sprintf:$comment_searchresults}</p>
<ul class="comment_result plainList"> <ul class="comment_result plainList">
{foreach from=$comment_results item="result"} {foreach $comment_results AS $result}
<li>{$result.ctimestamp|@formatTime:DATE_FORMAT_ENTRY}: <li>{$result.ctimestamp|formatTime:DATE_FORMAT_ENTRY}:
{if $result.type == 'TRACKBACK'} {if $result.type == 'TRACKBACK'}
<a href="{$result.url|@escape}">{$result.author|@escape}</a> - <a href="{$result.permalink|@escape}">{$result.title|@escape}</a> <a href="{$result.url|escape}">{$result.author|escape}</a> - <a href="{$result.permalink|escape}">{$result.title|escape}</a>
{else} {else}
{$result.author|@escape} - <a href="{$result.permalink|@escape}">{$result.title|@escape}</a> {$result.author|escape} - <a href="{$result.permalink|escape}">{$result.title|escape}</a>
{/if} {/if}
<br /> <br />
{$result.comment|@truncate:200:" ..."}</li> {$result.comment|truncate:200:" ..."}</li>
{/foreach} {/foreach}
</ul> </ul>
</div> </div>
<!-- commentsearch searchresults origin template file -->

View file

@ -1,21 +1,15 @@
<?php # <?php
if (IN_serendipity !== true) { if (IN_serendipity !== true) {
die ("Don't hack!"); die ("Don't hack!");
} }
// Probe for a language include with constants. Still include defines later on, if some constants were missing @serendipity_plugin_api::load_language(dirname(__FILE__));
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}
include dirname(__FILE__) . '/lang_en.inc.php';
class serendipity_event_commentsearch extends serendipity_event class serendipity_event_commentsearch extends serendipity_event
{ {
var $title = COMMENTSEARCH_TITLE; var $title = COMMENTSEARCH_TITLE;
function introspect(&$propbag) function introspect(&$propbag)
{ {
global $serendipity; global $serendipity;
@ -23,22 +17,23 @@ class serendipity_event_commentsearch extends serendipity_event
$propbag->add('name', COMMENTSEARCH_TITLE); $propbag->add('name', COMMENTSEARCH_TITLE);
$propbag->add('description', COMMENTSEARCH_DESC); $propbag->add('description', COMMENTSEARCH_DESC);
$propbag->add('event_hooks', array( $propbag->add('event_hooks', array(
'entries_footer' => true, 'entries_footer' => true,
'frontend_fetchentries' => true 'frontend_fetchentries' => true
)); ));
$propbag->add('author', 'Garvin Hicking'); $propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '1.5'); $propbag->add('version', '1.6');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.8', 'serendipity' => '1.7',
'smarty' => '2.6.7', 'smarty' => '3.1.0',
'php' => '4.1.0' 'php' => '5.1.0'
)); ));
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('groups', array('FRONTEND_FEATURES')); $propbag->add('groups', array('FRONTEND_FEATURES'));
} }
function setupDB() { function setupDB()
{
global $serendipity; global $serendipity;
$built = $this->get_config('db_built', null); $built = $this->get_config('db_built', null);
@ -49,7 +44,8 @@ class serendipity_event_commentsearch extends serendipity_event
} }
} }
function showSearch() { function showSearch()
{
global $serendipity; global $serendipity;
$this->setupDB(); $this->setupDB();
@ -59,12 +55,12 @@ class serendipity_event_commentsearch extends serendipity_event
$group = ''; $group = '';
$distinct = 'DISTINCT'; $distinct = 'DISTINCT';
$find_part = "(c.title ILIKE '%$term%' OR c.body ILIKE '%$term%')"; $find_part = "(c.title ILIKE '%$term%' OR c.body ILIKE '%$term%')";
} elseif ($serendipity['dbType'] == 'sqlite') { } elseif (stristr($serendipity['dbType'], 'sqlite') !== FALSE) {
$group = 'GROUP BY id'; $group = 'GROUP BY id';
$distinct = ''; $distinct = '';
$term = serendipity_mb('strtolower', $term); $term = serendipity_mb('strtolower', $term);
$find_part = "(lower(c.title) LIKE '%$term%' OR lower(c.body) LIKE '%$term%')"; $find_part = "(lower(c.title) LIKE '%$term%' OR lower(c.body) LIKE '%$term%')";
} else { } else { // MYSQL
$group = 'GROUP BY id'; $group = 'GROUP BY id';
$distinct = ''; $distinct = '';
$term = str_replace('&quot;', '"', $term); $term = str_replace('&quot;', '"', $term);
@ -95,11 +91,11 @@ class serendipity_event_commentsearch extends serendipity_event
$myAddData = array("from" => "serendipity_plugin_commentsearch:generate_content"); $myAddData = array("from" => "serendipity_plugin_commentsearch:generate_content");
foreach($results AS $idx => $result) { foreach($results AS $idx => $result) {
$results[$idx]['permalink'] = serendipity_archiveURL($result['id'], $result['title'], 'baseURL', true, $result); $results[$idx]['permalink'] = serendipity_archiveURL($result['id'], $result['title'], 'baseURL', true, $result);
$results[$idx]['comment'] = $result['body'];//(function_exists('serendipity_specialchars') ? serendipity_specialchars(strip_tags($result['body'])) : htmlspecialchars(strip_tags($result['body']), ENT_COMPAT, LANG_CHARSET)); $results[$idx]['comment'] = $result['body']; // escape it in the template (function_exists('serendipity_specialchars') ? serendipity_specialchars(strip_tags($result['body'])) : htmlspecialchars(strip_tags($result['body']), ENT_COMPAT, LANG_CHARSET));
serendipity_plugin_api::hook_event('frontend_display', $results[$idx], $myAddData); serendipity_plugin_api::hook_event('frontend_display', $results[$idx], $myAddData);
// let the template decide, if we want to have tags or not // let the template decide, if we want to have tags or not
$results[$idx]['commenthtml'] = $results[$idx]['comment']; $results[$idx]['commenthtml'] = $results[$idx]['comment'];
$results[$idx]['comment'] = strip_tags($results[$idx]['comment']); $results[$idx]['comment'] = strip_tags($results[$idx]['comment']);
} }
$serendipity['smarty']->assign( $serendipity['smarty']->assign(
@ -110,18 +106,12 @@ class serendipity_event_commentsearch extends serendipity_event
); );
$filename = 'plugin_commentsearch_searchresults.tpl'; $filename = 'plugin_commentsearch_searchresults.tpl';
$tfile = serendipity_getTemplateFile($filename, 'serendipityPath'); $content = $this->parseTemplate($filename);
if (!$tfile) {
$tfile = dirname(__FILE__) . '/' . $filename;
}
$inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
$serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
$content = $serendipity['smarty']->fetch('file:'. $tfile);
$serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
echo $content; echo $content;
} }
function event_hook($event, &$bag, &$eventData, $addData = null) { function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity; global $serendipity;
$hooks = &$bag->get('event_hooks'); $hooks = &$bag->get('event_hooks');
@ -147,5 +137,8 @@ class serendipity_event_commentsearch extends serendipity_event
} }
return false; return false;
} }
} }
/* vim: set sts=4 ts=4 expandtab : */ /* vim: set sts=4 ts=4 expandtab : */
?>