Commit 56843b32 authored by Dave Reid's avatar Dave Reid
Browse files

by Dave Reid: Added changefreq and language to custom links table.

parent c2e5afd6
......@@ -8,25 +8,35 @@
function xmlsitemap_custom_list_links() {
$header = array(
'loc' => array('data' => t('Location'), 'field' => 'loc'),
'priority' => array('data' => t('Priority'), 'field' => 'loc'),
'loc' => array('data' => t('Location'), 'field' => 'loc', 'sort' => 'asc'),
'priority' => array('data' => t('Priority'), 'field' => 'priority'),
'changefreq' => array('data' => t('Change frequency'), 'field' => 'changefreq'),
'language' => array('data' => t('Language'), 'field' => 'language'),
'operations' => array('data' => t('Operations')),
);
// Do not include the language column if locale is disabled.
if (!module_exists('locale')) {
unset($header['language']);
}
$rows = array();
$destination = drupal_get_destination();
$query = db_select('xmlsitemap')->extend('PagerDefault')->extend('TableSort');
$result = $query
->fields('xmlsitemap')
->condition('type', 'custom')
->orderByHeader(array_values($header))
->limit(50)
->execute();
$query = db_select('xmlsitemap');
$query->fields('xmlsitemap');
$query->condition('type', 'custom');
$query->extend('PagerDefault')->limit(50);
$query->extend('TableSort')->orderByHeader($header);
$result = $query->execute();
foreach ($result as $link) {
$row = array();
$row['loc'] = l($link->loc, $link->loc);
$row['priority'] = number_format($link->priority, 1);
$row['changefreq'] = $link->changefreq ? drupal_ucfirst(xmlsitemap_get_changefreq($link->changefreq)) : t('None');
if (isset($header['language'])) {
$row['language'] = module_invoke('locale', 'language_name', $link->language);
}
$operations = array();
$operations['edit'] = array(
'title' => t('Edit'),
......@@ -48,6 +58,7 @@ function xmlsitemap_custom_list_links() {
$rows[] = $row;
}
// @todo Convert to tableselect
$build['xmlsitemap_custom_table'] = array(
'#theme' => 'table',
'#header' => $header,
......@@ -83,21 +94,21 @@ function xmlsitemap_custom_edit_link_form($form, &$form_state, $link = array())
'#type' => 'textfield',
'#title' => t('Path to link'),
'#field_prefix' => url('', array('absolute' => TRUE)),
'#default_value' => drupal_get_path_alias($link['loc'], $link['language']),
'#default_value' => $link['loc'] ? drupal_get_path_alias($link['loc'], $link['language']) : '',
'#required' => TRUE,
'#size' => 30,
);
$form['xmlsitemap']['priority'] = array(
$form['priority'] = array(
'#type' => 'select',
'#title' => t('Priority'),
'#options' => xmlsitemap_get_priority_options(),
'#default_value' => number_format($link['priority'], 1),
'#description' => t('The priority of this URL relative to other URLs on your site.'),
);
$form['xmlsitemap']['changefreq'] = array(
$form['changefreq'] = array(
'#type' => 'select',
'#title' => t('Change frequency'),
'#options' => array(0 => t('No value')) + xmlsitemap_get_changefreq_options(),
'#options' => array(0 => t('None')) + xmlsitemap_get_changefreq_options(),
'#default_value' => $link['changefreq'],
'#description' => t('How frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page.'),
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment