FINAL suepr merge step : added all modules to this super repos

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-19 16:46:59 +02:00
7585 changed files with 1723356 additions and 18 deletions

View File

@@ -0,0 +1,53 @@
<?php
// $Id: xmlsitemap_engines.test,v 1.5 2010/01/24 05:33:27 davereid Exp $
/**
* @file
* Unit tests for the xmlsitemap_engines module.
*/
class XMLSitemapEnginesFunctionalTest extends XMLSitemapTestHelper {
public static function getInfo() {
return array(
'name' => 'XML sitemap engines interface tests',
'description' => 'Functional tests for the XML sitemap engines module.',
'group' => 'XML sitemap',
);
}
function setUp() {
parent::setUp('xmlsitemap_engines', 'xmlsitemap_engines_test');
$this->admin_user = $this->drupalCreateUser(array('access content', 'administer xmlsitemap'));
$this->drupalLogin($this->admin_user);
variable_set('xmlsitemap_generated_last', REQUEST_TIME);
}
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.'));
xmlsitemap_engines_cron();
$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(t('Invalid custom URL an-invalid-url.'));
$this->assertNoText(t('The configuration options have been saved.'));
$edit = array('xmlsitemap_engines_custom_urls' => url('ping', array('absolute' => TRUE)));
$this->drupalPost('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
xmlsitemap_engines_cron();
$this->assertWatchdogMessage(array('type' => 'xmlsitemap', 'message' => 'Submitted the sitemap to %url and received response @code.'));
$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' => url('ping', array('absolute' => TRUE, 'query' => array('sitemap' => '[sitemap]'))));
$this->drupalPost('admin/config/search/xmlsitemap/engines', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
}
}

View File

@@ -0,0 +1,15 @@
; $Id: xmlsitemap_engines_test.info,v 1.3 2009/12/22 23:56:59 davereid Exp $
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 2010-01-24
version = "7.x-2.x-dev"
core = "7.x"
project = "xmlsitemap"
datestamp = "1264335489"

View File

@@ -0,0 +1,43 @@
<?php
// $Id: xmlsitemap_engines_test.module,v 1.5 2010/01/24 05:33:27 davereid Exp $
/**
* 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']));
}
}

View File

@@ -0,0 +1,66 @@
<?php
// $Id: xmlsitemap_engines.admin.inc,v 1.3 2010/01/24 03:57:19 davereid Exp $
/**
* @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(300, 900, 1800, 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 custom submission 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'),
);
$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 custom URL %url.', array('%url' => $custom_url)));
}
}
$form_state['values']['xmlsitemap_engines_custom_urls'] = implode("\n", $custom_urls);
}

View File

@@ -0,0 +1,35 @@
<?php
// $Id: xmlsitemap_engines.api.php,v 1.2 2009/12/22 23:38:54 davereid Exp $
/**
* @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".
*/

View File

@@ -0,0 +1,19 @@
; $Id: xmlsitemap_engines.info,v 1.4 2009/12/22 23:56:59 davereid Exp $
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 2010-01-24
version = "7.x-2.x-dev"
core = "7.x"
project = "xmlsitemap"
datestamp = "1264335489"

View File

@@ -0,0 +1,69 @@
<?php
// $Id: xmlsitemap_engines.install,v 1.5 2010/01/18 07:46:29 davereid Exp $
/**
* @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');
}
/**
* Filter the xmlsitemap_engines_submit variable.
*/
function xmlsitemap_engines_update_1() {
variable_set('xmlsitemap_engines_submit', array_filter(variable_get('xmlsitemap_engines_submit', array())));
}
/**
* Rename the xmlsitemap_engines_engines variable to xmlsitemap_engines_submit.
*/
function xmlsitemap_engines_update_2() {
variable_set('xmlsitemap_engines_engines', variable_get('xmlsitemap_engines_submit', array()));
variable_del('xmlsitemap_engines_submit');
}
/**
* Increase the module weight so it always runs after sitemap generation.
*/
function xmlsitemap_engines_update_3() {
db_update('system')
->fields(array('weight' => 2))
->condition('type', 'module')
->condition('name', 'xmlsitemap_engines')
->execute();
}
/**
* Update Windows Live search to Bing.
*/
function xmlsitemap_engines_update_4() {
$engines = variable_get('xmlsitemap_engines_engines', array());
$index = array_search('windows_live', $engines);
if ($index !== FALSE) {
$engines[$index] = 'bing';
}
variable_set('xmlsitemap_engines_engines', $engines);
}

View File

@@ -0,0 +1,210 @@
<?php
// $Id: xmlsitemap_engines.module,v 1.7 2009/12/22 23:43:57 davereid Exp $
/**
* Implements hook_help().
*/
function xmlsitemap_engines_help($path, $arg) {
$output = '';
switch ($path) {
case 'admin/config/search/xmlsitemap/engines':
if (!module_exists('site_verify')) {
$output .= 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'));
}
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_submit_access() {
// Skip if the site is offline since search engines will not be able to
// access the site's content.
if (variable_get('site_offline', 0)) {
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.
*/
function xmlsitemap_engines_submit_engines() {
$sitemaps = xmlsitemap_get_sitemaps();
$engines = variable_get('xmlsitemap_engines_engines', array());
$engine_info = xmlsitemap_engines_get_engine_info();
foreach ($engines as $engine) {
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, $sitemaps = array()) {
foreach ($sitemaps as $sitemap) {
$url = xmlsitemap_engines_prepare_url($url, $sitemap);
$request = drupal_http_request($url);
watchdog('xmlsitemap', 'Submitted the sitemap to %url and received response @code.', array('%url' => $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, $reset = FALSE) {
global $language;
static $engines;
if ($reset) {
$engines = NULL;
}
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]',
);
$engines['yahoo'] = array(
'name' => t('Yahoo!'),
'url' => 'http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=[sitemap]',
);
$engines['ask'] = array(
'name' => t('Ask.com'),
'url' => 'http://submissions.ask.com/ping?sitemap=[sitemap]',
);
$engines['bing'] = array(
'name' => t('Bing (formerly Live Search)'),
'url' => 'http://www.bing.com/webmaster/ping.aspx?siteMap=[sitemap]',
);
$engines['moreover'] = array(
'name' => t('Moreover'),
'url' => 'http://api.moreover.com/ping?u=[sitemap]',
);
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;
}