Index: /extensions/SmiliesSupport/admin.php
===================================================================
--- /extensions/SmiliesSupport/admin.php	(revision 23233)
+++ /extensions/SmiliesSupport/admin.php	(revision 23234)
@@ -2,119 +2,90 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
+include_once(SMILIES_PATH.'include/functions.inc.php');
+
 global $conf, $template;
-load_language('plugin.lang', SMILIES_PATH);
-
-if (strpos($conf['smiliessupport'],',') !== false)
-{
-  include(SMILIES_PATH .'maintain.inc.php');
-  plugin_activate();
-}
-
-$conf_smiliessupport = unserialize($conf['smiliessupport']);
-
-// Enregistrement de la configuration
-if (isset($_POST['submit']))
-{
-  // the smilies.txt file is not saved if the directory is changed
-  if (isset($_POST['folder']) AND $_POST['folder'] != $conf_smiliessupport['folder']) 
-  {
-    $not_save_file = true;
-    
-    if (!file_exists(SMILIES_PATH.'smilies/'.$_POST['folder'].'/'.$_POST['representant']))
-    {
-      $handle = opendir(SMILIES_PATH.'smilies/'.$_POST['folder']);
-      $i = 0;
-      while (false !== ($file = readdir($handle)))
-      {
-        if ( $file != '.' AND $file != '..' AND in_array(get_extension($file), array('gif', 'jpg', 'png')) )
-        {
-          $_POST['representant'] = $file;
-          closedir($handle);
-          break;
-        }
-      }
-    }
-  }
-  
-  // new configuration
-  $conf_smiliessupport = array(
-    'folder' => isset($_POST['folder']) ? $_POST['folder'] : 'crystal',
-    'cols' => isset($_POST['cols']) ? $_POST['cols'] : '6',
-    'representant' => isset($_POST['representant']) ? $_POST['representant'] : 'smile.png',
-  );
-  if (empty($_POST['text'])) $_POST['text'] = '';
-    
-  conf_update_param('smiliessupport', serialize($conf_smiliessupport));
-  array_push($page['infos'], l10n('Information data registered in database'));
-  
-  // new definitions file
-  if (!isset($not_save_file)) 
-  {
-    $smilies_file = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt';      
-
-    if (file_exists($smilies_file)) {
-      @copy($smilies_file, get_filename_wo_extension($smilies_file).'.bak');
-    }
-    
-    if (@!file_put_contents($smilies_file, stripslashes($_POST['text']))) {  
-      array_push($page['errors'], l10n('File/directory read error').' : '.$smilies_file);
-    }
-  }
-}
-
-// check if the representant exists
-if (!file_exists(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$conf_smiliessupport['representant'])) {
-  array_push($page['errors'], l10n('File/directory read error').' : smilies/'.$conf_smiliessupport['folder'].'/'.$conf_smiliessupport['representant']);
-}
 
 // get available sets
 $sets = array();
-$handle = opendir(SMILIES_PATH.'smilies/');
-while (false !== ($file = readdir($handle)))
+$handle = opendir(SMILIES_DIR);
+while (false !== ($folder = readdir($handle)))
 { 
-  if ( $file != '.' && $file != '..' && is_dir(SMILIES_PATH.'smilies/'.$file) )
+  if ( $folder != '.' && $folder != '..' && is_dir(SMILIES_DIR.$folder) )
   {
-    $sets[$file] = $file;
+    if (file_exists(SMILIES_DIR.$folder.'/representant.txt'))
+    {
+      $sets[$folder] = file_get_contents(SMILIES_DIR.$folder.'/representant.txt');
+    }
+    else
+    {
+      $sets[$folder] = get_first_file(SMILIES_DIR.$folder, $conf['smiliessupport']['ext']);
+    }
   }
 }
 closedir($handle);
 
-// get available smilies
-$smilies_table = $smilies = array();
-$handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder']);
-$i = 1;
-while (false !== ($file = readdir($handle)))
+
+// save configuration
+if (isset($_POST['submit']))
 {
-  if ( $file != '.' AND $file != '..' AND in_array(get_extension($file), array('gif', 'jpg', 'png')) )
+  // new configuration
+  $conf['smiliessupport'] = array(
+    'folder' =>       $_POST['folder'],
+    'cols' =>         preg_match('#^([0-9]+)$#', $_POST['cols']) ? $_POST['cols'] : 6,
+    'representant' => $sets[ $_POST['folder'] ],
+  );
+  
+  conf_update_param('smiliessupport', serialize($conf['smiliessupport']));
+  array_push($page['infos'], l10n('Information data registered in database'));
+  
+  // shortcuts file
+  $used = array();
+  $content = null;
+  
+  foreach ($_POST['shortcuts'] as $file => $data)
   {
-    $smilies[$file] = $file;
-    $smilies_table[] = array(
-      'PATH' => SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$file,
-      'TITLE' => ':'.get_filename_wo_extension($file).':',
-      'TR' => ($i>0 AND $i%$conf_smiliessupport['cols'] == 0) ? '</tr><tr>' : null,
-    );
-    $i++;
+    if (empty($data)) continue;
+    
+    $data = explode(',', stripslashes($data));
+    foreach ($data as $short)
+    {
+      if (array_key_exists($short, $used))
+      {
+        $page['errors'][] = sprintf(
+                              l10n('<i>%s</i>, shortcut &laquo; %s &raquo; already used for <i>%s</i>'),
+                              get_filename_wo_extension($file),
+                              $short,
+                              get_filename_wo_extension($used[ $short ])
+                              );
+      }
+      else
+      {
+        $used[ $short ] = $file;
+        $content.= $short."\t\t".$file."\n";
+      }
+    }
+  }
+
+  if (file_exists(SMILIES_DIR.$_POST['folder'].'/smilies.txt'))
+  {
+    @copy(SMILIES_DIR.$_POST['folder'].'/smilies.txt', SMILIES_DIR.$_POST['folder'].'/smilies.bak');
+  }
+  
+  if (@!file_put_contents(SMILIES_DIR.$_POST['folder'].'/smilies.txt', $content))
+  {  
+    $page['errors'][] = l10n('File/directory read error').' : '.SMILIES_DIR.$_POST['folder'].'/smilies.txt';
   }
 }
-closedir($handle);
 
+
+// template
 $template->assign(array(
-  'FOLDER' => $conf_smiliessupport['folder'],
-  'COLS' => $conf_smiliessupport['cols'],
-  'REPRESENTANT' => $conf_smiliessupport['representant'],
-  'sets' => $sets,
-  'smiliesfiles' => $smilies_table,
-  'smilies' => $smilies,
+  'FOLDER' =>       $conf['smiliessupport']['folder'],
+  'COLS' =>         $conf['smiliessupport']['cols'],
+  'SETS' =>         $sets,
+  'SMILIES_PATH' => SMILIES_PATH,
 ));
 
-// get the content of definitions file
-$smilies_file = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt';
-if (file_exists($smilies_file))
-{
-  $content_file = file_get_contents($smilies_file);
-  $template->assign(array('CONTENT_FILE' => $content_file));
-}
-  
-$template->assign('SMILIES_PATH', SMILIES_PATH);
+
 $template->set_filename('smiliessupport_conf', dirname(__FILE__).'/template/smiliessupport_admin.tpl');
 $template->assign_var_from_handle('ADMIN_CONTENT', 'smiliessupport_conf');
