You are here

nodewords_extra.module in Nodewords: D6 Meta Tags 6

Same filename and directory in other branches
  1. 6.2 nodewords_extra/nodewords_extra.module

Define extra meta tags for Drupal pages.

File

nodewords_extra/nodewords_extra.module
View source
<?php

/**
 * @file
 * Define extra meta tags for Drupal pages.
 */

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

/**
 * Implements hook_nodewords_tags_info().
 */
function nodewords_extra_nodewords_tags_info() {
  $tags = array(
    'dcterms.contributor' => array(
      'callback' => 'nodewords_extra_dc_contributor',
      'context' => array(
        'allowed' => array(
          NODEWORDS_TYPE_DEFAULT,
          NODEWORDS_TYPE_NODE,
          NODEWORDS_TYPE_PAGE,
        ),
      ),
      'label' => t('Dublin Core: Contributor'),
      'multiple' => TRUE,
      'permission' => 'edit meta tag Dublin Core CONTRIBUTOR',
      'templates' => array(
        'head' => array(
          'dcterms.contributor' => NODEWORDS_META,
        ),
      ),
      'weight' => array(
        'dcterms.contributor' => -177,
      ),
    ),
    'dcterms.creator' => array(
      'callback' => 'nodewords_extra_dc_creator',
      'context' => array(
        'allowed' => array(
          NODEWORDS_TYPE_DEFAULT,
          NODEWORDS_TYPE_NODE,
          NODEWORDS_TYPE_PAGE,
        ),
      ),
      'label' => t('Dublin Core: Creator'),
      'permission' => 'edit meta tag Dublin Core CREATOR',
      'templates' => array(
        'head' => array(
          'dcterms.creator' => NODEWORDS_META,
        ),
      ),
      'weight' => array(
        'dcterms.creator' => -178,
      ),
    ),
    'dcterms.date' => array(
      'callback' => 'nodewords_extra_dc_date',
      'context' => array(
        'allowed' => array(
          NODEWORDS_TYPE_DEFAULT,
          NODEWORDS_TYPE_NODE,
          NODEWORDS_TYPE_PAGE,
        ),
      ),
      'label' => t('Dublin Core: Date'),
      'permission' => 'edit meta tag Dublin Core DATE',
      'templates' => array(
        'head' => array(
          'dcterms.date' => NODEWORDS_META,
        ),
      ),
      'weight' => array(
        'dcterms.date' => -183,
      ),
    ),
    'dcterms.description' => array(
      'callback' => 'nodewords_extra_dc_description',
      'context' => array(),
      'label' => t('Dublin Core: Description'),
      'permission' => 'edit meta tag Dublin Core DESCRIPTION',
      'templates' => array(
        'head' => array(
          'dcterms.description' => NODEWORDS_META,
        ),
      ),
      'weight' => array(
        'dcterms.description' => -188,
      ),
    ),
    'dcterms.publisher' => array(
      'callback' => 'nodewords_extra_dc_publisher',
      'context' => array(
        'allowed' => array(
          NODEWORDS_TYPE_DEFAULT,
          NODEWORDS_TYPE_PAGE,
        ),
      ),
      'label' => t('Dublin Core: Publisher'),
      'permission' => 'edit meta tag Dublin Core PUBLISHER',
      'templates' => array(
        'head' => array(
          'dcterms.publisher' => NODEWORDS_META,
        ),
      ),
    ),
    'dcterms.title' => array(
      'callback' => 'nodewords_extra_dc_title',
      'context' => array(
        'denied' => array(
          NODEWORDS_TYPE_DEFAULT,
        ),
      ),
      'label' => t('Dublin Core: Title'),
      'permission' => 'edit meta tag Dublin Core TITLE',
      'templates' => array(
        'head' => array(
          'dcterms.title' => NODEWORDS_META,
        ),
      ),
      'weight' => array(
        'dcterms.title' => -198,
      ),
    ),
    'location' => array(
      'callback' => 'nodewords_extra_location',
      'label' => t('Geotagging: Coordinates (latitude, longitude)'),
      'permission' => 'edit location meta tag',
      'templates' => array(
        'head' => array(
          'geo.position' => NODEWORDS_META,
          'icbm' => NODEWORDS_META,
        ),
      ),
      'weight' => array(
        'location' => -159,
      ),
    ),
    'geo.placename' => array(
      'callback' => 'nodewords_extra_geo_placename',
      'label' => t('Geotagging: Placename'),
      'permission' => 'edit meta tag GEO PLACENAME',
      'templates' => array(
        'head' => array(
          'geo.placename' => NODEWORDS_META,
        ),
      ),
      'weight' => array(
        'geo.placename' => -151,
      ),
    ),
    'geo.region' => array(
      'callback' => 'nodewords_extra_geo_region',
      'label' => t('Geotagging: Region'),
      'permission' => 'edit meta tag GEO REGION',
      'templates' => array(
        'head' => array(
          'geo.region' => NODEWORDS_META,
        ),
      ),
      'weight' => array(
        'geo.region' => -150,
      ),
    ),
    'shorturl' => array(
      'callback' => 'nodewords_extra_shorturl',
      'context' => array(
        'denied' => array(
          NODEWORDS_TYPE_DEFAULT,
          NODEWORDS_TYPE_ERRORPAGE,
          NODEWORDS_TYPE_OFFLINE,
          NODEWORDS_TYPE_TRACKER,
        ),
      ),
      'label' => t('Short URL'),
      'permission' => 'edit short URL meta tag',
      'templates' => array(
        'head' => array(
          'shorturl' => NODEWORDS_LINK_REL,
        ),
      ),
      'weight' => array(
        'shorturl' => -138,
      ),
    ),
  );
  return $tags;
}

