Ignore:
Timestamp:
Jun 10, 2011, 9:02:29 PM (13 years ago)
Author:
mistic100
Message:

parsing bug fixed, works with theme 'Simple'

File:
1 edited

Legend:

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

    r10986 r11294  
    55function set_smiliessupport()
    66{
    7   global $conf, $lang;
     7  global $conf, $template, $page;
     8 
     9  load_language('plugin.lang', SMILIES_PATH);
    810  $conf_smiliessupport = explode(',' , $conf['smiliessupport']);
    911 
    1012  $smilies = get_smilies($conf_smiliessupport);
    11   $lang['Comment'] .= SmiliesTable($conf_smiliessupport, $smilies); 
     13 
     14  // edit field has different id
     15  // if (
     16    // (isset($_GET['action']) AND $_GET['action'] == 'edit_comment')
     17    // OR (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage')
     18  // ) {
     19    // $template->assign('smilies_textarea', 'contenteditid');
     20  // } else {
     21    // $template->assign('smilies_textarea', 'contentid');
     22  // }
     23  $template->assign('smilies_textarea', 'contentid');
     24 
     25  $template->assign(array(
     26    'SMILIES_PATH' => SMILIES_PATH,
     27    'REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2],
     28    'smiliesfiles' => $smilies,
     29  ));
     30 
     31  $template->set_prefilter('picture', 'set_smiliessupport_prefilter'); 
     32}
     33
     34function set_smiliessupport_prefilter($content, &$smarty)
     35{
     36  $search = "<label>{'Comment'|@translate}";
     37  $replace = file_get_contents(SMILIES_PATH.'/template/smiliessupport_page.tpl').$search;
     38  return str_replace($search, $replace, $content);
    1239}
    1340
     
    3461   
    3562    return $smilies;
    36   } else {
     63  }
     64  else
     65  {
    3766    return false;
    3867  }
    39 }
    40 
    41 // get the smilies button ## must received the unserialized configuration array AND the smilies array
    42 function SmiliesTable($conf_smiliessupport, $smilies)
    43 {
    44   global $template;
    45   load_language('plugin.lang', SMILIES_PATH);
    46 
    47   // edit field has different id
    48   // if (
    49     // (isset($_GET['action']) AND $_GET['action'] == 'edit_comment')
    50     // OR (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage')
    51   // ) {
    52     // $template->assign('form_name', 'editComment');
    53   // } else {
    54     // $template->assign('form_name', 'addComment');
    55   // }
    56   $template->assign('form_name', 'addComment');
    57 
    58   $template->assign(array(
    59     'SMILIES_PATH' => SMILIES_PATH,
    60     'REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2],
    61     'smiliesfiles' => $smilies,
    62   ));
    63  
    64   $template->set_filename('smiliessupport_page', dirname(__FILE__).'/template/smiliessupport_page.tpl');
    65   return $template->parse('smiliessupport_page', true);
    6668}
    6769
     
    7476  $def_path = $conf_smiliessupport[0].'/smilies.txt';
    7577  $accepted_ext = array('gif', 'jpg', 'png');
     78  $str = ' '.$str;
    7679 
    7780  if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0]))
     
    7982    while (false !== ($file = readdir($handle)))
    8083    {
    81       if ($file != "." && $file != ".." && in_array(get_extension($file), $accepted_ext)) {
    82         $v = ':'.get_filename_wo_extension($file).':';
    83         $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" alt=":'.get_filename_wo_extension($file).':" title=":'.get_filename_wo_extension($file).':"/>';
     84      if ($file != "." && $file != ".." && in_array(get_extension($file), $accepted_ext))
     85      {
     86        $filename = get_filename_wo_extension($file);
     87        $v = ':'.$filename.':';
     88        $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" alt=":'.$filename.':"/>';
    8489        $str = str_replace($v, $s, $str);
    8590      }
     
    9398    {
    9499      $v = trim($v);
    95       if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches)) { 
    96         $r = '#'.preg_quote($matches[1],'/').'#';         
    97         $t = '<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" alt=":'.get_filename_wo_extension($matches[2]).':" title=":'.get_filename_wo_extension($matches[2]).':"/>';
    98         $str = preg_replace($r, $t, $str);
     100      if (preg_match('#^([^\t]+)[ \t]+(.+)$#', $v, $matches))
     101      { 
     102        $filename = get_filename_wo_extension($matches[2]);
     103        $v = '#[^"]'.preg_quote($matches[1],'/').'#';         
     104        $t = '<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" alt=":'.$filename.':"/>';
     105        $str = preg_replace($v, $t, $str);
    99106      }
    100107    }
    101108  }
    102109 
    103   return $str;
     110  return trim($str);
    104111}
    105112
Note: See TracChangeset for help on using the changeset viewer.