Changeset 14526 for extensions
- Timestamp:
- Apr 29, 2012, 5:00:53 PM (12 years ago)
- Location:
- extensions/SmiliesSupport
- Files:
-
- 3 added
- 2 deleted
- 6 edited
- 45 copied
- 32 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmiliesSupport/admin.php
r10986 r14526 4 4 global $conf, $template; 5 5 load_language('plugin.lang', SMILIES_PATH); 6 $conf_smiliessupport = explode("," , $conf['smiliessupport']); 6 7 if (strpos($conf['smiliessupport'],',') !== false) 8 { 9 include(SMILIES_PATH .'maintain.inc.php'); 10 plugin_activate(); 11 } 12 13 $conf_smiliessupport = unserialize($conf['smiliessupport']); 7 14 8 15 // Enregistrement de la configuration … … 10 17 { 11 18 // 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']) 13 20 { 14 21 $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 } 15 34 } 16 35 17 36 // new configuration 18 37 $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', 22 41 ); 23 42 if (empty($_POST['text'])) $_POST['text'] = ':) smile.png'; 24 43 25 conf_update_param('smiliessupport', implode(",",$conf_smiliessupport));44 conf_update_param('smiliessupport', serialize($conf_smiliessupport)); 26 45 array_push($page['infos'], l10n('Information data registered in database')); 27 46 … … 29 48 if (!isset($not_save_file)) 30 49 { 31 $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';50 $smilies_file = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt'; 32 51 33 52 if (file_exists($smilies_file)) { … … 42 61 43 62 // 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]);63 if (!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']); 46 65 } 47 66 67 // get available sets 68 $sets = array(); 69 $handle = opendir(SMILIES_PATH.'smilies/'); 70 while (false !== ($file = readdir($handle))) 71 { 72 if ( $file != '.' && $file != '..' && is_dir(SMILIES_PATH.'smilies/'.$file) ) 73 { 74 $sets[$file] = $file; 75 } 76 } 77 closedir($handle); 78 79 // get available smilies 80 $smilies_table = $smilies = array(); 81 $handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder']); 82 $i = 1; 83 while (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 } 96 closedir($handle); 97 48 98 $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, 52 105 )); 53 106 54 // build the table of smilies55 include_once(SMILIES_PATH . '/smiliessupport.inc.php');56 $template->assign('smiliesfiles', get_smilies($conf_smiliessupport));57 58 107 // 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'; 60 109 if (file_exists($smilies_file)) { 61 110 $content_file = file_get_contents($smilies_file); -
extensions/SmiliesSupport/main.inc.php
r11294 r14526 22 22 global $page, $pwg_loaded_plugins; 23 23 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']) 27 27 ) { 28 28 set_smiliessupport(); -
extensions/SmiliesSupport/maintain.inc.php
r10986 r14526 4 4 function plugin_install() 5 5 { 6 conf_update_param('smiliessupport', 'plugins/SmiliesSupport/smilies_1,6,smile.png'); 7 } 8 9 function plugin_activate() 10 { 6 11 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)); 12 31 } 13 32 } … … 15 34 function plugin_uninstall() 16 35 { 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;'); 22 37 } 23 38 -
extensions/SmiliesSupport/smiliessupport.inc.php
r11450 r14526 8 8 9 9 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 25 12 $template->assign(array( 26 13 '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), 29 16 )); 30 17 … … 34 21 function set_smiliessupport_prefilter($content, &$smarty) 35 22 { 36 $search = "<label>{'Comment'|@translate}";23 $search = '<div id="commentAdd">'; 37 24 $replace = file_get_contents(SMILIES_PATH.'/template/smiliessupport_page.tpl').$search; 38 25 return str_replace($search, $replace, $content); … … 44 31 $accepted_ext = array('gif', 'jpg', 'png'); 45 32 46 if ($handle = opendir( PHPWG_ROOT_PATH.$conf_smiliessupport[0]))33 if ($handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'])) 47 34 { 48 35 $i = 1; … … 52 39 { 53 40 $smilies[] = array( 54 'PATH' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$file,41 'PATH' => SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$file, 55 42 '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, 57 44 ); 58 45 $i++; … … 60 47 } 61 48 49 closedir($handle); 62 50 return $smilies; 63 51 } … … 73 61 global $conf; 74 62 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'; 77 65 $accepted_ext = array('gif', 'jpg', 'png'); 78 66 $str = ' '.$str; 79 67 80 if ($handle = opendir( PHPWG_ROOT_PATH.$conf_smiliessupport[0]))68 if ($handle = opendir(SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'])) 81 69 { 82 70 while (false !== ($file = readdir($handle))) … … 86 74 $filename = get_filename_wo_extension($file); 87 75 $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.':"/>'; 89 77 $str = str_replace($v, $s, $str); 90 78 } 91 79 } 80 81 closedir($handle); 92 82 } 93 83 … … 102 92 $filename = get_filename_wo_extension($matches[2]); 103 93 $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.':"/>'; 105 95 $str = preg_replace($v, $t, $str); 106 96 } -
extensions/SmiliesSupport/template/smiliessupport_admin.tpl
r11875 r14526 2 2 {include file='include/autosize.inc.tpl'} 3 3 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: '|' 12 8 }); 13 {/literal} 14 {/footer_script} 9 {/literal}{/footer_script} 15 10 16 11 {html_head} … … 37 32 </div> 38 33 39 <form method="post" action="" class="properties" ENCTYPE="multipart/form-data">34 <form method="post" action="" class="properties"> 40 35 <fieldset> 41 36 <legend>{'Configuration'|@translate}</legend> … … 43 38 <li> 44 39 <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> 46 43 </li> 47 44 <li> … … 51 48 <li> 52 49 <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> 54 53 </li> 55 54 <li> -
extensions/SmiliesSupport/template/smiliessupport_page.tpl
r11875 r14526 6 6 jQuery(document).ready(function() { 7 7 if (jQuery('.markItUp').length == 0) { 8 jQuery('# {/literal}{$smilies_textarea}{literal}').markItUp({markupSet: []});8 jQuery('#contentid').markItUp({markupSet: []}); 9 9 } 10 10 jQuery('#SmiliesSupport').appendTo('.markItUpHeader ul:first-child'); 11 11 jQuery('#allsmilies').hover(function(){ 12 jQuery("# {/literal}{$smilies_textarea}{literal}").focus();12 jQuery("#contentid").focus(); 13 13 jQuery('#smiliesdiv').css('display',''); 14 14 }); … … 25 25 <ul style="display:none;"> 26 26 <li id="SmiliesSupport" class="markItUpButton markItUpDropMenu"> 27 <a id="allsmilies" style="background-image:url({$R epresentative});" title="{'All Smilies'|@translate}"></a>27 <a id="allsmilies" style="background-image:url({$REPRESENTANT});" title="{'All Smilies'|@translate}"></a> 28 28 29 29 <ul id="smiliesdiv">
Note: See TracChangeset
for help on using the changeset viewer.