Ignore:
Timestamp:
Jun 15, 2013, 6:52:37 PM (11 years ago)
Author:
mistic100
Message:

rewrite admin page
new set from Pidgin

Location:
extensions/SmiliesSupport/include
Files:
1 added
1 moved

Legend:

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

    r23217 r23234  
    55function set_smiliessupport($prefilter='picture', $textarea_id='contentid')
    66{
    7   global $conf, $template, $page;
    8  
    9   load_language('plugin.lang', SMILIES_PATH);
    10   $conf_smiliessupport = unserialize($conf['smiliessupport']);
     7  global $conf, $template;
    118
    129  $template->assign(array(
    1310    'SMILIES_PATH' => SMILIES_PATH,
    14     'SMILIES_ID' => $textarea_id,
    15     'REPRESENTANT' => SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$conf_smiliessupport['representant'],
    16     'smiliesfiles' => get_smilies($conf_smiliessupport),
     11    'SMILIES_ID' =>   $textarea_id,
     12    'REPRESENTANT' => SMILIES_DIR.$conf['smiliessupport']['folder'].'/'.$conf['smiliessupport']['representant'],
     13    'smiliesfiles' => get_smilies(),
    1714  ));
    1815 
     
    2724}
    2825
    29 // return an array with available smilies (name and path) ## must received the unserialized configuration array
    30 function get_smilies($conf_smiliessupport)
     26// return an array with available smilies (name and path)
     27function get_smilies()
    3128{
    32   $accepted_ext = array('gif', 'jpg', 'png');
     29  global $conf;
    3330 
    34   if ($handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder']))
     31  if ($handle = opendir(SMILIES_DIR.$conf['smiliessupport']['folder']))
    3532  {
    3633    $i = 1;
    3734    while (false !== ($file = readdir($handle)))
    3835    {
    39       if ($file != '.' AND $file != '..' AND in_array(get_extension($file), $accepted_ext))
     36      if ($file != '.' and $file != '..' and in_array(get_extension($file), $conf['smiliessupport']['ext']))
    4037      {
    4138        $smilies[] = array(
    42           'PATH' => SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$file,
     39          'PATH' => SMILIES_DIR.$conf['smiliessupport']['folder'].'/'.$file,
    4340          'TITLE' => ':'.get_filename_wo_extension($file).':',
    44           'TR' => ($i>0 AND $i%$conf_smiliessupport['cols'] == 0) ? '</tr><tr>' : null,
     41          'TR' => ($i>0 and $i%$conf['smiliessupport']['cols'] == 0) ? '</tr><tr>' : null,
    4542        );
    4643        $i++;
     
    6158{
    6259  global $conf;
    63 
    64   $conf_smiliessupport = unserialize($conf['smiliessupport']);
    65   $folder = get_absolute_root_url().SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'];
    66   $def_path = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt';
    67   $accepted_ext = array('gif', 'jpg', 'png');
     60 
     61  $root_path = get_absolute_root_url();
     62  $folder = SMILIES_DIR.$conf['smiliessupport']['folder'].'/';
    6863  $str = ' '.$str;
    6964 
    70   if ($handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder']))
     65  if ($handle = opendir($folder))
    7166  {
    7267    while (false !== ($file = readdir($handle)))
    7368    {
    74       if ($file != "." && $file != ".." && in_array(get_extension($file), $accepted_ext))
     69      if ($file != "." && $file != ".." && in_array(get_extension($file), $conf['smiliessupport']['ext']))
    7570      {
    7671        $filename = get_filename_wo_extension($file);
    7772        $v = ':'.$filename.':';
    78         $s = '<img src="'.$folder.'/'.$file.'" alt=":'.$filename.':"/>';
     73        $s = '<img src="'.$root_path.$folder.$file.'" alt=":'.$filename.':"/>';
    7974        $str = str_replace($v, $s, $str);
    8075      }
     
    8479  }
    8580 
    86   if (file_exists($def_path))
     81  if (file_exists($folder.'smilies.txt'))
    8782  {
    88     $def = file($def_path);
    89     foreach($def as $v)
     83    foreach (file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES) as $v)
    9084    {
    9185      $v = trim($v);
    92       if (preg_match('#^([^\t]+)[ \t]+(.+)$#', $v, $matches))
     86      if (preg_match('#^([^\s]+)[\s]+(.+)$#', $v, $matches))
    9387      { 
    9488        $filename = get_filename_wo_extension($matches[2]);
    9589        $v = '#([^"])'.preg_quote($matches[1],'/').'#';         
    96         $t = '$1<img src="'.$folder.'/'.$matches[2].'" alt=":'.$filename.':"/>';
     90        $t = '$1<img src="'.$root_path.$folder.$matches[2].'" alt=":'.$filename.':"/>';
    9791        $str = preg_replace($v, $t, $str);
    9892      }
Note: See TracChangeset for help on using the changeset viewer.