function nodewords_tags_edit_fields in Nodewords: D6 Meta Tags 6.3
Same name and namespace in other branches
- 6.2 nodewords.module \nodewords_tags_edit_fields()
Return the form used to set the meta tags values.
Parameters
$type: An array containing the type of the object, and its ID.
$tags: The meta tags array as returned by nodewords_load_tags().
Return value
An array as requested by the form version.
5 calls to nodewords_tags_edit_fields()
- nodewords_admin_form_taxonomy_form_term_alter in nodewords_admin/
nodewords_admin.module - Implements hook_form_FORM_ID_alter().
- nodewords_admin_form_taxonomy_form_vocabulary_alter in nodewords_admin/
nodewords_admin.module - Implements hook_form_FORM_ID_alter().
- nodewords_admin_tags_edit_form in nodewords_admin/
nodewords_admin.admin.inc - Meta tags edit form.
- nodewords_ui_form_alter in nodewords_ui/
nodewords_ui.module - Implements hook_form_alter().
- nodewords_ui_user in nodewords_ui/
nodewords_ui.module - Implements hook_user().
File
- ./
nodewords.module, line 722 - Implement an version that other modules can use to add meta tags.
Code
function nodewords_tags_edit_fields($object, $tags, array $options = array()) {
$form = array();
$tokens_support = FALSE;
$tokens_type = array();
$options += array(
'admin' => FALSE,
'collapsed' => TRUE,
'collapsible' => TRUE,
'description' => '',
'fieldset' => FALSE,
'title' => t('Meta tags'),
'weight' => 20,
);
$edit_tags = variable_get(!empty($options['admin']) ? 'nodewords_admin_edit' : 'nodewords_ui_edit', array());
$head_output = variable_get('nodewords_head', array());
$tokens_enabled = module_exists('token') && variable_get('nodewords_enable_tokens', TRUE);
$object += _nodewords_get_default_metatags_type();
if (isset($options['tag options']) && is_array($options['tag options'])) {
$tag_options = $options['tag options'] + $object;
}
else {
$tag_options = $object;
}
nodewords_load_all_includes('nodewords.tags.inc');
nodewords_load_all_includes('nodewords.hooks.inc');
$filter_metatags = $object['type'] != NODEWORDS_TYPE_DEFAULT;
foreach (nodewords_get_possible_tags() as $name => $info) {
$description = array();
$permission = TRUE;
drupal_alter('metatags_permission', $permission, $object, $name, $info);
if ($permission) {
$bool = !empty($info['context']['allowed']) && is_array($info['context']['allowed']) && !in_array($object['type'], $info['context']['allowed']) || !empty($info['context']['denied']) && is_array($info['context']['denied']) && in_array($object['type'], $info['context']['denied']);
if ($bool || $filter_metatags && empty($edit_tags[$name])) {
continue;
}
if (!empty($info['tokens'])) {
$description[] = ' <strong>' . t('This meta tag supports tokens.') . '</strong>';
$tokens_support = TRUE;
}
if (empty($head_output[$name]) && user_access('administer meta tags')) {
$description[] = ' ' . t('This meta tag has not been selected to be output in HTML.');
}
if (function_exists($function = $info['callback'] . '_form')) {
if (!empty($description)) {
$tag_options['description'] = implode('', $description);
}
else {
$tag_options['description'] = '';
}
$tag_options['parameters'] = !empty($info['callback arguments']) ? $info['callback arguments'] : array();
$function($form_metatags, _nodewords_tag_value($name, isset($tags[$name]) ? $tags[$name] : array(), $object + array(
'admin' => $options['admin'],
)), $tag_options);
}
}
}
if (!empty($form_metatags) && $options['fieldset']) {
$form['#tree'] = TRUE;
$form['#type'] = 'fieldset';
$form['#title'] = $options['title'];
$form['#description'] = $options['description'];
$form['#collapsible'] = $options['collapsible'];
$form['#collapsed'] = $options['collapsed'];
$form['#weight'] = $options['weight'];
$form['#group'] = 'additional_settings';
}
if (!empty($options['first fields'])) {
$form = $options['first fields'] + $form;
}
if (!empty($form_metatags)) {
$form['metatags'] = $form_metatags;
}
if ($tokens_enabled && $tokens_support) {
nodewords_add_tokens_help($form, $type);
}
if (!empty($options['last fields'])) {
$form += $options['last fields'];
}
return $form;
}