Changeset 23234


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
Files:
44 added
23 deleted
9 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/SmiliesSupport/admin.php

    r15110 r23234  
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    33
     4include_once(SMILIES_PATH.'include/functions.inc.php');
     5
    46global $conf, $template;
    5 load_language('plugin.lang', SMILIES_PATH);
    6 
    7 if (strpos($conf['smiliessupport'],',') !== false)
    8 {
    9   include(SMILIES_PATH .'maintain.inc.php');
    10   plugin_activate();
    11 }
    12 
    13 $conf_smiliessupport = unserialize($conf['smiliessupport']);
    14 
    15 // Enregistrement de la configuration
    16 if (isset($_POST['submit']))
    17 {
    18   // the smilies.txt file is not saved if the directory is changed
    19   if (isset($_POST['folder']) AND $_POST['folder'] != $conf_smiliessupport['folder'])
    20   {
    21     $not_save_file = true;
    22    
    23     if (!file_exists(SMILIES_PATH.'smilies/'.$_POST['folder'].'/'.$_POST['representant']))
    24     {
    25       $handle = opendir(SMILIES_PATH.'smilies/'.$_POST['folder']);
    26       $i = 0;
    27       while (false !== ($file = readdir($handle)))
    28       {
    29         if ( $file != '.' AND $file != '..' AND in_array(get_extension($file), array('gif', 'jpg', 'png')) )
    30         {
    31           $_POST['representant'] = $file;
    32           closedir($handle);
    33           break;
    34         }
    35       }
    36     }
    37   }
    38  
    39   // new configuration
    40   $conf_smiliessupport = array(
    41     'folder' => isset($_POST['folder']) ? $_POST['folder'] : 'crystal',
    42     'cols' => isset($_POST['cols']) ? $_POST['cols'] : '6',
    43     'representant' => isset($_POST['representant']) ? $_POST['representant'] : 'smile.png',
    44   );
    45   if (empty($_POST['text'])) $_POST['text'] = '';
    46    
    47   conf_update_param('smiliessupport', serialize($conf_smiliessupport));
    48   array_push($page['infos'], l10n('Information data registered in database'));
    49  
    50   // new definitions file
    51   if (!isset($not_save_file))
    52   {
    53     $smilies_file = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt';     
    54 
    55     if (file_exists($smilies_file)) {
    56       @copy($smilies_file, get_filename_wo_extension($smilies_file).'.bak');
    57     }
    58    
    59     if (@!file_put_contents($smilies_file, stripslashes($_POST['text']))) { 
    60       array_push($page['errors'], l10n('File/directory read error').' : '.$smilies_file);
    61     }
    62   }
    63 }
    64 
    65 // check if the representant exists
    66 if (!file_exists(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$conf_smiliessupport['representant'])) {
    67   array_push($page['errors'], l10n('File/directory read error').' : smilies/'.$conf_smiliessupport['folder'].'/'.$conf_smiliessupport['representant']);
    68 }
    697
    708// get available sets
    719$sets = array();
    72 $handle = opendir(SMILIES_PATH.'smilies/');
    73 while (false !== ($file = readdir($handle)))
     10$handle = opendir(SMILIES_DIR);
     11while (false !== ($folder = readdir($handle)))
    7412{
    75   if ( $file != '.' && $file != '..' && is_dir(SMILIES_PATH.'smilies/'.$file) )
     13  if ( $folder != '.' && $folder != '..' && is_dir(SMILIES_DIR.$folder) )
    7614  {
    77     $sets[$file] = $file;
     15    if (file_exists(SMILIES_DIR.$folder.'/representant.txt'))
     16    {
     17      $sets[$folder] = file_get_contents(SMILIES_DIR.$folder.'/representant.txt');
     18    }
     19    else
     20    {
     21      $sets[$folder] = get_first_file(SMILIES_DIR.$folder, $conf['smiliessupport']['ext']);
     22    }
    7823  }
    7924}
    8025closedir($handle);
    8126
    82 // get available smilies
    83 $smilies_table = $smilies = array();
    84 $handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder']);
    85 $i = 1;
    86 while (false !== ($file = readdir($handle)))
     27
     28// save configuration
     29if (isset($_POST['submit']))
    8730{
    88   if ( $file != '.' AND $file != '..' AND in_array(get_extension($file), array('gif', 'jpg', 'png')) )
     31  // new configuration
     32  $conf['smiliessupport'] = array(
     33    'folder' =>       $_POST['folder'],
     34    'cols' =>         preg_match('#^([0-9]+)$#', $_POST['cols']) ? $_POST['cols'] : 6,
     35    'representant' => $sets[ $_POST['folder'] ],
     36  );
     37 
     38  conf_update_param('smiliessupport', serialize($conf['smiliessupport']));
     39  array_push($page['infos'], l10n('Information data registered in database'));
     40 
     41  // shortcuts file
     42  $used = array();
     43  $content = null;
     44 
     45  foreach ($_POST['shortcuts'] as $file => $data)
    8946  {
    90     $smilies[$file] = $file;
    91     $smilies_table[] = array(
    92       'PATH' => SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$file,
    93       'TITLE' => ':'.get_filename_wo_extension($file).':',
    94       'TR' => ($i>0 AND $i%$conf_smiliessupport['cols'] == 0) ? '</tr><tr>' : null,
    95     );
    96     $i++;
     47    if (empty($data)) continue;
     48   
     49    $data = explode(',', stripslashes($data));
     50    foreach ($data as $short)
     51    {
     52      if (array_key_exists($short, $used))
     53      {
     54        $page['errors'][] = sprintf(
     55                              l10n('<i>%s</i>, shortcut &laquo; %s &raquo; already used for <i>%s</i>'),
     56                              get_filename_wo_extension($file),
     57                              $short,
     58                              get_filename_wo_extension($used[ $short ])
     59                              );
     60      }
     61      else
     62      {
     63        $used[ $short ] = $file;
     64        $content.= $short."\t\t".$file."\n";
     65      }
     66    }
     67  }
     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  }
     73 
     74  if (@!file_put_contents(SMILIES_DIR.$_POST['folder'].'/smilies.txt', $content))
     75  { 
     76    $page['errors'][] = l10n('File/directory read error').' : '.SMILIES_DIR.$_POST['folder'].'/smilies.txt';
    9777  }
    9878}
    99 closedir($handle);
    10079
     80
     81// template
    10182$template->assign(array(
    102   'FOLDER' => $conf_smiliessupport['folder'],
    103   'COLS' => $conf_smiliessupport['cols'],
    104   'REPRESENTANT' => $conf_smiliessupport['representant'],
    105   'sets' => $sets,
    106   'smiliesfiles' => $smilies_table,
    107   'smilies' => $smilies,
     83  'FOLDER' =>       $conf['smiliessupport']['folder'],
     84  'COLS' =>         $conf['smiliessupport']['cols'],
     85  'SETS' =>         $sets,
     86  'SMILIES_PATH' => SMILIES_PATH,
    10887));
    10988
    110 // get the content of definitions file
    111 $smilies_file = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt';
    112 if (file_exists($smilies_file))
    113 {
    114   $content_file = file_get_contents($smilies_file);
    115   $template->assign(array('CONTENT_FILE' => $content_file));
    116 }
    117  
    118 $template->assign('SMILIES_PATH', SMILIES_PATH);
     89
    11990$template->set_filename('smiliessupport_conf', dirname(__FILE__).'/template/smiliessupport_admin.tpl');
    12091$template->assign_var_from_handle('ADMIN_CONTENT', 'smiliessupport_conf');
  • 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      }
  • extensions/SmiliesSupport/language/en_UK/plugin.lang.php

    r11875 r23234  
    11<?php
    22
    3 $lang['Smileys\' folder'] = 'Smileys\' folder';
    4 $lang['Nb. columns'] = 'Nb. columns';
    5 $lang['Representative'] = 'Representative';
    6 $lang['All Smilies'] = 'All Smilies';
    7 $lang['smilies_file_help'] = 'By default when a user clicks on a smiley, Smilies Support adds a keyword matching the name of the file (smile.png -> :smile:).<br>
    8   But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.';
     3$lang['Smilies set'] = 'Smilies set';
     4$lang['Smiley'] = 'Smiley';
     5$lang['Shortcuts'] = 'Shortcuts';
     6$lang['Columns'] = 'Columns';
     7$lang['Smilies'] = 'Smilies';
     8$lang['Edit shorcuts'] = 'Edit shorcuts';
     9$lang['If you change current set you will lost every shortcuts changes.'] = 'If you change current set you will lost every shortcuts changes.';
    910
    1011?>
  • extensions/SmiliesSupport/language/fr_FR/plugin.lang.php

    r11875 r23234  
    11<?php
    22
    3 $lang['Smileys\' folder'] = 'Dossier des smileys';
    4 $lang['Nb. columns'] = 'Nb. de colonnes';
    5 $lang['Representative'] = 'Représentant';
    6 $lang['All Smilies'] = 'Tous les smileys';
    7 $lang['smilies_file_help'] = 'Par défaut quand l\'utilisateur clique sur un smiley, Smilies Support ajoute un mot clef correspondant au nom du fichier (smile.png -> :smile:).<br>
    8   Mais vous pouvez configurer ici d\'autres chaînes de caractères qui seront remplacées. Chaque dossier de smileys a son propre fichier <i>smilies.txt</i>.';
     3$lang['Smilies set'] = 'Set de smileys';
     4$lang['Smiley'] = 'Smiley';
     5$lang['Shortcuts'] = 'Raccourcis';
     6$lang['Columns'] = 'Colonnes';
     7$lang['Smilies'] = 'Smileys';
     8$lang['Edit shorcuts'] = 'Modifier les raccouris';
     9$lang['If you change current set you will lost every shortcuts changes.'] = 'Si vous changez de set, vous perdrez les modifications des raccourcis.';
    910
    1011?>
  • extensions/SmiliesSupport/main.inc.php

    r23204 r23234  
    44Version: auto
    55Description: Allow add Smilies for comments and descriptions.
    6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=159
     6Plugin URI: auto
    77Author: Atadilo & P@t & Mistic
    88*/
     
    1010if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1111
    12 define('SMILIES_DIR',  basename(dirname(__FILE__)));
    13 define('SMILIES_PATH', PHPWG_PLUGINS_PATH . SMILIES_DIR . '/');
     12define('SMILIES_ID',   basename(dirname(__FILE__)));
     13define('SMILIES_PATH', PHPWG_PLUGINS_PATH . SMILIES_ID . '/');
     14define('SMILIES_DIR',  SMILIES_PATH . 'smilies/');
    1415
    15 include_once(SMILIES_PATH.'smiliessupport.inc.php');
     16include_once(SMILIES_PATH.'include/functions.inc.php');
     17include_once(SMILIES_PATH.'include/smiliessupport.inc.php');
    1618
     19add_event_handler('init', 'init_smiliessupport');
    1720add_event_handler('render_comment_content', 'SmiliesParse', 60);
    1821add_event_handler('render_contact_content', 'SmiliesParse');
    1922add_event_handler('loc_after_page_header', 'add_smiliessupport');
     23
     24
     25function init_smiliessupport()
     26{
     27  global $conf;
     28 
     29  $conf['smiliessupport'] = unserialize($conf['smiliessupport']);
     30  $conf['smiliessupport']['ext'] = array('gif', 'jpg', 'png', 'GIF', 'JPG', 'PNG');
     31 
     32  load_language('plugin.lang', SMILIES_PATH);
     33}
    2034
    2135function add_smiliessupport()
     
    5973{
    6074  add_event_handler('get_admin_plugin_menu_links', 'smiliessupport_admin_menu');
     75  add_event_handler('init', 'smiliessupport_get_list');
     76 
    6177  function smiliessupport_admin_menu($menu)
    6278  {
    6379    array_push($menu, array(
    6480      'NAME' => 'Smilies Support',
    65       'URL' => get_root_url().'admin.php?page=plugin-' . SMILIES_DIR
     81      'URL' => get_root_url().'admin.php?page=plugin-' . SMILIES_ID
    6682    ));
    6783    return $menu;
    6884  }
    6985}
     86
    7087?>
  • extensions/SmiliesSupport/smilies/crystal/smilies.txt

    r14526 r23234  
    1 :)              smile.png
    2 :-)             smile.png
    31:D              biggrin.png
    42:-D             biggrin.png
    5 ;)              wink.png
    6 ;-)             wink.png
     3:s              confused.png
     4:S              confused.png
     5;(              cry.png
     6;-(             cry.png
     7oO              eek.png
     8Oo              eek.png
     9OO              eek.png
     10<3              like.png
     11^^              lol.png
     12:|              neutral.png
     13:-|             neutral.png
    714:P              razz.png
    815:p              razz.png
     
    1118:(              sad.png
    1219:-(             sad.png
    13 ;(              cry.png
    14 ;-(             cry.png
    15 oO              eek.png
    16 Oo              eek.png
    17 OO              eek.png
     20:)              smile.png
     21:-)             smile.png
    1822:o              surprised.png
    1923:O              surprised.png
    2024:-o             surprised.png
    2125:-O             surprised.png
    22 :s              confused.png
    23 :S              confused.png
    24 :|              neutral.png
    25 :-|             neutral.png
    26 <3              like.png
    27 ^^              lol.png
     26;)              wink.png
     27;-)             wink.png
  • extensions/SmiliesSupport/smilies/ipb/smilies.txt

    r14526 r23234  
    1 :)              sourire.gif
    2 :-)             sourire.gif
    31:D              happy.gif
    42:-D             happy.gif
    5 ;)              wink.gif
    6 ;-)             wink.gif
    73:P              langue.gif
    84:p              langue.gif
    95:-p             langue.gif
    106:-P             langue.gif
    11 :(              triste.gif
    12 :-(             triste.gif
    13 ;(              pleure.gif
    14 ;-(             pleure.gif
    157oO              perplexe.gif
    168Oo              perplexe.gif
    179OO              perplexe.gif
     10;(              pleure.gif
     11;-(             pleure.gif
     12:)              sourire.gif
     13:-)             sourire.gif
    1814:o              surpris.gif
    1915:O              surpris.gif
    2016:-o             surpris.gif
    2117:-O             surpris.gif
     18:(              triste.gif
     19:-(             triste.gif
     20;)              wink.gif
     21;-)             wink.gif
    2222<3              wub.gif
  • extensions/SmiliesSupport/smilies/sylvia/smilies.txt

    r14526 r23234  
    1 :)              smile.png
    2 :-)             smile.png
    31:D              biggrin.png
    42:-D             biggrin.png
    5 ;)              wink.png
    6 ;-)             wink.png
     3:s              confused.png
     4:S              confused.png
     5;(              cry.png
     6;-(             cry.png
     7oO              eek.png
     8Oo              eek.png
     9OO              eek.png
     10:|              neutral.png
     11:-|             neutral.png
    712:P              razz.png
    813:p              razz.png
     
    1116:(              sad.png
    1217:-(             sad.png
    13 ;(              cry.png
    14 ;-(             cry.png
    15 oO              eek.png
    16 Oo              eek.png
    17 OO              eek.png
     18:)              smile.png
     19:-)             smile.png
    1820:o              surprised.png
    1921:O              surprised.png
    2022:-o             surprised.png
    2123:-O             surprised.png
    22 :s              confused.png
    23 :S              confused.png
    24 :|              neutral.png
    25 :-|             neutral.png
     24;)              wink.png
     25;-)             wink.png
  • extensions/SmiliesSupport/template/smiliessupport_admin.tpl

    r15110 r23234  
    1 {combine_script id='jquery.cluetip' require='jquery' path='themes/default/js/plugins/jquery.cluetip.js'}
    2 {include file='include/autosize.inc.tpl'}
     1{combine_script id='jquery.tokeninput' load='footer' path='themes/default/js/plugins/jquery.tokeninput.js'}
     2{combine_css path=$SMILIES_PATH|cat:'template/style.css'}
    33
    4 {footer_script require="jquery.cluetip"}{literal}
    5   jQuery('.cluetip').cluetip({
    6     width: 550,
    7     splitTitle: '|'
    8   });
     4
     5{footer_script}{literal}
     6var data = {};
     7var edit = false;
     8var edited = false;
     9
     10// set changed
     11jQuery("select[name='folder']").change(function() {
     12    if (edited) {
     13        var ok = confirm("{/literal}{'If you change current set you will lost every shortcuts changes.'|@translate}{literal}");
     14        if (!ok) {
     15            jQuery(this).val(jQuery(this).data("selected"));
     16            return false;
     17        }
     18    }
     19   
     20    var image = jQuery(this).find(":selected").css("background-image");
     21    jQuery(this).css("background-image", image);
     22    jQuery(this).data("selected", jQuery(this).val());
     23   
     24    fetch();
     25});
     26
     27// size changed
     28jQuery("input[name='cols']").change(function() {
     29    update();
     30});
     31
     32// switch preview/edit
     33jQuery(".edit").click(function() {
     34    if (edit) {
     35        $(this).html("{/literal}{'Edit shorcuts'|@translate}{literal}");
     36    }
     37    else {
     38        $(this).html("{/literal}{'Preview'|@translate}{literal}");
     39    }
     40   
     41    edit = !edit;
     42    update();
     43    return false;
     44});
     45
     46// display edit form before submit
     47jQuery("#smiliesupport").submit(function() {
     48    if (!edit) jQuery(".edit").click();
     49    return true;
     50});
     51
     52/* get smilies list */
     53function fetch() {
     54    jQuery.ajax({
     55        url: 'admin.php',
     56        type: 'GET',
     57        dataType: 'json',
     58        data: {
     59            action: 'ss_preview',
     60            folder: jQuery("select[name='folder']").val(),
     61        },
     62        success: function(result) {
     63            data = result;
     64            edited = false;
     65            update();
     66        }
     67    });
     68}
     69
     70/* update preview/edit table */
     71function update() {
     72    var html = '';
     73   
     74    if (!edit) {
     75        html+= '<tr>';
     76        var cols = parseInt(jQuery("input[name='cols']").val());
     77        var i=0;
     78       
     79        for (var file in data.smilies) {
     80            var smiley = data.smilies[file];
     81            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>';
     83            i++;
     84        }
     85       
     86        html+= '</tr>';
     87    }
     88    else {
     89    {/literal}
     90        html+= '<tr>'
     91            +'<th>{'Smiley'|@translate}</th>'
     92            +'<th>{'Name'|@translate}</th>'
     93            +'<th>{'Shortcuts'|@translate}</th>'
     94          +'</tr>';
     95     {literal}
     96     
     97        for (var file in data.smilies) {
     98            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">';
     104               
     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        }
     113    }
     114   
     115    jQuery("#preview").html(html);
     116   
     117    // init tokeninput
     118    jQuery(".shortcuts").tokenInput([], {
     119        hintText: '{/literal}{'Type in a new shortcut'|@translate}{literal}',
     120        newText: '',
     121        animateDropdown: false,
     122        preventDuplicates: true,
     123        caseSensitive: true,
     124        allowCreation: true,
     125        minChars: 2,
     126        searchDelay: 10,
     127       
     128        onAdd: function(item) {
     129            edited = true;
     130            var file = $(this).parents("tr").data("file");
     131           
     132            if (data.smilies[file].short == null) {
     133                data.smilies[file].short = [item.name];
     134            }
     135            else {
     136                data.smilies[file].short.push(item.name);
     137            }
     138        },
     139        onDelete: function(item) {
     140          edited = true;
     141          var file = $(this).parents("tr").data("file");
     142         
     143          for (var i in data.smilies[file].short) {
     144              if (data.smilies[file].short[i] == item.name) {
     145                  data.smilies[file].short.splice(i, 1);
     146              }
     147          }
     148        },
     149    });
     150   
     151    // prevent spaces
     152    jQuery(".token-input-input-token input").keydown(function(e) {
     153        if (e.keyCode == 32) {
     154            return false;
     155        }
     156    });
     157}
     158
     159// init
     160fetch();
    9161{/literal}{/footer_script}
    10162
    11 {html_head}
    12 <style type="text/css">
    13   legend .cluetip {ldelim}
    14     text-align:center;
    15     margin:20px 0 -10px 0;
    16     font-size:1.2em;
    17   }
    18   .cluetip:after {ldelim}
    19     margin-left:5px;
    20     vertical-align:top;
    21     content:url('{$themeconf.admin_icon_dir}/help.png');
    22   }
    23   .properties textarea {ldelim}
    24     width:60%;
    25     margin:0 20%;
    26   }
    27 </style>
    28 {/html_head}
    29163
    30164<div class="titrePage">
     
    32166</div>
    33167
    34 <form method="post" action="" class="properties">
    35   <fieldset>
    36       <legend>{'Configuration'|@translate}</legend>   
    37     <ul>     
     168<form method="post" action="" class="properties" id="smiliesupport">
     169
     170<fieldset>
     171  <legend>{'Configuration'|@translate}</legend> 
     172 
     173  <ul>     
    38174    <li>
    39       <span class="property">{'Smileys\' folder'|@translate}</span>
    40       <select name="folder">
    41         {html_options options=$sets selected=$FOLDER}
     175      <b>{'Smilies set'|@translate}</b>
     176      <select name="folder" style="background-image:url('{$SMILIES_PATH}smilies/{$FOLDER}/{$SETS[$FOLDER]}');" data-selected="{$FOLDER}">
     177      {foreach from=$SETS item=rep key=set}
     178        <option value="{$set}" style="background-image:url('{$SMILIES_PATH}smilies/{$set}/{$rep}');" {if $set==$FOLDER}selected{/if}>{$set}</option>
     179      {/foreach}
    42180      </select>
    43181    </li>
    44182    <li>
    45       <span class="property">{'Nb. columns'|@translate}</span>
    46       <input type="text" size="3" name="cols" value="{$COLS}" />
    47     </li>   
    48     <li>
    49       <span class="property">{'Representative'|@translate}</span>
    50       <select name="representant">
    51         {html_options options=$smilies selected=$REPRESENTANT}
    52       </select>
     183      <b>{'Columns'|@translate}</b>
     184      <input type="text" size="2" name="cols" value="{$COLS}">
    53185    </li>
    54     <li>
    55       <table><tr>
    56       {foreach from=$smiliesfiles item=smileyfile}
    57         <td><a href="#" title="{$smileyfile.TITLE}"><img src="{$smileyfile.PATH}"/></a></td>
    58         {$smileyfile.TR}
    59       {/foreach}
    60       </tr></table>
    61     </li>
    62     </ul>
    63   </fieldset>
     186  </ul>
     187</fieldset>
     188
     189<fieldset>
     190  <legend>{'Preview'|@translate}</legend> 
     191  <a href="#" class="edit buttonLike">{'Edit shorcuts'|@translate}</a>
     192  <table id="preview"></table>
     193</fieldset>
    64194 
    65   <fieldset>
    66     <legend><span class="cluetip" title="smilies.txt|{'smilies_file_help'|@translate}">smilies.txt</legend>
    67     <textarea rows="5" name="text">{$CONTENT_FILE}</textarea>
    68   </fieldset> 
    69  
    70   <p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p>
     195<p class="formButtons"><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p>
     196
    71197</form>
  • extensions/SmiliesSupport/template/smiliessupport_page.tpl

    r23204 r23234  
    44{/if}
    55
    6 {footer_script require='jquery'}
    7 {literal}
     6{footer_script require='jquery'}{literal}
    87if (jQuery('.markItUp').length == 0) {
    98  jQuery('#{/literal}{$SMILIES_ID}{literal}').markItUp({markupSet: []});
     
    2827  return false;
    2928});
    30 {/literal}
    31 {/footer_script}
     29{/literal}{/footer_script}
     30
     31{html_style}{literal}
     32#smiliesdiv table a { width:auto; height:auto; }
     33{/literal}{/html_style}
    3234
    3335<ul style="display:none;">
    3436<li id="SmiliesSupport" class="markItUpButton markItUpDropMenu">
    35   <a id="allsmilies" style="background-image:url('{$ROOT_URL}{$REPRESENTANT}');" title="{'All Smilies'|@translate}"></a>
     37  <a id="allsmilies" style="background-image:url('{$ROOT_URL}{$REPRESENTANT}');" title="{'Smilies'|@translate}"></a>
    3638
    3739  <ul id="smiliesdiv">
Note: See TracChangeset for help on using the changeset viewer.