Ignore:
Timestamp:
Mar 19, 2011, 10:27:48 AM (13 years ago)
Author:
mistic100
Message:

[extentions] Smilies Support

  • active for admin in the comments page
  • two new sets of smilies
  • help tip on admin page (needs translation)
Location:
extensions/SmiliesSupport
Files:
46 added
1 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • extensions/SmiliesSupport/admin.php

    r9683 r9764  
    99if (isset($_POST['submit']))
    1010{
    11         if (!isset($_POST['text1'])) $_POST['text1'] = 'plugins/SmiliesSupport/smilies';
    12         if (!isset($_POST['text2'])) $_POST['text2'] = '5';
    13         if (!isset($_POST['text3'])) $_POST['text3'] = 'sourire.gif';
     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                $not_save_file = true;
     14        }
    1415       
    1516        $conf_smiliessupport = array(
    16                 $_POST['text1'],
    17                 $_POST['text2'],
    18                 $_POST['text3']
     17                isset($_POST['text1']) ? $_POST['text1'] : 'plugins/SmiliesSupport/smilies',
     18                isset($_POST['text2']) ? $_POST['text2'] : '5',
     19                isset($_POST['text3']) ? $_POST['text3'] : 'sourire.gif',
    1920        );
     21       
     22        if (empty($_POST['text'])) $_POST['text'] = ':)         sourire.gif';
    2023               
    21     $new_value_smiliessupport = implode ("," , $conf_smiliessupport);
     24    $new_value_smiliessupport = implode (",", $conf_smiliessupport);
    2225    $query = 'UPDATE ' . CONFIG_TABLE . '
    23         SET value="' . $new_value_smiliessupport . '"
    24         WHERE param="smiliessupport"';
     26                SET value="' . $new_value_smiliessupport . '"
     27                WHERE param="smiliessupport"';
    2528    pwg_query($query);
    2629   
    27         $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';     
     30        if (!isset($not_save_file)) {
     31                $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';     
    2832
    29         if (file_exists($smilies_file))
    30         {
    31                 if  (@copy($smilies_file , get_filename_wo_extension($smilies_file).'.bak'))
    32                 {
    33                         $file = @fopen($smilies_file , "w");
    34                         fwrite($file , stripslashes($content_file = $_POST['text']));
    35                         fclose($file);       
    36                         array_push($page['infos'], l10n('Configuration saved.'));
     33                if (file_exists($smilies_file)) {
     34                        @copy($smilies_file, get_filename_wo_extension($smilies_file).'.bak');
    3735                }
    38                 else
    39                 {
    40                         array_push($page['errors'], l10n('Configuration not saved. (copy : '.$smilies_file.' to '.get_filename_wo_extension($smilies_file).'.bak').')' );
     36               
     37                if (@file_put_contents($smilies_file, stripslashes($_POST['text']))) { 
     38                        $page['infos'][] = l10n('Information data registered in database');
     39                } else {
     40                        $page['errors'][] = l10n('File/directory read error').'   '.$smilies_file;
    4141                }
    42         }
    43         else
    44         {
    45                 array_push($page['errors'], l10n('Configuration not saved. (file exists : '.$smilies_file.')' ));
    4642        }
    4743}
     
    5551
    5652$smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';
    57 $content_file = '';
     53$content_file = null;
    5854
    59 if (file_exists($smilies_file))
    60 {
     55if (file_exists($smilies_file)) {
    6156        $content_file = file_get_contents($smilies_file);
    62         $template->assign(array('CONTENT_FILE' =>$content_file ));
     57        $template->assign(array('CONTENT_FILE' => $content_file));
    6358}
    6459       
  • extensions/SmiliesSupport/language/cs_CZ/plugin.lang.php

    r9700 r9764  
    55$lang['representant'] = "Representative";
    66$lang['All Smilies'] = "All Smilies";
     7$lang['smilies_file_help'] = "By default when a user clicks on a smiley, Smilies Support adds a keyword matching the name of the file (smile.png -> :smile:).<br>
     8        But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    79
    810?>
  • extensions/SmiliesSupport/language/de_DE/plugin.lang.php

    r9703 r9764  
    55$lang['representant'] = "Repräsentative";
    66$lang['All Smilies'] = "Alle Smilies";
     7$lang['smilies_file_help'] = "By default when a user clicks on a smiley, Smilies Support adds a keyword matching the name of the file (smile.png -> :smile:).<br>
     8        But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    79
    810?>
  • extensions/SmiliesSupport/language/en_UK/plugin.lang.php

    r9700 r9764  
    55$lang['representant'] = "Representative";
    66$lang['All Smilies'] = "All Smilies";
     7$lang['smilies_file_help'] = "By default when a user clicks on a smiley, Smilies Support adds a keyword matching the name of the file (smile.png -> :smile:).<br>
     8        But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    79
    810?>
  • extensions/SmiliesSupport/language/fr_FR/plugin.lang.php

    r9700 r9764  
    55$lang['representant'] = "Représentant";
    66$lang['All Smilies'] = "Tous les smileys";
     7$lang['smilies_file_help'] = "Par défaut quand l'utilisateur clique sur un smiley, Smilies Support ajoute un mot clef correspondant au nom du fichier (smile.png -> :smile:).<br>
     8        Mais vous pouvez configurer ici d'autres chaînes de caractères qui seront remplacées. Chaque dossier de smileys a son propre fichier <i>smilies.txt</i>.";
    79
    810?>
  • extensions/SmiliesSupport/language/hu_HU/plugin.lang.php

    r9701 r9764  
    55$lang['representant'] = "Képviselő";
    66$lang['All Smilies'] = "Összes hangulatjel";
     7$lang['smilies_file_help'] = "By default when a user clicks on a smiley, Smilies Support adds a keyword matching the name of the file (smile.png -> :smile:).<br>
     8        But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    79
    810?>
  • extensions/SmiliesSupport/language/it_IT/plugin.lang.php

    r9703 r9764  
    55$lang['representant'] = "Rappresentante";
    66$lang['All Smilies'] = "Tutti gli smiley";
     7$lang['smilies_file_help'] = "By default when a user clicks on a smiley, Smilies Support adds a keyword matching the name of the file (smile.png -> :smile:).<br>
     8        But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    79
    810?>
  • extensions/SmiliesSupport/language/lv_LV/plugin.lang.php

    r9724 r9764  
    55$lang['representant'] = "Parstavošs";
    66$lang['All Smilies'] = "Visi Smailini";
     7$lang['smilies_file_help'] = "By default when a user clicks on a smiley, Smilies Support adds a keyword matching the name of the file (smile.png -> :smile:).<br>
     8        But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    79
    810?>
  • extensions/SmiliesSupport/language/no_NO/plugin.lang.php

    r9700 r9764  
    55$lang['representant'] = "Representative";
    66$lang['All Smilies'] = "All Smilies";
     7$lang['smilies_file_help'] = "By default when a user clicks on a smiley, Smilies Support adds a keyword matching the name of the file (smile.png -> :smile:).<br>
     8        But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    79
    810?>
  • extensions/SmiliesSupport/language/ru_RU/plugin.lang.php

    r9700 r9764  
    55$lang['representant'] = "Representative";
    66$lang['All Smilies'] = "All Smilies";
     7$lang['smilies_file_help'] = "By default when a user clicks on a smiley, Smilies Support adds a keyword matching the name of the file (smile.png -> :smile:).<br>
     8        But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    79
    810?>
  • extensions/SmiliesSupport/language/sk_SK/plugin.lang.php

    r9726 r9764  
    55$lang['representant'] = "Zástupca";
    66$lang['All Smilies'] = "Všetky smajlíky";
     7$lang['smilies_file_help'] = "By default when a user clicks on a smiley, Smilies Support adds a keyword matching the name of the file (smile.png -> :smile:).<br>
     8        But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    79
    810?>
  • extensions/SmiliesSupport/language/tr_TR/plugin.lang.php

    r9728 r9764  
    55$lang['representant'] = "Temsilcisi";
    66$lang['All Smilies'] = "Tüm İfadeler";
     7$lang['smilies_file_help'] = "By default when a user clicks on a smiley, Smilies Support adds a keyword matching the name of the file (smile.png -> :smile:).<br>
     8        But here you can configure other strings to be replaced. Each smilies folder has its own <i>smilies.txt</i> file.";
    79
    810?>
  • extensions/SmiliesSupport/main.inc.php

    r9683 r9764  
    22/*
    33Plugin Name: Smilies Support
    4 Version: 2.2.0
     4Version: 2.2.a
    55Description: Allow add Smilies for comments and descriptions.
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=159
     
    1616
    1717add_event_handler('render_comment_content', 'SmiliesParse', 60);
    18 add_event_handler('loc_begin_picture', 'set_smiliessupport_page');
     18add_event_handler('loc_after_page_header', 'add_smiliessupport');
     19
     20function add_smiliessupport() {
     21        global $page;
     22        if ($page['body_id'] == 'theCommentsPage' OR $page['body_id'] == 'thePicturePage') {
     23                set_smiliessupport_page();
     24        }
     25}
    1926
    2027if (script_basename() == 'admin')
  • extensions/SmiliesSupport/maintain.inc.php

    r9683 r9764  
    66        global $conf;
    77
    8         if (!isset($conf['smiliessupport']))
    9         {
     8        if (!isset($conf['smiliessupport'])) {
    109                $q = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
    11                         VALUES ("smiliessupport","plugins/SmiliesSupport/smilies,5,sourire.gif","Parametres SmiliesSupport");';
     10                        VALUES ("smiliessupport","plugins/SmiliesSupport/smilies_1,6,smile.png","Parametres SmiliesSupport");';
    1211                pwg_query($q);
    1312        }
     
    1817        global $conf;
    1918
    20         if (isset($conf['smiliessupport']))
    21         {
     19        if (isset($conf['smiliessupport'])) {
    2220                pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE param="smiliessupport" LIMIT 1;');
    2321        }
  • extensions/SmiliesSupport/smilies/smilies.txt

    r3304 r9764  
    1515oO              perplexe.gif
    1616Oo              perplexe.gif
     17OO              perplexe.gif
    1718:o              surpris.gif
    1819:O              surpris.gif
    1920:-o             surpris.gif
    2021:-O             surpris.gif
     22<3              wub.gif
  • extensions/SmiliesSupport/smiliessupport.inc.php

    r9683 r9764  
    66        global $template, $lang, $pwg_loaded_plugins;
    77
    8         if (!isset($pwg_loaded_plugins['bbcode_bar']))
    9         {
     8        if (!isset($pwg_loaded_plugins['bbcode_bar'])) {
    109                $lang['Comment'] .= SmiliesTable();
    1110        }
     
    1413function SmiliesTable($new_conf=null)
    1514{
    16         global $conf, $template;
     15        global $conf, $template, $page;
    1716
    1817        // this is for live update on admin page
    19         if (empty($new_conf))
     18        if (empty($new_conf)) {
    2019                $conf_smiliessupport = explode("," , $conf['smiliessupport']);
    21         else
     20        } else {
    2221                $conf_smiliessupport = $new_conf;
     22        }
    2323
    2424        // edit field has a different id
    25         if (isset($_GET['action']) AND $_GET['action'] == 'edit_comment')
     25        if (
     26                (isset($_GET['action']) AND $_GET['action'] == 'edit_comment')
     27                OR (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage')
     28        ) {
    2629                $template->assign('form_name', 'editComment');
    27         else
     30        } else {
    2831                $template->assign('form_name', 'addComment');
     32        }
    2933
    3034        $cnt = 1;
     
    4044                        if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png"))
    4145                        {
    42                                 if (( $cnt > 0 ) && ( $cnt % $conf_smiliessupport[1] == 0 ))
    43                                 {
     46                                if (( $cnt > 0 ) && ( $cnt % $conf_smiliessupport[1] == 0 )) {
    4447                                        $trvalue = '</tr><tr>';
    4548                                }
     
    5154                        }
    5255                }
    53         }
    54         else
    55         {
     56               
     57        } else {
    5658                array_push($page['errors'], l10n('opendir failed : '.PHPWG_ROOT_PATH.$conf_smiliessupport[0].')' ));
    5759        }
     
    6668        $conf_smiliessupport = explode("," , $conf['smiliessupport']);
    6769        $def_path = $conf_smiliessupport[0].'/smilies.txt';
     70        $accepted_ext = array('gif', 'jpg', 'png');
    6871       
    6972        if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0]))
     
    7174                while (false !== ($file = readdir($handle)))
    7275                {
    73                         if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png")) {
     76                        if ($file != "." && $file != ".." && in_array(get_extension($file), $accepted_ext)) {
    7477                                $v = ':'.get_filename_wo_extension($file).':';
    7578                                $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" alt=":'.get_filename_wo_extension($file).':" title=":'.get_filename_wo_extension($file).':"/>';
     
    7982        }
    8083       
    81         if ( file_exists($def_path) )
     84        if (file_exists($def_path))
    8285        {
    8386                $def = file($def_path);
     
    8588                {
    8689                        $v = trim($v);
    87                         if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches))
    88                         {       
     90                        if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches)) { 
    8991                                $r = '#'.preg_quote($matches[1],'/').'#';                                       
    9092                                $t = '<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" alt=":'.get_filename_wo_extension($matches[2]).':" title=":'.get_filename_wo_extension($matches[2]).':"/>';
  • extensions/SmiliesSupport/smiliessupport_admin.tpl

    r9683 r9764  
    11{combine_script id='jquery'}
     2{combine_script id='jquery.cluetip' require='jquery' path='themes/default/js/plugins/jquery.cluetip.js'}
    23{include file='include/autosize.inc.tpl'}
     4
     5{footer_script}
     6{literal}
     7        jQuery().ready(function(){
     8                // Cluetip
     9                jQuery('.cluetip').cluetip({
     10                        width: 550,
     11                        splitTitle: '|'
     12                });
     13        });
     14{/literal}
     15{/footer_script}
     16
     17{html_head}
     18<style type="text/css">
     19        legend .cluetip {ldelim}
     20                text-align:center;
     21                margin:20px 0 -10px 0;
     22                font-size:1.2em;
     23        }
     24        .cluetip:after {ldelim}
     25                margin-left:5px;
     26                vertical-align:top;
     27                content:url('{$themeconf.admin_icon_dir}/help.png');
     28        }
     29</style>
     30{/html_head}
    331
    432<div class="titrePage">
     
    2957       
    3058        <fieldset>
    31                 <legend>smilies.txt</legend>
     59                <legend><span class="cluetip" title="smilies.txt|{'smilies_file_help'|@translate}">smilies.txt</legend>
    3260                <textarea rows="5" name="text">{$CONTENT_FILE}</textarea>
    3361        </fieldset>     
Note: See TracChangeset for help on using the changeset viewer.