| 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) ? ' ' : $subject;
|
| 34 |
$variables['content'] = $vars['comment']->comment;
|
| 35 |
$variables['links'] = empty($vars['links']) ? ' ' : $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']) ? ' ' : $vars['title'];
|
| 45 |
$variables['content'] = $vars['node']->body;
|
| 46 |
$variables['links'] = empty($vars['links']) ? ' ' : $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 |
|