diff --git includes/common.inc includes/common.inc index 9f45fec..1d4cf5c 100644 --- includes/common.inc +++ includes/common.inc @@ -3185,6 +3185,8 @@ function drupal_get_js($scope = 'header', $javascript = NULL) { * An array of JavaScript components to add. * @param $css * An array of cascading stylesheets to add. + * @param $dialog + * An array of parameters as expected by drupal_add_dialog(). * @param $weight * The default weight of JavaScript and CSS being added. This is only applied * to the stylesheets and JavaScript items that don't have an explicit weight @@ -3199,7 +3201,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) { * * @see drupal_add_library(), drupal_render() */ -function drupal_process_attached(array $libraries = array(), array $js = array(), array $css = array(), $weight = JS_DEFAULT, $dependency_check = FALSE) { +function drupal_process_attached(array $libraries = array(), array $js = array(), array $css = array(), array $dialogs, $weight = JS_DEFAULT, $dependency_check = FALSE) { // Add the libraries first. $success = TRUE; foreach ($libraries as $library) { @@ -3234,6 +3236,12 @@ function drupal_process_attached(array $libraries = array(), array $js = array() call_user_func('drupal_add_' . $type, $data, $options); } } + + // Dialogs to the page. + foreach ($dialogs as $dialog) { + call_user_func_array('drupal_add_dialog', $dialog); + } + return $success; } @@ -3266,7 +3274,7 @@ function drupal_add_library($module, $name) { if (!isset($added[$module][$name])) { if ($library = drupal_get_library($module, $name)) { // Add all components within the library. - $added[$module][$name] = drupal_process_attached($library['dependencies'], $library['js'], $library['css'], JS_LIBRARY, TRUE); + $added[$module][$name] = drupal_process_attached($library['dependencies'], $library['js'], $library['css'], array(), JS_LIBRARY, TRUE); } else { // Requested library does not exist. @@ -4119,7 +4127,8 @@ function drupal_render(&$elements) { drupal_process_attached( isset($elements['#attached_library']) ? $elements['#attached_library'] : array(), isset($elements['#attached_js']) ? $elements['#attached_js'] : array(), - isset($elements['#attached_css']) ? $elements['#attached_css'] : array() + isset($elements['#attached_css']) ? $elements['#attached_css'] : array(), + isset($elements['#attached_dialog']) ? $elements['#attached_dialog'] : array() ); $prefix = isset($elements['#prefix']) ? $elements['#prefix'] : ''; @@ -4230,7 +4239,8 @@ function drupal_render_cache_get($elements) { drupal_process_attached( isset($cache->data['#attached_library']) ? $cache->data['#attached_library'] : array(), isset($cache->data['#attached_js']) ? $cache->data['#attached_js'] : array(), - isset($cache->data['#attached_css']) ? $cache->data['#attached_css'] : array() + isset($cache->data['#attached_css']) ? $cache->data['#attached_css'] : array(), + isset($cache->data['#attached_dialog']) ? $cache->data['#attached_dialog'] : array() ); // Return the rendered output. return $cache->data['#markup'];; @@ -5409,3 +5419,34 @@ function xmlrpc($url) { return call_user_func_array('_xmlrpc', $args); } +/** + * Adds a dialog using jQuery UI. + * + * @param $trigger_selector + * A jQuery selector which should open a dialog when clicked. + * Example: 'a#modal-link' + * @param $content_selector + * A jQuery selector which contains the content for display in the dialog. + * @param $options + * An array of dialog options keyed by option name. + * See http://docs.jquery.com/UI/Dialog#options for available options. + */ +function drupal_add_dialog($trigger_selector = '', $content_selector = '', $options = array()) { + $dialogs = &drupal_static(__FUNCTION__, array()); + if (!count($dialogs)) { + drupal_add_library('system', 'ui.dialog'); + drupal_add_library('system', 'ui.draggable'); + drupal_add_library('system', 'ui.resizable'); + drupal_add_js('misc/dialog.js'); + } + if (!isset($dialogs[$trigger_selector])) { + $dialogs[$trigger_selector] = array( + 'content_selector' => $content_selector, + 'options' => $options, + ); + // Allow modules to alter dialogs. + drupal_alter('dialog', $dialogs); + drupal_add_js(array('dialogs' => $dialogs), 'setting'); + } + return $dialogs; +} diff --git modules/filter/filter.module modules/filter/filter.module index 6ab8245..cdc3182 100644 --- modules/filter/filter.module +++ modules/filter/filter.module @@ -57,9 +57,6 @@ function filter_theme() { 'arguments' => array('tips' => NULL, 'long' => FALSE), 'file' => 'filter.pages.inc', ), - 'filter_tips_more_info' => array( - 'arguments' => array(), - ), 'filter_guidelines' => array( 'arguments' => array('format' => NULL), ), @@ -635,10 +632,11 @@ function filter_form($selected_format = FILTER_FORMAT_DEFAULT, $weight = NULL, $ ); $form['format_help'] = array( '#prefix' => '
', - '#markup' => theme('filter_tips_more_info'), + '#attached_dialog' => array(array(".filter-tips-modal", "#filter-tips-modal-dialog", array('width' => 600, 'height' => 500))), '#suffix' => '
', '#weight' => 1, ); + $form['format_help'] = array_merge($form['format_help'], filter_tips_more_info()); return $form; } @@ -736,12 +734,16 @@ function filter_dom_serialize($dom_document) { } /** - * Format a link to the more extensive filter tips. - * - * @ingroup themeable + * Build a render() array which links to the more extensive filter tips. */ -function theme_filter_tips_more_info() { - return '

' . l(t('More information about text formats'), 'filter/tips') . '

'; +function filter_tips_more_info() { + $build['more'] = array('#markup' => l(t('More information about text formats'), 'filter/tips', array('attributes' => array('class' => 'filter-tips-modal')))); + $build['long'] = array( + '#prefix' => '
', + '#markup' => filter_tips_long(), + '#suffix' => '
', + ); + return $build; } /** diff --git modules/filter/filter.pages.inc modules/filter/filter.pages.inc index 5d76af4..165876d 100644 --- modules/filter/filter.pages.inc +++ modules/filter/filter.pages.inc @@ -11,14 +11,7 @@ * Menu callback; show a page with long filter tips. */ function filter_tips_long() { - $format = arg(2); - if ($format) { - $output = theme('filter_tips', _filter_tips($format, TRUE), TRUE); - } - else { - $output = theme('filter_tips', _filter_tips(-1, TRUE), TRUE); - } - return $output; + return theme('filter_tips', _filter_tips(-1, TRUE), TRUE); } diff --git modules/php/php.test modules/php/php.test index 4099ef9..fe98f83 100644 --- modules/php/php.test +++ modules/php/php.test @@ -56,7 +56,7 @@ class PHPFilterTestCase extends PHPTestCase { // Make sure that the PHP code shows up as text. $this->drupalGet('node/' . $node->nid); - $this->assertText('print', t('PHP code is displayed.')); + $this->assertText('print "SimpleTest PHP was executed!"', t('PHP code is displayed.')); // Change filter to PHP filter and see that PHP code is evaluated. $edit = array(); @@ -66,7 +66,7 @@ class PHPFilterTestCase extends PHPTestCase { $this->assertRaw(t('Page %title has been updated.', array('%title' => $node->title)), t('PHP code filter turned on.')); // Make sure that the PHP code shows up as text. - $this->assertNoText('print', t('PHP code isn\'t displayed.')); + $this->assertNoText('print "SimpleTest PHP was executed!"', t('PHP code isn\'t displayed.')); $this->assertText('SimpleTest PHP was executed!', t('PHP code has been evaluated.')); } }