WiseLoop PHP Web Media Grabber 3.1.1
Advanced PHP web resources extractor
wlWmgFilter Class Reference

Public Member Functions

 __construct ($values, $type=self::TYPE_SEARCH, $operator=self::OPERATOR_EQUALS, $action=self::ACTION_INCLUDE)
 getAction ()
 getType ()
 getOperator ()
 getValues ()
 getValuesAsString ()
 getWhen ()

Static Public Member Functions

static doTest ($operator, $operand, $values)
static getOperators ($numericOnly=false)
static getTypes ()

Data Fields

const BEFORE_URL_VALIDATION = 'before'
const AFTER_URL_VALIDATION = 'after'
const ACTION_INCLUDE = true
const ACTION_EXCLUDE = false
const TYPE_SEARCH = 'search'
const TYPE_TAG_NAME = 'tag-name'
const TYPE_TAG_CONTENT = 'tag-content'
const TYPE_URL = 'url'
const TYPE_CONTENT_LENGTH = 'content-length'
const TYPE_CONTENT_TYPE = 'content-type'
const OPERATOR_EQUALS = '='
const OPERATOR_CONTAINS = '-%-'
const OPERATOR_ENDSWITH = '-%'
const OPERATOR_STARTSWITH = '%-'
const OPERATOR_GREATERTHAN = '>'
const OPERATOR_SMALLERTHAN = '<'

Private Attributes

 $_action
 $_type
 $_operator
 $_values

Detailed Description

WiseLoop Web Media Grabber Filter class definition
This class provides a nice mechanism to filter grabbed media results.
Using filter objects, you can grab only certain type of media (ex. images of a certain width or height, videos of certain size, various files having a certain extension etc.)
A common filter consists of:

  • filter time: specifies if the filter will be applied before or after the media checking procedure (ie. testing if media exists, retrieving its headers, retrieving its size etc.);
  • an action: specifies if the media should be included or excluded from the grabbed results if the filter condition is meet
  • an operator: specifies the operator used in comparison (equals, contains, endswith, startswith, greaterthan, smallerthan)
  • a set of values (operands): an array or a string of values separated by "|" that specifies which values are used in comparison to evaluate the filter condition
  • a type: specifies what media information will be used in comparison; there are some standard values for this, but custom grabbers can implement another values of their own
    The common standard values for the filter type are:
  • SEARCH: the set of values will hold some strings used to search the HTML DOM structure, in order to extract the full tags that envelopes the desired media to be grabbed;
  • TAG_NAME: used to filter the media that is enveloped by the specified tag names stored in the set of values;
  • TAG_CONTENT: used to filter the media that is enveloped by the specified tag contents stored in the set of values;
  • URL: every grabbed media will have an url; this filter type is used to filter by media url;
  • CONTENT_LENGTH: used to filter by the media size;
  • CONTENT_TYPE: used to filter by the HTML content type response header;
    Author:
    WiseLoop

Constructor & Destructor Documentation

__construct ( values,
type = self::TYPE_SEARCH,
operator = self::OPERATOR_EQUALS,
action = self::ACTION_INCLUDE 
)

Constructor.
Creates a wlWmgFilter object.

Parameters:
string | array$valuesthe values used in comparison to evaluate the filter condition; if string, the values must be "|" separated
string$typethe filter type
string$operatorthe filter operator
bool$actionthe filter action
See also:
ACTION_INCLUDE, ACTION_EXCLUDE
TYPE_TAG_NAME, TYPE_TAG_CONTENT, TYPE_SEARCH, TYPE_URL, TYPE_CONTENT_LENGTH, TYPE_CONTENT_TYPE
OPERATOR_EQUALS, OPERATOR_CONTAINS, OPERATOR_STARTSWITH, OPERATOR_ENDSWITH, OPERATOR_GREATERTHAN, OPERATOR_SMALLERTHAN
Returns:
wlWmgFilter

Member Function Documentation

static doTest ( operator,
operand,
values 
) [static]

Evaluates a filter condition.

