contenido\classes\class.properties.php
Description: Custom properties
Requirements:
- Author
- Timo A. Hummel
- Con_php_req
- 5.0
- Copyright
- four for business AG
- License
- http://www.contenido.org/license/LIZENZ.txt
- Link
- http://www.4fb.de
- Link
- http://www.contenido.org
- Package
- Contenido Backend classes
- Since
- file available since contenido release <= 4.6 {@internal created 2003-12-21 modified 2008-06-30, Dominik Ziegler, add security fix modified 2009-09-27, Dominik Ziegler, fixed wrong (un)escaping $Id: class.properties.php 1058 2009-09-28 12:19:15Z dominik.ziegler $: }}
- Version
- 1.1.6
\PropertyCollection
- Parent(s)
- \ItemCollection
- Author
- Timo A. Hummel
- Copyright
- four for business 2003
- Version
- 0.1
Properties

array $_forwardJoinPartnersForward join partners for this data object
- Type
- array
- Access
- private
- Inherited_from
- \ItemCollection::$$_forwardJoinPartners

array $_groupConditions- Type
- array
- Access
- private
- Inherited_from
- \ItemCollection::$$_groupConditions

array $_innerGroupConditions = array()array()Details- Type
- array
- Access
- private
- Inherited_from
- \ItemCollection::$$_innerGroupConditions

array $_resultFields = array()array()Details- Type
- array
- Access
- private
- Inherited_from
- \ItemCollection::$$_resultFields

array $_whereRestriction- Type
- array
- Access
- private
- Inherited_from
- \ItemCollection::$$_whereRestriction

string $table- Type
- string
- Access
- private
- Inherited_from
- \ItemCollection::$$table
Methods

ItemCollection(string $table, $primaryKey, $lifetime = 10) : voidConstructor Function Note: Default lifetime is 10 seconds.
Inherited from: \ItemCollection::ItemCollection()| Name | Type | Description |
|---|---|---|
| $table | string | The table to use as information source |
| $primaryKey | ||
| $lifetime |

_buildGroupWhereStatements() : arrayBuilds a where statement out of the setGroupWhere calls
| Type | Description |
|---|---|
| array | with all where statements |

_buildWhereStatements() : arrayBuilds a where statement out of the setWhere calls
| Type | Description |
|---|---|
| array | with all where statements |

_fetchJoinTables(\none $ignore_root) : arrayFetches all tables which will be joined later on.
The returned array has the following format:
array( array(fields), array(tables), array(joins), array(wheres) );
Notes: The table is the table name which needs to be added to the FROM clause The join statement which is inserted after the master table The where statement is combined with all other where statements The fields to select from
| Name | Type | Description |
|---|---|---|
| $ignore_root | \none |
| Type | Description |
|---|---|
| array | see above |

_findReverseJoinPartner( $parentclass, $classname) : void| Name | Type | Description |
|---|---|---|
| $parentclass | ||
| $classname |

_initializeDriver( $bForceInit = false) : void_initializeDriver: Initializes the driver to use with GenericDB.
Inherited from: \ItemCollection::_initializeDriver()| Name | Type | Description |
|---|---|---|
| $bForceInit | boolean If true, forces the driver to initialize, even if it already exists. |

_recursiveStructuredFetch( $objects, $array) : void| Name | Type | Description |
|---|---|---|
| $objects | ||
| $array |

_setItemClass(string $classname) : \none_setItemClass: private method to set the accompanying item object.
Inherited from: \ItemCollection::_setItemClass()| Name | Type | Description |
|---|---|---|
| $classname | string | specifies the classname |
| Type | Description |
|---|---|
| \none |

_setJoinPartner(string $foreignCollectionClass) : \none_setJoinPartner: Defines the reverse links for this table.
Inherited from: \ItemCollection::_setJoinPartner()Important: The class specified by $foreignCollectionClass needs to be a collection class and has to exist Define all links in the constructor of your object
| Name | Type | Description |
|---|---|---|
| $foreignCollectionClass | string | Specifies the foreign class to use |
| Type | Description |
|---|---|
| \none |

addResultField( $field) : void| Name | Type | Description |
|---|---|---|
| $field |

create( $itemtype, $itemid, $type, $name, $value, $bInternally = false) : voidcreate() Creates a new item in the table and loads it afterwards.
| Name | Type | Description |
|---|---|---|
| $itemtype | ||
| $itemid | ||
| $type | ||
| $name | ||
| $value | ||
| $bInternally |

deleteProperties(\itemtype $itemtype, \itemid $itemid) : voidDelete all properties which match itemtype and itemid
| Name | Type | Description |
|---|---|---|
| $itemtype | \itemtype | mixed Type of the item (example: idcat) |
| $itemid | \itemid | mixed ID of the item (example: 31) |

