Commit 171018fb authored by RenatoG's avatar RenatoG Committed by RenatoG

Issue #2907549 by RenatoG: Fix Drupal Coding Standards for XML sitemap default folder

parent 28ea81cd
...@@ -48,7 +48,11 @@ function xmlsitemap_sitemap_list_form() { ...@@ -48,7 +48,11 @@ function xmlsitemap_sitemap_list_form() {
$header['context_' . $context_key] = $context_info['label']; $header['context_' . $context_key] = $context_info['label'];
} }
} }
$header['updated'] = array('data' => t('Last updated'), 'field' => 'updated', 'sort' => 'asc'); $header['updated'] = array(
'data' => t('Last updated'),
'field' => 'updated',
'sort' => 'asc',
);
$header['links'] = array('data' => t('Links'), 'field' => 'links'); $header['links'] = array('data' => t('Links'), 'field' => 'links');
$header['chunks'] = array('data' => t('Pages'), 'field' => 'chunks'); $header['chunks'] = array('data' => t('Pages'), 'field' => 'chunks');
$header['operations'] = array('data' => t('Operations')); $header['operations'] = array('data' => t('Operations'));
...@@ -150,6 +154,7 @@ function xmlsitemap_sitemap_list_form_submit($form, &$form_state) { ...@@ -150,6 +154,7 @@ function xmlsitemap_sitemap_list_form_submit($form, &$form_state) {
call_user_func_array($function, $args); call_user_func_array($function, $args);
$count = count($form_state['values']['sitemaps']); $count = count($form_state['values']['sitemaps']);
// @codingStandardsIgnoreLine
// watchdog('xmlsitemap', '@action @count XML sitemaps.', array('@action' => $operation['action past'], '@count' => $count));. // watchdog('xmlsitemap', '@action @count XML sitemaps.', array('@action' => $operation['action past'], '@count' => $count));.
drupal_set_message(format_plural(count($sitemaps), '@action @count XML sitemap.', '@action @count XML sitemaps.', array('@action' => $operation['action past'], '@count' => $count))); drupal_set_message(format_plural(count($sitemaps), '@action @count XML sitemap.', '@action @count XML sitemaps.', array('@action' => $operation['action past'], '@count' => $count)));
// $form_state['redirect'] = 'admin/config/search/xmlsitemap';. // $form_state['redirect'] = 'admin/config/search/xmlsitemap';.
...@@ -157,7 +162,7 @@ function xmlsitemap_sitemap_list_form_submit($form, &$form_state) { ...@@ -157,7 +162,7 @@ function xmlsitemap_sitemap_list_form_submit($form, &$form_state) {
} }
/** /**
* * Edit Form.
*/ */
function xmlsitemap_sitemap_edit_form(array $form, array &$form_state, stdClass $sitemap = NULL) { function xmlsitemap_sitemap_edit_form(array $form, array &$form_state, stdClass $sitemap = NULL) {
_xmlsitemap_set_breadcrumb(); _xmlsitemap_set_breadcrumb();
...@@ -199,7 +204,7 @@ function xmlsitemap_sitemap_edit_form(array $form, array &$form_state, stdClass ...@@ -199,7 +204,7 @@ function xmlsitemap_sitemap_edit_form(array $form, array &$form_state, stdClass
} }
/** /**
* * Edit Form Pre Render.
*/ */
function xmlsitemap_sitemap_edit_form_pre_render($form) { function xmlsitemap_sitemap_edit_form_pre_render($form) {
$visible_children = element_get_visible_children($form['context']); $visible_children = element_get_visible_children($form['context']);
...@@ -213,7 +218,7 @@ function xmlsitemap_sitemap_edit_form_pre_render($form) { ...@@ -213,7 +218,7 @@ function xmlsitemap_sitemap_edit_form_pre_render($form) {
} }
/** /**
* * Edit form validate.
*/ */
function xmlsitemap_sitemap_edit_form_validate($form, &$form_state) { function xmlsitemap_sitemap_edit_form_validate($form, &$form_state) {
// If there are no context options, the $form_state['values']['context'] // If there are no context options, the $form_state['values']['context']
...@@ -226,7 +231,7 @@ function xmlsitemap_sitemap_edit_form_validate($form, &$form_state) { ...@@ -226,7 +231,7 @@ function xmlsitemap_sitemap_edit_form_validate($form, &$form_state) {
} }
/** /**
* * Edit Form Submit.
*/ */
function xmlsitemap_sitemap_edit_form_submit($form, &$form_state) { function xmlsitemap_sitemap_edit_form_submit($form, &$form_state) {
form_state_values_clean($form_state); form_state_values_clean($form_state);
...@@ -237,7 +242,7 @@ function xmlsitemap_sitemap_edit_form_submit($form, &$form_state) { ...@@ -237,7 +242,7 @@ function xmlsitemap_sitemap_edit_form_submit($form, &$form_state) {
} }
/** /**
* * Delete form.
*/ */
function xmlsitemap_sitemap_delete_form(array $form, array &$form_state, stdClass $sitemap) { function xmlsitemap_sitemap_delete_form(array $form, array &$form_state, stdClass $sitemap) {
_xmlsitemap_set_breadcrumb(); _xmlsitemap_set_breadcrumb();
...@@ -263,7 +268,7 @@ function xmlsitemap_sitemap_delete_form(array $form, array &$form_state, stdClas ...@@ -263,7 +268,7 @@ function xmlsitemap_sitemap_delete_form(array $form, array &$form_state, stdClas
} }
/** /**
* * Delete form submit.
*/ */
function xmlsitemap_sitemap_delete_form_submit($form, $form_state) { function xmlsitemap_sitemap_delete_form_submit($form, $form_state) {
xmlsitemap_sitemap_delete($form_state['values']['smid']); xmlsitemap_sitemap_delete($form_state['values']['smid']);
...@@ -281,7 +286,18 @@ function xmlsitemap_settings_form($form, &$form_state) { ...@@ -281,7 +286,18 @@ function xmlsitemap_settings_form($form, &$form_state) {
$form['xmlsitemap_minimum_lifetime'] = array( $form['xmlsitemap_minimum_lifetime'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Minimum sitemap lifetime'), '#title' => t('Minimum sitemap lifetime'),
'#options' => array(0 => t('No minimum')) + drupal_map_assoc(array(300, 900, 1800, 3600, 10800, 21600, 43200, 86400, 172800, 259200, 604800), 'format_interval'), '#options' => array(0 => t('No minimum')) + drupal_map_assoc(array(300,
900,
1800,
3600,
10800,
21600,
43200,
86400,
172800,
259200,
604800,
), 'format_interval'),
'#description' => t('The minimum amount of time that will elapse before the sitemaps are regenerated. The sitemaps will also only be regenerated on cron if any links have been added, updated, or deleted.') . '<br />' . t('Recommended value: %value.', array('%value' => t('1 day'))), '#description' => t('The minimum amount of time that will elapse before the sitemaps are regenerated. The sitemaps will also only be regenerated on cron if any links have been added, updated, or deleted.') . '<br />' . t('Recommended value: %value.', array('%value' => t('1 day'))),
'#default_value' => variable_get('xmlsitemap_minimum_lifetime', 0), '#default_value' => variable_get('xmlsitemap_minimum_lifetime', 0),
); );
...@@ -305,16 +321,27 @@ function xmlsitemap_settings_form($form, &$form_state) { ...@@ -305,16 +321,27 @@ function xmlsitemap_settings_form($form, &$form_state) {
'#collapsed' => !variable_get('xmlsitemap_developer_mode', 0), '#collapsed' => !variable_get('xmlsitemap_developer_mode', 0),
'#weight' => 10, '#weight' => 10,
); );
// @codingStandardsIgnoreStart
// $form['advanced']['xmlsitemap_gz'] = array( // $form['advanced']['xmlsitemap_gz'] = array(
// '#type' => 'checkbox', // '#type' => 'checkbox',
// '#title' => t('Generate additional compressed sitemaps using gzip.'), // '#title' => t('Generate additional compressed sitemaps using gzip.'),
// '#default_value' => xmlsitemap_var('gz'), // '#default_value' => xmlsitemap_var('gz'),
// '#disabled' => !function_exists('gzencode'), // '#disabled' => !function_exists('gzencode'),
// );. // );.
// @codingStandardsIgnoreEnd
$form['advanced']['xmlsitemap_chunk_size'] = array( $form['advanced']['xmlsitemap_chunk_size'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Number of links in each sitemap page'), '#title' => t('Number of links in each sitemap page'),
'#options' => array('auto' => t('Automatic (recommended)')) + drupal_map_assoc(array(100, 500, 1000, 2500, 5000, 10000, 25000, XMLSITEMAP_MAX_SITEMAP_LINKS)), '#options' => array('auto' => t('Automatic (recommended)')) + drupal_map_assoc(array(
100,
500,
1000,
2500,
5000,
10000,
25000,
XMLSITEMAP_MAX_SITEMAP_LINKS,
)),
'#default_value' => xmlsitemap_var('chunk_size'), '#default_value' => xmlsitemap_var('chunk_size'),
// @todo This description is not clear. // @todo This description is not clear.
'#description' => t('If there are problems with rebuilding the sitemap, you may want to manually set this value. If you have more than @max links, an index with multiple sitemap pages will be generated. There is a maximum of @max sitemap pages.', array('@max' => XMLSITEMAP_MAX_SITEMAP_LINKS)), '#description' => t('If there are problems with rebuilding the sitemap, you may want to manually set this value. If you have more than @max links, an index with multiple sitemap pages will be generated. There is a maximum of @max sitemap pages.', array('@max' => XMLSITEMAP_MAX_SITEMAP_LINKS)),
...@@ -322,7 +349,18 @@ function xmlsitemap_settings_form($form, &$form_state) { ...@@ -322,7 +349,18 @@ function xmlsitemap_settings_form($form, &$form_state) {
$form['advanced']['xmlsitemap_batch_limit'] = array( $form['advanced']['xmlsitemap_batch_limit'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Maximum number of sitemap links to process at once'), '#title' => t('Maximum number of sitemap links to process at once'),
'#options' => drupal_map_assoc(array(5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000)), '#options' => drupal_map_assoc(array(
5,
10,
25,
50,
100,
250,
500,
1000,
2500,
5000,
)),
'#default_value' => xmlsitemap_var('batch_limit'), '#default_value' => xmlsitemap_var('batch_limit'),
'#description' => t('If you have problems running cron or rebuilding the sitemap, you may want to lower this value.'), '#description' => t('If you have problems running cron or rebuilding the sitemap, you may want to lower this value.'),
); );
...@@ -379,7 +417,11 @@ function xmlsitemap_settings_form($form, &$form_state) { ...@@ -379,7 +417,11 @@ function xmlsitemap_settings_form($form, &$form_state) {
'changefreq' => t('Change frequency: @changfreq', array('@changfreq' => '<changefreq>')), 'changefreq' => t('Change frequency: @changfreq', array('@changfreq' => '<changefreq>')),
'priority' => t('Priority: @priority', array('@priority' => '<priority>')), 'priority' => t('Priority: @priority', array('@priority' => '<priority>')),
), ),
'#default_value' => drupal_map_assoc(variable_get('xmlsitemap_output_elements', array('lastmod', 'changefreq', 'priority'))), '#default_value' => drupal_map_assoc(variable_get('xmlsitemap_output_elements', array(
'lastmod',
'changefreq',
'priority',
))),
); );
$form['xmlsitemap_settings'] = array( $form['xmlsitemap_settings'] = array(
...@@ -588,6 +630,7 @@ function xmlsitemap_add_form_entity_summary(&$form, $entity, array $entity_info) ...@@ -588,6 +630,7 @@ function xmlsitemap_add_form_entity_summary(&$form, $entity, array $entity_info)
function xmlsitemap_add_link_bundle_settings(array &$form, array &$form_state, $entity, $bundle) { function xmlsitemap_add_link_bundle_settings(array &$form, array &$form_state, $entity, $bundle) {
$entity_info = xmlsitemap_get_link_info($entity); $entity_info = xmlsitemap_get_link_info($entity);
// @codingStandardsIgnoreStart
// If (!isset($bundle) && isset($entity_info['bundle keys']['bundle'])) { // If (!isset($bundle) && isset($entity_info['bundle keys']['bundle'])) {
// $bundle_key = $entity_info['bundle keys']['bundle']; // $bundle_key = $entity_info['bundle keys']['bundle'];
// if (isset($form[$bundle_key]['#value'])) { // if (isset($form[$bundle_key]['#value'])) {
...@@ -597,6 +640,7 @@ function xmlsitemap_add_link_bundle_settings(array &$form, array &$form_state, $ ...@@ -597,6 +640,7 @@ function xmlsitemap_add_link_bundle_settings(array &$form, array &$form_state, $
// $bundle = $form[$bundle_key]['#default_value']; // $bundle = $form[$bundle_key]['#default_value'];
// } // }
// }. // }.
// @codingStandardsIgnoreEnd
$bundle_info = xmlsitemap_link_bundle_load($entity, $bundle); $bundle_info = xmlsitemap_link_bundle_load($entity, $bundle);
$form['xmlsitemap'] = array( $form['xmlsitemap'] = array(
...@@ -658,7 +702,7 @@ function xmlsitemap_add_link_bundle_settings(array &$form, array &$form_state, $ ...@@ -658,7 +702,7 @@ function xmlsitemap_add_link_bundle_settings(array &$form, array &$form_state, $
} }
/** /**
* * Link bundle settings form.
*/ */
function xmlsitemap_link_bundle_settings_form(array $form, array &$form_state, array $bundle) { function xmlsitemap_link_bundle_settings_form(array $form, array &$form_state, array $bundle) {
if (empty($form_state['ajax']) && $admin_path = xmlsitemap_get_bundle_path($bundle['entity'], $bundle['bundle'])) { if (empty($form_state['ajax']) && $admin_path = xmlsitemap_get_bundle_path($bundle['entity'], $bundle['bundle'])) {
...@@ -744,7 +788,12 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) { ...@@ -744,7 +788,12 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) {
$form['xmlsitemap']['description'] = array( $form['xmlsitemap']['description'] = array(
'#prefix' => '<div class="description">', '#prefix' => '<div class="description">',
'#suffix' => '</div>', '#suffix' => '</div>',
'#markup' => t('The default XML sitemap settings for this @bundle can be changed <a href="@link-type">here</a>.', array('@bundle' => drupal_strtolower($info['bundle label']), '@link-type' => url($path, array('query' => drupal_get_destination())))), '#markup' => t('The default XML sitemap settings for this @bundle can be changed <a href="@link-type">here</a>.', array(
'@bundle' => drupal_strtolower($info['bundle label']),
'@link-type' => url($path, array(
'query' => drupal_get_destination(),
)),
)),
); );
} }
...@@ -803,7 +852,7 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) { ...@@ -803,7 +852,7 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) {
'#type' => 'value', '#type' => 'value',
'#value' => $link['priority_override'], '#value' => $link['priority_override'],
); );
// @codingStandardsIgnoreStart
// Other persistent fields. // Other persistent fields.
// $form['xmlsitemap']['lastmod'] = array( // $form['xmlsitemap']['lastmod'] = array(
// '#type' => 'value', // '#type' => 'value',
...@@ -817,6 +866,7 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) { ...@@ -817,6 +866,7 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) {
// '#type' => 'value', // '#type' => 'value',
// '#value' => $node->xmlsitemap['changecount'], // '#value' => $node->xmlsitemap['changecount'],
// ); // );
// @codingStandardsIgnoreEnd
// Add the submit handler to adjust the default values if selected. // Add the submit handler to adjust the default values if selected.
$form += array('#submit' => array()); $form += array('#submit' => array());
if (!in_array('xmlsitemap_process_form_link_options', $form['#submit'])) { if (!in_array('xmlsitemap_process_form_link_options', $form['#submit'])) {
...@@ -827,12 +877,12 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) { ...@@ -827,12 +877,12 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) {
/** /**
* Get a list of priority options. * Get a list of priority options.
* *
* @param $default * @param string $default
* Include a 'default' option. * Include a 'default' option.
* @param $guides * @param string $guides
* Add helpful indicators for the highest, middle and lowest values. * Add helpful indicators for the highest, middle and lowest values.
* *
* @return * @return array
* An array of options. * An array of options.
*/ */
function xmlsitemap_get_priority_options($default = NULL, $guides = TRUE) { function xmlsitemap_get_priority_options($default = NULL, $guides = TRUE) {
...@@ -871,10 +921,10 @@ function xmlsitemap_get_priority_options($default = NULL, $guides = TRUE) { ...@@ -871,10 +921,10 @@ function xmlsitemap_get_priority_options($default = NULL, $guides = TRUE) {
/** /**
* Get a list of priority options. * Get a list of priority options.
* *
* @param $default * @param string $default
* Include a 'default' option. * Include a 'default' option.
* *
* @return * @return array
* An array of options. * An array of options.
* *
* @see _xmlsitemap_translation_strings() * @see _xmlsitemap_translation_strings()
......
...@@ -74,7 +74,7 @@ function hook_xmlsitemap_link_alter(array &$link, array $context) { ...@@ -74,7 +74,7 @@ function hook_xmlsitemap_link_alter(array &$link, array $context) {
/** /**
* Inform modules that an XML sitemap link has been created. * Inform modules that an XML sitemap link has been created.
* *
* @param $link * @param array $link
* Associative array defining an XML sitemap link as passed into * Associative array defining an XML sitemap link as passed into
* xmlsitemap_link_save(). * xmlsitemap_link_save().
* @param array $context * @param array $context
...@@ -95,7 +95,7 @@ function hook_xmlsitemap_link_insert(array $link, array $context) { ...@@ -95,7 +95,7 @@ function hook_xmlsitemap_link_insert(array $link, array $context) {
/** /**
* Inform modules that an XML sitemap link has been updated. * Inform modules that an XML sitemap link has been updated.
* *
* @param $link * @param array $link
* Associative array defining an XML sitemap link as passed into * Associative array defining an XML sitemap link as passed into
* xmlsitemap_link_save(). * xmlsitemap_link_save().
* @param array $context * @param array $context
...@@ -230,6 +230,8 @@ function hook_xmlsitemap_element_alter(array &$element, array $link, $sitemap) { ...@@ -230,6 +230,8 @@ function hook_xmlsitemap_element_alter(array &$element, array $link, $sitemap) {
* Alter the attributes used for the root element of the XML sitemap. * Alter the attributes used for the root element of the XML sitemap.
* *
* For example add an xmlns:video attribute: * For example add an xmlns:video attribute:
*
* @codingStandardsIgnoreStart
* <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"> * <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
* *
* @param array $attributes * @param array $attributes
...@@ -239,13 +241,14 @@ function hook_xmlsitemap_element_alter(array &$element, array $link, $sitemap) { ...@@ -239,13 +241,14 @@ function hook_xmlsitemap_element_alter(array &$element, array $link, $sitemap) {
* The sitemap that is currently being generated. * The sitemap that is currently being generated.
*/ */
function hook_xmlsitemap_root_attributes_alter(&$attributes, $sitemap) { function hook_xmlsitemap_root_attributes_alter(&$attributes, $sitemap) {
// @codingStandardsIgnoreEnd
$attributes['xmlns:video'] = 'http://www.google.com/schemas/sitemap-video/1.1'; $attributes['xmlns:video'] = 'http://www.google.com/schemas/sitemap-video/1.1';
} }
/** /**
* Alter the query selecting data from {xmlsitemap} during sitemap generation. * Alter the query selecting data from {xmlsitemap} during sitemap generation.
* *
* @param $query * @param QueryAlterableInterface $query
* A Query object describing the composite parts of a SQL query. * A Query object describing the composite parts of a SQL query.
* *
* @see hook_query_TAG_alter() * @see hook_query_TAG_alter()
...@@ -277,7 +280,7 @@ function hook_xmlsitemap_sitemap_operations() { ...@@ -277,7 +280,7 @@ function hook_xmlsitemap_sitemap_operations() {
* This hook is invoked from xmlsitemap_sitemap_delete_multiple() after the XML * This hook is invoked from xmlsitemap_sitemap_delete_multiple() after the XML
* sitemap has been removed from the table in the database. * sitemap has been removed from the table in the database.
* *
* @param $sitemap * @param object $sitemap
* The XML sitemap object that was deleted. * The XML sitemap object that was deleted.
*/ */
function hook_xmlsitemap_sitemap_delete(stdClass $sitemap) { function hook_xmlsitemap_sitemap_delete(stdClass $sitemap) {
......
...@@ -164,7 +164,11 @@ function drush_xmlsitemap_queue_rebuild() { ...@@ -164,7 +164,11 @@ function drush_xmlsitemap_queue_rebuild() {
} }
if ($link_count) { 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'); 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 { else {
drush_log(dt('No links to queue for rebuild processing.'), 'ok'); drush_log(dt('No links to queue for rebuild processing.'), 'ok');
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
* at once so that only one database query is executed instead of several or * at once so that only one database query is executed instead of several or
* possibly thousands during sitemap generation. * possibly thousands during sitemap generation.
* *
* @param $path * @param string $path
* An internal Drupal path. * An internal Drupal path.
* @param $language * @param string $language
* A language code to use when looking up the paths. * A language code to use when looking up the paths.
*/ */
function xmlsitemap_get_path_alias($path, $language) { function xmlsitemap_get_path_alias($path, $language) {
...@@ -78,7 +78,7 @@ function _xmlsitemap_regenerate_before() { ...@@ -78,7 +78,7 @@ function _xmlsitemap_regenerate_before() {
} }
/** /**
* * Get Memory Usage.
*/ */
function _xmlsitemap_get_memory_usage($start = FALSE) { function _xmlsitemap_get_memory_usage($start = FALSE) {
static $memory_start; static $memory_start;
...@@ -116,7 +116,7 @@ function _xmlsitemap_get_optimal_memory_limit() { ...@@ -116,7 +116,7 @@ function _xmlsitemap_get_optimal_memory_limit() {
/** /**
* Calculate the optimal memory level for sitemap generation. * Calculate the optimal memory level for sitemap generation.
* *
* @param $new_limit * @param string $new_limit
* An optional PHP memory limit in bytes. If not provided, the value of * An optional PHP memory limit in bytes. If not provided, the value of
* _xmlsitemap_get_optimal_memory_limit() will be used. * _xmlsitemap_get_optimal_memory_limit() will be used.
*/ */
...@@ -135,9 +135,9 @@ function _xmlsitemap_set_memory_limit($new_limit = NULL) { ...@@ -135,9 +135,9 @@ function _xmlsitemap_set_memory_limit($new_limit = NULL) {
/** /**
* Generate one page (chunk) of the sitemap. * Generate one page (chunk) of the sitemap.
* *
* @param $sitemap * @param object $sitemap
* An unserialized data array for an XML sitemap. * An unserialized data array for an XML sitemap.
* @param $page * @param string $page
* An integer of the specific page of the sitemap to generate. * An integer of the specific page of the sitemap to generate.
*/ */
function xmlsitemap_generate_page(stdClass $sitemap, $page) { function xmlsitemap_generate_page(stdClass $sitemap, $page) {
...@@ -150,17 +150,20 @@ function xmlsitemap_generate_page(stdClass $sitemap, $page) { ...@@ -150,17 +150,20 @@ function xmlsitemap_generate_page(stdClass $sitemap, $page) {
catch (Exception $e) { catch (Exception $e) {
watchdog_exception('xmlsitemap', $e); watchdog_exception('xmlsitemap', $e);
throw $e; throw $e;
return FALSE;
} }
return $writer->getSitemapElementCount(); return $writer->getSitemapElementCount();
} }
/** /**
* * Generate chunk.
*/ */
function xmlsitemap_generate_chunk(stdClass $sitemap, XMLSitemapWriter $writer, $chunk) { function xmlsitemap_generate_chunk(stdClass $sitemap, XMLSitemapWriter $writer, $chunk) {
$output_elements = drupal_map_assoc(variable_get('xmlsitemap_output_elements', array('lastmod', 'changefreq', 'priority'))); $output_elements = drupal_map_assoc(variable_get('xmlsitemap_output_elements', array(
'lastmod',
'changefreq',
'priority',
)));
$lastmod_format = variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM); $lastmod_format = variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM);
$url_options = $sitemap->uri['options']; $url_options = $sitemap->uri['options'];
...@@ -175,7 +178,19 @@ function xmlsitemap_generate_chunk(stdClass $sitemap, XMLSitemapWriter $writer, ...@@ -175,7 +178,19 @@ function xmlsitemap_generate_chunk(stdClass $sitemap, XMLSitemapWriter $writer,
$link_count = 0; $link_count = 0;
$query = db_select('xmlsitemap', 'x'); $query = db_select('xmlsitemap', 'x');
$query->fields('x', array('id', 'type', 'subtype', '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.access', 1);
$query->condition('x.status', 1); $query->condition('x.status', 1);
$query->orderBy('x.language', 'DESC'); $query->orderBy('x.language', 'DESC');
...@@ -247,7 +262,7 @@ function xmlsitemap_generate_chunk(stdClass $sitemap, XMLSitemapWriter $writer, ...@@ -247,7 +262,7 @@ function xmlsitemap_generate_chunk(stdClass $sitemap, XMLSitemapWriter $writer,
/** /**
* Generate the index sitemap. * Generate the index sitemap.
* *
* @param $sitemap * @param object $sitemap
* An unserialized data array for an XML sitemap. * An unserialized data array for an XML sitemap.
*/ */
function xmlsitemap_generate_index(stdClass $sitemap) { function xmlsitemap_generate_index(stdClass $sitemap) {
...@@ -260,21 +275,20 @@ function xmlsitemap_generate_index(stdClass $sitemap) { ...@@ -260,21 +275,20 @@ function xmlsitemap_generate_index(stdClass $sitemap) {
catch (Exception $e) { catch (Exception $e) {
watchdog_exception('xmlsitemap', $e); watchdog_exception('xmlsitemap', $e);
throw $e; throw $e;
return FALSE;
} }
return $writer->getSitemapElementCount(); return $writer->getSitemapElementCount();
} }
// BATCH OPERATIONS ------------------------------------------------------------.
/** /**
* BATCH OPERATIONS -----------------------------------------------------------.
*
* Batch information callback for regenerating the sitemap files. * Batch information callback for regenerating the sitemap files.
* *
* @param $smids * @param array $smids
* An optional array of XML sitemap IDs. If not provided, it will load all * An optional array of XML sitemap IDs. If not provided, it will load all
* existing XML sitemaps. * existing XML sitemaps.
*/ */
function xmlsitemap_regenerate_batch(array $smids = array()) { function xmlsitemap_regenerate_batch(array $smids = array()) {
if (empty($smids)) { if (empty($smids)) {
$smids = db_query("SELECT smid FROM {xmlsitemap_sitemap}")->fetchCol(); $smids = db_query("SELECT smid FROM {xmlsitemap_sitemap}")->fetchCol();
...@@ -398,7 +412,9 @@ function xmlsitemap_rebuild_batch(array $entities, $save_custom = FALSE) { ...@@ -398,7 +412,9 @@ function xmlsitemap_rebuild_batch(array $entities, $save_custom = FALSE) {
$batch['operations'][] = array('xmlsitemap_batch_variable_set', array(array('xmlsitemap_rebuild_needed' => TRUE))); $batch['operations'][] = array('xmlsitemap_batch_variable_set', array(array('xmlsitemap_rebuild_needed' => TRUE)));
// Purge any links first. // Purge any links first.
$batch['operations'][] = array('xmlsitemap_rebuild_batch_clear', array($entities, (bool) $save_custom)); $batch['operations'][] = array('xmlsitemap_rebuild_batch_clear',
array($entities, (bool) $save_custom),
);
// Fetch all the sitemap links and save them to the {xmlsitemap} table. // Fetch all the sitemap links and save them to the {xmlsitemap} table.
foreach ($entities as $entity) { foreach ($entities as $entity) {
...@@ -484,7 +500,12 @@ function xmlsitemap_rebuild_batch_fetch($entity, &$context) { ...@@ -484,7 +500,12 @@ function xmlsitemap_rebuild_batch_fetch($entity, &$context) {
$info['xmlsitemap']['process callback']($ids); $info['xmlsitemap']['process callback']($ids);
$context['sandbox']['last_id'] = end($ids); $context['sandbox']['last_id'] = end($ids);
$context['sandbox']['progress'] += count($ids); $context['sandbox']['progress'] += count($ids);
$context['message'] = t('Now processing %entity @last_id (@progress of @count).', array('%entity' => $entity, '@last_id' => $context['sandbox']['last_id'], '@progress' => $context['sandbox']['progress'], '@count' => $context['sandbox']['max'])); $context['message'] = t('Now processing %entity @last_id (@progress of @count).', array(
'%entity' => $entity,
'@last_id' => $context['sandbox']['last_id'],
'@progress' => $context['sandbox']['progress'],
'@count' => $context['sandbox']['max'],
));
if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { if ($context['sandbox']['progress'] >= $context['sandbox']['max']) {
$context['finished'] = 1; $context['finished'] = 1;
...@@ -507,7 +528,7 @@ function xmlsitemap_rebuild_batch_finished($success, $results, $operations, $ela ...@@ -507,7 +528,7 @@ function xmlsitemap_rebuild_batch_finished($success, $results, $operations, $ela
} }
/** /**
* * Get Rebuildable link types.
*/ */
function xmlsitemap_get_rebuildable_link_types() { function xmlsitemap_get_rebuildable_link_types() {
$rebuild_types = array(); $rebuild_types = array();
......
...@@ -19,11 +19,11 @@ function _xmlsitemap_get_blurb($check_version = TRUE) { ...@@ -19,11 +19,11 @@ function _xmlsitemap_get_blurb($check_version = TRUE) {
$blurb = FALSE; $blurb = FALSE;
if (!$check_version || (($version = _xmlsitemap_get_version()) && preg_match('/dev|unstable|alpha|beta|HEAD/i', $version))) { if (!$check_version || (($version = _xmlsitemap_get_version()) && preg_match('/dev|unstable|alpha|beta|HEAD/i', $version))) {
$sponsors = array( $sponsors = array(
l('Symantec', 'http://www.symantec.com/'), l(t('Symantec'), 'http://www.symantec.com/'),
l('WebWise Solutions', 'http://www.webwiseone.com/'), l(t('WebWise Solutions'), 'http://www.webwiseone.com/'),
l('Volacci', 'http://www.volacci.com/'), l(t('Volacci'), 'http://www.volacci.com/'),
l('lanetro', 'http://www.lanetro.com/'), l(t('lanetro'), 'http://www.lanetro.com/'),
l('Coupons Dealuxe', 'http://couponsdealuxe.com/'), l(t('Coupons Dealuxe'), 'http://couponsdealuxe.com/'),
); );
// Don't extract the following string for translation. // Don't extract the following string for translation.
$blurb = '<div class="description"><p>Thank you for helping test the XML sitemap module rewrite. Please consider helping offset developer free time by <a href="http://davereid.chipin.com/">donating</a> or if your company is interested in sponsoring the rewrite or a specific feature, please <a href="http://davereid.net/contact">contact the developer</a>. Thank you to the following current sponsors: ' . implode(', ', $sponsors) . ', and all the individuals that have donated. This message will not be seen in the stable versions.</p></div>'; $blurb = '<div class="description"><p>Thank you for helping test the XML sitemap module rewrite. Please consider helping offset developer free time by <a href="http://davereid.chipin.com/">donating</a> or if your company is interested in sponsoring the rewrite or a specific feature, please <a href="http://davereid.net/contact">contact the developer</a>. Thank you to the following current sponsors: ' . implode(', ', $sponsors) . ', and all the individuals that have donated. This message will not be seen in the stable versions.</p></div>';
...@@ -35,7 +35,7 @@ function _xmlsitemap_get_blurb($check_version = TRUE) { ...@@ -35,7 +35,7 @@ function _xmlsitemap_get_blurb($check_version = TRUE) {
} }
/** /**
* * Get version.
*/ */
function _xmlsitemap_get_version() { function _xmlsitemap_get_version() {
static $version; static $version;
......
name = XML sitemap name = XML sitemap
# @codingStandardsIgnoreFile
description = Creates an XML sitemap conforming to the <a href="http://sitemaps.org/">sitemaps.org protocol</a>. description = Creates an XML sitemap conforming to the <a href="http://sitemaps.org/">sitemaps.org protocol</a>.
package = XML sitemap package = XML sitemap
core = 7.x core = 7.x
files[] = xmlsitemap.module
files[] = xmlsitemap.inc files[] = xmlsitemap.inc
files[] = xmlsitemap.admin.inc files[] = xmlsitemap.admin.inc
files[] = xmlsitemap.drush.inc files[] = xmlsitemap.drush.inc
files[] = xmlsitemap.generate.inc files[] = xmlsitemap.generate.inc
files[] = xmlsitemap.xmlsitemap.inc files[] = xmlsitemap.xmlsitemap.inc
files[] = xmlsitemap.pages.inc files[] = xmlsitemap.pages.inc
files[] = xmlsitemap.install
files[] = xmlsitemap.test files[] = xmlsitemap.test
recommends[] = robotstxt recommends[] = robotstxt
configure = admin/config/search/xmlsitemap configure = admin/config/search/xmlsitemap
...@@ -62,7 +62,11 @@ function xmlsitemap_requirements($phase) { ...@@ -62,7 +62,11 @@ function xmlsitemap_requirements($phase) {
if (!empty($directories)) { if (!empty($directories)) {
$requirements['xmlsitemap_directory']['value'] = $t('Not found or not writable'); $requirements['xmlsitemap_directory']['value'] = $t('Not found or not writable');
$requirements['xmlsitemap_directory']['severity'] = REQUIREMENT_ERROR; $requirements['xmlsitemap_directory']['severity'] = REQUIREMENT_ERROR;
$requirements['xmlsitemap_directory']['description'] = $t('The following directories were not found or are not writable by the server. See <a href="@docpage">@docpage</a> for more information. !directories', array('!directories' => theme('item_list', array('items' => array_keys($directories))), '@docpage' => 'http://drupal.org/node/34025')); $requirements['xmlsitemap_directory']['description'] = $t('The following directories were not found or are not writable by the server. See <a href="@docpage">@docpage</a> for more information. !directories', array(
'!directories' => theme('item_list', array(
'items' => array_keys($directories),
)), '@docpage' => 'http://drupal.org/node/34025',
));
} }
} }
...@@ -111,7 +115,10 @@ function xmlsitemap_requirements($phase) { ...@@ -111,7 +115,10 @@ function xmlsitemap_requirements($phase) {
$generated_ago = REQUEST_TIME - $generated_last; $generated_ago = REQUEST_TIME - $generated_last;
$requirements['xmlsitemap_generated'] = array( $requirements['xmlsitemap_generated'] = array(
'title' => $t('XML sitemap'), 'title' => $t('XML sitemap'),
'value' => $generated_last ? $t('Last attempted generation on !date (!interval ago).', array('!date' => format_date($generated_last, 'small'), '!interval' => format_interval($generated_ago))) : $t('Cached files have not been generated yet.'), 'value' => $generated_last ? $t('Last attempted generation on !date (!interval ago).', array(
'!date' => format_date($generated_last, 'small'),
'!interval' => format_interval($generated_ago),
)) : $t('Cached files have not been generated yet.'),
'severity' => REQUIREMENT_OK, 'severity' => REQUIREMENT_OK,
); );
if (variable_get('xmlsitemap_rebuild_needed', FALSE) && _xmlsitemap_rebuild_form_access()) { if (variable_get('xmlsitemap_rebuild_needed', FALSE) && _xmlsitemap_rebuild_form_access()) {
...@@ -286,6 +293,7 @@ function xmlsitemap_schema() { ...@@ -286,6 +293,7 @@ function xmlsitemap_schema() {
'not null' => TRUE, 'not null' =&