You are here

function _opengraph_meta_contact_form_fields in Open Graph meta tags 7

Same name and namespace in other branches
  1. 6 opengraph_meta.module \_opengraph_meta_contact_form_fields()
3 calls to _opengraph_meta_contact_form_fields()
opengraph_meta_form_alter in ./opengraph_meta.module
Implementation of hook_form_alter.
opengraph_meta_settings_form in ./opengraph_meta.admin.inc
Menu callback: settings form.
opengraph_meta_settings_form_submit in ./opengraph_meta.admin.inc

File

./opengraph_meta.module, line 154

Code

function _opengraph_meta_contact_form_fields($node = NULL) {
  $ret = array();
  $fields = array(
    OpenGraphMeta::EMAIL => array(
      'Email',
      'Email address.',
    ),
    OpenGraphMeta::PHONE_NUMBER => array(
      'Phone number',
      'Phone number.',
    ),
    OpenGraphMeta::FAX_NUMBER => array(
      'Fax number',
      'Fax number.',
    ),
  );
  $defaults = OpenGraphMeta::instance()
    ->get_og_optional_tag_defaults($node);
  foreach ($fields as $f => $i) {
    $default_value = '';
    if (!empty($node->opengraph_meta) && !empty($node->opengraph_meta[$f])) {
      $default_value = $node->opengraph_meta[$f];
    }
    $ret[$f] = array(
      '#title' => t($i[0]),
      '#type' => 'textfield',
      '#maxlength' => 255,
      '#default_value' => $default_value,
      '#description' => t($i[1]),
    );

    // global fallback value?
    if (!empty($node) && isset($node->nid) && !empty($defaults[$f])) {
      $ret[$f]['#description'] .= t(' If left unset then the global fallback value will be used: "@s"', array(
        '@s' => $defaults[$f],
      ));
    }
  }
  return $ret;
}