Commit 1d71bbf2 authored by gbyte.co's avatar gbyte.co

Clean up

parent 4a1621ca
......@@ -172,7 +172,7 @@ HOW CAN YOU CONTRIBUTE?
https://localize.drupal.org/translate/projects/simple_sitemap
* If you would like to say thanks and support the development of this module, a
donation is always appreciated.
donation will be much appreciated.
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5AFYRSBLGSC3W
......
......@@ -5,6 +5,8 @@
* Module install and update procedures.
*/
use Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapGeneratorBase;
/**
* Implements hook_requirements().
*
......@@ -28,7 +30,7 @@ function simple_sitemap_requirements($phase) {
case 'runtime':
$generator = \Drupal::service('simple_sitemap.generator');
$generated_ago = $generator->getGeneratedAgo('default'); //todo
$generated_ago = $generator->getGeneratedAgo(SitemapGeneratorBase::DEFAULT_SITEMAP_TYPE); //todo
$cron_generation = $generator->getSetting('cron_generate');
if (!$generated_ago) {
......@@ -373,7 +375,7 @@ function simple_sitemap_update_8208() {
}
}
return t('You may now want to configure the new changefreq setting for sitemap entities and custom links.');
return t('You may now want to configure the new changefreq setting for the XML sitemap entities and custom links.');
}
/**
......@@ -409,7 +411,7 @@ function simple_sitemap_update_8209() {
}
}
return t('You may now want to configure your sitemap entities to include images.');
return t('You may now want to configure your XML sitemap entities to include images.');
}
/**
......@@ -444,6 +446,8 @@ function simple_sitemap_update_8210() {
]
);
}
return t('The XML sitemap needs to be regenerated.');
}
......@@ -86,7 +86,7 @@ abstract class SimplesitemapFormBase extends ConfigFormBase {
*
*/
protected function getDonationText() {
return '<div class="description">' . $this->t('If you would like to say thanks and support the development of this module, a <a target="_blank" href="@url">donation</a> is always appreciated.', ['@url' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5AFYRSBLGSC3W']) . '</div>';
return '<div class="description">' . $this->t('If you would like to say thanks and support the development of this module, a <a target="_blank" href="@url">donation</a> will be much appreciated.', ['@url' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5AFYRSBLGSC3W']) . '</div>';
}
}
......@@ -27,6 +27,11 @@ class DefaultSitemapGenerator extends SitemapGeneratorBase {
const XMLNS_XHTML = 'http://www.w3.org/1999/xhtml';
const XMLNS_IMAGE = 'http://www.google.com/schemas/sitemap-image/1.1';
/**
* @var bool
*/
protected $isHreflangSitemap;
/**
* @var array
*/
......@@ -164,4 +169,17 @@ class DefaultSitemapGenerator extends SitemapGeneratorBase {
return $this->writer->outputMemory();
}
/**
* @return bool
*/
protected function isHreflangSitemap() {
if (NULL === $this->isHreflangSitemap) {
$this->isHreflangSitemap = count(
array_diff_key($this->languageManager->getLanguages(),
$this->settings['excluded_languages'])
) > 1;
}
return $this->isHreflangSitemap;
}
}
......@@ -38,11 +38,6 @@ abstract class SitemapGeneratorBase extends SimplesitemapPluginBase implements S
*/
protected $moduleHandler;
/**
* @var bool
*/
protected $isHreflangSitemap;
/**
* @var \Drupal\Component\Datetime\Time
*/
......@@ -210,16 +205,6 @@ abstract class SitemapGeneratorBase extends SimplesitemapPluginBase implements S
}
}
/**
* @return bool
*/
protected function isHreflangSitemap() {
if (NULL === $this->isHreflangSitemap) {
$this->isHreflangSitemap = count(array_diff_key($this->languageManager->getLanguages(), $this->settings['excluded_languages'])) > 1;
}
return $this->isHreflangSitemap;
}
/**
* @param array $settings
* @return $this
......
......@@ -134,13 +134,13 @@ class Simplesitemap {
* exist.
*
* @param string $name
* Name of the setting, like 'max_links'.
* Name of the setting, like 'max_links'.
*
* @param mixed $default
* Value to be returned if the setting does not exist in the configuration.
* Value to be returned if the setting does not exist in the configuration.
*
* @return mixed
* The current setting from configuration or a default value.
* The current setting from configuration or a default value.
*/
public function getSetting($name, $default = FALSE) {
$setting = $this->configFactory
......@@ -153,9 +153,9 @@ class Simplesitemap {
* Stores a specific sitemap setting in configuration.
*
* @param string $name
* Setting name, like 'max_links'.
* Setting name, like 'max_links'.
* @param mixed $setting
* The setting to be saved.
* The setting to be saved.
*
* @return $this
*/
......@@ -174,10 +174,10 @@ class Simplesitemap {
* @param int $delta
*
* @return string|false
* If no sitemap id provided, either a sitemap index is returned, or the
* whole sitemap, if the amount of links does not exceed the max links
* setting. If a sitemap id is provided, a sitemap chunk is returned. False
* if sitemap is not retrievable from the database.
* If no sitemap ID provided, either a sitemap index is returned, or the
* whole sitemap, if the amount of links does not exceed the max links
* setting. If a sitemap ID is provided, a sitemap chunk is returned.
* Returns false if the sitemap is not retrievable from the database.
*/
public function getSitemap($type = SitemapGeneratorBase::DEFAULT_SITEMAP_TYPE, $delta = NULL) {
$chunk_info = $this->fetchSitemapChunkInfo($type);
......@@ -185,12 +185,12 @@ class Simplesitemap {
if (empty($delta) || !isset($chunk_info[$delta])) {
if (isset($chunk_info[SitemapGeneratorBase::INDEX_DELTA])) {
// Return sitemap index, if there are multiple sitemap chunks.
// Return sitemap index if one exists.
return $this->fetchSitemapChunk($chunk_info[SitemapGeneratorBase::INDEX_DELTA]->id)
->sitemap_string;
}
else {
// Return sitemap if there is only one chunk.
// Return sitemap chunk if there is only one chunk.
return isset($chunk_info[SitemapGeneratorBase::FIRST_CHUNK_DELTA])
? $this->fetchSitemapChunk($chunk_info[SitemapGeneratorBase::FIRST_CHUNK_DELTA]->id)
->sitemap_string
......@@ -209,7 +209,7 @@ class Simplesitemap {
* @param string|null $type
*
* @return array
* An array containing chunk creation timestamps keyed by chunk ID.
* An array containing chunk creation timestamps keyed by chunk ID.
*/
protected function fetchSitemapChunkInfo($type = NULL) {
$query = $this->db->select('simple_sitemap', 's')
......@@ -239,11 +239,11 @@ class Simplesitemap {
}
/**
* Generates the XML sitemap and saves it to the db.
* Generates the XML sitemap and saves it to the database.
*
* @param string $from
* Can be 'form', 'backend', 'drush' or 'nobatch'.
* This decides how the batch process is to be run.
* Can be 'form', 'backend', 'drush' or 'nobatch'.
* This decides how the batch process is to be run.
*
* @param array|null $sitemap_types
*
......@@ -337,8 +337,13 @@ class Simplesitemap {
}
/**
* @param null|array $sitemap_types
*
* @todo Add removeSitemap API method.
*/
public function removeSitemap($sitemap_types = NULL) {
}
/**
* Returns a 'time ago' string of last timestamp generation.
......@@ -346,7 +351,7 @@ class Simplesitemap {
* @param string|null $type
*
* @return string|array|false
* Formatted timestamp of last sitemap generation, otherwise FALSE.
* Formatted timestamp of last sitemap generation, otherwise FALSE.
*/
public function getGeneratedAgo($type = NULL) {
$chunks = $this->fetchSitemapChunkInfo($type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment