Commit 28ea81cd authored by RenatoG's avatar RenatoG Committed by RenatoG

Issue #2906673 by RenatoG: Fix Drupal Sniffer and Best Practices for XML sitemap Main files

parent 27d8fc6f
......@@ -35,8 +35,8 @@ function xmlsitemap_sitemap_list_form() {
$form['operations']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
//'#validate' => array('xmlsitemap_sitemap_list_form_validate'),
//'#submit' => array('xmlsitemap_sitemap_list_form_submit'),
// '#validate' => array('xmlsitemap_sitemap_list_form_validate'),
// '#submit' => array('xmlsitemap_sitemap_list_form_submit'),.
);
$contexts = xmlsitemap_get_context_info();
......@@ -82,8 +82,7 @@ function xmlsitemap_sitemap_list_form() {
$options[$smid]['chunks'] = $sitemap->updated ? $sitemap->chunks : '-';
// @todo Highlight sitemaps that need updating.
//$options[$smid]['#attributes']['class'][] = 'warning';
// $options[$smid]['#attributes']['class'][] = 'warning';
$operations = array();
$operations['edit'] = xmlsitemap_get_operation_link('admin/config/search/xmlsitemap/edit/' . $smid, array('title' => t('Edit'), 'modal' => TRUE));
$operations['delete'] = xmlsitemap_get_operation_link('admin/config/search/xmlsitemap/delete/' . $smid, array('title' => t('Delete'), 'modal' => TRUE));
......@@ -151,12 +150,15 @@ function xmlsitemap_sitemap_list_form_submit($form, &$form_state) {
call_user_func_array($function, $args);
$count = count($form_state['values']['sitemaps']);
//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)));
//$form_state['redirect'] = 'admin/config/search/xmlsitemap';
// $form_state['redirect'] = 'admin/config/search/xmlsitemap';.
}
}
/**
*
*/
function xmlsitemap_sitemap_edit_form(array $form, array &$form_state, stdClass $sitemap = NULL) {
_xmlsitemap_set_breadcrumb();
......@@ -196,6 +198,9 @@ function xmlsitemap_sitemap_edit_form(array $form, array &$form_state, stdClass
return $form;
}
/**
*
*/
function xmlsitemap_sitemap_edit_form_pre_render($form) {
$visible_children = element_get_visible_children($form['context']);
if (empty($visible_children)) {
......@@ -207,6 +212,9 @@ function xmlsitemap_sitemap_edit_form_pre_render($form) {
return $form;
}
/**
*
*/
function xmlsitemap_sitemap_edit_form_validate($form, &$form_state) {
// If there are no context options, the $form_state['values']['context']
// disappears.
......@@ -217,6 +225,9 @@ function xmlsitemap_sitemap_edit_form_validate($form, &$form_state) {
}
}
/**
*
*/
function xmlsitemap_sitemap_edit_form_submit($form, &$form_state) {
form_state_values_clean($form_state);
$sitemap = (object) $form_state['values'];
......@@ -225,6 +236,9 @@ function xmlsitemap_sitemap_edit_form_submit($form, &$form_state) {
$form_state['redirect'] = 'admin/config/search/xmlsitemap';
}
/**
*
*/
function xmlsitemap_sitemap_delete_form(array $form, array &$form_state, stdClass $sitemap) {
_xmlsitemap_set_breadcrumb();
......@@ -248,6 +262,9 @@ function xmlsitemap_sitemap_delete_form(array $form, array &$form_state, stdClas
);
}
/**
*
*/
function xmlsitemap_sitemap_delete_form_submit($form, $form_state) {
xmlsitemap_sitemap_delete($form_state['values']['smid']);
drupal_set_message(t('The sitemap has been deleted.'));
......@@ -288,12 +305,12 @@ function xmlsitemap_settings_form($form, &$form_state) {
'#collapsed' => !variable_get('xmlsitemap_developer_mode', 0),
'#weight' => 10,
);
//$form['advanced']['xmlsitemap_gz'] = array(
// $form['advanced']['xmlsitemap_gz'] = array(
// '#type' => 'checkbox',
// '#title' => t('Generate additional compressed sitemaps using gzip.'),
// '#default_value' => xmlsitemap_var('gz'),
// '#disabled' => !function_exists('gzencode'),
//);
// );.
$form['advanced']['xmlsitemap_chunk_size'] = array(
'#type' => 'select',
'#title' => t('Number of links in each sitemap page'),
......@@ -425,7 +442,7 @@ function xmlsitemap_settings_form_validate($form, &$form_state) {
}
/**
* Submit handler;
* Submit handler;.
*
* @see xmlsitemap_settings_form()
*/
......@@ -571,7 +588,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) {
$entity_info = xmlsitemap_get_link_info($entity);
//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'];
// if (isset($form[$bundle_key]['#value'])) {
// $bundle = $form[$bundle_key]['#value'];
......@@ -579,8 +596,7 @@ function xmlsitemap_add_link_bundle_settings(array &$form, array &$form_state, $
// elseif (isset($form[$bundle_key]['#default_value'])) {
// $bundle = $form[$bundle_key]['#default_value'];
// }
//}
// }.
$bundle_info = xmlsitemap_link_bundle_load($entity, $bundle);
$form['xmlsitemap'] = array(
......@@ -641,6 +657,9 @@ function xmlsitemap_add_link_bundle_settings(array &$form, array &$form_state, $
}
}
/**
*
*/
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 this is a non-ajax form, redirect to the bundle administration page.
......@@ -649,7 +668,7 @@ function xmlsitemap_link_bundle_settings_form(array $form, array &$form_state, a
drupal_goto($admin_path, array('query' => $destination));
}
else {
drupal_set_title( t('@bundle XML sitemap settings', array('@bundle' => $bundle['info']['label'])));
drupal_set_title(t('@bundle XML sitemap settings', array('@bundle' => $bundle['info']['label'])));
}
$form = array();
......@@ -756,7 +775,7 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) {
'#value' => $link['status_override'],
);
// Priority field
// Priority field.
$form['xmlsitemap']['priority'] = array(
'#type' => 'select',
'#title' => t('Priority'),
......@@ -786,19 +805,18 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) {
);
// Other persistent fields.
//$form['xmlsitemap']['lastmod'] = array(
// $form['xmlsitemap']['lastmod'] = array(
// '#type' => 'value',
// '#value' => $node->xmlsitemap['lastmod'],
//);
//$form['xmlsitemap']['changefreq'] = array(
// );
// $form['xmlsitemap']['changefreq'] = array(
// '#type' => 'value',
// '#value' => $node->xmlsitemap['changefreq'],
//);
//$form['xmlsitemap']['changecount'] = array(
// );
// $form['xmlsitemap']['changecount'] = array(
// '#type' => 'value',
// '#value' => $node->xmlsitemap['changecount'],
//);
// );
// Add the submit handler to adjust the default values if selected.
$form += array('#submit' => array());
if (!in_array('xmlsitemap_process_form_link_options', $form['#submit'])) {
......@@ -813,6 +831,7 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) {
* Include a 'default' option.
* @param $guides
* Add helpful indicators for the highest, middle and lowest values.
*
* @return
* An array of options.
*/
......@@ -854,6 +873,7 @@ function xmlsitemap_get_priority_options($default = NULL, $guides = TRUE) {
*
* @param $default
* Include a 'default' option.
*
* @return
* An array of options.
*
......
......@@ -24,9 +24,9 @@ function hook_xmlsitemap_link_info() {
'label' => 'My module',
'base table' => 'mymodule',
'entity keys' => array(
// Primary ID key on {base table}
// Primary ID key on {base table}.
'id' => 'myid',
// Subtype key on {base table}
// Subtype key on {base table}.
'bundle' => 'mysubtype',
),
'path callback' => 'mymodule_path',
......@@ -52,7 +52,7 @@ function hook_xmlsitemap_link_info() {
'rebuild callback' => '',
// Callback function called from the XML sitemap settings page.
'settings callback' => '',
)
),
),
);
}
......@@ -136,7 +136,7 @@ function hook_xmlsitemap_index_links($limit) {
/**
* Provide information about contexts available to XML sitemap.
*
* @see hook_xmlsitemap_context_info_alter().
* @see hook_xmlsitemap_context_info_alter()
*/
function hook_xmlsitemap_context_info() {
$info['vocabulary'] = array(
......@@ -150,7 +150,7 @@ function hook_xmlsitemap_context_info() {
/**
* Alter XML sitemap context info.
*
* @see hook_xmlsitemap_context_info().
* @see hook_xmlsitemap_context_info()
*/
function hook_xmlsitemap_context_info_alter(&$info) {
$info['vocabulary']['label'] = t('Site vocabularies');
......
......@@ -70,13 +70,16 @@ function _xmlsitemap_regenerate_before() {
if (variable_get('xmlsitemap_developer_mode', 0)) {
watchdog('xmlsitemap', 'Starting XML sitemap generation. Memory usage: @memory-peak.', array(
'@memory-peak' => format_size(memory_get_peak_usage(TRUE)),
),
'@memory-peak' => format_size(memory_get_peak_usage(TRUE)),
),
WATCHDOG_DEBUG
);
}
}
/**
*
*/
function _xmlsitemap_get_memory_usage($start = FALSE) {
static $memory_start;
$current = memory_get_peak_usage(TRUE);
......@@ -153,6 +156,9 @@ function xmlsitemap_generate_page(stdClass $sitemap, $page) {
return $writer->getSitemapElementCount();
}
/**
*
*/
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);
......@@ -260,8 +266,7 @@ function xmlsitemap_generate_index(stdClass $sitemap) {
return $writer->getSitemapElementCount();
}
// BATCH OPERATIONS ------------------------------------------------------------
// BATCH OPERATIONS ------------------------------------------------------------.
/**
* Batch information callback for regenerating the sitemap files.
*
......@@ -269,15 +274,16 @@ function xmlsitemap_generate_index(stdClass $sitemap) {
* An optional array of XML sitemap IDs. If not provided, it will load all
* existing XML sitemaps.
*/
function xmlsitemap_regenerate_batch(array $smids = array()) {
if (empty($smids)) {
$smids = db_query("SELECT smid FROM {xmlsitemap_sitemap}")->fetchCol();
}
//$t = get_t();
// $t = get_t();
$batch = array(
'operations' => array(),
//'error_message' => $t('An error has occurred.'),
// 'error_message' => $t('An error has occurred.'),.
'finished' => 'xmlsitemap_regenerate_batch_finished',
'title' => t('Regenerating Sitemap'),
'file' => drupal_get_path('module', 'xmlsitemap') . '/xmlsitemap.generate.inc',
......@@ -361,7 +367,7 @@ function xmlsitemap_regenerate_batch_generate_index($smid, array &$context) {
function xmlsitemap_regenerate_batch_finished($success, $results, $operations, $elapsed) {
if ($success && !variable_get('xmlsitemap_regenerate_needed', FALSE)) {
variable_set('xmlsitemap_generated_last', REQUEST_TIME);
//drupal_set_message(t('The sitemaps were regenerated.'));
// drupal_set_message(t('The sitemaps were regenerated.'));
// Show a watchdog message that the sitemap was regenerated.
watchdog('xmlsitemap',
'Finished XML sitemap generation in @elapsed. Memory usage: @memory-peak.',
......@@ -468,7 +474,8 @@ function xmlsitemap_rebuild_batch_fetch($entity, &$context) {
// PostgreSQL cannot have the ORDERED BY in the count query.
$query->entityOrderBy('entity_id');
$limit = 20; //variable_get('xmlsitemap_batch_limit', 100)
// variable_get('xmlsitemap_batch_limit', 100)
$limit = 20;
$query->range(0, $limit);
$result = $query->execute();
......@@ -499,6 +506,9 @@ function xmlsitemap_rebuild_batch_finished($success, $results, $operations, $ela
}
}
/**
*
*/
function xmlsitemap_get_rebuildable_link_types() {
$rebuild_types = array();
$entities = xmlsitemap_get_link_info();
......
......@@ -27,13 +27,16 @@ function _xmlsitemap_get_blurb($check_version = TRUE) {
);
// 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>';
//http://drupalmodules.com/module/xml-sitemap
// http://drupalmodules.com/module/xml-sitemap
}
}
return $blurb;
}
/**
*
*/
function _xmlsitemap_get_version() {
static $version;
if (!isset($version)) {
......
......@@ -214,8 +214,8 @@ function xmlsitemap_schema() {
'type' => 'float',
'default' => NULL,
// @todo Convert this field to non-nullable.
//'default' => 0.5,
//'not null' => NULL,
// 'default' => 0.5,
// 'not null' => NULL,
),
'priority_override' => array(
'description' => 'A boolean that if TRUE means that the priority field has been overridden from its default value.',
......@@ -286,13 +286,13 @@ function xmlsitemap_schema() {
'not null' => TRUE,
'default' => 0,
),
//'queued' => array(
// 'queued' => array(
// 'type' => 'int',
// 'unsigned' => TRUE,
// 'not null' => TRUE,
// 'default' => 0,
// 'description' => 'Time when this sitemap was queued for regeneration, 0 if not queued.',
//),
// ),.
),
'primary key' => array('smid'),
);
......@@ -554,6 +554,9 @@ function xmlsitemap_update_7203() {
_xmlsitemap_sitemap_rehash_all();
}
/**
*
*/
function _xmlsitemap_sitemap_rehash_all() {
// Reload the schema cache and reprocess all sitemap hashes into smids.
drupal_load('module', 'xmlsitemap');
......
<?php
/**
* @file
* @defgroup xmlsitemap XML sitemap
*/
......@@ -19,11 +20,16 @@ define('XMLSITEMAP_MAX_SITEMAP_LINKS', 50000);
*/
define('XMLSITEMAP_MAX_SITEMAP_FILESIZE', 10485760);
define('XMLSITEMAP_FREQUENCY_YEARLY', 31449600); // 60 * 60 * 24 * 7 * 52
define('XMLSITEMAP_FREQUENCY_MONTHLY', 2419200); // 60 * 60 * 24 * 7 * 4
define('XMLSITEMAP_FREQUENCY_WEEKLY', 604800); // 60 * 60 * 24 * 7
define('XMLSITEMAP_FREQUENCY_DAILY', 86400); // 60 * 60 * 24
define('XMLSITEMAP_FREQUENCY_HOURLY', 3600); // 60 * 60
// 60 * 60 * 24 * 7 * 52.
define('XMLSITEMAP_FREQUENCY_YEARLY', 31449600);
// 60 * 60 * 24 * 7 * 4.
define('XMLSITEMAP_FREQUENCY_MONTHLY', 2419200);
// 60 * 60 * 24 * 7.
define('XMLSITEMAP_FREQUENCY_WEEKLY', 604800);
// 60 * 60 * 24.
define('XMLSITEMAP_FREQUENCY_DAILY', 86400);
// 60 * 60.
define('XMLSITEMAP_FREQUENCY_HOURLY', 3600);
define('XMLSITEMAP_FREQUENCY_ALWAYS', 60);
/**
......@@ -97,10 +103,13 @@ function xmlsitemap_help($path, $arg) {
case 'admin/config/search/xmlsitemap/edit/%':
case 'admin/config/search/xmlsitemap/delete/%':
return;
case 'admin/help#xmlsitemap':
break;
case 'admin/config/search/xmlsitemap':
break;
case 'admin/config/search/xmlsitemap/rebuild':
$output .= '<p>' . t("This action rebuilds your site's XML sitemap and regenerates the cached files, and may be a lengthy process. If you just installed XML sitemap, this can be helpful to import all your site's content into the sitemap. Otherwise, this should only be used in emergencies.") . '</p>';
}
......@@ -338,13 +347,16 @@ function xmlsitemap_var($name, $default = NULL) {
/**
* Load an XML sitemap array from the database.
*
* @param $smid
* @param array $smid
* An XML sitemap ID.
*
* @return
* @return object
* The XML sitemap object.
*
* @codingStandardsIgnoreStart
*/
function xmlsitemap_sitemap_load($smid) {
// @codingStandardsIgnoreEnd
$sitemap = xmlsitemap_sitemap_load_multiple(array($smid));
return $sitemap ? reset($sitemap) : FALSE;
}
......@@ -352,15 +364,18 @@ function xmlsitemap_sitemap_load($smid) {
/**
* Load multiple XML sitemaps from the database.
*
* @param $smids
* @param array $smids
* An array of XML sitemap IDs, or FALSE to load all XML sitemaps.
* @param $conditions
* @param array $conditions
* An array of conditions in the form 'field' => $value.
*
* @return
* @return array
* An array of XML sitemap objects.
*
* @codingStandardsIgnoreStart
*/
function xmlsitemap_sitemap_load_multiple($smids = array(), array $conditions = array()) {
// @codingStandardsIgnoreEnd
if ($smids !== FALSE) {
$conditions['smid'] = $smids;
}
......@@ -383,7 +398,7 @@ function xmlsitemap_sitemap_load_multiple($smids = array(), array $conditions =
/**
* Load an XML sitemap array from the database based on its context.
*
* @param $context
* @param array $context
* An optional XML sitemap context array to use to find the correct XML
* sitemap. If not provided, the current site's context will be used.
*
......@@ -401,7 +416,7 @@ function xmlsitemap_sitemap_load_by_context(array $context = NULL) {
/**
* Save changes to an XML sitemap or add a new XML sitemap.
*
* @param $sitemap
* @param object $sitemap
* The XML sitemap array to be saved. If $sitemap->smid is omitted, a new
* XML sitemap will be added.
*
......@@ -450,25 +465,28 @@ function xmlsitemap_sitemap_save(stdClass $sitemap) {
/**
* Delete an XML sitemap.
*
* @param $smid
* @param array $smid
* An XML sitemap ID.
*
* @codingStandardsIgnoreStart
*/
function xmlsitemap_sitemap_delete($smid) {
// @codingStandardsIgnoreEnd
xmlsitemap_sitemap_delete_multiple(array($smid));
}
/**
* Delete multiple XML sitemaps.
*
* @param $smids
* @param array $smids
* An array of XML sitemap IDs.
*/
function xmlsitemap_sitemap_delete_multiple(array $smids) {
if (!empty($smids)) {
$sitemaps = xmlsitemap_sitemap_load_multiple($smids);
db_delete('xmlsitemap_sitemap')
->condition('smid', $smids)
->execute();
->condition('smid', $smids)
->execute();
foreach ($sitemaps as $sitemap) {
xmlsitemap_clear_directory($sitemap, TRUE);
......@@ -480,9 +498,9 @@ function xmlsitemap_sitemap_delete_multiple(array $smids) {
/**
* Return the expected file path for a specific sitemap chunk.
*
* @param $sitemap
* @param object $sitemap
* An XML sitemap array.
* @param $chunk
* @param string $chunk
* An optional specific chunk in the sitemap. Defaults to the index page.
*/
function xmlsitemap_sitemap_get_file(stdClass $sitemap, $chunk = 'index') {
......@@ -492,7 +510,7 @@ function xmlsitemap_sitemap_get_file(stdClass $sitemap, $chunk = 'index') {
/**
* Find the maximum file size of all a sitemap's XML files.
*
* @param $sitemap
* @param object $sitemap
* The XML sitemap array.
*/
function xmlsitemap_sitemap_get_max_filesize(stdClass $sitemap) {
......@@ -504,6 +522,9 @@ function xmlsitemap_sitemap_get_max_filesize(stdClass $sitemap) {
return $sitemap->max_filesize;
}
/**
* Get context.
*/
function xmlsitemap_sitemap_get_context_hash(array &$context) {
asort($context);
return drupal_hash_base64(serialize($context));
......@@ -512,9 +533,10 @@ function xmlsitemap_sitemap_get_context_hash(array &$context) {
/**
* Returns the uri elements of an XML sitemap.
*
* @param $sitemap
* @param object $sitemap
* An unserialized data array for an XML sitemap.
* @return
*
* @return array
* An array containing the 'path' and 'options' keys used to build the uri of
* the XML sitemap, and matching the signature of url().
*/
......@@ -532,11 +554,12 @@ function xmlsitemap_sitemap_uri(stdClass $sitemap) {
/**
* Load a specific sitemap link from the database.
*
* @param $entity_type
* @param string $entity_type
* A string with the entity type.
* @param $entity_id
* @param int $entity_id
* An integer with the entity ID.
* @return
*
* @return array
* A sitemap link (array) or FALSE if the conditions were not found.
*/
function xmlsitemap_link_load($entity_type, $entity_id) {
......@@ -547,10 +570,11 @@ function xmlsitemap_link_load($entity_type, $entity_id) {
/**
* Load sitemap links from the database.
*
* @param $conditions
* @param array $conditions
* An array of conditions on the {xmlsitemap} table in the form
* 'field' => $value.
* @return
*
* @return array
* An array of sitemap link arrays.
*/
function xmlsitemap_link_load_multiple(array $conditions = array()) {
......@@ -596,10 +620,16 @@ function xmlsitemap_link_save(array $link, array $context = array()) {
// Temporary validation checks.
// @todo Remove in final?
if ($link['priority'] < 0 || $link['priority'] > 1) {
trigger_error(t('Invalid sitemap link priority %priority.<br />@link', array('%priority' => $link['priority'], '@link' => var_export($link, TRUE))), E_USER_ERROR);
trigger_error(t('Invalid sitemap link priority %priority.<br />@link', array(
'%priority' => $link['priority'],
'@link' => var_export($link, TRUE),
)), E_USER_ERROR);
}
if ($link['changecount'] < 0) {
trigger_error(t('Negative changecount value. Please report this to <a href="@516928">@516928</a>.<br />@link', array('@516928' => 'http://drupal.org/node/516928', '@link' => var_export($link, TRUE))), E_USER_ERROR);
trigger_error(t('Negative changecount value. Please report this to <a href="@516928">@516928</a>.<br />@link', array(
'@516928' => 'http://drupal.org/node/516928',
'@link' => var_export($link, TRUE),
)), E_USER_ERROR);
$link['changecount'] = 0;
}
......@@ -629,14 +659,18 @@ function xmlsitemap_link_save(array $link, array $context = array()) {
* If visible links are updated, this will automatically set the regenerate
* needed flag to TRUE.
*
* @param $updates
* @param array $updates
* An array of values to update fields to, keyed by field name.
* @param $conditions
* @param array $conditions
* An array of values to match keyed by field.
* @return
*
* @return int
* The number of links that were updated.
*
* @codingStandardsIgnoreStart
*/
function xmlsitemap_link_update_multiple($updates = array(), $conditions = array(), $check_flag = TRUE) {
// @codingStandardsIgnoreEnd
// If we are going to modify a visible sitemap link, we will need to set
// the regenerate needed flag.
if ($check_flag && !variable_get('xmlsitemap_regenerate_needed', FALSE)) {
......@@ -659,11 +693,12 @@ function xmlsitemap_link_update_multiple($updates = array(), $conditions = array
* If a visible sitemap link was deleted, this will automatically set the
* regenerate needed flag.
*
* @param $entity_type
* @param string $entity_type
* A string with the entity type.
* @param $entity_id
* @param int $entity_id
* An integer with the entity ID.
* @return
*
* @return int
* The number of links that were deleted.
*/
function xmlsitemap_link_delete($entity_type, $entity_id) {
......@@ -677,10 +712,11 @@ function xmlsitemap_link_delete($entity_type, $entity_id) {
* If visible sitemap links were deleted, this will automatically set the
* regenerate needed flag.
*
* @param $conditions
* @param array $conditions
* An array of conditions on the {xmlsitemap} table in the form
* 'field' => $value.
* @return
*
* @return int
* The number of links that were deleted.
*/
function xmlsitemap_link_delete_multiple(array $conditions) {
......@@ -709,12 +745,13 @@ function xmlsitemap_link_delete_multiple(array $conditions) {
/**
* Check if there is a visible sitemap link given a certain set of conditions.
*
* @param $conditions
* @param array $conditions
* An array of values to match keyed by field.
* @param $flag
* @param string $flag
* An optional boolean that if TRUE, will set the regenerate needed flag if
* there is a match. Defaults to FALSE.
* @return
*
* @return bool
* TRUE if there is a visible link, or FALSE otherwise.
*/
function _xmlsitemap_check_changed_links(array $conditions = array(), array $updates = array(), $flag = FALSE) {
......@@ -740,19 +777,23 @@ function _xmlsitemap_check_changed_links(array $conditions = array(), array $upd
/**
* Check if there is sitemap link is changed from the existing data.
*
* @param $link
* @param array $link
* An array of the sitemap link.
* @param $original_link
* @param array $original_link
* An optional array of the existing data. This should only contain the
* fields necessary for comparison. If not provided the existing data will be
* loaded from the database.
* @param $flag
* @param bool $flag
* An optional boolean that if TRUE, will set the regenerate needed flag if
* there is a match. Defaults to FALSE.
* @return
*
* @return bool
* TRUE if the link is changed, or FALSE otherwise.
*
* @codingStandardsIgnoreStart
*/
function _xmlsitemap_check_changed_link(array $link, $original_link = NULL, $flag = FALSE) {
// @codingStandardsIgnoreEnd
$changed = FALSE;
if ($original_link === NULL) {
......@@ -772,7 +813,7 @@ function _xmlsitemap_check_changed_link(array $link, $original_link = NULL, $fla
$changed = TRUE;
}
elseif ($original_link['access'] && $original_link['status'] && array_diff_assoc($original_link, $link)) {
// Changing a visible link
// Changing a visible link.
$changed = TRUE;
}
}
......@@ -787,7 +828,6 @@ function _xmlsitemap_check_changed_link(array $link, $original_link = NULL, $fla
/**
* @} End of "defgroup xmlsitemap_api"
*/
function xmlsitemap_get_directory(stdClass $sitemap = NULL) {
$directory = &drupal_static(__FUNCTION__);
......@@ -815,6 +855,9 @@ function xmlsitemap_check_directory(stdClass $sitemap = NULL) {
return $result;
}
/**
* Check all directories.
*/
function xmlsitemap_check_all_directories() {
$directories = array();
......@@ -837,6 +880,9 @@ function xmlsitemap_check_all_directories() {
return $directories;
}
/**
* Clear Directory.
*/
function xmlsitemap_clear_directory(stdClass $sitemap = NULL, $delete = FALSE) {
$directory = xmlsitemap_get_directory($sitemap);
return _xmlsitemap_delete_recursive($directory, $delete);
......@@ -845,14 +891,14 @@ function xmlsitemap_clear_directory(stdClass $sitemap = NULL, $delete = FALSE) {
/**
* Move a directory to a new location.
*
* @param $old_dir
* @param string $old_dir
* A string specifying the filepath or URI of the original directory.
* @param $new_dir
* @param string $new_dir
* A string specifying the filepath or URI of the new directory.
* @param $replace
* @param string $replace
* Replace behavior when the destination file already exists.
*
* @return
* @return bool
* TRUE if the directory was moved successfully. FALSE otherwise.
*/
function xmlsitemap_directory_move($old_dir, $new_dir, $replace = FILE_EXISTS_REPLACE) {
......@@ -882,9 +928,9 @@ function xmlsitemap_directory_move($old_dir, $new_dir, $replace = FILE_EXISTS_RE
*
* Note that this only deletes visible files with write permission.
*
* @param $path
* @param string $path
* A filepath relative to the Drupal root directory.
* @param $delete_root
* @param bool $delete_root
* A boolean if TRUE will delete the $path directory afterwards.
*/
function _xmlsitemap_delete_recursive($path, $delete_root = FALSE) {
......@@ -908,10 +954,10 @@ function _xmlsitemap_delete_recursive($path, $delete_root = FALSE) {
/**
* Returns information about supported sitemap link types.
*
* @param $type
* @param string $type
* (optional) The link type to return information for. If omitted,
* information for all link types is returned.
* @param $reset
* @param bool $reset
* (optional) Boolean whether to reset the static cache and do nothing. Only
* used for tests.
*
......@@ -943,7 +989,7 @@ function xmlsitemap_get_link_info($type = NULL, $reset = FALSE) {
foreach ($info['bundles'] as $bundle_key => $bundle) {
if (!isset($bundle['xmlsitemap'])) {
// Remove any un-supported entity bundles.
//unset($link_info[$key]['bundles'][$bundle_key]);
// unset($link_info[$key]['bundles'][$bundle_key]);.
}
}
}
......@@ -979,19 +1025,25 @@ function xmlsitemap_get_link_info($type = NULL, $reset = FALSE) {
return $link_info;
}
/**
* Enabled Bundles.
*/