Developing New Uber Filter Data Sources

Uber Filter uses a pluggable mechanism for filter data sources. With some PHP and SQL knowledge, new sources can easily be developed.

Data sources map onto Magic Data contexts. So amongst the existing sources, the Page source will be automatically used for Uber Filters associated to an Uber List of Page(s), the User source will be automatically used for Uber Filters associated to an Uber List of User(s), and the File source will be automatically used for Uber Filters associated to an Uber List of File(s).

Currently available data sources are:

Index data for filtering files.
Form Response
Index data for filtering form responses.
Index data for filtering pages.
Index data for filtering users.

Please see the Filter Widget Documentation for details of each of the Uber Filter blocks.

The sources provided with Uber Filter can be found at packages/jl_uber_filter/models/index_data. Have a look through the source and you will see they are all variations of a common pattern.

To incorporate a new source in your own package or as a root level model, the plugin class should be placed at models/uber_filter/index_data/magic_data_context_name.

For example, Magic Data Forms provides a Form Response data source. The file is located at packages/jl_magic_data_forms/models/uber_filter/index_data/form_response and this filter data interface will be automatically used for any Uber Filter widget associated with an Uber List that lists Form Response(s).

All filter data sources must extend the base class UberFilterFilterPluginBase. They also need to provide name, description and help methods that are used for plugin management and automated documentation generation. The name must match the Magic Data context that the plugin is associated with. So again taking Form Respponse as an example, the class is declared:

Loader::Library('uber_filter/filter_plugin_base', 'jl_uber_filter');
class UberFilterIndexDataFormResponse extends UberFilterFilterPluginBase{ public function getName(){ // must be the same as the Magic Data context the filter works with return t('Form Response'); } public function getDescription(){ return t('Index data for filtering form responses.'); } public function getHelp(){ return t('Provides Uber Filter indexing for form data accessed through Magic Data Forms.'); } }

From that point onward, the methods are concerned with listing available columns, listing requested rows of data, providing cleaned and tidied lists and names, or introspection of that information about the data.

For the Page, User and File filter data indexes, This includes crafted SQL to interrogate the relevant databases. For Form Response, it uses the generic form interface layer of Magic Data Forms, which may not be as fast as custom crafted SQL, but is very flexible as it can interface to anything Magic Data Forms has a Form Response plugin for, including files of CSV data.

Last updated: over a year ago