Flexifilter was created as part of ghop so it would make sense to port this module to drupal7 during gci :)

Deliverables

Port the module to drupal7 and provide a patch for the update.

Resources

Update modules from 6 to 7 introduction http://drupal.org/node/224333
Coder module: has some automatic ways to update a module http://drupal.org/project/coder
Create patches: http://drupal.org/patch/create

Primary contact

dereine on (drupal.org or #drupal or #drupal-contribute or #drupal-gci).

Comments

vosechu’s picture

Status: Needs review » Reviewed & tested by the community

Looks awesome to me. If we did it during GHOP we can certainly do the port during GCI with some love and attention from the mentors.

cwgordon7’s picture

Status: Reviewed & tested by the community » Needs review

Flexifilter is kind of in disrepair in Drupal 6 as it is. Are we sure it's a good idea to port it to Drupal 7?

dmitrig01’s picture

what about rewriting flexifilter in d7?

dmitrig01’s picture

(maybe giving it a better name?)

vosechu’s picture

If dmitri is ready to go on this we may as well right? I'm sure that no matter what he does it's going to turn out awesome so maybe this is a great time to rewrite.

alex ua’s picture

Status: Needs review » Reviewed & tested by the community

Yes, let's give this one a go. This should definitely be marked as difficult in the GCI system... Marking as RTBC.

alex ua’s picture

Status: Reviewed & tested by the community » Fixed

This has been moved to GCI. For now I set it to 7 days for the length of time needed- please let me know if it needs more/less time.

dawehner’s picture

Status: Fixed » Active

Now the student can work on it.

axyjo’s picture

Assigned: Unassigned » axyjo

Hi all,

I've claimed the task on Melange and I had a quick question about when I'm supposed to use the drupal_* string functions compared to the standard PHP string functions. Coder says that I should replace the standard PHP functions with the drupal_* equivalents in most cases. However, the 6.x branch for flexifield does not use the drupal_* functions even though a.d.o says that the drupal_* functions have been around since 4.7. Should I leave it as-is then?

Work in progress is located here: https://github.com/axyjo/flexifilter-d7

Thanks!

axyjo’s picture

Status: Active » Needs work

Forgot to change status.

axyjo’s picture

Got my question answered on #drupal-gci by dmitrig01.

axyjo’s picture

Status: Needs work » Needs review

Could I get an extension please? I need this weekend to fix one last hook (hook_filter), make it work in sqlite and test it with mysql. I don't have postgres, so I can't test with that. Existing work is available in the github repository mentioned in #9.

okokokok’s picture

With the current git I'm getting this error on admin/structure/flexifilters:
Fatal error: [] operator not supported for strings in /var/www/example.org/htdocs/includes/theme.inc on line 1629

axyjo’s picture

Thanks, I'll look into it.

dmitrig01’s picture

axyjo, try re-claiming the GCI task

cor3huis’s picture

If you use the drupal_* string function make sure flexifilter can still export correct PHP module code.

axyjo’s picture

Issue tags: -gci-proposal, -gci-hard, -gci-code

Sorry about the delay, just finished exams yesterday. Here's the code on GitHub that *should* be ready to go. I've clicked through the admin interfaces and it seems to work, but I'm not sure how to test whether everything works as it should. There's also D7 coding standards changes included in it. Link: https://github.com/axyjo/flexifilter-d7

I've also attached a patch on this comment. This is against the current 6.x version in CVS.

@cor3huis: It seems that the PHP module code is syntactically correct, but I have no idea on how to test it.

axyjo’s picture

I have no idea why the file didn't upload and why the issue got untagged.

axyjo’s picture

Issue tags: +gci-proposal, +gci-hard, +gci-code
StatusFileSize
new73.74 KB

Ugh, trying again.
Edit: Finally!

cwgordon7’s picture

Wow, axyjo, this looks impressive! I'll ask dereine to take a look at it. Thanks for all your hard work!

dawehner’s picture

-    db_query("UPDATE {flexifilters_parts} SET fid = %d, parent_pid = %d, type = %d, class_name = '%s', settings = '%s' WHERE pid = %d",
-      $fid, $parent, FLEXIFILTER_PART_TYPE_CONDITION, $condition['class'], serialize($condition['settings']), $our_pid);
+    db_update('flexifilters_parts')
+  ->fields(array(
+      'fid' => $fid,
+      'parent_pid' => $parent,
+      'type' => FLEXIFILTER_PART_TYPE_CONDITION,
+      'class_name' => $condition['class'],
+      'settings' => serialize($condition['settings']),
+    ))
+  ->condition('pid', $our_pid)
+  ->execute();
   }
   else {
-    db_query("INSERT INTO {flexifilters_parts} (fid, parent_pid, type, class_name, settings) VALUES (%d, %d, %d, '%s', '%s')",
-      $fid, $parent, FLEXIFILTER_PART_TYPE_CONDITION, $condition['class'], serialize($condition['settings']));
-    $our_pid = db_last_insert_id('flexifilters_parts', 'pid');
+    $our_pid = db_insert('flexifilters_parts')
+  ->fields(array(
+      'fid' => $fid,
+      'parent_pid' => $parent,
+      'type' => FLEXIFILTER_PART_TYPE_CONDITION,
+      'class_name' => $condition['class'],
+      'settings' => serialize($condition['settings']),

Couldn't this part be converted to drupal_write_record?

Some left over debug code


+  dvm(base64_decode($form_state['values']['flexifilter']));

In general it looks very nice! Awesome work.

Would like to do some more review/testing but it seems to be ready to be approved.

cor3huis’s picture

THX for the reply on http://drupal.org/node/957528#comment-3844280 will test it on D6, I need to fix first other D6 module issues (Mailhandler)

axyjo’s picture

@dereine: Sorry about the debug code. It was part of my uncommitted changes and it got rolled in with the patch. I'll look into drupal_write_record and re-roll shortly (without the debug code).

@cor3huis: This patch converts Flexifilter to D7.

pillarsdotnet’s picture

StatusFileSize
new447 bytes

Patch against the github code to move flexifilter to the same modules group as Markdown, SimpleWiki, Textile, and Typogrify.

pillarsdotnet’s picture

StatusFileSize
new745 bytes

Added a filter and a chunk-grabber, and got the following notice:

  • Notice: Use of undefined constant FLEXIFILTER_MAX_FILTERS - assumed 'FLEXIFILTER_MAX_FILTERS' in flexifilter_filter_edit_form_submit() (line 756 of flexifilter.admin.inc).

The constant doesn't appear to be defined in any of the other source files, either.

sites/all/modules/flexifilter$ grep -ri max .
./flexifilter.module:      $id_next = max($id_next, $row->pid + 1);
./flexifilter.components.inc:      $max          = isset($settings['number']) ? $settings['number'] : '2';
./flexifilter.components.inc:      $max     = count($replace);
./flexifilter.components.inc:        if ($i >= $max) {
./flexifilter.components.inc:          $i = $i - $max;
./flexifilter.components.inc:        '#title' => t('The maximum number of characters to allow in this slice.'),
./flexifilter.admin.inc:      $condition_max_id = 0;
./flexifilter.admin.inc:          $condition_max_id = max($condition_max_id, 1 + (int) substr($key, 10));
./flexifilter.admin.inc:        $form['condition_' . $condition_max_id] = flexifilter_filter_edit_form_condition(flexifilter_filter_edit_form_new_condition_data($data['add_condition']), $show_advanced);
./flexifilter.admin.inc:    '#maxlength' => 127,
./flexifilter.admin.inc:    '#maxlength' => 255,
./flexifilter.admin.inc:    if (flexifilter_get_number_enabled_filters() < FLEXIFILTER_MAX_FILTERS) {

The code context is as follows:

function flexifilter_filter_edit_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  $values['components'] = flexifilter_filter_edit_form_components_from_data($values['components'])\
;
  $values += $values['basic'];
  unset($values['basic']);
  if ($values['fid'] === 'new') {
    $enabled = 0;
    if (flexifilter_get_number_enabled_filters() < FLEXIFILTER_MAX_FILTERS) {
      $enabled = 1;
    }
    $values['enabled'] = $enabled;
  }
  $fid = flexifilter_save_filter($values);
  if ($values['fid'] === 'new') {
    drupal_set_message(t('Flexifilter created.'));
    if ($values['op'] == $values['submit2']) {
      unset($form_state['storage']);
      unset($form_state['rebuild']);
      $form_state['redirect'] = 'admin/structure/flexifilters/' . $fid . '/edit';
    }
  }
  else {
    drupal_set_message(t('Flexifilter saved.'));
  }
  if ($values['op'] == $values['submit1']) {
    unset($form_state['storage']);
    unset($form_state['rebuild']);
    $form_state['redirect'] = 'admin/structure/flexifilters';
  }
}

Dunno... I'm tempted to just comment out the offending code.

pillarsdotnet’s picture

Mmm....

Tried adding components multiple times, but the form just kept coming back without any noticeable change.

Finally tried clicking on the [Preview] tab, typed "foo" into the text box, and clicked the (Preview) button. Got the following errors:

  • Notice: Undefined index: components in flexifilter_filter_preview_form_submit() (line 1031 of flexifilter.admin.inc).
  • Warning: Invalid argument supplied for foreach() in flexifilter_invoke_components() (line 321 of flexifilter.module).
  • Notice: Undefined index: components in flexifilter_filter_preview_form_submit() (line 1032 of flexifilter.admin.inc).
  • Warning: Invalid argument supplied for foreach() in flexifilter_invoke_components() (line 321 of flexifilter.module).

Gonna give it up. Was hoping to port a couple of customfilters (D6) to flexifilter (D7) but it looks like I'm gonna have to write a custom module or two, instead.

axyjo’s picture

Status: Needs review » Needs work

FLEXIFILTERS_MAX_FILTERS was removed. Let me fix up the code and try doing what you did again. I'll also integrate your patch. Thanks for testing!

pillarsdotnet’s picture

Noticed the change to use drupal_write_record(). Is it ready for testing again?

axyjo’s picture

There's still an issue with the installation process where some of the values aren't populated correctly in the database. I'll update the issue when I fix this error. Thanks for helping test this!

cor3huis’s picture

@pillarsdotnet IMHO helping to get this to work will save you quite some time instead of creating yet another module, but then again, I don't know how fast you can type ;)

axyjo’s picture

Alright, the preview functionality now works in the latest HEAD. The latest HEAD also includes some unit tests. Currently working on the component adding issue.

pillarsdotnet’s picture

@cor3huis -- I already created the modules I needed. One of them converts scripture references (e.g. [John 3:16]) to block-formatted quotations from the Bible. The other converts references to node titles (e.g. [About] or [Contact Us]) to node links. Source available on request.

However, I'm still interested in testing and troubleshooting this module, once it's ready.

axyjo’s picture

Status: Needs work » Needs review
StatusFileSize
new89.11 KB

All done (I think)! Click-testing through the issues reported above works, as well as creating a text format with a flexifilter. Patch against current 6.x HEAD attached, and incremental work can be found on GitHub (http://github.com/axyjo/flexifilter-d7).

Seasons greetings!

axyjo’s picture

StatusFileSize
new88.92 KB

A few more fixes based on dereine's comments in IRC.

dawehner’s picture

Project: Google Code-in » Flexifilter
Version: » 6.x-2.x-dev
Component: Code » Code - API
Status: Needs review » Reviewed & tested by the community

In general this looks fineIn general this looks fine.

dawehner’s picture

In general this looks fineIn general this looks fine.

dawehner’s picture

In general this looks fineIn general this looks fine.

js’s picture

subscribing

finex’s picture

subscribe

flokli’s picture

subscribe.
What about creating a d7 branch (and d7 -dev version) for this on the module page?

jarodms’s picture

subscribe

xenyo’s picture

subscribe

xenyo’s picture

Any progress on this axygo? I tried to install the Github version but enabling the mediawiki filter gives me errors.

Cheers.

axyjo’s picture

The patch in 35 is the latest version.

majortom’s picture

Any idea on a time frame for a D7 release?

cor3huis’s picture

@majortom, as always, no timeframe. The only way to speed things up is to help out with current flexifilter whereevery you can. Thus walk the issue queue and solve issues you can, comment on issues, provide patches.
You can also contact the module maintainer an ask to become a co maintainrer for the time being. You could use the coder module online http://upgrade.boombatower.com/tools/php/directories to auto convert to a D7 version, fix something and post the alpha version as an issue with review status.

axyjo’s picture

The patch in 35 is ready to go as soon as the maintainer is ready to commit it. It passes basic testing.

cor3huis’s picture

@axyjo YEAH! happy happy joy joy!. If I'm done with other Drupal stuff I'm ready to test Flexifilter, and brush-up my RegEx skills in the same run ;). IMHO Flexifilter is awork of art and undervaluated. It would be a candidate module to put in the Spotlight as soon as stable version is available.

cappadona’s picture

subscribe

Anonymous’s picture

sub

cwgordon7’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev
Status: Reviewed & tested by the community » Needs work

It is difficult to apply this patch because it was rolled against a drupal.org tarball from the CVS era. There are $Id$ style tags in there, as well as information added by the drupal.org packaging script. If you could reroll this against the git 6.x-1.x branch, that would be a big help. Thanks!

cwgordon7’s picture

Status: Needs work » Fixed

Committed. Thanks everyone!

Status: Fixed » Closed (fixed)
Issue tags: -gci-proposal, -gci-hard, -gci-code

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