source: extensions/FCKEditor/fckeditor.php @ 9268

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

Compatible with future additional page plugin version

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      or $section == 'AdditionalPages/admin/admin.php')
52    {
53      $areas[] = 'ap_content';
54      $width = '100%';
55      $template->set_prefilter('plugin_admin_content', 'add_remove_button');
56    }
57    // PWG Stuffs
58    elseif ($section == 'PWG_Stuffs/admin/add_module.php' and $_GET['type'] == 'Personal')
59    {
60      $areas[] = 'personal_content';
61      $width = '99%';
62      $height = '250px';
63      $template->set_prefilter('module_options', 'add_remove_button_stuffs');
64    }
65    // Personal About
66    elseif ($section == 'PersoAbout/admin/admin.php')
67    {
68      $areas[] = 'perso_about';
69      $width = '100%';
70      $height = '300px';
71      $template->set_prefilter('plugin_admin_content', 'add_remove_button');
72    }
73  }
74
75  if (!empty($areas))
76  {
77    set_fckeditor_instance($areas, $toolbar, $width, $height);
78  }
79  return $plugin_menu_links;
80}
81
82function add_remove_button($content, &$smarty)
83{
84  $pattern = '#(<textarea.*?name="(.*?)".*?</textarea>)#ims';
85  $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>';
86  return preg_replace($pattern, $replacement, $content);
87}
88
89function add_remove_button_stuffs($content, &$smarty)
90{
91  $pattern = '#<textarea.*?</textarea>#ims';
92  $replacement = '<textarea name="personal_content" id="personal_content" rows="10" cols="50" style="width:100%; height: 300px;">{$PERSONAL_CONTENT}</textarea>
93<br><a href="#" onClick="toogleEditor(\'personal_content\'); return false;" style="border-bottom: none; float: right;">FCK Editor On/Off</a>';
94  return preg_replace($pattern, $replacement, $content);
95}
96
97function add_remove_button_banner($content, &$smarty)
98{
99  $pattern = '#(<textarea.*?name="(.*?)".*?</textarea>)#ims';
100  $replacement = '$1<a href="#" onClick="toogleEditor(\'$2\'); return false;" style="border-bottom: none; float: right; margin-right: 5%;">FCK Editor On/Off</a>';
101  return preg_replace($pattern, $replacement, $content);
102}
103
104?>
Note: See TracBrowser for help on using the repository browser.