$plugin, 'instance' => $instance, ); drupal_add_js(array('wysiwyg' => $settings), 'setting'); $build = $callback($instance); if (!is_array($build)) { $build = array('#markup' => $build); } $build += array( '#instance' => $instance, '#plugin' => $plugin, ); return $build; } /** * @see drupal_deliver_html_page() */ function wysiwyg_deliver_dialog_page($page_callback_result) { // Menu status constants are integers; page content is a string or array. if (is_int($page_callback_result)) { return drupal_deliver_html_page($page_callback_result); } // Emit the correct charset HTTP header, but not if the page callback // result is NULL, since that likely indicates that it printed something // in which case, no further headers may be sent, and not if code running // for this page request has already set the content type header. if (isset($page_callback_result) && is_null(drupal_get_http_header('Content-Type'))) { drupal_add_http_header('Content-Type', 'text/html; charset=utf-8'); } // Send appropriate HTTP-Header for browsers and search engines. global $language; drupal_add_http_header('Content-Language', $language->language); if (isset($page_callback_result)) { // Print anything besides a menu constant, assuming it's not NULL or // undefined. print wysiwyg_render_dialog_page($page_callback_result); } // Perform end-of-request tasks. drupal_page_footer(); } /** * @see drupal_render_page() */ function wysiwyg_render_dialog_page($page) { $main_content_display = &drupal_static('system_main_content_added', FALSE); // Allow menu callbacks to return strings or arbitrary arrays to render. // If the array returned is not of #type page directly, we need to fill // in the page with defaults. if (is_string($page) || (is_array($page) && (!isset($page['#type']) || ($page['#type'] != 'page')))) { drupal_set_page_content($page); $page = element_info('wysiwyg_dialog_page'); } // Modules alter the $page as needed. Blocks are populated into regions like // 'sidebar_first', 'footer', etc. drupal_alter(array('wysiwyg_dialog_page', 'page'), $page); // If no module has taken care of the main content, add it to the page now. // This allows the site to still be usable even if no modules that // control page regions (for example, the Block module) are enabled. if (!$main_content_display) { $page['content']['system_main'] = drupal_set_page_content(); } return drupal_render($page); } /** * Template preprocess function for theme_wysiwyg_dialog_page(). * * @see wysiwyg_dialog() * @see wysiwyg-dialog-page.tpl.php * @see template_preprocess_page() */ function template_preprocess_wysiwyg_dialog_page(&$variables) { template_preprocess_page($variables); } /** * Template process function for theme_wysiwyg_dialog_page(). * * @see wysiwyg_dialog() * @see wysiwyg-dialog-page.tpl.php * @see template_process_page() */ function template_process_wysiwyg_dialog_page(&$variables) { template_process_page($variables); }