PHP Class PageFinder, ProcessWire

Inheritance: extends Wire
Mostrar archivo Open project: ryancramerdesign/ProcessWire Class Usage Examples

Protected Properties

Property Type Description
$checkAccess
$defaultOptions Options (and their defaults) that may be provided as the 2nd argument to find()
$extraOrSelectors
$extraSubSelectors one from each field must match
$fieldgroups
$getQueryNumChildren
$getTotal
$getTotalType whether to find the total number of matches
$lastOptions number of times the function has been called
$limit
$parent_id
$start
$templates_id
$total May be: 'calc', 'count', or blank to auto-detect.

Public Methods

Method Description
___find ( Selectors $selectors, array $options = [] ) : array Return all pages matching the given selector.
__construct ( ) Construct the PageFinder
findIDs ( Selectors $selectors, array $options = [] ) : array Same as find() but returns just a simple array of page IDs without any other info
getLimit ( ) Returns the limit placed upon the last find() operation, or 0 if no limit was specified
getOptions ( ) Return array of the options provided to PageFinder, as well as those determined at runtime
getParentID ( ) Returns the parent ID, if it was part of the selector
getStart ( ) Returns the start placed upon the last find() operation
getTemplatesID ( ) Returns the templates ID, if it was part of the selector
getTotal ( ) : integer Returns the total number of results returned from the last find() operation

Protected Methods

Method Description
___getQuery ( array $selectors, array $options ) : DatabaseQuerySelect Given one or more selectors, create the SQL query for finding pages.
___getQueryAllowedTemplatesWhere ( DatabaseQuerySelect $query, string $where ) : string Method that allows external hooks to add to or modify the access control WHERE conditions
___getQueryJoinPath ( DatabaseQuerySelect $query, $selector ) Special case when requested value is path or URL
arrangeFields ( array $fields ) Arrange the order of field names where necessary
getQueryAllowedTemplates ( DatabaseQuerySelect $query, $options ) Determine which templates the user is allowed to view
getQueryHasParent ( DatabaseQuerySelect $query, $selector ) Make the query specific to all pages below a certain parent (children, grandchildren, great grandchildren, etc.)
getQueryNativeField ( DatabaseQuerySelect $query, Selector $selector, array $fields ) Special case when field is native to the pages table
getQueryNumChildren ( DatabaseQuerySelect $query, $selector ) Match a number of children count
getQuerySortSelector ( DatabaseQuerySelect $query, Selector $selector )
getQueryStartLimit ( DatabaseQuerySelect $query, $selectors )
postProcessQuery ( $parentQuery )
preProcessSelector ( Selector $selector ) : boolean Pre-process the given selector to perform any necessary replacements
setupStatusChecks ( Selectors $selectors, array &$options ) Pre-process the selectors to add Page status checks
whereEmptyValuePossible ( Field $field, $selector, $query, string $value, string &$where ) : boolean Generate SQL and modify $query for situations where it should be possible to match empty values

Method Details

___find() public method

Return all pages matching the given selector.
public ___find ( Selectors $selectors, array $options = [] ) : array
$selectors Selectors
$options array
return array

___getQuery() protected method

Given one or more selectors, create the SQL query for finding pages.
protected ___getQuery ( array $selectors, array $options ) : DatabaseQuerySelect
$selectors array Array of selectors.
$options array
return DatabaseQuerySelect

___getQueryAllowedTemplatesWhere() protected method

Called only if it's hooked. To utilize it, modify the $where argument in a BEFORE hook or the $event->return in an AFTER hook.
protected ___getQueryAllowedTemplatesWhere ( DatabaseQuerySelect $query, string $where ) : string
$query DatabaseQuerySelect
$where string SQL string for WHERE statement, not including the actual "WHERE"
return string

___getQueryJoinPath() protected method

Special case when requested value is path or URL
protected ___getQueryJoinPath ( DatabaseQuerySelect $query, $selector )
$query DatabaseQuerySelect

__construct() public method

Construct the PageFinder
public __construct ( )

arrangeFields() protected method

