KWeb  6.4
KWebAggregator Class Reference

Aggregator classes are used to aggregate content from external sources in an automatic way - based on predefined set of rules. More...

Inheritance diagram for KWebAggregator:
KWebAggregator_CSV KWebAggregator_FaceBook KWebAggregator_Google KWebAggregator_RSS KWebAggregator_YouTube KWebAggregator_FaceBook_Photos KWebAggregator_FaceBook_Wall KWebAggregator_Google_LatitudeBadge KWebAggregator_YouTube_Videos

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.

Detailed Description

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.


Constructor & Destructor Documentation


Member Function Documentation

KWebAggregator::connect ( )
KWebAggregator::createConfigSection ( section)

Created configuration section for this aggregator.

Parameters:
$sectionKDBSetting_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:

  • id - ID of an item
    • item_type - type of an item (will be matched with $rules) And optional:
    • item_parent_id - ID of this item's parent
    • item_update - TRUE if update should be updated if it already exists (otherwise existing items will be skipped)

Other fields dependent on used aggregator.

Returns:
array(id, item_type)

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 
)
Returns:
array|bool|null - NULL if item doesn't exist, FALSE on error
KWebAggregator::getDBSettings ( )
Returns:
KDBSettings
KWebAggregator::isConnected ( )
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.

Returns:
array('synch' => array(KWebSynchItem) )
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.


Field Documentation

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
Initial value:
 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:

  • string - name of the matched field
KWebAggregator::$storeLimit = false

Limit of items to store in one go.

KWebAggregator::$userId = null

The documentation for this class was generated from the following file: