Changeset 9966 for extensions/SmiliesSupport
- Timestamp:
- Apr 1, 2011, 10:56:28 PM (13 years ago)
- Location:
- extensions/SmiliesSupport
- Files:
-
- 5 added
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmiliesSupport/admin.php
r9789 r9966 10 10 { 11 11 // the smilies.txt file is not saved if the directory is changed 12 if (isset($_POST['text1']) AND $_POST['text1'] != $conf_smiliessupport[0]) { 12 if (isset($_POST['text1']) AND $_POST['text1'] != $conf_smiliessupport[0]) 13 { 13 14 $not_save_file = true; 14 15 } 15 16 17 // new configuration 16 18 $conf_smiliessupport = array( 17 19 isset($_POST['text1']) ? $_POST['text1'] : 'plugins/SmiliesSupport/smilies_1', … … 19 21 isset($_POST['text3']) ? $_POST['text3'] : 'smile.png', 20 22 ); 21 22 23 if (empty($_POST['text'])) $_POST['text'] = ':) smile.png'; 23 24 24 $new_value_smiliessupport = implode 25 $query = 'UPDATE ' . CONFIG_TABLE . '26 SET value= "' . $new_value_smiliessupport . '"27 WHERE param= "smiliessupport"';25 $new_value_smiliessupport = implode(",", $conf_smiliessupport); 26 $query = "UPDATE " . CONFIG_TABLE . " 27 SET value='" . $new_value_smiliessupport . "' 28 WHERE param='smiliessupport'"; 28 29 pwg_query($query); 29 30 if (!isset($not_save_file)) { 30 31 // new definitions file 32 if (!isset($not_save_file)) 33 { 31 34 $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt'; 32 35 … … 38 41 $page['infos'][] = l10n('Information data registered in database'); 39 42 } else { 40 $page['errors'][] = l10n('File/directory read error').' '.$smilies_file;43 $page['errors'][] = l10n('File/directory read error').' : '.$smilies_file; 41 44 } 42 45 } 46 } 47 48 // check if the representant exists 49 if (!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]; 43 51 } 44 52 … … 49 57 )); 50 58 59 // build the table of smilies 51 60 include_once(SMILIES_PATH . '/smiliessupport.inc.php'); 52 $template->assign(' SMILIESSUPPORT_PAGE', SmiliesTable($conf_smiliessupport));61 $template->assign('smiliesfiles', get_smilies($conf_smiliessupport)); 53 62 63 // get the content of definitions file 54 64 $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt'; 55 56 65 if (file_exists($smilies_file)) { 57 66 $content_file = file_get_contents($smilies_file); -
extensions/SmiliesSupport/main.inc.php
r9789 r9966 19 19 20 20 function add_smiliessupport() { 21 global $page; 22 if ($page['body_id'] == 'theCommentsPage' OR $page['body_id'] == 'thePicturePage') { 23 set_smiliessupport_page(); 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(); 24 27 } 25 28 } -
extensions/SmiliesSupport/smiliessupport.inc.php
r9789 r9966 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 function set_smiliessupport_page() 4 // add smilies button to the comment field 5 function set_smiliessupport() 5 6 { 6 global $template, $lang, $pwg_loaded_plugins; 7 global $conf, $lang; 8 $conf_smiliessupport = explode(',' , $conf['smiliessupport']); 9 10 $smilies = get_smilies($conf_smiliessupport); 11 $lang['Comment'] .= SmiliesTable($conf_smiliessupport, $smilies); 12 } 7 13 8 if (!isset($pwg_loaded_plugins['bbcode_bar'])) { 9 $lang['Comment'] .= SmiliesTable(); 14 // return an array with available smilies (name and path) ## must received the unserialized configuration array 15 function get_smilies($conf_smiliessupport) 16 { 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; 10 38 } 11 39 } 12 40 13 function SmiliesTable($new_conf=null) 41 // get the smilies button ## must received the unserialized configuration array AND the smilies array 42 function SmiliesTable($conf_smiliessupport, $smilies) 14 43 { 15 global $conf, $template, $page; 44 global $template; 45 load_language('plugin.lang', SMILIES_PATH); 16 46 17 // this is for live update on admin page 18 if (empty($new_conf)) { 19 $conf_smiliessupport = explode("," , $conf['smiliessupport']); 20 } else { 21 $conf_smiliessupport = $new_conf; 22 } 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'); 23 57 24 // edit field has a different id 25 if ( 26 (isset($_GET['action']) AND $_GET['action'] == 'edit_comment') 27 OR (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage') 28 ) { 29 $template->assign('form_name', 'editComment'); 30 } else { 31 $template->assign('form_name', 'addComment'); 32 } 33 34 $cnt = 1; 35 $template->assign('SMILIES_PATH', SMILIES_PATH); 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 36 64 $template->set_filename('smiliessupport_page', dirname(__FILE__).'/template/smiliessupport_page.tpl'); 37 $template->assign(array('REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2]));38 39 if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0]))40 {41 while (false !== ($file = readdir($handle)))42 {43 $trvalue = '';44 45 if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png"))46 {47 if (( $cnt > 0 ) && ( $cnt % $conf_smiliessupport[1] == 0 )) {48 $trvalue = '</tr><tr>';49 }50 $cnt = $cnt + 1;51 $template->append('smiliesfiles',52 array('PATH' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$file,53 'TITLE' => ':'.get_filename_wo_extension($file).':',54 'TR'=>$trvalue));55 }56 }57 58 } else {59 array_push($page['errors'], l10n('opendir failed : '.PHPWG_ROOT_PATH.$conf_smiliessupport[0].')' ));60 }61 62 65 return $template->parse('smiliessupport_page', true); 63 66 } 64 67 68 // parse smilies 65 69 function SmiliesParse($str) 66 70 { -
extensions/SmiliesSupport/template/smiliessupport_admin.tpl
r9789 r9966 26 26 content:url('{$themeconf.admin_icon_dir}/help.png'); 27 27 } 28 .properties textarea {ldelim} 29 width:60%; 30 margin:0 20%; 31 } 28 32 </style> 29 33 {/html_head} … … 50 54 </li> 51 55 <li> 52 <table><tr><td>{$SMILIESSUPPORT_PAGE}</td></tr></table> 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> 53 62 </li> 54 63 </ul> -
extensions/SmiliesSupport/template/smiliessupport_page.tpl
r9789 r9966 1 {combine_script id="jquery"} 2 {combine_script id="smiliessupport" path=$SMILIES_PATH|@cat:"template/smiliessupport.js"} 3 {combine_css path=$SMILIES_PATH|@cat:"template/smiliessupport_page.css"} 1 {combine_script id="markitup" require='jquery' path=$SMILIES_PATH|@cat:"template/markitup/jquery.markitup.js"} 2 {combine_css path=$SMILIES_PATH|@cat:"template/markitup/style.markitup.css"} 4 3 5 <div width="500pt"> 6 <img id="allsmilies" src="{$REPRESENTANT}" title="{'All Smilies'|@translate}" onmouseover="jQuery('#smiliesdiv').css('visibility','visible');"> 4 {footer_script require='jquery'} 5 {literal} 6 $(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("title"); 17 jQuery.markItUp({ replaceWith:emoticon }); 18 jQuery('#smiliesdiv').css('display','none'); 19 return false; 20 }); 21 }); 22 {/literal} 23 {/footer_script} 7 24 8 <div id="smiliesdiv" > 9 <table class="smiliestable" 10 onmouseover="jQuery('#smiliesdiv').css('visibility','visible');" 11 onmouseout="jQuery('#smiliesdiv').css('visibility','hidden');"> 12 <tr> 13 {foreach from=$smiliesfiles item=smiliesfile} 14 <td><img src="{$smiliesfile.PATH}" title="{$smiliesfile.TITLE}" onclick="SmiliesWrite('{$form_name}','content','','{$smiliesfile.TITLE}',true); jQuery('#smiliesdiv').css('visibility','hidden');"> </td> 15 {$smiliesfile.TR} 16 {/foreach} 17 </tr> 18 </table> 19 </div> 20 </div> 25 <li id="SmiliesSupport" class="markItUpButton markItUpDropMenu"> 26 <a id="allsmilies" style="background-image:url({$REPRESENTANT});" title="{'All Smilies'|@translate}"></a> 27 28 <ul id="smiliesdiv"> 29 <li><table><tr> 30 {foreach from=$smiliesfiles item=smileyfile} 31 <td><a href="#" title="{$smileyfile.TITLE}"><img src="{$smileyfile.PATH}"/></a></td> 32 {$smileyfile.TR} 33 {/foreach} 34 </tr></table></li> 35 </ul> 36 </li>
Note: See TracChangeset
for help on using the changeset viewer.