summaryrefslogtreecommitdiffstats
path: root/wysiwyg.dialog.inc
blob: d7404226e54e7c89ddac3fbc21e93856b9b8ac0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
// $Id$

/**
 * @file
 * Wysiwyg dialog page handling functions.
 */

/**
 * Menu callback; Output a wysiwyg plugin dialog page.
 */
function wysiwyg_dialog($plugin, $instance) {
  $plugins = wysiwyg_get_all_plugins();
  if (!isset($plugins[$plugin])) {
    return drupal_access_denied();
  }
  $callback = $plugin . '_wysiwyg_dialog';
  if (!function_exists($callback)) {
    return drupal_not_found();
  }

  // Suppress admin menu.
  module_invoke('admin_menu', 'suppress');
  // Add editor instance id to Drupal.settings.
  drupal_add_js(array('instance' => $instance), 'setting');

  echo theme('wysiwyg_dialog_page', $callback($instance));
}

/**
 * Template preprocess function for theme_wysiwyg_dialog_page().
 *
 * @see wysiwyg_dialog()
 * @see wysiwyg-dialog-page.tpl.php
 * @see template_preprocess()
 */
function template_preprocess_wysiwyg_dialog_page(&$variables) {
  // Construct page title
  $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal'));

  $variables['head_title']        = implode(' | ', $head_title);
  $variables['base_path']         = base_path();
  $variables['front_page']        = url();
  // @todo Would a breadcrumb make sense / possible at all?
  // $variables['breadcrumb']        = theme('breadcrumb', drupal_get_breadcrumb());
  $variables['head']              = drupal_get_html_head();
  $variables['help']              = theme('help');
  $variables['language']          = $GLOBALS['language'];
  $variables['language']->dir     = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
  $variables['messages']          = $variables['show_messages'] ? theme('status_messages') : '';
  $variables['site_name']         = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : '');
  $variables['css']               = drupal_add_css();
  $variables['styles']            = drupal_get_css();
  $variables['scripts']           = drupal_get_js();
  $variables['tabs']              = theme('menu_local_tasks');
  $variables['title']             = drupal_get_title();
  // Closure should be filled last.
  $variables['closure']           = theme('closure');
}

/**
 * Render a single Wysiwyg (plugin) dialog page. (D5 only)
 *
 * @see template_preprocess_wysiwyg_dialog_page()
 * @see wysiwyg-dialog-page.tpl.php
 */
function theme_wysiwyg_dialog_page($content) {
  $variables = array('content' => $content);
  template_preprocess_wysiwyg_dialog_page($variables);
  return _phptemplate_render(drupal_get_path('module', 'wysiwyg') . '/wysiwyg-dialog-page.tpl.php', $variables);
}