home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (nodewords_verification_tags.module)

This example Drupal source code file (nodewords_verification_tags.module) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, content, edit, empty, function, meta, options, php, site, tag, to, verification, webmaster, you

The nodewords_verification_tags.module Drupal example source code

<?php
// $Id: nodewords_verification_tags.module,v 1.1.2.8 2009/12/28 21:04:51 kiam Exp $

/**
 * @file
 * Allows users to add site verification meta tags which some web services require.
 */

/**
 * @addtogroup nodewords_verification_tags
 * @{
 */

/**
 * Implements hook_nodewords_api().
 */
function nodewords_verification_tags_nodewords_api() {
  return array(
    'version' => '1.9',
  );
}

/**
 * Implements hook_nodewords_tags_info().
 */
function nodewords_verification_tags_nodewords_tags_info() {
  $tags = array(
    'bing_webmaster_center' => array(
      'tag:context:allowed' => array(NODEWORDS_TYPE_FRONTPAGE),
      'tag:function:prefix' => 'nodewords_verification_tags_bing_webmaster_center',
      'tag:template' => array(
        'msvalidate.01' => NODEWORDS_META,
      ),
      'widget:label' => t('Bing Webmaster Center verification code'),
      'widget:permission' => 'edit Bing Webmaster Center verification meta tag',
    ),
    'google_webmaster_tools' => array(
      'tag:context:allowed' => array(NODEWORDS_TYPE_FRONTPAGE),
      'tag:function:prefix' => 'nodewords_verification_tags_google_webmaster_tools',
      'tag:template' => array(
        'google-site-verification' => NODEWORDS_META,
      ),
      'widget:label' => t('Google Webmaster Tools verification code'),
      'widget:permission' => 'edit Google Webmaster Tools verification meta tag',
    ),
    'yahoo_site_explorer' => array(
      'tag:context:allowed' => array(NODEWORDS_TYPE_FRONTPAGE),
      'tag:function:prefix' => 'nodewords_verification_tags_yahoo_site_explorer',
      'tag:template' => array(
        'y_key' => NODEWORDS_META,
      ),
      'widget:label' => t('Yahoo! Site Explorer verification code'),
      'widget:permission' => 'edit Yahoo! Site Explorer verification meta tag',
    ),
  );

  return $tags;
}

/**
 * Implements hook_perm().
 */
function nodewords_verification_tags_perm() {
  return array(
    'edit Bing Webmaster Center verification meta tag',
    'edit Google Webmaster Tools verification meta tag',
    'edit Yahoo! Site Explorer verification meta tag',
  );
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_verification_tags_bing_webmaster_center_form(&$form, $content, $options) {
  $form['bing_webmaster_center'] = array(
    '#tree' => TRUE,
  );

  $form['bing_webmaster_center']['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Bing Webmaster Center verification code'),
    '#description' => t('<a href="@bing-url">Bing Webmaster Center</a> will ask you to add a meta tag in order to verify you have write access to the pages of the web site you registered with their services.', array('@bing-url' => 'http://www.bing.com/webmaster')),
    '#default_value' => empty($content['value']) ? '' : $content['value'],
    '#size' => 60,
    '#maxlength' => variable_get('nodewords_max_size', 350),
  );
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_verification_tags_google_webmaster_tools_form(&$form, $content, $options) {
  $form['google_webmaster_tools'] = array(
    '#tree' => TRUE,
  );

  $form['google_webmaster_tools']['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Google Webmaster Tools verification code'),
    '#description' => t('<a href="@google-url">Google Webmaster Tools</a> will ask you to add a meta tag in your web site to provide you with an easy way to make your site more <a href="http://google.com">Google</a>-friendly.', array('@google-url' => 'http://www.google.com/webmasters/tools')),
    '#default_value' => empty($content['value']) ? '' : $content['value'],
    '#size' => 60,
    '#maxlength' => variable_get('nodewords_max_size', 350),
  );
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_verification_tags_yahoo_site_explorer_form(&$form, $content, $options) {
  $form['yahoo_site_explorer'] = array(
    '#tree' => TRUE,
  );

  $form['yahoo_site_explorer']['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Yahoo! Site Explorer'),
    '#description' => t('<a href="@yahoo-url">Yahoo! Site Explorer</a> will ask you to add a meta tag in your web site to allow you to explore all the web pages indexed by <a href="http://search.yahoo.com">Yahoo! Search</a>.', array('@yahoo-url' => 'https://siteexplorer.search.yahoo.com/')),
    '#default_value' => empty($content['value']) ? '' : $content['value'],
    '#size' => 60,
    '#maxlength' => variable_get('nodewords_max_size', 350),
  );
}

/**
 * Set the meta tag content.
 */
function nodewords_verification_tags_bing_webmaster_center_prepare(&$tags, $content, $options) {
  if (!empty($content['value'])) {
    $tags['bing_webmaster_center:msvalidate.01'] = $content['value'];
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_verification_tags_google_webmaster_tools_prepare(&$tags, $content, $options) {
  if (!empty($content['value'])) {
    $tags['google_webmaster_tools:google-site-verification'] = $content['value'];
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_verification_tags_yahoo_site_explorer_prepare(&$tags, $content, $options) {
  if (!empty($content['value'])) {
    $tags['yahoo_site_explorer:y_key'] = $content['value'];
  }
}

/**
 * @} End of "addtogroup nodewords_verification_tags".
 */

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal nodewords_verification_tags.module source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.