function views_handler_area_link::options_form in Views link area 7
Same name and namespace in other branches
- 6 views_handler_area_link.inc \views_handler_area_link::options_form()
Default options form that provides the label widget that all fields should have.
Overrides views_handler_area::options_form
File
- ./
views_handler_area_link.inc, line 24
Class
Code
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#default_value' => $this->options['text'],
'#description' => t('The text of the link'),
);
$form['html'] = array(
'#type' => 'checkbox',
'#title' => t('Display link text as HTML'),
'#default_value' => $this->options['html'],
'#description' => t('Show link text as HTML instead of plain text.'),
);
$form['path'] = array(
'#type' => 'textfield',
'#title' => t('Link path'),
'#default_value' => $this->options['path'],
'#description' => t('The Drupal path or full URL to which to link'),
);
$form['querystring'] = array(
'#type' => 'textfield',
'#title' => t('Link querystring'),
'#default_value' => $this->options['querystring'],
'#description' => t('The query parameters that follow the full path'),
);
$form['return'] = array(
'#type' => 'checkbox',
'#title' => t('Set destination as the current page'),
'#default_value' => $this->options['return'],
'#description' => t('If the link leads to a form, this will redirect the user to the view when the form is submitted. This will override any destination set in the querystring option above.'),
);
$form['anchor'] = array(
'#type' => 'textfield',
'#title' => t('Link anchor'),
'#default_value' => $this->options['anchor'],
'#description' => t('The anchor data that follows the full path and query parameters'),
);
$form['attributes'] = array(
'#type' => 'fieldset',
'#title' => t('Attributes'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['class'] = array(
'#type' => 'textfield',
'#title' => t('Link CSS class'),
'#default_value' => $this->options['class'],
'#description' => t('A custom CSS class to add to the link'),
'#fieldset' => 'attributes',
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Link title'),
'#description' => t('Set the title attribute of the link'),
'#default_value' => $this->options['title'],
'#fieldset' => 'attributes',
);
$form['rel'] = array(
'#type' => 'textfield',
'#title' => t('Link rel'),
'#description' => t('Set the rel attribute of the link'),
'#default_value' => $this->options['rel'],
'#fieldset' => 'attributes',
);
$form['prefix'] = array(
'#type' => 'textfield',
'#title' => t('Prefix text'),
'#default_value' => $this->options['prefix'],
'#description' => t('Any text to display before this link. You may include HTML.'),
'#fieldset' => 'attributes',
);
$form['suffix'] = array(
'#type' => 'textfield',
'#title' => t('Suffix text'),
'#default_value' => $this->options['suffix'],
'#description' => t('Any text to display after this link. You may include HTML.'),
'#fieldset' => 'attributes',
);
$target_options = array(
'' => t('None'),
'_blank' => t('New window (_blank)'),
'_parent' => '_parent',
'_self' => '_self',
'_top' => '_top',
);
$form['target'] = array(
'#type' => 'select',
'#title' => t('Link target'),
'#description' => t('Set the target attribute of the link.'),
'#options' => $target_options,
'#default_value' => $this->options['target'],
'#fieldset' => 'attributes',
);
$tokenize_id = drupal_html_id('tokenize_checkbox');
$form['tokenize'] = array(
'#id' => $tokenize_id,
'#type' => 'checkbox',
'#title' => t('Use replacement tokens from the first row'),
'#default_value' => $this->options['tokenize'],
);
// Get a list of the available fields and arguments for token replacement.
$options = array();
foreach ($this->view->display_handler
->get_handlers('field') as $field => $handler) {
$options[t('Fields')]["[{$field}]"] = $handler
->ui_name();
}
$count = 0;
// This lets us prepare the key as we want it printed.
foreach ($this->view->display_handler
->get_handlers('argument') as $arg => $handler) {
$options[t('Arguments')]['%' . ++$count] = t('@argument title', array(
'@argument' => $handler
->ui_name(),
));
$options[t('Arguments')]['!' . $count] = t('@argument input', array(
'@argument' => $handler
->ui_name(),
));
}
$output = t('<p>You must add some additional fields to this display before using this field. These fields may be marked as <em>Exclude from display</em> if you prefer. Note that due to rendering order, you cannot use fields that come after this field; if you need a field not listed here, rearrange your fields.</p>');
if (!empty($options)) {
$output = '';
foreach ($options as $type => $values) {
if (empty($values)) {
continue;
}
$vars = array(
'title' => $type,
);
foreach ($values as $key => $label) {
$vars['items'][] = $key . ' == ' . $label;
}
$output .= theme('item_list', $vars);
}
}
$form['help'] = array(
'#type' => 'fieldset',
'#title' => t('Replacement patterns'),
'#description' => '<p>' . t('The following tokens are available. If you would like to have the characters \'[\' and \']\' please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.') . '</p>',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#value' => $output,
'#dependency' => array(
$tokenize_id => array(
1,
),
),
);
}