deleteValue(\itemtype $itemtype, \itemid $itemid, \type $type, \name $name) : voidDelete a property item.
Example:
$properties->deleteValue("idcat", 27, "visual", "image");
| Name | Type | Description |
|---|---|---|
| $itemtype | \itemtype | mixed Type of the item (example: idcat) |
| $itemid | \itemid | mixed ID of the item (example: 31) |
| $type | \type | mixed Type of the data to store (arbitary data) |
| $name | \name | mixed Entry name |

deleteWhere( $field, $restriction, $operator = "=") : voiddeleteWhere ($field, $restriction, $operator)
Inherited from: \ItemCollection::deleteWhere()Restricts a query with a where clause
| Name | Type | Description |
|---|---|---|
| $field | ||
| $restriction | ||
| $operator |

deleteWhereGroup( $group, $field, $restriction, $operator = "=") : voiddeleteWhereGroup ($group, $field, $restriction, $operator)
Inherited from: \ItemCollection::deleteWhereGroup()Restricts a query with a where clause, groupable
| Name | Type | Description |
|---|---|---|
| $group | ||
| $field | ||
| $restriction | ||
| $operator |

exists(integer $id) : boolean| Name | Type | Description |
|---|---|---|
| $id | integer | The id to check for |
| Type | Description |
|---|---|
| boolean | true if object exists, false if not |

fetchArray( $key, $fields) : arrayfetchArray() Fetches an array of fields from the database.
Inherited from: \ItemCollection::fetchArray()Example: $i = $object->fetchArray("idartlang", array("idlang", "name"));
could result in: $i[5] = array("idlang" => 5, "name" => "My Article");
Important: If you don't pass an array for fields, the function doesn't create an array.
| Name | Type | Description |
|---|---|---|
| $key | string Name of the field to use for the key | |
| $fields | mixed String or array |
| Type | Description |
|---|---|
| array | Resulting array |

fetchObject( $class) : void| Name | Type | Description |
|---|---|---|
| $class |

fetchTable( $fields = array(), $objects = array()) : void| Name | Type | Description |
|---|---|---|
| $fields | ||
| $objects |

flexSelect(string $distinct = "", string $from = "", string $where = "", string $group_by = "", string $order_by = "", string $limit = "") : arrayflexSelect ($distinct = "", $from = "", $where = "", $group_by = "", $order_by = "", $limit = "") Selects all entries from the database and returns them as DBObject-objects to the user.
Inherited from: \ItemCollection::flexSelect()Objects are loaded using their primary key.
| Name | Type | Description |
|---|---|---|
| $distinct | string | Specifies if distinct will be added to the SQL statement ($distinct !== "" -> DISTINCT) |
| $from | string | Specifies the additional from clause (e.g. "con_news_groups AS groups, con_news_groupmembers AS groupmembers"). |
| $where | string | Specifies the where clause. |
| $group_by | string | Specifies the group by clause. |
| $order_by | string | Specifies the order by clause. |
| $limit | string | Specifies the limit by clause. |
| Type | Description |
|---|---|
| array | Array of DBObject-Objects |
- Author
- HerrB

getAllValues( $field, $fieldValue, $auth = NULL) : arrayReturns all datasets selected by given field and value combination
| Name | Type | Description |
|---|---|---|
| $field | Field to search in | |
| $fieldValue | Value to search for | |
| $auth | Narrow result down to user in auth objext |
| Type | Description |
|---|---|
| array | for each given item |

getProperties(\itemtype $itemtype, \itemid $itemid) : arrayChecks if values for a given item are available.
| Name | Type | Description |
|---|---|---|
| $itemtype | \itemtype | mixed Type of the item (example: idcat) |
| $itemid | \itemid | mixed ID of the item (example: 31) |
| Type | Description |
|---|---|
| array | for each given item |

getValue(\itemtype $itemtype, \itemid $itemid, \type $type, \name $name, $default = false) : mixedReturns the value for a given item.
Example:
$file = $properties->getValue("idcat", 27, "visual", "image");
| Name | Type | Description |
|---|---|---|
| $itemtype | \itemtype | mixed Type of the item (example: idcat) |
| $itemid | \itemid | mixed ID of the item (example: 31) |
| $type | \type | mixed Type of the data to store (arbitary data) |
| $name | \name | mixed Entry name |
| $default |
| Type | Description |
|---|---|
| mixed | Value |

