array( 'template' => 'node' ), 'bluefish_comment' => array( 'template' => 'comment' ), 'bluefish_box' => array( 'template' => 'box' ), 'bluefish_block' => array( 'template' => 'block' ), 'bluefish_maintenance_page' => array( 'template' => 'maintenance_page' ), 'bluefish_search-theme-form' => array( 'template' => 'search-theme-form' ) ); } // We use this to inject a proper page suggestion template for issue nodes. // See http://www.ajaxhacking.com/156/changing_pagetpl_based_on_node_type function bluefish_preprocess(&$vars, $hook) { switch ($hook) { case 'page': // Add a content-type page template in second to last. if ('node' == arg(0)) { $node_template = array_pop($vars['template_files']); $vars['template_files'][] = 'page-'. $vars['node']->type; $vars['template_files'][] = $node_template; } break; } return $vars; } /** * Implementation of hook preporcess_page(). * Used for intercepting & adding of variables. * @return unknown_type */ function bluefish_preprocess_page(&$vars) { // Send a new variable, $logged_in, to page.tpl.php to tell us if the current user is logged in or out. // get the currently logged in user global $user; $vars['user'] = $user; $vars['logged_in'] = $user->uid > 0; $body_classes = array(); // classes for body element // allows advanced theming based on context (home page, node of certain type, etc.) $body_classes[] = ($vars['is_front']) ? 'front' : 'not-front'; $body_classes[] = ($vars['logged_in']) ? 'logged-in' : 'not-logged-in'; if ($vars['node']->type) { $body_classes[] = 'ntype-'. zen_id_safe($vars['node']->type); } switch (TRUE) { case $vars['sidebar_left'] && $vars['sidebar_right'] : $body_classes[] = 'both-sidebars'; break; case $vars['sidebar_left'] : $body_classes[] = 'sidebar-left'; break; case $vars['sidebar_right'] : $body_classes[] = 'sidebar-right'; break; } // implode with spaces $vars['body_classes'] = implode(' ', $body_classes); // This will show the menu blocks on an 404 page // Only does the check if required if (!$vars['show_blocks']) { global $theme; $regions = system_region_list($theme); foreach (array_keys($regions) as $region) { // Only set left and right regions // Drupal core sets the other blocks already // IMHO this shows a real lack of design considerations for leaving these out! if ($region == 'left' || $region == 'right') { $blocks = theme('blocks', $region); if (isset($variables[$region])) { $vars[$region] .= $blocks; } else { $vars[$region] = $blocks; } } } } // Now define node type-specific variables by calling their own preprocess functions (if they exist) $function = 'bluefish_preprocess_page'.'_'. $vars['node']->type; if (function_exists($function)) { $function(&$vars); } } function bluefish_preprocess_page_issue(&$vars) { $foo = 'bar'; $vars['issue_header'] = $vars['node']->issue_header; } /** * Implementation of hook preporcess_node(). * Used for intercepting & adding of variables. * @return unknown_type */ function bluefish_preprocess_node(&$vars) { // get the currently logged in user global $user; // set a new $is_admin variable // this is determined by looking at the currently logged in user and seeing if they are in the role 'admin' $vars['is_admin'] = in_array('admin', $user->roles); $node_classes = array('node'); if ($vars['sticky']) { $node_classes[] = 'sticky'; } if (!$vars['node']->status) { $node_classes[] = 'node-unpublished'; } $node_classes[] = 'ntype-'. zen_id_safe($vars['node']->type); // implode with spaces $vars['node_classes'] = implode(' ', $node_classes); } /** * Implementation of hook preporcess_comment(). * Used for intercepting & adding of variables. * @return unknown_type */ function bluefish_preprocess_comment(&$vars, $links = 0) { // we load the node object that the current comment is attached to $node = node_load($vars['comment']->nid); // if the author of this comment is equal to the author of the node, we set a variable // then in our theme we can theme this comment differently to stand out $vars['author_comment'] = $vars['comment']->uid == $node->uid ? TRUE : FALSE; $comment = $vars['comment']; $vars['author'] = theme('username', $comment); $vars['comment'] = $comment; $vars['content'] = $comment->comment; $vars['date'] = format_date($comment->timestamp); //-------------------------------------------------------------------------- // In order to remove the 'reply' link, it's necessary to get them again as // an array. By the time this function is called, they have already been // rendered as HTML. if (isset($links)) { $link_array = module_invoke_all('link', 'comment', $comment); $vars['links'] = theme('links', $link_array, array('class' => 'links inline')); } else { $vars['links'] = ''; } $vars['new'] = $comment->new ? t('new') : ''; $vars['picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', $comment) : ''; $vars['submitted'] = t('Submitted by !a on @b.', array('!a' => theme('username', $comment), '@b' => format_date($comment->timestamp))); $vars['title'] = l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")); // from comment.module: // l($comment->subject, comment_node_url() .'/'. $comment->cid, array('fragment' => "comment-$comment->cid")) } /** * Theming for the "maintenance page". */ function bluefish_preprocess_maintenance_page(&$vars) { $vars['head_title'] = "Maintenance Page"; $vars['title'] = "Maintenance Page"; $vars['styles'] = ''; $vars['picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', $comment) : ''; bluefish_preprocess_page($vars); } /** * Prepare the values passed to the theme_links function * Overwrites theme_links */ function bluefish_links($links, $attributes = array('class' => 'links')) { $output = ''; // Hack to remove the 'My blog' link if a project owner hides the 'Blog' link foreach ($links as $id => $link) { if ($link['title'] == "My blog") { unset($links[$id]); break; } } if (count($links) > 0) { $output = '