Commit 240db77c authored by Dries's avatar Dries
Browse files

- Patch #582378 by sun: more filter system clean-up.

parent b1a26d0b
......@@ -90,8 +90,8 @@ function theme_filter_admin_overview($variables) {
*/
function filter_admin_format_page($format = NULL) {
if (!isset($format->name)) {
drupal_set_title(t('Add text format'), PASS_THROUGH);
$format = (object)array('name' => '', 'format' => 0);
drupal_set_title(t('Add text format'));
$format = (object) array('name' => '', 'format' => 0);
}
return drupal_get_form('filter_admin_format_form', $format);
}
......
......@@ -120,20 +120,20 @@ function filter_update_7000() {
* Break out "escape HTML filter" option to its own filter.
*/
function filter_update_7001() {
$result = db_query("SELECT format FROM {filter_formats}");
$result = db_query("SELECT format FROM {filter_formats}")->fetchCol();
$insert = db_insert('filters')->fields(array('format', 'module', 'delta', 'weight'));
foreach ($result as $format) {
foreach ($result as $format_id) {
// Deprecated constants FILTER_HTML_STRIP = 1 and FILTER_HTML_ESCAPE = 2.
if (variable_get('filter_html_' . $format->format, 1) == 2) {
$insert->values(array(
'format' => $format->format,
'filter' => 'filter',
'delta' => 4,
'weight' => 0,
));
if (variable_get('filter_html_' . $format_id, 1) == 2) {
$insert->values(array(
'format' => $format_id,
'filter' => 'filter',
'delta' => 4,
'weight' => 0,
));
}
variable_del('filter_html_' . $format->format);
variable_del('filter_html_' . $format_id);
}
$insert->execute();
......
This diff is collapsed.
......@@ -11,9 +11,9 @@
* Menu callback; show a page with long filter tips.
*/
function filter_tips_long() {
$format = arg(2);
if ($format) {
$output = theme('filter_tips', array('tips' => _filter_tips($format, TRUE), 'long' => TRUE));
$format_id = arg(2);
if ($format_id) {
$output = theme('filter_tips', array('tips' => _filter_tips($format_id, TRUE), 'long' => TRUE));
}
else {
$output = theme('filter_tips', array('tips' => _filter_tips(-1, TRUE), 'long' => TRUE));
......
......@@ -165,7 +165,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$this->drupalPost(NULL, $edit, t('Save configuration'));
// Edit text format.
$format = $this->getFilter($edit['name']);
$format = $this->getFormat($edit['name']);
$this->drupalGet('admin/config/content/formats');
$this->assertRaw('admin/config/content/formats/' . $format->format);
$this->drupalGet('admin/config/content/formats/' . $format->format);
......@@ -240,7 +240,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
$this->assertRaw(t('Added text format %format.', array('%format' => $edit['name'])), t('New filter created.'));
$format = $this->getFilter($edit['name']);
$format = $this->getFormat($edit['name']);
$this->assertNotNull($format, t('Format found in database.'));
if ($format !== NULL) {
......@@ -347,14 +347,14 @@ class FilterAdminTestCase extends DrupalWebTestCase {
}
/**
* Get filter by name.
* Retrieve a text format object by name.
*
* @param $name
* Name of filter to find.
* The name of a text format.
* @return
* A filter object.
* A text format object.
*/
function getFilter($name) {
function getFormat($name) {
return db_query("SELECT * FROM {filter_format} WHERE name = :name", array(':name' => $name))->fetchObject();
}
}
......@@ -540,7 +540,7 @@ class FilterNoFormatTestCase extends DrupalWebTestCase {
/**
* Unit tests for core filters.
*/
class FilterUnitTestCase extends DrupalWebTestCase {
class FilterUnitTestCase extends DrupalUnitTestCase {
public static function getInfo() {
return array(
'name' => 'Core filters',
......@@ -1148,12 +1148,12 @@ class FilterHooksTestCase extends DrupalWebTestCase {
$this->assertRaw(t('Added text format %format.', array('%format' => $name)), t('New format created.'));
$this->assertText('hook_filter_format_insert invoked.', t('hook_filter_format_insert was invoked.'));
$format = db_query("SELECT format FROM {filter_format} WHERE name = :name", array(':name' => $name))->fetchField();
$format_id = db_query("SELECT format FROM {filter_format} WHERE name = :name", array(':name' => $name))->fetchField();
// Update text format.
$edit = array();
$edit['roles[2]'] = 1;
$this->drupalPost('admin/config/content/formats/' . $format, $edit, t('Save configuration'));
$this->drupalPost('admin/config/content/formats/' . $format_id, $edit, t('Save configuration'));
$this->assertRaw(t('The text format %format has been updated.', array('%format' => $name)), t('Format successfully updated.'));
$this->assertText('hook_filter_format_update invoked.', t('hook_filter_format_update() was invoked.'));
......@@ -1163,7 +1163,7 @@ class FilterHooksTestCase extends DrupalWebTestCase {
$custom_block['title'] = $this->randomName(8);
$custom_block['body'] = $this->randomName(32);
// Use the format created.
$custom_block['body_format'] = $format;
$custom_block['body_format'] = $format_id;
$this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
$this->assertText(t('The block has been created.'), t('New block successfully created.'));
......@@ -1172,7 +1172,7 @@ class FilterHooksTestCase extends DrupalWebTestCase {
$this->assertNotNull($bid, t('New block found in database'));
// Delete the text format.
$this->drupalPost('admin/config/content/formats/' . $format . '/delete', array(), t('Delete'));
$this->drupalPost('admin/config/content/formats/' . $format_id . '/delete', array(), t('Delete'));
$this->assertRaw(t('Deleted text format %format.', array('%format' => $name)), t('Format successfully deleted.'));
$this->assertText('hook_filter_format_delete invoked.', t('hook_filter_format_delete() was invoked.'));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment