xmlsitemap.inc 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * @file
  4. * Miscellaneous functions for the xmlsitemap module.
  5. *
  6. * @ingroup xmlsitemap
  7. */
  8. /**
  9. * Fetch a short blurb string about module maintainership and sponsors.
  10. *
  11. * This message will be FALSE in 'official' releases.
  12. */
  13. function _xmlsitemap_get_blurb($check_version = TRUE) {
  14. static $blurb;
  15. if (!isset($blurb)) {
  16. $blurb = FALSE;
  17. if (!$check_version || (($version = _xmlsitemap_get_version()) && preg_match('/dev|unstable|alpha|beta|HEAD/i', $version))) {
  18. $sponsors = array(
  19. l('Symantec', 'http://www.symantec.com/'),
  20. l('WebWise Solutions', 'http://www.webwiseone.com/'),
  21. l('Volacci', 'http://www.volacci.com/'),
  22. l('lanetro', 'http://www.lanetro.com/'),
  23. l('Coupons Dealuxe', 'http://couponsdealuxe.com/'),
  24. );
  25. // Don't extract the following string for translation.
  26. $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>';
  27. //http://drupalmodules.com/module/xml-sitemap
  28. }
  29. }
  30. return $blurb;
  31. }
  32. function _xmlsitemap_get_version() {
  33. static $version;
  34. if (!isset($version)) {
  35. $modules = _system_rebuild_module_data();
  36. $version = $modules['xmlsitemap']->info['version'];
  37. }
  38. return $version;
  39. }
  40. /**
  41. * Check the status of all hook_requirements() from any xmlsitemap modules.
  42. */
  43. function xmlsitemap_check_status() {
  44. $messages = &drupal_static(__FUNCTION__);
  45. if (!isset($messages)) {
  46. // Cache the list of modules that are checked.
  47. if ($cache = cache_get('xmlsitemap:registry:requirements')) {
  48. $modules = $cache->data;
  49. }
  50. else {
  51. $modules = array();
  52. module_load_all_includes('install');
  53. foreach (module_implements('requirements') as $module) {
  54. if (strpos($module, 'xmlsitemap') !== FALSE) {
  55. $modules[] = $module;
  56. }
  57. }
  58. cache_set('xmlsitemap:registry:requirements', $modules);
  59. }
  60. $messages = array();
  61. foreach ($modules as $module) {
  62. module_load_install($module);
  63. $requirements = module_invoke($module, 'requirements', 'runtime');
  64. foreach ($requirements as $requirement) {
  65. if (isset($requirement['severity']) && max(REQUIREMENT_OK, $requirement['severity'])) {
  66. $messages[] = $requirement['description'];
  67. }
  68. }
  69. }
  70. if ($messages) {
  71. $message = t('One or more problems were detected with your XML sitemap configuration: !messages', array('!messages' => theme('item_list', array('items' => $messages))));
  72. if (user_access('access site reports')) {
  73. $message .= t('Check the <a href="@status-report">status report</a> for more information.', array('@status-report' => url('admin/reports/status')));
  74. }
  75. drupal_set_message($message, 'warning', FALSE);
  76. }
  77. }
  78. return !empty($messages);
  79. }