Guestbook hide entry

FIXME translate

A small enlhancement to turn new guestbook entries invisible until they have been edited by admin (released) in BE.

Explanation:

  • After submitting a new entry, a ”[##]” is placed at the beginning of the message text automatically (mini-hack).
  • All entries including a ”[##]” will not be displayed in the FE output, or an alternative text is displayed. (Template/cp-trigger Script).
  • If ”[##]” will be deleted from the entry in BE, the entry in FE will become visible. (”[##]” can also be added in BE in order to hide entries).


Blocked Messages:


Unlocked Entries:


Necessary preparations

- as there are:

  1. enter the switch $phpwcms['guestbook_hidden'] = 1; in conf.inc.php
  2. The file include/inc_front/content/cnt18.article.inc.php has to be changed a little bit (small hack)
  3. In template template/inc_cntpart/guestbook/*.html there have to be entered two new Tags (at least)
  4. The PHP-Script template/inc_script/frontend_init/cp_trig_guestbook.php has to be installed



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

  • $phpwcms['allow_ext_init'] = 1;
  • $phpwcms['allow_cntPHP_rt'] = 1;


Tag (in template):

<!--GUESTBOOK_ENTRY_START//-->
<!--##Begin-{DBID}##//--> … Entry … <!--##End-{DBID}##//-->
<!--GUESTBOOK_ENTRY_END//-->

  • All between <!--##Begin-{DBID}##//--> and <!--##End-{DBID}##//--> will be triggered and will not be delivered in case a [##] is found.

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] &#8212; <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//-->


conf.inc.php

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


Code snippet (hack)

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


Documentation

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
 ======================================================== */
?>


Template

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>


PHP

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/

cp_trig_guestbook.php

<?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"> &nbsp;[[Der Eintrag wird bearbeitet]]</span><br><br>'.LF;
        $replacement_text = ' <span style="color:red"> &nbsp;[[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');
 
?>


english/other-enhancements/hacks/guestbook-hide_entry.txt · Last modified: 2018/06/03 18:09 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0