- Symphony 2.7.10
-
› assets
14 -
› boot
15 -
› core
24 -
› cryptography
4 -
› data-sources
6 -
› email-gateways
3 -
› events
3 -
› global
62 -
› interface
9 -
› toolkit
60 - Delegates101
- Deprecated28
Versions
- 2.7.9
- 2.7.8
- 2.7.7
- 2.7.6
- 2.7.5
- 2.7.3
- 2.7.2
- 2.7.10
- 2.7.1
- 2.7.0
- 2.6.9
- 2.6.8
- 2.6.7
- 2.6.6
- 2.6.5
- 2.6.4
- 2.6.3
- 2.6.2
- 2.6.11
- 2.6.10
- 2.6.1
- 2.6.0
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4
- 2.3.6
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2
Options
public class Datasource
class.datasource.php #21The Datasource class provides functionality to mainly process any parameters
that the fields will use in filters find the relevant Entries and return these Entries
data as XML so that XSLT can be applied on it to create your website. In Symphony,
there are four Datasource types provided, Section, Author, Navigation and Dynamic
XML. Section is the mostly commonly used Datasource, which allows the filtering
and searching for Entries in a Section to be returned as XML. Navigation datasources
expose the Symphony Navigation structure of the Pages in the installation. Authors
expose the Symphony Authors that are registered as users of the backend. Finally,
the Dynamic XML datasource allows XML pages to be retrieved. This is especially
helpful for working with Restful XML API's. Datasources are saved through the
Symphony backend, which uses a Datasource template defined in
TEMPLATE . /datasource.tpl
.
Constants
static integer FILTER_AND = 1
A constant that represents if this filter is an AND filter in which
an Entry must match all these filters. This filter is triggered when
the filter string contains a +
.
static integer FILTER_OR = 2
A constant that represents if this filter is an OR filter in which an entry can match any or all of these filters
Methods
void __construct(
$env, $process_params)
Constructor for the datasource sets the parent, if $process_params
is set,
the $env
variable will be run through Datasource::processParameters
.
Parameters
See Also
integer __determineFilterType(
$value)
By default, all Symphony filters are considering to be OR and "+" filters are used for AND. They are all used and Entries must match each filter to be included. It is possible to use OR filtering in a field by using an "," to separate the values. eg. If the filter is "test1, test2", this will match any entries where this field is test1 OR test2. If the filter is "test1 + test2", this will match entries where this field is test1 AND test2. Not all fields supports this feature. This function is run on each filter (ie. each field) in a datasource.
Parameters
Returns
Datasource::FILTEROR or Datasource::FILTERAND
Deprecated
Since Symphony 2.6.0 it is recommended to use the static version, Datasource::determineFilterType
XMLElement __negateResult()
Returns an error XMLElement with 'Result Negated' text
XMLElement __noRecordsFound()
Returns an error XMLElement with 'No records found' text
string __processParametersInString(
$value, $env, $includeParenthesis, $escape)
This function will replace any parameters in a string with their value.
Parameters are defined by being prefixed by a $
character. In certain
situations, the parameter will be surrounded by {}
, which Symphony
takes to mean, evaluate this parameter to a value, other times it will be
omitted which is usually used to indicate that this parameter exists
Parameters
Returns
The string with all parameters evaluated. If a parameter is not found, it will not be replaced and remain in the $value
.
array about()
Returns an associative array of information about a datasource.
boolean allowEditorToParse()
This function is required in order to edit it in the datasource editor page.
Do not overload this function if you are creating a custom datasource. It is only
used by the datasource editor. If this is set to false, which is default, the
Datasource's about()
information will be displayed.
Returns
true if the Datasource can be edited, false otherwise. Defaults to false
static integer determineFilterType(
$value)
By default, all Symphony filters are considering to be OR and " + " filters are used for AND. They are all used and Entries must match each filter to be included. It is possible to use OR filtering in a field by using an ", " to separate the values.
If the filter is "test1, test2", this will match any entries where this field is test1 OR test2. If the filter is "test1 + test2", this will match entries where this field is test1 AND test2. The spaces around the + are required.
Not all fields supports this feature.
This function is run on each filter (ie. each field) in a datasource.
Parameters
Returns
Datasource::FILTEROR or Datasource::FILTERAND
XMLElement emptyXMLSet(XMLElement $xml)
If there is no results to return this function calls Datasource::__noRecordsFound
which appends an XMLElement to the current root element.
Parameters
static string escapeCommas(
$string)
Using regexp, this escapes any commas in the given string
Parameters
XMLElement execute(
$param_pool)
The meat of the Datasource, this function includes the datasource type's file that will preform the logic to return the data for this datasource It is passed the current parameters.
Parameters
Returns
The XMLElement to add into the XML for a page.
static mixed findParameterInEnv(
$needle, $env)
Parameters can exist in three different facets of Symphony; in the URL, in the parameter pool or as an Symphony param. This function will attempt to find a parameter in those three areas and return the value. If it is not found null is returned
Parameters
Returns
If the value is not found, null, otherwise a string or an array is returned
array getDependencies()
Accessor function to return this Datasource's dependencies
mixed getSource()
This function is required in order to identify what section this Datasource is for. It is used in the datasource editor. It must remain intact. Do not overload this function in custom events. Other datasources may return a string here defining their datasource type when they do not query a section.
void grab(
$param_pool)
See Also
Deprecated
This function has been renamed to execute
as of Symphony 2.3.1, please use execute()
instead. This function will be removed in Symphony 3.0
XMLElement negateXMLSet(XMLElement $xml)
If the datasource has been negated this function calls Datasource::__negateResult
which appends an XMLElement to the current root element.
Parameters
string parseParamURL(
$url)
This function will parse a string (usually a URL) and fully evaluate any parameters (defined by {$param}) to return the absolute string value.
Parameters
Returns
The parsed URL
void processParameters(
$env)
This function will iterates over the filters and replace any parameters with their actual values. All other Datasource variables such as sorting, ordering and pagination variables are also set by this function
Parameters
static string removeEscapedCommas(
$string)
Used in conjunction with escapeCommas, this function will remove the escaping pattern applied to the string (and commas)
Parameters
static array splitFilter(
$filter_type, $value)
Splits the filter string value into an array.
Parameters
Returns
The splitted filter value, according to its type