function template_preprocess_views_galleriffic_view_gallerifficrows in Views Galleriffic 7
Same name and namespace in other branches
- 6 views_galleriffic.module \template_preprocess_views_galleriffic_view_gallerifficrows()
Implementation of template preprocess for the view fields
File
- ./
views_galleriffic.module, line 86 - Views Galleriffic module file.
Code
function template_preprocess_views_galleriffic_view_gallerifficrows(&$vars) {
$view = $vars['view'];
$options = $vars['options'];
// Ensure it's at least an empty array.
$vars['fields'] = array();
foreach ($view->field as $id => $field) {
$field_output = $view->field[$id]
->theme($vars['row']);
$object = array();
$object['content'] = $field_output;
// Find the option (ie title, description, slide, thumbnail) for the field.
foreach ($options as $field_title => $field_label) {
if ($field_label == $id) {
$object['option'] = $field_title;
}
}
// This is to check if the field has an option. If not ignore.
if (count($object) > 1) {
$vars['fields'][$object['option']]->content = $object['content'];
if ($object['option'] == 'title_field') {
$vars['fields']['title']->content = check_markup($vars['fields']['title_field']->content, $format_id = 'full_html', '', $check = FALSE);
// Slideshow can break if there are spaces or '#' in the title.
$vars['fields']['title']->stripped = str_replace('#', '', str_replace(' ', '', strip_tags($vars['fields']['title_field']->content)));
}
if ($object['option'] == 'description_field') {
$vars['fields']['desc']->content = check_markup($vars['fields']['description_field']->content, $format_id = 'full_html', '', $check = FALSE);
}
if ($object['option'] == 'thumbnail_field') {
if (preg_match('/(src=")(\\S+)(")/', $vars['fields']['thumbnail_field']->content, $thumb_url)) {
$vars['fields']['thumbnail']->content = $thumb_url['2'];
}
}
if ($object['option'] == 'slide_field') {
if (preg_match('/(src=")(\\S+)(")/', $vars['fields']['slide_field']->content, $slide_url)) {
$vars['fields']['slide']->content = $slide_url['2'];
}
}
}
}
// Allow for empty fields that didn't already get defined.
if (!array_key_exists('desc', $vars['fields'])) {
$vars['fields']['desc'] = NULL;
}
if (!array_key_exists('title', $vars['fields'])) {
$vars['fields']['title'] = NULL;
}
}