KWeb
6.4
|
Aggregator classes are used to aggregate content from external sources in an automatic way - based on predefined set of rules. More...
Public Member Functions | |
__construct ($id) | |
run ($dryRun=false) | |
Runs the aggregation process. | |
cronRun () | |
connect () | |
isConnected () | |
fetchItems () | |
Returns an array of fetched items. | |
prepareItems ($feedItems) | |
Prepares fetched items and returns an array with items to be created or updated. | |
parseItem ($feedItem, &$result) | |
Parses fetched item based on $rules and stores necessary data in the $result. | |
findMatchingItem ($rules, $feedItem) | |
findForeignId ($foreignId, $match=false, $parentId=false) | |
createSynchItems ($rules, $feedItem, $matched, $parentId) | |
prepareFieldValue ($to, $from, $feedItem) | |
storeItems ($items, $dryRun=false) | |
Stores selected items in the system. | |
storeSynchItems ($items, $dryRun=false) | |
Stores selected synch items in the system. | |
getDBSettings () | |
createConfigSection ($section) | |
Created configuration section for this aggregator. | |
Data Fields | |
$id | |
$publishItems = false | |
$forceUpdate = false | |
$forceDryruns = false | |
$cronInterval = 900 | |
Interval in seconds (default: 15 minutes), or false if cron is not allowed. | |
$parentId | |
Main parent id. | |
$userId = null | |
$fetchLimit | |
Limit of items to fetch from server (depends on implementation) | |
$fetchOffset | |
Offset of items to fetch from server (depends on implementation) | |
$storeLimit = false | |
Limit of items to store in one go. | |
$allowUpdates = true | |
Allows for item updates. | |
$callbackBeforeParseItem = null | |
Callback after parsing item ($this, &$feedItem, &$result) | |
$callbackAfterParseItem = null | |
Callback after parsing item ($this, &$feedItem, &$synchItems, &$result) | |
$rules | |
Set of rules to apply to different item types. | |
$defaultType = 'default' | |
Type to be used as default. |
Aggregator classes are used to aggregate content from external sources in an automatic way - based on predefined set of rules.
Standard operation goes like this: # All items are fetched from the source (eg RSS) and returned as array of arrays (fetchItems()) # Aggregator checks all items for existence/modification and decides what to do with the items based on the set of rules defined in KWebAggregator::$rules (prepareItems()) # If the item doesn't exist, or should be updated, KWebSynchItem object is created in the result object. No modification to the database are made on this stage! # If everything goes allright, storeItems() is called and all prepared actions are performed on the CMS.
This model allows both for fully-automatic, and user-managed modes of operation.
KWebAggregator::__construct | ( | $ | id | ) |
KWebAggregator::connect | ( | ) |
Reimplemented in KWebAggregator_CSV, KWebAggregator_FaceBook, KWebAggregator_RSS, and KWebAggregator_YouTube.
KWebAggregator::createConfigSection | ( | $ | section | ) |
Created configuration section for this aggregator.
$section | KDBSetting_section_form |
Reimplemented in KWebAggregator_FaceBook.
KWebAggregator::createSynchItems | ( | $ | rules, |
$ | feedItem, | ||
$ | matched, | ||
$ | parentId | ||
) |
KWebAggregator::cronRun | ( | ) |
KWebAggregator::fetchItems | ( | ) |
Returns an array of fetched items.
These are not KWebItem objects, but just representation of fetched data in a common format.
Every item should be an array (or array accessible object) with minimum fields:
Other fields dependent on used aggregator.
Reimplemented in KWebAggregator_FaceBook_Photos, KWebAggregator_FaceBook_Wall, KWebAggregator_YouTube_Videos, KWebAggregator_CSV, KWebAggregator_RSS, and KWebAggregator_Google_LatitudeBadge.
KWebAggregator::findForeignId | ( | $ | foreignId, |
$ | match = false , |
||
$ | parentId = false |
||
) |
KWebAggregator::findMatchingItem | ( | $ | rules, |
$ | feedItem | ||
) |
KWebAggregator::getDBSettings | ( | ) |
KWebAggregator::isConnected | ( | ) |
Reimplemented in KWebAggregator_YouTube, KWebAggregator_FaceBook, KWebAggregator_CSV, and KWebAggregator_RSS.
KWebAggregator::parseItem | ( | $ | feedItem, |
&$ | result | ||
) |
Parses fetched item based on $rules and stores necessary data in the $result.
KWebAggregator::prepareFieldValue | ( | $ | to, |
$ | from, | ||
$ | feedItem | ||
) |
KWebAggregator::prepareItems | ( | $ | feedItems | ) |
Prepares fetched items and returns an array with items to be created or updated.
Normally, the result contains an array of KWebSynchItem objects, under key "synch". The objects will represent all actions that should be executed in the system in order to create/update aggregated items.
This function calls parseItem() for every item in the list.
KWebAggregator::run | ( | $ | dryRun = false | ) |
Runs the aggregation process.
KWebAggregator::storeItems | ( | $ | items, |
$ | dryRun = false |
||
) |
Stores selected items in the system.
KWebAggregator::storeSynchItems | ( | $ | items, |
$ | dryRun = false |
||
) |
Stores selected synch items in the system.
KWebAggregator::$allowUpdates = true |
Allows for item updates.
KWebAggregator::$callbackAfterParseItem = null |
Callback after parsing item ($this, &$feedItem, &$synchItems, &$result)
KWebAggregator::$callbackBeforeParseItem = null |
Callback after parsing item ($this, &$feedItem, &$result)
KWebAggregator::$cronInterval = 900 |
Interval in seconds (default: 15 minutes), or false if cron is not allowed.
KWebAggregator::$defaultType = 'default' |
Type to be used as default.
KWebAggregator::$fetchLimit |
Limit of items to fetch from server (depends on implementation)
KWebAggregator::$fetchOffset |
Offset of items to fetch from server (depends on implementation)
KWebAggregator::$forceDryruns = false |
KWebAggregator::$forceUpdate = false |
KWebAggregator::$id |
KWebAggregator::$parentId |
Main parent id.
KWebAggregator::$publishItems = false |
KWebAggregator::$rules |
array( 'default' => array( 'genre' => GENRE_ITEM, 'type' => ITEMT_ART, 'match' => 'item_foreign_id', 'fields' => array( 'item_foreign_id' => 'id', 'item_title' => 'title', 'info' => 'info', 'src' => 'text', ), ), )
Set of rules to apply to different item types.
"default" will be applied to all unknown item types
genre type match - id of the db field to match upon fields - fields mapping db -> fetched item field values can be stored as:
KWebAggregator::$storeLimit = false |
Limit of items to store in one go.
KWebAggregator::$userId = null |