1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | function set_smiliessupport_page() |
---|
5 | { |
---|
6 | global $template, $lang, $pwg_loaded_plugins; |
---|
7 | |
---|
8 | if (!isset($pwg_loaded_plugins['bbcode_bar'])) |
---|
9 | { |
---|
10 | $lang['Comment'] .= SmiliesTable(); |
---|
11 | } |
---|
12 | } |
---|
13 | |
---|
14 | function SmiliesTable($new_conf=null) |
---|
15 | { |
---|
16 | global $conf, $template; |
---|
17 | |
---|
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; |
---|
23 | |
---|
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'); |
---|
29 | |
---|
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); |
---|
60 | } |
---|
61 | |
---|
62 | function SmiliesParse($str) |
---|
63 | { |
---|
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; |
---|
97 | } |
---|
98 | |
---|
99 | ?> |
---|