array( '!IE' => FALSE, ), 'weight' => 500, 'group' => 5000, 'every_page' => TRUE, )); // Disable sticky in the sidebar. Set option in JS $disable_sticky = theme_get_setting('rubik_disable_sticky_sidebar'); drupal_add_js(array('rubik' => array('disable_sticky' => $disable_sticky)), array('type' => 'setting')); } /** * Implements hook_css_alter(). * @TODO: Do this in .info once http://drupal.org/node/575298 is committed. */ function rubik_css_alter(&$css) { if (isset($css['modules/overlay/overlay-child.css'])) { $css['modules/overlay/overlay-child.css']['data'] = drupal_get_path('theme', 'rubik') . '/css/overlay-child.css'; } if (isset($css['modules/shortcut/shortcut.css'])) { $css['modules/shortcut/shortcut.css']['data'] = drupal_get_path('theme', 'rubik') . '/css/shortcut.css'; } } /** * Implementation of hook_theme(). */ function rubik_theme() { $items = array(); // Content theming. $items['help'] = $items['node'] = $items['comment'] = $items['comment_wrapper'] = array( 'path' => drupal_get_path('theme', 'rubik') .'/templates', 'template' => 'object', ); $items['node']['template'] = 'node'; // Help pages really need help. See preprocess_page(). $items['help_page'] = array( 'variables' => array('content' => array()), 'path' => drupal_get_path('theme', 'rubik') .'/templates', 'template' => 'object', 'preprocess functions' => array( 'template_preprocess', 'rubik_preprocess_help_page', ), 'process functions' => array('template_process'), ); if (!theme_get_setting('rubik_disable_sidebar_in_form')) { // Form layout: default (2 column). $items['block_add_block_form'] = $items['block_admin_configure'] = $items['comment_form'] = $items['contact_admin_edit'] = $items['contact_mail_page'] = $items['contact_mail_user'] = $items['filter_admin_format_form'] = $items['forum_form'] = $items['locale_languages_edit_form'] = $items['menu_edit_menu'] = $items['menu_edit_item'] = $items['node_type_form'] = $items['path_admin_form'] = $items['system_settings_form'] = $items['system_themes_form'] = $items['system_modules'] = $items['system_actions_configure'] = $items['taxonomy_form_term'] = $items['taxonomy_form_vocabulary'] = $items['user_profile_form'] = $items['user_admin_access_add_form'] = array( 'render element' => 'form', 'path' => drupal_get_path('theme', 'rubik') .'/templates', 'template' => 'form-default', 'preprocess functions' => array( 'rubik_preprocess_form_buttons', ), ); // These forms require additional massaging. $items['confirm_form'] = array( 'render element' => 'form', 'path' => drupal_get_path('theme', 'rubik') .'/templates', 'template' => 'form-simple', 'preprocess functions' => array( 'rubik_preprocess_form_confirm' ), ); $items['node_form'] = array( 'render element' => 'form', 'path' => drupal_get_path('theme', 'rubik') .'/templates', 'template' => 'form-default', 'preprocess functions' => array( 'rubik_preprocess_form_buttons', 'rubik_preprocess_form_node', ), ); } return $items; } /** * Preprocessor for theme('page'). */ function rubik_preprocess_page(&$vars) { // Show a warning if base theme is not present. if (!function_exists('tao_theme') && user_access('administer site configuration')) { drupal_set_message(t('The Rubik theme requires the !tao base theme in order to work properly.', array('!tao' => l('Tao', 'http://drupal.org/project/tao'))), 'warning'); } // Set a page icon class. $vars['page_icon_class'] = ($item = menu_get_item()) ? implode(' ' , _rubik_icon_classes($item['href'])) : ''; // Help pages. They really do need help. if (strpos($_GET['q'], 'admin/help/') === 0 && isset($vars['page']['content']['system_main']['main']['#markup'])) { $vars['page']['content']['system_main']['main']['#markup'] = theme('help_page', array('content' => $vars['page']['content']['system_main']['main']['#markup'])); } // Clear out help text if empty. if (empty($vars['help']) || !(strip_tags($vars['help']))) { $vars['help'] = ''; } // Process local tasks. This will get called for rubik and its subthemes. _rubik_local_tasks($vars); // Overlay is enabled. $vars['overlay'] = (module_exists('overlay') && overlay_get_mode() === 'child'); } /** * Preprocessor for theme('fieldset'). */ function rubik_preprocess_fieldset(&$vars) { if (!empty($vars['element']['#collapsible'])) { $vars['title'] = "" . $vars['title']; } } /** * Preprocessor for handling form button for most forms. */ function rubik_preprocess_form_buttons(&$vars) { if (!empty($vars['form']['actions'])) { $vars['actions'] = $vars['form']['actions']; unset($vars['form']['actions']); } } /** * Preprocessor for theme('confirm_form'). */ function rubik_preprocess_form_confirm(&$vars) { // Move the title from the page title (usually too big and unwieldy) $title = filter_xss_admin(drupal_get_title()); $vars['form']['description']['#type'] = 'item'; $vars['form']['description']['#value'] = empty($vars['form']['description']['#value']) ? "{$title}" : "{$title}

