Feature suggestion: Internal commenting

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Stosh
Regular
Posts: 75
Joined: Mon Oct 12, 2009 11:47 pm

Feature suggestion: Internal commenting

Post by Stosh »

Hi,

This is just a feature suggestion. Not something I need, but just something that would be nice to have.

In my glossary (example) I have a set of message editing tags ([comment] blah blah blah [/comment]) that denote that anything between them is a comment, which is stored in the database, but is never displayed when the message is displayed at the outside level.

It is implemented simply by parsing out the entire structure to an empty string when the message is being parsed for display.

Again, not a demand, just thought it would be cool to have (very helpful in the glossary).

-s
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Feature suggestion: Internal commenting

Post by garvinhicking »

Hi!

Not really sure if there is public demand, but a plugin could very simply do this:

Code: Select all

<?php
class serendipity_event_commenthide extends serendipity_event {
    var $title = 'Hide internal comments';
    function introspect(&$propbag) {
        global $serendipity;

        $propbag->add('name',          $this->title);
        $propbag->add('event_hooks',   array('frontend_display' => true));
    }

    function commentify($string) {
        return preg_replace('@\[comment](.+)\[/comment\]@imsU', '', $string);
    }

    function event_hook($event, &$bag, &$eventData, $addData = null) {
        global $serendipity;
        $hooks = &$bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch($event) {
                case 'frontend_display':
                    $el = array('body', 'extended');
                    foreach ($el as $temp) {
                        if (isset($eventData[$temp['element']]) &&
                            !$eventData['properties']['ep_disable_markup_' . $this->instance] &&
                            !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
                            $element = $temp['element'];
                            $eventData[$element] = $this->commentify($eventData[$element]);
                        }
                    }
                    return true;
                    break;
            }
        }

        return false;
    }
}
?>
HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply