diff --git a/file_entity.info b/file_entity.info index a230176..250a3dd 100644 --- a/file_entity.info +++ b/file_entity.info @@ -12,6 +12,7 @@ files[] = views/views_handler_filter_file_type.inc files[] = views/views_handler_field_file_link.inc files[] = views/views_handler_field_file_link_edit.inc files[] = views/views_handler_field_file_link_delete.inc +files[] = views/views_handler_filter_scehma_type.inc files[] = views/views_plugin_row_file_view.inc files[] = tests/file_entity.test configure = admin/structure/file-types diff --git a/file_entity.views.inc b/file_entity.views.inc index d60d9fb..d3ba5bd 100644 --- a/file_entity.views.inc +++ b/file_entity.views.inc @@ -83,6 +83,15 @@ function file_entity_views_data() { ), ); + // File schema type. + $data['file_managed']['schema_type'] = array( + 'title' => t('Schema type'), + 'help' => t('Filter files by private/public schema.'), + 'filter' => array( + 'handler' => 'views_handler_filter_scehma_type', + ), + ); + return $data; } diff --git a/views/views_handler_filter_scehma_type.inc b/views/views_handler_filter_scehma_type.inc new file mode 100644 index 0000000..ca2e2c9 --- /dev/null +++ b/views/views_handler_filter_scehma_type.inc @@ -0,0 +1,46 @@ + 'private'); + return $options; + } + + /** + * Define the file schema type. + */ + public function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + + // Collect the available schema types. + $options = array(); + foreach (file_get_stream_wrappers() as $type => $info) { + $options[$type] = $info['name']; + } + + $form['schema_type'] = array( + '#type' => 'select', + '#title' => t('Schema type'), + '#description' => t('Display files by the Schema type.'), + '#default_value' => $this->options['schema_type'], + '#options' => $options, + ); + } + + /** + * Add to the query conditions the file schema type. + */ + function query($group_by = FALSE) { + $this->query->add_where($group_by, 'uri', $this->options['schema_type'] . "://%", 'LIKE'); + } +}