Changeset 23236


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

Location:
extensions/SmiliesSupport
Files:
2 added
9 edited
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/SmiliesSupport/admin.php

    r23234 r23236  
    6666    }
    6767  }
    68 
    69   if (file_exists(SMILIES_DIR.$_POST['folder'].'/smilies.txt'))
    70   {
    71     @copy(SMILIES_DIR.$_POST['folder'].'/smilies.txt', SMILIES_DIR.$_POST['folder'].'/smilies.bak');
    72   }
    7368 
    74   if (@!file_put_contents(SMILIES_DIR.$_POST['folder'].'/smilies.txt', $content))
     69  if (@!file_put_contents(SMILIES_DIR.$_POST['folder'].'/smilies-custom.txt', $content))
    7570  { 
    76     $page['errors'][] = l10n('File/directory read error').' : '.SMILIES_DIR.$_POST['folder'].'/smilies.txt';
     71    $page['errors'][] = l10n('File/directory read error').' : '.SMILIES_DIR.$_POST['folder'].'/smilies-custom.txt';
    7772  }
    7873}
  • 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}
  • extensions/SmiliesSupport/include/smiliessupport.inc.php

    r23234 r23236  
    7979  }
    8080 
    81   if (file_exists($folder.'smilies.txt'))
     81  if (file_exists($folder.'smilies-custom.txt'))
    8282  {
    83     foreach (file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES) as $v)
     83    $file = file($folder.'smilies-custom.txt', FILE_IGNORE_NEW_LINES);
     84  }
     85  else if (file_exists($folder.'smilies.txt'))
     86  {
     87    $file = file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES);
     88  }
     89  if (!empty($file))
     90  {
     91    foreach ($file as $v)
    8492    {
    8593      $v = trim($v);
  • extensions/SmiliesSupport/language/en_UK/plugin.lang.php

    r23234 r23236  
    22
    33$lang['Smilies set'] = 'Smilies set';
    4 $lang['Smiley'] = 'Smiley';
    54$lang['Shortcuts'] = 'Shortcuts';
    65$lang['Columns'] = 'Columns';
    76$lang['Smilies'] = 'Smilies';
    87$lang['Edit shorcuts'] = 'Edit shorcuts';
     8$lang['Reset defaults'] = 'Reset defaults';
    99$lang['If you change current set you will lost every shortcuts changes.'] = 'If you change current set you will lost every shortcuts changes.';
    1010
  • extensions/SmiliesSupport/language/fr_FR/plugin.lang.php

    r23234 r23236  
    22
    33$lang['Smilies set'] = 'Set de smileys';
    4 $lang['Smiley'] = 'Smiley';
    54$lang['Shortcuts'] = 'Raccourcis';
    65$lang['Columns'] = 'Colonnes';
    76$lang['Smilies'] = 'Smileys';
    87$lang['Edit shorcuts'] = 'Modifier les raccouris';
     8$lang['Reset defaults'] = 'Réinitialiser';
    99$lang['If you change current set you will lost every shortcuts changes.'] = 'Si vous changez de set, vous perdrez les modifications des raccourcis.';
    1010
  • extensions/SmiliesSupport/main.inc.php

    r23234 r23236  
    7373{
    7474  add_event_handler('get_admin_plugin_menu_links', 'smiliessupport_admin_menu');
    75   add_event_handler('init', 'smiliessupport_get_list');
     75  add_event_handler('init', 'smiliessupport_action');
    7676 
    7777  function smiliessupport_admin_menu($menu)
  • extensions/SmiliesSupport/smilies/pidgin/smilies.txt

    r23234 r23236  
    1313:)              happy.png
    1414:-)             happy.png
    15 <3              in_love.png
     15<3              in-love.png
    1616:|              neutral.png
    1717:-|             neutral.png
  • extensions/SmiliesSupport/template/smiliessupport_admin.tpl

    r23234 r23236  
    4444});
    4545
     46// reset defaults
     47jQuery(".reset").click(function() {
     48    var ok = confirm("{/literal}{'Are you sure?'|@translate}{literal}");
     49    if (!ok) return false;
     50   
     51    jQuery.ajax({
     52        url: 'admin.php',
     53        type: 'GET',
     54        dataType: 'json',
     55        data: {
     56            action: 'ss_reset',
     57            folder: jQuery("select[name='folder']").val(),
     58        },
     59        success: function(result) {
     60            data = result;
     61            edited = false;
     62            update();
     63        }
     64    });
     65   
     66    return false;
     67});
     68
    4669// display edit form before submit
    4770jQuery("#smiliesupport").submit(function() {
     
    5780        dataType: 'json',
    5881        data: {
    59             action: 'ss_preview',
     82            action: 'ss_list',
    6083            folder: jQuery("select[name='folder']").val(),
    6184        },
     
    7497    if (!edit) {
    7598        html+= '<tr>';
     99       
    76100        var cols = parseInt(jQuery("input[name='cols']").val());
    77101        var i=0;
     
    80104            var smiley = data.smilies[file];
    81105            html+= '<td><a href="#" title="'+ smiley.title +'"><img src="'+ data.path + smiley.file +'"/></a></td>';
    82             if ((parseInt(i)+1)%cols == 0) html+= '</tr><tr>';
     106            html+= (i+1)%cols==0 ? '</tr><tr>' : '';
    83107            i++;
    84108        }
    85109       
    86110        html+= '</tr>';
     111       
     112        jQuery(".reset").hide();
    87113    }
    88114    else {
    89115    {/literal}
    90116        html+= '<tr>'
    91             +'<th>{'Smiley'|@translate}</th>'
     117            +'<th></th>'
    92118            +'<th>{'Name'|@translate}</th>'
    93119            +'<th>{'Shortcuts'|@translate}</th>'
    94           +'</tr>';
     120            +'<th class="spacer"></th>'
     121            +'<th></th>'
     122            +'<th>{'Name'|@translate}</th>'
     123            +'<th>{'Shortcuts'|@translate}</th>'
     124          +'</tr>'
     125         
     126          +'<tr>';
    95127     {literal}
     128     
     129        var i=0;
    96130     
    97131        for (var file in data.smilies) {
    98132            var smiley = data.smilies[file];
    99             html+= '<tr data-file="'+ smiley.file +'">'
    100                 +'<td><img src="'+ data.path + smiley.file +'"/></td>'
    101                 +'<td>'+ smiley.title +'</td>'
    102                 +'<td>'
    103                   +'<select name="shortcuts['+ smiley.file +']" class="shortcuts">';
     133           
     134            html+=
     135              '<td><img src="'+ data.path + smiley.file +'"/></td>'
     136              +'<td>'+ smiley.title +'</td>'
     137              +'<td data-file="'+ smiley.file +'">'
     138                +'<select name="shortcuts['+ smiley.file +']" class="shortcuts">';
     139             
     140              for (var j in smiley.short) {
     141                  html+= '<option value="'+ smiley.short[j] +'" selected>'+ smiley.short[j] +'</option>';
     142              }
    104143               
    105                 for (var j in smiley.short) {
    106                     html+= '<option value="'+ smiley.short[j] +'" selected>'+ smiley.short[j] +'</option>';
    107                 }
    108                  
    109                 html+= '</select>'
    110                 +'</td>'
    111               +'</tr>';
    112         }
     144            html+=
     145                '</select>'
     146              +'</td>';
     147           
     148            html+= (i+1)%2==0 ? '</tr><tr>' : '<td></td>';
     149            i++;
     150        }
     151       
     152        html+= '</tr>';
     153       
     154        jQuery(".reset").show();
    113155    }
    114156   
     
    128170        onAdd: function(item) {
    129171            edited = true;
    130             var file = $(this).parents("tr").data("file");
     172            var file = $(this).parent("td").data("file");
    131173           
    132174            if (data.smilies[file].short == null) {
     
    139181        onDelete: function(item) {
    140182          edited = true;
    141           var file = $(this).parents("tr").data("file");
     183          var file = $(this).parent("td").data("file");
    142184         
    143185          for (var i in data.smilies[file].short) {
     
    191233  <a href="#" class="edit buttonLike">{'Edit shorcuts'|@translate}</a>
    192234  <table id="preview"></table>
     235  <a href="#" class="reset buttonLike" style="display:none;">{'Reset defaults'|@translate}</a>
    193236</fieldset>
    194237 
  • extensions/SmiliesSupport/template/style.css

    r23234 r23236  
    66}
    77
    8 .token-input-list li {
    9   clear:none !important;
    10   padding: 1px 3px !important;
    11   margin-bottom: 3px !important;
     8.token-input-list {
     9  width:250px !important;
    1210}
     11  .token-input-list li {
     12    clear:none !important;
     13    padding: 1px 3px !important;
     14    margin-bottom: 3px !important;
     15  }
    1316
    1417table#preview {
    15   margin:10px 0 0 0;
     18  margin:10px 0;
    1619}
     20  table#preview .spacer {
     21    width:30px;
     22  }
    1723
    18 input, select {
     24input[type=text], select, .token-input-list {
    1925  border-radius:3px;
    2026}
Note: See TracChangeset for help on using the changeset viewer.