{{indexmenu_n>20}} ====== 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:** {{:english:other-enhancements:hacks:gb_entry_hide_fe01_en_1.gif| }} {{:deutsch:andere-erweiterungen:hacks:gb_entry_hide_be01_2.gif|}} \\ **Unlocked Entries:** {{:deutsch:andere-erweiterungen:hacks:gb_entry_hide_fe02_1.gif| }} {{:deutsch:andere-erweiterungen:hacks:gb_entry_hide_be02_2.gif|}} \\ ===== Necessary preparations ===== - as there are: - enter the switch **$phpwcms['guestbook_hidden'] = 1;** in conf.inc.php - The file **include/inc_front/content/cnt18.article.inc.php** has to be changed a little bit //(small hack)// - In template **template/inc_cntpart/guestbook/*.html** there have to be entered two new Tags (at least) - 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:** -> [[http://www.phpwcms-docu.de/confincphp_de.phtml|/config/phpwcms/conf.inc.php]] \\ * $phpwcms['allow_ext_init'] = 1; * $phpwcms['allow_cntPHP_rt'] = 1; ---- \\ **Tag** //(in template)//: %%%% \\ ##%%%%## **... Entry ...** ##%%%%## \\ %%%% \\ * All between **%%%%** and **%%%%** will be triggered and will not be delivered in case a [##] is found. In the text is entered which will be shown in case the entry is locked, e.g. ''%%%%''. **%%%%** has to be set anywhere between **%%%%** and **%%%%** . \\ //(If the alternative text is not set the output will stay empty)//. \\ **Example:**

entry #{ID} by [URL]{NAME}[/URL][URL_ELSE]{NAME}[/URL_ELSE]

{TIMESTAMP:m/d/Y H:i}[EMAIL] — email[/EMAIL]

[IMAGE]
{IMAGE:50x50x1}
[/IMAGE] [MSG]

{MSG}

[/MSG]
\\ ==== 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**) // \\ ==== Template ==== **File name:** guestbook_vorlage.html \\ **Location:** template/inc_cntpart/guestbook/ Here you'll have to insert the Wrapper-Tags: e.g.: ..... ..... The Tag %%%% has to be between \\ **%%%%** \\ %%%% \\ **%%%%** \\ \\ ==== 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 ''%%%%'' is used. ---- \\ **File name:** cp_trig_guestbook.php \\ **Location:** template/inc_script/frontend_init/ * * * * ....... * ....... * * * * * Tag in message: [##] * * If the script find te tag [##] in a guestbook message, this message kicked out for output and * a replacement text in 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 = '  [[Der Eintrag wird bearbeitet]]

'.LF; $replacement_text = '  [[The entry will be processed]]

'.LF; // ===================================== // Cut out text between your tags in template preg_match_all('/(.*?)/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 = '/(.*?)/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 } } return $text; } register_cp_trigger('CP_GUESTBOOK'); ?>
\\