.

GSiteMapModel Class Reference
[GSitemap]

Encapsulates rules for one sitemap model, which is a combination of a model and an action and a set of rules. More...

Inheritance diagram for GSiteMapModel:
PolicyHolder IPolicyHolder

List of all members.

Public Member Functions

  __construct ($model, $action= 'view', $policy=GsitemapController::USE_TIMESTAMP)
  Constructor.
  build_index_name ($chunk)
  create_adapter ()
  Creates adapter for given model.
  create_formatter (IDataObject $dao)
  Create Formatter.
  extract_chunk ($index)
  get_changefreq ()
  Return change frequency ofthis site.
  get_lastmod (IDataObject $item)
  Returns last modification date (or 0 if unknown).
  get_model_name ()
  get_number_of_chunks ()
  get_priority ()
  Return priority of this site.
  get_url (IDataObject $item)
  Returns URL for given item.
  select_chunk (IDataObject $adapter, $chunk)
  Limit adapter to chunk.

Public Attributes

  $action = 'view'
  $changefreq = ''
  $items_per_file = GsitemapController::ITEMS_PER_FILE
  $model
  $priority = 0.0

Protected Member Functions

  get_index_elements ()

Protected Attributes

  $adapter

Detailed Description

Encapsulates rules for one sitemap model, which is a combination of a model and an action and a set of rules.

Author:
Gerd Riesselmann

Definition at line 9 of file gsitemapmodel.cls.php.


Constructor & Destructor Documentation

GSiteMapModel::__construct ( model,
action = 'view',
policy = GsitemapController::USE_TIMESTAMP  
)

Constructor.

Definition at line 33 of file gsitemapmodel.cls.php.

00033                                                                                                          {
00034                 $this->model = $model;
00035                 $this->action = $action;
00036                 parent::__construct($policy);
00037         }

Member Function Documentation

GSiteMapModel::build_index_name ( chunk  ) 

Definition at line 79 of file gsitemapmodel.cls.php.

00079                                                  {
00080                 $index_elems = $this->get_index_elements();
00081                 $index_elems[] = $chunk;
00082                 return implode('.', $index_elems);              
00083         }
GSiteMapModel::create_adapter (  ) 

Creates adapter for given model.

Returns:
IDataObject

Definition at line 44 of file gsitemapmodel.cls.php.

00044                                          {
00045                 if (empty($this->adapter)) {
00046                         if ($this->model instanceof IDataObject) {
00047                                 $this->adapter = $this->model;
00048                         }
00049                         else {
00050                                 $this->adapter = DB::create(Cast::string($this->model));
00051                         }
00052                 }
00053                 return $this->adapter;
00054         }
GSiteMapModel::create_formatter ( IDataObject dao  ) 

Create Formatter.

Parameters:
\IDataObject  $dao
Returns:

Definition at line 154 of file gsitemapmodel.cls.php.

00154                                                            {
00155                 return new GSiteMapItemFormatter($this->get_url($dao), array(
00156                         'lastmod' => $this->get_lastmod($dao),
00157                         'changefreq' => $this->get_changefreq(),
00158                         'priority' => $this->get_priority()
00159                 ));
00160         }
GSiteMapModel::extract_chunk ( index  ) 

Definition at line 85 of file gsitemapmodel.cls.php.

00085                                               {
00086                 $ret = false;
00087                 $index_elems = $this->get_index_elements();
00088                 $start = implode('.', $index_elems) . '.';
00089                 $l_start = strlen($start);
00090                 if (substr($index, 0, $l_start) == $start) {
00091                         $si = substr($index, $l_start);
00092                         $i = Cast::int($si);
00093                         if ($si == (string)$i) {
00094                                 $ret = $i;
00095                         }
00096                 }
00097                 return $ret;
00098         }
GSiteMapModel::get_changefreq (  ) 

Return change frequency ofthis site.

Returns:
string

Definition at line 144 of file gsitemapmodel.cls.php.

00144                                          {
00145                 return $this->changefreq;
00146         }
GSiteMapModel::get_index_elements (  )  [protected]

Definition at line 72 of file gsitemapmodel.cls.php.

00072                                                 {
00073                 return array(
00074                         $this->get_model_name(),
00075                         $this->action
00076                 );
00077         }
GSiteMapModel::get_lastmod ( IDataObject item  ) 

Returns last modification date (or 0 if unknown).

Parameters:
IDataObject  $item
Returns:
int

Definition at line 122 of file gsitemapmodel.cls.php.

00122                                                        {
00123                 $ret = 0;
00124                 if ($this->has_policy(GsitemapController::USE_TIMESTAMP) && ($item instanceof ITimeStamped)) {
00125                         $ret = $item->get_modification_date();
00126                 }
00127                 return $ret;
00128         }
GSiteMapModel::get_model_name (  ) 

Definition at line 56 of file gsitemapmodel.cls.php.

00056                                          {
00057                 if (is_string($this->model)) {
00058                         return $this->model;
00059                 } else {
00060                         $adapter = $this->create_adapter();
00061                         return $adapter->get_table_name();
00062                 }
00063         }
GSiteMapModel::get_number_of_chunks (  ) 

Definition at line 100 of file gsitemapmodel.cls.php.

00100                                                {
00101                 $adapter = $this->create_adapter();
00102                 $c = ceil($adapter->count() / $this->items_per_file);
00103                 return $c;              
00104         }
GSiteMapModel::get_priority (  ) 

Return priority of this site.

Returns:
float

Definition at line 135 of file gsitemapmodel.cls.php.

00135                                        {
00136                 return $this->priority;
00137         }
GSiteMapModel::get_url ( IDataObject item  ) 

Returns URL for given item.

Parameters:
IDataObject  $item
Returns:
string

Definition at line 112 of file gsitemapmodel.cls.php.

00112                                                    {
00113                 return ActionMapper::get_url($this->action, $item);
00114         }
GSiteMapModel::select_chunk ( IDataObject adapter,
chunk  
)

Limit adapter to chunk.

Definition at line 68 of file gsitemapmodel.cls.php.

00068                                                                    {
00069                 $adapter->limit($chunk * $this->items_per_file, $this->items_per_file);                         
00070         }

Member Data Documentation

GSiteMapModel::$action = 'view'

Definition at line 21 of file gsitemapmodel.cls.php.

GSiteMapModel::$adapter [protected]

Definition at line 28 of file gsitemapmodel.cls.php.

GSiteMapModel::$changefreq = ''

Definition at line 26 of file gsitemapmodel.cls.php.

GSiteMapModel::$items_per_file = GsitemapController::ITEMS_PER_FILE

Definition at line 23 of file gsitemapmodel.cls.php.

GSiteMapModel::$model

Definition at line 15 of file gsitemapmodel.cls.php.

GSiteMapModel::$priority = 0.0

Definition at line 25 of file gsitemapmodel.cls.php.


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