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

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

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


Revision 1.7 - (show annotations) (download) (as text)
Thu May 11 18:17:29 2006 UTC (3 years, 6 months ago) by ayman
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-4-7
Changes since 1.6: +2 -0 lines
File MIME type: text/x-php
+ CVS ID
1 <?php
2 // $Id$
3
4 function _phptemplate_variables($hook, $vars) {
5 static $is_forum;
6 $variables = array();
7 if (!isset($is_forum)) {
8 if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '') {
9 $nid = arg(1);
10 }
11 if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
12 $nid = arg(2);
13 }
14 if ($nid) {
15 $node = node_load(array('nid' => $nid));
16 }
17 $is_forum = ($node && $node->type == 'forum');
18 _is_forum($is_forum);
19 }
20 if ($is_forum) {
21 switch ($hook) {
22 case 'comment' :
23 $variables['template_file'] = 'node-forum';
24 $variables['row_class'] = _row_class();
25 $variables['name'] = $vars['author'];
26 $variables['userid'] = $vars['comment']->uid;
27 $joined = module_invoke('flatforum', 'get_created', $vars['comment']->uid);
28 $variables['joined'] = $joined ? format_date($joined, 'custom', 'Y-m-d') : '';
29 $posts = module_invoke('flatforum', 'get', $vars['comment']->uid);
30 $variables['posts'] = $posts ? $posts : 0;
31 $variables['submitted'] = format_date($vars['comment']->timestamp);
32 $subject = $vars['comment']->subject;
33 $variables['title'] = empty($subject) ? '&nbsp' : $subject;
34 $variables['content'] = $vars['comment']->comment;
35 $variables['links'] = empty($vars['links']) ? '&nbsp' : $vars['links'];
36 break;
37 case 'node' :
38 $variables['row_class'] = _row_class();
39 $variables['userid']=$vars['node']->uid;
40 $joined = module_invoke('flatforum', 'get_created', $vars['node']->uid);
41 $variables['joined'] = $joined ? format_date($joined, 'custom', 'Y-m-d') : '';
42 $posts = module_invoke('flatforum', 'get', $vars['node']->uid);
43 $variables['posts'] = $posts ? $posts : 0;
44 $variables['title'] = empty($vars['title']) ? '&nbsp' : $vars['title'];
45 $variables['content'] = $vars['node']->body;
46 $variables['links'] = empty($vars['links']) ? '&nbsp' : $vars['links'];
47 break;
48 }
49 }
50 return $variables;
51 }
52 function _row_class() {
53 static $forum_row = TRUE;
54 $forum_row = !$forum_row;
55 return $forum_row ? 'odd' : 'even';
56 }
57 function _is_forum($arg = NULL) {
58 static $is_forum = FALSE;
59 if ($arg) {
60 $is_forum = $arg;
61 }
62 return $is_forum;
63 }
64

  ViewVC Help
Powered by ViewVC 1.1.2