This module provides a plugin for Views 3.x that allows you to grab a variable in any one of the superglobals and use them as a default value for a contextual filter. The most commonly used superglobal would be $_GET, which would allow you to pull any variables that have been passed via the URL into the contextual filter.

Example Use Case

  • The Search API and Facet API modules both pass their filter values via the URL. This module would allow you grab those values via $_GET and use them in a secondary view, such as a 'Suggested Results' block or some sort of related content.

It currently supports all of the superglobals and can traverse any number of nested arrays or objects.

Sandbox: http://drupal.org/sandbox/ryan.armstrong/1946464
Git: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/ryan.armstrong/1946464.git views_superglobals_default
cd views_superglobals_default

Comments

ycshen’s picture

Status: Needs review » Needs work

Review of the 7.x-1.x branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.


FILE: ...7-pareview/pareview_temp/views_plugin_argument_default_superglobals.inc
--------------------------------------------------------------------------------
FOUND 23 ERROR(S) AND 1 WARNING(S) AFFECTING 13 LINE(S)
--------------------------------------------------------------------------------
 13 | ERROR   | Class name must begin with a capital letter
 13 | ERROR   | Class name must use UpperCamel naming without underscores
 14 | ERROR   | Missing function doc comment
 14 | ERROR   | Method name
    |         | "views_plugin_argument_default_superglobals::option_definition"
    |         | is not in lowerCamel format, it must not contain underscores
 14 | ERROR   | No scope modifier specified for function "option_definition"
 22 | ERROR   | Missing function doc comment
 22 | ERROR   | Method name
    |         | "views_plugin_argument_default_superglobals::options_form" is
    |         | not in lowerCamel format, it must not contain underscores
 22 | ERROR   | No scope modifier specified for function "options_form"
 25 | ERROR   | Inline comments must end in full-stops, exclamation marks, or
    |         | question marks
 47 | WARNING | Avoid backslash escaping in translatable strings when possible,
    |         | use "" quotes instead
 52 | ERROR   | Missing function doc comment
 52 | ERROR   | Method name
    |         | "views_plugin_argument_default_superglobals::get_argument" is
    |         | not in lowerCamel format, it must not contain underscores
 52 | ERROR   | No scope modifier specified for function "get_argument"
 89 | ERROR   | Functions must not contain multiple empty lines in a row; found
    |         | 2 empty lines
 94 | ERROR   | Line indented incorrectly; expected 6 spaces, found 8
 95 | ERROR   | Line indented incorrectly; expected 8 spaces, found 12
 96 | ERROR   | else must start on a new line
 96 | ERROR   | Use "elseif" in place of "else if"
 96 | ERROR   | Line indented incorrectly; expected 6 spaces, found 8
 97 | ERROR   | Line indented incorrectly; expected 8 spaces, found 12
 98 | ERROR   | Line indented incorrectly; expected 6 spaces, found 8
 98 | ERROR   | Line indented incorrectly; expected 6 spaces, found 8
 98 | ERROR   | else must start on a new line
 99 | ERROR   | Line indented incorrectly; expected 8 spaces, found 12
--------------------------------------------------------------------------------


FILE: ...r/www/drupal-7-pareview/pareview_temp/views_superglobals_default.module
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 2 WARNING(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
 17 | WARNING | A comma should follow the last multiline array item. Found: )
 18 | WARNING | A comma should follow the last multiline array item. Found: )
--------------------------------------------------------------------------------

Source: http://ventral.org/pareview - PAReview.sh online service

ryan.armstrong’s picture

Status: Needs work » Needs review

Ok, I fixed most of the errors and warning except the following:

