contrib modules security updates

This commit is contained in:
Bachir Soussi Chiadmi
2016-10-13 12:10:40 +02:00
parent ffd758abc9
commit 747127f643
732 changed files with 67976 additions and 23207 deletions

View File

@@ -1,4 +0,0 @@
XML Sitemap 7.x-2.x-dev
-----------------------

View File

@@ -65,7 +65,7 @@ MORE INFORMATION
queue at http://drupal.org/project/issues/xmlsitemap.
- For additional documentation, see the online module handbook at
http://drupal.org/handbook/modules/gsitemap.
http://drupal.org/handbook/modules/xmlsitemap.
- You can view the sitemap.org specification at http://sitemaps.org.

View File

@@ -105,7 +105,7 @@ function xmlsitemap_sitemap_list_form() {
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No XML sitemaps available.') . ' ' . l('Add a new XML sitemap', 'admin/config/search/xmlsitemap/add'),
'#empty' => t('No XML sitemaps available.') . ' ' . l(t('Add a new XML sitemap'), 'admin/config/search/xmlsitemap/add'),
);
return $form;
}
@@ -348,6 +348,22 @@ function xmlsitemap_settings_form($form, &$form_state) {
'#title' => t('Enable developer mode to expose additional settings.'),
'#default_value' => variable_get('xmlsitemap_developer_mode', 0),
);
$form['advanced']['xmlsitemap_disable_cron_regeneration'] = array(
'#type' => 'checkbox',
'#title' => t('Disable cron generation of sitemap files.'),
'#default_value' => variable_get('xmlsitemap_disable_cron_regeneration', 0),
'#description' => t('This can be disabled if other methods are being used to generate the sitemap files, like <em>drush xmlsitemap-regenerate</em>.'),
);
$form['advanced']['xmlsitemap_output_elements'] = array(
'#type' => 'checkboxes',
'#title' => t('Enable or disable the individual @loc elements from output', array('@loc' => '<loc>')),
'#options' => array(
'lastmod' => t('Last modification date: @lastmod', array('@lastmod' => '<lastmod>')),
'changefreq' => t('Change frequency: @changfreq', array('@changfreq' => '<changefreq>')),
'priority' => t('Priority: @priority', array('@priority' => '<priority>')),
),
'#default_value' => drupal_map_assoc(variable_get('xmlsitemap_output_elements', array('lastmod', 'changefreq', 'priority'))),
);
$form['xmlsitemap_settings'] = array(
'#type' => 'vertical_tabs',
@@ -355,7 +371,7 @@ function xmlsitemap_settings_form($form, &$form_state) {
);
$entities = xmlsitemap_get_link_info(NULL, TRUE);
module_load_all_includes('inc', 'xmlsitemap');
module_load_all_includes('xmlsitemap.inc');
foreach ($entities as $entity => $entity_info) {
$form[$entity] = array(
'#type' => 'fieldset',

View File

@@ -60,10 +60,12 @@ function hook_xmlsitemap_link_info() {
/**
* Alter the data of a sitemap link before the link is saved.
*
* @param $link
* @param array $link
* An array with the data of the sitemap link.
* @param array $context
* An optional context array containing data related to the link.
*/
function hook_xmlsitemap_link_alter(&$link) {
function hook_xmlsitemap_link_alter(array &$link, array $context) {
if ($link['type'] == 'mymodule') {
$link['priority'] += 0.5;
}
@@ -75,10 +77,12 @@ function hook_xmlsitemap_link_alter(&$link) {
* @param $link
* Associative array defining an XML sitemap link as passed into
* xmlsitemap_link_save().
* @param array $context
* An optional context array containing data related to the link.
*
* @see hook_xmlsitemap_link_update()
*/
function hook_xmlsitemap_link_insert(array $link) {
function hook_xmlsitemap_link_insert(array $link, array $context) {
db_insert('mytable')
->fields(array(
'link_type' => $link['type'],
@@ -94,10 +98,12 @@ function hook_xmlsitemap_link_insert(array $link) {
* @param $link
* Associative array defining an XML sitemap link as passed into
* xmlsitemap_link_save().
* @param array $context
* An optional context array containing data related to the link.
*
* @see hook_xmlsitemap_link_insert()
*/
function hook_xmlsitemap_link_update(array $link) {
function hook_xmlsitemap_link_update(array $link, array $context) {
db_update('mytable')
->fields(array(
'link_type' => $link['type'],
@@ -107,6 +113,20 @@ function hook_xmlsitemap_link_update(array $link) {
->execute();
}
/**
* Respond to XML sitemap link clearing and rebuilding.
*
* @param array $types
* An array of link types that are being rebuilt.
* @param bool $save_custom
* If links with overridden status and/or priority are being removed or not.
*/
function hook_xmlsitemap_rebuild_clear(array $types, $save_custom) {
db_delete('mytable')
->condition('link_type', $types, 'IN')
->execute();
}
/**
* Index links for the XML sitemaps.
*/
@@ -172,6 +192,56 @@ function hook_xmlsitemap_context_url_options(array $context) {
function hook_xmlsitemap_context_url_options_alter(array &$options, array $context) {
}
/**
* Alter the content added to an XML sitemap for an individual element.
*
* This hooks is called when the module is generating the XML content for the
* sitemap and allows other modules to alter existing or add additional XML data
* for any element by adding additional key value paris to the $element array.
*
* The key in the element array is then used as the name of the XML child
* element to add and the value is the value of that element. For example:
*
* @code $element['video:title'] = 'Big Ponycorn'; @endcode
*
* Would result in a child element like <video:title>Big Ponycorn</video:title>
* being added to the sitemap for this particular link.
*
* @param array $element
* The element that will be converted to XML for the link.
* @param array $link
* An array of properties providing context about the link that we are
* generating an XML element for.
* @param object $sitemap
* The sitemap that is currently being generated.
*/
function hook_xmlsitemap_element_alter(array &$element, array $link, $sitemap) {
if ($link['subtype'] === 'video') {
$node = node_load($link['id']);
$element['video:video'] = array(
'video:title' => check_plain($node->title),
'video:description' => isset($node->body[LANGUAGE_NONE][0]['summary']) ? check_plain($node->body[LANGUAGE_NONE][0]['summary']) : check_plain($node->body[LANGUAGE_NONE][0]['value']),
'video:live' => 'no',
);
}
}
/**
* Alter the attributes used for the root element of the XML sitemap.
*
* For example add an xmlns:video attribute:
* <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
*
* @param array $attributes
* An associative array of attributes to use in the root element of an XML
* sitemap.
* @param object $sitemap
* The sitemap that is currently being generated.
*/
function hook_xmlsitemap_root_attributes_alter(&$attributes, $sitemap) {
$attributes['xmlns:video'] = 'http://www.google.com/schemas/sitemap-video/1.1';
}
/**
* Alter the query selecting data from {xmlsitemap} during sitemap generation.
*

View File

@@ -20,13 +20,23 @@ function xmlsitemap_drush_command() {
'description' => 'Dump and re-process all possible XML sitemap data, and then regenerate the files.',
'callback' => 'drush_xmlsitemap_rebuild',
'drupal dependencies' => array('xmlsitemap'),
'options' => array(
'types' => 'The types of links to rebuild, comma separated. If not provided, all link types will be used.',
),
);
$items['xmlsitemap-index'] = array(
'description' => 'Process un-indexed XML sitemap links.',
'callback' => 'drush_xmlsitemap_index',
'drupal dependencies' => array('xmlsitemap'),
'options' => array(
'--limit' => 'The limit of links of each type to process. Default value: ' . variable_get('xmlsitemap_batch_limit', 100),
'limit' => 'The limit of links of each type to process. Default value: ' . variable_get('xmlsitemap_batch_limit', 100),
),
);
$items['xmlsitemap-queue-rebuild'] = array(
'description' => 'Dump and queues all possible XML sitemap data to be re-processed via the xmlsitemap_link_process queue. This command does not regenerate the sitemap files.',
'options' => array(
'types' => 'The types of links to queue for rebuild, comma separated. If not provided, all link types will be used.',
'limit' => 'The number of links to be processed in each queue task.',
),
);
return $items;
@@ -39,6 +49,7 @@ function drush_xmlsitemap_regenerate() {
module_load_include('generate.inc', 'xmlsitemap');
// Run the batch process.
timer_start('xmlsitemap_regenerate');
xmlsitemap_run_unprogressive_batch('xmlsitemap_regenerate_batch');
$vars = array(
@@ -55,10 +66,21 @@ function drush_xmlsitemap_rebuild() {
module_load_include('generate.inc', 'xmlsitemap');
// Build a list of rebuildable link types.
$rebuild_types = xmlsitemap_get_rebuildable_link_types();
$types = xmlsitemap_get_rebuildable_link_types();
if ($option_types = drush_get_option('types', '')) {
$option_types = explode(',', $option_types);
if ($invalid_types = array_diff($option_types, $types)) {
drush_set_error(dt('The following link types are invalid: @types', array('@types' => implode(', ', $invalid_types))));
}
$types = array_intersect($types, $option_types);
}
if (empty($types)) {
return drush_set_error(dt('No link types are rebuildable.'));
}
// Run the batch process.
xmlsitemap_run_unprogressive_batch('xmlsitemap_rebuild_batch', $rebuild_types, TRUE);
timer_start('xmlsitemap_rebuild');
xmlsitemap_run_unprogressive_batch('xmlsitemap_rebuild_batch', $types, TRUE);
$vars = array(
'@timer' => timer_read('xmlsitemap_rebuild'),
@@ -84,3 +106,66 @@ function drush_xmlsitemap_index() {
drush_print(dt('Indexed @count new XML sitemap links.', array('@count' => $count_after - $count_before)));
}
}
/**
* Dump and queue all the sitemap links to be rebuilt in a queue process.
*/
function drush_xmlsitemap_queue_rebuild() {
module_load_include('generate.inc', 'xmlsitemap');
$types = xmlsitemap_get_rebuildable_link_types();
if ($option_types = drush_get_option('types', '')) {
$option_types = explode(',', $option_types);
if ($invalid_types = array_diff($option_types, $types)) {
drush_set_error(dt('The following link types are invalid: @types', array('@types' => implode(', ', $invalid_types))));
}
$types = array_intersect($types, $option_types);
}
if (empty($types)) {
return drush_set_error(dt('No link types are rebuildable.'));
}
xmlsitemap_rebuild_clear($types, TRUE);
$link_count = 0;
$chunk_count = 0;
$chunk_size = (int) drush_get_option('limit', variable_get('xmlsitemap_batch_limit', 100));
// @todo Figure out how to re-use this code with xmlsitemap_rebuild_batch_fetch()
foreach ($types as $type) {
$info = xmlsitemap_get_link_info($type);
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', $type);
$query->entityCondition('entity_id', 0, '>');
$query->addTag('xmlsitemap_link_bundle_access');
$query->addTag('xmlsitemap_rebuild');
$query->addMetaData('entity', $type);
$query->addMetaData('entity_info', $info);
if ($bundles = xmlsitemap_get_link_type_enabled_bundles($type)) {
$query->entityCondition('bundle', $bundles, 'IN');
}
else {
// If no enabled bundle types, skip everything else.
continue;
}
$results = $query->execute();
if (!empty($results[$type])) {
$ids = array_keys($results[$type]);
$link_count += count($ids);
$chunks = array_chunk($ids, $chunk_size);
$chunk_count += count($chunks);
foreach ($chunks as $chunk) {
xmlsitemap_link_enqueue($type, $chunk);
}
}
}
if ($link_count) {
drush_log(dt('Queued @link_count links for rebuild processing in the xmlsitemap_link_process (in @chunk_count chunks of up to @chunk_size links each).', array('@link_count' => $link_count, '@chunk_count' => $chunk_count, '@chunk_size' => $chunk_size)), 'success');
}
else {
drush_log(dt('No links to queue for rebuild processing.'), 'ok');
}
variable_set('xmlsitemap_rebuild_needed', FALSE);
}

View File

@@ -32,15 +32,33 @@ function xmlsitemap_get_path_alias($path, $language) {
$last_language = $language;
}
// We need to pass our path through hook_url_outbound_alter(). This fixes
// clean URLs not working when they don't exist in the {url_alias} table and
// are created with something like subpathauto.
$normalized_path = $path;
// hook_url_outbound_alter() expects defaults in url() options.
$options = array(
'fragment' => '',
'query' => array(),
'absolute' => FALSE,
'alias' => FALSE,
'prefix' => '',
'external' => FALSE,
);
if ($language != LANGUAGE_NONE && isset($aliases[$language][$path])) {
return $aliases[$language][$path];
$normalized_path = $aliases[$language][$path];
$options['alias'] = TRUE;
}
elseif (isset($aliases[LANGUAGE_NONE][$path])) {
return $aliases[LANGUAGE_NONE][$path];
}
else {
return $path;
$normalized_path = $aliases[LANGUAGE_NONE][$path];
$options['alias'] = TRUE;
}
$original_path = $normalized_path;
drupal_alter('url_outbound', $normalized_path, $options, $original_path);
return $normalized_path;
}
/**
@@ -136,6 +154,7 @@ function xmlsitemap_generate_page(stdClass $sitemap, $page) {
}
function xmlsitemap_generate_chunk(stdClass $sitemap, XMLSitemapWriter $writer, $chunk) {
$output_elements = drupal_map_assoc(variable_get('xmlsitemap_output_elements', array('lastmod', 'changefreq', 'priority')));
$lastmod_format = variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM);
$url_options = $sitemap->uri['options'];
@@ -150,7 +169,7 @@ function xmlsitemap_generate_chunk(stdClass $sitemap, XMLSitemapWriter $writer,
$link_count = 0;
$query = db_select('xmlsitemap', 'x');
$query->fields('x', array('loc', 'lastmod', 'changefreq', 'changecount', 'priority', 'language', 'access', 'status'));
$query->fields('x', array('id', 'type', 'subtype', 'loc', 'lastmod', 'changefreq', 'changecount', 'priority', 'language', 'access', 'status'));
$query->condition('x.access', 1);
$query->condition('x.status', 1);
$query->orderBy('x.language', 'DESC');
@@ -191,22 +210,28 @@ function xmlsitemap_generate_chunk(stdClass $sitemap, XMLSitemapWriter $writer,
$element = array();
$element['loc'] = $link_url;
if ($link['lastmod']) {
$element['lastmod'] = gmdate($lastmod_format, $link['lastmod']);
if (!empty($output_elements['lastmod'])) {
$element['lastmod'] = gmdate($lastmod_format, $link['lastmod']);
}
// If the link has a lastmod value, update the changefreq so that links
// with a short changefreq but updated two years ago show decay.
// We use abs() here just incase items were created on this same cron run
// because lastmod would be greater than REQUEST_TIME.
$link['changefreq'] = (abs(REQUEST_TIME - $link['lastmod']) + $link['changefreq']) / 2;
}
if ($link['changefreq']) {
if (!empty($output_elements['changefreq']) && $link['changefreq']) {
$element['changefreq'] = xmlsitemap_get_changefreq($link['changefreq']);
}
if (isset($link['priority']) && $link['priority'] != 0.5) {
if (!empty($output_elements['priority']) && isset($link['priority']) && $link['priority'] != 0.5) {
// Don't output the priority value for links that have 0.5 priority. This
// is the default 'assumed' value if priority is not included as per the
// sitemaps.org specification.
$element['priority'] = number_format($link['priority'], 1);
}
// @todo Should this be moved to XMLSitemapWritier::writeSitemapElement()?
drupal_alter('xmlsitemap_element', $element, $link, $sitemap);
$writer->writeSitemapElement('url', $element);
}
@@ -399,19 +424,8 @@ function xmlsitemap_batch_variable_set(array $variables) {
*/
function xmlsitemap_rebuild_batch_clear(array $entities, $save_custom, &$context) {
if (!empty($entities)) {
$query = db_delete('xmlsitemap');
$query->condition('type', $entities);
// If we want to save the custom data, make sure to exclude any links
// that are not using default inclusion or priority.
if ($save_custom) {
$query->condition('status_override', 0);
$query->condition('priority_override', 0);
}
$query->execute();
xmlsitemap_rebuild_clear($entities, $save_custom);
}
$context['message'] = t('Purging links.');
}
@@ -433,6 +447,13 @@ function xmlsitemap_rebuild_batch_fetch($entity, &$context) {
$query->addTag('xmlsitemap_rebuild');
$query->addMetaData('entity', $entity);
$query->addMetaData('entity_info', $info);
if ($types = xmlsitemap_get_link_type_enabled_bundles($entity)) {
$query->entityCondition('bundle', $types, 'IN');
}
else {
// If no enabled bundle types, skip everything else.
return;
}
if (!isset($context['sandbox']['max'])) {
$count_query = clone $query;
@@ -499,3 +520,32 @@ function xmlsitemap_get_rebuildable_link_types() {
return $rebuild_types;
}
/**
* Clear all sitemap links for given entity types.
*
* @param array $types
* An array of link types.
* @param bool $save_custom
* A boolean if links with status or priority overridden should not be
* removed (and hence overridden values not lost).
*
* @return int
* The number of deleted links.
*/
function xmlsitemap_rebuild_clear(array $types, $save_custom) {
// Let other modules respond to the rebuild clearing.
module_invoke_all('xmlsitemap_rebuild_clear', $types, $save_custom);
$query = db_delete('xmlsitemap');
$query->condition('type', $types);
// If we want to save the custom data, make sure to exclude any links
// that are not using default inclusion or priority.
if ($save_custom) {
$query->condition('status_override', 0);
$query->condition('priority_override', 0);
}
return $query->execute();
}

View File

@@ -14,9 +14,9 @@ files[] = xmlsitemap.test
recommends[] = robotstxt
configure = admin/config/search/xmlsitemap
; Information added by drupal.org packaging script on 2012-12-08
version = "7.x-2.0-rc2+0-dev"
; Information added by Drupal.org packaging script on 2016-05-25
version = "7.x-2.3"
core = "7.x"
project = "xmlsitemap"
datestamp = "1354931808"
datestamp = "1464191061"

View File

@@ -338,6 +338,11 @@ function xmlsitemap_install() {
->execute();
// @todo Does the sitemap show up on first install or is it a 404 page?
// Create the link process the queue.
/** @var DrupalReliableQueueInterface $queue */
$queue = DrupalQueue::get('xmlsitemap_link_process', TRUE);
$queue->createQueue();
}
/**
@@ -363,6 +368,11 @@ function xmlsitemap_uninstall() {
// Remove the file cache directory.
xmlsitemap_clear_directory(NULL, TRUE);
// Remove the queue.
/** @var DrupalReliableQueueInterface $queue */
$queue = DrupalQueue::get('xmlsitemap_link_process', TRUE);
$queue->deleteQueue();
}
/**

View File

@@ -64,6 +64,8 @@ function xmlsitemap_hook_info() {
'xmlsitemap_context_info_alter',
'xmlsitemap_context_url_options',
'xmlsitemap_context',
'xmlsitemap_element_alter',
'xmlsitemap_root_attributes_alter',
'xmlsitemap_sitemap_insert',
'xmlsitemap_sitemap_update',
'xmlsitemap_sitemap_operations',
@@ -72,6 +74,7 @@ function xmlsitemap_hook_info() {
'query_xmlsitemap_generate_alter',
'query_xmlsitemap_link_bundle_access_alter',
'form_xmlsitemap_sitemap_edit_form_alter',
'xmlsitemap_rebuild_clear',
);
$hooks = array_combine($hooks, $hooks);
@@ -234,6 +237,10 @@ function xmlsitemap_cron() {
if (!variable_get('xmlsitemap_regenerate_needed', FALSE)) {
return;
}
// If cron sitemap file regeneration is disabled, stop.
if (variable_get('xmlsitemap_disable_cron_regeneration', 0)) {
return;
}
// If the minimum sitemap lifetime hasn't been passed, skip.
$lifetime = REQUEST_TIME - variable_get('xmlsitemap_generated_last', 0);
@@ -290,6 +297,8 @@ function xmlsitemap_variables() {
'xmlsitemap_frontpage_changefreq' => XMLSITEMAP_FREQUENCY_DAILY,
'xmlsitemap_lastmod_format' => XMLSITEMAP_LASTMOD_MEDIUM,
'xmlsitemap_gz' => FALSE,
'xmlsitemap_disable_cron_regeneration' => 0,
'xmlsitemap_output_elements' => array('lastmod', 'changefreq', 'priority'),
// Removed variables are set to NULL so they can still be deleted.
'xmlsitemap_regenerate_last' => NULL,
'xmlsitemap_custom_links' => NULL,
@@ -560,10 +569,15 @@ function xmlsitemap_link_load_multiple(array $conditions = array()) {
/**
* Saves or updates a sitemap link.
*
* @param $link
* @param array $link
* An array with a sitemap link.
* @param array $context
* An optional context array containing data related to the link.
*
* @return array
* The saved sitemap link.
*/
function xmlsitemap_link_save(array $link) {
function xmlsitemap_link_save(array $link, array $context = array()) {
$link += array(
'access' => 1,
'status' => 1,
@@ -577,7 +591,7 @@ function xmlsitemap_link_save(array $link) {
);
// Allow other modules to alter the link before saving.
drupal_alter('xmlsitemap_link', $link);
drupal_alter('xmlsitemap_link', $link, $context);
// Temporary validation checks.
// @todo Remove in final?
@@ -599,11 +613,11 @@ function xmlsitemap_link_save(array $link) {
// Save the link and allow other modules to respond to the link being saved.
if ($existing) {
drupal_write_record('xmlsitemap', $link, array('type', 'id'));
module_invoke_all('xmlsitemap_link_update', $link);
module_invoke_all('xmlsitemap_link_update', $link, $context);
}
else {
drupal_write_record('xmlsitemap', $link);
module_invoke_all('xmlsitemap_link_insert', $link);
module_invoke_all('xmlsitemap_link_insert', $link, $context);
}
return $link;
@@ -1535,5 +1549,47 @@ function xmlsitemap_get_operation_link($url, $options = array()) {
}
$link += array('query' => $destination);
drupal_alter('xmlsitemap_operation_link', $link);
return $link;
}
/**
* Implements hook_cron_queue_info().
*/
function xmlsitemap_cron_queue_info() {
$info['xmlsitemap_link_process'] = array(
'worker callback' => 'xmlsitemap_link_queue_process',
'time' => 60,
);
return $info;
}
/**
* Queue callback for processing sitemap links.
*/
function xmlsitemap_link_queue_process($data) {
$info = xmlsitemap_get_link_info($data['type']);
$ids = isset($data['ids']) ? $data['ids'] : array($data['id']);
if (function_exists($info['xmlsitemap']['process callback'])) {
$info['xmlsitemap']['process callback']($ids);
}
}
/**
* Enqueue sitemap links to be updated via the xmlsitemap_link_process queue.
*
* @param string $type
* The link type.
* @param array|int $ids
* An array of link IDs or a singular link ID.
*/
function xmlsitemap_link_enqueue($type, $ids) {
$data = array();
$data['type'] = $type;
$data['ids'] = is_array($ids) ? $ids : array($ids);
/** @var DrupalReliableQueueInterface $queue */
$queue = DrupalQueue::get('xmlsitemap_link_process');
$queue->createItem($data);
}

View File

@@ -13,7 +13,6 @@ class XMLSitemapGenerationException extends XMLSitemapException {}
* Extended class for writing XML sitemap files.
*/
class XMLSitemapWriter extends XMLWriter {
protected $status = TRUE;
protected $uri = NULL;
protected $sitemapElementCount = 0;
protected $linkCountFlush = 500;
@@ -37,7 +36,7 @@ class XMLSitemapWriter extends XMLWriter {
}
public function openUri($uri) {
$return = parent::openUri(drupal_realpath($uri));
$return = parent::openUri($uri);
if (!$return) {
throw new XMLSitemapGenerationException(t('Could not open file @file for writing.', array('@file' => $uri)));
}
@@ -46,18 +45,36 @@ class XMLSitemapWriter extends XMLWriter {
public function startDocument($version = '1.0', $encoding = 'UTF-8', $standalone = NULL) {
$this->setIndent(FALSE);
parent::startDocument($version, $encoding);
$result = parent::startDocument($version, $encoding);
if (!$result) {
throw new XMLSitemapGenerationException(t('Unknown error occurred while writing to file @file.', array('@file' => $this->uri)));
}
if (variable_get('xmlsitemap_xsl', 1)) {
$this->writeXSL();
}
$this->startElement($this->rootElement, TRUE);
return $result;
}
public function getSitemapUrl($path, array $options = array()) {
$options += $this->sitemap->uri['options'];
$options += array(
'absolute' => TRUE,
'base_url' => variable_get('xmlsitemap_base_url', $GLOBALS['base_url']),
'language' => language_default(),
'alias' => TRUE,
);
if (!empty($options['protocol_relative'])) {
$options['base_url'] = preg_replace('~^https?:~', '', $options['base_url']);
}
return url($path, $options);
}
/**
* Add the XML stylesheet to the XML page.
*/
public function writeXSL() {
$this->writePi('xml-stylesheet', 'type="text/xsl" href="' . url('sitemap.xsl') . '"');
$this->writePi('xml-stylesheet', 'type="text/xsl" href="' . $this->getSitemapUrl('sitemap.xsl', array('protocol_relative' => TRUE)) . '"');
$this->writeRaw(PHP_EOL);
}
@@ -70,6 +87,9 @@ class XMLSitemapWriter extends XMLWriter {
$attributes['xmlns:xsi'] = 'http://www.w3.org/2001/XMLSchema-instance';
$attributes['xsi:schemaLocation'] = 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd';
}
drupal_alter('xmlsitemap_root_attributes', $attributes, $this->sitemap);
return $attributes;
}
@@ -111,37 +131,27 @@ class XMLSitemapWriter extends XMLWriter {
/**
* Write full element tag including support for nested elements.
*
* @param $name
* @param string $name
* The element name.
* @param $content
* @param string|array $content
* The element contents or an array of the elements' sub-elements.
*
* @todo Missing a return value since XMLWriter::writeElement() has one.
*/
public function writeElement($name, $content = '') {
public function writeElement($name, $content = NULL) {
if (is_array($content)) {
$this->startElement($name);
foreach ($content as $sub_name => $sub_content) {
$this->writeElement($sub_name, $sub_content);
}
$xml_content = format_xml_elements($content);
// Remove additional spaces from the output.
$xml_content = str_replace(array(" <", ">\n"), array("<", ">"), $xml_content);
$this->writeRaw($xml_content);
$this->endElement();
}
else {
parent::writeElement($name, $content);
parent::writeElement($name, check_plain((string) $content));
}
}
/**
* Override of XMLWriter::flush() to track file writing status.
*/
public function flush($empty = TRUE) {
$return = parent::flush($empty);
$this->status &= (bool) $return;
return $return;
}
public function getStatus() {
return $this->status;
}
public function getURI() {
return $this->uri;
}
@@ -153,7 +163,7 @@ class XMLSitemapWriter extends XMLWriter {
public function endDocument() {
$return = parent::endDocument();
if (!$this->getStatus()) {
if (!$return) {
throw new XMLSitemapGenerationException(t('Unknown error occurred while writing to file @file.', array('@file' => $this->uri)));
}
@@ -179,24 +189,18 @@ class XMLSitemapIndexWriter extends XMLSitemapWriter {
$attributes['xmlns:xsi'] = 'http://www.w3.org/2001/XMLSchema-instance';
$attributes['xsi:schemaLocation'] = 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd';
}
drupal_alter('xmlsitemap_root_attributes', $attributes, $this->sitemap);
return $attributes;
}
public function generateXML() {
$lastmod_format = variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM);
$url_options = $this->sitemap->uri['options'];
$url_options += array(
'absolute' => TRUE,
'base_url' => variable_get('xmlsitemap_base_url', $GLOBALS['base_url']),
'language' => language_default(),
'alias' => TRUE,
);
for ($i = 1; $i <= $this->sitemap->chunks; $i++) {
$url_options['query']['page'] = $i;
$element = array(
'loc' => url('sitemap.xml', $url_options),
'loc' => $this->getSitemapUrl('sitemap.xml', array('query' => array('page' => $i))),
// @todo Use the actual lastmod value of the chunk file.
'lastmod' => gmdate($lastmod_format, REQUEST_TIME),
);

View File

@@ -21,11 +21,13 @@ function xmlsitemap_custom_list_links() {
$rows = array();
$destination = drupal_get_destination();
$query = db_select('xmlsitemap');
$query = db_select('xmlsitemap')
->extend('PagerDefault')
->extend('TableSort');
$query->fields('xmlsitemap');
$query->condition('type', 'custom');
$query->extend('PagerDefault')->limit(50);
$query->extend('TableSort')->orderByHeader($header);
$query->limit(25);
$query->orderByHeader($header);
$result = $query->execute();
foreach ($result as $link) {

View File

@@ -9,9 +9,9 @@ files[] = xmlsitemap_custom.install
files[] = xmlsitemap_custom.test
configure = admin/config/search/xmlsitemap/custom
; Information added by drupal.org packaging script on 2012-12-08
version = "7.x-2.0-rc2+0-dev"
; Information added by Drupal.org packaging script on 2016-05-25
version = "7.x-2.3"
core = "7.x"
project = "xmlsitemap"
datestamp = "1354931808"
datestamp = "1464191061"

View File

@@ -6,9 +6,9 @@ files[] = xmlsitemap_engines_test.module
version = VERSION
hidden = TRUE
; Information added by drupal.org packaging script on 2012-12-08
version = "7.x-2.0-rc2+0-dev"
; Information added by Drupal.org packaging script on 2016-05-25
version = "7.x-2.3"
core = "7.x"
project = "xmlsitemap"
datestamp = "1354931808"
datestamp = "1464191061"

View File

@@ -10,9 +10,9 @@ files[] = tests/xmlsitemap_engines.test
recommends[] = site_verify
configure = admin/config/search/xmlsitemap/engines
; Information added by drupal.org packaging script on 2012-12-08
version = "7.x-2.0-rc2+0-dev"
; Information added by Drupal.org packaging script on 2016-05-25
version = "7.x-2.3"
core = "7.x"
project = "xmlsitemap"
datestamp = "1354931808"
datestamp = "1464191061"

View File

@@ -7,9 +7,9 @@ dependencies[] = i18n
files[] = xmlsitemap_i18n.module
files[] = xmlsitemap_i18n.test
; Information added by drupal.org packaging script on 2012-12-08
version = "7.x-2.0-rc2+0-dev"
; Information added by Drupal.org packaging script on 2016-05-25
version = "7.x-2.3"
core = "7.x"
project = "xmlsitemap"
datestamp = "1354931808"
datestamp = "1464191061"

View File

@@ -86,24 +86,24 @@ function xmlsitemap_i18n_query_xmlsitemap_generate_alter(QueryAlterableInterface
switch ($mode) {
case 'simple':
// Current language and language neutral.
$query->condition('language', array($current, LANGUAGE_NONE));
$query->condition('x.language', array($current, LANGUAGE_NONE));
break;
case 'mixed':
// Mixed current language (if available) or default language (if not) and language neutral.
$query->condition('language', array($current, $default, LANGUAGE_NONE));
$query->condition('x.language', array($current, $default, LANGUAGE_NONE));
break;
case 'default':
// Only default language and language neutral.
$query->condition('language', array($default, LANGUAGE_NONE));
$query->condition('x.language', array($default, LANGUAGE_NONE));
break;
case 'strict':
// Only current language (for nodes), simple for all other types.
$node_condition = db_and();
$node_condition->condition('type', 'node');
$node_condition->condition('language', $current);
$node_condition->condition('x.type', 'node');
$node_condition->condition('x.language', $current);
$normal_condition = db_and();
$normal_condition->condition('type', 'node', '<>');
$normal_condition->condition('language', array($current, LANGUAGE_NONE));
$normal_condition->condition('x.type', 'node', '<>');
$normal_condition->condition('x.language', array($current, LANGUAGE_NONE));
$condition = db_or();
$condition->condition($node_condition);
$condition->condition($normal_condition);

View File

@@ -8,9 +8,9 @@ files[] = xmlsitemap_menu.module
files[] = xmlsitemap_menu.install
files[] = xmlsitemap_menu.test
; Information added by drupal.org packaging script on 2012-12-08
version = "7.x-2.0-rc2+0-dev"
; Information added by Drupal.org packaging script on 2016-05-25
version = "7.x-2.3"
core = "7.x"
project = "xmlsitemap"
datestamp = "1354931808"
datestamp = "1464191061"

View File

@@ -31,6 +31,7 @@ function xmlsitemap_menu_entity_info_alter(&$info) {
'process callback' => 'xmlsitemap_menu_xmlsitemap_process_menu_links',
),
'bundle label' => t('Menu'),
'token type' => 'menu_link',
);
foreach (menu_get_menus() as $type => $name) {
@@ -45,6 +46,15 @@ function xmlsitemap_menu_entity_info_alter(&$info) {
);
}
}
else {
// If the entity type already exists ensure the xmlsitemap is added.
$info['menu_link'] += array(
'uri callback' => 'xmlsitemap_menu_menu_link_uri',
'xmlsitemap' => array(
'process callback' => 'xmlsitemap_menu_xmlsitemap_process_menu_links',
),
);
}
}
/**
@@ -93,7 +103,7 @@ function xmlsitemap_menu_xmlsitemap_process_menu_links(array $mlids, array $xmls
$menu_item['xmlsitemap'] = $xmlsitemap;
}
$link = xmlsitemap_menu_create_link($menu_item);
xmlsitemap_link_save($link);
xmlsitemap_link_save($link, array($link['type'] => $menu_item));
}
// Set the global user variable back to the original user.
@@ -278,3 +288,16 @@ function xmlsitemap_menu_variables() {
}
return $defaults;
}
/**
* Implements hook_features_pipe_COMPONENT_alter().
*
* Add variables to exported menus.
*/
function xmlsitemap_menu_features_pipe_menu_custom_alter(&$pipe, $data, $export) {
if (!empty($data)) {
foreach ($data as $menu_name) {
$pipe['variable'][] = "xmlsitemap_settings_menu_link_{$menu_name}";
}
}
}

View File

@@ -7,9 +7,9 @@ dependencies[] = ctools
files[] = xmlsitemap_modal.module
hidden = TRUE
; Information added by drupal.org packaging script on 2012-12-08
version = "7.x-2.0-rc2+0-dev"
; Information added by Drupal.org packaging script on 2016-05-25
version = "7.x-2.3"
core = "7.x"
project = "xmlsitemap"
datestamp = "1354931808"
datestamp = "1464191061"

View File

@@ -27,7 +27,7 @@ function xmlsitemap_modal_get_form() {
$form_state = array(
'ajax' => TRUE,
'args' => $args,
'build_info' => array('args' => $args),
);
$commands = ctools_modal_form_wrapper($form_id, $form_state);
@@ -37,8 +37,8 @@ function xmlsitemap_modal_get_form() {
$commands[] = ctools_ajax_command_redirect($_GET['destination']);
}
}
return ajax_render($commands);
//return ctools_ajax_render($commands);
print ajax_render($commands);
exit;
}
else {
array_unshift($args, $form_id);

View File

@@ -7,9 +7,9 @@ files[] = xmlsitemap_node.module
files[] = xmlsitemap_node.install
files[] = xmlsitemap_node.test
; Information added by drupal.org packaging script on 2012-12-08
version = "7.x-2.0-rc2+0-dev"
; Information added by Drupal.org packaging script on 2016-05-25
version = "7.x-2.3"
core = "7.x"
project = "xmlsitemap"
datestamp = "1354931808"
datestamp = "1464191061"

View File

@@ -40,7 +40,7 @@ function xmlsitemap_node_xmlsitemap_process_node_links(array $nids) {
$nodes = node_load_multiple($nids);
foreach ($nodes as $node) {
$link = xmlsitemap_node_create_link($node);
xmlsitemap_link_save($link);
xmlsitemap_link_save($link, array($link['type'] => $node));
}
}
@@ -56,7 +56,7 @@ function xmlsitemap_node_node_insert(stdClass $node) {
*/
function xmlsitemap_node_node_update(stdClass $node) {
$link = xmlsitemap_node_create_link($node);
xmlsitemap_link_save($link);
xmlsitemap_link_save($link, array($link['type'] => $node));
}
/**
@@ -146,7 +146,7 @@ function xmlsitemap_node_form_node_form_alter(array &$form, array &$form_state)
* An array of UNIX timestamp integers.
*/
function xmlsitemap_node_get_timestamps(stdClass $node) {
static $timestamps = array();
$timestamps = &drupal_static(__FUNCTION__, array());
if (!isset($timestamps[$node->nid])) {
$timestamps[$node->nid] = db_query("SELECT nr.timestamp FROM {node_revision} nr WHERE nr.nid = :nid", array(':nid' => $node->nid))->fetchCol();
@@ -331,3 +331,16 @@ function xmlsitemap_node_view_access($node, $account = NULL) {
return FALSE;
}
/**
* Implements hook_features_pipe_COMPONENT_alter().
*
* Add variables to exported node types.
*/
function xmlsitemap_node_features_pipe_node_alter(&$pipe, $data, $export) {
if (!empty($data)) {
foreach ($data as $node_type) {
$pipe['variable'][] = "xmlsitemap_settings_node_{$node_type}";
}
}
}

View File

@@ -8,9 +8,9 @@ files[] = xmlsitemap_taxonomy.module
files[] = xmlsitemap_taxonomy.install
files[] = xmlsitemap_taxonomy.test
; Information added by drupal.org packaging script on 2012-12-08
version = "7.x-2.0-rc2+0-dev"
; Information added by Drupal.org packaging script on 2016-05-25
version = "7.x-2.3"
core = "7.x"
project = "xmlsitemap"
datestamp = "1354931808"
datestamp = "1464191061"

View File

@@ -50,7 +50,7 @@ function xmlsitemap_taxonomy_xmlsitemap_process_taxonomy_term_links(array $tids)
$terms = taxonomy_term_load_multiple($tids);
foreach ($terms as $term) {
$link = xmlsitemap_taxonomy_create_link($term);
xmlsitemap_link_save($link);
xmlsitemap_link_save($link, array($link['type'] => $term));
}
}
@@ -107,7 +107,7 @@ function xmlsitemap_taxonomy_vocabulary_update(stdClass $vocabulary) {
*/
function xmlsitemap_taxonomy_term_insert(stdClass $term) {
$link = xmlsitemap_taxonomy_create_link($term);
xmlsitemap_link_save($link);
xmlsitemap_link_save($link, array($link['type'] => $term));
}
/**
@@ -115,7 +115,7 @@ function xmlsitemap_taxonomy_term_insert(stdClass $term) {
*/
function xmlsitemap_taxonomy_term_update(stdClass $term) {
$link = xmlsitemap_taxonomy_create_link($term);
xmlsitemap_link_save($link);
xmlsitemap_link_save($link, array($link['type'] => $term));
}
/**
@@ -263,3 +263,16 @@ function xmlsitemap_taxonomy_entity_query_alter($query) {
}
}
}
/**
* Implements hook_features_pipe_COMPONENT_alter().
*
* Add variables to exported taxonomy vocabularies.
*/
function xmlsitemap_taxonomy_features_pipe_taxonomy_alter(&$pipe, $data, $export) {
if (!empty($data)) {
foreach ($data as $vocabulary_name) {
$pipe['variable'][] = "xmlsitemap_settings_taxonomy_term_{$vocabulary_name}";
}
}
}

View File

@@ -7,9 +7,9 @@ files[] = xmlsitemap_user.module
files[] = xmlsitemap_user.install
files[] = xmlsitemap_user.test
; Information added by drupal.org packaging script on 2012-12-08
version = "7.x-2.0-rc2+0-dev"
; Information added by Drupal.org packaging script on 2016-05-25
version = "7.x-2.3"
core = "7.x"
project = "xmlsitemap"
datestamp = "1354931808"
datestamp = "1464191061"

View File

@@ -37,7 +37,7 @@ function xmlsitemap_user_xmlsitemap_process_user_links(array $uids) {
$accounts = user_load_multiple($uids);
foreach ($accounts as $account) {
$link = xmlsitemap_user_create_link($account);
xmlsitemap_link_save($link);
xmlsitemap_link_save($link, array($link['type'] => $account));
}
}
@@ -51,7 +51,7 @@ function xmlsitemap_user_user_presave(&$edit, $account, $category) {
$link = $edit['xmlsitemap'] + $link;
unset($edit['xmlsitemap']);
}
xmlsitemap_link_save($link);
xmlsitemap_link_save($link, array($link['type'] => $account));
}
}
@@ -60,7 +60,7 @@ function xmlsitemap_user_user_presave(&$edit, $account, $category) {
*/
function xmlsitemap_user_user_insert(&$edit, $account, $category) {
$link = xmlsitemap_user_create_link($account);
xmlsitemap_link_save($link);
xmlsitemap_link_save($link, array($link['type'] => $account));
}
/**
@@ -68,7 +68,7 @@ function xmlsitemap_user_user_insert(&$edit, $account, $category) {
*/
function xmlsitemap_user_user_update(&$edit, $account, $category) {
$link = xmlsitemap_user_create_link($account);
xmlsitemap_link_save($link);
xmlsitemap_link_save($link, array($link['type'] => $account));
}
/**

View File

@@ -27,7 +27,7 @@
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:output method="html" doctype-system="about:legacy-compat" encoding="UTF-8" indent="yes" />
<!-- Root template -->
<xsl:template match="/">
<html>

View File

@@ -28,9 +28,10 @@ $.tablesorter.addParser({
});
$(document).ready(function() {
// Set some location variales.
$('h1').append(': ' + location);
document.title += ': ' + location;
// Set some location variables.
var h1 = $('h1');
h1.text(h1.text() + ': ' + location);
document.title = h1.text();
$('table').tablesorter({
sortList: [[0,0]],