Changeset 82 for branches

Show
Ignore:
Timestamp:
04/02/06 17:33:30 (3 years ago)
Author:
michiel
Message:

removed the acronym stuff from the core and introduced it as plugin

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/mvblog-plugins/common/functions_blog.php

    r81 r82  
    33 * MvBlog -- An open source no-noncence blogtool 
    44 * 
    5  * Copyright (C) 2005, Michiel van Baak 
     5 * Copyright (C) 2005-2006, Michiel van Baak 
    66 * Logo design (C) 2005, Sofie van Tendeloo 
    77 * 
     
    3737        return $db; 
    3838} 
     39//}}}--------------------------- 
     40//{{{ initialize the mvblog tool 
     41//------------------------------ 
    3942session_start(); 
    4043ob_start(); 
    4144$db = db_init(); 
    42 $acronyms = array(); 
    4345$version = "SVN \$Id$"; 
    4446$plugins = array(); 
     
    111113//------------------------------------------------------- 
    112114function show_article($id) { 
    113         global $db, $acronyms; 
     115        global $db; 
    114116        //get all the authors in an array 
    115117        $res =& $db->query("SELECT * FROM authors"); 
     
    132134                $categories[$row["id"]] = $row["name"]; 
    133135        } 
    134         //same with acronyms 
    135         $res =& $db->query("SELECT acronym,description FROM acronyms"); 
    136         if (PEAR::isError($res)) { 
    137                 die($res->getMessage()); 
    138         } 
    139         while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
    140                 $acronyms[$row["acronym"]] = $row["description"]; 
    141         } 
    142  
    143136        $res =& $db->query("SELECT * FROM articles WHERE id=$id"); 
    144137 
     
    157150                <div class="log_body"> 
    158151                        <div class="log_contents"> 
    159                                 <?=acro_replace(strip_invalid_xml(str_replace("##BREAKPOINT##", "", $row["body"])))?> 
     152                                <?=run_plugins(strip_invalid_xml(str_replace("##BREAKPOINT##", "", $row["body"])), "text_output")?> 
    160153                        </div> 
    161154                </div> 
     
    187180                        <div class="log_body"> 
    188181                                <div class="log_contents"> 
    189                                         <?=nl2br(strip_invalid_xml(acro_replace($row["comment"])))?> 
     182                                        <?=nl2br(strip_invalid_xml(run_plugins($row["comment"], "text_output")))?> 
    190183                                </div> 
    191184                                <div class="log_foot"> 
     
    338331        switch ($_REQUEST["action"]) { 
    339332                case "view"         : show_article($_REQUEST["id"]);      break; 
    340                 case "saveacro"     : save_acro_to_db();                  break; 
    341333                case "post_comment" : post_comment($_POST);               break; 
    342334                case "rss"          : header("Location: common/rss.php"); break; 
     
    694686        <? 
    695687} 
    696  
    697 //}}}------------------------------------------ 
    698 //{{{ acro_replace(): do some acronym replacing 
    699 //--------------------------------------------- 
    700 function acro_replace($text) { 
    701         global $acronyms; 
    702         foreach ($acronyms as $acronym => $description) { 
    703                 //replace all the supplied acronyms 
    704                 $text = preg_replace("|(?!<[^<>]*?)(?<![?./&])\b$acronym\b(?!:)(?![^<>]*?>)|imsU","<acronym class=\"blog_acro\" title=\"$description\">$acronym</acronym>" , $text); 
    705                 //allow user to overwrite acronym replacing by putting the term between $ signs 
    706                 $text = preg_replace("|[$]<acronym class=\"blog_acro\" title=\"$description\">$acronym</acronym>[$]|imsU" , "$acronym" , $text); 
    707         } 
    708         return trim($text); 
    709 } 
    710688//}}}--------------------------------------------------------------- 
    711689//{{{ strip_invalid_xml(): strip some stuff leftover from old editor