3 // A collaborative project by Matt Westgate <drupal at asitis dot org>
4 // and Richard Bennett <richard.b@gritechnologies.com>
8 * Integrate the TinyMCE editor (http://tinymce.moxiecode.com/) into Drupal.
12 * Implementation of hook_menu().
14 function tinymce_menu($may_cache) {
17 $items[] = array('path' => 'admin/settings/tinymce', 'title' => t('tinymce'),
18 'callback' => 'tinymce_admin',
19 'access' => user_access('administer tinymce'));
25 * Implementation of hook_help().
27 function tinymce_help($section) {
29 case
'admin/modules#description':
30 return t('The TinyMCE Javascript HTML WYSIWYG editor.');
32 case
'admin/settings/tinymce#pages':
33 return "node/*\nuser/*\ncomment/*";
38 * Implementation of hook_perm().
40 function tinymce_perm() {
41 return array('administer tinymce', 'access tinymce');
45 * Implementation of hook_img_assist_head().
47 function tinymce_img_assist_head() {
49 // The tinymce docs say to include tiny_mce_popup.js, but this was killing IE!
50 $popup_path = $base_url .
'/'.
drupal_get_path('module', 'tinymce').
'/tinymce/jscripts/tiny_mce/tiny_mce_popup.js';
51 $img_assist_prop = $base_url .
'/'.
drupal_get_path('module', 'img_assist').
'/properties.js';
52 $clean_url = variable_get('clean_url', 0);
53 $img_template = variable_get('img_assist_img_html', img_assist_help('img_assist/template'));
54 $img_template = str_replace("\r\n", "\n", $img_template);
55 $img_template = str_replace("\n", '\n', addslashes($img_template));
58 <script language
="javascript" src
="$img_assist_prop"></script
>
59 <script language
="javascript">
60 var clean_url
= $clean_url;
61 var img_template
= "$img_template";
63 function insertImage(form
) {
65 form
['edit[thumbpath]'].value
= window.opener.tinyMCE.
convertURL(form
['edit[thumbpath]'].value
);
66 form
['edit[filepath]'].value
= window.opener.tinyMCE.
convertURL(form
['edit[filepath]'].value
);
67 form
['edit[nodePath]'].value
= window.opener.tinyMCE.
convertURL(form
['edit[nodePath]'].value
);
69 var img
= generate_image_tag(form
, 'html');
71 // Find the tinymce instance we're dealin' with.
72 var inst
= window.opener.tinyMCE.
getInstanceById(myTextarea.name
);
73 inst.
execCommand('mceInsertContent', false
, img
);
83 * Implementation of hook_img_assist_on_submit().
85 function tinymce_img_assist_on_submit() {
86 return 'parent.insertImage(this.form);';
90 * Implementation of hook_textarea().
92 function tinymce_textarea($op, $textarea_name) {
93 static
$is_running = FALSE
;
94 if (!user_access('access tinymce')) return NULL
;
100 // Since tinymce_config() makes a db hit, only call it when we're pretty sure
101 // we're gonna render tinymce.
102 $valid_so_far = FALSE
;
104 if (!$profile_name) {
105 $profile_name = db_result(db_query('SELECT s.name FROM {tinymce_settings} s INNER JOIN {tinymce_role} r ON r.name = s.name WHERE r.rid IN (%s)', implode(',', array_keys($user->roles
))));
107 $profile = tinymce_profile_load($profile_name);
108 $init = tinymce_config($profile);
109 $init['elements'] = 'edit['.
$textarea_name .
']';
110 $valid_so_far = TRUE
;
113 if ($valid_so_far && _tinymce_page_match($profile)) {
114 // Merge and overrivide user-defined TinyMCE settings.
115 $init = array_merge($init, (array) theme('tinymce_theme', $init, $textarea_name, $init['theme'], $is_running));
116 foreach ($init as
$k => $v) {
117 if (strtolower($v) != 'true' && strtolower($v) != 'false') {
120 $settings[] = $k.
' : '.
$v;
122 $tinymce_settings = implode(",\n ", $settings);
124 if (function_exists('img_assist_help')) {
125 $img_assist_js_on = $base_url .
'/'.
url('img_assist/add&editor=tinymce') .
'&textarea=';
126 $img_assist_js_off = $base_url .
'/'.
url('img_assist/add') .
'&textarea=';
127 $img_assist_on = $base_url .
'/'.
url('img_assist/add&editor=tinymce') .
'&textarea=edit['.
$textarea_name .
']';
128 $img_assist_off = $base_url .
'/'.
url('img_assist/add') .
'&textarea=edit['.
$textarea_name .
']';
131 $enable = t('enable rich-text');
132 $disable = t('disable rich-text');
134 $tinymce_invoke = <<<EOD
135 <script language
="javascript" type
="text/javascript">
143 <script language
="javascript" type
="text/javascript">
144 function mceToggle(id
, linkid
) {
145 element
= document.
getElementById(id
);
146 link = document.
getElementById(linkid
);
147 img_assist
= document.
getElementById('img_assist-link-'+ id
);
149 if (tinyMCE.
getEditorId(element.name
) == null
) {
150 tinyMCE.
addMCEControl(element
, element.name
);
152 link.innerHTML
= '$disable';
153 link.href
= "javascript:mceToggle('" +id
+ "', '" +linkid
+ "');";
155 img_assist.href
= "$img_assist_js_on"+ element.name
;
159 tinyMCE.
removeMCEControl(tinyMCE.
getEditorId(element.name
));
160 element.togg
= 'off';
161 link.innerHTML
= '$enable';
162 link.href
= "javascript:mceToggle('" +id
+ "', '" +linkid
+ "');";
164 img_assist.href
= "$img_assist_js_off"+ element.name
;
171 $status = isset($user->tinymce_status
) ?
$user->tinymce_status
: variable_get('tinymce_default_state', 0);
172 $link_text = $status == 1 ?
$disable : $enable;
173 $no_wysiwyg = t('Your current web browser does not support WYSIWYG editing.');
174 $wysiwyg_link = <<<EOD
175 <script language
="javascript" type
="text/javascript">
176 img_assist
= document.
getElementById('img_assist-link-edit-$textarea_name');
178 img_assist.href
= tinyMCE.
getEditorId('edit-$textarea_name') == null ?
"$img_assist_on" : "$img_assist_off";
180 if (typeof(document.execCommand
) == 'undefined') {
181 img_assist.href
= "$img_assist_off";
182 document.
write('<div style="font-size:x-small">$no_wysiwyg</div>');
185 document.
write("<div><a href=\"javascript:mceToggle('edit-$textarea_name', 'wysiwyg4$textarea_name');\" id=\"wysiwyg4$textarea_name\">$link_text</div></a>");
190 // We only load the TinyMCE js file once per request
193 // For some crazy reason IE will only load this JS file if the absolute reference is given to it.
194 drupal_set_html_head('<script language="javascript" type="text/javascript" src="'.
$base_url .
'/'.
drupal_get_path('module', 'tinymce') .
'/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>');
195 drupal_set_html_head($js_toggle);
196 // We have to do this becuase of some unfocused CSS in certain themes. See http://drupal.org/node/18879 for details
197 drupal_set_html_head('<style type="text/css" media="all">.mceEditor img { display: inline; }</style>');
199 // Load a TinyMCE init for each textarea.
200 drupal_set_html_head($tinymce_invoke);
202 return $wysiwyg_link;
207 * Implementation of hook_user().
209 function tinymce_user($type, &$edit, &$user, $category = NULL
) {
210 if ($type == 'form' && $category == 'account' && user_access('access tinymce')) {
211 $user_status = $edit['tinymce_status'] != NULL ?
$edit['tinymce_status'] : ($user->tinymce_status
!= NULL ?
$user->tinymce_status
: variable_get('tinymce_default_state', 0));
212 $form = form_radios(t('Default status'), 'tinymce_status', $user_status, array(t('Off'), t('On')), t('Should rich-text editing be enabled or disabled by default in textarea fields?'));
213 return array(array('title' => t('TinyMCE settings'), 'data' => $form));
215 if ($type == 'validate') {
216 return array('tinymce_status' => $edit['tinymce_status']);
222 * @addtogroup themeable
227 * Customize a TinyMCE theme.
230 * An array of settings TinyMCE should invoke a theme. You may override any
231 * of the TinyMCE settings. Details here:
233 * http://tinymce.moxiecode.com/wrapper.php?url=tinymce/docs/using.htm
235 * @param textarea_name
236 * The name of the textarea TinyMCE wants to enable.
239 * The default theme name to be enabled for this textarea. The sitewide
240 * default is 'simple', but the user may also override this.
243 * A boolean flag that identifies id TinyMCE is currently running for this
244 * request life cycle. If it's already running then anything returned by this
245 * will be ignored. This is necessary since TinyMCE works by being invoked
246 * once per request and not once per textarea.
248 function theme_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
249 // Force the 'simple' theme for some of the smaller textareas.
250 switch ($textarea_name) {
255 case
'settings][access_pages':
256 $init['theme'] = 'simple';
257 unset($init['theme_advanced_toolbar_location']);
258 unset($init['theme_advanced_toolbar_align']);
259 unset($init['theme_advanced_path_location']);
260 unset($init['theme_advanced_blockformats']);
261 unset($init['theme_advanced_styles']);
265 switch ($theme_name) {
267 $init['extended_valid_elements'] = 'a[href|target|name|title|onclick]';
268 $init['theme_advanced_buttons3_add_before'] = 'tablecontrols,separator';
269 $init['plugins'] = file_exists(drupal_get_path('module', 'tinymce').
'/tinymce/jscripts/tiny_mce/plugins/drupalimage') ?
'drupalimage,table,emotions,print' : 'table,emotions,print';
270 $init['theme_advanced_buttons3_add'] = 'drupalimage,emotions,separator,print';
275 /** @} End of addtogroup themeable */
278 * Grab the themes available to TinyMCE.
280 * TinyMCE themes control the functionality and buttons that are available to a
281 * user. Themes are only looked for within the default TinyMCE theme directory.
284 * An array of theme names.
286 function _tinymce_get_themes() {
287 static
$themes = array();
290 $theme_loc = drupal_get_path('module', 'tinymce') .
'/tinymce/jscripts/tiny_mce/themes/';
291 if (is_dir($theme_loc) && $dh = opendir($theme_loc)) {
292 while (($file = readdir($dh)) !== false
) {
293 if (!in_array($file, array('.', '..', 'CVS')) && is_dir($theme_loc .
$file)) {
294 $themes[$file] = $file;
305 /********************************************************************
306 * Module Functions :: Public
307 ********************************************************************/
310 * Controller for tinymce administrative settings.
312 function tinymce_admin($arg = NULL
) {
313 $edit = $_POST['edit'];
316 $op = $arg && !$op ?
$arg : $op;
320 $breadcrumb[] = array('path' => 'admin', 'title' => t('administer'));
321 $breadcrumb[] = array('path' => 'admin/settings/tinymce', 'title' => t('tinymce'));
322 $breadcrumb[] = array('path' => 'admin/settings/tinymce/add', 'title' => t('Add new tinymce profile'));
323 menu_set_location($breadcrumb);
324 $output = tinymce_profile_form($edit);
328 drupal_set_title(t('Edit tinymce profile'));
329 $output = tinymce_profile_form(tinymce_profile_load(urldecode(arg(4))));
333 tinymce_profile_delete(urldecode(arg(4)));
334 drupal_set_message(t('Deleted profile'));
335 drupal_goto('admin/settings/tinymce');
338 case
t('Create profile');
339 case
t('Update profile');
340 if (tinymce_profile_validate($edit)) {
341 tinymce_profile_save($edit);
342 $edit['old_name'] ?
drupal_set_message(t('Your tinymce profile has been updated.')) : drupal_set_message(t('Your tinymce profile has been created.'));
343 drupal_goto('admin/settings/tinymce');
346 $output = tinymce_profile_form($edit);
350 case
t('Save settings'):
351 variable_set('tinymce_default_state', $edit['tinymce_default_state']);
352 drupal_set_message(t('Settings updated'));
353 drupal_goto('admin/settings/tinymce');
357 drupal_set_title(t('TinyMCE settings (%revision)', array('%revision' => '$Revision$')));
358 //Check if TinyMCE is installed.
359 $tinymce_loc = drupal_get_path('module', 'tinymce') .
'/tinymce/';
360 if (!is_dir($tinymce_loc)) {
361 drupal_set_message(t('Could not find the TinyMCE engine installed at <strong>%tinymce-directory</strong>. Please <a href="http://tinymce.moxiecode.com/">download TinyMCE</a>, uncompress it and copy the folder into %tinymce-path.', array('%tinymce-path' => drupal_get_path('module', 'tinymce'), '%tinymce-directory' => $tinymce_loc)), 'error');
363 $output = tinymce_profile_overview();
366 print theme('page', $output);
370 * Return an array of initial tinymce config options from the current role.
372 function tinymce_config($profile) {
376 $settings = $profile->settings
;
378 // Build a default list of TinyMCE settings.
380 // Is tinymce on by default?
381 $init['mode'] = variable_get('tinymce_default_state', 0) == 1 ?
'exact' : 'none';
382 $status = isset($user->tinymce_status
) ?
$user->tinymce_status
: variable_get('tinymce_default_state', 0);
383 $init['mode'] = $status == 1 ?
'exact' : 'none';
384 $init['theme'] = $settings['theme'] ?
$settings['theme'] : 'simple';
385 $init['document_base_url'] = "$base_url/";
387 $init['verify_html'] = $settings['verify_html'] ?
$settings['verify_html'] : 'false';
388 $init['auto_cleanup_word'] = $settings['msword'] ?
$settings['msword'] : 'false';
389 $init['preformatted'] = $settings['preformatted'] ?
$settings['preformatted'] : 'false';
390 $init['force_br_newlines'] = $settings['force_br'] ?
$settings['force_br'] : 'false';
391 $init['force_p_newlines'] = $settings['force_p'] ?
$settings['force_p'] : 'false';
392 if ($init['theme'] == 'advanced') {
393 $init['theme_advanced_toolbar_location'] = $settings['toolbar_loc'] ?
$settings['toolbar_loc'] : 'bottom';
394 $init['theme_advanced_toolbar_align'] = $settings['toolbar_align'] ?
$settings['toolbar_align'] : 'left';
395 $init['theme_advanced_path_location'] = $settings['path_loc'] ?
$settings['path_loc'] : 'none';
396 $init['theme_advanced_blockformats'] = $settings['block_formats'] ?
$settings['block_formats'] : 'p,address,pre,h1,h2,h3,h4,h5,h6';
399 if ($edit['css_classes']) $init['theme_advanced_styles'] = $settings['css_classes'];
400 if ($settings['width']) $init['width'] = $settings['width'];
401 if ($settings['height']) $init['height'] = $settings['height'];
403 if ($settings['css_setting'] == 'theme') {
404 $css = drupal_get_path('theme', init_theme()) .
'/style.css';
405 if (file_exists($css)) {
406 $init['content_css'] = $base_url .
'/'.
$css;
408 else if ($settings['css_setting'] == 'self') {
409 $init['content_css'] = $edit['css_path'];
417 * Remove a profile from the database.
419 function tinymce_profile_delete($name) {
420 db_query("DELETE FROM {tinymce_settings} WHERE name = '%s'", $name);
421 db_query("DELETE FROM {tinymce_role} WHERE name = '%s'", $name);
425 * Return an HTML form for profile configuration.
427 function tinymce_profile_form($edit) {
428 $edit = array2object($edit);
430 // Only display the roles that currently don't have a tinymce profile. One
432 $orig_roles = user_roles();
433 $roles = $orig_roles;
434 if (arg(3) == 'add') {
435 $result = db_query('SELECT DISTINCT(rid) FROM {tinymce_role}');
436 while ($data = db_fetch_object($result)) {
437 unset($roles[$data->rid
]);
440 drupal_set_message(t('You will not be allowed to create a new profile since all user roles have already been assigned profiles. First remove an existing tinymce profile from at least one role in order to create a new profile.'), 'error');
442 else if (count($orig_roles) != count($roles)) {
443 drupal_set_message(t('Not all user roles are shown since they already have tinymce profiles. You must first unassign profiles in order to add them to a new one.'));
445 $btn = t('Create profile');
448 $output = form_hidden('old_name', $edit->name
);
449 $btn = t('Update profile');
452 $group = form_textfield(t('Profile name'), 'name', $edit->name
, 40, 128, t('Enter an unique name for this profile. This name is only visible in the tinymce administration page.'), NULL
, TRUE
);
453 $group .
= form_checkboxes(t('Roles allowed to use this profile'), 'rids', array_keys((array) $edit->rids
), $roles, t('Select at least one role.'), NULL
, TRUE
);
454 $group .
= form_radios(t('Theme'), 'settings][theme', $edit->settings
['theme'] ?
$edit->settings
['theme'] : 'simple', _tinymce_get_themes(), t('Select the tinymce theme.'));
455 $group .
= form_radios(t('Make tinymce visible on'), 'settings][access', $edit->settings
['access'], array(t('specific pages'), t('all textareas')));
456 $group .
= form_textarea(t('Specific pages'), 'settings][access_pages', $edit->settings
['access_pages'] ?
$edit->settings
['access_pages'] : tinymce_help('admin/settings/tinymce#pages'), 40, 5, t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '<em>blog</em>' for the blog page and '<em>blog/*</em>' for every personal blog. '<em><front></em>' is the front page."));
457 $output .
= form_group(t('Basic setup'), $group);
459 $output .
= t('<h3>Advanced options</h3>');
461 $group = form_textfield(t('Editor width'), 'settings][width', $edit->settings
['width'], 3, 5, t('Set width of editor. Leave blank to use size of textarea being replaced.'));
462 $group .
= form_textfield(t('Editor height'), 'settings][height', $edit->settings
['height'], 3, 5, t('Set height of editor. Leave blank to use size of textarea being replaced.'));
463 $group .
= form_select(t('Toolbar location'), 'settings][toolbar_loc', $edit->settings
['toolbar_loc'], array('bottom' => 'bottom', 'top' => 'top'), t('Show toolbar at the top or bottom of the editor area?'));
464 $group .
= form_select(t('Toolbar alignment'), 'settings][toolbar_align', $edit->settings
['toolbar_align'], array('center' => 'center', 'left' => 'left', 'right' => 'right'), t('Align tool icons left, center, or right within the toolbar.'));
465 $group .
= form_select(t('Path location'), 'settings][path_loc', $edit->settings
['path_loc'], array('none' => 'none', 'top' => 'top', 'bottom' => 'bottom'), t('Path to html elements (i.e. "body>table>tr>td"). Show at top, bottom, or not at all.'));
466 $output .
= form_group(t('Editor display'), $group);
468 $group = form_select(t('Auto cleanup Word'), 'settings][msword', $edit->settings
['msword'], array('true' => 'true', 'false' => 'false'), t('Automatically cleanup MS Office/Word HTML will be executed automatically on paste operations. (Only works in Internet Explorer)'));
469 $group .
= form_select(t('Verify HTML'), 'settings][verify_html', $edit->settings
['verify_html'], array('true' => 'true', 'false' => 'false'), t('Should the HTML contents be verified or not? Verifying will strip <head> tags, so choose false if you will be editing full page HTML.'));
470 $group .
= form_select(t('Preformatted'), 'settings][preformatted', $edit->settings
['preformatted'], array('false' => 'false', 'true' => 'true'), t('If this option is set to true, the editor will insert TAB characters on tab and preserve other whitespace characters just like a PRE HTML element does.'));
471 $output .
= form_group(t('On save'), $group);
473 $group = form_select(t('Editor CSS'), 'settings][css_setting', $edit->settings
['css_setting'] ?
$edit->settings
['css_setting'] : 'theme', array('theme' => 'use theme css', 'self' => 'define css', 'none' => 'tinyMCE default'), t('Defines the CSS to be used in the editor area.<br />use theme css - get css from current Drupal theme.<br/>define css - enter path for css file below.<br />tinyMCE default - uses default CSS from editor.'));
474 $group .
= form_textfield(t('CSS path'), 'settings][css_path', $edit->settings
['css_path'], 40, 255, t('Enter path to CSS file (example: "/css/editor.css"). Select "define css" above.'));
475 $group .
= form_textfield(t('CSS classes'), 'settings][css_classes', $edit->settings
['css_classes'], 40, 255, t('Adds CSS classes to the "styles" droplist. Format is "<title>=<class>;"<br/> Example: "Header 1=header1;Header 2=header2;Header 3=header3;"<br />Leave blank to automatically import list of CSS classes from style sheet.'));
476 $output .
= form_group(t('CSS'), $group);
478 $group = form_textfield(t('Block formats'), 'settings][block_formats', $edit->settings
['block_formats'] ?
$edit->settings
['block_formats'] : 'p,address,pre,h1,h2,h3,h4,h5,h6', 40, 250, t('Comma separated list of HTML block formats. You can only remove elements, not add.'));
479 $group .
= form_select(t('Force BR new lines'), 'settings][force_br', $edit->settings
['force_br'] ?
$edit->settings
['force_br'] : 'false', array('true' => 'true', 'false' => 'false'), t('Use BR tags for new lines rather than P.'));
480 $group .
= form_select(t('Force P new lines'), 'settings][force_p', $edit->settings
['force_p'] ?
$edit->settings
['force_p'] : 'true', array('true' => 'true', 'false' => 'false'), t('When enabled, Mozilla/Firefox will generate P elements on Enter/Return key and BR elements on Shift+Enter/Return..'));
481 $output .
= form_group(t('Formatting'), $group);
483 $output .
= form_submit($btn);
485 return form($output);
491 function tinymce_profile_load($name = '') {
492 static
$profiles = array();
495 $roles = user_roles();
496 $result = db_query('SELECT * FROM {tinymce_settings}');
497 while ($data = db_fetch_object($result)) {
498 $data->settings
= unserialize($data->settings
);
499 $result2 = db_query("SELECT rid FROM {tinymce_role} WHERE name = '%s'", $data->name
);
501 while ($r = db_fetch_object($result2)) {
502 $role[$r->rid
] = $roles[$r->rid
];
506 $profiles[$data->name
] = $data;
510 return ($name ?
$profiles[$name] : $profiles);
514 * Controller for tinymce profiles.
516 function tinymce_profile_overview() {
519 $output .
= t('<p><a href="%create-profile-url">Create new profile</a></p>', array('%create-profile-url' => url('admin/settings/tinymce/add')));
521 $profiles = tinymce_profile_load();
523 $roles = user_roles();
524 $header = array(t('Profile'), t('Roles'), t('Operations'));
525 foreach ($profiles as
$p) {
526 $rows[] = array(array('data' => $p->name
, 'valign' => 'top'), array('data' => implode("<br />\n", $p->rids
)), array('data' => l(t('edit'), 'admin/settings/tinymce/edit/'.
urlencode($p->name
)) .
' '.
l(t('delete'), 'admin/settings/tinymce/delete/'.
urlencode($p->name
)), 'valign' => 'top'));
528 $output .
= theme('table', $header, $rows).
'<p> </p>';
531 $output .
= t('<p>No profiles found.</p>');
534 $group = form_radios(t('Default tinymce state'), 'tinymce_default_state', variable_get('tinymce_default_state', 0), array(t('Off'), t('On')), t('Should tinymce be enabled or disabled by default when it\'s first loaded from a textarea? Note: The user may override this setting in their profile.'));
535 $output .
= form_group(t('Default settings'), $group);
536 $output .
= form_submit(t('Save settings'));
538 return form($output);
542 * Save a profile to the database.
544 function tinymce_profile_save($edit) {
545 db_query("DELETE FROM {tinymce_settings} WHERE name = '%s' or name = '%s'", $edit['name'], $edit['old_name']);
546 db_query("DELETE FROM {tinymce_role} WHERE name = '%s' or name = '%s'", $edit['name'], $edit['old_name']);
547 db_query("INSERT INTO {tinymce_settings} (name, settings) VALUES ('%s', '%s')", $edit['name'], serialize($edit['settings']));
548 foreach ($edit['rids'] as
$rid) {
549 db_query("INSERT INTO {tinymce_role} (name, rid) VALUES ('%s', %d)", $edit['name'], $rid);
554 * Profile validation.
556 function tinymce_profile_validate($edit) {
559 if (!$edit['name']) {
560 $errors['name'] = t('You must give a profile name.');
563 if (!$edit['rids']) {
564 $errors['rids'] = t('You must select at least one role.');
567 foreach ($errors as
$name => $message) {
568 form_set_error($name, $message);
571 return count($errors) == 0;
574 /********************************************************************
575 * Module Functions :: Private
576 ********************************************************************/
579 * Determine if TinyMCE has permission to be used on the current page.
582 * TRUE if can render, FALSE if not allowed.
584 function _tinymce_page_match($edit) {
585 //Kill TinyMCE if we're editing a textarea with PHP in it!
586 if ($_POST['edit']['format'] == 2) {
590 // PHP input formats are #2 in the filters table.
591 preg_match("|^node/(\d+)(/edit)$|", $_GET['q'], $match);
592 if (intval($match[1]) > 0) {
593 if (db_result(db_query('SELECT format FROM {node} WHERE nid = %d AND format = 2', $match[1]))) {
599 if ($edit->settings
['access'] == 1) {
604 $pages = $edit->settings
['access_pages'] ?
$edit->settings
['access_pages'] : tinymce_help('admin/settings/tinymce#pages');
606 $path = drupal_get_path_alias($_GET['q']);
607 $regexp = '/^('.
preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'.
variable_get('site_frontpage', 'node') .
'\2'), preg_quote($pages, '/')) .
')$/';
608 $page_match = preg_match($regexp, $path);