Index: modules/php/php.test =================================================================== RCS file: /cvs/drupal/drupal/modules/php/php.test,v retrieving revision 1.16 diff -u -r1.16 php.test --- modules/php/php.test 28 Aug 2009 16:23:04 -0000 1.16 +++ modules/php/php.test 6 Sep 2009 20:23:24 -0000 @@ -56,7 +56,7 @@ // 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 @@ $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.')); } } Index: modules/filter/filter.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.pages.inc,v retrieving revision 1.7 diff -u -r1.7 filter.pages.inc --- modules/filter/filter.pages.inc 8 Mar 2009 21:25:18 -0000 1.7 +++ modules/filter/filter.pages.inc 6 Sep 2009 20:23:23 -0000 @@ -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); } Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.287 diff -u -r1.287 filter.module --- modules/filter/filter.module 30 Aug 2009 06:04:09 -0000 1.287 +++ modules/filter/filter.module 6 Sep 2009 20:23:23 -0000 @@ -57,9 +57,6 @@ '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,18 @@ ); $form['format_help'] = array( '#prefix' => '
', - '#markup' => theme('filter_tips_more_info'), '#suffix' => '
', '#weight' => 1, ); + $form['format_help']['#attached']['drupal_add_dialog'][][] = array( + 'trigger_selector' => '.filter-tips-modal', + 'content_selector' => '#filter-tips-modal-dialog', + 'options' => array( + 'width' => 600, + 'height' => 500, + ), + ); + $form['format_help'] = array_merge($form['format_help'], filter_tips_more_info()); return $form; } @@ -736,12 +741,16 @@ } /** - * 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; } /** Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.984 diff -u -r1.984 common.inc --- includes/common.inc 5 Sep 2009 15:05:01 -0000 1.984 +++ includes/common.inc 6 Sep 2009 20:23:15 -0000 @@ -5478,3 +5478,40 @@ return call_user_func_array('_xmlrpc', $args); } +/** + * Adds a dialog using jQuery UI. + * + * @param $options + * An array of options with the following keys: + * - 'trigger_selector' + * A jQuery selector which should open a dialog when clicked. + * Example: 'a#modal-link'. + * - 'content_selector' + * A jQuery selector which contains the content for display in the dialog. + * - 'options' + * An array of dialog options keyed by option name. + * See @link http://docs.jquery.com/UI/Dialog#options for available + * options. + */ +function drupal_add_dialog(array $options = array()) { + $dialogs = &drupal_static(__FUNCTION__, array()); + // Add default options to the options array. + $options += array( + 'options' => 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'); + } + $trigger_selector = $options['trigger_selector']; + if (!isset($dialogs[$trigger_selector])) { + $dialogs[$trigger_selector] = array( + 'content_selector' => $options['content_selector'], + 'options' => $options['options'], + ); + drupal_add_js(array('dialogs' => $dialogs), 'setting'); + } + return $dialogs; +} Index: misc/dialog.js =================================================================== RCS file: misc/dialog.js diff -N misc/dialog.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ misc/dialog.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,31 @@ +// $Id$ +(function ($) { + +/** + * Initialize all modal dialogs requested by drupal_add_dialog(). + */ +Drupal.behaviors.dialog = { + attach: function (context, settings) { + for (var key in Drupal.settings.dialogs) { + if (!$(key).hasClass('dialog-processed')) { + var dialog = Drupal.settings.dialogs[key]; + // Initialize the dialog with some default settings. + // Other default settings are defined by http://docs.jquery.com/UI/Dialog. + $(dialog.content_selector).dialog({ + autoOpen: false + }); + // Alter the dialog with any custom settings. + for (var optionName in dialog.options) { + $(dialog.content_selector).dialog('option', optionName, dialog.options[optionName]); + } + $(key).click(function() { + $(dialog.content_selector).dialog('open'); + return false; + }) + .addClass('dialog-processed'); + } + } + } +} + +})(jQuery);