{$vars['form']['description']['#value']}

"; drupal_set_title(t('Please confirm')); } /** * Preprocessor for theme('node_form'). */ function rubik_preprocess_form_node(&$vars) { $vars['sidebar'] = isset($vars['sidebar']) ? $vars['sidebar'] : array(); $map = array(); // Support field_group if present. if (module_exists('field_group')) { $map += array( 'group_sidebar' => 'sidebar', 'group_footer' => 'footer', ); } // Support nodeformcols if present. if (module_exists('nodeformcols')) { $map += array( 'nodeformcols_region_right' => 'sidebar', 'nodeformcols_region_footer' => 'footer', 'nodeformcols_region_main' => NULL, ); } if (isset($map)) { foreach ($map as $region => $target) { if (isset($vars['form'][$region])) { if (isset($vars['form'][$region]['#prefix'], $vars['form'][$region]['#suffix'])) { unset($vars['form'][$region]['#prefix']); unset($vars['form'][$region]['#suffix']); } if (isset($vars['form'][$region]['actions'], $vars['form'][$region]['actions'])) { $vars['actions'] = $vars['form'][$region]['actions']; unset($vars['form'][$region]['actions']); } if (isset($target)) { $vars[$target] = $vars['form'][$region]; unset($vars['form'][$region]); } } } } // Default to showing taxonomy in sidebar if nodeformcols is not present. elseif (isset($vars['form']['taxonomy']) && empty($vars['sidebar'])) { $vars['sidebar']['taxonomy'] = $vars['form']['taxonomy']; unset($vars['form']['taxonomy']); } } /** * Preprocessor for theme('button'). */ function rubik_preprocess_button(&$vars) { if (isset($vars['element']['#value'])) { $classes = array( t('Save') => 'yes', t('Submit') => 'yes', t('Yes') => 'yes', t('Add') => 'add', t('Delete') => 'remove', t('Remove') => 'remove', t('Cancel') => 'no', t('No') => 'no', ); foreach ($classes as $search => $class) { if (strpos($vars['element']['#value'], $search) !== FALSE) { $vars['element']['#attributes']['class'][] = 'button-' . $class; break; } } } } /** * Preprocessor for theme('help'). */ function rubik_preprocess_help(&$vars) { $vars['hook'] = 'help'; $vars['attr']['id'] = 'help-text'; $class = 'path-admin-help clear-block toggleable'; $vars['attr']['class'] = isset($vars['attr']['class']) ? "{$vars['attr']['class']} $class" : $class; $help = menu_get_active_help(); if (($test = strip_tags($help)) && !empty($help)) { // Thankfully this is static cached. $vars['attr']['class'] .= menu_secondary_local_tasks() ? ' with-tabs' : ''; $vars['is_prose'] = TRUE; $vars['layout'] = TRUE; $vars['content'] = "" . $help; // Link to help section. $item = menu_get_item('admin/help'); if ($item && $item['path'] === 'admin/help' && $item['access']) { $vars['links'] = l(t('More help topics'), 'admin/help'); } } } /** * Preprocessor for theme('help_page'). */ function rubik_preprocess_help_page(&$vars) { $vars['hook'] = 'help-page'; $vars['title_attributes_array']['class'][] = 'help-page-title'; $vars['title_attributes_array']['class'][] = 'clearfix'; $vars['content_attributes_array']['class'][] = 'help-page-content'; $vars['content_attributes_array']['class'][] = 'clearfix'; $vars['content_attributes_array']['class'][] = 'prose'; $vars['layout'] = TRUE; // Truly hackish way to navigate help pages. $module_info = system_rebuild_module_data(); $empty_arg = drupal_help_arg(); $modules = array(); foreach (module_implements('help', TRUE) as $module) { if (module_invoke($module, 'help', "admin/help#$module", $empty_arg)) { $modules[$module] = $module_info[$module]->info['name']; } } asort($modules); $links = array(); foreach ($modules as $module => $name) { $links[] = array('title' => $name, 'href' => "admin/help/{$module}"); } $vars['links'] = theme('links', array('links' => $links)); } /** * Preprocessor for theme('node'). */ function rubik_preprocess_node(&$vars) { $vars['layout'] = TRUE; if ($vars['display_submitted']) { $vars['submitted'] = _rubik_submitted($vars['node']); } } /** * Preprocessor for theme('comment'). */ function rubik_preprocess_comment(&$vars) { $vars['layout'] = TRUE; $vars['submitted'] = _rubik_submitted($vars['comment']); } /** * Preprocessor for theme('comment_wrapper'). */ function rubik_preprocess_comment_wrapper(&$vars) { $vars['hook'] = 'box'; $vars['layout'] = FALSE; $vars['title'] = t('Comments'); $vars['attributes_array']['id'] = 'comments'; $vars['title_attributes_array']['class'][] = 'box-title'; $vars['title_attributes_array']['class'][] = 'clearfix'; $vars['content_attributes_array']['class'][] = 'box-content'; $vars['content_attributes_array']['class'][] = 'clearfix'; $vars['content_attributes_array']['class'][] = 'prose'; $vars['content'] = drupal_render_children($vars['content']); } /** * Preprocessor for theme('admin_block'). */ function rubik_preprocess_admin_block(&$vars) { // Add icon and classes to admin block titles. if (isset($vars['block']['href'])) { $vars['block']['localized_options']['attributes']['class'] = _rubik_icon_classes($vars['block']['href']); } $vars['block']['localized_options']['html'] = TRUE; if (isset($vars['block']['link_title'])) { $vars['block']['title'] = l("" . filter_xss_admin($vars['block']['title']), $vars['block']['href'], $vars['block']['localized_options']); } if (empty($vars['block']['content'])) { $vars['block']['content'] = "
{$vars['block']['description']}
"; } } /** * Override of theme('breadcrumb'). */ function rubik_breadcrumb($vars) { $output = ''; // Add current page onto the end. if (!drupal_is_front_page()) { $item = menu_get_item(); $end = end($vars['breadcrumb']); if ($end && strip_tags($end) !== $item['title']) { $vars['breadcrumb'][] = (isset($item['localized_options']['html']) && $item['localized_options']['html']) ? $item['title'] : check_plain($item['title']); } } // Optional: Add the site name to the front of the stack. if (!empty($vars['prepend'])) { $site_name = empty($vars['breadcrumb']) ? "". check_plain(variable_get('site_name', '')) ."" : l(variable_get('site_name', ''), '', array('purl' => array('disabled' => TRUE))); array_unshift($vars['breadcrumb'], $site_name); } $depth = 0; foreach ($vars['breadcrumb'] as $link) { // If the item isn't a link, surround it with a strong tag to format it like // one. if (!preg_match('/^'; } $output .= "{$link}"; $depth++; } return $output; } /** * Override of theme('filter_guidelines'). */ function rubik_filter_guidelines($variables) { return ''; } /** * Override of theme('node_add_list'). */ function rubik_node_add_list($vars) { $content = $vars['content']; $output = ""; return $output; } /** * Override of theme_admin_block_content(). */ function rubik_admin_block_content($vars) { $content = $vars['content']; $output = ''; if (!empty($content)) { foreach ($content as $k => $item) { //-- Safety check for invalid clients of the function if (empty($content[$k]['localized_options']['attributes']['class'])) { $content[$k]['localized_options']['attributes']['class'] = array(); } if (!is_array($content[$k]['localized_options']['attributes']['class'])) { $content[$k]['localized_options']['attributes']['class'] = array($content[$k]['localized_options']['attributes']['class']); } $content[$k]['title'] = "" . filter_xss_admin($item['title']); $content[$k]['localized_options']['html'] = TRUE; if (!empty($content[$k]['localized_options']['attributes']['class'])) { $content[$k]['localized_options']['attributes']['class'] += _rubik_icon_classes($item['href']); } else { $content[$k]['localized_options']['attributes']['class'] = _rubik_icon_classes($item['href']); } } $output = system_admin_compact_mode() ? '