function views_add_button_area::render in Views Add Button 7
Render the area.
Overrides views_handler_area::render
File
- views/
views_add_button_area.inc, line 107 - Definition of views_add_button_area.
Class
- views_add_button_area
- Views area text handler.
Code
function render($empty = FALSE) {
if (!$empty || !empty($this->options['empty'])) {
$content_type = check_plain($this->options['content_type']);
if (user_access('create ' . $content_type . ' content') || user_access('bypass node access')) {
$content_type_hyphen = str_replace('_', '-', $content_type);
$ct_options = array();
foreach (node_type_get_types() as $key => $type) {
$ct_options[$key] = $type->name;
}
$query_string = filter_xss($this->options['query_string']);
$button_classes = check_plain($this->options['button_classes']);
if ($this->options['tokenize']) {
$query_string = $this->view->style_plugin
->tokenize_value($query_string, 0);
$button_classes = $this->view->style_plugin
->tokenize_value($button_classes, 0);
}
// Build the link
$url = '/node/add/' . $content_type_hyphen;
$url .= $query_string ? '?' . $query_string : '';
if ($this->options['destination'] && strpos($url, 'destination') === FALSE) {
$url .= $query_string ? '&destination=' . current_path() : '?destination=' . current_path();
}
$l = '<a href="' . $url . '" class="' . $button_classes . '">' . t('Add ' . $ct_options[$content_type]) . '</a>';
return $l;
}
return '';
}
return '';
}