getValuesByType(\itemtype $itemtype, \itemid $itemid, \type $type) : arrayReturns the value for a given item.
Example:
$file = $properties->getValuesByType("idcat", 27, "visual");
| Name | Type | Description |
|---|---|---|
| $itemtype | \itemtype | mixed Type of the item (example: idcat) |
| $itemid | \itemid | mixed ID of the item (example: 31) |
| $type | \type | mixed Type of the data to store (arbitary data) |
| Type | Description |
|---|---|
| array | Value |

link( $foreignClass) : voidsets the query to use foreign tables in the resultset
Inherited from: \ItemCollection::link()| Name | Type | Description |
|---|---|---|
| $foreignClass |

loadItem( $vitem) : objectloadItem ($item) Loads a single object from the database.
Inherited from: \ItemCollection::loadItem()Needs to be overridden by the extension class.
| Name | Type | Description |
|---|---|---|
| $vitem |
| Type | Description |
|---|---|
| object | The newly created object |

queryAndFetchStructured(\objects $objects) : arrayfetchStructured Returns an array of arrays
Inherited from: \ItemCollection::queryAndFetchStructured()| Name | Type | Description |
|---|---|---|
| $objects | \objects | array with the correct order of the objects |
| Type | Description |
|---|---|
| array | result |

removeResultField( $field) : void| Name | Type | Description |
|---|---|---|
| $field |

select(string $where = "", string $group_by = "", string $order_by = "", string $limit = "") : arrayselect ($where = "", $group_by = "", $order_by = "", $limit = "") Selects all entries from the database and returns them as DBObject-objects to the user.
Inherited from: \ItemCollection::select()Objects are loaded using their primary key.
| Name | Type | Description |
|---|---|---|
| $where | string | Specifies the where clause. |
| $group_by | string | Specifies the group by clause. |
| $order_by | string | Specifies the order by clause. |
| $limit | string | Specifies the limit by clause. |
| Type | Description |
|---|---|
| array | Array of DBObject-Objects |

setEncoding( $sEncoding) : void| Name | Type | Description |
|---|---|---|
| $sEncoding |

setGroupCondition( $group1, $group2, $condition = "AND") : voidsetGroupCondition ($group1, $group2, $condition)
Inherited from: \ItemCollection::setGroupCondition()Defines how groups are linked to each other
| Name | Type | Description |
|---|---|---|
| $group1 | ||
| $group2 | ||
| $condition |

setInnerGroupCondition( $group, $condition = "AND") : voidsetInnerGroupCondition ($group, $condition)
Inherited from: \ItemCollection::setInnerGroupCondition()Defines how relations in one group are linked each together
| Name | Type | Description |
|---|---|---|
| $group | ||
| $condition |

setLimit( $iRowStart, $iRowCount) : void| Name | Type | Description |
|---|---|---|
| $iRowStart | ||
| $iRowCount |

setOrder( $order) : void| Name | Type | Description |
|---|---|---|
| $order |

setValue(\itemtype $itemtype, \itemid $itemid, \type $type, \name $name, \value $value, \idProp $idProp = 0) : voidSets a property item.
Handles creation and updating.
Example:
$properties->setValue("idcat", 27, "visual", "image", "images/tool.gif");
| Name | Type | Description |
|---|---|---|
| $itemtype | \itemtype | mixed Type of the item (example: idcat) |
| $itemid | \itemid | mixed ID of the item (example: 31) |
| $type | \type | mixed Type of the data to store (arbitary data) |
| $name | \name | mixed Entry name |
| $value | \value | mixed Value |
| $idProp | \idProp | int id of database record (if set, update on this basis (possiblity to update name value and type)) |

setWhere( $field, $restriction, $operator = "=") : voidRestricts a query with a where clause
| Name | Type | Description |
|---|---|---|
| $field | ||
| $restriction | ||
| $operator |

setWhereGroup( $group, $field, $restriction, $operator = "=") : voidsetWhereGroup ($group, $field, $restriction, $operator)
Inherited from: \ItemCollection::setWhereGroup()Restricts a query with a where clause, groupable
| Name | Type | Description |
|---|---|---|
| $group | ||
| $field | ||
| $restriction | ||
| $operator |
\PropertyItem
- Parent(s)
- \Item
- Author
- Timo A. Hummel
- Copyright
- four for business 2003
- Version
- 0.1
Properties

array $_arrInFilters = array('urlencode', 'conHtmlSpecialChars', 'addslashes')array('urlencode', 'conHtmlSpecialChars', 'addslashes')Details- Type
- array
- Access
- private
- Inherited_from
- \Item::$$_arrInFilters

array $_arrOutFilters = array('stripslashes', 'htmldecode', 'urldecode')array('stripslashes', 'htmldecode', 'urldecode')Details- Type
- array
- Access
- private
- Inherited_from
- \Item::$$_arrOutFilters