Parameters:
string$operatorthe operator
mixed$operandthe operand
array$valuesthe values
Returns:
bool if condition is meet
getAction ( )

Returns the filter action.

Returns:
bool
See also:
ACTION_INCLUDE, ACTION_EXCLUDE
getOperator ( )
static getOperators ( numericOnly = false) [static]

Returns a nice formatted array containing the available operators.

Parameters:
bool$numericOnly
Returns:
array
getType ( )

Returns the filter type.

Returns:
string
See also:
TYPE_TAG_NAME, TYPE_TAG_CONTENT, TYPE_SEARCH, TYPE_URL, TYPE_CONTENT_LENGTH, TYPE_CONTENT_TYPE
static getTypes ( ) [static]

Returns the list of valid filter types.

Returns:
array
getValues ( )

Returns the set of values used in filter condition evaluation.

Returns:
array
getValuesAsString ( )

Returns the set of values used in filter condition evaluation.

Returns:
string
getWhen ( )

Returns the filter time.

Returns:
string
See also:
BEFORE_URL_VALIDATION, AFTER_URL_VALIDATION

Field Documentation

$_action [private]

Type: bool specifies if the media should be included or excluded from the grabbed results if the filter condition is meet

See also:
ACTION_INCLUDE, ACTION_EXCLUDE
$_operator [private]

Type: string specifies the operator used in comparison

See also:
OPERATOR_EQUALS, OPERATOR_CONTAINS, OPERATOR_STARTSWITH, OPERATOR_ENDSWITH, OPERATOR_GREATERTHAN, OPERATOR_SMALLERTHAN
$_type [private]

Type: string specifies what media information will be used in comparison

See also:
TYPE_TAG_NAME, TYPE_TAG_CONTENT, TYPE_SEARCH, TYPE_URL, TYPE_CONTENT_LENGTH, TYPE_CONTENT_TYPE
$_values [private]

Type: array an array or a string of values separated by "|" that specifies which values are used in comparison to evaluate the filter condition

const ACTION_EXCLUDE = false

Filter action: exclude

const ACTION_INCLUDE = true

Filter action: include

const AFTER_URL_VALIDATION = 'after'

Filter time: after media checking

const BEFORE_URL_VALIDATION = 'before'

Filter time: before media checking

const OPERATOR_CONTAINS = '-%-'

Filter operator: contains - filter condition is meet if at least one value from the set of values is contained in within the information specified by the filter type

const OPERATOR_ENDSWITH = '-%'

Filter operator: ends with - filter condition is meet if the information specified by the filter type ends with at least one value from the set of values

const OPERATOR_EQUALS = '='

Filter operator: equals - filter condition is meet if at least one value from the set of values is equal with the information specified by the filter type

const OPERATOR_GREATERTHAN = '>'

Filter operator: ends with - filter condition is meet if the information specified by the filter type is greater than at least one value from the set of values

const OPERATOR_SMALLERTHAN = '<'

Filter operator: ends with - filter condition is meet if the information specified by the filter type is smaller than at least one value from the set of values

const OPERATOR_STARTSWITH = '%-'

Filter operator: ends with - filter condition is meet if the information specified by the filter type starts with at least one value from the set of values

const TYPE_CONTENT_LENGTH = 'content-length'

Filter type: content-length - used to filter by the media size

const TYPE_CONTENT_TYPE = 'content-type'

Filter type: content-type - used to filter by the HTML content type response header

const TYPE_SEARCH = 'search'

Filter type: search - the set of values will hold some strings used to search the HTML DOM structure, in order to extract the full tags that envelopes the desired media to be grabbed

const TYPE_TAG_CONTENT = 'tag-content'

Filter type: tag content - used to filter the media that is enveloped by the specified tag contents stored in the set of values

const TYPE_TAG_NAME = 'tag-name'

Filter type: tag name - used to filter the media that is enveloped by the specified tag names stored in the set of values

const TYPE_URL = 'url'

Filter type: url - every grabbed media will have an url; this filter type is used to filter by media url


The documentation for this class was generated from the following file:
 All Data Structures Functions Variables