Ejemplo n.º 1
0
</h1>
        <h5 id="subinfo"><b><?php 
echo date('d M, Y', strtotime($row['added']));
?>
</b><?php 
echo $row['views'];
?>
 Views &nbsp;&nbsp;&nbsp; <?php 
echo Articles::getCommentsCount($row['id']);
?>
 Comments</h5>
        <p id="post">
         	<?php 
if (($text = $CACHE->get('articles/article_' . $row['id'])) === false) {
    // create the BBCode parser
    $parser = new SBBCodeParser_Document(true, false);
    //Strip slashes
    $text = stripslashes($row['text']);
    //Parse
    $text = $parser->parse($text)->detect_links()->detect_emails()->detect_emoticons()->get_html(true);
    //fix multiple break lines
    $text = preg_replace("/<br\\s*\\/?>\\s<br\\s*\\/?>\\s+/", "<br/>", $text);
    unset($parser);
    //Store the parsed post in the cache for a month
    $CACHE->store('articles/article_' . $row['id'], $text, "2592000");
}
//Print the text
echo $text;
?>
            <br/><br/>
        </p>
Ejemplo n.º 2
0
    }
    /**
     * Gets an array of tages to be excluded from
     * the elcude param
     * @param int $exclude What to gets excluded from i.e. SBBCodeParser_BBCode::AUTO_DETECT_EXCLUDE_EMOTICON
     * @return array
     */
    private function get_excluded_tags($exclude)
    {
        $ret = array();
        foreach ($this->bbcodes as $bbcode) {
            if ($bbcode->auto_detect_exclude() & $exclude) {
                $ret[] = $bbcode->tag();
            }
        }
        return $ret;
    }
}
IoC::singleton('BBCodeDocParser', function () {
    $instance = new SBBCodeParser_Document();
    $instance->add_emoticons(array(":)" => URL::to_asset('bundles/forums/emoticons/smile.png'), "=)" => URL::to_asset('bundles/forums/emoticons/smile.png'), "=]" => URL::to_asset('bundles/forums/emoticons/smile.png'), ":angel:" => URL::to_asset('bundles/forums/emoticons/angel.png'), ":angry:" => URL::to_asset('bundles/forums/emoticons/angry.png'), "8-)" => URL::to_asset('bundles/forums/emoticons/cool.png'), ":'(" => URL::to_asset('bundles/forums/emoticons/cwy.png'), "='(" => URL::to_asset('bundles/forums/emoticons/cwy.png'), "='[" => URL::to_asset('bundles/forums/emoticons/cwy.png'), ":ermm:" => URL::to_asset('bundles/forums/emoticons/ermm.png'), ":D" => URL::to_asset('bundles/forums/emoticons/grin.png'), "=D" => URL::to_asset('bundles/forums/emoticons/grin.png'), "<3" => URL::to_asset('bundles/forums/emoticons/heart.png'), ":(" => URL::to_asset('bundles/forums/emoticons/sad.png'), ":O" => URL::to_asset('bundles/forums/emoticons/shocked.png'), ":P" => URL::to_asset('bundles/forums/emoticons/tongue.png'), "=(" => URL::to_asset('bundles/forums/emoticons/sad.png'), "=[" => URL::to_asset('bundles/forums/emoticons/sad.png'), "=O" => URL::to_asset('bundles/forums/emoticons/shocked.png'), "=P" => URL::to_asset('bundles/forums/emoticons/tongue.png'), ";)" => URL::to_asset('bundles/forums/emoticons/wink.png'), ":alien:" => URL::to_asset('bundles/forums/emoticons/alien.png'), ":blink:" => URL::to_asset('bundles/forums/emoticons/blink.png'), ":blush:" => URL::to_asset('bundles/forums/emoticons/blush.png'), ":cheerful:" => URL::to_asset('bundles/forums/emoticons/cheerful.png'), ":devil:" => URL::to_asset('bundles/forums/emoticons/devil.png'), ":dizzy:" => URL::to_asset('bundles/forums/emoticons/dizzy.png'), ":getlost:" => URL::to_asset('bundles/forums/emoticons/getlost.png'), ":happy:" => URL::to_asset('bundles/forums/emoticons/happy.png'), ":kissing:" => URL::to_asset('bundles/forums/emoticons/kissing.png'), ":ninja:" => URL::to_asset('bundles/forums/emoticons/ninja.png'), ":pinch:" => URL::to_asset('bundles/forums/emoticons/pinch.png'), ":pouty:" => URL::to_asset('bundles/forums/emoticons/pouty.png'), ":sick:" => URL::to_asset('bundles/forums/emoticons/sick.png'), ":sideways:" => URL::to_asset('bundles/forums/emoticons/sideways.png'), ":silly:" => URL::to_asset('bundles/forums/emoticons/silly.png'), ":sleeping:" => URL::to_asset('bundles/forums/emoticons/sleeping.png'), ":unsure:" => URL::to_asset('bundles/forums/emoticons/unsure.png'), ":woot:" => URL::to_asset('bundles/forums/emoticons/w00t.png'), ":wassat:" => URL::to_asset('bundles/forums/emoticons/wassat.png')));
    return $instance;
});
class BBCodeParser
{
    public static function parse($elements)
    {
        $parser = IoC::resolve('BBCodeDocParser');
        return $parser->parse($elements)->detect_links()->detect_emails()->detect_emoticons()->get_html();
    }
}