CMS  Version 3.9
SiteMapManager Class Reference

Scans the application home directory and PHP include path and builds the component and administration page map that describe the configuration of the application. More...

Public Member Functions

 __construct ()
 Creates a new ComponentManager object. More...
 
 update ()
 
 deleteSiteMapPage ($siteMapPage)
 
 setHierarchyFromMenuItems ()
 Default the hierarchy of pages to the global menu's hierarchy. More...
 
 removeOldContentFromSiteMap ()
 Check if the SiteMap contains records of content that has been removed from the site. More...
 
 getTitle ($content, $type, $item)
 Given an instance of a CMS content item, get the title. More...
 
 saveNewContentToSiteMap ()
 Gather all CMS content and if an item is not already in the site map, add it. More...
 
 categorizeItemTypes ($itemsByType)
 
 getLink ($section, $identifier)
 

Static Public Member Functions

static updateSiteMap ()
 
static upgradeComponent ($version)
 
static registerSerializationHandler ()
 

Public Attributes

 $pages = array()
 
 $map = array()
 
 $currentContent = array()
 

Static Public Attributes

static $titleFields
 

Detailed Description

Scans the application home directory and PHP include path and builds the component and administration page map that describe the configuration of the application.

Definition at line 67 of file site_map_manager.inc.

Constructor & Destructor Documentation

◆ __construct()

SiteMapManager::__construct ( )

Creates a new ComponentManager object.

Definition at line 88 of file site_map_manager.inc.

89  {
90  $this->map = IndexedQuery::create(SiteMap, "", "url")->execute();
91 
92  if(!is_array($this->map))
93  {
94  $this->map = array();
95  }
96  }

Member Function Documentation

◆ categorizeItemTypes()

SiteMapManager::categorizeItemTypes (   $itemsByType)

Definition at line 276 of file site_map_manager.inc.

277  {
278  $types = array();
279 
280  foreach($itemsByType as $type => $items)
281  {
282  foreach($items as $item)
283  {
284  $types[$item->identifier] = $type;
285  }
286  }
287 
288  return $types;
289  }
$itemsByType
$types

◆ deleteSiteMapPage()

SiteMapManager::deleteSiteMapPage (   $siteMapPage)

Definition at line 125 of file site_map_manager.inc.

126  {
127  $parent = $siteMapPage->Parent();
128 
129  $children = $siteMapPage->Children();
130  if(count($children) > 0)
131  {
132  foreach($children as $child)
133  {
134  $child->parent_url = ($parent AND $parent->url) ?
135  $parent->url : "";
136  $child->save();
137  }
138  }
139  $siteMapPage->delete();
140  }
$parent
Definition: templates.inc:42
$siteMapPage

◆ getLink()

SiteMapManager::getLink (   $section,
  $identifier 
)

Definition at line 291 of file site_map_manager.inc.

292  {
293  if ($section->section == "/")
294  $url = "/$identifier";
295  else
296  $url = "/{$section->section}/$identifier";
297 
298  return $url;
299  }
$section
Definition: event_form.inc:44
if(! $blog->published||! $blog->enable_rss_feed||!checkRole($blog->allow_read)) $url
Definition: rss.inc:58

◆ getTitle()

SiteMapManager::getTitle (   $content,
  $type,
  $item 
)

Given an instance of a CMS content item, get the title.

Definition at line 202 of file site_map_manager.inc.

203  {
204  if ($content->override_page_title)
205  {
206  $title = $content->override_page_title;
207  }
208  else if(array_key_exists($type, SiteMapManager::$titleFields))
209  {
211  $title = $item->$field;
212  }
213  else
214  {
215  $title = prettify($item->identifier);
216  }
217 
218  return $title;
219  }
if(array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER)) $content
Definition: styles.css.inc:24

◆ registerSerializationHandler()

static SiteMapManager::registerSerializationHandler ( )
static

Definition at line 308 of file site_map_manager.inc.

309  {
311  return true;
312  }
registerHandler($component, $title, $handler)
Registers a serialization handler for a component.

◆ removeOldContentFromSiteMap()

SiteMapManager::removeOldContentFromSiteMap ( )

Check if the SiteMap contains records of content that has been removed from the site.

Definition at line 186 of file site_map_manager.inc.

187  {
188  foreach($this->map as $url => $siteMapPage)
189  {
190  if(array_search($url, $this->currentContent) === FALSE)
191  {
193  }
194  }
195  }
deleteSiteMapPage($siteMapPage)

◆ saveNewContentToSiteMap()

SiteMapManager::saveNewContentToSiteMap ( )

Gather all CMS content and if an item is not already in the site map, add it.

Definition at line 225 of file site_map_manager.inc.

