* @license PHP License * @package WB * @subpackage datasource */ WBClass::load('WBObserver' , 'WBObserver_Observable' ); /** * Datasource Sitemap * * @version 0.2.0 * @package WB * @subpackage datasource */ abstract class WBDatasource_Sitemap extends WBStdClass implements WBObserver_Observable { /** * current priority * @var float */ private $priority = 1.0; /** * current path * @var float */ private $path = '/'; /** * sitemap snippet XML chunk, usually empty * @var string */ private $snippet = ''; /** * list of observers * @var array */ private $observers = array(); /** * datasource config * @var array */ protected $config = array(); /** * Configure datasource object * * Merge given config with default configuration * * @see $config * @param array $config */ final public function configure($config) { if (!is_array($config)) { $config = array(); } $this->config = array_merge($this->config, $config); } /** * attach observer * * @param WBObserver $observer */ final public function attach(WBObserver $observer) { $this->observers[$observer->getObjectId()] = $observer; } /** * detach observer * * @param WBObserver $observer */ final public function detach(WBObserver $observer) { unset($this->observers[$observer->getObjectId()]); } /** * notify observer * */ final public function notify() { foreach ($this->observers as $o) { $o->update($this); } } /** * Set current path * * @param string $path * @param string $snippet, usually empty */ final protected function setPath($path, $snippet = '') { $this->path = $path; $this->snippet = $snippet; } /** * Set current priority * * @param float $priority */ final protected function setPriority($priority) { $this->priority = $priority; } /** * Get current path * * Usually called by observer * * @return string */ final public function getPath() { return $this->path; } /** * Get current priority * * Usually called by observer * * @return float */ final public function getPriority() { return $this->priority; } /** * Get current snippet * * Usually called by observer. Snippet is usually empty * * @return float */ final public function getSnippet() { return $this->snippet; } /** * Find all the URLs * * Walk through all the pages etc. to find all URLs to be added to the sitemap. */ abstract public function find(); }