| 1 |
<?php
|
| 2 |
// $Id: template.php,v 1.13 2008/05/13 09:19:13 johnalbin Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
*
|
| 7 |
* OVERRIDING THEME FUNCTIONS
|
| 8 |
*
|
| 9 |
* The Drupal theme system uses special theme functions to generate HTML output
|
| 10 |
* automatically. Often we wish to customize this HTML output. To do this, we
|
| 11 |
* have to override the theme function. You have to first find the theme
|
| 12 |
* function that generates the output, and then "catch" it and modify it here.
|
| 13 |
* The easiest way to do it is to copy the original function in its entirety and
|
| 14 |
* paste it here, changing the prefix from theme_ to TVframe_. For example:
|
| 15 |
*
|
| 16 |
* original: theme_breadcrumb()
|
| 17 |
* theme override: TVframe_breadcrumb()
|
| 18 |
*
|
| 19 |
* where TVframe is the name of your sub-theme. For example, the zen_classic
|
| 20 |
* theme would define a zen_classic_breadcrumb() function.
|
| 21 |
*
|
| 22 |
* If you would like to override any of the theme functions used in Zen core,
|
| 23 |
* you should first look at how Zen core implements those functions:
|
| 24 |
* theme_breadcrumbs() in zen/template.php
|
| 25 |
* theme_menu_item_link() in zen/template-menus.php
|
| 26 |
* theme_menu_local_tasks() in zen/template-menus.php
|
| 27 |
*/
|
| 28 |
|
| 29 |
|
| 30 |
/*
|
| 31 |
* Add any conditional stylesheets you will need for this sub-theme.
|
| 32 |
*
|
| 33 |
* To add stylesheets that ALWAYS need to be included, you should add them to
|
| 34 |
* your .info file instead. Only use this section if you are including
|
| 35 |
* stylesheets based on certain conditions.
|
| 36 |
*/
|
| 37 |
|
| 38 |
/* -- Delete this line if you want to use and modify this code
|
| 39 |
// Example: optionally add a fixed width CSS file.
|
| 40 |
if (theme_get_setting('TVframe_fixed')) {
|
| 41 |
drupal_add_css(path_to_theme() . '/layout-fixed.css', 'theme', 'all');
|
| 42 |
}
|
| 43 |
// */
|
| 44 |
|
| 45 |
|
| 46 |
/**
|
| 47 |
* Implementation of HOOK_theme().
|
| 48 |
*/
|
| 49 |
function TVframe_theme(&$existing, $type, $theme, $path) {
|
| 50 |
return zen_theme($existing, $type, $theme, $path);
|
| 51 |
}
|
| 52 |
|
| 53 |
/**
|
| 54 |
* Override or insert PHPTemplate variables into all templates.
|
| 55 |
*
|
| 56 |
* @param $vars
|
| 57 |
* A sequential array of variables to pass to the theme template.
|
| 58 |
* @param $hook
|
| 59 |
* The name of the theme function being called (name of the .tpl.php file.)
|
| 60 |
*/
|
| 61 |
/* -- Delete this line if you want to use this function
|
| 62 |
function TVframe_preprocess(&$vars, $hook) {
|
| 63 |
$vars['sample_variable'] = t('Lorem ipsum.');
|
| 64 |
}
|
| 65 |
// */
|
| 66 |
|
| 67 |
/**
|
| 68 |
* Override or insert PHPTemplate variables into the page templates.
|
| 69 |
*
|
| 70 |
* @param $vars
|
| 71 |
* A sequential array of variables to pass to the theme template.
|
| 72 |
* @param $hook
|
| 73 |
* The name of the theme function being called ("page" in this case.)
|
| 74 |
*/
|
| 75 |
/* -- Delete this line if you want to use this function
|
| 76 |
function TVframe_preprocess_page(&$vars, $hook) {
|
| 77 |
$vars['sample_variable'] = t('Lorem ipsum.');
|
| 78 |
}
|
| 79 |
// */
|
| 80 |
|
| 81 |
/**
|
| 82 |
* Override or insert PHPTemplate variables into the node templates.
|
| 83 |
*
|
| 84 |
* @param $vars
|
| 85 |
* A sequential array of variables to pass to the theme template.
|
| 86 |
* @param $hook
|
| 87 |
* The name of the theme function being called ("node" in this case.)
|
| 88 |
*/
|
| 89 |
/* -- Delete this line if you want to use this function
|
| 90 |
function TVframe_preprocess_node(&$vars, $hook) {
|
| 91 |
$vars['sample_variable'] = t('Lorem ipsum.');
|
| 92 |
}
|
| 93 |
// */
|
| 94 |
|
| 95 |
/**
|
| 96 |
* Override or insert PHPTemplate variables into the comment templates.
|
| 97 |
*
|
| 98 |
* @param $vars
|
| 99 |
* A sequential array of variables to pass to the theme template.
|
| 100 |
* @param $hook
|
| 101 |
* The name of the theme function being called ("comment" in this case.)
|
| 102 |
*/
|
| 103 |
/* -- Delete this line if you want to use this function
|
| 104 |
function TVframe_preprocess_comment(&$vars, $hook) {
|
| 105 |
$vars['sample_variable'] = t('Lorem ipsum.');
|
| 106 |
}
|
| 107 |
// */
|
| 108 |
|
| 109 |
/**
|
| 110 |
* Override or insert PHPTemplate variables into the block templates.
|
| 111 |
*
|
| 112 |
* @param $vars
|
| 113 |
* A sequential array of variables to pass to the theme template.
|
| 114 |
* @param $hook
|
| 115 |
* The name of the theme function being called ("block" in this case.)
|
| 116 |
*/
|
| 117 |
/* -- Delete this line if you want to use this function
|
| 118 |
function TVframe_preprocess_block(&$vars, $hook) {
|
| 119 |
$vars['sample_variable'] = t('Lorem ipsum.');
|
| 120 |
}
|
| 121 |
// */
|
| 122 |
|
| 123 |
|
| 124 |
/**
|
| 125 |
* The rel="nofollow" attribute is missing from anonymous users' URL in Drupal 6.0-6.2.
|
| 126 |
*/
|
| 127 |
/* -- Delete this line if you want to use this function
|
| 128 |
function TVframe_username($object) {
|
| 129 |
|
| 130 |
if ($object->uid && $object->name) {
|
| 131 |
// Shorten the name when it is too long or it will break many tables.
|
| 132 |
if (drupal_strlen($object->name) > 20) {
|
| 133 |
$name = drupal_substr($object->name, 0, 15) . '...';
|
| 134 |
}
|
| 135 |
else {
|
| 136 |
$name = $object->name;
|
| 137 |
}
|
| 138 |
|
| 139 |
if (user_access('access user profiles')) {
|
| 140 |
$output = l($name, 'user/' . $object->uid, array('attributes' => array('title' => t('View user profile.'))));
|
| 141 |
}
|
| 142 |
else {
|
| 143 |
$output = check_plain($name);
|
| 144 |
}
|
| 145 |
}
|
| 146 |
else if ($object->name) {
|
| 147 |
// Sometimes modules display content composed by people who are
|
| 148 |
// not registered members of the site (e.g. mailing list or news
|
| 149 |
// aggregator modules). This clause enables modules to display
|
| 150 |
// the true author of the content.
|
| 151 |
if (!empty($object->homepage)) {
|
| 152 |
$output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
|
| 153 |
}
|
| 154 |
else {
|
| 155 |
$output = check_plain($object->name);
|
| 156 |
}
|
| 157 |
|
| 158 |
$output .= ' (' . t('not verified') . ')';
|
| 159 |
}
|
| 160 |
else {
|
| 161 |
$output = variable_get('anonymous', t('Anonymous'));
|
| 162 |
}
|
| 163 |
|
| 164 |
return $output;
|
| 165 |
}
|
| 166 |
// */
|
| 167 |
|
| 168 |
function dom_menu_body_class() {
|
| 169 |
$trail = menu_tree_page_data('primary-links');
|
| 170 |
|
| 171 |
foreach($trail as $item => $info) {
|
| 172 |
if ($info['link']['in_active_trail'] == 1 && $info['link']['plid'] == 0) {
|
| 173 |
$extra_class = ' menu-section-'.$info['link']['mlid'];
|
| 174 |
break;
|
| 175 |
}
|
| 176 |
}
|
| 177 |
|
| 178 |
return $extra_class;
|
| 179 |
}
|
| 180 |
|
| 181 |
/* Allow placement / or non-placement of comments in node
|
| 182 |
* To insert comments in node.tpl.php use $comments and/or
|
| 183 |
* $comment_form */
|
| 184 |
function phptemplate_preprocess_page(&$vars) {
|
| 185 |
$vars['comments'] = $vars['comment_form'] = '';
|
| 186 |
if (module_exists('comment') && isset($vars['node'])) {
|
| 187 |
$vars['comments'] = comment_render($vars['node']);
|
| 188 |
$vars['comment_form'] = drupal_get_form('comment_form', array('nid' => $vars['node']->nid));
|
| 189 |
}
|
| 190 |
}
|
| 191 |
|
| 192 |
function phptemplate_preprocess_node(&$vars) {
|
| 193 |
if($vars['node']->type == 'livestream'){
|
| 194 |
$vars['node']->comment = 0;
|
| 195 |
}
|
| 196 |
}
|
| 197 |
|
| 198 |
|
| 199 |
/* This would add the user login template if i got it to work */
|
| 200 |
/* if i change mytheme to TVframe, it conflicts with the prior use on line 49 */
|
| 201 |
/* from http://drupal.org/node/19855 */
|
| 202 |
function mytheme_theme() {
|
| 203 |
return array(
|
| 204 |
'user_login_block' => array(
|
| 205 |
'template' => 'user_login',
|
| 206 |
'arguments' => array('form' => NULL),
|
| 207 |
),
|
| 208 |
// other theme registration code...
|
| 209 |
);
|
| 210 |
}
|
| 211 |
|
| 212 |
function mytheme_preprocess_user_login_block(&$variables) {
|
| 213 |
$variables['intro_text'] = t('This is my awesome login form');
|
| 214 |
$variables['rendered'] = drupal_render($variables['form']);
|
| 215 |
}
|
| 216 |
|
| 217 |
|
| 218 |
/**
|
| 219 |
* Theme function for shoutbox posts.
|
| 220 |
*
|
| 221 |
* @param shout
|
| 222 |
* The shout to be themed.
|
| 223 |
* @param links
|
| 224 |
* Links of possible actions that can be performed on this shout
|
| 225 |
* by the current user.
|
| 226 |
* @param $alter_row_color
|
| 227 |
* Whether or not to alternate the row color for posts. Should be set to
|
| 228 |
* FALSE for the page view.
|
| 229 |
*/
|
| 230 |
function phptemplate_shoutbox_post($shout, $links = array(), $alter_row_color=TRUE) {
|
| 231 |
// Get the registered username of the person who posted the shout.
|
| 232 |
if ($shout->uid > 0) {
|
| 233 |
$user = user_load(array("uid" => $shout->uid));
|
| 234 |
$shout->username = $user->name;
|
| 235 |
}
|
| 236 |
else {
|
| 237 |
$shout->username = 'an anonymous user';
|
| 238 |
}
|
| 239 |
|
| 240 |
// BUGBUG strstr returns from http:// till end
|
| 241 |
// we should use that instead of full url.
|
| 242 |
if (strstr($shout->url, "http://")) {
|
| 243 |
$shout->url = '<a href="'. $shout->url .'" target="_blank">'. $shout->nick .'</a>';
|
| 244 |
}
|
| 245 |
else {
|
| 246 |
$shout->url = $shout->nick;
|
| 247 |
}
|
| 248 |
|
| 249 |
if ($links) {
|
| 250 |
foreach ($links as $link) {
|
| 251 |
$linkattributes = $link['linkattributes'];
|
| 252 |
$link_html = '<img src="'. $link['img'] .'" width="'. $link['img_width'] .'" height="'. $link['img_height'] .'" alt="'. $link['title'] .'" class="shoutbox-imglink">';
|
| 253 |
$link_url = 'shoutbox/'. $shout->shout_id .'/'. $link['action'];
|
| 254 |
$img_links = l($link_html, $link_url, array('html' => TRUE)) . $img_links;
|
| 255 |
}
|
| 256 |
}
|
| 257 |
|
| 258 |
$title = 'Posted '. format_date($shout->created, 'custom', 'm/d/y') .' at '. format_date($shout->created, 'custom', 'h:ia') .' by '. $shout->username;
|
| 259 |
$shout_classes="shoutbox-msg ";
|
| 260 |
if ($alter_row_color) {
|
| 261 |
$shout_classes .= (($shout->color) ? ("shout-odd ") : ("shout-even "));
|
| 262 |
}
|
| 263 |
|
| 264 |
if ($shout->moderate == 1) {
|
| 265 |
$shout_classes .= "shoutbox-unpublished ";
|
| 266 |
$shout->shout .= t("(This shout is waiting for approval by a moderator.)");
|
| 267 |
}
|
| 268 |
return "<div class=\" $shout_classes \" title=\"$title\">$img_links<div class=\"shouter\">$shout->url:</div><div class=\"shouted\">$shout->shout</div></div>\n";
|
| 269 |
}
|
| 270 |
|
| 271 |
function TVframe_preprocess_node(&$variables, $hook) {
|
| 272 |
$variables['node_region'] = theme('blocks', 'node_region');
|
| 273 |
}
|