contenido\classes\class.article.php
Description: Contenido Article Object and Collection
Requirements:
- Author
- Jan Lengowski
- 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_API
- Since
- file available since contenido release <= 4.6 {@internal created unknown modified 2008-06-30, Dominik Ziegler, add security fix $Id: class.article.php 870 2008-11-10 09:29:58Z rudi.bieller $: }}
- Version
- 1.1.7
\Article
This object represents a Contenido article
Create object with $obj = new Article(idart, client, lang [, idartlang]);
You can now read the article properties with $obj->getField(property);
List of article properties:
idartlang - Language dependant article id idart - Language indepenant article id idclient - Id of the client idtplcfg - Template configuration id title - Internal Title pagetitle - HTML Title summary - Article summary created - Date created lastmodified - Date lastmodiefied author - Article author (username) online - On-/offline redirect - Redirect redirect_url - Redirect URL artsort - Article sort key timemgmt - Time management datestart - Time management start date dateend - Time management end date status - Article status free_use_01 - Free to use free_use_02 - Free to use free_use_03 - Free to use time_move_cat - Move category after time management time_target_cat - Move category to this cat after time management time_online_move - Set article online after move external_redirect - Open article in new window locked - Article is locked for editing
You can extract article content with the $obj->getContent(contype [, number]) method.
To extract the first headline you can use:
$headline = $obj->getContent("htmlhead", 1);
If the second parameter is ommitted the method returns an array with all available content of this type. The array has the following schema:
array( number => content );
$headlines = $obj->getContent("htmlhead");
$headlines[1] First headline $headlines[2] Second headline $headlines[6] Sixth headline
Legal content type string are defined in the Contenido system table 'con_type'. Default content types are:
NOTE: This parameter is case insesitive, you can use html or cms_HTML or CmS_HtMl. Your don't need start with cms, but it won't crash if you do so.
htmlhead - HTML Headline html - HTML Text headline - Headline (no HTML) text - Text (no HTML) img - Upload id of the element imgdescr - Image description link - Link (URL) linktarget - Linktarget (_self, _blank, _top ...) linkdescr - Linkdescription swf - Upload id of the element
- 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

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

Article(int $idart, $client, int $lang, $idartlang = 0) : voidConstructor
| Name | Type | Description |
|---|---|---|
| $idart | int | Article Id |
| $client | ||
| $lang | int | Language Id |
| $idartlang |

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 |

_getArticleContent() : voidLoad the articles content and stores it in the 'content' property of the article object
$article->content[type][number] = value;

_getIdArtLang(int $idart, int $lang) : intExtract 'idartlang' for a specified 'idart' and 'lang'
| Name | Type | Description |
|---|---|---|
| $idart | int | Article id |
| $lang | int | Language id |
| Type | Description |
|---|---|
| int | Language dependant article id |
- Access
- private

_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 |

getContent(string $type, int $id = NULL) : mixedGet content(s) from an article
Returns the specified content element or an array("id"=>"value") if the second parameter is omitted.
Legal content type string are defined in the Contenido system table 'con_type'. Default content types are:
NOTE: Parameter is case insesitive, you can use html or cms_HTML or CmS_HtMl. Your don't need start with cms, but it won't crash if you do so.
htmlhead - HTML Headline html - HTML Text headline - Headline (no HTML) text - Text (no HTML) img - Upload id of the element imgdescr - Image description link - Link (URL) linktarget - Linktarget (_self, _blank, _top ...) linkdescr - Linkdescription swf - Upload id of the element
| Name | Type | Description |
|---|---|---|
| $type | string | CMS_TYPE - Legal cms type string |
| $id | int | Id of the content |
| Type | Description |
|---|---|
| mixed | String/Array Content Data |

