Changeset 10986


Ignore:
Timestamp:
May 22, 2011, 12:48:18 PM (13 years ago)
Author:
mistic100
Message:

code cleanup

Location:
extensions/SmiliesSupport
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • extensions/SmiliesSupport/admin.php

    r9966 r10986  
    99if (isset($_POST['submit']))
    1010{
    11         // the smilies.txt file is not saved if the directory is changed
    12         if (isset($_POST['text1']) AND $_POST['text1'] != $conf_smiliessupport[0])
    13         {
    14                 $not_save_file = true;
    15         }
    16        
    17         // new configuration
    18         $conf_smiliessupport = array(
    19                 isset($_POST['text1']) ? $_POST['text1'] : 'plugins/SmiliesSupport/smilies_1',
    20                 isset($_POST['text2']) ? $_POST['text2'] : '6',
    21                 isset($_POST['text3']) ? $_POST['text3'] : 'smile.png',
    22         );
    23         if (empty($_POST['text'])) $_POST['text'] = ':)         smile.png';
    24                
    25     $new_value_smiliessupport = implode(",", $conf_smiliessupport);
    26     $query = "UPDATE " . CONFIG_TABLE . "
    27                 SET value='" . $new_value_smiliessupport . "'
    28                 WHERE param='smiliessupport'";
    29     pwg_query($query);
    30        
    31         // new definitions file
    32         if (!isset($not_save_file))
    33         {
    34                 $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';     
     11  // the smilies.txt file is not saved if the directory is changed
     12  if (isset($_POST['text1']) AND $_POST['text1'] != $conf_smiliessupport[0])
     13  {
     14    $not_save_file = true;
     15  }
     16 
     17  // new configuration
     18  $conf_smiliessupport = array(
     19    isset($_POST['text1']) ? $_POST['text1'] : 'plugins/SmiliesSupport/smilies_1',
     20    isset($_POST['text2']) ? $_POST['text2'] : '6',
     21    isset($_POST['text3']) ? $_POST['text3'] : 'smile.png',
     22  );
     23  if (empty($_POST['text'])) $_POST['text'] = ':)    smile.png';
     24   
     25  conf_update_param('smiliessupport', implode(",", $conf_smiliessupport));
     26  array_push($page['infos'], l10n('Information data registered in database'));
     27 
     28  // new definitions file
     29  if (!isset($not_save_file))
     30  {
     31    $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';     
    3532
    36                 if (file_exists($smilies_file)) {
    37                         @copy($smilies_file, get_filename_wo_extension($smilies_file).'.bak');
    38                 }
    39                
    40                 if (@file_put_contents($smilies_file, stripslashes($_POST['text']))) { 
    41                         $page['infos'][] = l10n('Information data registered in database');
    42                 } else {
    43                         $page['errors'][] = l10n('File/directory read error').' : '.$smilies_file;
    44                 }
    45         }
     33    if (file_exists($smilies_file)) {
     34      @copy($smilies_file, get_filename_wo_extension($smilies_file).'.bak');
     35    }
     36   
     37    if (@!file_put_contents($smilies_file, stripslashes($_POST['text']))) { 
     38      array_push($page['errors'], l10n('File/directory read error').' : '.$smilies_file);
     39    }
     40  }
    4641}
    4742
    4843// check if the representant exists
    4944if (!file_exists(PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2])) {
    50         $page['errors'][] = l10n('File/directory read error').' : '.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2];
     45  array_push($page['errors'], l10n('File/directory read error').' : '.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2]);
    5146}
    5247
    5348$template->assign(array(
    54         'TEXT1_VALUE' => $conf_smiliessupport[0],
    55         'TEXT2_VALUE' => $conf_smiliessupport[1],
    56         'TEXT3_VALUE' => $conf_smiliessupport[2],
     49  'TEXT1_VALUE' => $conf_smiliessupport[0],
     50  'TEXT2_VALUE' => $conf_smiliessupport[1],
     51  'TEXT3_VALUE' => $conf_smiliessupport[2],
    5752));
    5853
     
    6459$smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';
    6560if (file_exists($smilies_file)) {
    66         $content_file = file_get_contents($smilies_file);
    67         $template->assign(array('CONTENT_FILE' => $content_file));
     61  $content_file = file_get_contents($smilies_file);
     62  $template->assign(array('CONTENT_FILE' => $content_file));
    6863}
    69        
     64 
    7065$template->assign('SMILIES_PATH', SMILIES_PATH);
    7166$template->set_filename('smiliessupport_conf', dirname(__FILE__).'/template/smiliessupport_admin.tpl');
  • extensions/SmiliesSupport/language/ar_SA/plugin.lang.php

    r10265 r10986  
    66$lang['All Smilies'] = "كل الوجوه التعبيرية";
    77$lang['smilies_file_help'] = "افتراضيا عندما ينقر المستخدم على  الوجوه التعبيرية، دعم الوجوه التعبيرية يضيف مطابقة الكلمات لاسم الملف (smile.png -> :smile:).<br>
    8     ولكن هنا يمكنك تكوين كلمات أخرى لتحل محلها. كل الوجوه التعبيرية في مجلد لها خاصيتها<i>smilies.txt</i> file.";
     8  ولكن هنا يمكنك تكوين كلمات أخرى لتحل محلها. كل الوجوه التعبيرية في مجلد لها خاصيتها<i>smilies.txt</i> file.";
    99
    1010?>
  • extensions/SmiliesSupport/language/cs_CZ/plugin.lang.php

    r9764 r10986  
    66$lang['All Smilies'] = "All Smilies";
    77$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.";
     8  But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    99
    1010?>
  • extensions/SmiliesSupport/language/de_DE/plugin.lang.php

    r9764 r10986  
    66$lang['All Smilies'] = "Alle Smilies";
    77$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.";
     8  But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    99
    1010?>
  • extensions/SmiliesSupport/language/en_UK/plugin.lang.php

    r9764 r10986  
    66$lang['All Smilies'] = "All Smilies";
    77$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.";
     8  But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    99
    1010?>
  • extensions/SmiliesSupport/language/fr_FR/plugin.lang.php

    r9764 r10986  
    66$lang['All Smilies'] = "Tous les smileys";
    77$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>.";
     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>.";
    99
    1010?>
  • extensions/SmiliesSupport/language/hu_HU/plugin.lang.php

    r9777 r10986  
    66$lang['All Smilies'] = "Összes hangulatjel";
    77$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>
    8         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.";
     8  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.";
    99
    1010?>
  • extensions/SmiliesSupport/language/it_IT/plugin.lang.php

    r10622 r10986  
    66$lang['All Smilies'] = 'Tutti gli smiley';
    77$lang['smilies_file_help'] = 'Di default, quando un utente clicca su un smiley, SmiliesSupport aggiunge una keyword corrispondente al nome del fine (smile.png -> :smile:).<br>
    8         Ma potete configurare qui altre serie di caratteri che saranno rimpiazzate. Ogni cartella di smileys ha il suo file <i>smilies.txt</i>';
     8  Ma potete configurare qui altre serie di caratteri che saranno rimpiazzate. Ogni cartella di smileys ha il suo file <i>smilies.txt</i>';
    99
    1010?>
  • extensions/SmiliesSupport/language/lv_LV/plugin.lang.php

    r10103 r10986  
    55$lang['representant'] = "Parstavošs";
    66$lang['All Smilies'] = "Visi Smailini";
    7 $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.";
     7$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>
     8  Ir iespējams nokonfigurēt arī citus variantus. Katrai smailiju mapei ir pašai savs <i>smilies.txt</i> fails.";
    89
    910?>
  • extensions/SmiliesSupport/language/nl_NL/description.txt

    r10733 r10986  
    1 Laat smileys toe voor reacties en beschrijvingen.
     1Allow add Smilies for comments and descriptions.
  • extensions/SmiliesSupport/language/nl_NL/plugin.lang.php

    r10695 r10986  
    66$lang['All Smilies'] = 'Alle Smileys';
    77$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>
    8 Maar hier kan je andere trefwoorden instellen. Elke smiley map heeft zijn eigen <i>smilies.txt</i> bestand.';
     8  Maar hier kan je andere trefwoorden instellen. Elke smiley map heeft zijn eigen <i>smilies.txt</i> bestand.';
    99?>
  • extensions/SmiliesSupport/language/no_NO/plugin.lang.php

    r9764 r10986  
    66$lang['All Smilies'] = "All Smilies";
    77$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.";
     8  But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    99
    1010?>
  • extensions/SmiliesSupport/language/pl_PL/plugin.lang.php

    r10794 r10986  
    66$lang['All Smilies'] = 'Wszystkie emotikony';
    77$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>
    8     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 ';
     8  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 ';
    99
    1010?>
  • extensions/SmiliesSupport/language/ru_RU/plugin.lang.php

    r9764 r10986  
    66$lang['All Smilies'] = "All Smilies";
    77$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.";
     8  But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    99
    1010?>
  • extensions/SmiliesSupport/language/sk_SK/plugin.lang.php

    r10462 r10986  
    66$lang['All Smilies'] = "Všetky smajlíky";
    77$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>
    8     Ale môžete konfigurovať iné reťazce na prepísanie. Každý adresár smajlíka má vlastný <i>smilies.txt</i> súbor.';
    9 
     8  Ale môžete konfigurovať iné reťazce na prepísanie. Každý adresár smajlíka má vlastný <i>smilies.txt</i> súbor.';
     9   
    1010?>
  • extensions/SmiliesSupport/language/sv_SE/plugin.lang.php

    r9816 r10986  
    66$lang['All Smilies'] = "Alla Smilies";
    77$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>
    8         Men här kan du konfigurera andra strängar som ska ersättas. Varje smilies mapp har sin egen <i>smilies.txt</i> fil.";
     8  Men här kan du konfigurera andra strängar som ska ersättas. Varje smilies mapp har sin egen <i>smilies.txt</i> fil.";
    99
    1010?>
  • extensions/SmiliesSupport/language/tr_TR/plugin.lang.php

    r9764 r10986  
    66$lang['All Smilies'] = "Tüm İfadeler";
    77$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.";
     8  But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    99
    1010?>
  • extensions/SmiliesSupport/main.inc.php

    r9966 r10986  
    22/*
    33Plugin Name: Smilies Support
    4 Version: 2.2.a
     4Version: auto
    55Description: Allow add Smilies for comments and descriptions.
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=159
     
    1919
    2020function add_smiliessupport() {
    21         global $page, $pwg_loaded_plugins;
    22        
    23         if (!isset($pwg_loaded_plugins['bbcode_bar'])
    24                 AND isset($page['body_id']) AND $page['body_id'] == 'thePicturePage')
    25         {
    26                 set_smiliessupport();
    27         }
     21  global $page, $pwg_loaded_plugins;
     22 
     23  if (!isset($pwg_loaded_plugins['bbcode_bar'])
     24    AND isset($page['body_id']) AND $page['body_id'] == 'thePicturePage')
     25  {
     26    set_smiliessupport();
     27  }
    2828}
    2929
    3030if (script_basename() == 'admin')
    3131{
    32         add_event_handler('get_admin_plugin_menu_links', 'smiliessupport_admin_menu');
    33         function smiliessupport_admin_menu($menu)
    34         {
    35                 array_push($menu, array(
    36                         'NAME' => 'Smilies Support',
    37                         'URL' => get_root_url().'admin.php?page=plugin-' . SMILIES_DIR));
    38                 return $menu;
    39         }
     32  add_event_handler('get_admin_plugin_menu_links', 'smiliessupport_admin_menu');
     33  function smiliessupport_admin_menu($menu)
     34  {
     35    array_push($menu, array(
     36      'NAME' => 'Smilies Support',
     37      'URL' => get_root_url().'admin.php?page=plugin-' . SMILIES_DIR));
     38    return $menu;
     39  }
    4040}
    4141?>
  • extensions/SmiliesSupport/maintain.inc.php

    r9764 r10986  
    44function plugin_install()
    55{
    6         global $conf;
     6  global $conf;
    77
    8         if (!isset($conf['smiliessupport'])) {
    9                 $q = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
    10                         VALUES ("smiliessupport","plugins/SmiliesSupport/smilies_1,6,smile.png","Parametres SmiliesSupport");';
    11                 pwg_query($q);
    12         }
     8  if (!isset($conf['smiliessupport'])) {
     9    $q = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
     10      VALUES ("smiliessupport","plugins/SmiliesSupport/smilies_1,6,smile.png","Parametres SmiliesSupport");';
     11    pwg_query($q);
     12  }
    1313}
    1414
    1515function plugin_uninstall()
    1616{
    17         global $conf;
     17  global $conf;
    1818
    19         if (isset($conf['smiliessupport'])) {
    20                 pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE param="smiliessupport" LIMIT 1;');
    21         }
     19  if (isset($conf['smiliessupport'])) {
     20    pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE param="smiliessupport" LIMIT 1;');
     21  }
    2222}
    2323
  • extensions/SmiliesSupport/smiliessupport.inc.php

    r9966 r10986  
    55function set_smiliessupport()
    66{
    7         global $conf, $lang;
    8         $conf_smiliessupport = explode(',' , $conf['smiliessupport']);
    9        
    10         $smilies = get_smilies($conf_smiliessupport);
    11         $lang['Comment'] .= SmiliesTable($conf_smiliessupport, $smilies);       
     7  global $conf, $lang;
     8  $conf_smiliessupport = explode(',' , $conf['smiliessupport']);
     9 
     10  $smilies = get_smilies($conf_smiliessupport);
     11  $lang['Comment'] .= SmiliesTable($conf_smiliessupport, $smilies); 
    1212}
    1313
     
    1515function get_smilies($conf_smiliessupport)
    1616{
    17         $accepted_ext = array('gif', 'jpg', 'png');
    18        
    19         if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0]))
    20         {
    21                 $i = 1;
    22                 while (false !== ($file = readdir($handle)))
    23                 {
    24                         if ($file != '.' AND $file != '..' AND in_array(get_extension($file), $accepted_ext))
    25                         {
    26                                 $smilies[] = array(
    27                                         'PATH' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$file,
    28                                         'TITLE' => ':'.get_filename_wo_extension($file).':',
    29                                         'TR' => ($i>0 AND $i%$conf_smiliessupport[1] == 0) ? '</tr><tr>' : null,
    30                                 );
    31                                 $i++;
    32                         }
    33                 }
    34                
    35                 return $smilies;
    36         } else {
    37                 return false;
    38         }
     17  $accepted_ext = array('gif', 'jpg', 'png');
     18 
     19  if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0]))
     20  {
     21    $i = 1;
     22    while (false !== ($file = readdir($handle)))
     23    {
     24      if ($file != '.' AND $file != '..' AND in_array(get_extension($file), $accepted_ext))
     25      {
     26        $smilies[] = array(
     27          'PATH' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$file,
     28          'TITLE' => ':'.get_filename_wo_extension($file).':',
     29          'TR' => ($i>0 AND $i%$conf_smiliessupport[1] == 0) ? '</tr><tr>' : null,
     30        );
     31        $i++;
     32      }
     33    }
     34   
     35    return $smilies;
     36  } else {
     37    return false;
     38  }
    3939}
    4040
     
    4242function SmiliesTable($conf_smiliessupport, $smilies)
    4343{
    44         global $template;
    45         load_language('plugin.lang', SMILIES_PATH);
     44  global $template;
     45  load_language('plugin.lang', SMILIES_PATH);
    4646
    47         // edit field has different id
    48         // if (
    49                 // (isset($_GET['action']) AND $_GET['action'] == 'edit_comment')
    50                 // OR (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage')
    51         // ) {
    52                 // $template->assign('form_name', 'editComment');
    53         // } else {
    54                 // $template->assign('form_name', 'addComment');
    55         // }
    56         $template->assign('form_name', 'addComment');
     47  // edit field has different id
     48  // if (
     49    // (isset($_GET['action']) AND $_GET['action'] == 'edit_comment')
     50    // OR (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage')
     51  // ) {
     52    // $template->assign('form_name', 'editComment');
     53  // } else {
     54    // $template->assign('form_name', 'addComment');
     55  // }
     56  $template->assign('form_name', 'addComment');
    5757
    58         $template->assign(array(
    59                 'SMILIES_PATH' => SMILIES_PATH,
    60                 'REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2],
    61                 'smiliesfiles' => $smilies,
    62         ));
    63        
    64         $template->set_filename('smiliessupport_page', dirname(__FILE__).'/template/smiliessupport_page.tpl');
    65         return $template->parse('smiliessupport_page', true);
     58  $template->assign(array(
     59    'SMILIES_PATH' => SMILIES_PATH,
     60    'REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2],
     61    'smiliesfiles' => $smilies,
     62  ));
     63 
     64  $template->set_filename('smiliessupport_page', dirname(__FILE__).'/template/smiliessupport_page.tpl');
     65  return $template->parse('smiliessupport_page', true);
    6666}
    6767
     
    6969function SmiliesParse($str)
    7070{
    71         global $conf;
     71  global $conf;
    7272
    73         $conf_smiliessupport = explode("," , $conf['smiliessupport']);
    74         $def_path = $conf_smiliessupport[0].'/smilies.txt';
    75         $accepted_ext = array('gif', 'jpg', 'png');
    76        
    77         if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0]))
    78         {
    79                 while (false !== ($file = readdir($handle)))
    80                 {
    81                         if ($file != "." && $file != ".." && in_array(get_extension($file), $accepted_ext)) {
    82                                 $v = ':'.get_filename_wo_extension($file).':';
    83                                 $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" alt=":'.get_filename_wo_extension($file).':" title=":'.get_filename_wo_extension($file).':"/>';
    84                                 $str = str_replace($v, $s, $str);
    85                         }
    86                 }
    87         }
    88        
    89         if (file_exists($def_path))
    90         {
    91                 $def = file($def_path);
    92                 foreach($def as $v)
    93                 {
    94                         $v = trim($v);
    95                         if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches)) { 
    96                                 $r = '#'.preg_quote($matches[1],'/').'#';                                       
    97                                 $t = '<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" alt=":'.get_filename_wo_extension($matches[2]).':" title=":'.get_filename_wo_extension($matches[2]).':"/>';
    98                                 $str = preg_replace($r, $t, $str);
    99                         }
    100                 }
    101         }
    102        
    103         return $str;
     73  $conf_smiliessupport = explode("," , $conf['smiliessupport']);
     74  $def_path = $conf_smiliessupport[0].'/smilies.txt';
     75  $accepted_ext = array('gif', 'jpg', 'png');
     76 
     77  if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0]))
     78  {
     79    while (false !== ($file = readdir($handle)))
     80    {
     81      if ($file != "." && $file != ".." && in_array(get_extension($file), $accepted_ext)) {
     82        $v = ':'.get_filename_wo_extension($file).':';
     83        $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" alt=":'.get_filename_wo_extension($file).':" title=":'.get_filename_wo_extension($file).':"/>';
     84        $str = str_replace($v, $s, $str);
     85      }
     86    }
     87  }
     88 
     89  if (file_exists($def_path))
     90  {
     91    $def = file($def_path);
     92    foreach($def as $v)
     93    {
     94      $v = trim($v);
     95      if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches)) { 
     96        $r = '#'.preg_quote($matches[1],'/').'#';         
     97        $t = '<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" alt=":'.get_filename_wo_extension($matches[2]).':" title=":'.get_filename_wo_extension($matches[2]).':"/>';
     98        $str = preg_replace($r, $t, $str);
     99      }
     100    }
     101  }
     102 
     103  return $str;
    104104}
    105105
  • extensions/SmiliesSupport/template/smiliessupport_admin.tpl

    r9966 r10986  
    44{footer_script require="jquery.cluetip"}
    55{literal}
    6         jQuery().ready(function(){
    7                 // Cluetip
    8                 jQuery('.cluetip').cluetip({
    9                         width: 550,
    10                         splitTitle: '|'
    11                 });
    12         });
     6  jQuery().ready(function(){
     7    // Cluetip
     8    jQuery('.cluetip').cluetip({
     9      width: 550,
     10      splitTitle: '|'
     11    });
     12  });
    1313{/literal}
    1414{/footer_script}
     
    1616{html_head}
    1717<style type="text/css">
    18         legend .cluetip {ldelim}
    19                 text-align:center;
    20                 margin:20px 0 -10px 0;
    21                 font-size:1.2em;
    22         }
    23         .cluetip:after {ldelim}
    24                 margin-left:5px;
    25                 vertical-align:top;
    26                 content:url('{$themeconf.admin_icon_dir}/help.png');
    27         }
    28         .properties textarea {ldelim}
    29                 width:60%;
    30                 margin:0 20%;
    31         }
     18  legend .cluetip {ldelim}
     19    text-align:center;
     20    margin:20px 0 -10px 0;
     21    font-size:1.2em;
     22  }
     23  .cluetip:after {ldelim}
     24    margin-left:5px;
     25    vertical-align:top;
     26    content:url('{$themeconf.admin_icon_dir}/help.png');
     27  }
     28  .properties textarea {ldelim}
     29    width:60%;
     30    margin:0 20%;
     31  }
    3232</style>
    3333{/html_head}
    3434
    3535<div class="titrePage">
    36         <h2>Smilies Support</h2>
     36  <h2>Smilies Support</h2>
    3737</div>
    3838
    3939<form method="post" action="" class="properties" ENCTYPE="multipart/form-data">
    40         <fieldset>
    41       <legend>{'Configuration'|@translate}</legend>      
    42           <ul>                 
    43                 <li>
    44                         <span class="property">{'smilies_dir'|@translate}</span>
    45                         <input type="text" size="40" name="text1" value="{$TEXT1_VALUE}" />
    46                 </li>
    47                 <li>
    48                         <span class="property">{'nb_columns'|@translate}</span>
    49                         <input type="text" size="3" name="text2" value="{$TEXT2_VALUE}" />
    50                 </li>           
    51                 <li>
    52                         <span class="property">{'representant'|@translate}</span>
    53                         <input type="text" size="20" name="text3" value="{$TEXT3_VALUE}" />
    54                 </li>
    55                 <li>
    56                         <table><tr>
    57                         {foreach from=$smiliesfiles item=smileyfile}
    58                                 <td><a href="#" title="{$smileyfile.TITLE}"><img src="{$smileyfile.PATH}"/></a></td>
    59                                 {$smileyfile.TR}
    60                         {/foreach}
    61                         </tr></table>
    62                 </li>
     40  <fieldset>
     41      <legend>{'Configuration'|@translate}</legend>   
     42    <ul>     
     43    <li>
     44      <span class="property">{'smilies_dir'|@translate}</span>
     45      <input type="text" size="40" name="text1" value="{$TEXT1_VALUE}" />
     46    </li>
     47    <li>
     48      <span class="property">{'nb_columns'|@translate}</span>
     49      <input type="text" size="3" name="text2" value="{$TEXT2_VALUE}" />
     50    </li>   
     51    <li>
     52      <span class="property">{'representant'|@translate}</span>
     53      <input type="text" size="20" name="text3" value="{$TEXT3_VALUE}" />
     54    </li>
     55    <li>
     56      <table><tr>
     57      {foreach from=$smiliesfiles item=smileyfile}
     58        <td><a href="#" title="{$smileyfile.TITLE}"><img src="{$smileyfile.PATH}"/></a></td>
     59        {$smileyfile.TR}
     60      {/foreach}
     61      </tr></table>
     62    </li>
    6363    </ul>
    64         </fieldset>
    65        
    66         <fieldset>
    67                 <legend><span class="cluetip" title="smilies.txt|{'smilies_file_help'|@translate}">smilies.txt</legend>
    68                 <textarea rows="5" name="text">{$CONTENT_FILE}</textarea>
    69         </fieldset>     
    70        
    71         <p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p>
     64  </fieldset>
     65 
     66  <fieldset>
     67    <legend><span class="cluetip" title="smilies.txt|{'smilies_file_help'|@translate}">smilies.txt</legend>
     68    <textarea rows="5" name="text">{$CONTENT_FILE}</textarea>
     69  </fieldset> 
     70 
     71  <p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p>
    7272</form>
  • extensions/SmiliesSupport/template/smiliessupport_page.tpl

    r10025 r10986  
    55{literal}
    66jQuery(document).ready(function() {
    7         if (jQuery('.markItUp').length == 0) {
    8                 jQuery('#{/literal}{$form_name}{literal} textarea').markItUp({markupSet: []});
    9         }
    10         jQuery('#SmiliesSupport').appendTo('.markItUpHeader ul:first-child');
    11         jQuery('#allsmilies').mouseover(function(){
    12                 jQuery("#{/literal}{$form_name}{literal} textarea").focus();
    13                 jQuery('#smiliesdiv').css('display','');
    14         });
    15         jQuery('#smiliesdiv a').click(function() {
    16                 emoticon = jQuery(this).attr("href");
    17                 jQuery.markItUp({ replaceWith:emoticon });
    18                 jQuery('#smiliesdiv').css('display','none');
    19                 return false;
    20         });
     7  if (jQuery('.markItUp').length == 0) {
     8    jQuery('#{/literal}{$form_name}{literal} textarea').markItUp({markupSet: []});
     9  }
     10  jQuery('#SmiliesSupport').appendTo('.markItUpHeader ul:first-child');
     11  jQuery('#allsmilies').mouseover(function(){
     12    jQuery("#{/literal}{$form_name}{literal} textarea").focus();
     13    jQuery('#smiliesdiv').css('display','');
     14  });
     15  jQuery('#smiliesdiv a').click(function() {
     16    emoticon = jQuery(this).attr("href");
     17    jQuery.markItUp({ replaceWith:emoticon });
     18    jQuery('#smiliesdiv').css('display','none');
     19    return false;
     20  });
    2121});
    2222{/literal}
     
    2525<ul style="display:none;">
    2626<li id="SmiliesSupport" class="markItUpButton markItUpDropMenu">
    27         <a id="allsmilies" style="background-image:url({$REPRESENTANT});" title="{'All Smilies'|@translate}"></a>
     27  <a id="allsmilies" style="background-image:url({$REPRESENTANT});" title="{'All Smilies'|@translate}"></a>
    2828
    29         <ul id="smiliesdiv">
    30                 <li><table><tr>
    31                 {foreach from=$smiliesfiles item=smileyfile}
    32                         <td><a href="{$smileyfile.TITLE}"><img src="{$smileyfile.PATH}"/></a></td>
    33                         {$smileyfile.TR}
    34                 {/foreach}
    35                 </tr></table></li>
    36         </ul>
     29  <ul id="smiliesdiv">
     30    <li><table><tr>
     31    {foreach from=$smiliesfiles item=smileyfile}
     32      <td><a href="{$smileyfile.TITLE}"><img src="{$smileyfile.PATH}"/></a></td>
     33      {$smileyfile.TR}
     34    {/foreach}
     35    </tr></table></li>
     36  </ul>
    3737</li>
    3838</ul>
Note: See TracChangeset for help on using the changeset viewer.