Changeset 9683 for extensions/SmiliesSupport
- Timestamp:
- Mar 14, 2011, 9:38:51 PM (14 years ago)
- Location:
- extensions/SmiliesSupport
- Files:
-
- 8 added
- 9 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmiliesSupport/main.inc.php
r6774 r9683 2 2 /* 3 3 Plugin Name: Smilies Support 4 Version: auto4 Version: 2.2.0 5 5 Description: Allow add Smilies for comments and descriptions. 6 6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=159 7 Author: Atadilo & P@t 7 Author: Atadilo & P@t & Mistic 8 8 */ 9 9 10 10 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 11 11 12 include_once(dirname(__FILE__).'/smiliessupport.inc.php'); 12 define('SMILIES_DIR' , basename(dirname(__FILE__))); 13 define('SMILIES_PATH' , PHPWG_PLUGINS_PATH . SMILIES_DIR . '/'); 14 15 include_once(SMILIES_PATH.'smiliessupport.inc.php'); 13 16 14 17 add_event_handler('render_comment_content', 'SmiliesParse', 60); … … 17 20 if (script_basename() == 'admin') 18 21 { 19 20 21 function smiliessupport_admin_menu($menu){22 array_push($menu, 23 array('NAME' => 'Smilies Support',24 'URL' => get_admin_plugin_menu_link(dirname(__FILE__) . '/smiliessupport_admin.php')));25 26 22 add_event_handler('get_admin_plugin_menu_links', 'smiliessupport_admin_menu'); 23 function smiliessupport_admin_menu($menu) 24 { 25 array_push($menu, array( 26 'NAME' => 'Smilies Support', 27 'URL' => get_root_url().'admin.php?page=plugin-' . SMILIES_DIR)); 28 return $menu; 29 } 27 30 } 28 31 ?> -
extensions/SmiliesSupport/maintain.inc.php
r3304 r9683 1 1 <?php 2 3 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 3 5 4 function plugin_install() 6 5 { 7 6 global $conf; 8 7 9 10 11 12 VALUES ("smiliessupport","plugins/SmiliesSupport/smilies,5,sourire.gif","Parametres SmiliesSupport");';13 14 8 if (!isset($conf['smiliessupport'])) 9 { 10 $q = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) 11 VALUES ("smiliessupport","plugins/SmiliesSupport/smilies,5,sourire.gif","Parametres SmiliesSupport");'; 12 pwg_query($q); 13 } 15 14 } 16 15 17 16 function plugin_uninstall() 18 17 { 19 18 global $conf; 20 19 21 22 23 24 20 if (isset($conf['smiliessupport'])) 21 { 22 pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE param="smiliessupport" LIMIT 1;'); 23 } 25 24 } 25 26 ?> -
extensions/SmiliesSupport/smiliessupport.inc.php
r6298 r9683 1 1 <?php 2 3 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 3 5 4 function set_smiliessupport_page() 6 5 { 7 6 global $template, $lang, $pwg_loaded_plugins; 8 7 9 10 11 12 8 if (!isset($pwg_loaded_plugins['bbcode_bar'])) 9 { 10 $lang['Comment'] .= SmiliesTable(); 11 } 13 12 } 14 13 15 function SmiliesTable( )14 function SmiliesTable($new_conf=null) 16 15 { 17 16 global $conf, $template; 18 17 19 $conf_smiliessupport = explode("," , $conf['smiliessupport']); 18 // this is for live update on admin page 19 if (empty($new_conf)) 20 $conf_smiliessupport = explode("," , $conf['smiliessupport']); 21 else 22 $conf_smiliessupport = $new_conf; 20 23 21 $cnt = 1; 22 23 $template->set_filename('smiliessupport_page', dirname(__FILE__).'/smiliessupport_page.tpl'); 24 25 $template->assign(array('REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2])); 26 27 if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0])) 28 { 29 while (false !== ($file = readdir($handle))) 30 { 31 $trvalue = ''; 24 // edit field has a different id 25 if (isset($_GET['action']) AND $_GET['action'] == 'edit_comment') 26 $template->assign('form_name', 'editComment'); 27 else 28 $template->assign('form_name', 'addComment'); 32 29 33 if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png")) 34 { 35 if (( $cnt > 0 ) && ( $cnt % $conf_smiliessupport[1] == 0 )) 36 { 37 $trvalue = '</tr><tr>'; 38 } 39 $cnt = $cnt + 1; 40 $template->append('smiliesfiles', 41 array('PATH' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$file, 42 'TITLE' => ':'.get_filename_wo_extension($file).':', 43 'TR'=>$trvalue)); 44 } 45 } 46 } 47 else 48 { 49 array_push($page['errors'], l10n('opendir failed : '.PHPWG_ROOT_PATH.$conf_smiliessupport[0].')' )); 50 } 51 return $template->parse('smiliessupport_page', true); 30 $cnt = 1; 31 $template->set_filename('smiliessupport_page', dirname(__FILE__).'/smiliessupport_page.tpl'); 32 $template->assign(array('REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2])); 33 34 if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0])) 35 { 36 while (false !== ($file = readdir($handle))) 37 { 38 $trvalue = ''; 39 40 if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png")) 41 { 42 if (( $cnt > 0 ) && ( $cnt % $conf_smiliessupport[1] == 0 )) 43 { 44 $trvalue = '</tr><tr>'; 45 } 46 $cnt = $cnt + 1; 47 $template->append('smiliesfiles', 48 array('PATH' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$file, 49 'TITLE' => ':'.get_filename_wo_extension($file).':', 50 'TR'=>$trvalue)); 51 } 52 } 53 } 54 else 55 { 56 array_push($page['errors'], l10n('opendir failed : '.PHPWG_ROOT_PATH.$conf_smiliessupport[0].')' )); 57 } 58 59 return $template->parse('smiliessupport_page', true); 52 60 } 53 61 54 62 function SmiliesParse($str) 55 63 { 56 global $conf; 57 58 $conf_smiliessupport = explode("," , $conf['smiliessupport']); 59 60 $def_path = $conf_smiliessupport[0].'/smilies.txt'; 61 if ( file_exists($def_path) ) 62 { 63 $def = file($def_path); 64 foreach($def as $v) 65 { 66 $v = trim($v); 67 if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches)) 68 { 69 $r[] = '/(\A|[\s]+|>)('.preg_quote($matches[1],'/').')([\s]+|[<]|\Z)/ms'; 70 $s[] = '<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" '.'alt="$2" title="$2" />'; 71 $str = preg_replace($r, $s, $str); 72 } 73 } 74 } 75 if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0])) 76 { 77 while (false !== ($file = readdir($handle))) 78 { 79 if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png")) { 80 $v = ':'.get_filename_wo_extension($file).':'; 81 $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" '.'alt="'.get_filename_wo_extension($file).'" title="'.get_filename_wo_extension($file).'" />'; 82 $str = str_replace($v, $s, $str); 83 } 84 } 85 } 86 return $str; 64 global $conf; 65 66 $conf_smiliessupport = explode("," , $conf['smiliessupport']); 67 $def_path = $conf_smiliessupport[0].'/smilies.txt'; 68 69 if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0])) 70 { 71 while (false !== ($file = readdir($handle))) 72 { 73 if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png")) { 74 $v = ':'.get_filename_wo_extension($file).':'; 75 $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" alt=":'.get_filename_wo_extension($file).':" title=":'.get_filename_wo_extension($file).':"/>'; 76 $str = str_replace($v, $s, $str); 77 } 78 } 79 } 80 81 if ( file_exists($def_path) ) 82 { 83 $def = file($def_path); 84 foreach($def as $v) 85 { 86 $v = trim($v); 87 if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches)) 88 { 89 $r = '#'.preg_quote($matches[1],'/').'#'; 90 $t = '<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" alt=":'.get_filename_wo_extension($matches[2]).':" title=":'.get_filename_wo_extension($matches[2]).':"/>'; 91 $str = preg_replace($r, $t, $str); 92 } 93 } 94 } 95 96 return $str; 87 97 } 98 88 99 ?> -
extensions/SmiliesSupport/smiliessupport_admin.tpl
r3304 r9683 1 {combine_script id='jquery'} 2 {include file='include/autosize.inc.tpl'} 3 1 4 <div class="titrePage"> 2 5 <h2>Smilies Support</h2> 3 6 </div> 4 <form method="post" action="" class="properties" ENCTYPE="multipart/form-data"> 5 < div align="center">7 8 <form method="post" action="" class="properties" ENCTYPE="multipart/form-data"> 6 9 <fieldset> 7 <legend>SmiliesSupport</legend> 8 <UL> 9 <LI>Location : <input type="text" size="40" name="text1" value="{$TEXT1_VALUE}" /> </LI> 10 <LI>Nb Column : <input type="text" size="20" name="text2" value="{$TEXT2_VALUE}" /> </LI> 11 <LI>Representant : <input type="text" size="20" name="text3" value="{$TEXT3_VALUE}" /> </LI> 12 <LI>{$SMILIESSUPPORT_PAGE}</LI> 13 </UL> 10 <legend>{'Configuration'|@translate}</legend> 11 <ul> 12 <li> 13 <span class="property">{'smilies_dir'|@translate}</span> 14 <input type="text" size="40" name="text1" value="{$TEXT1_VALUE}" /> 15 </li> 16 <li> 17 <span class="property">{'nb_columns'|@translate}</span> 18 <input type="text" size="3" name="text2" value="{$TEXT2_VALUE}" /> 19 </li> 20 <li> 21 <span class="property">{'representant'|@translate}</span> 22 <input type="text" size="20" name="text3" value="{$TEXT3_VALUE}" /> 23 </li> 24 <li> 25 <table><tr><td>{$SMILIESSUPPORT_PAGE}</td></tr></table> 26 </li> 27 </ul> 14 28 </fieldset> 29 15 30 <fieldset> 16 31 <legend>smilies.txt</legend> 17 <textarea rows=" 30" name="text" cols="100">{$CONTENT_FILE}</textarea>32 <textarea rows="5" name="text">{$CONTENT_FILE}</textarea> 18 33 </fieldset> 19 <input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" />20 </div>34 35 <p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p> 21 36 </form> -
extensions/SmiliesSupport/smiliessupport_page.css
r3304 r9683 2 2 position:absolute; 3 3 z-index:1000; 4 width:10px;5 4 visibility:hidden; 6 5 } … … 8 7 .smiliestable { 9 8 background: buttonface; 10 border-top: 1px solid; 11 border-left: 1px solid; 12 border-bottom: 1px solid; 13 border-right: 1px solid; 9 border: 1px solid; 14 10 margin: 1; 15 11 } 16 12 17 #smiliesdiv IMG{13 #smiliesdiv img { 18 14 cursor: pointer; 19 15 } 16 17 .properties textarea { 18 width:80%; 19 margin:0 10%; 20 } -
extensions/SmiliesSupport/smiliessupport_page.tpl
r3304 r9683 1 {known_script id="smiliessupport" src=$ROOT_URL|@cat:"plugins/SmiliesSupport/smiliessupport.js"} 2 {html_head} 3 <link rel="stylesheet" type="text/css" href="{$ROOT_URL|@cat:"plugins/SmiliesSupport/smiliessupport_page.css"}" > 4 {/html_head} 1 {combine_script id="jquery"} 2 {combine_script id="smiliessupport" path=$ROOT_URL|@cat:"plugins/SmiliesSupport/smiliessupport.js"} 3 {combine_css path=$ROOT_URL|@cat:"plugins/SmiliesSupport/smiliessupport_page.css"} 5 4 6 <img id="allsmilies" src="{$REPRESENTANT}" title="All Smilies" onmouseover="document.getElementById('smiliesdiv').style.visibility='visible';" > 7 <div id="smiliesdiv" > 8 <table class="smiliestable" 9 onmouseover="document.getElementById('smiliesdiv').style.visibility='visible';" 10 onmouseout="document.getElementById('smiliesdiv').style.visibility='hidden';" > 11 <tr> 12 {foreach from=$smiliesfiles item=smiliesfile} 13 <td><img src="{$smiliesfile.PATH}" title="{$smiliesfile.TITLE}" onclick="SmiliesWrite('addComment', 'content', '', '{$smiliesfile.TITLE}', true); document.getElementById('smiliesdiv').style.visibility='hidden';"> </td> 14 {$smiliesfile.TR} 15 {/foreach} 16 </tr> 17 </table> 5 <div width="500pt"> 6 <img id="allsmilies" src="{$REPRESENTANT}" title="All Smilies" onmouseover="jQuery('#smiliesdiv').css('visibility','visible');"> 7 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> 18 20 </div>
Note: See TracChangeset
for help on using the changeset viewer.