first import
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the xmlsitemap_engines module.
|
||||
*/
|
||||
|
||||
class XMLSitemapEnginesFunctionalTest extends XMLSitemapTestHelper {
|
||||
protected $submit_url;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'XML sitemap engines functional tests',
|
||||
'description' => 'Functional tests for the XML sitemap engines module.',
|
||||
'group' => 'XML sitemap',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp($modules = array()) {
|
||||
$modules[] = 'xmlsitemap_engines';
|
||||
$modules[] = 'xmlsitemap_engines_test';
|
||||
parent::setUp($modules);
|
||||
|
||||
$this->admin_user = $this->drupalCreateUser(array('access content', 'administer xmlsitemap'));
|
||||
$this->drupalLogin($this->admin_user);
|
||||
|
||||
// @todo For some reason the test client does not have clean URLs while
|
||||
// the test runner does, so it causes mismatches in watchdog assertions
|
||||
// later.
|
||||
variable_set('clean_url', 0);
|
||||
|
||||
$this->submit_url = url('ping', array('absolute' => TRUE, 'query' => array('sitemap' => ''))) . '[sitemap]';
|
||||
}
|
||||
|
||||
function submitEngines() {
|
||||
variable_set('xmlsitemap_engines_submit_last', REQUEST_TIME - 10000);
|
||||
variable_set('xmlsitemap_generated_last', REQUEST_TIME - 100);
|
||||
variable_set('xmlsitemap_engines_minimum_lifetime', 0);
|
||||
xmlsitemap_engines_cron();
|
||||
$this->assertTrue(variable_get('xmlsitemap_engines_submit_last', 0) > (REQUEST_TIME - 100), 'Submitted the sitemaps to search engines.');
|
||||
}
|
||||
|
||||
function testPrepareURL() {
|
||||
$sitemap = 'http://example.com/sitemap.xml';
|
||||
$input = 'http://example.com/ping?sitemap=[sitemap]&foo=bar';
|
||||
$output = 'http://example.com/ping?sitemap=http://example.com/sitemap.xml&foo=bar';
|
||||
$this->assertEqual(xmlsitemap_engines_prepare_url($input, $sitemap), $output);
|
||||
}
|
||||
|
||||
function testSubmitSitemaps() {
|
||||
$sitemaps = array();
|
||||
$sitemap = new stdClass();
|
||||
$sitemap->uri = array(
|
||||
'path' => 'http://example.com/sitemap.xml',
|
||||
'options' => array(),
|
||||
);
|
||||
$sitemaps[] = $sitemap;
|
||||
$sitemap = new stdClass();
|
||||
$sitemap->uri = array(
|
||||
'path' => 'http://example.com/sitemap-2.xml',
|
||||
'options' => array(),
|
||||
);
|
||||
$sitemaps[] = $sitemap;
|
||||
xmlsitemap_engines_submit_sitemaps($this->submit_url, $sitemaps);
|
||||
|
||||
$this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Recieved ping for @sitemap.', 'variables' => array('@sitemap' => 'http://example.com/sitemap.xml')));
|
||||
$this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Recieved ping for @sitemap.', 'variables' => array('@sitemap' => 'http://example.com/sitemap-2.xml')));
|
||||
}
|
||||
|
||||
function testPing() {
|
||||
$edit = array('xmlsitemap_engines_engines[simpletest]' => TRUE);
|
||||
$this->drupalPost('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'));
|
||||
|
||||
$this->submitEngines();
|
||||
$this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Submitted the sitemap to %url and received response @code.'));
|
||||
$this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Recieved ping for @sitemap.'));
|
||||
}
|
||||
|
||||
function testCustomURL() {
|
||||
$edit = array('xmlsitemap_engines_custom_urls' => 'an-invalid-url');
|
||||
$this->drupalPost('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
|
||||
$this->assertText('Invalid URL an-invalid-url.');
|
||||
$this->assertNoText('The configuration options have been saved.');
|
||||
|
||||
$url = url('ping', array('absolute' => TRUE));
|
||||
$edit = array('xmlsitemap_engines_custom_urls' => $url);
|
||||
$this->drupalPost('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'));
|
||||
|
||||
$this->submitEngines();
|
||||
$this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Submitted the sitemap to %url and received response @code.', 'variables' => array('%url' => $url, '@code' => '404')));
|
||||
$this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'No valid sitemap parameter provided.'));
|
||||
$this->assertWatchdogMessage(array('type' => 'page not found', 'message' => 'ping'));
|
||||
|
||||
$edit = array('xmlsitemap_engines_custom_urls' => $this->submit_url);
|
||||
$this->drupalPost('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'));
|
||||
|
||||
$this->submitEngines();
|
||||
$url = xmlsitemap_engines_prepare_url($this->submit_url, url('sitemap.xml', array('absolute' => TRUE)));
|
||||
$this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Submitted the sitemap to %url and received response @code.', 'variables' => array('%url' => $url, '@code' => '200')));
|
||||
$this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Recieved ping for @sitemap.', 'variables' => array('@sitemap' => url('sitemap.xml', array('absolute' => TRUE)))));
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
name = XML sitemap engines test
|
||||
description = Support module for XML sitemap engines testing.
|
||||
package = Testing
|
||||
core = 7.x
|
||||
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"
|
||||
core = "7.x"
|
||||
project = "xmlsitemap"
|
||||
datestamp = "1354931808"
|
||||
|
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function xmlsitemap_engines_test_menu() {
|
||||
$items['ping'] = array(
|
||||
'page callback' => 'xmlsitemap_engines_test_pinged',
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_xmlsitemap_engine_info().
|
||||
*/
|
||||
function xmlsitemap_engines_test_xmlsitemap_engine_info() {
|
||||
$engines['simpletest'] = array(
|
||||
'name' => t('SimpleTest'),
|
||||
'url' => 'http://example.com/',
|
||||
);
|
||||
return $engines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_xmlsitemap_engine_info_alter().
|
||||
*/
|
||||
function xmlsitemap_engines_test_xmlsitemap_engine_info_alter(&$engines) {
|
||||
$engines['simpletest']['url'] = url('ping', array('absolute' => TRUE, 'query' => array('sitemap' => ''))) . '[sitemap]';
|
||||
}
|
||||
|
||||
function xmlsitemap_engines_test_pinged() {
|
||||
if (empty($_GET['sitemap']) || !valid_url($_GET['sitemap'])) {
|
||||
watchdog('xmlsitemap', 'No valid sitemap parameter provided.', array(), WATCHDOG_WARNING);
|
||||
// @todo Remove this? Causes an extra watchdog error to be handled.
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
else {
|
||||
watchdog('xmlsitemap', 'Recieved ping for @sitemap.', array('@sitemap' => $_GET['sitemap']));
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Administrative page callbacks for the xmlsitemap_engines module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Form builder; Administration settings form.
|
||||
*/
|
||||
function xmlsitemap_engines_settings_form() {
|
||||
// Build the list of support engines for the checkboxes options.
|
||||
$engines = xmlsitemap_engines_get_engine_info();
|
||||
$engine_options = array();
|
||||
foreach ($engines as $engine => $engine_info) {
|
||||
$engine_options[$engine] = $engine_info['name'];
|
||||
}
|
||||
asort($engine_options);
|
||||
|
||||
$form['xmlsitemap_engines_engines'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Submit the sitemap to the following engines'),
|
||||
'#default_value' => variable_get('xmlsitemap_engines_engines', array()),
|
||||
'#options' => $engine_options,
|
||||
);
|
||||
$form['xmlsitemap_engines_minimum_lifetime'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Do not submit more often than every'),
|
||||
'#options' => drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 604800 * 2, 604800 * 4), 'format_interval'),
|
||||
'#default_value' => variable_get('xmlsitemap_engines_minimum_lifetime', 86400),
|
||||
);
|
||||
$form['xmlsitemap_engines_submit_updated'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Only submit if the sitemap has been updated since the last submission.'),
|
||||
'#default_value' => variable_get('xmlsitemap_engines_submit_updated', TRUE),
|
||||
);
|
||||
$form['xmlsitemap_engines_custom_urls'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Custom submission URLs'),
|
||||
'#description' => t('Enter one URL per line. The token [sitemap] will be replaced with the URL to your sitemap. For example: %example-before would become %example-after.', array('%example-before' => 'http://example.com/ping?[sitemap]', '%example-after' => xmlsitemap_engines_prepare_url('http://example.com/ping?[sitemap]', url('sitemap.xml', array('absolute' => TRUE))))),
|
||||
'#default_value' => variable_get('xmlsitemap_engines_custom_urls', ''),
|
||||
'#rows' => 2,
|
||||
'#wysiwyg' => FALSE,
|
||||
'#element_validate' => array('xmlsitemap_engines_validate_custom_urls'),
|
||||
);
|
||||
|
||||
// Ensure the xmlsitemap_engines variable gets filterd to a simple array.
|
||||
$form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the custom submission URL element.
|
||||
*/
|
||||
function xmlsitemap_engines_validate_custom_urls($element, &$form_state) {
|
||||
$custom_urls = preg_split('/[\r\n]+/', $element['#value'], -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($custom_urls as $custom_url) {
|
||||
$url = xmlsitemap_engines_prepare_url($custom_url, '');
|
||||
if (!valid_url($url, TRUE)) {
|
||||
form_error($element, t('Invalid URL %url.', array('%url' => $custom_url)));
|
||||
}
|
||||
}
|
||||
$form_state['values']['xmlsitemap_engines_custom_urls'] = implode("\n", $custom_urls);
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Hooks provided by the XML sitemap engines module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup hooks
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provide a list of supported sitemap engines.
|
||||
*/
|
||||
function hook_xmlsitemap_engine_info() {
|
||||
$engines['example'] = array(
|
||||
'name' => t('Example search engine'),
|
||||
'url' => 'http://example.com/ping?sitemap=[sitemap]'
|
||||
);
|
||||
return $engines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter the list of sitemap engines.
|
||||
*/
|
||||
function hook_xmlsitemap_engine_info_alter(&$engines) {
|
||||
$engines['example']['name'] = t('Kitten Search');
|
||||
$engines['example']['url'] = 'http://kittens.com/ping?sitemap=[sitemap]';
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup hooks".
|
||||
*/
|
@@ -0,0 +1,18 @@
|
||||
name = XML sitemap engines
|
||||
description = Submit the sitemap to search engines.
|
||||
package = XML sitemap
|
||||
core = 7.x
|
||||
dependencies[] = xmlsitemap
|
||||
files[] = xmlsitemap_engines.module
|
||||
files[] = xmlsitemap_engines.admin.inc
|
||||
files[] = xmlsitemap_engines.install
|
||||
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"
|
||||
core = "7.x"
|
||||
project = "xmlsitemap"
|
||||
datestamp = "1354931808"
|
||||
|
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the xmlsitemap_engines module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function xmlsitemap_engines_install() {
|
||||
// Set this module's weight to 1 so xmlsitemap_engines_cron() runs after
|
||||
// the sitemap has been generated in xmlsitemap_cron().
|
||||
db_update('system')
|
||||
->fields(array('weight' => 2))
|
||||
->condition('type', 'module')
|
||||
->condition('name', 'xmlsitemap_engines')
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function xmlsitemap_engines_uninstall() {
|
||||
variable_del('xmlsitemap_engines_engines');
|
||||
variable_del('xmlsitemap_engines_custom_urls');
|
||||
variable_del('xmlsitemap_engines_minimum_lifetime');
|
||||
variable_del('xmlsitemap_engines_submit_last');
|
||||
variable_del('xmlsitemap_engines_submit_updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecate support for Ask.com, Moreover, and Yahoo! search engines.
|
||||
*/
|
||||
function xmlsitemap_engines_update_6202() {
|
||||
$engines = variable_get('xmlsitemap_engines_engines', array());
|
||||
$removed = array(
|
||||
'ask' => 'Ask.com',
|
||||
'moreover' => 'Moreover',
|
||||
'yahoo' => 'Yahoo.com',
|
||||
);
|
||||
$engines = array_diff($engines, array_keys($removed));
|
||||
variable_set('xmlsitemap_engines_engines', $engines);
|
||||
return t('The following search engines have deprecated their XML sitemap ping services and have been disabled: !list.', array('!list' => implode(', ', $removed)));
|
||||
}
|
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_hook_info().
|
||||
*/
|
||||
function xmlsitemap_engines_hook_info() {
|
||||
$hooks['xmlsitemap_engine_info'] = array(
|
||||
'group' => 'xmlsitemap',
|
||||
);
|
||||
$hooks['xmlsitemap_engine_info_alter'] = array(
|
||||
'group' => 'xmlsitemap',
|
||||
);
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
*/
|
||||
function xmlsitemap_engines_help($path, $arg) {
|
||||
$output = '';
|
||||
switch ($path) {
|
||||
case 'admin/config/search/xmlsitemap/engines':
|
||||
if (!module_exists('site_verify')) {
|
||||
$output .= '<p>' . t('In order to verify site ownership with the search engines listed below, it is highly recommended to download and install the <a href="@site-verify">Site verification module</a>.', array('@site-verify' => 'http://drupal.org/project/site_verify')) . '</p>';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function xmlsitemap_engines_menu() {
|
||||
$items['admin/config/search/xmlsitemap/engines'] = array(
|
||||
'title' => 'Search Engines',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('xmlsitemap_engines_settings_form'),
|
||||
'access arguments' => array('administer xmlsitemap'),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'file' => 'xmlsitemap_engines.admin.inc',
|
||||
);
|
||||
//$items['admin/config/search/xmlsitemap/engines/submit'] = array(
|
||||
// 'page callback' => 'xmlsitemap_engines_submit',
|
||||
// 'access callback' => 'xmlsitemap_engines_submit_access',
|
||||
// 'type' => MENU_CALLBACK,
|
||||
//);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_cron().
|
||||
*/
|
||||
function xmlsitemap_engines_cron() {
|
||||
if (xmlsitemap_engines_submit_access()) {
|
||||
xmlsitemap_engines_submit_engines();
|
||||
}
|
||||
}
|
||||
|
||||
function xmlsitemap_engines_can_submit() {
|
||||
// Skip if the site is offline since search engines will not be able to
|
||||
// access the site's content.
|
||||
if (variable_get('maintenance_mode', 0) || defined('MAINTENANCE_MODE')) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!variable_get('xmlsitemap_engines_engines', array()) && !variable_get('xmlsitemap_engines_custom_urls', '')) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function xmlsitemap_engines_submit_access() {
|
||||
if (!xmlsitemap_engines_can_submit()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Allow manual submissions to run.
|
||||
//if ($_GET['q'] == 'admin/config/search/xmlsitemap/engines/submit' && user_access('administer xmlsitemap')) {
|
||||
// return TRUE;
|
||||
//}
|
||||
|
||||
$submit_updated = variable_get('xmlsitemap_engines_submit_updated', TRUE);
|
||||
$submitted_last = variable_get('xmlsitemap_engines_submit_last', 0);
|
||||
$minimum_lifetime = variable_get('xmlsitemap_engines_minimum_lifetime', 86400);
|
||||
|
||||
// Skip if sitemap data has not been updated since last submission.
|
||||
if ($submit_updated && variable_get('xmlsitemap_generated_last', 0) <= $submitted_last) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Skip if the time since last submission is less than the minimum lifetime.
|
||||
if ((REQUEST_TIME - $submitted_last) < $minimum_lifetime) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the sitemaps to all the specified search engines.
|
||||
*
|
||||
* @param $smids
|
||||
* An optional array of XML sitemap IDs. If not provided, it will load all
|
||||
* existing XML sitemaps.
|
||||
*/
|
||||
function xmlsitemap_engines_submit_engines(array $smids = array()) {
|
||||
if (empty($smids)) {
|
||||
$smids = FALSE;
|
||||
}
|
||||
|
||||
$sitemaps = xmlsitemap_sitemap_load_multiple($smids);
|
||||
$engines = variable_get('xmlsitemap_engines_engines', array());
|
||||
$engine_info = xmlsitemap_engines_get_engine_info();
|
||||
|
||||
foreach ($engines as $engine) {
|
||||
if (isset($engine_info[$engine]['url'])) {
|
||||
xmlsitemap_engines_submit_sitemaps($engine_info[$engine]['url'], $sitemaps);
|
||||
}
|
||||
}
|
||||
|
||||
$custom_urls = variable_get('xmlsitemap_engines_custom_urls', '');
|
||||
$custom_urls = preg_split('/[\r\n]+/', $custom_urls, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($custom_urls as $custom_url) {
|
||||
xmlsitemap_engines_submit_sitemaps($custom_url, $sitemaps);
|
||||
}
|
||||
|
||||
variable_set('xmlsitemap_engines_submit_last', REQUEST_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the sitemaps to a specific URL.
|
||||
*
|
||||
* @param $url
|
||||
* The URL for sitemap submission.
|
||||
* @param $sitemaps
|
||||
* An array of URLs of the sitemaps to submit.
|
||||
*/
|
||||
function xmlsitemap_engines_submit_sitemaps($url, array $sitemaps) {
|
||||
foreach ($sitemaps as $sitemap) {
|
||||
$sitemap->url = url($sitemap->uri['path'], $sitemap->uri['options']);
|
||||
$submit_url = xmlsitemap_engines_prepare_url($url, $sitemap->url);
|
||||
$request = drupal_http_request($submit_url);
|
||||
watchdog('xmlsitemap', 'Submitted the sitemap to %url and received response @code.', array('%url' => $submit_url, '@code' => $request->code));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace valid tokens in the URL with their appropriate values.
|
||||
*
|
||||
* @param $url
|
||||
* An un-tokenized URL.
|
||||
* @return
|
||||
* A tokenized URL.
|
||||
*/
|
||||
function xmlsitemap_engines_prepare_url($url, $sitemap) {
|
||||
return str_replace('[sitemap]', $sitemap, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about supported search engines.
|
||||
*
|
||||
* @param $engine
|
||||
* (optional) The engine to return information for. If omitted, information
|
||||
* for all engines is returned.
|
||||
* @param $reset
|
||||
* (optional) Boolean whether to reset the static cache and do nothing. Only
|
||||
* used for tests.
|
||||
*
|
||||
* @see hook_xmlsitemap_engines_info()
|
||||
* @see hook_xmlsitemap_engines_info_alter()
|
||||
*/
|
||||
function xmlsitemap_engines_get_engine_info($engine = NULL) {
|
||||
global $language;
|
||||
$engines = &drupal_static(__FUNCTION__);
|
||||
|
||||
if (!isset($engines)) {
|
||||
if ($cached = cache_get('xmlsitemap:engines:' . $language->language)) {
|
||||
$engines = $cached->data;
|
||||
}
|
||||
else {
|
||||
// Fetch the results of all hook_xmlsitemap_engine_info() implementations.
|
||||
$engines = module_invoke_all('xmlsitemap_engine_info');
|
||||
// Allow other modulse to alter the engine info.
|
||||
drupal_alter('xmlsitemap_engine_info', $engines);
|
||||
// Cache by language since engine names are translated.
|
||||
cache_set('xmlsitemap:engines:' . $language->language, $engines);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($engine)) {
|
||||
return isset($engines[$engine]) ? $engines[$engine] : NULL;
|
||||
}
|
||||
else {
|
||||
return $engines;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_xmlsitemap_engine_info().
|
||||
*/
|
||||
function xmlsitemap_engines_xmlsitemap_engine_info() {
|
||||
$engines['google'] = array(
|
||||
'name' => t('Google'),
|
||||
'url' => 'http://www.google.com/webmasters/tools/ping?sitemap=[sitemap]',
|
||||
'help url' => 'http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156184',
|
||||
);
|
||||
$engines['bing'] = array(
|
||||
'name' => t('Bing'),
|
||||
'url' => 'http://www.bing.com/webmaster/ping.aspx?siteMap=[sitemap]',
|
||||
'help url' => 'http://www.bing.com/webmaster',
|
||||
);
|
||||
return $engines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_variables().
|
||||
*/
|
||||
function xmlsitemap_engines_variables() {
|
||||
$variables = array(
|
||||
'xmlsitemap_engines_engines' => array(),
|
||||
'xmlsitemap_engines_custom_urls' => '',
|
||||
'xmlsitemap_engines_minimum_lifetime' => 86400,
|
||||
'xmlsitemap_engines_submit_last' => 0,
|
||||
'xmlsitemap_engines_submit_updated' => TRUE,
|
||||
);
|
||||
return $variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_xmlsitemap_sitemap_operations().
|
||||
*/
|
||||
function xmlsitemap_engines_xmlsitemap_sitemap_operations() {
|
||||
if (xmlsitemap_engines_can_submit()) {
|
||||
$operations['xmlsitemap_engines_submit'] = array(
|
||||
'label' => t('Submit to search engines'),
|
||||
'action past' => t('Submitted'),
|
||||
'callback' => 'xmlsitemap_engines_submit_engines',
|
||||
);
|
||||
return $operations;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user