Index: /extensions/SmiliesSupport/include/functions.inc.php
===================================================================
--- /extensions/SmiliesSupport/include/functions.inc.php	(revision 23234)
+++ /extensions/SmiliesSupport/include/functions.inc.php	(revision 23234)
@@ -0,0 +1,57 @@
+<?php
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+function get_first_file($path, $ext=null)
+{
+  $path  = rtrim($path, '/').'/';
+  $handle = opendir($path);
+  
+  while ( false !== ($file=readdir($handle)) )
+  {
+    if ( $file!='.' && $file!='..' && is_file($path.$file) && (!is_array($ext) || in_array(get_extension($file), $ext)) )
+    {
+      closedir($handle);
+      return $file;
+    }
+  }
+  
+  closedir($handle);
+  return null;
+}
+
+function smiliessupport_get_list()
+{
+  if (!isset($_GET['action']) || $_GET['action']!='ss_preview') return;
+  
+  global $conf;
+  
+  $folder = SMILIES_DIR . ltrim($_GET['folder'], '/') . '/';
+  
+  $short = array();
+  if (file_exists($folder.'smilies.txt'))
+  {
+    foreach (file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES) as $v)
+    {
+      if (preg_match('#^([^\s]+)[\s]+(.+)$#', trim($v), $matches)) 
+      {
+        $short[ $matches[2] ][] = $matches[1];
+      }
+    }
+  }
+
+  $smilies = array();
+  $handle = opendir($folder);
+  while (false !== ($file = readdir($handle)))
+  {
+    if ( $file != '.' && $file != '..' && in_array(get_extension($file), $conf['smiliessupport']['ext']) )
+    {
+      $smilies[$file] = array('title'=>':'.get_filename_wo_extension($file).':', 'file'=>$file, 'short'=>@$short[$file]);
+    }
+  }
+  closedir($handle);
+  
+  echo json_encode(array('path'=>$folder, 'smilies'=>$smilies));
+  exit;
+}
+
+?>
Index: /extensions/SmiliesSupport/include/index.php
===================================================================
--- /extensions/SmiliesSupport/include/index.php	(revision 23234)
+++ /extensions/SmiliesSupport/include/index.php	(revision 23234)
@@ -0,0 +1,7 @@
+<?php
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/SmiliesSupport/include/smiliessupport.inc.php
===================================================================
--- /extensions/SmiliesSupport/include/smiliessupport.inc.php	(revision 23234)
+++ /extensions/SmiliesSupport/include/smiliessupport.inc.php	(revision 23234)
@@ -0,0 +1,99 @@
+<?php
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+// add smilies button to the comment field
+function set_smiliessupport($prefilter='picture', $textarea_id='contentid')
+{
+  global $conf, $template;
+
+  $template->assign(array(
+    'SMILIES_PATH' => SMILIES_PATH,
+    'SMILIES_ID' =>   $textarea_id,
+    'REPRESENTANT' => SMILIES_DIR.$conf['smiliessupport']['folder'].'/'.$conf['smiliessupport']['representant'],
+    'smiliesfiles' => get_smilies(),
+  ));
+  
+  $template->set_prefilter($prefilter, 'set_smiliessupport_prefilter');  
+}
+
+function set_smiliessupport_prefilter($content, &$smarty)
+{
+  $search = '#(<div id="guestbookAdd">|<div id="commentAdd">|<div class="contact">)#';
+  $replace = file_get_contents(SMILIES_PATH.'/template/smiliessupport_page.tpl').'$1';
+  return preg_replace($search, $replace, $content);
+}
+
+// return an array with available smilies (name and path)
+function get_smilies()
+{
+  global $conf;
+  
+  if ($handle = opendir(SMILIES_DIR.$conf['smiliessupport']['folder']))
+  {
+    $i = 1;
+    while (false !== ($file = readdir($handle)))
+    {
+      if ($file != '.' and $file != '..' and in_array(get_extension($file), $conf['smiliessupport']['ext']))
+      {
+        $smilies[] = array(
+          'PATH' => SMILIES_DIR.$conf['smiliessupport']['folder'].'/'.$file,
+          'TITLE' => ':'.get_filename_wo_extension($file).':',
+          'TR' => ($i>0 and $i%$conf['smiliessupport']['cols'] == 0) ? '</tr><tr>' : null,
+        );
+        $i++;
+      }
+    }
+    
+    closedir($handle);
+    return $smilies;
+  } 
+  else 
+  {
+    return false;
+  }
+}
+
+// parse smilies
+function SmiliesParse($str)
+{
+  global $conf;
+  
+  $root_path = get_absolute_root_url();
+  $folder = SMILIES_DIR.$conf['smiliessupport']['folder'].'/';
+  $str = ' '.$str;
+  
+  if ($handle = opendir($folder))
+  {
+    while (false !== ($file = readdir($handle)))
+    { 
+      if ($file != "." && $file != ".." && in_array(get_extension($file), $conf['smiliessupport']['ext'])) 
+      {
+        $filename = get_filename_wo_extension($file);
+        $v = ':'.$filename.':'; 
+        $s = '<img src="'.$root_path.$folder.$file.'" alt=":'.$filename.':"/>';
+        $str = str_replace($v, $s, $str);
+      }
+    }
+    
+    closedir($handle);
+  }
+  
+  if (file_exists($folder.'smilies.txt'))
+  {
+    foreach (file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES) as $v)
+    {
+      $v = trim($v);
+      if (preg_match('#^([^\s]+)[\s]+(.+)$#', $v, $matches)) 
+      {  
+        $filename = get_filename_wo_extension($matches[2]);
+        $v = '#([^"])'.preg_quote($matches[1],'/').'#';          
+        $t = '$1<img src="'.$root_path.$folder.$matches[2].'" alt=":'.$filename.':"/>';
+        $str = preg_replace($v, $t, $str);
+      }
+    }
+  } 
+  
+  return trim($str);
+}
+
+?>
Index: tensions/SmiliesSupport/language/ar_SA/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/ar_SA/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'مجلد الوجوه التعبيرية';
-$lang['Nb. columns'] = 'عدد الاعمدة';
-$lang['Representative'] = 'ممثل';
-$lang['All Smilies'] = 'كل الوجوه التعبيرية';
-$lang['smilies_file_help'] = 'افتراضيا عندما ينقر المستخدم على  الوجوه التعبيرية، دعم الوجوه التعبيرية يضيف مطابقة الكلمات لاسم الملف (smile.png -> :smile:).<br>
-  ولكن هنا يمكنك تكوين كلمات أخرى لتحل محلها. كل الوجوه التعبيرية في مجلد لها خاصيتها<i>smilies.txt</i> file.';
-
-?>
Index: tensions/SmiliesSupport/language/bg_BG/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/bg_BG/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,29 +1,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Piwigo - a PHP based photo gallery                                    |
-// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team                  http://piwigo.org |
-// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
-// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify  |
-// | it under the terms of the GNU General Public License as published by  |
-// | the Free Software Foundation                                          |
-// |                                                                       |
-// | This program is distributed in the hope that it will be useful, but   |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-// | General Public License for more details.                              |
-// |                                                                       |
-// | You should have received a copy of the GNU General Public License     |
-// | along with this program; if not, write to the Free Software           |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA.                                                                  |
-// +-----------------------------------------------------------------------+
-$lang['smilies_file_help'] = 'По подразбиране когато потребител натисне на усмивка, плъгина добавя съответната дума отговаряща на този файл (smile.png -> :smile:)<br> 
- Но тук вие може да добавяте или променяте стрингове. Всяка усмивка има собствен <i>smilies.txt</i> файл.';
-$lang['Smileys\' folder'] = 'Папка със усмивки';
-$lang['Representative'] = 'Представен';
-$lang['Nb. columns'] = 'Брой колони';
-$lang['All Smilies'] = 'Добави усмивки';
-?>
Index: tensions/SmiliesSupport/language/ca_ES/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/ca_ES/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,29 +1,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Piwigo - a PHP based photo gallery                                    |
-// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
-// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
-// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify  |
-// | it under the terms of the GNU General Public License as published by  |
-// | the Free Software Foundation                                          |
-// |                                                                       |
-// | This program is distributed in the hope that it will be useful, but   |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-// | General Public License for more details.                              |
-// |                                                                       |
-// | You should have received a copy of the GNU General Public License     |
-// | along with this program; if not, write to the Free Software           |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA.                                                                  |
-// +-----------------------------------------------------------------------+
-$lang['All Smilies'] = 'Tots els emoticons';
-$lang['Nb. columns'] = 'Mb. Columnes';
-$lang['Representative'] = 'Representatiu';
-$lang['Smileys\' folder'] = 'Carpeta d\'emoticons';
-$lang['smilies_file_help'] = 'Per defecte, quan un usuari fa clic a una emoticona, el Suport d\'Emoticones afegeix una paraula clau que coincideixi amb el nom de l\'arxiu (smile.png -> :smile:).<br>
-Però aquí es pot ajustar el reemplaçament de diverses cadenes. Cada carpeta d\'emoticones té el seu arxiu propi <i>smilies.txt</i>.';
-?>
Index: tensions/SmiliesSupport/language/cs_CZ/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/cs_CZ/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Smileys\' složka';
-$lang['Nb. columns'] = 'Nb. sloupců';
-$lang['Representative'] = 'Vzor';
-$lang['All Smilies'] = 'Všechny Smajlíci';
-$lang['smilies_file_help'] = 'jako výchozí je když uživatel klikne na smajlík, Podpora Smajlíků vloží klíčové slovo udávající význam podle názvu souboru (smile.png -> :smile:).<br>
-  Ale lze také nastavit jiné popisy k nahrazení stávajících. Každá složka se smajlíky ma vlastní <i>smilies.txt</i> soubor.';
-
-?>
Index: tensions/SmiliesSupport/language/da_DK/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/da_DK/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,29 +1,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Piwigo - a PHP based photo gallery                                    |
-// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
-// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
-// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify  |
-// | it under the terms of the GNU General Public License as published by  |
-// | the Free Software Foundation                                          |
-// |                                                                       |
-// | This program is distributed in the hope that it will be useful, but   |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-// | General Public License for more details.                              |
-// |                                                                       |
-// | You should have received a copy of the GNU General Public License     |
-// | along with this program; if not, write to the Free Software           |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA.                                                                  |
-// +-----------------------------------------------------------------------+
-$lang['All Smilies'] = 'Alle smilies';
-$lang['Nb. columns'] = 'Antal kolonner';
-$lang['Representative'] = 'Repræsentant';
-$lang['Smileys\' folder'] = 'Smiley-mappe';
-$lang['smilies_file_help'] = 'Som standard, når en bruger klikker på en smiley, tilføjer Smilies Support et nøgleord, som svarer til navnet på filen (smile.png -> :smile:).<br>
-Men her kan man opsætte andre erstatningsstrenge.  Hver smilies-mappe har sin egen <i>smilies.txt</i>-fil.';
-?>
Index: tensions/SmiliesSupport/language/de_DE/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/de_DE/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Smilies Ordner';
-$lang['Nb. columns'] = 'Anz. Spalten';
-$lang['Representative'] = 'Repräsentative';
-$lang['All Smilies'] = 'Alle Smilies';
-$lang['smilies_file_help'] = 'Standardmäßig fügt Smilies Support ein dem Dateinamen entsprechendes Schlüsselwort (smile.png -> :smile:) ein, wenn ein Benutzer auf einen Smiley klickt.<br>
-  Hier können Sie jedoch andere Wörter angeben, die ersetzt werden sollen. Jeder Smilies Ordner verfügt über eine eigene <i>smilies.txt</i> Datei.';
-
-?>
Index: tensions/SmiliesSupport/language/el_GR/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/el_GR/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,29 +1,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Piwigo - a PHP based photo gallery                                    |
-// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
-// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
-// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify  |
-// | it under the terms of the GNU General Public License as published by  |
-// | the Free Software Foundation                                          |
-// |                                                                       |
-// | This program is distributed in the hope that it will be useful, but   |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-// | General Public License for more details.                              |
-// |                                                                       |
-// | You should have received a copy of the GNU General Public License     |
-// | along with this program; if not, write to the Free Software           |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA.                                                                  |
-// +-----------------------------------------------------------------------+
-$lang['All Smilies'] = 'Όλα τα Smilies';
-$lang['Nb. columns'] = 'Αριθμός Στηλών';
-$lang['Representative'] = 'Εκπρόσωπος';
-$lang['Smileys\' folder'] = 'Κατάλογος Smiley';
-$lang['smilies_file_help'] = 'Από προεπιλογή, όταν ένας χρήστης κάνει κλικ σε ένα Smiley, H Υποστήριξη Smilies  προσθέτει μια λέξη-κλειδί που ταιριάζει με το όνομα του αρχείου (smile.png ->:smile:).<br>
-   Αλλά εδώ μπορείτε να ρυθμίσετε άλλη συμβολοσειρά για να αντικατασταθεί. Κάθε κατάλογος smilies έχει το δικό του <i>smilies.txt</i> αρχείο.';
-?>
Index: /extensions/SmiliesSupport/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/en_UK/plugin.lang.php	(revision 23233)
+++ /extensions/SmiliesSupport/language/en_UK/plugin.lang.php	(revision 23234)
@@ -1,10 +1,11 @@
 <?php
 
-$lang['Smileys\' folder'] = 'Smileys\' folder';
-$lang['Nb. columns'] = 'Nb. columns';
-$lang['Representative'] = 'Representative';
-$lang['All Smilies'] = 'All Smilies';
-$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>
-  But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.';
+$lang['Smilies set'] = 'Smilies set';
+$lang['Smiley'] = 'Smiley';
+$lang['Shortcuts'] = 'Shortcuts';
+$lang['Columns'] = 'Columns';
+$lang['Smilies'] = 'Smilies';
+$lang['Edit shorcuts'] = 'Edit shorcuts';
+$lang['If you change current set you will lost every shortcuts changes.'] = 'If you change current set you will lost every shortcuts changes.';
 
 ?>
Index: tensions/SmiliesSupport/language/es_ES/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/es_ES/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Portapapeles de los smileys';
-$lang['Nb. columns'] = 'Núm. de columnas';
-$lang['Representative'] = 'Representativee';
-$lang['All Smilies'] ='Todos los smileys';
-$lang['smilies_file_help'] = 'Sin instrucción cuando el usuario hace clic en un smiley, Smilies Support añade una palabra clave correspondiendo con el nombre del   archivo (smile.png -> :smile:).<br>
- Pero puede Vd configurar aquí otras cadenas de caracteres que serán sustituídas. Cada  portapapeles de smileys tiene su propio archivo  <i>smilies.txt</i>.';
-
-?>
Index: /extensions/SmiliesSupport/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/fr_FR/plugin.lang.php	(revision 23233)
+++ /extensions/SmiliesSupport/language/fr_FR/plugin.lang.php	(revision 23234)
@@ -1,10 +1,11 @@
 <?php
 
