There is not a real text format API to load/save/delete text formats, all the queries are executed in form submit handlers.

Install profiles could use text format APIs to add predefined formats when installing.

The patch add filter_format_save() and filter_format_delete() to filter module. The code from the submit handlers is moved to these API functions.

Related issue: #428296: Filter system doesn't communicate with modules about altered text formats. We should add the hooks proposed there inside these API functions.

CommentFileSizeAuthor
#4 formats-API-4.patch7.61 KBdropcube
formats-API.patch7.84 KBdropcube
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dropcube’s picture

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Nice work. We have good code coverage for this with testFilterAdmin() class so we can proceed with RTBC.

Ping me if you have a patch to start using strings for text format IDs (hint hint).

Thanks for working on our neglected text format system.

sun’s picture

Status: Reviewed & tested by the community » Needs work
+++ modules/filter/filter.module	22 Aug 2009 22:17:04 -0000
@@ -138,6 +138,100 @@
+ * @param $format
+ *  A format object.

Wrong indentation.

+++ modules/filter/filter.module	22 Aug 2009 22:17:04 -0000
@@ -138,6 +138,100 @@
+  $current = filter_list_format($format->format);
+  $format->name = trim($format->name);
+  $filters = $format->filters;

These lines could use some simple comments to explain what's being done.

+++ modules/filter/filter.module	22 Aug 2009 22:17:04 -0000
@@ -138,6 +138,100 @@
+  
...
+    
...
+    ->execute();  
+  

(and elsewhere) Trailing white-space.

+++ modules/filter/filter.module	22 Aug 2009 22:17:04 -0000
@@ -138,6 +138,100 @@
+  // Add a new text format.
+  if (!$format->format) {

Better check using !empty().

+++ modules/filter/filter.admin.inc	22 Aug 2009 22:16:47 -0000
@@ -197,78 +197,23 @@
+    
+  switch ($status) {
+    case SAVED_NEW:
+     drupal_set_message(t('Added text format %format.', array('%format' => $format->name)));
+      $return .= '/' . $format->format;
+      break;
+    case SAVED_UPDATED:
+      drupal_set_message(t('The text format settings have been updated.'));
+      break;
+  }  
+

Wrong indentation and trailing white-space here.

I'm on crack. Are you, too?

dropcube’s picture

Status: Needs work » Needs review
FileSize
7.61 KB

Update patch fixing issues reported by sun and other cleanups.

dropcube’s picture

Title: Add text format API to manipulate format » Add text format API to manipulate formats
moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community
Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -DX (Developer Experience), -FilterSystemRevamp, -API change, -API addition

Automatically closed -- issue fixed for 2 weeks with no activity.