Missed giving credit to cousin_itt, sorry.
[project/wysiwyg.git] / wysiwyg.dialog.inc
CommitLineData
6e91d64e 1<?php
2// $Id$
3
4/**
5 * @file
6 * Wysiwyg dialog page handling functions.
7 */
8
9/**
10 * Menu callback; Output a wysiwyg plugin dialog page.
11 */
12function wysiwyg_dialog($plugin, $instance) {
13 $plugins = wysiwyg_get_all_plugins();
14 if (!isset($plugins[$plugin])) {
15 return drupal_access_denied();
16 }
17 $callback = $plugin . '_wysiwyg_dialog';
18 if (!function_exists($callback)) {
19 return drupal_not_found();
20 }
21
22 // Suppress admin menu.
23 module_invoke('admin_menu', 'suppress');
24 // Add editor instance id to Drupal.settings.
ef25c211 25 $settings = array(
26 'plugin' => $plugin,
27 'instance' => $instance,
28 );
29 drupal_add_js(array('wysiwyg' => $settings), 'setting');
6e91d64e 30
31 echo theme('wysiwyg_dialog_page', $callback($instance));
32}
33
34/**
35 * Template preprocess function for theme_wysiwyg_dialog_page().
36 *
37 * @see wysiwyg_dialog()
38 * @see wysiwyg-dialog-page.tpl.php
39 * @see template_preprocess()
40 */
41function template_preprocess_wysiwyg_dialog_page(&$variables) {
42 // Construct page title
43 $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal'));
44
45 $variables['head_title'] = implode(' | ', $head_title);
46 $variables['base_path'] = base_path();
47 $variables['front_page'] = url();
48 // @todo Would a breadcrumb make sense / possible at all?
49 // $variables['breadcrumb'] = theme('breadcrumb', drupal_get_breadcrumb());
50 $variables['head'] = drupal_get_html_head();
51 $variables['help'] = theme('help');
52 $variables['language'] = $GLOBALS['language'];
53 $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
54 $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : '';
55 $variables['site_name'] = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : '');
56 $variables['css'] = drupal_add_css();
57 $variables['styles'] = drupal_get_css();
58 $variables['scripts'] = drupal_get_js();
59 $variables['tabs'] = theme('menu_local_tasks');
60 $variables['title'] = drupal_get_title();
61 // Closure should be filled last.
62 $variables['closure'] = theme('closure');
63}
64