";
}
}
}
/**
* Modify search results based on theme settings
*/
function adaptivetheme_preprocess_search_result(&$variables) {
static $search_zebra = 'even';
$search_zebra = ($search_zebra == 'even') ? 'odd' : 'even';
$variables['search_zebra'] = $search_zebra;
$result = $variables['result'];
$variables['url'] = check_url($result['link']);
$variables['title'] = check_plain($result['title']);
// Check for existence. User search does not include snippets.
$variables['snippet'] = '';
if (isset($result['snippet']) && theme_get_setting('search_snippet')) {
$variables['snippet'] = $result['snippet'];
}
$info = array();
if (!empty($result['type']) && theme_get_setting('search_info_type')) {
$info['type'] = check_plain($result['type']);
}
if (!empty($result['user']) && theme_get_setting('search_info_user')) {
$info['user'] = $result['user'];
}
if (!empty($result['date']) && theme_get_setting('search_info_date')) {
$info['date'] = format_date($result['date'], 'small');
}
if (isset($result['extra']) && is_array($result['extra'])) {
// $info = array_merge($info, $result['extra']); Drupal bug? [extra] array not keyed with 'comment' & 'upload'
if (!empty($result['extra'][0]) && theme_get_setting('search_info_comment')) {
$info['comment'] = $result['extra'][0];
}
if (!empty($result['extra'][1]) && theme_get_setting('search_info_upload')) {
$info['upload'] = $result['extra'][1];
}
}
// Provide separated and grouped meta information.
$variables['info_split'] = $info;
$variables['info'] = implode(' - ', $info);
// Provide alternate search result template.
$variables['template_files'][] = 'search-result-'. $variables['type'];
}
/**
* Override username theming to display/hide 'not verified' text
*/
function adaptivetheme_username($object) {
if ($object->uid && $object->name) {
// Shorten the name when it is too long or it will break many tables.
if (drupal_strlen($object->name) > 20) {
$name = drupal_substr($object->name, 0, 15) .'...';
}
else {
$name = $object->name;
}
if (user_access('access user profiles')) {
$output = l($name, 'user/'. $object->uid, array('attributes' => array('title' => t('View user profile.'))));
}
else {
$output = check_plain($name);
}
}
else if ($object->name) {
// Sometimes modules display content composed by people who are
// not registered members of the site (e.g. mailing list or news
// aggregator modules). This clause enables modules to display
// the true author of the content.
if (!empty($object->homepage)) {
$output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
}
else {
$output = check_plain($object->name);
}
// Display or hide 'not verified' text
if (theme_get_setting('user_notverified_display') == 1) {
$output .= ' ('. t('not verified') .')';
}
}
else {
$output = variable_get('anonymous', t('Anonymous'));
}
return $output;
}
/**
* Set default form file input size
*/
function adaptivetheme_file($element) {
$element['#size'] = 60;
return theme_file($element);
}
/**
* Return a themed breadcrumb trail.
*
* @param $breadcrumb
* An array containing the breadcrumb links.
* @return
* A string containing the breadcrumb output.
*/
function adaptivetheme_breadcrumb($breadcrumb) {
// Determine if we are to display the breadcrumb.
$show_breadcrumb = theme_get_setting('breadcrumb_display');
if ($show_breadcrumb == 'yes' || $show_breadcrumb == 'admin' && arg(0) == 'admin') {
// Optionally get rid of the homepage link.
$show_breadcrumb_home = theme_get_setting('breadcrumb_home');
if (!$show_breadcrumb_home) {
array_shift($breadcrumb);
}
// Return the breadcrumb with separators.
if (!empty($breadcrumb)) {
$breadcrumb_separator = theme_get_setting('breadcrumb_separator');
$trailing_separator = $title = '';
if (theme_get_setting('breadcrumb_title')) {
$trailing_separator = $breadcrumb_separator;
$title = menu_get_active_title();
}
elseif (theme_get_setting('breadcrumb_trailing')) {
$trailing_separator = $breadcrumb_separator;
}
return implode($breadcrumb_separator, $breadcrumb) . $trailing_separator . $title;
}
}
// Otherwise, return an empty string.
return '';
}
// Override theme_button for expanding graphic buttons
function adaptivetheme_button($element) {
if (isset($element['#attributes']['class'])) {
$element['#attributes']['class'] = 'form-'. $element['#button_type'] .' '. $element['#attributes']['class'];
}
else {
$element['#attributes']['class'] = 'form-'. $element['#button_type'];
}
// Wrap visible inputs with span tags for button graphics
if (stristr($element['#attributes']['style'], 'display: none;') || stristr($element['#attributes']['class'], 'fivestar-submit')) {
return '\n";
}
else {
return '\n";
}
}
/**
* Format a group of form items.
*
* @param $element
* An associative array containing the properties of the element.
*
* @return
* A themed HTML string representing the form item group.
*/
function adaptivetheme_fieldset($element) {
if ($element['#collapsible']) {
drupal_add_js('misc/collapse.js');
if (!isset($element['#attributes']['class'])) {
$element['#attributes']['class'] = '';
}
$element['#attributes']['class'] .= ' collapsible';
if ($element['#collapsed']) {
$element['#attributes']['class'] .= ' collapsed';
}
}
// Custom fieldset CSS class from element #title.
$css_class = 'fieldset-'. safe_string($element['#title']);
$element['#attributes']['class'] .= (!empty($element['#attributes']['class']) ? " " : "") . $css_class;
return '\n";
}
/**
* Modify the theme settings form for our theme.
*
* This is incldued here to make it easier to set up the theme, so
* you only have one file to worry about search/repeace the theme name.
*/
function adaptivetheme_system_settings_form($form) {
// Theme the crap out of the theme settings fieldsets.
$form['theme_settings']['#title'] = t('Drupal core theme settings');
$form['theme_settings']['#collapsible'] = TRUE;
$form['theme_settings']['#collapsed'] = TRUE;
$form['theme_settings']['#prefix'] = '