NAVIGATION
translate
A small enlhancement to turn new guestbook entries invisible until they have been edited by admin (released) in BE.
Explanation:
Blocked Messages:
Unlocked Entries:
- as there are:
Docu: –
Forum: –
Autor: K.Heermann (flip-flop) http://planmatrix.de
CMS Version: >= 1.4x
Version: V1.0 (08.02.2010)
Bedingung: → /config/phpwcms/conf.inc.php
Tag (in template):
<!--GUESTBOOK_ENTRY_START//-->
<!--##Begin-{DBID}##//--> … Entry … <!--##End-{DBID}##//-->
<!--GUESTBOOK_ENTRY_END//-->
In
<!--##:Alternative AlternativText:##//-->
the text is entered which will be shown in case the entry is locked, e.g. <!--##:<h2>{TIMESTAMP:d.m.Y H:i}</h2> :##//-->
.
<!--##:AlternativeText AlternativeText:##//--> has to be set anywhere between <!--##Begin-{DBID}##//--> and <!--##End-{DBID}##//--> .
(If the alternative text is not set the output will stay empty).
Example:
<!--GUESTBOOK_ENTRY_START//--> <div class="gbListEntry" id="entry-{DBID}"> <!--##Begin-{DBID}##//--> <!--##:<h1 style="padding-top:10px">Entry on {TIMESTAMP:m/d/Y H:i} by {NAME}</h1>:##//--> <h1><span class="entryID">entry #{ID} by </span>[URL]<a href="{URL}" target="_blank">{NAME}</a>[/URL][URL_ELSE]{NAME}[/URL_ELSE]</h1> <h2>{TIMESTAMP:m/d/Y H:i}[EMAIL] — <a href="mailto:{EMAIL}">email</a>[/EMAIL]</h2> [IMAGE]<div class="gbImage">{IMAGE:50x50x1}</div>[/IMAGE] [MSG]<p>{MSG}</p>[/MSG] <!--##End-{DBID}##//--> </div> <!--GUESTBOOK_ENTRY_END//-->
Here you can determine if the little guestbook hack is on or off. (If not present at all this is equal to “0” = off ).
In config/phpwcms/conf.inc.php you'll enter
$phpwcms['guestbook_hidden'] = 1; // enable|disable hidden guestbook entry +KH090210
File name: cnt18.article.inc.php
Location: include/inc_front/content/
Enhancement of the file around line 387:
The line
$guestbook['sql'] .= "guestbook_msg='".aporeplace($guestbook['post']['msg'])."', ";
will be replaced by
// Insert tag to hide entry ================= +KH090210 if ($phpwcms['guestbook_hidden']) $guestbook['sql'] .= "guestbook_msg='".'[##]'.aporeplace($guestbook['post']['msg'])."', "; else $guestbook['sql'] .= "guestbook_msg='". aporeplace($guestbook['post']['msg'])."', "; // =========================================== +KH090210
Save the file PATCH-DOC01.php in include/inc_front/content/ . (Or at any other place or under any other name, but with the suffix *.php)
include/inc_front/content/PATCH-DOC01.php
<?php /* ======================================================== // 09.02.10 KH // Hide guestbook entry with simple tag [##] in message text // Around line 387 // disble and/or replace the following snipped: // guestbook['sql'] .= "guestbook_msg='".aporeplace($guestbook['post']['msg'])."', "; // Insert tag to hide entry ================= +KH090210 if ($phpwcms['guestbook_hidden']) $guestbook['sql'] .= "guestbook_msg='".'[##]'.aporeplace($guestbook['post']['msg'])."', "; else $guestbook['sql'] .= "guestbook_msg='".aporeplace($guestbook['post']['msg'])."', "; // =========================================== +KH090210 ======================================================== */ ?>
File name: guestbook_vorlage.html
Location: template/inc_cntpart/guestbook/
Here you'll have to insert the Wrapper-Tags:
e.g.:
<!--GUESTBOOK_ENTRY_START//--> <!--##Begin-{DBID}##//--> <!--##:SUBSTITUTETEXT SUBSTITUTETEXT SUBSTITUTETEXT:##//--> ..... ..... <!--##End-{DBID}##//--> <!--GUESTBOOK_ENTRY_END//-->
<note important>
The Tag <!--##:SUBSTITUTETEXT SUBSTITUTETEXT SUBSTITUTETEXT:##//--> has to be between
<!--##Begin-{DBID}##//-->
<!--##:SUBSTITUTETEXT SUBSTITUTETEXT SUBSTITUTETEXT:##//-->
<!--##End-{DBID}##//-->
</note>
In the area CUSTOM VAR ==========================
an additional text can be entered in $replacement_text, which is issued when an item is not yet released. This text will be displayed only if in template also the tag <!--##:AlternativText AlternativText:##//-->
is used.
File name: cp_trig_guestbook.php
Location: template/inc_script/frontend_init/
<?php /** * Hide an guestbook entry with a simple tag [##] * 09.02.2010 K.Heermann (flip-flop) http://planmatrix.de * Template: * <!--GUESTBOOK_ENTRY_START//--> * * <!--##Begin-{DBID}##//--> * <!--##:REPTEXT REPTEXT REPTEXT:##//--> * ....... * ....... * <!--##End-{DBID}##//--> * *<!--GUESTBOOK_ENTRY_END//--> * * Tag in message: [##] * * If the script find te tag [##] in a guestbook message, this message kicked out for output and * a replacement text in <!--##:REPTEXT REPTEXT REPTEXT:##//--> appears. * * CUSTOM VAR: * $guestbook_hidden = 1; // if not set in the config * $entry_count = 20; // only the last XX entries are processed * $replacement_text = ''; // additional replacement text * */ // ------------------------------------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day."); } // ------------------------------------------------------------------------------------------- function CP_GUESTBOOK($text, & $data) { if( $data['acontent_type'] == 18 ) // CP: 18 => guestbook { // Is the var in config set? if (isset($GLOBALS['phpwcms']['guestbook_hidden'])) $guestbook_hidden = $GLOBALS['phpwcms']['guestbook_hidden']; else $guestbook_hidden = 1; // CUSTOM VAR // CUSTOM VAR ========================== // For small process runtime, only the last XX entries are processed // if you want that all messages are processed, increment the counter e.g. to 10000 $entry_count = 20; // additional replacement text // $replacement_text = ' <span style="color:red"> [[Der Eintrag wird bearbeitet]]</span><br><br>'.LF; $replacement_text = ' <span style="color:red"> [[The entry will be processed]]</span><br><br>'.LF; // ===================================== // Cut out text between your tags in template preg_match_all('/<!--##Begin-(.*?)##\/\/-->(.*?)<!--##End-(.*?)##\/\/-->/ism',$text, $_text); if ($_text[2][0]) { // is there any text available? foreach ($_text[2] as $key =>$value) { // Hidden tag [##] find? if ( strpos($value, '[##]')!== false ) { // Hidden tag entry switched on or off? if ($guestbook_hidden) { // replacement text available? if (preg_match('/<!--##:(.*?):##\/\/-->/ism', $value, $_temp)) { $value = $_temp[1] . $replacement_text; } else $value = ''; // no entry is shown // no hidden tag entry in config, kill the tag for output } else $value = str_replace('[##]','', $value); $search = '/<!--##Begin-'.$_text[3][$key].'##\/\/-->(.*?)<!--##End-'.$_text[3][$key].'##\/\/-->/ism'; $text = preg_replace($search, $value, $text,1); } // Only the first XX entries for small runtime if ($key > $entry_count) break; } // If you want kill the replacement text comment // $text = preg_replace('/<!--##:(.*?):##\/\/-->/ism', '$1', $text); // Kill all <!--:TEXT TEXT {NAME}://--> } } return $text; } register_cp_trigger('CP_GUESTBOOK'); ?>