- Timestamp:
- Jun 15, 2013, 6:52:37 PM (11 years ago)
- Location:
- extensions/SmiliesSupport/include
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmiliesSupport/include/smiliessupport.inc.php
r23217 r23234 5 5 function set_smiliessupport($prefilter='picture', $textarea_id='contentid') 6 6 { 7 global $conf, $template, $page; 8 9 load_language('plugin.lang', SMILIES_PATH); 10 $conf_smiliessupport = unserialize($conf['smiliessupport']); 7 global $conf, $template; 11 8 12 9 $template->assign(array( 13 10 'SMILIES_PATH' => SMILIES_PATH, 14 'SMILIES_ID' => $textarea_id,15 'REPRESENTANT' => SMILIES_ PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$conf_smiliessupport['representant'],16 'smiliesfiles' => get_smilies( $conf_smiliessupport),11 'SMILIES_ID' => $textarea_id, 12 'REPRESENTANT' => SMILIES_DIR.$conf['smiliessupport']['folder'].'/'.$conf['smiliessupport']['representant'], 13 'smiliesfiles' => get_smilies(), 17 14 )); 18 15 … … 27 24 } 28 25 29 // return an array with available smilies (name and path) ## must received the unserialized configuration array30 function get_smilies( $conf_smiliessupport)26 // return an array with available smilies (name and path) 27 function get_smilies() 31 28 { 32 $accepted_ext = array('gif', 'jpg', 'png');29 global $conf; 33 30 34 if ($handle = opendir(SMILIES_ PATH.'smilies/'.$conf_smiliessupport['folder']))31 if ($handle = opendir(SMILIES_DIR.$conf['smiliessupport']['folder'])) 35 32 { 36 33 $i = 1; 37 34 while (false !== ($file = readdir($handle))) 38 35 { 39 if ($file != '.' AND $file != '..' AND in_array(get_extension($file), $accepted_ext))36 if ($file != '.' and $file != '..' and in_array(get_extension($file), $conf['smiliessupport']['ext'])) 40 37 { 41 38 $smilies[] = array( 42 'PATH' => SMILIES_ PATH.'smilies/'.$conf_smiliessupport['folder'].'/'.$file,39 'PATH' => SMILIES_DIR.$conf['smiliessupport']['folder'].'/'.$file, 43 40 'TITLE' => ':'.get_filename_wo_extension($file).':', 44 'TR' => ($i>0 AND $i%$conf_smiliessupport['cols'] == 0) ? '</tr><tr>' : null,41 'TR' => ($i>0 and $i%$conf['smiliessupport']['cols'] == 0) ? '</tr><tr>' : null, 45 42 ); 46 43 $i++; … … 61 58 { 62 59 global $conf; 63 64 $conf_smiliessupport = unserialize($conf['smiliessupport']); 65 $folder = get_absolute_root_url().SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder']; 66 $def_path = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt'; 67 $accepted_ext = array('gif', 'jpg', 'png'); 60 61 $root_path = get_absolute_root_url(); 62 $folder = SMILIES_DIR.$conf['smiliessupport']['folder'].'/'; 68 63 $str = ' '.$str; 69 64 70 if ($handle = opendir( SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder']))65 if ($handle = opendir($folder)) 71 66 { 72 67 while (false !== ($file = readdir($handle))) 73 68 { 74 if ($file != "." && $file != ".." && in_array(get_extension($file), $ accepted_ext))69 if ($file != "." && $file != ".." && in_array(get_extension($file), $conf['smiliessupport']['ext'])) 75 70 { 76 71 $filename = get_filename_wo_extension($file); 77 72 $v = ':'.$filename.':'; 78 $s = '<img src="'.$ folder.'/'.$file.'" alt=":'.$filename.':"/>';73 $s = '<img src="'.$root_path.$folder.$file.'" alt=":'.$filename.':"/>'; 79 74 $str = str_replace($v, $s, $str); 80 75 } … … 84 79 } 85 80 86 if (file_exists($ def_path))81 if (file_exists($folder.'smilies.txt')) 87 82 { 88 $def = file($def_path); 89 foreach($def as $v) 83 foreach (file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES) as $v) 90 84 { 91 85 $v = trim($v); 92 if (preg_match('#^([^\ t]+)[ \t]+(.+)$#', $v, $matches))86 if (preg_match('#^([^\s]+)[\s]+(.+)$#', $v, $matches)) 93 87 { 94 88 $filename = get_filename_wo_extension($matches[2]); 95 89 $v = '#([^"])'.preg_quote($matches[1],'/').'#'; 96 $t = '$1<img src="'.$ folder.'/'.$matches[2].'" alt=":'.$filename.':"/>';90 $t = '$1<img src="'.$root_path.$folder.$matches[2].'" alt=":'.$filename.':"/>'; 97 91 $str = preg_replace($v, $t, $str); 98 92 }
Note: See TracChangeset
for help on using the changeset viewer.