Arrange the order of field names where necessary
protected arrangeFields ( array $fields )
$fields array

findIDs() public method

Same as find() but returns just a simple array of page IDs without any other info
public findIDs ( Selectors $selectors, array $options = [] ) : array
$selectors Selectors
$options array
return array of page IDs

getLimit() public method

Returns the limit placed upon the last find() operation, or 0 if no limit was specified
public getLimit ( )

getOptions() public method

Return array of the options provided to PageFinder, as well as those determined at runtime
public getOptions ( )

getParentID() public method

Returns the parent ID, if it was part of the selector
public getParentID ( )

getQueryAllowedTemplates() protected method

Determine which templates the user is allowed to view
protected getQueryAllowedTemplates ( DatabaseQuerySelect $query, $options )
$query DatabaseQuerySelect

getQueryHasParent() protected method

Make the query specific to all pages below a certain parent (children, grandchildren, great grandchildren, etc.)
protected getQueryHasParent ( DatabaseQuerySelect $query, $selector )
$query DatabaseQuerySelect

getQueryNativeField() protected method

TODO not all operators will work here, so may want to add some translation or filtering
protected getQueryNativeField ( DatabaseQuerySelect $query, Selector $selector, array $fields )
$query DatabaseQuerySelect
$selector Selector
$fields array

getQueryNumChildren() protected method

Match a number of children count
protected getQueryNumChildren ( DatabaseQuerySelect $query, $selector )
$query DatabaseQuerySelect

getQuerySortSelector() protected method

protected getQuerySortSelector ( DatabaseQuerySelect $query, Selector $selector )
$query DatabaseQuerySelect
$selector Selector

getQueryStartLimit() protected method

protected getQueryStartLimit ( DatabaseQuerySelect $query, $selectors )
$query DatabaseQuerySelect

getStart() public method

Returns the start placed upon the last find() operation
public getStart ( )

getTemplatesID() public method

Returns the templates ID, if it was part of the selector
public getTemplatesID ( )

getTotal() public method

If the last find() included limit, then this returns the total without the limit
public getTotal ( ) : integer
return integer

postProcessQuery() protected method

protected postProcessQuery ( $parentQuery )

preProcessSelector() protected method

This is primarily used to handle sub-selections, i.e. "bar=foo, id=[this=that, foo=bar]"
protected preProcessSelector ( Selector $selector ) : boolean
$selector Selector
return boolean Returns false if selector should be skipped over by getQuery()

setupStatusChecks() protected method

Pre-process the selectors to add Page status checks
protected setupStatusChecks ( Selectors $selectors, array &$options )
$selectors Selectors
$options array

whereEmptyValuePossible() protected method

This can include equals/not-equals with blank or 0, as well as greater/less-than searches that can potentially match blank or 0.
protected whereEmptyValuePossible ( Field $field, $selector, $query, string $value, string &$where ) : boolean
$field Field
$selector
$query
$value string The value presumed to be blank (passed the empty() test)
$where string SQL where string that will be modified/appended
return boolean Whether or not the query was handled and modified

Property Details

$checkAccess protected_oe property

protected $checkAccess

$defaultOptions protected_oe property

Options (and their defaults) that may be provided as the 2nd argument to find()
protected $defaultOptions

$extraOrSelectors protected_oe property

protected $extraOrSelectors

$extraSubSelectors protected_oe property

one from each field must match
protected $extraSubSelectors

$fieldgroups protected_oe property

protected $fieldgroups

$getQueryNumChildren protected_oe property

protected $getQueryNumChildren

$getTotal protected_oe property

protected $getTotal

$getTotalType protected_oe property

whether to find the total number of matches
protected $getTotalType

$lastOptions protected_oe property

number of times the function has been called
protected $lastOptions

$limit protected_oe property

protected $limit

$parent_id protected_oe property

protected $parent_id

$start protected_oe property

protected $start

$templates_id protected_oe property

protected $templates_id

$total protected_oe property

May be: 'calc', 'count', or blank to auto-detect.
protected $total