-$lang['Smileys\' folder'] = 'Dossier des smileys';
-$lang['Nb. columns'] = 'Nb. de colonnes';
-$lang['Representative'] = 'Représentant';
-$lang['All Smilies'] = 'Tous les smileys';
-$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>
-  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>.';
+$lang['Smilies set'] = 'Set de smileys';
+$lang['Smiley'] = 'Smiley';
+$lang['Shortcuts'] = 'Raccourcis';
+$lang['Columns'] = 'Colonnes';
+$lang['Smilies'] = 'Smileys';
+$lang['Edit shorcuts'] = 'Modifier les raccouris';
+$lang['If you change current set you will lost every shortcuts changes.'] = 'Si vous changez de set, vous perdrez les modifications des raccourcis.';
 
 ?>
Index: tensions/SmiliesSupport/language/hu_HU/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/hu_HU/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Hangulatjel készlet';
-$lang['Nb. columns'] = 'Oszlopok száma';
-$lang['Representative'] = 'Képviselő';
-$lang['All Smilies'] = 'Összes hangulatjel';
-$lang['smilies_file_help'] = 'Alapértelmezésben, amikor egy felhasználó rákattint egy hangulatjelre, a Smilies Support hozzáad egy kulcsszóegyezőséget a fájl nevéhez. (smile.png -> :smile:).<br>
-  Lehetőség van beállítani másik stringet a kicseréléséhez. Minden egyes hangulatjel könyvtár rendelkezik egy saját <i>smilies.txt</i> fájllal.';
-
-?>
Index: tensions/SmiliesSupport/language/it_IT/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/it_IT/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Cartella degli smileys';
-$lang['Nb. columns'] = 'Num. di colonne';
-$lang['Representative'] = 'Rappresentante';
-$lang['All Smilies'] = 'Tutti gli smiley';
-$lang['smilies_file_help'] = 'Di default, quando un utente clicca su uno smiley, SmiliesSupport aggiunge una keyword corrispondente al nome del file (smile.png -> :smile:).<br>
-  Ma potete configurare qui altre serie di caratteri che saranno rimpiazzate. Ogni cartella di smileys ha il suo file <i>smilies.txt</i>';
-
-?>
Index: tensions/SmiliesSupport/language/lv_LV/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/lv_LV/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Smailinu mape';
-$lang['Nb. columns'] = 'Nb. kolonas';
-$lang['Representative'] = 'Parstavošs';
-$lang['All Smilies'] = 'Visi Smailini';
-$lang['smilies_file_help'] = 'Pēc noklusēšanas, ja klikšķiniet uz smaidiņa, Smaidiņu Atbalsts (Smilies Support) pievieno ar faila (smile.png -> :smile:) nosaukumu sakrītošu atslēgvārdu.<br>
-  Ir iespējams nokonfigurēt arī citus variantus. Katrai smailiju mapei ir pašai savs <i>smilies.txt</i> fails.';
-
-?>
Index: tensions/SmiliesSupport/language/nb_NO/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/nb_NO/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Smileys\' folder';
-$lang['Nb. columns'] = 'Nb. columns';
-$lang['Representative'] = 'Representative';
-$lang['All Smilies'] = 'All Smilies';
-$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>
-  But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.';
-
-?>
Index: tensions/SmiliesSupport/language/nl_NL/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/nl_NL/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,9 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Smiley\'s map';
-$lang['Nb. columns'] = 'Nb. kolommen';
-$lang['Representative'] = 'Representatieve';
-$lang['All Smilies'] = 'Alle Smileys';
-$lang['smilies_file_help'] = 'Als een gebruiker op een smiley klikt, voegt de Smilies Support standaard een trefwoord toe die overeenkomt met de naam van het bestand (smile.png -> :smile:). <br>
-  Maar hier kan je andere trefwoorden instellen. Elke smiley map heeft zijn eigen <i>smilies.txt</i> bestand.';
-?>
Index: tensions/SmiliesSupport/language/pl_PL/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/pl_PL/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Folder z emotikonami';
-$lang['Nb. columns'] = 'Liczba kolumn'; 
-$lang['Representative'] = 'Reprezentant';
-$lang['All Smilies'] = 'Wszystkie emotikony';
-$lang['smilies_file_help'] = 'Domyślnie, gdy użytkownik kliknie w emotikon, Smilies Support doda słowo kluczowe odpowiadające nazwie danego pliku z emotikonem (smile.png -> :smile:). <br>
-  Jednak w tym miejscu możesz także skonfigurować inne ciągi znaków. Każdy folder z emotikonami ma swój własny <i>smilies.txt</i> plik ';
-
-?>
Index: tensions/SmiliesSupport/language/pt_BR/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/pt_BR/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,29 +1,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Piwigo - a PHP based photo gallery                                    |
-// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team                  http://piwigo.org |
-// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
-// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify  |
-// | it under the terms of the GNU General Public License as published by  |
-// | the Free Software Foundation                                          |
-// |                                                                       |
-// | This program is distributed in the hope that it will be useful, but   |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-// | General Public License for more details.                              |
-// |                                                                       |
-// | You should have received a copy of the GNU General Public License     |
-// | along with this program; if not, write to the Free Software           |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA.                                                                  |
-// +-----------------------------------------------------------------------+
-$lang['All Smilies'] = 'Todos os Smilies';
-$lang['Nb. columns'] = 'Nu. colunas';
-$lang['Representative'] = 'Representante';
-$lang['Smileys\' folder'] = 'Pasta de smileys';
-$lang['smilies_file_help'] = 'Por padrão, quando um usuário clica em um smiley, Suporte Smilies acrescenta uma palavra-chave correspondente ao nome do arquivo (smile.png ->:smile:).<br>
-Mas aqui você pode configurar outras strings para serem substituídas. Cada pasta de arquivo tem seus próprios arquivos <i>smilies.txt</i>.';
-?>
Index: tensions/SmiliesSupport/language/pt_PT/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/pt_PT/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,29 +1,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Piwigo - a PHP based photo gallery                                    |
-// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
-// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
-// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify  |
-// | it under the terms of the GNU General Public License as published by  |
-// | the Free Software Foundation                                          |
-// |                                                                       |
-// | This program is distributed in the hope that it will be useful, but   |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-// | General Public License for more details.                              |
-// |                                                                       |
-// | You should have received a copy of the GNU General Public License     |
-// | along with this program; if not, write to the Free Software           |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA.                                                                  |
-// +-----------------------------------------------------------------------+
-$lang['All Smilies'] = 'Todos os icones smille';
-$lang['Nb. columns'] = 'Colunas num.';
-$lang['Representative'] = 'Representativo';
-$lang['Smileys\' folder'] = 'Directório dos icones smille';
-$lang['smilies_file_help'] = 'Por defeito, quando um utilizador clica num icon smille,o suporte dos Smilles adiciona uma palavra chave coorrespondente ao nome do smille pretendido (smille.png->: smille :)<br>
-Mas aqui você pode configurar sequências para substituição. Cada pasta tem o seu próprio arquivo <i>smilies.txt</i>.';
-?>
Index: tensions/SmiliesSupport/language/ru_RU/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/ru_RU/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,9 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Папка со смайликами';
-$lang['Nb. columns'] = 'Количество';
-$lang['Representative'] = 'Представитель';
-$lang['All Smilies'] = 'Все смайлики';
-$lang['smilies_file_help'] = 'По умолчанию, когда пользователь кликает на смайлик, плагин добавляет коючевое слово, соотретствующее имени файла со смайликом (например, smile.png -> :smile:).<br> С помощью плагина вы можете настроить автозамену. В каждой папке со смайликами находится файл <i>smilies.txt</i>.';
-
-?>
Index: tensions/SmiliesSupport/language/sk_SK/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/sk_SK/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Adresár smajlíkov';
-$lang['Nb. columns'] = 'Počet stĺpcov';
-$lang['Representative'] = 'Zástupca';
-$lang['All Smilies'] = 'Všetky smajlíky';
-$lang['smilies_file_help'] = 'Predvolene, ak používateľ klikne na smajlíka, podpora smajlíkov pridá kľúčové slovo spárované s menom súboru (smile.png -> :smile:).<br>
-  Ale môžete konfigurovať iné reťazce na prepísanie. Každý adresár smajlíka má vlastný <i>smilies.txt</i> súbor.';
-    
-?>
Index: tensions/SmiliesSupport/language/sv_SE/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/sv_SE/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Smileys\' Mappar';
-$lang['Nb. columns'] = 'Nb. Kolumer';
-$lang['Representative'] = 'Representant';
-$lang['All Smilies'] = 'Alla Smilies';
-$lang['smilies_file_help'] = 'Som standard när en användare klickar på en smiley, tillägger Smilies Stödja ett sökord som matchar namnet på filen (smile.png -> :smile:).<br>
-  Men här kan du konfigurera andra strängar som ska ersättas. Varje smilies mapp har sin egen <i>smilies.txt</i> fil.';
-
-?>
Index: tensions/SmiliesSupport/language/tr_TR/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/tr_TR/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'İfadeler\' dosya';
-$lang['Nb. columns'] = 'Numara Sütunü';
-$lang['Representative'] = 'Temsilci';
-$lang['All Smilies'] = 'Tüm İfadeler';
-$lang['smilies_file_help'] = 'Kullanıcı bir ifadeye tıkladığı zaman, Smilies Support eklentisi ifade ile eşleşen bir anahtar kelime ekler örnek (smile.png -> :smile:).<br>
-  Burada diğer anahtar kelimeleri düzenleyebilirsiniz. Her gülümseme klasörü kendi <i>smilies.txt</i> dosyasına sahiptir.';
-
-?>
Index: tensions/SmiliesSupport/language/uk_UA/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/uk_UA/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,29 +1,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Piwigo - a PHP based photo gallery                                    |
-// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
-// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
-// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify  |
-// | it under the terms of the GNU General Public License as published by  |
-// | the Free Software Foundation                                          |
-// |                                                                       |
-// | This program is distributed in the hope that it will be useful, but   |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-// | General Public License for more details.                              |
-// |                                                                       |
-// | You should have received a copy of the GNU General Public License     |
-// | along with this program; if not, write to the Free Software           |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA.                                                                  |
-// +-----------------------------------------------------------------------+
-$lang['All Smilies'] = 'Всі смайли';
-$lang['Nb. columns'] = 'Кількість стовпців по горизонталі';
-$lang['Representative'] = 'Типовий';
-$lang['Smileys\' folder'] = 'Тека зі смайлами';
-$lang['smilies_file_help'] = 'За замовчуванням, коли користувач натискає на смайлик, смайлики підтримка додає ключових слів назви файлу (smile.png -> :smile:).<br>
-   Але тут ви можете налаштувати, інші рядки повинні бути замінені. Кожна папка смайликів має свій <i>smilies.txt</i> файл';
-?>
Index: tensions/SmiliesSupport/language/vi_VN/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/vi_VN/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<?php
-
-$lang['Smileys\' folder'] = 'Thư mục hình mặt cười';
-$lang['Nb. columns'] = 'Nb. Cột';
-$lang['Representative'] = 'Đại diện';
-$lang['All Smilies'] = 'Tất cả hình mặt cười';
-$lang['smilies_file_help'] = 'Theo mặc định, khi người dùng click lên một hình mặt cười, thì Mục hỗ trợ Hình mặt cười sẽ thêm vào một từ khóa trùng với tên tệp tin (ví dụ smile.png -> :smile:).<br>
-  Nhưng bạn cũng có thể cấu hình chuỗi ký tự khác cần thay thế tại đây. Mỗi thư mục chứa hình mặt cười đều chứa tệp tin <i>smilies.txt</i> của riêng thư mục đó.';
-
-?>
Index: tensions/SmiliesSupport/language/zh_CN/plugin.lang.php
===================================================================
--- /extensions/SmiliesSupport/language/zh_CN/plugin.lang.php	(revision 23233)
+++ 	(revision )
@@ -1,28 +1,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Piwigo - a PHP based photo gallery                                    |
-// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
-// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
-// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify  |
-// | it under the terms of the GNU General Public License as published by  |
-// | the Free Software Foundation                                          |
-// |                                                                       |
-// | This program is distributed in the hope that it will be useful, but   |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-// | General Public License for more details.                              |
-// |                                                                       |
-// | You should have received a copy of the GNU General Public License     |
-// | along with this program; if not, write to the Free Software           |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA.                                                                  |
-// +-----------------------------------------------------------------------+
-$lang['All Smilies'] = '所有表情';
-$lang['Smileys\' folder'] = '表情目录';
-$lang['smilies_file_help'] = '默认情况下，用户点击一个表情时，表情支持会添加一个适配表情文件名字的关键词（smile.png -> :smile:）。<br>这里你可以配置其他被替换的字符串。每个表情文件目录需要配置自己的<i>smiles.txt</i>文件。';
-$lang['Nb. columns'] = '序列';
-$lang['Representative'] = '代表性的';
-?>
Index: /extensions/SmiliesSupport/main.inc.php
===================================================================
--- /extensions/SmiliesSupport/main.inc.php	(revision 23233)
+++ /extensions/SmiliesSupport/main.inc.php	(revision 23234)
@@ -4,5 +4,5 @@
 Version: auto
 Description: Allow add Smilies for comments and descriptions.
