xmlsitemap.inc 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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(t('Symantec'), 'http://www.symantec.com/'),
  20. l(t('WebWise Solutions'), 'http://www.webwiseone.com/'),
  21. l(t('Volacci'), 'http://www.volacci.com/'),
  22. l(t('lanetro'), 'http://www.lanetro.com/'),
  23. l(t('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. /**
  33. * Get version.
  34. */
  35. function _xmlsitemap_get_version() {
  36. static $version;
  37. if (!isset($version)) {
  38. $modules = _system_rebuild_module_data();
  39. $version = $modules['xmlsitemap']->info['version'];
  40. }
  41. return $version;
  42. }
  43. /**
  44. * Check the status of all hook_requirements() from any xmlsitemap modules.
  45. */
  46. function xmlsitemap_check_status() {
  47. $messages = &drupal_static(__FUNCTION__);
  48. if (!isset($messages)) {
  49. // Cache the list of modules that are checked.
  50. if ($cache = cache_get('xmlsitemap:registry:requirements')) {
  51. $modules = $cache->data;
  52. }
  53. else {
  54. $modules = array();
  55. module_load_all_includes('install');
  56. foreach (module_implements('requirements') as $module) {
  57. if (strpos($module, 'xmlsitemap') !== FALSE) {
  58. $modules[] = $module;
  59. }
  60. }
  61. cache_set('xmlsitemap:registry:requirements', $modules);
  62. }
  63. $messages = array();
  64. foreach ($modules as $module) {
  65. module_load_install($module);
  66. $requirements = module_invoke($module, 'requirements', 'runtime');
  67. foreach ($requirements as $requirement) {
  68. if (isset($requirement['severity']) && max(REQUIREMENT_OK, $requirement['severity'])) {
  69. $messages[] = $requirement['description'];
  70. }
  71. }
  72. }
  73. if ($messages) {
  74. $message = t('One or more problems were detected with your XML sitemap configuration: !messages', array('!messages' => theme('item_list', array('items' => $messages))));
  75. if (user_access('access site reports')) {
  76. $message .= t('Check the <a href="@status-report">status report</a> for more information.', array('@status-report' => url('admin/reports/status')));
  77. }
  78. drupal_set_message($message, 'warning', FALSE);
  79. }
  80. }
  81. return !empty($messages);
  82. }