Changeset 14526


Ignore:
Timestamp:
04/29/12 17:00:53 (8 years ago)
Author:
mistic100
Message:

update for 2.4

Location:
extensions/SmiliesSupport
Files:
3 added
2 deleted
6 edited
45 copied
32 moved

Legend:

Unmodified
Added
Removed
  • extensions/SmiliesSupport/admin.php

    r10986 r14526  
    44global $conf, $template; 
    55load_language('plugin.lang', SMILIES_PATH); 
    6 $conf_smiliessupport = explode("," , $conf['smiliessupport']); 
     6 
     7if (strpos($conf['smiliessupport'],',') !== false) 
     8{ 
     9  include(SMILIES_PATH .'maintain.inc.php'); 
     10  plugin_activate(); 
     11} 
     12 
     13$conf_smiliessupport = unserialize($conf['smiliessupport']); 
    714 
    815// Enregistrement de la configuration 
     
    1017{ 
    1118  // the smilies.txt file is not saved if the directory is changed 
    12   if (isset($_POST['text1']) AND $_POST['text1'] != $conf_smiliessupport[0])  
     19  if (isset($_POST['text1']) AND $_POST['text1'] != $conf_smiliessupport['folder'])  
    1320  { 
    1421    $not_save_file = true; 
     22     
     23    $handle = opendir(SMILIES_PATH.'smilies/'.$_POST['text1']); 
     24    $i = 0; 
     25    while (false !== ($file = readdir($handle))) 
     26    { 
     27      if ( $file != '.' AND $file != '..' AND in_array(get_extension($file), array('gif', 'jpg', 'png')) ) 
     28      { 
     29        $_POST['text3'] = $file; 
     30        closedir($handle); 
     31        break; 
     32      } 
     33    } 
    1534  } 
    1635   
    1736  // new configuration 
    1837  $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', 
     38    'folder' => isset($_POST['text1']) ? $_POST['text1'] : 'crystal', 
     39    'cols' => isset($_POST['text2']) ? $_POST['text2'] : '6', 
     40    'representant' => isset($_POST['text3']) ? $_POST['text3'] : 'smile.png', 
    2241  ); 
    2342  if (empty($_POST['text'])) $_POST['text'] = ':)    smile.png'; 
    2443     
    25   conf_update_param('smiliessupport', implode(",", $conf_smiliessupport)); 
     44  conf_update_param('smiliessupport', serialize($conf_smiliessupport)); 
    2645  array_push($page['infos'], l10n('Information data registered in database')); 
    2746   
     
    2948  if (!isset($not_save_file))  
    3049  { 
    31     $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';       
     50    $smilies_file = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt';       
    3251 
    3352    if (file_exists($smilies_file)) { 
     
    4261 
    4362// check if the representant exists 
    44 if (!file_exists(PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2])) { 
    45   array_push($page['errors'], l10n('File/directory read error').' : '.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2]); 
     63if (!file_exists(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$conf_smiliessupport['representant'])) { 
     64  array_push($page['errors'], l10n('File/directory read error').' : smilies/'.$conf_smiliessupport['folder'].'/'.$conf_smiliessupport['representant']); 
    4665} 
    4766 
     67// get available sets 
     68$sets = array(); 
     69$handle = opendir(SMILIES_PATH.'smilies/'); 
     70while (false !== ($file = readdir($handle))) 
     71{  
     72  if ( $file != '.' && $file != '..' && is_dir(SMILIES_PATH.'smilies/'.$file) ) 
     73  { 
     74    $sets[$file] = $file; 
     75  } 
     76} 
     77closedir($handle); 
     78 
     79// get available smilies 
     80$smilies_table = $smilies = array(); 
     81$handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder']); 
     82$i = 1; 
     83while (false !== ($file = readdir($handle))) 
     84{ 
     85  if ( $file != '.' AND $file != '..' AND in_array(get_extension($file), array('gif', 'jpg', 'png')) ) 
     86  { 
     87    $smilies[$file] = $file; 
     88    $smilies_table[] = array( 
     89      'PATH' => SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$file, 
     90      'TITLE' => ':'.get_filename_wo_extension($file).':', 
     91      'TR' => ($i>0 AND $i%$conf_smiliessupport['cols'] == 0) ? '</tr><tr>' : null, 
     92    ); 
     93    $i++; 
     94  } 
     95} 
     96closedir($handle); 
     97 
    4898$template->assign(array( 
    49   'TEXT1_VALUE' => $conf_smiliessupport[0], 
    50   'TEXT2_VALUE' => $conf_smiliessupport[1], 
    51   'TEXT3_VALUE' => $conf_smiliessupport[2], 
     99  'TEXT1_VALUE' => $conf_smiliessupport['folder'], 
     100  'TEXT2_VALUE' => $conf_smiliessupport['cols'], 
     101  'TEXT3_VALUE' => $conf_smiliessupport['representant'], 
     102  'sets' => $sets, 
     103  'smiliesfiles' => $smilies_table, 
     104  'smilies' => $smilies, 
    52105)); 
    53106 
    54 // build the table of smilies 
    55 include_once(SMILIES_PATH . '/smiliessupport.inc.php'); 
    56 $template->assign('smiliesfiles', get_smilies($conf_smiliessupport)); 
    57  
    58107// get the content of definitions file 
    59 $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt'; 
     108$smilies_file = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt'; 
    60109if (file_exists($smilies_file)) { 
    61110  $content_file = file_get_contents($smilies_file); 
  • extensions/SmiliesSupport/main.inc.php

    r11294 r14526  
    2222  global $page, $pwg_loaded_plugins; 
    2323   
    24   if ( 
    25     !isset($pwg_loaded_plugins['bbcode_bar'])  
    26     AND isset($page['body_id']) AND $page['body_id'] == 'thePicturePage' 
     24  // if BBCodeBar is installed let him manage smilies 
     25  if ( isset($page['body_id']) AND $page['body_id'] == 'thePicturePage' 
     26    AND !isset($pwg_loaded_plugins['bbcode_bar']) 
    2727  ) { 
    2828    set_smiliessupport(); 
  • extensions/SmiliesSupport/maintain.inc.php

    r10986 r14526  
    44function plugin_install() 
    55{ 
     6  conf_update_param('smiliessupport', 'plugins/SmiliesSupport/smilies_1,6,smile.png'); 
     7} 
     8 
     9function plugin_activate() 
     10{ 
    611  global $conf; 
    7  
    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   
     13  if (strpos($conf['smiliessupport'],',') !== false) 
     14  { 
     15    $conf_smiliessupport = explode(',', $conf['smiliessupport']); 
     16     
     17    switch ($conf_smiliessupport[0]) 
     18    { 
     19      case 'plugins/SmiliesSupport/smilies': $conf_smiliessupport[0] = 'ipb'; break; 
     20      case 'plugins/SmiliesSupport/smilies_2': $conf_smiliessupport[0] = 'sylvia'; break; 
     21      default: $conf_smiliessupport[0] = 'crystal'; break; 
     22    } 
     23     
     24    $new_smiliessupport =  array( 
     25      'folder'       => $conf_smiliessupport[0], 
     26      'cols'         => $conf_smiliessupport[1], 
     27      'representant' => $conf_smiliessupport[2], 
     28    ); 
     29     
     30    conf_update_param('smiliessupport', serialize($new_smiliessupport)); 
    1231  } 
    1332} 
     
    1534function plugin_uninstall() 
    1635{ 
    17   global $conf; 
    18  
    19   if (isset($conf['smiliessupport'])) { 
    20     pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE param="smiliessupport" LIMIT 1;'); 
    21   } 
     36  pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE param="smiliessupport" LIMIT 1;'); 
    2237} 
    2338 
  • extensions/SmiliesSupport/smiliessupport.inc.php

    r11450 r14526  
    88   
    99  load_language('plugin.lang', SMILIES_PATH); 
    10   $conf_smiliessupport = explode(',' , $conf['smiliessupport']); 
    11    
    12   $smilies = get_smilies($conf_smiliessupport); 
    13    
    14   // edit field has different id 
    15   // if ( 
    16     // (isset($_GET['action']) AND $_GET['action'] == 'edit_comment')  
    17     // OR (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage') 
    18   // ) { 
    19     // $template->assign('smilies_textarea', 'contenteditid'); 
    20   // } else { 
    21     // $template->assign('smilies_textarea', 'contentid'); 
    22   // } 
    23   $template->assign('smilies_textarea', 'contentid'); 
    24    
     10  $conf_smiliessupport = unserialize($conf['smiliessupport']); 
     11 
    2512  $template->assign(array( 
    2613    'SMILIES_PATH' => SMILIES_PATH, 
    27     'REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2], 
    28     'smiliesfiles' => $smilies, 
     14    'REPRESENTANT' => SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$conf_smiliessupport['representant'], 
     15    'smiliesfiles' => get_smilies($conf_smiliessupport), 
    2916  )); 
    3017   
     
    3421function set_smiliessupport_prefilter($content, &$smarty) 
    3522{ 
    36   $search = "<label>{'Comment'|@translate}"; 
     23  $search = '<div id="commentAdd">'; 
    3724  $replace = file_get_contents(SMILIES_PATH.'/template/smiliessupport_page.tpl').$search; 
    3825  return str_replace($search, $replace, $content); 
     
    4431  $accepted_ext = array('gif', 'jpg', 'png'); 
    4532   
    46   if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0])) 
     33  if ($handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'])) 
    4734  { 
    4835    $i = 1; 
     
    5239      { 
    5340        $smilies[] = array( 
    54           'PATH' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$file, 
     41          'PATH' => SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$file, 
    5542          'TITLE' => ':'.get_filename_wo_extension($file).':', 
    56           'TR' => ($i>0 AND $i%$conf_smiliessupport[1] == 0) ? '</tr><tr>' : null, 
     43          'TR' => ($i>0 AND $i%$conf_smiliessupport['cols'] == 0) ? '</tr><tr>' : null, 
    5744        ); 
    5845        $i++; 
     
    6047    } 
    6148     
     49    closedir($handle); 
    6250    return $smilies; 
    6351  }  
     
    7361  global $conf; 
    7462 
    75   $conf_smiliessupport = explode("," , $conf['smiliessupport']); 
    76   $def_path = $conf_smiliessupport[0].'/smilies.txt'; 
     63  $conf_smiliessupport = unserialize($conf['smiliessupport']); 
     64  $def_path = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt'; 
    7765  $accepted_ext = array('gif', 'jpg', 'png'); 
    7866  $str = ' '.$str; 
    7967   
    80   if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0])) 
     68  if ($handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'])) 
    8169  { 
    8270    while (false !== ($file = readdir($handle))) 
     
    8674        $filename = get_filename_wo_extension($file); 
    8775        $v = ':'.$filename.':';  
    88         $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" alt=":'.$filename.':"/>'; 
     76        $s = '<img src="'.SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$file.'" alt=":'.$filename.':"/>'; 
    8977        $str = str_replace($v, $s, $str); 
    9078      } 
    9179    } 
     80     
     81    closedir($handle); 
    9282  } 
    9383   
     
    10292        $filename = get_filename_wo_extension($matches[2]); 
    10393        $v = '#([^"])'.preg_quote($matches[1],'/').'#';           
    104         $t = '$1<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" alt=":'.$filename.':"/>'; 
     94        $t = '$1<img src="'.SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$matches[2].'" alt=":'.$filename.':"/>'; 
    10595        $str = preg_replace($v, $t, $str); 
    10696      } 
  • extensions/SmiliesSupport/template/smiliessupport_admin.tpl

    r11875 r14526  
    22{include file='include/autosize.inc.tpl'} 
    33 
    4 {footer_script require="jquery.cluetip"} 
    5 {literal} 
    6   jQuery().ready(function(){ 
    7     // Cluetip 
    8     jQuery('.cluetip').cluetip({ 
    9       width: 550, 
    10       splitTitle: '|' 
    11     }); 
     4{footer_script require="jquery.cluetip"}{literal} 
     5  jQuery('.cluetip').cluetip({ 
     6    width: 550, 
     7    splitTitle: '|' 
    128  }); 
    13 {/literal} 
    14 {/footer_script} 
     9{/literal}{/footer_script} 
    1510 
    1611{html_head} 
     
    3732</div> 
    3833 
    39 <form method="post" action="" class="properties" ENCTYPE="multipart/form-data">  
     34<form method="post" action="" class="properties">  
    4035  <fieldset> 
    4136      <legend>{'Configuration'|@translate}</legend>     
     
    4338    <li> 
    4439      <span class="property">{'Smileys\' folder'|@translate}</span> 
    45       <input type="text" size="40" name="text1" value="{$TEXT1_VALUE}" /> 
     40      <select name="text1"> 
     41        {html_options options=$sets selected=$TEXT1_VALUE} 
     42      </select> 
    4643    </li> 
    4744    <li> 
     
    5148    <li> 
    5249      <span class="property">{'Representative'|@translate}</span> 
    53       <input type="text" size="20" name="text3" value="{$TEXT3_VALUE}" /> 
     50      <select name="text3"> 
     51        {html_options options=$smilies selected=$TEXT3_VALUE} 
     52      </select> 
    5453    </li> 
    5554    <li> 
  • extensions/SmiliesSupport/template/smiliessupport_page.tpl

    r11875 r14526  
    66jQuery(document).ready(function() { 
    77  if (jQuery('.markItUp').length == 0) { 
    8     jQuery('#{/literal}{$smilies_textarea}{literal}').markItUp({markupSet: []}); 
     8    jQuery('#contentid').markItUp({markupSet: []}); 
    99  } 
    1010  jQuery('#SmiliesSupport').appendTo('.markItUpHeader ul:first-child'); 
    1111  jQuery('#allsmilies').hover(function(){  
    12     jQuery("#{/literal}{$smilies_textarea}{literal}").focus(); 
     12    jQuery("#contentid").focus(); 
    1313    jQuery('#smiliesdiv').css('display','');  
    1414  }); 
     
    2525<ul style="display:none;"> 
    2626<li id="SmiliesSupport" class="markItUpButton markItUpDropMenu"> 
    27   <a id="allsmilies" style="background-image:url({$Representative});" title="{'All Smilies'|@translate}"></a> 
     27  <a id="allsmilies" style="background-image:url({$REPRESENTANT});" title="{'All Smilies'|@translate}"></a> 
    2828 
    2929  <ul id="smiliesdiv"> 
Note: See TracChangeset for help on using the changeset viewer.