function metatag_context_config_edit_form in Metatag 7
FormAPI callback to build the edit form.
1 string reference to 'metatag_context_config_edit_form'
- metatag_context_menu in metatag_context/
metatag_context.module - Implements hook_menu().
File
- metatag_context/
metatag_context.admin.inc, line 109 - Admin settings page for Metatag Context.
Code
function metatag_context_config_edit_form($form, &$form_state, $context) {
$form_state['metatag_context']['context'] = $context;
// Empty form to start with.
$form = array();
// Don't care about the instance name, the data is being managed by Context
// and not Metatag.
$instance = "";
$options = array(
'token types' => array(
'node',
'term',
'user',
),
);
$metatags = $context->reactions['metatag_context_reaction']['metatags'];
if (!isset($metatags[LANGUAGE_NONE])) {
$metatags = array(
LANGUAGE_NONE => $metatags,
);
}
// Load the METATAG form.
metatag_metatags_form($form, $instance, $metatags[LANGUAGE_NONE], $options);
$form['paths'] = array(
'#title' => 'Path',
'#description' => t('Set this metatag context when any of the paths above match the page path. Put each path on a separate line. You can use the <code>*</code> character (asterisk) as a wildcard and the <code>~</code> character (tilde) to exclude one or more paths. Use <code><front></code> for the site front page. Only local paths (e.g. "example/page") will work, do not use relative URLs ("/example/page") or absolute URLs ("http://example.com/example/page").'),
'#type' => 'textarea',
'#default_value' => isset($context->conditions['path']['values']) ? html_entity_decode(implode(' ', $context->conditions['path']['values'])) : '',
'#required' => 1,
'#weight' => -100,
);
// If other conditions are assigned, mention it.
$conditions = array_keys($context->conditions);
foreach ($conditions as $key => $condition) {
if ($condition == 'path') {
unset($conditions[$key]);
}
}
if (!empty($conditions)) {
$form['other_conditions'] = array(
'#prefix' => '<p><em>',
'#markup' => t('Other conditions have been assigned that must be controlled through the main Context settings page.'),
'#suffix' => '</em></p>',
'#weight' => -99.90000000000001,
);
}
$form['help'] = array(
'#prefix' => '<hr /><p><em>',
'#markup' => t('Values assigned here inherit from the <a href="@url" title="Edit the global default meta tags.">global defaults</a>.', array(
'@url' => url('admin/config/search/metatags/config/global'),
)),
'#suffix' => '</em></p>',
'#weight' => -99,
);
$form['metatags']['#type'] = 'container';
unset($form['metatags']['#collapsed']);
unset($form['metatags']['#collapsible']);
$form['actions']['#type'] = 'actions';
$form['actions']['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
$form['actions']['cancel'] = array(
'#type' => 'link',
'#title' => t('Cancel'),
'#href' => isset($_GET['destination']) ? $_GET['destination'] : 'admin/config/search/metatags/context',
);
$form['#submit'][] = 'metatag_context_config_edit_form_submit';
return $form;
}