function _sarnia_build_path in Sarnia 7
Build a path based on Sarnia field formatter settings.
Parameters
int $i: The index of $values that the path should be built from.
array $values: An array of values that will comprise the end of the path.
array $components: An array of values that will comprise the middle of the path. If present, the value corresponding to $i will be used in the path; otherwise, if this is a single value array, the same value will be used for all paths.
string $base_path: A constant value to use as the base for all paths.
1 call to _sarnia_build_path()
- sarnia_field_formatter_view in ./
sarnia.field_formatter.inc - Implements hook_field_formatter_view().
File
- ./
sarnia.field_formatter.inc, line 541 - Field formatter hook implementations.
Code
function _sarnia_build_path($i, $values, $components = array(), $base_path = '') {
$path = '';
// @TODO: Should we run anything here through urlencode()?
if (!empty($values[$i])) {
$path = $values[$i];
if (isset($components[$i])) {
$path = rtrim($components[$i], '/') . '/' . ltrim($path, '/');
}
elseif (count($components) == 1) {
$path = rtrim($components[0], '/') . '/' . ltrim($path, '/');
}
if (!empty($base_path)) {
$path = rtrim($base_path, '/') . '/' . ltrim($path, '/');
}
}
return $path;
}