source: extensions/FCKEditor/fckeditor.php @ 8133

Last change on this file since 8133 was 8133, checked in by patdenice, 13 years ago

FCK Editor is now compatible with Personal About plugin.

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