'Holds XML sitemaps as strings for quick retrieval.',
'fields' => array(
'id' => array(
'description' => 'Sitemap chunk unique identifier.',
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
),
'sitemap_string' => array(
'description' => 'XML sitemap chunk string.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
),
'sitemap_created' => array(
'description' => 'Timestamp of sitemap chunk generation.',
'type' => 'int',
'default' => 0,
'not null' => TRUE,
),
),
'primary key' => array('id'),
);
return $schema;
}
/**
* Implements hook_install().
*/
function simplesitemap_install() {
$base_url = $GLOBALS['base_url'];
drupal_set_message(t("You can now include content into the XML sitemap by visiting the corresponding entity type edit pages (e.g. content type, taxonomy vocabulary, menu and user pages.)
Custom links can be added on this configuration page.", array('@sitemap_url' => "$base_url/sitemap.xml", '@content_type_url' => "$base_url/admin/structure/types", '@taxonomy_vocabulary_url' => "$base_url/admin/structure/taxonomy", '@menu_url' => "$base_url/admin/structure/menu", '@user_url' => "$base_url/admin/config/people/accounts", '@config_url' => "$base_url/admin/config/search/simplesitemap/custom")));
}
/**
* Update: Altering the {simplesitemap} language_code table field to hold longer strings.
*/
function simplesitemap_update_8101() {
db_change_field('simplesitemap', 'language_code', 'language_code', array(
'type' => 'varchar',
'not null' => TRUE,
'length' => 12,));
}
/**
* Changing config settings according to new config structure.
*/
function simplesitemap_update_8102() {
$entity_types = \Drupal::config('simplesitemap.settings')->get('entity_types');
$entity_types = is_array($entity_types) ? $entity_types : array();
if (isset($entity_types['node'])) {
$entity_types['node_type'] = $entity_types['node'];
unset($entity_types['node']);
}
if (isset($entity_types['taxonomy_term'])) {
$entity_types['taxonomy_vocabulary'] = $entity_types['taxonomy_term'];
unset($entity_types['taxonomy_term']);
}
\Drupal::service('config.factory')->getEditable('simplesitemap.settings')
->set('entity_types', $entity_types)->save();
}
/**
* Modifying database structure to hold one multilingual sitemap.
*/
function simplesitemap_update_8103() {
db_truncate('simplesitemap')->execute();
db_drop_primary_key('simplesitemap');
db_change_field('simplesitemap', 'language_code', 'id', array(
'type' => 'serial',
'not null' => TRUE
), array('primary key' => array('id')));
return t('Before the sitemap can be accessed, it must be regenerated manually or via cron run.');
}
/**
* Modifying database structure to accommodate sitemap chunks.
*/
function simplesitemap_update_8104() {
db_truncate('simplesitemap')->execute();
db_change_field('simplesitemap', 'id', 'id', array(
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
));
\Drupal::service('config.factory')->getEditable('simplesitemap.settings')
->set('settings', array('max_links' => 2000))->save();
return t('Before the sitemap can be accessed, it must be regenerated manually or via cron run.');
}
/**
* Modifying database structure to accommodate sitemap chunk timestamps.
*/
function simplesitemap_update_8105() {
db_add_field('simplesitemap', 'generated', array(
'description' => 'Timestamp of sitemap chunk generation.',
'type' => 'int',
'default' => 0,
'not null' => TRUE,
));
}
/**
* Changing column name to 'sitemap_created', as 'generated' is a reserved word since MySQL 5.7.6.
*/
function simplesitemap_update_8106() {
// Omitting the high level DB API to be able to escape the column name.
Drupal\Core\Database\Database::getConnection()
->query("alter table {simplesitemap} CHANGE `generated` sitemap_created int(11) NOT NULL");
}