Ignore:
Timestamp:
Mar 19, 2011, 10:27:48 AM (13 years ago)
Author:
mistic100
Message:

[extentions] Smilies Support

  • active for admin in the comments page
  • two new sets of smilies
  • help tip on admin page (needs translation)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/SmiliesSupport/smiliessupport.inc.php

    r9683 r9764  
    66        global $template, $lang, $pwg_loaded_plugins;
    77
    8         if (!isset($pwg_loaded_plugins['bbcode_bar']))
    9         {
     8        if (!isset($pwg_loaded_plugins['bbcode_bar'])) {
    109                $lang['Comment'] .= SmiliesTable();
    1110        }
     
    1413function SmiliesTable($new_conf=null)
    1514{
    16         global $conf, $template;
     15        global $conf, $template, $page;
    1716
    1817        // this is for live update on admin page
    19         if (empty($new_conf))
     18        if (empty($new_conf)) {
    2019                $conf_smiliessupport = explode("," , $conf['smiliessupport']);
    21         else
     20        } else {
    2221                $conf_smiliessupport = $new_conf;
     22        }
    2323
    2424        // edit field has a different id
    25         if (isset($_GET['action']) AND $_GET['action'] == 'edit_comment')
     25        if (
     26                (isset($_GET['action']) AND $_GET['action'] == 'edit_comment')
     27                OR (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage')
     28        ) {
    2629                $template->assign('form_name', 'editComment');
    27         else
     30        } else {
    2831                $template->assign('form_name', 'addComment');
     32        }
    2933
    3034        $cnt = 1;
     
    4044                        if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png"))
    4145                        {
    42                                 if (( $cnt > 0 ) && ( $cnt % $conf_smiliessupport[1] == 0 ))
    43                                 {
     46                                if (( $cnt > 0 ) && ( $cnt % $conf_smiliessupport[1] == 0 )) {
    4447                                        $trvalue = '</tr><tr>';
    4548                                }
     
    5154                        }
    5255                }
    53         }
    54         else
    55         {
     56               
     57        } else {
    5658                array_push($page['errors'], l10n('opendir failed : '.PHPWG_ROOT_PATH.$conf_smiliessupport[0].')' ));
    5759        }
     
    6668        $conf_smiliessupport = explode("," , $conf['smiliessupport']);
    6769        $def_path = $conf_smiliessupport[0].'/smilies.txt';
     70        $accepted_ext = array('gif', 'jpg', 'png');
    6871       
    6972        if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0]))
     
    7174                while (false !== ($file = readdir($handle)))
    7275                {
    73                         if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png")) {
     76                        if ($file != "." && $file != ".." && in_array(get_extension($file), $accepted_ext)) {
    7477                                $v = ':'.get_filename_wo_extension($file).':';
    7578                                $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" alt=":'.get_filename_wo_extension($file).':" title=":'.get_filename_wo_extension($file).':"/>';
     
    7982        }
    8083       
    81         if ( file_exists($def_path) )
     84        if (file_exists($def_path))
    8285        {
    8386                $def = file($def_path);
     
    8588                {
    8689                        $v = trim($v);
    87                         if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches))
    88                         {       
     90                        if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches)) { 
    8991                                $r = '#'.preg_quote($matches[1],'/').'#';                                       
    9092                                $t = '<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" alt=":'.get_filename_wo_extension($matches[2]).':" title=":'.get_filename_wo_extension($matches[2]).':"/>';
Note: See TracChangeset for help on using the changeset viewer.