function community_tags_form in Community Tags 6.2
Same name and namespace in other branches
- 5 community_tags.module \community_tags_form()
- 6 community_tags.pages.inc \community_tags_form()
- 7 community_tags.pages.inc \community_tags_form()
Quick tag form.
Related topics
4 string references to 'community_tags_form'
- community_tags_from_js in ./
community_tags.ajax.inc - Callback for the JS tagger.
- community_tags_node_view in ./
community_tags.module - Community tags callback for node view.
- community_tags_ui_tag in community_tags_ui/
community_tags_ui.module - Menu page callback for community-tags/%ctools_js/tag/%node/%vocabulary
- community_tags_views_plugin_attachment_tagform::render in community_tags_views/
views/ plugins/ community_tags_views_plugin_attachment_tagform.inc
File
- ./
community_tags.pages.inc, line 16 - community_tags.pages.inc
Code
function community_tags_form($form_state, $edit, $title = NULL) {
$form['#attributes'] = array(
'class' => 'community-tags-form',
);
$vocabulary = taxonomy_vocabulary_load($edit['vid']);
if ($edit['cloud']) {
if ($edit['multiple'] > 1) {
// displaying more than 1 form so need to differentiate in headings
$all_title = t('All !name tags', array(
'!name' => $vocabulary->name,
));
}
else {
$all_title = t('All tags');
}
// attributes doesn't apply to type of item so wrap in a div to set class
$form['cloud'] = array(
'#prefix' => '<div class="ct-all-tags">',
'#type' => 'item',
'#title' => $all_title,
'#value' => '<div class="ct-cloud">' . $edit['cloud'] . '</div>',
'#suffix' => '</div>',
);
}
// anonymous tagging not supported
$access = user_is_logged_in() && user_access('tag content');
if ($edit['multiple'] > 1) {
// displaying more than 1 form so need to differentiate in headings
$my_title = t('My !name tags', array(
'!name' => $vocabulary->name,
));
}
else {
$my_title = t('My tags');
}
$form['tags'] = array(
'#prefix' => '<div class="ct-my-tags">',
'#type' => 'textfield',
'#title' => $my_title,
'#maxlength' => 100,
'#default_value' => $edit['tags'],
'#required' => FALSE,
'#autocomplete_path' => 'taxonomy/autocomplete/' . $edit['vid'],
'#attributes' => array(
'class' => 'form-tags form-tags-' . $edit['vid'],
),
'#access' => $access,
'#suffix' => '</div>',
);
if ($edit['inline']) {
$form['tags']['#size'] = 20;
}
if (!$access) {
$destination = drupal_get_destination();
$form['login'] = array(
'#type' => 'markup',
);
if (variable_get('user_register', true)) {
$form['login']['#value'] = '<div>' . t('<a href="@login">Login</a> or <a href="@register">register</a> to tag items', array(
'@login' => url('user/login', array(
'query' => $destination,
)),
'@register' => url('user/register', array(
'query' => $destination,
)),
)) . '</div>';
}
else {
$form['login']['#value'] = '<div>' . t('<a href="@login">Login</a> to tag items', array(
'@login' => url('user/login', array(
'query' => $destination,
)),
)) . '</div>';
}
}
else {
// supply this as we
$form['tags_refs'] = array(
'#type' => 'hidden',
'#value' => $edit['tags'],
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#access' => $access,
);
$form['node'] = array(
'#type' => 'value',
'#value' => $edit['node'],
);
$form['nid'] = array(
'#type' => 'hidden',
'#title' => t('NID'),
'#value' => $edit['nid'],
);
$form['vid'] = array(
'#type' => 'hidden',
'#default_value' => $edit['vid'],
);
if ($edit['links_container_class']) {
$form['links_container_class'] = array(
'#type' => 'hidden',
'#value' => $edit['links_container_class'],
);
}
if ($edit['source']) {
$form['source'] = array(
'#type' => 'hidden',
'#value' => $edit['source'],
);
}
if (!empty($edit['extra'])) {
foreach ($edit['extra'] as $name => $value) {
$form[$name] = array(
'#type' => 'hidden',
'#value' => $value,
);
}
}
return $form;
// drupal_add_js(array('communityTags' => array('n_'. $node->nid => array('v_'. $vid => array('tags' => $names, 'url' => url('community-tags/js/'. $node->nid .'/'. $vid), 'add' => t('Add'), 'token' => drupal_get_token('community_tags_form'))))), 'setting');
}