function opengraph_meta_settings_form in Open Graph meta tags 7
Same name and namespace in other branches
- 6 opengraph_meta.admin.inc \opengraph_meta_settings_form()
Menu callback: settings form.
1 string reference to 'opengraph_meta_settings_form'
- opengraph_meta_menu in ./
opengraph_meta.module - Implementation of hook_menu.
File
- ./
opengraph_meta.admin.inc, line 9
Code
function opengraph_meta_settings_form() {
$types = OpenGraphMetaDrupalLayer::get_node_types();
$type_options = array();
foreach ($types as $id => $data) {
$type_options[$id] = $data->name;
}
$form[OPENGRAPH_META_VAR_CONTENT_TYPES_ENABLED] = array(
'#title' => t('Enable for the following content types'),
'#type' => 'checkboxes',
'#options' => $type_options,
'#description' => t('The content types for which to enable Open Graph meta tags. If none are selected then tags will be enabled for ALL content types.'),
'#default_value' => variable_get(OPENGRAPH_META_VAR_CONTENT_TYPES_ENABLED, array()),
);
$form['defaults'] = array(
'#type' => 'fieldset',
'#title' => 'Default values for meta tags',
);
$form['defaults'][OPENGRAPH_META_VAR_SITE_NAME] = array(
'#title' => t('Site name'),
'#type' => 'textfield',
'#description' => t('The value for the %site_name meta tag.', array(
'%site_name' => 'og:site_name',
)),
'#default_value' => variable_get(OPENGRAPH_META_VAR_SITE_NAME, variable_get('site_name', 'Drupal')),
);
$form['defaults'][OPENGRAPH_META_VAR_FALLBACK_IMG] = array(
'#title' => t('Fallback image'),
'#type' => 'textfield',
'#description' => t('Absolute or site-relative URL to an image to use for the %tag tag for nodes which don\'t have their own images.', array(
'%tag' => 'og:image',
)),
'#default_value' => variable_get(OPENGRAPH_META_VAR_FALLBACK_IMG, ''),
);
$form['defaults']['types'] = array(
'#type' => 'fieldset',
'#title' => t('Mapping content type to meta type'),
'#description' => t('These can be overridden on a per-node basis.'),
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
foreach ($types as $id => $data) {
$form['defaults']['types'][OPENGRAPH_META_VAR_CONTENT_TYPE_ . $id] = array(
'#title' => $data->name,
'#type' => 'select',
'#options' => OpenGraphMeta::instance()
->get_all_og_types_for_select_field(),
'#description' => t('The value for the %ogtype meta tag for nodes of type %type. If left unset then the %ogtype tag will not get output for this content type.', array(
'%ogtype' => 'og:type',
'%type' => $id,
)),
'#default_value' => variable_get(OPENGRAPH_META_VAR_CONTENT_TYPE_ . $id, ''),
);
}
// optional tags defaults
$optionals = new stdClass();
$optionals->opengraph_meta = variable_get(OPENGRAPH_META_VAR_OPTIONAL_TAGS, array());
// Location stuff
$form['defaults']['location'] = array(
'#type' => 'fieldset',
'#title' => t('Location tags'),
'#description' => t('These can be overridden on a per-node basis.'),
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 100,
);
$form['defaults']['location'] = array_merge($form['defaults']['location'], _opengraph_meta_location_form_fields($optionals));
// Contact stuff
$form['defaults']['contact'] = array(
'#type' => 'fieldset',
'#title' => t('Contact tags'),
'#description' => t('These can be overridden on a per-node basis.'),
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 100,
);
$form['defaults']['contact'] = array_merge($form['defaults']['contact'], _opengraph_meta_contact_form_fields($optionals));
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Save',
);
return $form;
}