-Plugin URI: http://piwigo.org/ext/extension_view.php?eid=159
+Plugin URI: auto
 Author: Atadilo & P@t & Mistic
 */
@@ -10,12 +10,26 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-define('SMILIES_DIR',  basename(dirname(__FILE__)));
-define('SMILIES_PATH', PHPWG_PLUGINS_PATH . SMILIES_DIR . '/');
+define('SMILIES_ID',   basename(dirname(__FILE__)));
+define('SMILIES_PATH', PHPWG_PLUGINS_PATH . SMILIES_ID . '/');
+define('SMILIES_DIR',  SMILIES_PATH . 'smilies/');
 
-include_once(SMILIES_PATH.'smiliessupport.inc.php');
+include_once(SMILIES_PATH.'include/functions.inc.php');
+include_once(SMILIES_PATH.'include/smiliessupport.inc.php');
 
+add_event_handler('init', 'init_smiliessupport');
 add_event_handler('render_comment_content', 'SmiliesParse', 60);
 add_event_handler('render_contact_content', 'SmiliesParse');
 add_event_handler('loc_after_page_header', 'add_smiliessupport');
+
+
+function init_smiliessupport()
+{
+  global $conf;
+  
+  $conf['smiliessupport'] = unserialize($conf['smiliessupport']);
+  $conf['smiliessupport']['ext'] = array('gif', 'jpg', 'png', 'GIF', 'JPG', 'PNG');
+  
+  load_language('plugin.lang', SMILIES_PATH);
+}
 
 function add_smiliessupport() 
