[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/xmlsitemap/ -> xmlsitemap.drush.inc (source)

   1  <?php
   2  // $Id: xmlsitemap.drush.inc,v 1.1.2.15 2010/04/07 22:39:10 davereid Exp $
   3  
   4  /**
   5   * @file
   6   * Drush integration functions for the xmlsitemap module.
   7   *
   8   * @ingroup xmlsitemap
   9   */
  10  
  11  /**
  12   * Implements hook_drush_command().
  13   */
  14  function xmlsitemap_drush_command() {
  15    $items['xmlsitemap-regenerate'] = array(
  16      'description' => 'Regenerate the XML sitemap files.',
  17      'callback' => 'drush_xmlsitemap_regenerate',
  18      'drupal dependencies' => array('xmlsitemap'),
  19    );
  20    $items['xmlsitemap-rebuild'] = array(
  21      'description' => 'Dump and re-process all possible XML sitemap data, and then regenerate the files.',
  22      'callback' => 'drush_xmlsitemap_rebuild',
  23      'drupal dependencies' => array('xmlsitemap'),
  24    );
  25    $items['xmlsitemap-index'] = array(
  26      'description' => 'Process un-indexed XML sitemap links.',
  27      'callback' => 'drush_xmlsitemap_index',
  28      'drupal dependencies' => array('xmlsitemap'),
  29      'options' => array(
  30        '--limit' => 'The limit of links of each type to process. Default value: ' . variable_get('xmlsitemap_batch_limit', 100),
  31      ),
  32    );
  33    return $items;
  34  }
  35  
  36  /**
  37   * Regenerate the sitemap files from existing data.
  38   */
  39  function drush_xmlsitemap_regenerate() {
  40    module_load_include('generate.inc', 'xmlsitemap');
  41  
  42    // Run the batch process.
  43    xmlsitemap_run_progressive_batch('xmlsitemap_regenerate_batch');
  44  
  45    $vars = array(
  46      '@timer' => timer_read('xmlsitemap_regenerate'),
  47      '@memory-peak' => format_size(memory_get_peak_usage(TRUE)),
  48    );
  49    drush_print(dt('XML sitemap files regenerated in @timer ms. Peak memory usage: @memory-peak.', $vars));
  50  }
  51  
  52  /**
  53   * Dump and rebuild all the sitemap data, then regenerate the files.
  54   */
  55  function drush_xmlsitemap_rebuild() {
  56    module_load_include('generate.inc', 'xmlsitemap');
  57  
  58    // Build a list of rebuildable link types.
  59    $rebuild_types = xmlsitemap_get_rebuildable_link_types();
  60  
  61    // Run the batch process.
  62    xmlsitemap_run_progressive_batch('xmlsitemap_rebuild_batch', $rebuild_types, TRUE);
  63  
  64    $vars = array(
  65      '@timer' => timer_read('xmlsitemap_rebuild'),
  66      '@memory-peak' => format_size(memory_get_peak_usage(TRUE)),
  67    );
  68    drush_print(dt('XML sitemap files rebuilt in @timer ms. Peak memory usage: @memory-peak.', $vars));
  69  }
  70  
  71  /**
  72   * Process un-indexed XML sitemap links.
  73   */
  74  function drush_xmlsitemap_index() {
  75    $limit = (int) drush_get_option('limit', variable_get('xmlsitemap_batch_limit', 100));
  76    $count_before = db_result(db_query("SELECT COUNT(id) FROM {xmlsitemap}"));
  77  
  78    module_invoke_all('xmlsitemap_index_links', $limit);
  79    $count_after = db_result(db_query("SELECT COUNT(id) FROM {xmlsitemap}"));
  80  
  81    if ($count_after == $count_before) {
  82      drush_print(dt('No new XML sitemap links to index.'));
  83    }
  84    else {
  85      drush_print(dt('Indexed @count new XML sitemap links.', array('@count' => $count_after - $count_before)));
  86    }
  87  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7