getField(string $name) : mixedGet the value of an article property
List of article properties:
idartlang - Language dependant article id idart - Language indepenant article id idclient - Id of the client idtplcfg - Template configuration id title - Internal Title pagetitle - HTML Title summary - Article summary created - Date created lastmodified - Date lastmodiefied author - Article author (username) online - On-/offline redirect - Redirect redirect_url - Redirect URL artsort - Article sort key timemgmt - Time management datestart - Time management start date dateend - Time management end date status - Article status free_use_01 - Free to use free_use_02 - Free to use free_use_03 - Free to use time_move_cat - Move category after time management time_target_cat - Move category to this cat after time management time_online_move - Set article online after move external_redirect - Open article in new window locked - Article is locked for editing
| Name | Type | Description |
|---|---|---|
| $name | string | Property name |
| Type | Description |
|---|---|
| mixed | Property value |

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 = true) : voidsetField($field, $value) Sets the value of a specific field
Inherited from: \Item::setField()| 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 |
\ArticleCollection
This class is used to manage multiple Contenido article objects in a collection.
The constructor awaits an associative array as parameter with the following schema:
array( string paramname => mixed value );
The parameter idcat is required: array('idcat'=>n)
Legal parameter names are:
idcat - Contenido Category Id lang - Language Id, active language if ommited client - Client Id, active client if ommited start - include start article in the collection, defaults to false artspecs - Array of article specifications, which should be considered order - articles will be orderered by this article property, defaults to 'created' direction - Order direcion, 'asc' or 'desc' for ascending/descending, defaults to 'asc' limit - Limit numbers of articles in collection
You can easy create article lists/teasers with this class.
To create an article list of category 4 (maybe a news category) use:
$myList = new ArticleCollection(array("idcat"=>4);
while ($article = $myList->nextArticle()) { // Fetch the first headline $headline = $article->getContent('htmlhead', 1); $idart = $article->getField('idart');
// Create a link echo ''.$headline.'<br/>'; }
- Author
- Jan Lengowski
- Copyright
- four for business AG
- Version
- 1.0
Properties
Methods

ArticleCollection(array $options) : voidArticle Collection Constructor
| Name | Type | Description |
|---|---|---|
| $options | array | Options array with schema array("option"=>"value"); idcat (required) - Contenido Category Id lang - Language Id, active language if ommited client - Client Id, active client if ommited artspecs - Array of article specifications, which should be considered start - include start article in the collection, defaults to false order - articles will be orderered by this property, defaults to 'created' direction - Order direcion, 'asc' or 'desc' for ascending/descending limit - Limit numbers of articles in collection |

_getArticlesByCatId(int $idcat) : voidExtracts all articles from a specified category id and stores them in the internal article array
| Name | Type | Description |
|---|---|---|
| $idcat | int | Category Id |
- Access
- private

_setObjectProperties(array $options) : voidSet the Object properties
| Name | Type | Description |
|---|---|---|
| $options | array | Options array with schema array("option"=>"value"); idcat (required) - Contenido Category Id lang - Language Id, active language if ommited client - Client Id, active client if ommited artspecs - Array of article specifications, which should be considered start - include start article in the collection, defaults to false order - articles will be ordered by this property, defaults to 'created' direction - Order direcion, 'ASC' or 'DESC' for ascending/descending limit - Limit numbers of articles in collection |
- Access
- private

nextArticle() : objectIterate to the next article, return object of type Contenido Article Object if an article is found.
False otherwise.
| Type | Description |
|---|---|
| object | Contenido Article Object |

setPage(int $iPage) : voidSelect a page if the results was divided before.
$collection->setResultsPerPage(2); $collection->setPage(1);
// Iterate through all articles of page two while ($art = $collection->nextArticle()) { ... }
| Name | Type | Description |
|---|---|---|
| $iPage | int | The page of the article collection |
- Access
- public

setResultPerPage(int $resPerPage) : voidSplit the article results into pages of a given size.
Example: Article Collection with 5 articles
[0] => 250 [1] => 251 [2] => 253 [3] => 254 [4] => 255
$collection->setResultPerPage(2)
Would split the results into 3 pages
[0] => [0] => 250 [1] => 251 [1] => [0] => 253 [1] => 254 [2] => [0] => 255
A page can be selected with
$collection->setPage(int page)
| Name | Type | Description |
|---|---|---|
| $resPerPage | int |
- Access
- public