array( 'arguments' => array( 'form' => NULL, 'key' => 'adaptivetheme', ), ), ); // Compute the conditional stylesheets. if (!module_exists('conditional_styles')) { include_once drupal_get_path('theme', 'adaptivetheme') .'/inc/template.conditional-styles.inc'; // _conditional_styles_theme() only needs to be run once. if ($theme == 'adaptivetheme') { _conditional_styles_theme($existing, $type, $theme, $path); } } $templates = drupal_find_theme_functions($existing, array('phptemplate', $theme)); $templates += drupal_find_theme_templates($existing, '.tpl.php', $path); return $templates; } /** * Implementation of hook_preprocess() * * This function checks to see if a hook has a preprocess file associated with * it, and if so, loads it. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered. */ function adaptivetheme_preprocess(&$vars, $hook) { global $user; // Get the current user $vars['is_admin'] = in_array('admin', $user->roles); // Check for Admin, logged in $vars['logged_in'] = ($user->uid > 0) ? TRUE : FALSE; if(is_file(drupal_get_path('theme', 'adaptivetheme') . '/inc/template.preprocess-' . str_replace('_', '-', $hook) . '.inc')) { include(drupal_get_path('theme', 'adaptivetheme') . '/inc/template.preprocess-' . str_replace('_', '-', $hook) . '.inc'); } } /** * Include custom function<. */ include_once(drupal_get_path('theme', 'adaptivetheme') .'/inc/template.custom-functions.inc'); /** * Initialize theme settings */ if (is_null(theme_get_setting('user_notverified_display')) || theme_get_setting('rebuild_registry')) { // Auto-rebuild the theme registry during theme development. if (theme_get_setting('rebuild_registry')) { drupal_set_message(t('The theme registry has been rebuilt. Turn off this feature on production websites.', array('!link' => url('admin/build/themes/settings/'. $GLOBALS['theme']))), 'warning'); } global $theme_key; // Get node types $node_types = node_get_types('names'); /** * The default values for the theme variables. Make sure $defaults exactly * matches the $defaults in the theme-settings.php file. */ $defaults = array( 'user_notverified_display' => 1, 'breadcrumb' => 'yes', 'breadcrumb_separator' => ' » ', 'breadcrumb_home' => 0, 'breadcrumb_trailing' => 0, 'breadcrumb_title' => 0, 'search_snippet' => 1, 'search_info_type' => 1, 'search_info_user' => 1, 'search_info_date' => 1, 'search_info_comment' => 1, 'search_info_upload' => 1, 'mission_statement_pages' => 'home', 'taxonomy_display_default' => 'only', 'taxonomy_format_default' => 'vocab', 'taxonomy_enable_content_type' => 0, 'submitted_by_author_default' => 1, 'submitted_by_date_default' => 1, 'submitted_by_enable_content_type' => 0, 'rebuild_registry' => 0, 'load_firebug_lite' => 0, 'at_admin_theme' => 1, 'at_admin_theme_node' => 1, 'at_admin_theme_logo' => 0, 'block_edit_links' => 1, 'at_admin_hide_help' => 0, 'layout_method' => '0', 'layout_width' => '960px', 'layout_sidebar_first_width' => '240', 'layout_sidebar_last_width' => '240', 'layout_enable_settings' => 'off', // set to 'on' to enable, 'off' to disable 'color_schemes' => 'colors-default.css', 'color_enable_schemes' => 'off', // set to 'on' to enable, 'off' to disable ); // Make the default content-type settings the same as the default theme settings, // so we can tell if content-type-specific settings have been altered. $defaults = array_merge($defaults, theme_get_settings()); // Set the default values for content-type-specific settings foreach ($node_types as $type => $name) { $defaults["taxonomy_display_{$type}"] = $defaults['taxonomy_display_default']; $defaults["taxonomy_format_{$type}"] = $defaults['taxonomy_format_default']; $defaults["submitted_by_author_{$type}"] = $defaults['submitted_by_author_default']; $defaults["submitted_by_date_{$type}"] = $defaults['submitted_by_date_default']; } // Get default theme settings. $settings = theme_get_settings($theme_key); // Don't save the toggle_node_info_ variables if (module_exists('node')) { foreach (node_get_types() as $type => $name) { unset($settings['toggle_node_info_'. $type]); } } // Save default theme settings variable_set( str_replace('/', '_', 'theme_'. $theme_key .'_settings'), array_merge($defaults, $settings) ); // Force refresh of Drupal internals theme_get_setting('', TRUE); } // Load collapsed js on blocks page if (theme_get_setting('at_admin_theme')) { if (arg(2) == 'block') { drupal_add_js('misc/collapse.js', 'core', 'header', FALSE, TRUE, TRUE); $path_to_core = path_to_theme() .'/js/core/'; drupal_add_js($path_to_core .'admin.collapseblock.js', 'theme', 'header', FALSE, TRUE, TRUE); drupal_add_js($path_to_core .'jquery.cookie.js', 'theme', 'header', FALSE, TRUE, TRUE); } } // Load Firebug lite if (theme_get_setting('load_firebug_lite')) { $path_to_core = path_to_theme() .'/js/core/'; drupal_add_js($path_to_core .'firebug.lite.compressed.js', 'theme', 'header', FALSE, TRUE, TRUE); } /** * Add the color scheme stylesheet if color_enable_schemes is set to 'on'. * Note: you must have at minimum a color-default.css stylesheet in /css/theme/ */ if (theme_get_setting('color_enable_schemes') == 'on') { drupal_add_css(drupal_get_path('theme', 'adaptivetheme') . '/css/theme/' . get_at_colors(), 'theme'); } /** * 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); } /** * Creates a link with prefix and suffix text * * @param $prefix * The text to prefix the link. * @param $suffix * The text to suffix the link. * @param $text * The text to be enclosed with the anchor tag. * @param $path * The Drupal path being linked to, such as "admin/content/node". Can be an external * or internal URL. * - If you provide the full URL, it will be considered an * external URL. * - If you provide only the path (e.g. "admin/content/node"), it is considered an * internal link. In this case, it must be a system URL as the url() function * will generate the alias. * @param $options * An associative array that contains the following other arrays and values * @param $attributes * An associative array of HTML attributes to apply to the anchor tag. * @param $query * A query string to append to the link. * @param $fragment * A fragment identifier (named anchor) to append to the link. * @param $absolute * Whether to force the output to be an absolute link (beginning with http:). * Useful for links that will be displayed outside the site, such as in an RSS * feed. * @param $html * Whether the title is HTML or not (plain text) * @return * an HTML string containing a link to the given path. */ function _themesettings_link($prefix, $suffix, $text, $path, $options) { return $prefix . (($text) ? l($text, $path, $options) : '') . $suffix; } // Override theme_button for expanding graphic buttons function phptemplate_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"; } } /** * 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 ''; } /** * 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"; }