1 | <?php |
---|
2 | |
---|
3 | add_event_handler('loc_begin_admin_page', 'load_fckeditor_script'); |
---|
4 | |
---|
5 | function load_fckeditor_script() |
---|
6 | { |
---|
7 | global $page, $template, $conf; |
---|
8 | |
---|
9 | if (!isset($page['page'])) return true; |
---|
10 | |
---|
11 | if (!isset($conf['fckeditor_toolbar_always_full'])) |
---|
12 | { |
---|
13 | $conf['fckeditor_toolbar_always_full'] = false; |
---|
14 | } |
---|
15 | |
---|
16 | $toolbar = 'Full'; |
---|
17 | $width = '750px'; |
---|
18 | $height = '200px'; |
---|
19 | $areas = array(); |
---|
20 | |
---|
21 | // Category edit |
---|
22 | if ($page['page'] == 'album') |
---|
23 | { |
---|
24 | $areas[] = 'comment'; |
---|
25 | $areas[] = 'mail_content'; |
---|
26 | $toolbar = $conf['fckeditor_toolbar_always_full'] ? 'Full' : 'Basic'; |
---|
27 | $template->set_prefilter('album_properties', 'add_remove_button'); |
---|
28 | } |
---|
29 | // Picture modify |
---|
30 | elseif ($page['page'] == 'photo') |
---|
31 | { |
---|
32 | $areas[] = 'description'; |
---|
33 | $toolbar = $conf['fckeditor_toolbar_always_full'] ? 'Full' : 'Basic'; |
---|
34 | $template->set_prefilter('picture_modify', 'add_remove_button'); |
---|
35 | } |
---|
36 | // Notification by mail |
---|
37 | elseif ($page['page'] == 'notification_by_mail') |
---|
38 | { |
---|
39 | $areas[] = 'send_customize_mail_content'; |
---|
40 | $toolbar = $conf['fckeditor_toolbar_always_full'] ? 'Full' : 'Basic'; |
---|
41 | $template->set_prefilter('notification_by_mail', 'add_remove_button'); |
---|
42 | } |
---|
43 | // Page banner |
---|
44 | elseif ($page['page'] == 'configuration') |
---|
45 | { |
---|
46 | $areas[] = 'page_banner'; |
---|
47 | $width = '70%'; |
---|
48 | $toolbar = $conf['fckeditor_toolbar_always_full'] ? 'Full' : 'Basic'; |
---|
49 | $template->set_prefilter('config', 'add_remove_button_banner'); |
---|
50 | } |
---|
51 | elseif ($page['page'] == 'plugin') |
---|
52 | { |
---|
53 | $section = $_GET['section']; |
---|
54 | // Additional pages |
---|
55 | if ($section == 'AdditionalPages/admin/add_page.php' |
---|
56 | or (preg_match('#AdditionalPages/(?:admin/|)admin.php#', $section) and (@in_array($_GET['tab'], array('add_page', 'edit_page')))) |
---|
57 | ) |
---|
58 | { |
---|
59 | $areas[] = 'ap_content'; |
---|
60 | $width = '100%'; |
---|
61 | $height = '400px'; |
---|
62 | $template->set_prefilter('plugin_admin_content', 'add_remove_button'); |
---|
63 | } |
---|
64 | // PWG Stuffs |
---|
65 | elseif (($section == 'PWG_Stuffs/admin/add_module.php' and @$_GET['type'] == 'Personal') |
---|
66 | or (preg_match('#PWG_Stuffs/(?:admin/|)admin.php#', $section) and @in_array($_GET['tab'], array('edit_module', 'add_module'))) |
---|
67 | ) |
---|
68 | { |
---|
69 | $areas[] = 'personal_content'; |
---|
70 | $width = '99%'; |
---|
71 | $height = '400px'; |
---|
72 | $template->set_prefilter('module_options', 'add_remove_button_stuffs'); |
---|
73 | } |
---|
74 | // Personal About |
---|
75 | elseif ($section == 'PersoAbout/admin.php') |
---|
76 | { |
---|
77 | $areas[] = 'perso_about'; |
---|
78 | $width = '100%'; |
---|
79 | $height = '300px'; |
---|
80 | $template->set_prefilter('plugin_admin_content', 'add_remove_button'); |
---|
81 | } |
---|
82 | elseif ($section == 'PersoFooter/admin.php') |
---|
83 | { |
---|
84 | $areas[] = 'perso_footer'; |
---|
85 | $width = '100%'; |
---|
86 | $height = '300px'; |
---|
87 | $template->set_prefilter('plugin_admin_content', 'add_remove_button'); |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | if (!empty($areas)) |
---|
92 | { |
---|
93 | set_fckeditor_instance($areas, $toolbar, $width, $height); |
---|
94 | } |
---|
95 | |
---|
96 | } |
---|
97 | |
---|
98 | function add_remove_button($content, &$smarty) |
---|
99 | { |
---|
100 | $pattern = '#(<textarea.*?name="(.*?)".*?</textarea>)#ims'; |
---|
101 | $replacement = '$1</td></tr><tr><td></td><td><a href="#" onClick="toogleEditor(\'$2\'); return false;" style="border-bottom: none; float: right;">'.l10n('Display FCK Editor On/Off').'</a>'; |
---|
102 | return preg_replace($pattern, $replacement, $content); |
---|
103 | } |
---|
104 | |
---|
105 | function add_remove_button_stuffs($content, &$smarty) |
---|
106 | { |
---|
107 | $pattern = '#<textarea.*?</textarea>#ims'; |
---|
108 | $replacement = '<textarea name="personal_content" id="personal_content" rows="10" cols="50" style="width:100%; height: 300px;">{$PERSONAL_CONTENT}</textarea> |
---|
109 | <br><a href="#" onClick="toogleEditor(\'personal_content\'); return false;" style="border-bottom: none; float: right;">'.l10n('Display FCK Editor On/Off').'</a>'; |
---|
110 | return preg_replace($pattern, $replacement, $content); |
---|
111 | } |
---|
112 | |
---|
113 | function add_remove_button_banner($content, &$smarty) |
---|
114 | { |
---|
115 | $pattern = '#(<textarea.*?name="(.*?)".*?</textarea>)#ims'; |
---|
116 | $replacement = '$1<a href="#" onClick="toogleEditor(\'$2\'); return false;" style="border-bottom: none; float: right; margin-right: 5%;">'.l10n('Display FCK Editor On/Off').'</a>'; |
---|
117 | return preg_replace($pattern, $replacement, $content); |
---|
118 | } |
---|
119 | |
---|
120 | ?> |
---|