uid) {
$title = t('Please login to continue');
}
drupal_set_title($title);
return phptemplate_page($content);
}
/**
* Intercept template variables
*
* @param $hook
* The name of the theme function being executed
* @param $vars
* A sequential array of variables passed to the theme function.
*/
function _phptemplate_variables($hook, $vars = array()) {
global $user;
$path = base_path() . path_to_theme() .'/';
$path_theme = path_to_theme() .'/';
// global vars
$vars['path'] = $path;
$vars['user'] = $user;
switch ($hook) {
case 'page':
// add in CSS and JS files so they get aggregated and compressed properly
drupal_add_css($path_theme .'blueprint/blueprint/screen.css', 'theme', 'screen, projection');
drupal_add_css($path_theme .'blueprint/blueprint/print.css', 'theme', 'print');
drupal_add_css($path_theme .'css/blueprint.css', 'theme', 'screen, projection');
drupal_add_css($path_theme .'css/style.css', 'theme', 'screen, projection');
// url() handles appending ?q= but in this case, we need to pass in the variable so the path is correct when mod_rewrite is off
// use this in jQuery scripts, most notably AJAX ones
drupal_add_js(array('basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q=')), 'setting');
drupal_add_js($path_theme .'scripts/general.js');
// determine layout
// 3 columns
if ($vars['layout'] == 'both') {
$vars['left'] = '
'. $vars['sidebar_left'] .'
';
$vars['right'] = '
'. $vars['sidebar_right'] .'
';
$vars['center'] = 'col-center span-12';
$vars['body_class'] = 'col-3';
}
// 2 columns
else if ($vars['layout'] != 'none') {
// left column & center
if ($vars['layout'] == 'left') {
$vars['left'] = '
'. $vars['sidebar_left'] .'
';
$vars['right'] = '';
$vars['center'] = 'col-center span-18 last';
}
// right column & center
else if ($vars['layout'] == 'right') {
$vars['left'] = '';
$vars['right'] = '
'. $vars['sidebar_right'] .'
';
$vars['center'] = 'col-center span-18';
}
$vars['body_class'] = 'col-2';
}
// 1 column
else {
$vars['left'] = '';
$vars['right'] = '';
$vars['center'] = 'col-center span-24';
$vars['body_class'] = 'col-1';
}
// SEO optimization, add in the node's teaser, or if on the homepage, the mission statement
// as a description of the page that appears in search engines
if ($vars['is_front'] && $vars['mission'] != '') {
$vars['meta'] .= ''. "\n";
}
else if ($vars['node']->teaser != '') {
$vars['meta'] .= ''. "\n";
}
else if ($vars['node']->body != '') {
$vars['meta'] .= ''."\n";
}
// SEO optimization, if the node has tags, use these as keywords for the page
if ($vars['node']->taxonomy) {
$keywords = array();
foreach($vars['node']->taxonomy as $term) {
$keywords[] = $term->name;
}
$vars['meta'] .= ''. "\n";
}
// SEO optimization, avoid duplicate titles in search indexes for pager pages
if (isset($_GET['page']) || isset($_GET['sort'])) {
$vars['meta'] .= ''. "\n";
}
/* I like to embed the Google search in various places, uncomment to make use of this
// setup search for custom placement
$search = module_invoke('google_cse', 'block', 'view', '0');
$vars['search'] = $search['content'];
*/
// rebuild CSS and JS after all theme modifications to these structures
$new_css = drupal_add_css();
// removed unnessecary CSS styles
// unset($new_css['all']['all']['sites/all/modules/contrib/tagadelic/tagadelic.css']);
// rebuild CSS and JS
$vars['styles'] = drupal_get_css($new_css);
$vars['scripts'] = drupal_get_js();
break;
case 'node':
$node = $vars['node']; // for easy reference
// for easy variable adding for different node types
switch ($node->type) {
case 'page':
break;
}
break;
case 'comment':
// if the author of the node comments as well, highlight that comment
$node = node_load($vars['comment']->nid);
if ($vars['comment']->uid == $node->uid) {
$vars['author_comment'] = TRUE;
}
// only show links for users that can administer links
if (!user_access('administer comments')) {
$vars['links'] = '';
}
// if subjects in comments are turned off, don't show the title then
if (!variable_get('comment_subject_field', 1)) {
$vars['title'] = '';
}
// if user has no picture, add in a filler
if ($vars['picture'] == '') {
$vars['picture'] = '
';
}
break;
case 'box':
// rename to more common text
if (strpos($vars['title'], 'Post new comment') === 0) {
$vars['title'] = 'Add your comment';
}
break;
}
return $vars;
}
/**
* Override, add rel="nofollow" to comment poster's homepage, remove "not verified", confusing
*
* Format a username.
*
* @param $object
* The user object to format, usually returned from user_load().
* @return
* A string containing an HTML link to the user's page if the passed object
* suggests that this is a site user. Otherwise, only the username is returned.
*/
function phptemplate_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('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 ($object->homepage) {
$output = l($object->name, $object->homepage, array('rel' => 'nofollow'));
}
else {
$output = check_plain($object->name);
}
}
else {
$output = variable_get('anonymous', t('Anonymous'));
}
return $output;
}
/**
* Override, remove previous/next links for forum topics
*
* Makes forums look better and is great for performance
* More: http://www.sysarchitects.com/node/70
*/
function phptemplate_forum_topic_navigation($node) {
return '';
}
/**
* Override, make sure Drupal doesn't return empty
*
* Return a themed help message.
*
* @return a string containing the helptext for the current page.
*/
function phptemplate_help() {
$help = menu_get_active_help();
// Drupal sometimes returns empty
so strip tags to check if empty
if (strlen(strip_tags($help)) > 1) {
return '
'. $help .'
';
}
}
/**
* Override, use a better default breadcrumb separator.
*
* Return a themed breadcrumb trail.
*
* @param $breadcrumb
* An array containing the breadcrumb links.
* @return a string containing the breadcrumb output.
*/
function phptemplate_breadcrumb($breadcrumb) {
if (count($breadcrumb) > 1) {
$breadcrumb[] = drupal_get_title();
return '
'. implode(' › ', $breadcrumb) .'
';
}
}
/**
* Rewrite of theme_form_element() to suppress ":" if the title ends with a punctuation mark.
*/
function phptemplate_form_element() {
$args = func_get_args();
return preg_replace('@([.!?]):\s*()@i', '$1$2', call_user_func_array('theme_form_element', $args));
}
/**
* This override adds an ID to the label for all checkboxes, useful for jQuery.
*
* Format a checkbox.
*
* @param $element
* An associative array containing the properties of the element.
* Properties used: title, value, return_value, description, required
* @return
* A themed HTML string representing the checkbox.
*/
function phptemplate_checkbox($element) {
_form_set_class($element, array('form-checkbox'));
$checkbox = '';
if (!is_null($element['#title'])) {
$checkbox = '';
}
unset($element['#title']);
return theme('form_element', $element, $checkbox);
}
/**
* Set status messages to use Blueprint CSS classes.
*/
function phptemplate_status_messages($display = NULL) {
$output = '';
foreach (drupal_get_messages($display) as $type => $messages) {
// blueprint can either call this success or notice
if ($type == 'status') {
$type = 'success';
}
$output .= "
\n";
if (count($messages) > 1) {
$output .= "
\n";
foreach ($messages as $message) {
$output .= '
';
}
/**
* Trim a post to a certain number of characters, removing all HTML.
*/
function blueprint_trim_text($text, $length = 150) {
// remove any HTML or line breaks so these don't appear in the text
$text = trim(str_replace(array("\n", "\r"), ' ', strip_tags($text)));
$text = trim(substr($text, 0, $length));
$lastchar = substr($text, -1, 1);
// check to see if the last character in the title is a non-alphanumeric character, except for ? or !
// if it is strip it off so you don't get strange looking titles
if (preg_match('/[^0-9A-Za-z\!\?]/', $lastchar)) {
$text = substr($text, 0, -1);
}
// ? and ! are ok to end a title with since they make sense
if ($lastchar != '!' and $lastchar != '?') {
$text .= '...';
}
return $text;
}