You are here

function xmlsitemap_get_link_info in XML sitemap 7.2

Same name and namespace in other branches
  1. 8 xmlsitemap.module \xmlsitemap_get_link_info()
  2. 6.2 xmlsitemap.module \xmlsitemap_get_link_info()
  3. 2.x xmlsitemap.module \xmlsitemap_get_link_info()

Returns information about supported sitemap link types.

Parameters

string $type: (optional) The link type to return information for. If omitted, information for all link types is returned.

bool $reset: (optional) Boolean whether to reset the static cache and do nothing. Only used for tests.

See also

hook_xmlsitemap_link_info()

hook_xmlsitemap_link_info_alter()

14 calls to xmlsitemap_get_link_info()
drush_xmlsitemap_queue_rebuild in ./xmlsitemap.drush.inc
Dump and queue all the sitemap links to be rebuilt in a queue process.
xmlsitemap_add_form_link_options in ./xmlsitemap.admin.inc
Add a link's XML sitemap options to the link's form.
xmlsitemap_add_link_bundle_settings in ./xmlsitemap.admin.inc
Add the link type XML sitemap options to the link type's form.
xmlsitemap_get_bundle_path in ./xmlsitemap.module
Get Bundle.
xmlsitemap_get_link_type_enabled_bundles in ./xmlsitemap.module
Enabled Bundles.

... See full list

File

./xmlsitemap.module, line 1013
xmlsitemap XML sitemap

Code

function xmlsitemap_get_link_info($type = NULL, $reset = FALSE) {
  global $language;
  $link_info =& drupal_static(__FUNCTION__);
  if ($reset) {
    $link_info = NULL;
    cache_clear_all('xmlsitemap:link_info:', 'cache', TRUE);
  }
  if (!isset($link_info)) {
    $cid = 'xmlsitemap:link_info:' . $language->language;
    if ($cache = cache_get($cid)) {
      $link_info = $cache->data;
    }
    else {
      entity_info_cache_clear();
      $link_info = entity_get_info();
      foreach ($link_info as $key => $info) {
        if (empty($info['uri callback']) || !isset($info['xmlsitemap'])) {

          // Remove any non URL-able or XML sitemap un-supported entites.
          unset($link_info[$key]);
        }
        foreach ($info['bundles'] as $bundle_key => $bundle) {
          if (!isset($bundle['xmlsitemap'])) {

            // Remove any un-supported entity bundles.
            // unset($link_info[$key]['bundles'][$bundle_key]);.
          }
        }
      }
      $link_info = array_merge($link_info, module_invoke_all('xmlsitemap_link_info'));
      foreach ($link_info as $key => &$info) {
        $info += array(
          'type' => $key,
          'base table' => FALSE,
          'bundles' => array(),
          'xmlsitemap' => array(),
        );
        if (!isset($info['xmlsitemap']['rebuild callback']) && !empty($info['base table']) && !empty($info['entity keys']['id']) && !empty($info['xmlsitemap']['process callback'])) {
          $info['xmlsitemap']['rebuild callback'] = 'xmlsitemap_rebuild_batch_fetch';
        }
        foreach ($info['bundles'] as $bundle => &$bundle_info) {
          $bundle_info += array(
            'xmlsitemap' => array(),
          );
          $bundle_info['xmlsitemap'] += xmlsitemap_link_bundle_load($key, $bundle, FALSE);
        }
      }
      drupal_alter('xmlsitemap_link_info', $link_info);
      ksort($link_info);

      // Cache by language since this info contains translated strings.
      cache_set($cid, $link_info);
    }
  }
  if (isset($type)) {
    return isset($link_info[$type]) ? $link_info[$type] : NULL;
  }
  return $link_info;
}