I've tried to make OG HEAD work with Views-dev, with the new API changes.

* implemented hook_views_api().
* Moved all handlers to separet .inc files, implementing hook_views_handlers (some of these perhaps could be in the same file, but for easy updating I've put them all in their own files)
* Moved plugins (only one) to .inc file

There's still some issues with the handlers (i.e. they're not working...), but it's a start.

Side note: perhaps a new component for og_views in the issues?

Comments

blackdog’s picture

Status: Needs review » Needs work

Still needs work...

blackdog’s picture

Status: Needs work » Needs review
StatusFileSize
new54.04 KB

Updated patch with working handlers.

I've changed some class names so the og_views handlers have their own namespace.

karens’s picture

Status: Needs review » Needs work

I tried this out and it is pretty close but there are still some problems. I can get to the Views list and the og views show up on the list and can be edited.

1) in the file og_views.views.inc $date['og_uid']['is_manager'] should be using the new name for the handler, 'og_views_handler_is_manager' or you get a 'broken handler' message.

2) When I try to view the og directory, I get a message 'Class 'views_handler_field_numeric' not found in ...og_views_handler_field_og_post_count.inc on line 5.

That second message indicates that the parent handler isn't getting included correctly. The code looks like it is set up right so I don't know why that is broken. The parent is correctly declared in the views_handlers hook, so it should be working.

3) Nothing seems to be actually generating queries. That could be because the handlers aren't getting found, so fixing #2 may take care of that.

I don't have any more time to spend on this right now, but thought I'd add those observations.

yched’s picture

+function og_views_views_api() {
+  return array(
+    'api' => 2,
+  );
+}

This probably misses

'path' => drupal_get_path('module', 'og_views') . '/includes',

(if that's where the new handler files are added)

yched’s picture

Er, scratch that, that would be if the hook_views_plugins() etc implementations lived in a separate file.

karens’s picture

Nope, you're right. The files *are* in an 'includes' subfolder. That's what's missing. I added that and my problems went away.

I'll add that and my other fix in and roll a new patch.

karens’s picture

I can't get a patch to include all the new files as the original did, so maybe backdog can re-roll his patch.

Add the change in #4 and rename the handler for $date['og_uid']['is_manager'] to use the new name and things should be working.

rapsli’s picture

how can I help with the module?

blackdog’s picture

Re-roll on the way!

karens’s picture

One more change is needed. If you change the path in hook_api(), which you must, you also have to move og_views_views.inc into the includes folder along with all the other .inc files or you'll get messages about missing handlers.

With that last change everything works.

blackdog’s picture

StatusFileSize
new56.34 KB

I've updated the patch with the correct handler name for $data['og_uid']['is_manager'].

There's actually no need for the 'path' => drupal_get_path('module', 'og_views') . '/includes', in hook_view_api(), because the two .inc files that function calls are in the same directory (og_views.views.inc and og_views.views_default.inc).

Not working:

* Group directory - something is off with that handler.
* Group search (og/search) - filter handler not working.

All other OG Views seems to be working correctly.

karens’s picture

Agh!! I take it back, if you move that file the broken handler messages go away, but the views quit working.

I don't have any more time to mess with this now, but it's a path issue, one way or another. You'll have to play around with placing files in different locations and changing the way you declare the paths, then test which combination produces no 'broken handler' messages and creates the right queries.

[Edit] We cross-posted. If you got that much working you got further than I did.

blackdog’s picture

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

Ok, fixed the fatal error, but can't really say if it's a hack or if something is wrong with either Views class loading or og_views implementation. I removed the _numeric part of the class name in og_views_handler_field_og_post_count.inc, and now the View seems to work.

Og search was 'broken' because I hadn't enabled the search module. This view should probably be disabled as default, or a check be made if search module is available. That's another patch though.

A few other fixes has made it in this patch:

* A string fix in og_views.module for when the default og_ghp_ron view wasn't found: drupal_set_message(t('The View @name was not found. Check your variables table or settings.php', array('@name' => $name)), 'error');

* the database error explained here

* various code style fixes and comments.

Please review.

moshe weitzman’s picture

Thanks for your work, all. I'm hoping someone will review this until is RTBC. I will be sure to commit quickly at that point.

About the search and file library Views depending on other modules - see http://drupal.org/node/279257. I am waiting on Views2 to fix it like Views1 did.

karens’s picture

Removing the _numeric part of the class name is *not* the right fix. That means you're extending the wrong class. It fixes the error because the class you really need is not available, so if you put the right class back, you're back to the original error I was finding.

Yes, I also noticed a few views that generated errors because modules were not enabled. The file view won't work if upload module is disabled. So there are a few places that need to do some module_exists() checks before enabling those default views.

karens’s picture

Found it!!

It's a typo, in hook_views_handlers() we have:

      'og_views_handler_field_og_post_count' => array(
        'parent' => 'views_handler_filter_numeric',
      ),

but it *should* be:

      'og_views_handler_field_og_post_count' => array(
        'parent' => 'views_handler_field_numeric',
      ),

Fix that and fix the class name that you altered to avoid the fatal error and it might be working right :)