/**
 * Implements hook_perm().
 */
function nodewords_extra_perm() {
  return array(
    'edit meta tag Dublin Core CONTRIBUTOR',
    'edit meta tag Dublin Core CREATOR',
    'edit meta tag Dublin Core DATE',
    'edit meta tag Dublin Core DESCRIPTION',
    'edit meta tag Dublin Core PUBLISHER',
    'edit meta tag Dublin Core TITLE',
    'edit location meta tag',
    'edit meta tag GEO PLACENAME',
    'edit meta tag GEO REGION',
    'edit short URL meta tag',
  );
}

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Provide an option to automatically add the DC schema meta tag.
 */
function nodewords_extra_form_nodewords_settings_form_alter(&$form, &$form_state) {
  $form['metatags_creation']['nodewords_add_dc_schema'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add the Dublin Core schema meta tag'),
    '#default_value' => variable_get('nodewords_add_dc_schema', FALSE),
  );
}

/**
 * Implementation of hook_nodewords_tags_output_alter().
 *
 * Output the DC schema meta tag, if requested.
 */
function nodewords_extra_nodewords_tags_output_alter(&$output, $parameters) {
  $bool = variable_get('nodewords_add_dc_schema', FALSE) && isset($parameters['output']) && $parameters['type'] != NODEWORDS_TYPE_NONE && $parameters['output'] == 'head';
  if ($bool) {
    $output = '<link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />' . "\n" . $output;
  }
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_extra_dc_contributor_form(&$form, $content, $options) {
  $form['dcterms.contributor'] = array(
    '#tree' => TRUE,
    '#weight' => -178,
  );
  $form['dcterms.contributor']['value'] = array(
    '#type' => 'textarea',
    '#title' => t('Dublin Core: Contributor'),
    '#description' => t('Enter the name(s) of an entity responsible for making contributions to the resource. Examples of a contributor include a person, an organization, or a service. Multiple names may be added, one per line, up to a maximum of %count characters.', array(
      '%count' => variable_get('nodewords_max_size', 350),
    )),
    '#default_value' => empty($content['value']) ? '' : $content['value'],
    '#cols' => 60,
    '#rows' => 2,
    '#wysiwyg' => FALSE,
  );

  // Show the current default.
  if ($options['type'] != NODEWORDS_TYPE_DEFAULT) {

    // Load the current default.
    if (!empty($options['default']['dcterms.contributor']['value'])) {
      $default = $options['default']['dcterms.contributor']['value'];
    }
    else {
      $default = t('Not set.');
    }
    $form['dcterms.contributor']['value']['#description'] .= '<br />' . t('The default is: %default', array(
      '%default' => $default,
    ));
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_extra_dc_contributor_prepare(&$tags, $content, $options) {
  if (!empty($content['value'])) {
    $tags['dcterms.contributor'] = $content['value'];
  }
  elseif (!empty($options['default']['dcterms.contributor']['value'])) {
    $tags['dcterms.contributor'] = $options['default']['dcterms.contributor']['value'];
  }
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_extra_dc_creator_form(&$form, $content, $options) {
  $form['dcterms.creator'] = array(
    '#tree' => TRUE,
    '#weight' => -179,
  );
  $form['dcterms.creator']['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Dublin Core: Creator'),
    '#description' => t('Enter the name of an entity primarily responsible for making the resource. Examples of a creator include a person, an organization, or a service.'),
    '#default_value' => empty($content['value']) ? '' : $content['value'],
    '#size' => 60,
    '#maxlength' => variable_get('nodewords_max_size', 350),
  );

  // Show the current default.
  if ($options['type'] != NODEWORDS_TYPE_DEFAULT) {

    // Load the current default.
    if (!empty($options['default']['dcterms.creator']['value'])) {
      $default = $options['default']['dcterms.creator']['value'];
    }
    else {
      $default = t('Not set.');
    }
    $form['dcterms.creator']['value']['#description'] .= '<br />' . t('The default is: %default', array(
      '%default' => $default,
    ));
  }

  // Optionally auto-assign the value.
  if ($options['type'] == NODEWORDS_TYPE_DEFAULT || $options['type'] == NODEWORDS_TYPE_NODE) {
    $form['dcterms.creator']['auto'] = array(
      '#type' => 'checkbox',
      '#title' => t('Automatically assign the node author\'s username'),
      '#description' => t('Rather than manually filling in the value above, this will automatically assign the node author\'s username. This will be used if no name is manually filled in.'),
      '#default_value' => empty($content['auto']) ? FALSE : TRUE,
    );

    // Show the current default.
    if ($options['type'] != NODEWORDS_TYPE_DEFAULT) {

      // Load the current default.
      if (!empty($options['default']['dcterms.creator']['auto'])) {
        $default = t('Yes');
      }
      else {
        $default = t('No');
      }
      $form['dcterms.creator']['auto']['#description'] .= '<br />' . t('The default is: %default', array(
        '%default' => $default,
      ));
    }
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_extra_dc_creator_prepare(&$tags, $content, $options) {
  $auto = FALSE;

  // The manually assigned value.
  if (!empty($content['value'])) {
    $tags['dcterms.creator'] = $content['value'];
  }
  elseif ($options['type'] == NODEWORDS_TYPE_NODE && !empty($content['auto'])) {
    $auto = TRUE;
  }
  elseif (!empty($options['default']['dcterms.creator']['value'])) {
    $tags['dcterms.creator'] = $options['default']['dcterms.creator']['value'];
  }
  elseif ($options['type'] == NODEWORDS_TYPE_NODE && !empty($options['default']['dcterms.creator']['auto'])) {
    $auto = TRUE;
  }
  if ($auto) {
    $node = node_load($options['id']);
    $tags['dcterms.creator'] = $node->name;
  }
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_extra_dc_date_form(&$form, $content, $options) {
  $form['dcterms.date'] = array(
    '#tree' => TRUE,
    '#weight' => -183,
  );
  $form['dcterms.date']['value'] = array(
    '#type' => 'date',
    '#title' => t('Dublin Core: Date'),
    '#description' => t('A point or period of time associated with an event in the lifecycle of the resource. The date should be relative to UTC.'),
    '#default_value' => empty($content['value']) ? array() : $content['value'],
  );

  // Show the current default.
  if ($options['type'] != NODEWORDS_TYPE_DEFAULT) {

    // Load the current default.
    if (!empty($options['default']['dcterms.date']['value'])) {
      $date = $options['default']['dcterms.date']['value'];
      $default = format_date(mktime(0, 0, 0, $date['month'], $date['day'], $date['year']), 'custom', 'F jS, Y');
    }
    else {
      $default = t('Not set.');
    }
    $form['dcterms.date']['value']['#description'] .= '<br />' . t('The default is: %default', array(
      '%default' => $default,
    ));
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_extra_dc_date_prepare(&$tags, $content, $options) {
  $time = 0;
  if (!empty($content['value'])) {
    $time = mktime(0, 0, 0, $content['value']['month'], $content['value']['day'], $content['value']['year']);
  }
  elseif (!empty($options['default']['dcterms.date']['value']['month'])) {
    $time = mktime(0, 0, 0, $options['default']['dcterms.date']['value']['month'], $options['default']['dcterms.date']['value']['day'], $options['default']['dcterms.date']['value']['year']);
  }

  // If a time field was identified, use it.
  if (!empty($time)) {
    $tags['dcterms.date'] = date('Y-m-d\\TH:i:s\\Z', $time);
  }
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_extra_dc_description_form(&$form, $content, $options) {
  $autogenerate = FALSE;
  if ($options['type'] == NODEWORDS_TYPE_NODE && isset($options['node_type'])) {
    $autogenerate = variable_get('nodewords_metatags_generation_method_' . $options['node_type'], NODEWORDS_GENERATION_WHEN_EMPTY);
  }
  $form['dcterms.description'] = array(
    '#tree' => TRUE,
    '#weight' => -188,
  );
  $form['dcterms.description']['value'] = array(
    '#type' => 'textarea',
    '#title' => t('Dublin Core: Description'),
    '#description' => t('Enter a one or two sentence description of your page. Limit the description to about 20 words with a maximum of %count characters. It should not contain any HTML tags or other formatting.', array(
      '%count' => variable_get('nodewords_max_size', 350),
    )),
    '#default_value' => empty($content['value']) ? '' : $content['value'],
    '#cols' => 60,
    '#rows' => 3,
    '#wysiwyg' => FALSE,
  );
  if ($options['type'] == NODEWORDS_TYPE_NODE) {
    if ($autogenerate == NODEWORDS_GENERATION_ALWAYS) {
      $form['dcterms.description']['value']['#disabled'] = TRUE;
      $form['dcterms.description']['value']['#rows'] = 1;
      $form['dcterms.description']['value']['#default_value'] = '';
      $form['dcterms.description']['value']['#description'] = t('This will be automatically generated from the node.');
    }
    elseif ($autogenerate == NODEWORDS_GENERATION_WHEN_EMPTY) {
      $form['dcterms.description']['value']['#description'] .= ' ' . t('If this is left empty the value will be automatically generated from the node');
    }
  }

  // Show the current default.
  if ($options['type'] != NODEWORDS_TYPE_DEFAULT) {

    // Load the current default.
    if (!empty($options['default']['dcterms.description']['value'])) {
      $default = $options['default']['dcterms.description']['value'];
    }
    else {
      $default = t('Not set.');
    }
    $form['dcterms.description']['value']['#description'] .= '<br />' . t('The default is: %default', array(
      '%default' => $default,
    ));
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_extra_dc_description_prepare(&$tags, $content, $options) {
  _nodewords_prepare_description($tags, $content, $options, 'dcterms.description');
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_extra_dc_publisher_form(&$form, $content, $options) {
  $form['dcterms.publisher'] = array(
    '#tree' => TRUE,
  );
  $form['dcterms.publisher']['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Dublin Core: Publisher'),
    '#description' => t('Enter a name of an entity responsible for making the resource available. Examples of a publisher include a person, an organization, or a service.'),
    '#default_value' => empty($content['value']) ? '' : $content['value'],
    '#size' => 60,
    '#maxlength' => variable_get('nodewords_max_size', 350),
  );

  // Show the current default.
  if ($options['type'] != NODEWORDS_TYPE_DEFAULT) {

    // Load the current default.
    if (!empty($options['default']['dcterms.publisher']['value'])) {
      $default = $options['default']['dcterms.publisher']['value'];
    }
    else {
      $default = t('Not set.');
    }
    $form['dcterms.publisher']['value']['#description'] .= '<br />' . t('The default is: %default', array(
      '%default' => $default,
    ));
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_extra_dc_publisher_prepare(&$tags, $content, $options) {

  // Optional override.
  if (!empty($content['value'])) {
    $tags['dcterms.publisher'] = $content['value'];
  }
  elseif (!empty($options['default']['dcterms.publisher']['value'])) {
    $tags['dcterms.publisher'] = $options['default']['dcterms.publisher']['value'];
  }
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_extra_dc_title_form(&$form, $content, $options) {
  $form['dcterms.title'] = array(
    '#tree' => TRUE,
    '#weight' => -198,
  );
  $form['dcterms.title']['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Dublin Core: Title'),
    '#description' => t('Enter an alternative title. Do not use the value already used for the HTML tag TITLE, or you will probably get warning reports about duplicated titles from the search engines.'),
    '#default_value' => empty($content['value']) ? '' : $content['value'],
    '#size' => 60,
    '#maxlength' => variable_get('nodewords_max_size', 350),
  );

  // Show the current default.
  if ($options['type'] != NODEWORDS_TYPE_DEFAULT) {

    // Load the current default.
    if (!empty($options['default']['dcterms.title']['value'])) {
      $default = $options['default']['dcterms.title']['value'];
    }
    else {
      $default = t('Not set.');
    }
    $form['dcterms.title']['value']['#description'] .= '<br />' . t('The default is: %default', array(
      '%default' => $default,
    ));
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_extra_dc_title_prepare(&$tags, $content, $options) {
  $tags['dcterms.title'] = empty($content['value']) ? '' : $content['value'];
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_extra_location_form(&$form, $content, $options) {
  $form['location'] = array(
    '#tree' => TRUE,
    '#weight' => -159,
  );
  $form['location']['latitude'] = array(
    '#type' => 'textfield',
    '#title' => t('Geotagging: Latitude'),
    '#default_value' => !empty($content['latitude']) ? $content['latitude'] : '',
    '#element_validate' => array(
      'nodewords_extra_location_latitude_form_validate',
    ),
    '#description' => t('Must be a number between -90.0 and 90.0 (extrems included). Used for the "geo.position" and "icbm" meta tags.'),
    '#size' => 14,
    '#maxlength' => 14,
    '#latitude' => TRUE,
  );
  $form['location']['longitude'] = array(
    '#type' => 'textfield',
    '#title' => t('Geotagging: Longitude'),
    '#default_value' => !empty($content['longitude']) ? $content['longitude'] : '',
    '#description' => t('Must be a number between -180.0 and 180.0 (extrems included). Used for the "geo.position" and "icbm" meta tags.'),
    '#size' => 14,
    '#element_validate' => array(
      'nodewords_extra_location_longitude_form_validate',
    ),
    '#maxlength' => 14,
  );

  // Show the current default.
  if ($options['type'] != NODEWORDS_TYPE_DEFAULT) {

    // Load the current defaults.
    if (!empty($options['default']['location']['latitude'])) {
      $latitude = $options['default']['location']['latitude'];
    }
    else {
      $latitude = t('Not set');
    }
    $form['location']['latitude']['#description'] .= '<br />' . t('The default is: %latitude', array(
      '%latitude' => $latitude,
    ));
    if (!empty($options['default']['location']['longitude'])) {
      $longitude = $options['default']['location']['longitude'];
    }
    else {
      $longitude = t('Not set');
    }
    $form['location']['longitude']['#description'] .= '<br />' . t('The defaults is: %longitude', array(
      '%longitude' => $longitude,
    ));
  }
}

/**
 * Validate the value passed as latitude.
 */
function nodewords_extra_location_latitude_form_validate($element, &$form_state) {
  if (!empty($element['#value']) && (!is_numeric($element['#value']) || $element['#value'] < -90.0 || $element['#value'] > 90.0)) {
    form_error($element, t('Latitude must be a number between -90.0 and 90.0 (extrems included).'));
  }
}

/**
 * Validate the value passed as longitude.
 */
function nodewords_extra_location_longitude_form_validate($element, &$form_state) {
  if (!empty($element['#value']) && (!is_numeric($element['#value']) || $element['#value'] < -180.0 || $element['#value'] > 180.0)) {
    form_error($element, t('Longitude must be a number between -180.0 and 180.0 (extrems included).'));
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_extra_location_prepare(&$tags, $content, $options) {

  // Load the defaults if at one or more of the lat/long values is invalid.
  if (!isset($content['latitude']) || !is_numeric($content['latitude']) || !isset($content['longitude']) || !is_numeric($content['longitude'])) {
    if (isset($options['default']['location']['latitude']) && is_numeric($options['default']['location']['latitude']) && isset($options['default']['location']['longitude']) && is_numeric($options['default']['location']['longitude'])) {
      $content['latitude'] = $options['default']['location']['latitude'];
      $content['longitude'] = $options['default']['location']['longitude'];
    }
  }

  // Compile the output tag.
  if (isset($content['latitude']) && is_numeric($content['latitude']) && isset($content['longitude']) && is_numeric($content['longitude'])) {
    $tags['location:geo.position'] = $content['latitude'] . ';' . $content['longitude'];
    $tags['location:icbm'] = $content['latitude'] . ',' . $content['longitude'];
  }

  // Optional Location.module integration.
  // @TODO: Shouldn't this override existing data, rather than only be used if
  // nothing was previously set?
  $bool = empty($tags['location:geo.position']) && $options['type'] == NODEWORDS_TYPE_NODE && module_exists('location') && ($node = node_load($options['id'])) && isset($node->locations[0]['latitude']) && is_numeric($node->locations[0]['latitude']) && isset($node->locations[0]['longitude']) && is_numeric($node->locations[0]['longitude']);
  if ($bool) {
    $tags['location:geo.position'] = $node->locations[0]['latitude'] . ';' . $node->locations[0]['longitude'];
    $tags['location:icbm'] = $node->locations[0]['latitude'] . ',' . $node->locations[0]['longitude'];
  }
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_extra_shorturl_form(&$form, $content, $options) {
  $form['shorturl'] = array(
    '#tree' => TRUE,
    '#weight' => -138,
  );
  $form['shorturl']['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Short URL'),
    '#description' => t('Short URLs are used instead of the original URL because they are shorter, and easier to remember. Short URLs are provided by some web services, such as <a href="@bitly">bit.ly</a>, <a href="@shorturl">ShortURL</a>, and <a href="@tinyurl">TinyURL</a>.', array(
      '@bitly' => 'http://bit.ly',
      '@shorturl' => 'http://shorturl.com',
      '@tinyurl' => 'http://tinyurl.com',
    )),
    '#default_value' => empty($content['value']) ? '' : $content['value'],
    '#element_validate' => array(
      'nodewords_extra_shorturl_form_validate',
    ),
    '#size' => 60,
    '#maxlength' => variable_get('nodewords_max_size', 350),
  );
}
function nodewords_extra_shorturl_form_validate($element, &$form_state) {
  if (!empty($element['#value'])) {
    if (!valid_url($element['#value'], TRUE)) {
      form_error($element, t('The short URL is not a valid absolute URL.'));
    }
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_extra_shorturl_prepare(&$tags, $content, $options) {
  if (!empty($content['value'])) {
    $tags['shorturl'] = check_url($content['value']);
  }
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_extra_geo_placename_form(&$form, $content, $options) {
  $form['geo.placename'] = array(
    '#tree' => TRUE,
    '#weight' => -151,
  );
  $form['geo.placename']['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Geotagging: Placename'),
    '#description' => t('Usually used to store the address of the location this content is based in or related to.'),
    '#default_value' => empty($content['value']) ? '' : $content['value'],
    '#size' => 60,
    '#maxlength' => variable_get('nodewords_max_size', 350),
  );

  // Show the current default.
  if ($options['type'] != NODEWORDS_TYPE_DEFAULT) {

    // Load the current default.
    if (!empty($options['default']['geo.placename']['value'])) {
      $default = $options['default']['geo.placename']['value'];
    }
    else {
      $default = t('Not set.');
    }
    $form['geo.placename']['value']['#description'] .= '<br />' . t('The default is: %default', array(
      '%default' => $default,
    ));
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_extra_geo_placename_prepare(&$tags, $content, $options) {
  if (!empty($content['value'])) {
    $tags['geo.placename'] = $content['value'];
  }
  elseif (!empty($options['default']['geo.placename']['value'])) {
    $tags['geo.placename'] = $options['default']['geo.placename']['value'];
  }
}

/**
 * Set the form fields used to implement the options for the meta tag.
 */
function nodewords_extra_geo_region_form(&$form, $content, $options) {
  $form['geo.region'] = array(
    '#tree' => TRUE,
    '#weight' => -150,
  );
  $form['geo.region']['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Geotagging: Region'),
    '#description' => t('This is a restricted field that should only be used for storing the ISO 3166-2 country subdivision code, or the two-character country code if the preferred version is not know.'),
    '#default_value' => empty($content['value']) ? '' : $content['value'],
    '#size' => 10,
    '#maxlength' => variable_get('nodewords_max_size', 350),
  );

  // Show the current default.
  if ($options['type'] != NODEWORDS_TYPE_DEFAULT) {

    // Load the current default.
    if (!empty($options['default']['geo.region']['value'])) {
      $default = $options['default']['geo.region']['value'];
    }
    else {
      $default = t('Not set.');
    }
    $form['geo.region']['value']['#description'] .= '<br />' . t('The default is: %default', array(
      '%default' => $default,
    ));
  }
}

/**
 * Set the meta tag content.
 */
function nodewords_extra_geo_region_prepare(&$tags, $content, $options) {
  if (!empty($content['value'])) {
    $tags['geo.region'] = $content['value'];
  }
  elseif (!empty($options['default']['geo.region']['value'])) {
    $tags['geo.region'] = $options['default']['geo.region']['value'];
  }
}

Functions

Namesort descending Description
nodewords_extra_dc_contributor_form Set the form fields used to implement the options for the meta tag.
nodewords_extra_dc_contributor_prepare Set the meta tag content.
nodewords_extra_dc_creator_form Set the form fields used to implement the options for the meta tag.
nodewords_extra_dc_creator_prepare Set the meta tag content.
nodewords_extra_dc_date_form Set the form fields used to implement the options for the meta tag.
nodewords_extra_dc_date_prepare Set the meta tag content.
nodewords_extra_dc_description_form Set the form fields used to implement the options for the meta tag.
nodewords_extra_dc_description_prepare Set the meta tag content.
nodewords_extra_dc_publisher_form Set the form fields used to implement the options for the meta tag.
nodewords_extra_dc_publisher_prepare Set the meta tag content.
nodewords_extra_dc_title_form Set the form fields used to implement the options for the meta tag.
nodewords_extra_dc_title_prepare Set the meta tag content.
nodewords_extra_form_nodewords_settings_form_alter Implements hook_form_FORM_ID_alter().
nodewords_extra_geo_placename_form Set the form fields used to implement the options for the meta tag.
nodewords_extra_geo_placename_prepare Set the meta tag content.
nodewords_extra_geo_region_form Set the form fields used to implement the options for the meta tag.
nodewords_extra_geo_region_prepare Set the meta tag content.
nodewords_extra_location_form Set the form fields used to implement the options for the meta tag.
nodewords_extra_location_latitude_form_validate Validate the value passed as latitude.
nodewords_extra_location_longitude_form_validate Validate the value passed as longitude.
nodewords_extra_location_prepare Set the meta tag content.
nodewords_extra_nodewords_api Implements hook_nodewords_api().
nodewords_extra_nodewords_tags_info Implements hook_nodewords_tags_info().
nodewords_extra_nodewords_tags_output_alter Implementation of hook_nodewords_tags_output_alter().
nodewords_extra_perm Implements hook_perm().
nodewords_extra_shorturl_form Set the form fields used to implement the options for the meta tag.
nodewords_extra_shorturl_form_validate
nodewords_extra_shorturl_prepare Set the meta tag content.