@@ -59,12 +73,15 @@
 {
   add_event_handler('get_admin_plugin_menu_links', 'smiliessupport_admin_menu');
+  add_event_handler('init', 'smiliessupport_get_list');
+  
   function smiliessupport_admin_menu($menu) 
   {
     array_push($menu, array(
       'NAME' => 'Smilies Support',
-      'URL' => get_root_url().'admin.php?page=plugin-' . SMILIES_DIR
+      'URL' => get_root_url().'admin.php?page=plugin-' . SMILIES_ID
     ));
     return $menu;
   }
 }
+
 ?>
Index: /extensions/SmiliesSupport/maintain.inc.php
===================================================================
--- /extensions/SmiliesSupport/maintain.inc.php	(revision 23233)
+++ /extensions/SmiliesSupport/maintain.inc.php	(revision 23234)
Index: /extensions/SmiliesSupport/smilies/crystal/representant.txt
===================================================================
--- /extensions/SmiliesSupport/smilies/crystal/representant.txt	(revision 23234)
+++ /extensions/SmiliesSupport/smilies/crystal/representant.txt	(revision 23234)
@@ -0,0 +1,1 @@
+smile.png
Index: /extensions/SmiliesSupport/smilies/crystal/smilies.txt
===================================================================
--- /extensions/SmiliesSupport/smilies/crystal/smilies.txt	(revision 23233)
+++ /extensions/SmiliesSupport/smilies/crystal/smilies.txt	(revision 23234)
@@ -1,8 +1,15 @@
-:)		smile.png
-:-)		smile.png
 :D		biggrin.png
 :-D		biggrin.png
-;)		wink.png
-;-)		wink.png
+:s		confused.png
+:S		confused.png
+;(		cry.png
+;-(		cry.png
+oO		eek.png
+Oo		eek.png
+OO		eek.png
+<3		like.png
+^^		lol.png
+:|		neutral.png
+:-|		neutral.png
 :P		razz.png
 :p		razz.png
@@ -11,17 +18,10 @@
 :(		sad.png
 :-(		sad.png
-;(		cry.png
-;-(		cry.png
-oO		eek.png
-Oo		eek.png
-OO		eek.png
+:)		smile.png
+:-)		smile.png
 :o		surprised.png
 :O		surprised.png
 :-o		surprised.png
 :-O		surprised.png
-:s		confused.png
-:S		confused.png
-:|		neutral.png
-:-|		neutral.png
-<3		like.png
-^^		lol.png
+;)		wink.png
+;-)		wink.png
Index: /extensions/SmiliesSupport/smilies/ipb/representant.txt
===================================================================
--- /extensions/SmiliesSupport/smilies/ipb/representant.txt	(revision 23234)
+++ /extensions/SmiliesSupport/smilies/ipb/representant.txt	(revision 23234)
@@ -0,0 +1,1 @@
+sourire.gif
Index: /extensions/SmiliesSupport/smilies/ipb/smilies.txt
===================================================================
--- /extensions/SmiliesSupport/smilies/ipb/smilies.txt	(revision 23233)
+++ /extensions/SmiliesSupport/smilies/ipb/smilies.txt	(revision 23234)
@@ -1,22 +1,22 @@
-:)		sourire.gif
-:-)		sourire.gif
 :D		happy.gif
 :-D		happy.gif
-;)		wink.gif
-;-)		wink.gif
 :P		langue.gif
 :p		langue.gif
 :-p		langue.gif
 :-P		langue.gif