$_metaObject- Type
- n/a
- Inherited_from
- \Item::$$_metaObject

$maximumLength- Type
- n/a

string $oldPrimaryKey- Type
- string
- Access
- private
- Inherited_from
- \Item::$$oldPrimaryKey

array $values- Type
- array
- Access
- private
- Inherited_from
- \Item::$$values

boolean $virginIf true, the object is virgin and no operations on it except load-Functions are allowed.
- Type
- boolean
- Access
- private
- Inherited_from
- \Item::$$virgin
Methods

Item(string $table = "", string $primaryKey = "", $lifetime = 10) : void| Name | Type | Description |
|---|---|---|
| $table | string | The table to use as information source |
| $primaryKey | string | The primary key to use |
| $lifetime |

_inFilter(mixed $data) : mixedFilters the passed data using the functions defines in the _arrInFilters array.
Inherited from: \Item::_inFilter()| Name | Type | Description |
|---|---|---|
| $data | mixed | Data to filter |
| Type | Description |
|---|---|
| mixed | Filtered data |
- Access
- private
- See
- \setFilters

_onLoad() : \noneFunction which is called whenever an item is loaded. Inherited classes should override this function if desired.
| Type | Description |
|---|---|
| \none |

_outFilter(mixed $data) : mixedFilters the passed data using the functions defines in the _arrOutFilters array.
Inherited from: \Item::_outFilter()| Name | Type | Description |
|---|---|---|
| $data | mixed | Data to filter |
| Type | Description |
|---|---|
| mixed | Filtered data |
- Access
- private
- See
- \setFilters

_setMetaObject( $objectname) : void| Name | Type | Description |
|---|---|---|
| $objectname |

deleteProperty(string $type, string $name) : voiddeleteProperty ($type, $name) Deletes a custom property
Inherited from: \Item::deleteProperty()| Name | Type | Description |
|---|---|---|
| $type | string | Specifies the type |
| $name | string | Specifies the name |

get(string $field) : mixed| Name | Type | Description |
|---|---|---|
| $field | string | Specifies the field to retrieve |
| Type | Description |
|---|---|
| mixed | Value of the field |

getField(string $field) : mixed| Name | Type | Description |
|---|---|---|
| $field | string | Specifies the field to retrieve |
| Type | Description |
|---|---|
| mixed | Value of the field |

getProperty(string $type, string $name) : boolean| Name | Type | Description |
|---|---|---|
| $type | string | Specifies the type |
| $name | string | Specifies the name |
| Type | Description |
|---|---|
| boolean | Value of the given property |

loadBy(string $field, string $value, bool $bSafe = true) : boolloadBy ($field, $value) Loads an item by colum/field from the database
Inherited from: \Item::loadBy()| Name | Type | Description |
|---|---|---|
| $field | string | Specifies the field |
| $value | string | Specifies the value |
| $bSafe | bool | use inFilter or not |
| Type | Description |
|---|---|
| bool | True if the load was successful |

loadByPrimaryKey(string $value) : boolloadByPrimaryKey ($value) Loads an item by ID from the database
Inherited from: \Item::loadByPrimaryKey()| Name | Type | Description |
|---|---|---|
| $value | string | Specifies the primary key value |
| Type | Description |
|---|---|
| bool | True if the load was successful |

set(string $field, string $value, $safe = true) : void| Name | Type | Description |
|---|---|---|
| $field | string | Specifies the field to set |
| $value | string | Specifies the value to set |
| $safe |

setField(string $field, string $value, boolean $safe) : voidsetField($field, $value) Sets the value of a specific field
| Name | Type | Description |
|---|---|---|
| $field | string | Specifies the field to set |
| $value | string | Specifies the value to set |
| $safe | boolean | Speficies if we should translate characters |

setFilters(array $arrInFilters = array(), array $arrOutFilters = array()) : voidDefine the filter functions used when data is being stored or retrieved from the database.
Inherited from: \Item::setFilters()Examples:
$obj->setFilters(array('addslashes'), array('stripslashes')); $obj->setFilters(array('htmlencode', 'addslashes'), array('stripslashes', 'htmlencode'));
| Name | Type | Description |
|---|---|---|
| $arrInFilters | array | inFilters array with function names |
| $arrOutFilters | array | outFilters array with function names |

setProperty(string $type, string $name, string $value) : voidsetProperty ($type, $name, $value) Sets a custom property
Inherited from: \Item::setProperty()| Name | Type | Description |
|---|---|---|
| $type | string | Specifies the type |
| $name | string | Specifies the name |
| $value | string | Specifies the value |