[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/xmlsitemap/ -> xmlsitemap.api.php (source)

   1  <?php
   2  // $Id: xmlsitemap.api.php,v 1.1.2.19 2010/04/29 16:22:09 davereid Exp $
   3  
   4  /**
   5   * @file
   6   * Hooks provided by the XML sitemap module.
   7   *
   8   * @ingroup xmlsitemap
   9   */
  10  
  11  /**
  12   * @addtogroup hooks
  13   * @{
  14   */
  15  
  16  /**
  17   * Provide information on the type of links this module provides.
  18   *
  19   * @see hook_entity_info()
  20   * @see hook_entity_info_alter()
  21   */
  22  function hook_xmlsitemap_link_info() {
  23    return array(
  24      'mymodule' => array(
  25        'label' => 'My module',
  26        'base table' => 'mymodule',
  27        'entity keys' => array(
  28          // Primary ID key on {base table}
  29          'id' => 'myid',
  30          // Subtype key on {base table}
  31          'bundle' => 'mysubtype',
  32        ),
  33        'path callback' => 'mymodule_path',
  34        'bundle label' => t('Subtype name'),
  35        'bundles' => array(
  36          'mysubtype1' => array(
  37            'label' => t('My subtype 1'),
  38            'admin' => array(
  39              'real path' => 'admin/settings/mymodule/mysubtype1/edit',
  40              'access arguments' => array('administer mymodule'),
  41            ),
  42            'xmlsitemap' => array(
  43              'status' => XMLSITEMAP_STATUS_DEFAULT,
  44              'priority' => XMLSITEMAP_PRIORITY_DEFAULT,
  45            ),
  46          ),
  47        ),
  48        'xmlsitemap' => array(
  49          // Callback function to take an array of IDs and save them as sitemap
  50          // links.
  51          'process callback' => '',
  52          // Callback function used in batch API for rebuilding all links.
  53          'rebuild callback' => '',
  54          // Callback function called from the XML sitemap settings page.
  55          'settings callback' => '',
  56        )
  57      ),
  58    );
  59  }
  60  
  61  /**
  62   * Alter the data of a sitemap link before the link is saved.
  63   *
  64   * @param $link
  65   *   An array with the data of the sitemap link.
  66   */
  67  function hook_xmlsitemap_link_alter(&$link) {
  68    if ($link['type'] == 'mymodule') {
  69      $link['priority'] += 0.5;
  70    }
  71  }
  72  
  73  /**
  74   * Index links for the XML sitemaps.
  75   */
  76  function hook_xmlsitemap_index_links($limit) {
  77  }
  78  
  79  /**
  80   * Provide information about contexts available to XML sitemap.
  81   *
  82   * @see hook_xmlsitemap_context_info_alter().
  83   */
  84  function hook_xmlsitemap_context_info() {
  85    $info['vocabulary'] = array(
  86      'label' => t('Vocabulary'),
  87      'summary callback' => 'mymodule_xmlsitemap_vocabulary_context_summary',
  88      'settings callback' => 'mymodule_xmlsitemap_vocabulary_context_settings',
  89      'default' => 0,
  90    );
  91    return $info;
  92  }
  93  
  94  /**
  95   * Alter XML sitemap context info.
  96   *
  97   * @see hook_xmlsitemap_context_info().
  98   */
  99  function hook_xmlsitemap_context_info_alter(&$info) {
 100    $info['vocabulary']['label'] = t('Site vocabularies');
 101  }
 102  
 103  /**
 104   * Provide information about the current context on the site.
 105   *
 106   * @see hook_xmlsitemap_context_alter()
 107   */
 108  function hook_xmlsitemap_context() {
 109    $context = array();
 110    if ($vid = mymodule_get_current_vocabulary()) {
 111      $context['vocabulary'] = $vid;
 112    }
 113    return $context;
 114  }
 115  
 116  /**
 117   * Alter the current context information.
 118   *
 119   * @see hook_xmlsitemap_context()
 120   */
 121  function hook_xmlsitemap_context_alter(&$context) {
 122    if (user_access('administer taxonomy')) {
 123      unset($context['vocabulary']);
 124    }
 125  }
 126  
 127  /**
 128   * Provide options for the url() function based on an XML sitemap context.
 129   */
 130  function hook_xmlsitemap_context_url_options(array $context) {
 131  }
 132  
 133  /**
 134   * Alter the url() options based on an XML sitemap context.
 135   */
 136  function hook_xmlsitemap_context_url_options_alter(array &$options, array $context) {
 137  }
 138  
 139  /**
 140   * Alter the query selecting data from {xmlsitemap} during sitemap generation.
 141   *
 142   * Do not alter LIMIT or OFFSET as the query will be passed through
 143   * db_query_range() with a set limit and offset.
 144   *
 145   * @param $query
 146   *   An array of a query object, keyed by SQL keyword (SELECT, FROM, WHERE, etc).
 147   * @param $args
 148   *   An array of arguments to be passed to db_query() with $query.
 149   * @param $sitemap
 150   *   An XML sitemap array.
 151   */
 152  function hook_query_xmlsitemap_generate_alter(array &$query, array &$args, array $sitemap) {
 153    if (!empty($sitemap['context']['vocabulary'])) {
 154      $query['WHERE'] .= " AND ((x.type = 'taxonomy_term' AND x.subtype = '%s') OR (x.type <> 'taxonomy_term')";
 155      $args[] = $sitemap['context']['vocabulary'];
 156    }
 157  }
 158  
 159  /**
 160   * Provide information about XML sitemap bulk operations.
 161   */
 162  function hook_xmlsitemap_sitemap_operations() {
 163  }
 164  
 165  /**
 166   * Respond to XML sitemap deletion.
 167   *
 168   * This hook is invoked from xmlsitemap_sitemap_delete_multiple() after the XML
 169   * siteamp has been removed from the table in the database.
 170   *
 171   * @param $sitemap
 172   *   The XML sitemap array that was deleted.
 173   */
 174  function hook_xmlsitemap_siteamp_delete(array $sitemap) {
 175    db_query("DELETE FROM {mytable} WHERE smid = '%s'", $sitemap['smid']);
 176  }
 177  
 178  /**
 179   * @} End of "addtogroup hooks".
 180   */


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