While i was working on a view that display the files according to the file schema type(private/public) i notice that it not exists. I wrote a patch that contain the filter criteria by the file schema type.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RoySegall’s picture

Status: Needs work » Needs review
ParisLiakos’s picture

Status: Needs review » Needs work
+++ b/views/views_handler_filter_scehma_type.incundefined
@@ -0,0 +1,42 @@
+      '#title' => t('Scehma type'),
+      '#description' => t('Display files by the scehma type.'),

Typos

RoySegall’s picture

Status: Needs work » Needs review
FileSize
2.28 KB
Devin Carlson’s picture

Status: Needs review » Needs work

#3 looks good but it seems like it is hardcoded to either public or private stream wrappers?

I'd suggest using file_get_stream_wrappers() to enable filtering by other schemes like those provided by projects such as Remote stream wrapper and AmazonS3.

RoySegall’s picture

Not stream wrappers - Schema type. As far as i know, in drupal there is two types of file schema: public and private.

Dave Reid’s picture

The schema type of the file is the stream wrapper used, so Devin is correct this needs to support everything in file_get_stream_wrappers() that also has the 'visible' flag. There should be an file entity API function that can already be used to get the visible stream wrappers.

RoySegall’s picture

Status: Needs work » Needs review
FileSize
2.39 KB
agoradesign’s picture

There's a typo in the filename and also in the class name: views_handler_filter_scehma_type.inc (scehma)

agoradesign’s picture

I've tried out this filter. It basically works, but lacks of some basic configuration options:

There is no operator to choose. At least the possibility to reverse the filter in order to exclude a specific scheme would be nice. Now, if you have a couple of filters and want to exclude only one of them, you would have to insert multiple schema filters for all the remaining schemas in an Views filter group with an OR condition - at least theoratically. Because that didn't work for me and resulted in an empty search result.

I ended up in removing this filter and using a filter on the file's path with the condition set, that the path should not start with "private://" and it worked better for me

RoySegall’s picture

Re rolling and fix typos.

aaron’s picture

Status: Needs review » Needs work

This is a good start. However we need to address the concerns about the operator's in #9. Additionally, it does not work if you expose the filter. Lastly, we need to change the administrative description which currently reads "Filter files by private/public schema." I am not certain offhand what would be better, but an example would be if you are using, for instance, the media youtube module to add a youtube schema. Maybe we can have something like "filter files by their schema, such as private/public." Lastly lastly, I noticed that it allows you to select temporary files and I am not certain if those would be considered visible. And finally (for real), I think it would be better to have checkboxes to allow for multiple selections.

MPetrovic’s picture

This filter wasn't working for us either. Here's a new version that's more flexible.

MPetrovic’s picture

Status: Needs work » Needs review
MPetrovic’s picture

Missed a couple things

Status: Needs review » Needs work

The last submitted patch, filter-by-file-schema-type-1881356-12.patch, failed testing.

jorisdejong’s picture

Hi there,

I have recreated MPetrovic's #14 patch against the latest 7.x-2.x branch. Let's see if it gets passed by testbot.

ParisLiakos’s picture

Status: Needs work » Needs review
RoySegall’s picture

Status: Needs review » Needs work

Minor coding standart:

+++ b/views/views_handler_filter_schema_type.inc
@@ -0,0 +1,44 @@
+      $statements[] = 'uri '.$nope.'LIKE \''.db_like($schema).'://%\'';

=> $statements[] = 'uri ' . $nope . 'LIKE \'' . db_like($schema) . '://%\'';

jorisdejong’s picture

Made this small change in code, including your coding standard fix :)

$not_in = $this->operator == 'not in' ? TRUE : FALSE;
$schema_operator = $not_in ? 'NOT LIKE' : 'LIKE';
$composite = $not_in ? ' AND ' : ' OR ';

foreach ($this->value as $schema) {
  $statements[] = 'uri ' . $schema_operator . ' \'' . db_like($schema) . '://%\'';
}
jorisdejong’s picture

Status: Needs work » Needs review
aaron’s picture

aaron’s picture

Status: Needs review » Reviewed & tested by the community

Works as advertised. Congratulations!

  • Commit 929a939 on 7.x-2.x by aaron:
    Issue #1881356 by jorisdejong, MPetrovic, RoySegall: Views schema type...
aaron’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

PascalAnimateur’s picture

Is the Schema type also exposed as a field, or only as a filter criteria?