Ignore:
Timestamp:
Jun 16, 2013, 1:09:12 AM (11 years ago)
Author:
mistic100
Message:

two columns display for shortcuts form, keep save of original smilies.txt file

File:
1 edited

Legend:

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

    r23234 r23236  
    2020}
    2121
    22 function smiliessupport_get_list()
     22function smiliessupport_action()
    2323{
    24   if (!isset($_GET['action']) || $_GET['action']!='ss_preview') return;
     24  if (!isset($_GET['action'])) return;
     25  if (strpos($_GET['action'], 'ss_') !== 0) return;
    2526 
    2627  global $conf;
     
    2829  $folder = SMILIES_DIR . ltrim($_GET['folder'], '/') . '/';
    2930 
    30   $short = array();
    31   if (file_exists($folder.'smilies.txt'))
     31  if ($_GET['action'] == 'ss_reset')
    3232  {
    33     foreach (file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES) as $v)
     33    @unlink($folder.'smilies-custom.txt');
     34    $_GET['action'] = 'ss_list';
     35  }
     36 
     37  if ($_GET['action'] == 'ss_list')
     38  {
     39    $short = array();
     40    if (file_exists($folder.'smilies-custom.txt'))
    3441    {
    35       if (preg_match('#^([^\s]+)[\s]+(.+)$#', trim($v), $matches))
     42      $file = file($folder.'smilies-custom.txt', FILE_IGNORE_NEW_LINES);
     43    }
     44    else if (file_exists($folder.'smilies.txt'))
     45    {
     46      $file = file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES);
     47    }
     48    if (!empty($file))
     49    {
     50      foreach ($file as $v)
    3651      {
    37         $short[ $matches[2] ][] = $matches[1];
     52        if (preg_match('#^([^\s]+)[\s]+(.+)$#', trim($v), $matches))
     53        {
     54          $short[ $matches[2] ][] = $matches[1];
     55        }
    3856      }
    3957    }
     58
     59    $smilies = array();
     60    $handle = opendir($folder);
     61    while (false !== ($file = readdir($handle)))
     62    {
     63      if ( $file != '.' && $file != '..' && in_array(get_extension($file), $conf['smiliessupport']['ext']) )
     64      {
     65        $smilies[$file] = array('title'=>':'.get_filename_wo_extension($file).':', 'file'=>$file, 'short'=>@$short[$file]);
     66      }
     67    }
     68    closedir($handle);
     69   
     70    echo json_encode(array('path'=>$folder, 'smilies'=>$smilies));
    4071  }
    41 
    42   $smilies = array();
    43   $handle = opendir($folder);
    44   while (false !== ($file = readdir($handle)))
    45   {
    46     if ( $file != '.' && $file != '..' && in_array(get_extension($file), $conf['smiliessupport']['ext']) )
    47     {
    48       $smilies[$file] = array('title'=>':'.get_filename_wo_extension($file).':', 'file'=>$file, 'short'=>@$short[$file]);
    49     }
    50   }
    51   closedir($handle);
    5272 
    53   echo json_encode(array('path'=>$folder, 'smilies'=>$smilies));
    5473  exit;
    5574}
Note: See TracChangeset for help on using the changeset viewer.