Changeset 1648 in ExiteCMS for trunk/includes/core_functions.php


Ignore:
Timestamp:
08/17/08 22:34:14 (4 years ago)
Author:
hverton
Message:

added the HotEditor BBcode WYSIWYG editor
added a user profile open to disable the editor (if globally enabled)
replaced the smiley system. Now images are included instead if smiley shorthand
added a few hundered new smiley images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/core_functions.php

    r1647 r1648  
    576576    ); 
    577577    foreach($smiley as $key=>$smiley_img) { 
    578         $search = "#([[:space:]])".$key."([[:space:]])?#si"; 
     578        $search = "#(^|[[:space:]])".$key."([[:space:]]|$)?#si"; 
    579579        $replace = "\\1".$smiley_img."\\2"; 
    580580        $message = preg_replace($search, $replace, $message); 
     
    609609    global $locale; 
    610610 
    611     // validate the URL (in $matches[1]) 
    612     if (isURL($matches[1], true)) { 
     611    // validate the URL (in $matches[1]) or check if it is a local image file 
     612    if (isURL($matches[1], true) || file_exists(PATH_ROOT.$matches[1])) { 
    613613        if (verify_image($matches[1])) { 
    614614            return "<img src=\"".$matches[1]."\" style=\"border:0px\" alt=\"\" />"; 
     
    623623    global $settings, $locale; 
    624624     
    625     $text = preg_replace('#\[li\](.*?)\[/li\]#si', '<li>\1</li>', $text); 
    626     $text = preg_replace('#\[ul\](.*?)\[/ul\]#si', '<ul>\1</ul>', $text); 
    627  
     625    // horizontal line 
     626    $text = preg_replace('#\[hr\]#si', '<hr />', $text); 
     627 
     628    // old style lists 
     629    $text = preg_replace('#\[li\](.*?)\[/li\]#si', '<li style=\'margin-left:15px;\'>\1</li>', $text); 
     630    $text = preg_replace('#\[ul\](.*?)\[/ul\]#si', '<ul style=\'margin-left:-20px;\'>\1</ul>', $text); 
     631 
     632    // new style lists 
     633    $text = preg_replace('#\[list=1\](.*?)\[/list\]#si', '<ol>\1</ol>', $text); 
     634    $text = preg_replace('#\[list\](.*?)\[/list\]#si', '<ul>\1</ul>', $text); 
     635    $text = preg_replace('#\r\n\[\*\]#si', '<li>', $text); 
     636 
     637    //get rid of line breaks after a list item, for better formatting 
     638    $text=str_replace("</li><br />","</li>",$text); 
     639    $text=str_replace("</ul><br />","</ul>",$text); 
     640 
     641    // text formatting 
    628642    $text = preg_replace('#\[b\](.*?)\[/b\]#si', '<b>\1</b>', $text); 
    629643    $text = preg_replace('#\[i\](.*?)\[/i\]#si', '<i>\1</i>', $text); 
    630644    $text = preg_replace('#\[u\](.*?)\[/u\]#si', '<u>\1</u>', $text); 
    631     $text = preg_replace('#\[center\](.*?)\[/center\]#si', '<center>\1</center>', $text); 
     645    $text = preg_replace('#\[strike\](.*?)\[/strike\]#si', '<span style=\'text-decoration: line-through;\'>\1</span>', $text); 
     646    $text = preg_replace('#\[sup\](.*?)\[/sup\]#si', '<sup>\1</sup>', $text); 
     647    $text = preg_replace('#\[sub\](.*?)\[/sub\]#si', '<sub>\1</sub>', $text); 
     648    $text = preg_replace('#\[blockquote\](.*?)\[/blockquote\]#si', '<blockquote style=\'border:1px dotted;padding:2px;\'>\1</blockquote>', $text); 
     649 
     650    $text = preg_replace('#\[left\](.*?)\[/left\]#si', '<div align=\'left\'>\1</div>', $text); 
     651    $text = preg_replace('#\[center\](.*?)\[/center\]#si', '<div align=\'center\'>\1</div>', $text); 
     652    $text = preg_replace('#\[justify\](.*?)\[/justify\]#si', '<div align=\'justify\'>\1</div>', $text); 
     653    $text = preg_replace('#\[right\](.*?)\[/right\]#si', '<div align=\'right\'>\1</div>', $text); 
     654 
     655    $text = preg_replace('#\[font=(.*?)\](.*?)\[/font\]#si', '<span style=\'font-family:\1\'>\2</span>', $text); 
     656    $text = preg_replace('#\[size=([0-3]?[0-9])\](.*?)\[/size\]#si', '<span style=\'font-size:\1px\'>\2</span>', $text); 
     657    $text = preg_replace('#\[small\](.*?)\[/small\]#si', '<span class=\'small\'>\1</span>', $text); 
     658 
     659    $text = preg_replace('#\[color=(\#[0-9a-fA-F]{6}|black|blue|brown|cyan|grey|green|lime|maroon|navy|olive|orange|purple|red|silver|violet|white|yellow)\](.*?)\[/color\]#si', '<span style=\'color:\1\'>\2</span>', $text); 
     660    $text = preg_replace('#\[highlight=(\#[0-9a-fA-F]{6}|black|blue|brown|cyan|grey|green|lime|maroon|navy|olive|orange|purple|red|silver|violet|white|yellow)\](.*?)\[/highlight\]#si', '<span style=\'background-color:\1\'>\2</span>', $text); 
    632661 
    633662    // new wiki bbcode 
     
    649678    $text = preg_replace('#\[mail\]([\r\n]*)([^\s\'\";:\+]*?)([\r\n]*)\[/mail\]#si', '<a href=\'mailto:\2\'>\2</a>', $text); 
    650679    $text = preg_replace('#\[mail=([\r\n]*)([^\s\'\";:\+]*?)\](.*?)([\r\n]*)\[/mail\]#si', '<a href=\'mailto:\2\'>\3</a>', $text); 
    651     // small     
    652     $text = preg_replace('#\[small\](.*?)\[/small\]#si', '<span class=\'small\'>\1</span>', $text); 
    653     // color 
    654     $text = preg_replace('#\[color=(\#[0-9a-fA-F]{6}|black|blue|brown|cyan|grey|green|lime|maroon|navy|olive|orange|purple|red|silver|violet|white|yellow)\](.*?)\[/color\]#si', '<span style=\'color:\1\'>\2</span>', $text); 
    655     // new youtube bbcode 
     680 
     681    // youtube bbcode 
    656682    $text = preg_replace('#\[youtube\](.*?)\[/youtube\]#si', '<object type="application/x-shockwave-flash" width="425" height="350" data="http://www.youtube.com/v/\1"><param name="movie" value="http://www.youtube.com/v/\1"></param><param name="wmode" value="transparent"></param></object>', $text); 
     683 
    657684    // flash movies 
    658685    $text = preg_replace('#\[flash width=([0-9]*?) height=([0-9]*?)\]([^\s\'\";:\+]*?)(\.swf)\[/flash\]#si', '<object classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' codebase=\'http://active.macromedia.com/flash6/cabs/swflash.cab#version=6,0,0,0\' id=\'\3\4\' width=\'\1\' height=\'\2\'><param name=movie value=\'\3\4\'><param name=\'quality\' value=\'high\'><param name=\'bgcolor\' value=\'#ffffff\'><embed src=\'\3\4\' quality=\'high\' bgcolor=\'#ffffff\' width=\'\1\' height=\'\2\' type=\'application/x-shockwave-flash\' pluginspage=\'http://www.macromedia.com/go/getflashplayer\'></embed></object>', $text); 
     686 
    659687    // images 
    660688    if (ini_get('allow_url_fopen')) { 
     
    663691        $text = preg_replace("#\[img\]((http|ftp|https|ftps)://)(.*?)(\.(jpg|jpeg|gif|png|JPG|JPEG|GIF|PNG))\[/img\]#sie","'<img src=\'\\1'.str_replace(array('.php','?','&','='),'','\\3').'\\4\' style=\'border:0px\' alt=\'\' />'",$text); 
    664692    } 
    665     // quotes 
     693 
     694    // quote     & code blocks 
    666695    $text = preg_replace('#\[quote=([\r\n]*)(.*?)\]#si', '<b>\2 '.$locale['199'].':</b><br />[quote]', $text); 
    667696    $qcount = substr_count($text, "[quote]"); $ccount = substr_count($text, "[code]"); 
Note: See TracChangeset for help on using the changeset viewer.