This class contains functions for the article helper in CONTENIDO.

The article collector returns you a list of articles, which destination you can choose.

You have the ability to limit, sort and filter the article list. You can configure the article collector with an options array, which can include the following configuration. - idcat - category ID - categories - array with multiple category IDs - lang - language ID, active language if ommited - client - client ID, active client if ommited - artspecs - array of article specifications, which should be considered - offline - include offline article in the collection, defaults to false - offlineonly - only list offline articles, defaults to false - start - include start article in the collection, defaults to false - startonly - only list start articles, defaults to false - order - articles will be ordered by this property, defaults to created - direction - order direcion, ASC'or DESC for ascending/descending, defaults to DESC - limit - limit numbers of articles in collection, default to 0 (unlimited)

package Core
subpackage Helper

 Methods

Constructor.

__construct(array $options) : void

If options are defined, the loading process is automatically initiated.

Parameters

$options

array

array with options for the collector (optional, default: empty array)

Method "count" of the implemented Countable interface.

count() : int

Returns the amount of all loaded articles.

Returns

int

Method "current" of the implemented iterator.

current() : mixed

Returns

mixed

Method "key" of the implemented iterator.

key() : int | mixed

Returns

intmixed

Executes the article search with the given options.

loadArticles() : void

Method "next" of the implemented iterator.

next() : void

Compatibility method for old ArticleCollection class.

nextArticle() : bool | \cApiArticleLanguage

Returns the next article.

Returns

Method "rewind" of the implemented iterator.

rewind() : void

Seeks a specific position in the loaded articles.

seek(int $position) 

Parameters

$position

int

position to load

Exceptions

\cOutOfBoundsException

Setter for the collector options.

setOptions(array $options) : void

Validates incoming options and sets the default of the missing options.

Parameters

$options

array

array with option

Compatibility method for old ArticleCollection.

setPage(int $page) : void

Select a page if the results was divided before.

$collection->setResultPerPage(2); $collection->setPage(1);

// Iterate through all articles of page two while ($art = $collection->nextArticle()) { ... }

Parameters

$page

int

The page of the article collection

Compatibility method for old ArticleCollection.

setResultPerPage(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

$resPerPage

int

Compatibility method for old ArticleCollection class.

startArticle() : \cApiArticleLanguage

Returns the start article of a category. Does work only if one category was requested.

Exceptions

\cBadMethodCallException

Returns

Method "valid" of the implemented iterator.

valid() : bool

Returns

bool

 Properties

 

$_articles : array
 

$_currentPosition : int
 

$_options : array
 

$_pages : array
 

$_startArticles : array