226  {
227  $itemsByType = array();
229 
230  $sections = Query::create(Section, "ORDER BY section")->execute();
231 
232  foreach($sections as $section)
233  {
234  $content = $section->Content("ORDER BY identifier");
235  $contentByIdentifier = reindexList($content, "identifier");
236 
237  // e.g., type is Component Pages and items are all component pages
238  foreach($itemsByType as $type => $items)
239  {
240  foreach($items as $item)
241  {
242  if (!$item->identifier || !array_key_exists($item->identifier, $contentByIdentifier)) continue;
243 
244  trace(get_class($item). " - ".$item->identifier, 3);
245 
246  $content = $contentByIdentifier[$item->identifier];
247  $url = $this->getLink($section, $item->identifier);
248  $page_title = $this->getTitle($content, $type, $item);
249 
250  $siteMapPage = new SiteMap();
251  if(array_key_exists($url, $this->map))
252  {
253  $siteMapPage = $this->map[$url];
254  if($page_title != $siteMapPage->page_title)
255  {
256  $siteMapPage->page_title = $page_title;
257  $siteMapPage->filter = new InclusionFilter("page_title");
258  $siteMapPage->save();
259  }
260  }
261  else
262  {
263  $siteMapPage->url = $url;
264  $siteMapPage->published = true;
265  $siteMapPage->page_title = $page_title;
266  $siteMapPage->save();
267  $this->map[$siteMapPage->url] = $siteMapPage;
268  }
269 
270  $this->currentContent[] = $siteMapPage->url;
271  }
272  }
273  }
274  }
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
Section DataItem, defining the data model for sections within a site.
Definition: section.inc:45
getLink($section, $identifier)
getTitle($content, $type, $item)
Given an instance of a CMS content item, get the title.

◆ setHierarchyFromMenuItems()

SiteMapManager::setHierarchyFromMenuItems ( )

Default the hierarchy of pages to the global menu's hierarchy.

Definition at line 146 of file site_map_manager.inc.

147  {
148  $indexedMap = $this->map;
149 
150  $menuItems = GroupedQuery::create(MenuItem, "WHERE menu_id IN (SELECT menu_id FROM menu WHERE identifier='global')", "url")
151  ->execute();
152 
153  if(!count($menuItems)) return;
154 
155  foreach($menuItems as $url => $urlItems)
156  {
157  if(array_key_exists($url, $indexedMap))
158  {
159  $siteMapPage = $indexedMap[$url];
160 
161  if(!is_array($urlItems)) $urlItems = array($urlItems);
162 
163  foreach($urlItems as $menuItem)
164  {
165  $parent = $menuItem->Parent();
166  if(!$parent || $parent->url == $siteMapPage->url) continue;
167 
168  if($parent AND $parent->url != $siteMapPage->parent_url)
169  {
170  $siteMapPage->parent_url = $parent->url;
171  $siteMapPage->published = true;
172  $siteMapPage->sort_order = $menuItem->sort_order;
173  $siteMapPage->filter = new InclusionFilter("parent_url", "published");
174  $siteMapPage->save();
175  break;
176  }
177  }
178  }
179  }
180  }
$menuItem
$menuItems
Definition: menu_items.inc:50

◆ update()

SiteMapManager::update ( )

Definition at line 106 of file site_map_manager.inc.

107  {
108  $this->saveNewContentToSiteMap();
110  $this->setHierarchyFromMenuItems();
111  }
saveNewContentToSiteMap()
Gather all CMS content and if an item is not already in the site map, add it.
removeOldContentFromSiteMap()
Check if the SiteMap contains records of content that has been removed from the site.
setHierarchyFromMenuItems()
Default the hierarchy of pages to the global menu's hierarchy.

◆ updateSiteMap()

static SiteMapManager::updateSiteMap ( )
static

Definition at line 98 of file site_map_manager.inc.

99  {
100  trace("SiteMapManager processing method updateSiteMap", 3);
101 
102  $mgr = new SiteMapManager();
103  $mgr->update();
104  }
Scans the application home directory and PHP include path and builds the component and administration...

◆ upgradeComponent()

static SiteMapManager::upgradeComponent (   $version)
static

Definition at line 302 of file site_map_manager.inc.

303  {
304  $mgr = new SiteMapUpgradeManager();
305  $mgr->upgrade($version);
306  }

Member Data Documentation

◆ $currentContent

SiteMapManager::$currentContent = array()

Definition at line 71 of file site_map_manager.inc.

◆ $map

SiteMapManager::$map = array()

Definition at line 70 of file site_map_manager.inc.

◆ $pages

SiteMapManager::$pages = array()

Definition at line 69 of file site_map_manager.inc.

◆ $titleFields

SiteMapManager::$titleFields
static
Initial value:
= array(
"Blogs" => "title",
"Calendars" => "name",
"Document Libraries" => "name",
"Component Pages" => "page_title",
"Forums" => "title",
"Image Galleries" => "gallery_name",
"Link Libraries" => "name",
"Pages" => "page_title",
"Video Galleries" => "gallery_name",
)

Definition at line 73 of file site_map_manager.inc.


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