-:(		triste.gif
-:-(		triste.gif
-;(		pleure.gif
-;-(		pleure.gif
 oO		perplexe.gif
 Oo		perplexe.gif
 OO		perplexe.gif
+;(		pleure.gif
+;-(		pleure.gif
+:)		sourire.gif
+:-)		sourire.gif
 :o		surpris.gif
 :O		surpris.gif
 :-o		surpris.gif
 :-O		surpris.gif
+:(		triste.gif
+:-(		triste.gif
+;)		wink.gif
+;-)		wink.gif
 <3		wub.gif
Index: /extensions/SmiliesSupport/smilies/pidgin/representant.txt
===================================================================
--- /extensions/SmiliesSupport/smilies/pidgin/representant.txt	(revision 23234)
+++ /extensions/SmiliesSupport/smilies/pidgin/representant.txt	(revision 23234)
@@ -0,0 +1,1 @@
+happy.png
Index: /extensions/SmiliesSupport/smilies/pidgin/smilies.txt
===================================================================
--- /extensions/SmiliesSupport/smilies/pidgin/smilies.txt	(revision 23234)
+++ /extensions/SmiliesSupport/smilies/pidgin/smilies.txt	(revision 23234)
@@ -0,0 +1,34 @@
+oO		bulgy-eyes.png
+Oo		bulgy-eyes.png
+OO		bulgy-eyes.png
+:s		confused.png
+:S		confused.png
+:-s		confused.png
+:-S		confused.png
+;(		crying.png
+;-(		crying.png
+^^		cute.png
+:D		excited.png
+:-D		excited.png
+:)		happy.png
+:-)		happy.png
+<3		in_love.png
+:|		neutral.png
+:-|		neutral.png
+:?		question.png
+:(		sad.png
+:-(		sad.png
+:o		shocked.png
+:-o		shocked.png
+:O		shocked.png
+:-O		shocked.png
+:x		shut-mouth.png
+:-x		shut-mouth.png
+:\		thinking.png
+:-\		thinking.png
+:p		tongue.png
+:-p		tongue.png
+:P		tongue.png
+:-P		tongue.png
+;)		wink.png
+;-)		wink.png
Index: /extensions/SmiliesSupport/smilies/sylvia/representant.txt
===================================================================
--- /extensions/SmiliesSupport/smilies/sylvia/representant.txt	(revision 23234)
+++ /extensions/SmiliesSupport/smilies/sylvia/representant.txt	(revision 23234)
@@ -0,0 +1,1 @@
+smile.png
Index: /extensions/SmiliesSupport/smilies/sylvia/smilies.txt
===================================================================
--- /extensions/SmiliesSupport/smilies/sylvia/smilies.txt	(revision 23233)
+++ /extensions/SmiliesSupport/smilies/sylvia/smilies.txt	(revision 23234)
@@ -1,8 +1,13 @@
-:)		smile.png
-:-)		smile.png
 :D		biggrin.png
 :-D		biggrin.png
-;)		wink.png
-;-)		wink.png
+:s		confused.png
+:S		confused.png
+;(		cry.png
+;-(		cry.png
+oO		eek.png
+Oo		eek.png
+OO		eek.png
+:|		neutral.png
+:-|		neutral.png
 :P		razz.png
 :p		razz.png
@@ -11,15 +16,10 @@
 :(		sad.png
 :-(		sad.png
-;(		cry.png
-;-(		cry.png
-oO		eek.png
-Oo		eek.png
-OO		eek.png
+:)		smile.png
+:-)		smile.png
 :o		surprised.png
 :O		surprised.png
 :-o		surprised.png
 :-O		surprised.png
-:s		confused.png
-:S		confused.png
-:|		neutral.png
-:-|		neutral.png
+;)		wink.png
+;-)		wink.png
Index: tensions/SmiliesSupport/smiliessupport.inc.php
===================================================================
--- /extensions/SmiliesSupport/smiliessupport.inc.php	(revision 23233)
+++ 	(revision )
@@ -1,105 +1,0 @@
-<?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-
-// add smilies button to the comment field
-function set_smiliessupport($prefilter='picture', $textarea_id='contentid')
-{
-  global $conf, $template, $page;
-  
-  load_language('plugin.lang', SMILIES_PATH);
-  $conf_smiliessupport = unserialize($conf['smiliessupport']);
-
-  $template->assign(array(
-    'SMILIES_PATH' => SMILIES_PATH,
-    'SMILIES_ID' => $textarea_id,
-    'REPRESENTANT' => SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$conf_smiliessupport['representant'],
-    'smiliesfiles' => get_smilies($conf_smiliessupport),
-  ));
-  
-  $template->set_prefilter($prefilter, 'set_smiliessupport_prefilter');  
-}
-
-function set_smiliessupport_prefilter($content, &$smarty)
-{
-  $search = '#(<div id="guestbookAdd">|<div id="commentAdd">|<div class="contact">)#';
-  $replace = file_get_contents(SMILIES_PATH.'/template/smiliessupport_page.tpl').'$1';
-  return preg_replace($search, $replace, $content);
-}
-
-// return an array with available smilies (name and path) ## must received the unserialized configuration array
-function get_smilies($conf_smiliessupport)
-{
-  $accepted_ext = array('gif', 'jpg', 'png');
-  
-  if ($handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder']))
-  {
-    $i = 1;
-    while (false !== ($file = readdir($handle)))
-    {
-      if ($file != '.' AND $file != '..' AND in_array(get_extension($file), $accepted_ext))
-      {
-        $smilies[] = array(
-          'PATH' => SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$file,
-          'TITLE' => ':'.get_filename_wo_extension($file).':',
-          'TR' => ($i>0 AND $i%$conf_smiliessupport['cols'] == 0) ? '</tr><tr>' : null,
-        );
-        $i++;
-      }
-    }
-    
-    closedir($handle);
-    return $smilies;
-  } 
-  else 
-  {
-    return false;
-  }
-}
-
-// parse smilies
-function SmiliesParse($str)
-{
-  global $conf;
-
-  $conf_smiliessupport = unserialize($conf['smiliessupport']);
-  $folder = get_absolute_root_url().SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'];
-  $def_path = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt';
-  $accepted_ext = array('gif', 'jpg', 'png');
-  $str = ' '.$str;
-  
-  if ($handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder']))
-  {
-    while (false !== ($file = readdir($handle)))
-    { 
-      if ($file != "." && $file != ".." && in_array(get_extension($file), $accepted_ext)) 
-      {
-        $filename = get_filename_wo_extension($file);
-        $v = ':'.$filename.':'; 
-        $s = '<img src="'.$folder.'/'.$file.'" alt=":'.$filename.':"/>';
-        $str = str_replace($v, $s, $str);
-      }
-    }
-    
-    closedir($handle);
-  }
-  
-  if (file_exists($def_path))
-  {
-    $def = file($def_path);
-    foreach($def as $v)
-    {
-      $v = trim($v);
-      if (preg_match('#^([^\t]+)[ \t]+(.+)$#', $v, $matches)) 
-      {  
-        $filename = get_filename_wo_extension($matches[2]);
-        $v = '#([^"])'.preg_quote($matches[1],'/').'#';          
-        $t = '$1<img src="'.$folder.'/'.$matches[2].'" alt=":'.$filename.':"/>';
-        $str = preg_replace($v, $t, $str);
-      }
-    }
-  } 
-  
-  return trim($str);
-}
-
-?>
Index: /extensions/SmiliesSupport/template/smiliessupport_admin.tpl
===================================================================
--- /extensions/SmiliesSupport/template/smiliessupport_admin.tpl	(revision 23233)
+++ /extensions/SmiliesSupport/template/smiliessupport_admin.tpl	(revision 23234)
@@ -1,30 +1,164 @@
-{combine_script id='jquery.cluetip' require='jquery' path='themes/default/js/plugins/jquery.cluetip.js'}
-{include file='include/autosize.inc.tpl'}
+{combine_script id='jquery.tokeninput' load='footer' path='themes/default/js/plugins/jquery.tokeninput.js'}
+{combine_css path=$SMILIES_PATH|cat:'template/style.css'}
 
-{footer_script require="jquery.cluetip"}{literal}
-  jQuery('.cluetip').cluetip({
-    width: 550,
-    splitTitle: '|'
-  });
+
+{footer_script}{literal}
+var data = {};
+var edit = false;
+var edited = false;
+
+// set changed
+jQuery("select[name='folder']").change(function() {
+    if (edited) {
+        var ok = confirm("{/literal}{'If you change current set you will lost every shortcuts changes.'|@translate}{literal}");
+        if (!ok) {
+            jQuery(this).val(jQuery(this).data("selected"));
+            return false;
+        }
+    }
+    
+    var image = jQuery(this).find(":selected").css("background-image");
+    jQuery(this).css("background-image", image);
+    jQuery(this).data("selected", jQuery(this).val());
+    
+    fetch();
+});
+
+// size changed
+jQuery("input[name='cols']").change(function() {
+    update();
+});
+
+// switch preview/edit
+jQuery(".edit").click(function() {
+    if (edit) {
+        $(this).html("{/literal}{'Edit shorcuts'|@translate}{literal}");
+    }
+    else {
+        $(this).html("{/literal}{'Preview'|@translate}{literal}");
+    }
+    
+    edit = !edit;
+    update();
+    return false;
+});
+
+// display edit form before submit
+jQuery("#smiliesupport").submit(function() {
+    if (!edit) jQuery(".edit").click();
+    return true;
+});
+
+/* get smilies list */
+function fetch() {
+    jQuery.ajax({
+        url: 'admin.php',
+        type: 'GET',
+        dataType: 'json',
+        data: {
+            action: 'ss_preview',
+            folder: jQuery("select[name='folder']").val(),
+        },
+        success: function(result) {
+            data = result;
+            edited = false;
+            update();
+        }
+    });
+}
+
+/* update preview/edit table */
+function update() {
+    var html = '';
+    
+    if (!edit) {
+        html+= '<tr>';
+        var cols = parseInt(jQuery("input[name='cols']").val());
+        var i=0;
+        
+        for (var file in data.smilies) {
+            var smiley = data.smilies[file];
+            html+= '<td><a href="#" title="'+ smiley.title +'"><img src="'+ data.path + smiley.file +'"/></a></td>';
+            if ((parseInt(i)+1)%cols == 0) html+= '</tr><tr>';
+            i++;
+        }
+        
+        html+= '</tr>';
+    }
+    else {
+    {/literal}
+        html+= '<tr>'
+            +'<th>{'Smiley'|@translate}</th>'
+            +'<th>{'Name'|@translate}</th>'
+            +'<th>{'Shortcuts'|@translate}</th>'
+          +'</tr>';
+     {literal}
+     
+        for (var file in data.smilies) {
+            var smiley = data.smilies[file];
+            html+= '<tr data-file="'+ smiley.file +'">'
+                +'<td><img src="'+ data.path + smiley.file +'"/></td>'
+                +'<td>'+ smiley.title +'</td>'
+                +'<td>'
+                  +'<select name="shortcuts['+ smiley.file +']" class="shortcuts">';
+                
+                for (var j in smiley.short) {
+                    html+= '<option value="'+ smiley.short[j] +'" selected>'+ smiley.short[j] +'</option>';
+                }
+                  
+                html+= '</select>'
+                +'</td>'
+              +'</tr>';
+        }
+    }
+    
+    jQuery("#preview").html(html);
+    
+    // init tokeninput
+    jQuery(".shortcuts").tokenInput([], {
+        hintText: '{/literal}{'Type in a new shortcut'|@translate}{literal}',
+        newText: '',
+        animateDropdown: false,
+        preventDuplicates: true,
+        caseSensitive: true,
+        allowCreation: true,
+        minChars: 2,
+        searchDelay: 10,
+        
+        onAdd: function(item) {
+            edited = true;
+            var file = $(this).parents("tr").data("file");
+            
+            if (data.smilies[file].short == null) {
+                data.smilies[file].short = [item.name];
+            }
+            else {
+                data.smilies[file].short.push(item.name);
+            }
+        },
+        onDelete: function(item) {
+          edited = true;
+          var file = $(this).parents("tr").data("file");
+          
+          for (var i in data.smilies[file].short) {
+              if (data.smilies[file].short[i] == item.name) {
+                  data.smilies[file].short.splice(i, 1);
+              }
+          }
+        },
+    });
+    
+    // prevent spaces
+    jQuery(".token-input-input-token input").keydown(function(e) {
+        if (e.keyCode == 32) {
+            return false;
+        }
+    });
+}
+
+// init
+fetch();
 {/literal}{/footer_script}
 
-{html_head}
-<style type="text/css">
-  legend .cluetip {ldelim}
-    text-align:center;
-    margin:20px 0 -10px 0;
-    font-size:1.2em;
-  }
-  .cluetip:after {ldelim}
-    margin-left:5px;
-    vertical-align:top;
-    content:url('{$themeconf.admin_icon_dir}/help.png');
-  }
-  .properties textarea {ldelim}
-    width:60%;
-    margin:0 20%;
-  }
-</style>
-{/html_head}
 
 <div class="titrePage">
@@ -32,40 +166,32 @@
 </div>
 
-<form method="post" action="" class="properties"> 
-  <fieldset>
-      <legend>{'Configuration'|@translate}</legend>    
-    <ul>      
+<form method="post" action="" class="properties" id="smiliesupport">
+
+<fieldset>
+  <legend>{'Configuration'|@translate}</legend>  
+  
+  <ul>      
     <li>
-      <span class="property">{'Smileys\' folder'|@translate}</span>
-      <select name="folder">
-        {html_options options=$sets selected=$FOLDER}
+      <b>{'Smilies set'|@translate}</b>
+      <select name="folder" style="background-image:url('{$SMILIES_PATH}smilies/{$FOLDER}/{$SETS[$FOLDER]}');" data-selected="{$FOLDER}">
+      {foreach from=$SETS item=rep key=set}
+        <option value="{$set}" style="background-image:url('{$SMILIES_PATH}smilies/{$set}/{$rep}');" {if $set==$FOLDER}selected{/if}>{$set}</option>
+      {/foreach}
       </select>
     </li>
     <li>
-      <span class="property">{'Nb. columns'|@translate}</span>
-      <input type="text" size="3" name="cols" value="{$COLS}" />
-    </li>    
-    <li>
-      <span class="property">{'Representative'|@translate}</span>
-      <select name="representant">
-        {html_options options=$smilies selected=$REPRESENTANT}
-      </select>
+      <b>{'Columns'|@translate}</b>
+      <input type="text" size="2" name="cols" value="{$COLS}">
     </li>
-    <li>
-      <table><tr>
-      {foreach from=$smiliesfiles item=smileyfile} 
-        <td><a href="#" title="{$smileyfile.TITLE}"><img src="{$smileyfile.PATH}"/></a></td>
-        {$smileyfile.TR}
-      {/foreach}
-      </tr></table>
-    </li>
-    </ul>
-  </fieldset>
+  </ul>
+</fieldset>
+
+<fieldset>
+  <legend>{'Preview'|@translate}</legend>  
+  <a href="#" class="edit buttonLike">{'Edit shorcuts'|@translate}</a>
+  <table id="preview"></table>
+</fieldset>
   
-  <fieldset>
-    <legend><span class="cluetip" title="smilies.txt|{'smilies_file_help'|@translate}">smilies.txt</legend>
-    <textarea rows="5" name="text">{$CONTENT_FILE}</textarea>
-  </fieldset>  
-  
-  <p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p>
+<p class="formButtons"><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p>
+
 </form>
Index: /extensions/SmiliesSupport/template/smiliessupport_page.tpl
===================================================================
--- /extensions/SmiliesSupport/template/smiliessupport_page.tpl	(revision 23233)
+++ /extensions/SmiliesSupport/template/smiliessupport_page.tpl	(revision 23234)
@@ -4,6 +4,5 @@
 {/if}
 
-{footer_script require='jquery'}
-{literal}
+{footer_script require='jquery'}{literal}
 if (jQuery('.markItUp').length == 0) {
   jQuery('#{/literal}{$SMILIES_ID}{literal}').markItUp({markupSet: []});
@@ -28,10 +27,13 @@
   return false;
 });
