class context_metadata_reaction in Context Metadata 7
Same name and namespace in other branches
- 6 plugins/context_metadata_reaction.inc \context_metadata_reaction
@file context reaction
Hierarchy
- class \context_reaction
- class \context_metadata_reaction
Expanded class hierarchy of context_metadata_reaction
1 string reference to 'context_metadata_reaction'
- context_metadata_context_plugins in ./
context_metadata.module - Implements hook_context_plugins()
File
- plugins/
context_metadata_reaction.inc, line 6 - context reaction
View source
class context_metadata_reaction extends context_reaction {
function options_form($context) {
$values = $this
->fetch_from_context($context);
$form['metadata_title'] = array(
'#title' => t('Meta Title'),
'#description' => t('Title goes here'),
'#type' => 'textfield',
'#maxlength' => 256,
'#default_value' => isset($values['metadata_title']) ? $values['metadata_title'] : '',
);
$form['metadata_description'] = array(
'#title' => t('Meta Description'),
'#description' => t('Meta Description'),
'#type' => 'textfield',
'#maxlength' => 400,
'#default_value' => isset($values['metadata_description']) ? $values['metadata_description'] : '',
);
$form['metadata_keywords'] = array(
'#title' => t('Meta Keywords'),
'#description' => t('Meta Keywords'),
'#type' => 'textfield',
'#maxlength' => 400,
'#default_value' => isset($values['metadata_keywords']) ? $values['metadata_keywords'] : '',
);
$form['metadata_canonical'] = array(
'#title' => t('Canonical URL'),
'#description' => t('Canonical URL'),
'#type' => 'textfield',
'#maxlength' => 400,
'#default_value' => isset($values['metadata_canonical']) ? $values['metadata_canonical'] : '',
);
$form['metadata_h1'] = array(
'#title' => t('H1 tag'),
'#description' => t('Overrides the H1 title'),
'#type' => 'textfield',
'#maxlength' => 400,
'#default_value' => isset($values['metadata_h1']) ? $values['metadata_h1'] : '',
);
$form['metadata_robots'] = array(
'#title' => t('Robots'),
'#description' => t('Robots'),
'#type' => 'textfield',
'#maxlength' => 400,
'#default_value' => isset($values['metadata_robots']) ? $values['metadata_robots'] : '',
);
$form['tokens'] = array(
'#theme' => 'token_tree',
'#token_types' => array(
'node',
),
// The token types that have specific context. Can be multiple token types like 'term' and/or 'user'
'#global_types' => TRUE,
// A boolean TRUE or FALSE whether to include 'global' context tokens like [current-user:*] or [site:*]. Defaults to TRUE.
'#click_insert' => TRUE,
);
return $form;
}
/**
* Output a list of active contexts.
*/
function execute() {
$contexts = context_active_contexts();
foreach ($contexts as $context) {
if (!empty($context->reactions['context_metadata'])) {
$metadata_array = $context->reactions['context_metadata'];
$metadata =& drupal_static('metadata_array');
foreach ($metadata_array as $key => $value) {
if (!empty($value)) {
$metadata[$key] = t(check_plain($value));
}
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
context_metadata_reaction:: |
function | Output a list of active contexts. | ||
context_metadata_reaction:: |
function |
Overrides context_reaction:: |
||
context_reaction:: |
property | |||
context_reaction:: |
property | |||
context_reaction:: |
property | |||
context_reaction:: |
function | Retrieve options from the context provided. | 1 | |
context_reaction:: |
function | Retrieve active contexts that have values for this reaction. | ||
context_reaction:: |
function | Options form submit handler. | 3 | |
context_reaction:: |
function | Settings form. Provide variable settings for your reaction. | 2 | |
context_reaction:: |
function | Clone our references when we're being cloned. | ||
context_reaction:: |
function | Constructor. Do not override. |