blackdog’s picture

StatusFileSize
new57.11 KB

Updated patch fixes #16, and one more typo I made in hook_views_handlers().

All default Views seem to work as expected.

There's a string error on og/my, probably because I haven't enabled PHP filter, but that probably should be handled in another patch.

karens’s picture

Status: Needs review » Reviewed & tested by the community

This gets rid of all the missing file and broken handler messages and I can go into Views and edit and preview my views with no problem. I would say this is ready to commit.

abamarus’s picture

Looks like you guys are all making good progress on this - and thanks for all your efforts.

I'm having trouble applying the patch though. It looks like the #17 patch requires the module to already be patched with previous patches...? Is this correct? If so what patches do I need to apply and in what order?

Better yet... anyone got a patch that will update from the module as downloaded all in one go?

Thanks again

P

karens’s picture

No, the patch works fine applied against the current HEAD of og. If you're having trouble, just sit tight because I suspect moshe will quickly apply this patch and then you'll just have to get the latest HEAD.

moshe weitzman’s picture

Seems to be working well. I have one minor gripe - too much 'og' prefixing. I took a look at how Views handles its comment handlers/fields at views/modules/comment and its filenames are not prefixed by comment_. The names are just views_handler_field_comment_depth.inc, for example. So, ideally I'd like to see

  1. remove 'og_' from the front of all files in og_views/includes
  2. rename the classes within those files as per #1
  3. rename classes in hook_views_api as per #1

If noone gets around to this task, I will probably just commit whats here.

I fear that i have too much OG prefixing in the UI as well for field names and filter names and so on. Thats for a different patch.

yched’s picture

moshe : see #298823: Views integration using Views' namespace in CCK issue queue
As a result, CCK does now prefix all its handlers with content_...

moshe weitzman’s picture

Status: Reviewed & tested by the community » Fixed

Very well then. Committed. Thanks all.

blackdog’s picture

Status: Fixed » Reviewed & tested by the community

I added the prefixes to make it easier to see what og_views handles and what views handles, and later I saw the CCK issue yched mentions which makes it clear that og_views should use it's own namespace for it's own handlers.

blackdog’s picture

Status: Reviewed & tested by the community » Fixed

Sorry, cross-posted...

abamarus’s picture

Sorry to be thick but how do I get the fixed version? The downloads on the module page are still "old" version!

moshe weitzman’s picture

You wait up to 12 hours. Thats how often packaging happens for dev snapshots

abamarus’s picture

Thanks.... off to look up web sites on how to be patient!

rapsli’s picture

lil error:

/og/my

I get some weird text:
OPML feed containing feeds from all your subscribed groups.', array('!url' => url('og/opml'))); ?>

else, seems to work so far. Great work.

blackdog’s picture

#29: If you read above, this is probably because you haven't enabled the PHP filter. Pleas open a new issue for it.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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