FILE: ...7-pareview/pareview_temp/views_plugin_argument_default_superglobals.inc
--------------------------------------------------------------------------------
FOUND 11 ERROR(S) AFFECTING 4 LINE(S)
--------------------------------------------------------------------------------
13 | ERROR | Class name must begin with a capital letter
13 | ERROR | Class name must use UpperCamel naming without underscores
14 | ERROR | Missing function doc comment
14 | ERROR | Method name
| | "views_plugin_argument_default_superglobals::option_definition"
| | is not in lowerCamel format, it must not contain underscores
14 | ERROR | No scope modifier specified for function "option_definition"
22 | ERROR | Missing function doc comment
22 | ERROR | Method name
| | "views_plugin_argument_default_superglobals::options_form" is not
| | in lowerCamel format, it must not contain underscores
22 | ERROR | No scope modifier specified for function "options_form"
52 | ERROR | Missing function doc comment
52 | ERROR | Method name
| | "views_plugin_argument_default_superglobals::get_argument" is not
| | in lowerCamel format, it must not contain underscores
52 | ERROR | No scope modifier specified for function "get_argument"
--------------------------------------------------------------------------------

The reason being is that I used an core views plugin file (views_plugin_argument_default_raw.inc) as the starting point for my module and those remaining coding standard errors would be found in that views file as well. So I am moving this back to needs review with those errors still in place unless advised to fix them, regardless if they are contained in Views.

ibustos’s picture

ryan.armstrong,

Thank you for your interesting module. With the exception of the handler's method names, all other errors can be fixed, so it is my advise you do so.

ryan.armstrong’s picture

Priority: Normal » Major

Pushed a fix so that the module properly saves configuration. Exporting now works. Also, it's been 2 weeks so I am bumping up the priority to major. Also, in regards to the Coder messages, I am not going to fix the remaining ones. Instead I am going to leave it as the Views module has it to avoid any unexpected side effects.

ryan.armstrong’s picture

Issue summary: View changes

Fixing my git URL to remove my user name.

ryan.armstrong’s picture

Priority: Major » Critical

Bumping this up to critical as it's now been 4 weeks.

kscheirer’s picture

Priority: Critical » Normal
kscheirer’s picture

Status: Needs review » Needs work

The example in your image is incorrect - it says "if you wanted to use $_GET ['variable']['subvariable'], you would enter example" which doesn't look like it would work. That's in your help text in views_plugin_argument_default_superglobals::options_form().

Especially in the cases of _GET and _POST, you want to be running that through some sanitization, check_plain or filter_xss.

Setting to needs work for the security issue, otherwise this would be RTBC from me.

----
Top Shelf Modules - Enterprise modules from the community for the community.

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

I'm a robot and this is an automated message from Project Applications Scraper.

PA robot’s picture

Issue summary: View changes

Updating description. I removed the error message if the variable wasn't found as there may be cases where that isn't an error.

ryan.armstrong’s picture

Issue summary: View changes
Status: Closed (won't fix) » Needs review

Ok, I have updated the help text, as well as passed the $arg through filter_xss for security purposes.

ryan.armstrong’s picture

I also updated the screenshot on the project page.

ryan.armstrong’s picture

Title: Views Superglobals Default » [D7] Views Superglobals Default
Priority: Normal » Critical

Adding D7 to the title and upping this to critical. This has been sitting in the queue for a long time. Need to get this through.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

All feedback has been incorporated into the project. Marking as RTBC.

ryan.armstrong’s picture

@heddn: Thanks!

ryan.armstrong’s picture

Been in RTBC for 2 weeks. I know you guys have a huge backlog but since there have been no objections in 2 weeks, would it be possible to get this approved? Thanks!

heddn’s picture

Issue summary: View changes
heddn’s picture

Status: Reviewed & tested by the community » Fixed

Manual Review

drupal_map_assoc might be useful for these large (duplicate) arrays.

    $superglobal_options = array(
      '$_SERVER' => '$_SERVER',
      '$_GET' => '$_GET',
      '$_POST' => '$_POST',
      '$_FILES' => '$_FILES',
      '$_COOKIE' => '$_COOKIE',
      '$_SESSION' => '$_SESSION',
      '$_REQUEST' => '$_REQUEST',
      '$_ENV' => '$_ENV',
    );

However, that isn't a blocker...

Thanks for your contribution, ryan.armstrong!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

Status: Fixed » Closed (fixed)

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

ryan.armstrong’s picture

@heddm: Thank you! That is really good feedback regarding drupal_map_assoc(), I'll look into that.