/[drupal]/contributions/themes/TVframe/template.php
ViewVC logotype

Contents of /contributions/themes/TVframe/template.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Thu Nov 5 21:56:43 2009 UTC (3 weeks ago) by darrick
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +5 -3 lines
File MIME type: text/x-php
Added support for color module.
1 <?php
2 // $Id: template.php,v 1.4 2009/10/21 15:35:20 kreynen 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 function TVframe_preprocess_page(&$vars, $hook) {
76 // Hook into color.module
77 if (module_exists('color')) {
78 _color_page_alter($vars);
79 }
80 }
81 // */
82
83 /**
84 * Override or insert PHPTemplate variables into the node templates.
85 *
86 * @param $vars
87 * A sequential array of variables to pass to the theme template.
88 * @param $hook
89 * The name of the theme function being called ("node" in this case.)
90 */
91 /* -- Delete this line if you want to use this function
92 function TVframe_preprocess_node(&$vars, $hook) {
93 $vars['sample_variable'] = t('Lorem ipsum.');
94 }
95 // */
96
97 /**
98 * Override or insert PHPTemplate variables into the comment templates.
99 *
100 * @param $vars
101 * A sequential array of variables to pass to the theme template.
102 * @param $hook
103 * The name of the theme function being called ("comment" in this case.)
104 */
105 /* -- Delete this line if you want to use this function
106 function TVframe_preprocess_comment(&$vars, $hook) {
107 $vars['sample_variable'] = t('Lorem ipsum.');
108 }
109 // */
110
111 /**
112 * Override or insert PHPTemplate variables into the block templates.
113 *
114 * @param $vars
115 * A sequential array of variables to pass to the theme template.
116 * @param $hook
117 * The name of the theme function being called ("block" in this case.)
118 */
119 /* -- Delete this line if you want to use this function
120 function TVframe_preprocess_block(&$vars, $hook) {
121 $vars['sample_variable'] = t('Lorem ipsum.');
122 }
123 // */
124
125
126 /**
127 * The rel="nofollow" attribute is missing from anonymous users' URL in Drupal 6.0-6.2.
128 */
129 /* -- Delete this line if you want to use this function
130 function TVframe_username($object) {
131
132 if ($object->uid && $object->name) {
133 // Shorten the name when it is too long or it will break many tables.
134 if (drupal_strlen($object->name) > 20) {
135 $name = drupal_substr($object->name, 0, 15) . '...';
136 }
137 else {
138 $name = $object->name;
139 }
140
141 if (user_access('access user profiles')) {
142 $output = l($name, 'user/' . $object->uid, array('attributes' => array('title' => t('View user profile.'))));
143 }
144 else {
145 $output = check_plain($name);
146 }
147 }
148 else if ($object->name) {
149 // Sometimes modules display content composed by people who are
150 // not registered members of the site (e.g. mailing list or news
151 // aggregator modules). This clause enables modules to display
152 // the true author of the content.
153 if (!empty($object->homepage)) {
154 $output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
155 }
156 else {
157 $output = check_plain($object->name);
158 }
159
160 $output .= ' (' . t('not verified') . ')';
161 }
162 else {
163 $output = variable_get('anonymous', t('Anonymous'));
164 }
165
166 return $output;
167 }
168 // */
169
170 function dom_menu_body_class() {
171 $trail = menu_tree_page_data('primary-links');
172
173 foreach($trail as $item => $info) {
174 if ($info['link']['in_active_trail'] == 1 && $info['link']['plid'] == 0) {
175 $extra_class = ' menu-section-'.$info['link']['mlid'];
176 break;
177 }
178 }
179
180 return $extra_class;
181 }
182
183 /* Allow placement / or non-placement of comments in node
184 * To insert comments in node.tpl.php use $comments and/or
185 * $comment_form */
186 function phptemplate_preprocess_page(&$vars) {
187 $vars['comments'] = $vars['comment_form'] = '';
188 if (module_exists('comment') && isset($vars['node'])) {
189 $vars['comments'] = comment_render($vars['node']);
190 $vars['comment_form'] = drupal_get_form('comment_form', array('nid' => $vars['node']->nid));
191 }
192 }
193
194 function phptemplate_preprocess_node(&$vars) {
195 if($vars['node']->type == 'livestream'){
196 $vars['node']->comment = 0;
197 }
198 }
199
200
201 /* This would add the user login template if i got it to work */
202 /* if i change mytheme to TVframe, it conflicts with the prior use on line 49 */
203 /* from http://drupal.org/node/19855 */
204 function mytheme_theme() {
205 return array(
206 'user_login_block' => array(
207 'template' => 'user_login',
208 'arguments' => array('form' => NULL),
209 ),
210 // other theme registration code...
211 );
212 }
213
214 function mytheme_preprocess_user_login_block(&$variables) {
215 $variables['intro_text'] = t('This is my awesome login form');
216 $variables['rendered'] = drupal_render($variables['form']);
217 }
218
219
220 /**
221 * Theme function for shoutbox posts.
222 *
223 * @param shout
224 * The shout to be themed.
225 * @param links
226 * Links of possible actions that can be performed on this shout
227 * by the current user.
228 * @param $alter_row_color
229 * Whether or not to alternate the row color for posts. Should be set to
230 * FALSE for the page view.
231 */
232 function phptemplate_shoutbox_post($shout, $links = array(), $alter_row_color=TRUE) {
233 // Get the registered username of the person who posted the shout.
234 if ($shout->uid > 0) {
235 $user = user_load(array("uid" => $shout->uid));
236 $shout->username = $user->name;
237 }
238 else {
239 $shout->username = 'an anonymous user';
240 }
241
242 // BUGBUG strstr returns from http:// till end
243 // we should use that instead of full url.
244 if (strstr($shout->url, "http://")) {
245 $shout->url = '<a href="'. $shout->url .'" target="_blank">'. $shout->nick .'</a>';
246 }
247 else {
248 $shout->url = $shout->nick;
249 }
250
251 if ($links) {
252 foreach ($links as $link) {
253 $linkattributes = $link['linkattributes'];
254 $link_html = '<img src="'. $link['img'] .'" width="'. $link['img_width'] .'" height="'. $link['img_height'] .'" alt="'. $link['title'] .'" class="shoutbox-imglink">';
255 $link_url = 'shoutbox/'. $shout->shout_id .'/'. $link['action'];
256 $img_links = l($link_html, $link_url, array('html' => TRUE)) . $img_links;
257 }
258 }
259
260 $title = 'Posted '. format_date($shout->created, 'custom', 'm/d/y') .' at '. format_date($shout->created, 'custom', 'h:ia') .' by '. $shout->username;
261 $shout_classes="shoutbox-msg ";
262 if ($alter_row_color) {
263 $shout_classes .= (($shout->color) ? ("shout-odd ") : ("shout-even "));
264 }
265
266 if ($shout->moderate == 1) {
267 $shout_classes .= "shoutbox-unpublished ";
268 $shout->shout .= t("(This shout is waiting for approval by a moderator.)");
269 }
270 return "<div class=\" $shout_classes \" title=\"$title\">$img_links<div class=\"shouter\">$shout->url:</div><div class=\"shouted\">$shout->shout</div></div>\n";
271 }
272
273 function TVframe_preprocess_node(&$variables, $hook) {
274 $variables['node_region'] = theme('blocks', 'node_region');
275 }

  ViewVC Help
Powered by ViewVC 1.1.2