You are here

function _xmlsitemap_engines_yahoo in XML sitemap 5

Define actions for Yahoo!.

Related topics

1 call to _xmlsitemap_engines_yahoo()
xmlsitemap_engines_xmlsitemap_engines in xmlsitemap_engines/xmlsitemap_engines.module
Implementation of hook_xmlsitemap_engines().

File

xmlsitemap_engines/xmlsitemap_engines.module, line 86
Define actions for Google, Yahoo!, Ask, and Bing.

Code

function _xmlsitemap_engines_yahoo($op) {
  switch ($op) {
    case 'form':
      $form['yahoo'] = array(
        '#type' => 'fieldset',
        '#title' => t('Yahoo!'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      );
      $form['yahoo']['xmlsitemap_engines_yahoo_submit'] = array(
        '#type' => 'checkbox',
        '#title' => t('Submit site map to Yahoo!'),
        '#default_value' => variable_get('xmlsitemap_engines_yahoo_submit', FALSE),
      );
      $form['yahoo']['xmlsitemap_engines_yahoo_url'] = array(
        '#type' => 'textfield',
        '#title' => t('Submission URL'),
        '#default_value' => variable_get('xmlsitemap_engines_yahoo_url', 'http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=' . xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE)),
        '#description' => t('The URL to submit the site map to.'),
      );
      $form['yahoo']['xmlsitemap_engines_yahoo_verify'] = array(
        '#type' => 'textfield',
        '#title' => t('Verification link'),
        '#default_value' => variable_get('xmlsitemap_engines_yahoo_verify', ''),
        '#description' => t('Before allowing you to view additional information, Yahoo! will ask you to verify that you control this site by creating a file with a certain name. Enter that name here, and XML Sitemap will create a path to that file name. This will only work if you have clean URLs enabled.'),
      );
      $form['yahoo']['xmlsitemap_engines_yahoo_verify_string'] = array(
        '#type' => 'textfield',
        '#title' => t('Authentication key'),
        '#default_value' => variable_get('xmlsitemap_engines_yahoo_verify_string', ''),
        '#description' => t('Yahoo! will ask you to put an authentication key in the verification file.'),
      );
      return $form;
    case 'ping':
      if (variable_get('xmlsitemap_engines_yahoo_submit', FALSE)) {
        $result = drupal_http_request(variable_get('xmlsitemap_engines_yahoo_url', 'http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=' . xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE)));
        if ($result->code == 200) {
          watchdog('xmlsitemap', t('Site map successfully submitted to Yahoo!.'));
        }
        else {
          watchdog('xmlsitemap', t('Error occurred submitting site map to Yahoo!: @code', array(
            '@code' => $result->code,
          )), WATCHDOG_ERROR);
        }
      }
      break;
  }
}