source: extensions/FCKEditor/fckeditor.php

Last change on this file was 33001, checked in by plg, 4 months ago

deactivate FCK on Piwigo 14 new album editor

File size: 4.6 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    // With Piwigo 14 FCK Editor doesnt not worker with ajax validated form.
25    // For now let's completely deactivate FCK Editor on album editor.
26    // Better fix will come soon.
27    // $areas[] = 'comment';
28    // $areas[] = 'mail_content';
29    // $toolbar = $conf['fckeditor_toolbar_always_full'] ? 'Full' : 'Basic';
30    // $template->set_prefilter('album_properties', 'add_remove_button');
31  }
32  // Picture modify
33  elseif ($page['page'] == 'photo')
34  {
35    $areas[] = 'description';
36    $toolbar = $conf['fckeditor_toolbar_always_full'] ? 'Full' : 'Basic';
37    $template->set_prefilter('picture_modify', 'add_remove_button');
38  }
39  // Notification by mail
40  elseif ($page['page'] == 'notification_by_mail')
41  {
42    $areas[] = 'send_customize_mail_content';
43    $toolbar = $conf['fckeditor_toolbar_always_full'] ? 'Full' : 'Basic';
44    $template->set_prefilter('notification_by_mail', 'add_remove_button');
45  }
46  // Page banner
47  elseif ($page['page'] == 'configuration')
48  {
49    $areas[] = 'page_banner';
50    $width = '70%';
51    $toolbar = $conf['fckeditor_toolbar_always_full'] ? 'Full' : 'Basic';
52    $template->set_prefilter('config', 'add_remove_button_banner');
53  }
54  elseif ($page['page'] == 'intro')
55  {
56    $areas[] = 'admin_message';
57    $toolbar = $conf['fckeditor_toolbar_always_full'] ? 'Full' : 'Basic';
58    $template->set_prefilter('intro', 'add_remove_button');
59  }
60  elseif ($page['page'] == 'plugin')
61  {
62    $section = $_GET['section'];
63    // Additional pages
64    if ($section == 'AdditionalPages/admin/add_page.php'
65      or (preg_match('#AdditionalPages/(?:admin/|)admin.php#', $section) and (@in_array($_GET['tab'], array('add_page', 'edit_page'))))
66    )
67    {
68      $areas[] = 'ap_content';
69      $width = '100%';
70      $height = '400px';
71      $template->set_prefilter('plugin_admin_content', 'add_remove_button');
72    }
73    // PWG Stuffs
74    elseif (($section == 'PWG_Stuffs/admin/add_module.php' and @$_GET['type'] == 'Personal')
75      or (preg_match('#PWG_Stuffs/(?:admin/|)admin.php#', $section) and @in_array($_GET['tab'], array('edit_module', 'add_module')))
76    )
77    {
78      $areas[] = 'personal_content';
79      $width = '99%';
80      $height = '400px';
81      $template->set_prefilter('module_options', 'add_remove_button_stuffs');
82    }
83    // Personal About
84    elseif ($section == 'PersoAbout/admin.php')
85    {
86      $areas[] = 'perso_about';
87      $width = '100%';
88      $height = '300px';
89      $template->set_prefilter('plugin_admin_content', 'add_remove_button');
90    }
91        elseif ($section == 'PersoFooter/admin.php')
92    {
93      $areas[] = 'perso_footer';
94      $width = '100%';
95      $height = '300px';
96      $template->set_prefilter('plugin_admin_content', 'add_remove_button');
97    }
98        elseif ($section == 'Admin_Messages/admin.php')
99    {
100      $areas[] = 'admin_message';
101      $width = '100%';
102      $height = '300px';
103      $template->set_prefilter('plugin_admin_content', 'add_remove_button');
104    }
105  }
106
107  if (!empty($areas))
108  {
109    set_fckeditor_instance($areas, $toolbar, $width, $height);
110  }
111
112}
113
114function add_remove_button($content)
115{
116  $pattern = '#(<textarea.*?name="(.*?)".*?</textarea>)#ims';
117  $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>';
118  return preg_replace($pattern, $replacement, $content);
119}
120
121function add_remove_button_stuffs($content)
122{
123  $pattern = '#<textarea.*?</textarea>#ims';
124  $replacement = '<textarea name="personal_content" id="personal_content" rows="10" cols="50" style="width:100%; height: 300px;">{$PERSONAL_CONTENT}</textarea>
125<br><a href="#" onClick="toogleEditor(\'personal_content\'); return false;" style="border-bottom: none; float: right;">'.l10n('Display FCK Editor On/Off').'</a>';
126  return preg_replace($pattern, $replacement, $content);
127}
128
129function add_remove_button_banner($content)
130{
131  $pattern = '#(<textarea.*?name="(.*?)".*?</textarea>)#ims';
132  $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>';
133  return preg_replace($pattern, $replacement, $content);
134}
135
136?>
Note: See TracBrowser for help on using the repository browser.