contenido\classes\class.article.php

Show: PublicProtectedPrivateinherited
Table of Contents
Project: Contenido Content Management System

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

Package: Default
Contenido API - Article Object

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

>VPropertypublicarray $_arrInFilters = array('urlencode', 'conHtmlSpecialChars', 'addslashes')
inherited
Array storing the funcion names of the filters used when data is stored to the db
Inherited from: \Item::$$_arrInFilters
Default valuearray('urlencode', 'conHtmlSpecialChars', 'addslashes')Details
Type
array
Access
private  
Inherited_from
\Item::$$_arrInFilters  
>VPropertypublicarray $_arrOutFilters = array('stripslashes', 'htmldecode', 'urldecode')
inherited
Array storing the funcion names of the filters used when data is retrieved from the db
Inherited from: \Item::$$_arrOutFilters
Default valuearray('stripslashes', 'htmldecode', 'urldecode')Details
Type
array
Access
private  
Inherited_from
\Item::$$_arrOutFilters  
>VPropertypublic$_metaObject
inheritedInherited from: \Item::$$_metaObject
Details
Type
n/a
Inherited_from
\Item::$$_metaObject  
>VPropertypublicarray $cache
inherited
Cache the result items
Inherited from: \Item::$$cache
Details
Type
array
Access
private  
Inherited_from
\Item::$$cache  
>VPropertypublicarray $content
Article content
Details
Type
array
>VPropertypublicobject $db
inherited
DB_Contenido instance
Inherited from: \Item::$$db
Details
Type
object
Access
private  
Inherited_from
\Item::$$db  
>VPropertypublicstring $lasterror
inherited
Storage of the last error
Inherited from: \Item::$$lasterror
Details
Type
string
Access
private  
Inherited_from
\Item::$$lasterror  
>VPropertypublicint $lifetime
inherited

Lifetime in seconds

Inherited from: \Item::$$lifetime
Details
Type
int
Access
private  
Inherited_from
\Item::$$lifetime  
>VPropertypublicarray $modifiedValues
inherited
Storage of the fields which were modified
Inherited from: \Item::$$modifiedValues
Details
Type
array
Access
private  
Inherited_from
\Item::$$modifiedValues  
>VPropertypublicstring $oldPrimaryKey
inherited
stores the old primary key, just in case somebody wants to change it
Inherited from: \Item::$$oldPrimaryKey
Details
Type
string
Access
private  
Inherited_from
\Item::$$oldPrimaryKey  
>VPropertypublicobject $primaryKey
inherited
Primary key of the table
Inherited from: \Item::$$primaryKey
Details
Type
object
Access
private  
Inherited_from
\Item::$$primaryKey  
>VPropertypublicobject $properties
inherited

PropertyCollection object

Inherited from: \Item::$$properties
Details
Type
object
Access
private  
Inherited_from
\Item::$$properties  
>VPropertypublicarray $tab
Config array
Details
Type
array
>VPropertypublicstring $table
inherited
Storage of the source table to use for the user informations
Inherited from: \Item::$$table
Details
Type
string
Access
private  
Inherited_from
\Item::$$table  
>VPropertypublicarray $values
inherited
Storage of the source table to use for the user informations
Inherited from: \Item::$$values
Details
Type
array
Access
private  
Inherited_from
\Item::$$values  
>VPropertypublicboolean $virgin
inherited
Checks for the virginity of this object.
Inherited from: \Item::$$virgin

If true, the object is virgin and no operations on it except load-Functions are allowed.

Details
Type
boolean
Access
private  
Inherited_from
\Item::$$virgin  

Methods

methodpublicArticle(int $idart,  $client, int $lang,  $idartlang = 0) : void

Constructor

Parameters
NameTypeDescription
$idartint

Article Id

$client
$langint

Language Id

$idartlang
methodpublicItem(string $table = "", string $primaryKey = "",  $lifetime = 10) : void
inherited

Constructor Function

Inherited from: \Item::Item()
Parameters
NameTypeDescription
$tablestring

The table to use as information source

$primaryKeystring

The primary key to use

$lifetime
methodpublic_getArticleContent() : void

Load the articles content and stores it in the 'content' property of the article object

$article->content[type][number] = value;

methodpublic_getIdArtLang(int $idart, int $lang) : int

Extract 'idartlang' for a specified 'idart' and 'lang'

Parameters
NameTypeDescription
$idartint

Article id

$langint

Language id

Returns
TypeDescription
intLanguage dependant article id
Details
Access
private  
methodpublic_inFilter(mixed $data) : mixed
inherited

Filters the passed data using the functions defines in the _arrInFilters array.

Inherited from: \Item::_inFilter()
Parameters
NameTypeDescription
$datamixed

Data to filter

Returns
TypeDescription
mixedFiltered data
Details
Access
private  
See
\setFilters  
methodpublic_onLoad() : \none
inherited

_onLoad ()

Inherited from: \Item::_onLoad()

Function which is called whenever an item is loaded. Inherited classes should override this function if desired.

Returns
TypeDescription
\none
methodpublic_outFilter(mixed $data) : mixed
inherited

Filters the passed data using the functions defines in the _arrOutFilters array.

Inherited from: \Item::_outFilter()
Parameters
NameTypeDescription
$datamixed

Data to filter

Returns
TypeDescription
mixedFiltered data
Details
Access
private  
See
\setFilters  
methodpublic_setMetaObject( $objectname) : void
inherited

Inherited from: \Item::_setMetaObject()
Parameters
NameTypeDescription
$objectname
methodpublicdeleteProperty(string $type, string $name) : void
inherited

deleteProperty ($type, $name) Deletes a custom property

