Changeset 9966 for extensions/SmiliesSupport/smiliessupport.inc.php
- Timestamp:
- Apr 1, 2011, 10:56:28 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note: See TracChangeset
for help on using the changeset viewer.