function views_current_path_views_handler_field_current_path::render in Views Current Path (Global: Current Path) 7
Render the field.
Parameters
array $values: The values retrieved from the database.
Overrides views_handler_field::render
File
- handlers/
views_handler_field_current_path.inc, line 118 - Definition of views_handler_field_current_path.
Class
- views_current_path_views_handler_field_current_path
- Views field handler for current path.
Code
function render($values) {
// Display a placeholder (i.e. field id) when editing the view.
if (strpos(current_path(), 'admin/structure/views/nojs/preview/' . $this->view->name . '/') === 0) {
return '[' . $this->options['id'] . ']';
}
$path_format = $this->options['path_format'];
$query_string_support = $this->options['qs_support_fieldset']['query_string_support'];
// In case the path module has been disabled, revert "alias" to "raw".
if (strpos($path_format, 'alias') === 0 && !module_exists('path')) {
$path_format = str_replace('alias-', 'raw-', $path_format);
}
// Determine the URL prefix.
global $base_url;
$url_options = array();
if (function_exists('locale_language_url_rewrite_url')) {
$url_current_path = url(current_path());
locale_language_url_rewrite_url($url_current_path, $url_options);
}
$raw_relative_prefix = base_path() . (isset($url_options['prefix']) ? $url_options['prefix'] : '');
$raw_absolute_prefix = $base_url . $raw_relative_prefix;
// Determine the path.
switch ($path_format) {
case 'raw-internal':
$output = current_path();
break;
case 'raw-relative':
$output = $raw_relative_prefix . current_path();
break;
case 'raw-absolute':
$output = $raw_absolute_prefix . current_path();
break;
case 'alias-internal':
$output = request_path();
break;
case 'alias-relative':
$output = request_uri();
// If using alias-relative, process query string support setting.
switch ($query_string_support) {
// If bypass is selected, skip any changes.
case 'bypass-query-string':
break;
case 'remove-query-string':
if (stripos($output, '?') !== FALSE) {
$output = strtok($output, '?');
}
break;
case 'replace-query-string':
if (stripos($output, '?') !== FALSE) {
$output = strtok($output, '?') . '?';
}
break;
case 'concat-query-string':
if (stripos($output, '?') !== FALSE) {
$output .= '&';
}
else {
$output .= '?';
}
break;
}
break;
case 'alias-absolute':
$output = url(current_path(), array(
'absolute' => TRUE,
));
break;
case 'query-only':
$q_items = array();
parse_str($_SERVER["QUERY_STRING"], $q_items);
// Don't include useless "q=" that some servers return.
unset($q_items['q']);
$output = http_build_query($q_items);
break;
default:
$output = current_path();
}
return $output;
}