Changeset 11294 for extensions/SmiliesSupport/smiliessupport.inc.php
- Timestamp:
- Jun 10, 2011, 9:02:29 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmiliesSupport/smiliessupport.inc.php
r10986 r11294 5 5 function set_smiliessupport() 6 6 { 7 global $conf, $lang; 7 global $conf, $template, $page; 8 9 load_language('plugin.lang', SMILIES_PATH); 8 10 $conf_smiliessupport = explode(',' , $conf['smiliessupport']); 9 11 10 12 $smilies = get_smilies($conf_smiliessupport); 11 $lang['Comment'] .= SmiliesTable($conf_smiliessupport, $smilies); 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 25 $template->assign(array( 26 'SMILIES_PATH' => SMILIES_PATH, 27 'REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2], 28 'smiliesfiles' => $smilies, 29 )); 30 31 $template->set_prefilter('picture', 'set_smiliessupport_prefilter'); 32 } 33 34 function set_smiliessupport_prefilter($content, &$smarty) 35 { 36 $search = "<label>{'Comment'|@translate}"; 37 $replace = file_get_contents(SMILIES_PATH.'/template/smiliessupport_page.tpl').$search; 38 return str_replace($search, $replace, $content); 12 39 } 13 40 … … 34 61 35 62 return $smilies; 36 } else { 63 } 64 else 65 { 37 66 return false; 38 67 } 39 }40 41 // get the smilies button ## must received the unserialized configuration array AND the smilies array42 function SmiliesTable($conf_smiliessupport, $smilies)43 {44 global $template;45 load_language('plugin.lang', SMILIES_PATH);46 47 // edit field has different id48 // 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');57 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 64 $template->set_filename('smiliessupport_page', dirname(__FILE__).'/template/smiliessupport_page.tpl');65 return $template->parse('smiliessupport_page', true);66 68 } 67 69 … … 74 76 $def_path = $conf_smiliessupport[0].'/smilies.txt'; 75 77 $accepted_ext = array('gif', 'jpg', 'png'); 78 $str = ' '.$str; 76 79 77 80 if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0])) … … 79 82 while (false !== ($file = readdir($handle))) 80 83 { 81 if ($file != "." && $file != ".." && in_array(get_extension($file), $accepted_ext)) { 82 $v = ':'.get_filename_wo_extension($file).':'; 83 $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" alt=":'.get_filename_wo_extension($file).':" title=":'.get_filename_wo_extension($file).':"/>'; 84 if ($file != "." && $file != ".." && in_array(get_extension($file), $accepted_ext)) 85 { 86 $filename = get_filename_wo_extension($file); 87 $v = ':'.$filename.':'; 88 $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" alt=":'.$filename.':"/>'; 84 89 $str = str_replace($v, $s, $str); 85 90 } … … 93 98 { 94 99 $v = trim($v); 95 if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches)) { 96 $r = '#'.preg_quote($matches[1],'/').'#'; 97 $t = '<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" alt=":'.get_filename_wo_extension($matches[2]).':" title=":'.get_filename_wo_extension($matches[2]).':"/>'; 98 $str = preg_replace($r, $t, $str); 100 if (preg_match('#^([^\t]+)[ \t]+(.+)$#', $v, $matches)) 101 { 102 $filename = get_filename_wo_extension($matches[2]); 103 $v = '#[^"]'.preg_quote($matches[1],'/').'#'; 104 $t = '<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" alt=":'.$filename.':"/>'; 105 $str = preg_replace($v, $t, $str); 99 106 } 100 107 } 101 108 } 102 109 103 return $str;110 return trim($str); 104 111 } 105 112
Note: See TracChangeset
for help on using the changeset viewer.