Open Monograph Press  3.3.0
SitemapHandler.inc.php
1 <?php
2 
16 import('lib.pkp.pages.sitemap.PKPSitemapHandler');
17 
19 
23  function _createContextSitemap($request) {
24  $doc = parent::_createContextSitemap($request);
25  $root = $doc->documentElement;
26 
27  $press = $request->getPress();
28  $pressId = $press->getId();
29 
30  // Catalog
31  $root->appendChild($this->_createUrlTree($doc, $request->url($press->getPath(), 'catalog')));
32 
33  $submissionsIterator = Services::get('submission')->getMany(['status' => STATUS_PUBLISHED, 'contextId' => $pressId, 'count' => 1000]);
34  foreach ($submissionsIterator as $submission) {
35  // Book
36  $root->appendChild($this->_createUrlTree($doc, $request->url($press->getPath(), 'catalog', 'view', array($submission->getBestId()))));
37  // Files
38  // Get publication formats
39  $publicationFormats = DAORegistry::getDAO('PublicationFormatDAO')->getApprovedByPublicationId($submission->getCurrentPublication()->getId())->toArray();
40  foreach ($publicationFormats as $format) {
41  // Consider only available publication formats
42  if ($format->getIsAvailable()) {
43  // Consider only available publication format files
44  $submissionDao = DAORegistry::getDAO('SubmissionDAO'); /* @var $submissionDao SubmissionDAO */
45  $availableFiles = array_filter(
46  $submissionDao->getLatestRevisionsByAssocId(ASSOC_TYPE_PUBLICATION_FORMAT, $format->getId(), $submission->getId()),
47  function($a) {
48  return $a->getDirectSalesPrice() !== null;
49  }
50  );
51  foreach ($availableFiles as $file) {
52  $root->appendChild($this->_createUrlTree($doc, $request->url($press->getPath(), 'catalog', 'view', array($submission->getBestId(), $format->getBestId(), $file->getBestId()))));
53  }
54  }
55  }
56  }
57 
58  // New releases
59  $root->appendChild($this->_createUrlTree($doc, $request->url($press->getPath(), 'catalog', 'newReleases')));
60  // Browse by series
61  $seriesDao = DAORegistry::getDAO('SeriesDAO'); /* @var $seriesDao SeriesDAO */
62  $seriesResult = $seriesDao->getByPressId($pressId);
63  while ($series = $seriesResult->next()) {
64  $root->appendChild($this->_createUrlTree($doc, $request->url($press->getPath(), 'catalog', 'series', $series->getPath())));
65  }
66  // Browse by categories
67  $categoryDao = DAORegistry::getDAO('CategoryDAO'); /* @var $categoryDao CategoryDAO */
68  $categoriesResult = $categoryDao->getByContextId($pressId);
69  while ($category = $categoriesResult->next()) {
70  $root->appendChild($this->_createUrlTree($doc, $request->url($press->getPath(), 'catalog', 'category', $category->getPath())));
71  }
72 
73  $doc->appendChild($root);
74 
75  // Enable plugins to change the sitemap
76  HookRegistry::call('SitemapHandler::createPressSitemap', array(&$doc));
77 
78  return $doc;
79  }
80 
81 }
82 
83 
SitemapHandler\_createContextSitemap
_createContextSitemap($request)
Definition: SitemapHandler.inc.php:23
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
PKPSitemapHandler\_createUrlTree
_createUrlTree($doc, $loc, $lastmod=null, $changefreq=null, $priority=null)
Definition: PKPSitemapHandler.inc.php:135
SitemapHandler
Produce a sitemap in XML format for submitting to search engines.
Definition: SitemapHandler.inc.php:18
PKPSitemapHandler
Produce a sitemap in XML format for submitting to search engines.
Definition: PKPSitemapHandler.inc.php:20
HookRegistry\call
static call($hookName, $args=null)
Definition: HookRegistry.inc.php:86
PKPServices\get
static get($service)
Definition: PKPServices.inc.php:49