-{/literal}
-{/footer_script}
+{/literal}{/footer_script}
+
+{html_style}{literal}
+#smiliesdiv table a { width:auto; height:auto; }
+{/literal}{/html_style}
 
 <ul style="display:none;">
 <li id="SmiliesSupport" class="markItUpButton markItUpDropMenu">
-  <a id="allsmilies" style="background-image:url('{$ROOT_URL}{$REPRESENTANT}');" title="{'All Smilies'|@translate}"></a>
+  <a id="allsmilies" style="background-image:url('{$ROOT_URL}{$REPRESENTANT}');" title="{'Smilies'|@translate}"></a>
 
   <ul id="smiliesdiv">
Index: /extensions/SmiliesSupport/template/style.css
===================================================================
--- /extensions/SmiliesSupport/template/style.css	(revision 23234)
+++ /extensions/SmiliesSupport/template/style.css	(revision 23234)
@@ -0,0 +1,20 @@
+select[name='folder'], select[name='folder'] option {
+  background-position:2px center;
+  background-repeat:no-repeat;
+  padding:2px 2px 2px 26px;
+  height:22px;
+}
+
+.token-input-list li {
+  clear:none !important;
+  padding: 1px 3px !important;
+  margin-bottom: 3px !important;
+}
+
+table#preview {
+  margin:10px 0 0 0;
+}
+
+input, select {
+  border-radius:3px;
+}