Inherited from: \Item::deleteProperty()
Parameters
NameTypeDescription
$typestring

Specifies the type

$namestring

Specifies the name

methodpublicget(string $field) : mixed
inherited

get($field) Wrapper for getField (less to type)

Inherited from: \Item::get()
Parameters
NameTypeDescription
$fieldstring

Specifies the field to retrieve

Returns
TypeDescription
mixedValue of the field
methodpublicgetContent(string $type, int $id = NULL) : mixed

Get 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

Parameters
NameTypeDescription
$typestring

CMS_TYPE - Legal cms type string

$idint

Id of the content

Returns
TypeDescription
mixedString/Array Content Data
methodpublicgetField(string $name) : mixed

Get 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

Parameters
NameTypeDescription
$namestring

Property name

Returns
TypeDescription
mixedProperty value
methodpublicgetMetaObject() : void
inherited

Inherited from: \Item::getMetaObject()
methodpublicgetProperty(string $type, string $name) : boolean
inherited

getProperty ($type, $name) Sets a custom property

Inherited from: \Item::getProperty()
Parameters
NameTypeDescription
$typestring

Specifies the type

$namestring

Specifies the name

Returns
TypeDescription
booleanValue of the given property
methodpublicloadBy(string $field, string $value, bool $bSafe = true) : bool
inherited

loadBy ($field, $value) Loads an item by colum/field from the database

Inherited from: \Item::loadBy()
Parameters
NameTypeDescription
$fieldstring

Specifies the field

$valuestring

Specifies the value

$bSafebool

use inFilter or not

Returns
TypeDescription
boolTrue if the load was successful
methodpublicloadByPrimaryKey(string $value) : bool
inherited

loadByPrimaryKey ($value) Loads an item by ID from the database

Inherited from: \Item::loadByPrimaryKey()
Parameters
NameTypeDescription
$valuestring

Specifies the primary key value

Returns
TypeDescription
boolTrue if the load was successful
methodpublicset(string $field, string $value,  $safe = true) : void
inherited

set($field, $value) Shortcut to setField

Inherited from: \Item::set()
Parameters
NameTypeDescription
$fieldstring

Specifies the field to set

$valuestring

Specifies the value to set

$safe
methodpublicsetField(string $field, string $value, boolean $safe = true) : void
inherited

setField($field, $value) Sets the value of a specific field

Inherited from: \Item::setField()
Parameters
NameTypeDescription
$fieldstring

Specifies the field to set

$valuestring

Specifies the value to set

$safeboolean

Speficies if we should translate characters

methodpublicsetFilters(array $arrInFilters = array(), array $arrOutFilters = array()) : void
inherited

Define 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'));

Parameters
NameTypeDescription
$arrInFiltersarray

inFilters array with function names

$arrOutFiltersarray

outFilters array with function names

methodpublicsetProperty(string $type, string $name, string $value) : void
inherited

setProperty ($type, $name, $value) Sets a custom property

Inherited from: \Item::setProperty()
Parameters
NameTypeDescription
$typestring

Specifies the type

$namestring

Specifies the name

$valuestring

Specifies the value

methodpublicstore() : \none

Store -DISABLED-

This Article Object is READ ONLY

Returns
TypeDescription
\none
Details
Access
private  

\ArticleCollection

Package: Contenido API
Contenido API - Article Object Collection

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

>VPropertypublicarray $aPages
List of articles, splitted into pages
Details
Type
array
>VPropertypublicarray $articles
Articles
Details
Type
array
>VPropertypublicarray $artspecs
Article Specifications
Details
Type
array
>VPropertypublicint $client
Client ID
Details
Type
int
>VPropertypublicint $cnt = 0
Result Counter
Default value0Details
Type
int
>VPropertypublicint $count
Articles in collection
Details
Type
int
>VPropertypublicobject $db
Database Object
Details
Type
object
>VPropertypublicstring $direction
Sort direction
Details
Type
string
>VPropertypublicint $iCountPages
Pages in Article Collection
Details
Type
int
>VPropertypublicint $iResultPerPage
Results per page
Details
Type
int
>VPropertypublicint $lang
Language id
Details
Type
int
>VPropertypublicint $limit
Limit of numbers of articles in collection
Details
Type
int
>VPropertypublicstring $order
Sort order
Details
Type
string
>VPropertypublicint $start
Include the Start-Article
Details
Type
int
>VPropertypublicint $startId
Id of the start article
Details
Type
int
>VPropertypublicarray $tab
Config array
Details
Type
array

Methods

methodpublicArticleCollection(array $options) : void

Article Collection Constructor

Parameters
NameTypeDescription
$optionsarray

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

methodpublic_getArticlesByCatId(int $idcat) : void

Extracts all articles from a specified category id and stores them in the internal article array

Parameters
NameTypeDescription
$idcatint

Category Id

Details
Access
private  
methodpublic_setObjectProperties(array $options) : void

Set the Object properties

Parameters
NameTypeDescription
$optionsarray

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

Details
Access
private  
methodpublicnextArticle() : object

Iterate to the next article, return object of type Contenido Article Object if an article is found.

False otherwise.

Returns
TypeDescription
objectContenido Article Object
methodpublicsetPage(int $iPage) : void

Select 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()) { ... }

Parameters
NameTypeDescription
$iPageint

The page of the article collection

Details
Access
public  
methodpublicsetResultPerPage(int $resPerPage) : void

Split 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)

Parameters
NameTypeDescription
$resPerPageint
Details
Access
public  
methodpublicstartArticle() : object

Return ONLY the Start-Article

Returns
TypeDescription
objectContenido Article Object
Details
Access
public  
Documentation was generated by phpDocumentor 2.0.0a12.