source: extensions/FCKEditor/fckeditor.php @ 32717

Last change on this file since 32717 was 32717, checked in by ddtddt, 2 years ago

[fckeditor] update for plugin admin message

File size: 4.4 KB
Line 
1<?php
2
3add_event_handler('loc_begin_admin_page', 'load_fckeditor_script');
4 
5function 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'] == 'intro')
52  {
53    $areas[] = 'admin_message';
54    $toolbar = $conf['fckeditor_toolbar_always_full'] ? 'Full' : 'Basic';
55    $template->set_prefilter('intro', 'add_remove_button');
56  }
57  elseif ($page['page'] == 'plugin')
58  {
59    $section = $_GET['section'];
60    // Additional pages
61    if ($section == 'AdditionalPages/admin/add_page.php'
62      or (preg_match('#AdditionalPages/(?:admin/|)admin.php#', $section) and (@in_array($_GET['tab'], array('add_page', 'edit_page'))))
63    )
64    {
65      $areas[] = 'ap_content';
66      $width = '100%';
67      $height = '400px';
68      $template->set_prefilter('plugin_admin_content', 'add_remove_button');
69    }
70    // PWG Stuffs
71    elseif (($section == 'PWG_Stuffs/admin/add_module.php' and @$_GET['type'] == 'Personal')
72      or (preg_match('#PWG_Stuffs/(?:admin/|)admin.php#', $section) and @in_array($_GET['tab'], array('edit_module', 'add_module')))
73    )
74    {
75      $areas[] = 'personal_content';
76      $width = '99%';
77      $height = '400px';
78      $template->set_prefilter('module_options', 'add_remove_button_stuffs');
79    }
80    // Personal About
81    elseif ($section == 'PersoAbout/admin.php')
82    {
83      $areas[] = 'perso_about';
84      $width = '100%';
85      $height = '300px';
86      $template->set_prefilter('plugin_admin_content', 'add_remove_button');
87    }
88        elseif ($section == 'PersoFooter/admin.php')
89    {
90      $areas[] = 'perso_footer';
91      $width = '100%';
92      $height = '300px';
93      $template->set_prefilter('plugin_admin_content', 'add_remove_button');
94    }
95        elseif ($section == 'Admin_Messages/admin.php')
96    {
97      $areas[] = 'admin_message';
98      $width = '100%';
99      $height = '300px';
100      $template->set_prefilter('plugin_admin_content', 'add_remove_button');
101    }
102  }
103
104  if (!empty($areas))
105  {
106    set_fckeditor_instance($areas, $toolbar, $width, $height);
107  }
108
109}
110
111function add_remove_button($content)
112{
113  $pattern = '#(<textarea.*?name="(.*?)".*?</textarea>)#ims';
114  $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>';
115  return preg_replace($pattern, $replacement, $content);
116}
117
118function add_remove_button_stuffs($content)
119{
120  $pattern = '#<textarea.*?</textarea>#ims';
121  $replacement = '<textarea name="personal_content" id="personal_content" rows="10" cols="50" style="width:100%; height: 300px;">{$PERSONAL_CONTENT}</textarea>
122<br><a href="#" onClick="toogleEditor(\'personal_content\'); return false;" style="border-bottom: none; float: right;">'.l10n('Display FCK Editor On/Off').'</a>';
123  return preg_replace($pattern, $replacement, $content);
124}
125
126function add_remove_button_banner($content)
127{
128  $pattern = '#(<textarea.*?name="(.*?)".*?</textarea>)#ims';
129  $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>';
130  return preg_replace($pattern, $replacement, $content);
131}
132
133?>
Note: See TracBrowser for help on using the repository browser.