Class BuildFilterBehavior
BuildFilter Class build custom sql statements used in BEAppModel::findObjects() method to filter list of BEdita objects
It can be extended with custom behavior classes to refine query according to your needs
Example:
App::import('Behavior', 'BuildFilter');
ClassNameFilterBehavior extends BuildFilterBehavior {
public function myFilterMethod($data) {
}
}
to call that method you have to build your filter to pass at BEAppModel::findObjects() as
$filter['ClassNameFilter.myFilterMethod'] = $yourData;
$yourData item will be passed to myFilterMethod as first argument
methods of your custom filter class should be return an array that can have the following keys: - "fields" => string of fields to add to query - "fromStart" => string of FROM statement to insert at the begin of the string (LEFT, RIGHT and INNER JOIN statements) - "fromEnd" => string of FROM statement to insert at the end of the string (list of tables and aliases) - "conditions" => array of conditions to add at WHERE statement - "group" => string to add at GROUP statement - "order" => string to add at ORDER statement
- ModelBehavior
- BuildFilterBehavior
Modifiedby: $LastChangedBy$
Lastmodified:
$LastChangedDate$
$Id$
Located at models/behaviors/build_filter.php
Methods summary
public
|
|
public
array
|
#
prepareAfterFilter( array & $filter, string $order )
Prepare and return $afterFilter array built from $filter |
public
|
#
prepareCountPermissionFilter( array & $filter, string $order )
Check |
public
|
#
prepareCountAnnotationFilter( array & $filter, string $order )
Check |
public
|
#
prepareObjectTypeFilter( array & $filter )
Prepare object type filter transforming object type string in object type id |
public
|
|
public
array|boolean
|
|
public
array
|
|
private
|
|
protected
|
|
protected
|
#
object_userFilter( string $s, string $e, mixed $value = null )
filter to get user_id (as obj_userid) joined to an object through object_users table |
protected
|
#
count_annotationFilter( string $s, string $e, mixed $value )
add a count of Annotation objects as Comment, EditoreNote, etc... If 'object_type_id' specified in BuildFilter::filter then get annotations for that object type/s |
protected
|
#
mediatypeFilter( string $s, string $e )
get a category of an object naming it mediatype (used in Multimedia module) |
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
|
protected
|
#
ref_object_detailsFilter( string $s, string $e, string $value )
get the object referenced from an Annotation object as Comment, EditorNote |
protected
|
#
ref_object_typesFilter( string $s, string $e, string $value )
Filter Reference object types (used with ref_object_details filter for Annotations) |
protected
|
#
mail_groupFilter( string $s, string $e, integer $value )
filter the cards joined at a mail group (used in Newsletter module) |
protected
|
#
user_createdFilter( string $s, string $e )
get userid (username) and real name of user that has created the object |
protected
|
#
count_permissionFilter( string $s, string $e, mixed $value )
count objects' permissions as num_of_permission |
protected
|
#
custom_propertyFilter( string $s, string $e, mixed $value )
custom property filter get object_properties fields as ObjectProperty |
protected
|
#
date_itemFilter( string $s, string $e, mixed $value )
date item filter get date_items fields as DateItem |
protected
|
#
count_relationsFilter( string $s, string $e, mixed $value )
count relation filter If 'object_type_id' specified in BuildFilter::filter then get relations for that object type/s |
protected
|
Properties summary
private
string
|
$fields
string of query fields |
#
""
|
private
string
|
$from
sql FROM statement it hasn't to contain the "FROM" string |
#
''
|
private
string
|
$joins
sql JOINS built using CakePHP |
#
''
|
private
array
|
$conditions
sql conditions |
#
array()
|
private
string
|
$group
sql GROUP statement it hasn't to contain the "GROUP" string |
#
""
|
private
string
|
$order
sql ORDER BY statement it hasn't to contain the "ORDER BY" string |
#
""
|
protected
array
|
$filter
filter parameters used to build the sql statements |
#
array()
|
protected
string
|
$startQuote
sql start quote |
#
""
|
protected
string
|
$endQuote
sql end quote |
#
""
|
protected
|
$model
model |
#
""
|
private
string
|
$driver
sql driver |
#
""
|
private
array
|
$map
translate some filter shortcut to extended version |
#
array(
'relation' => 'ObjectRelation.switch',
'rel_object_id' => 'ObjectRelation.object_id',
'comment_object_id' => 'Comment.object_id'
)
|
private
|
$dataSource
|
#
null
|
private
boolean
|
$useGroupBy
Force BEAppModel::findObjects() to use 'GROUP BY' clausole its value is returned in self::getSqlItems() |
#
false
|