~edb/quam-plures/item_show_attachments

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
/**
 * "item feedback" sub-template

Need help doing something with this file?
http://docs.quamplures.net/li_templates.html - tutorials and autodocs

 * This is meant to be included via a .main.php (or other .inc.php) file
 *
 * Quam Plures - {@link http://quamplures.net/}
 * Released under GNU GPL License - {@link http://quamplures.net/license.html}
 * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
 * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
 * @package templates
 * @subpackage generics
 */
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

// set some default params...
$params = array_merge( array(
	'disp_comments' => true,
	'disp_comment_form' => true,
	'disp_trackbacks' => true,
	'disp_trackback_url' => true,
	'before_section_title' => '<h3>',
	'after_section_title' => '</h3>',
	'comment_list_start' => "\n\n",
	'comment_list_end' => "\n\n",
	'comment_start' => '<div class="bComment">',
	'comment_end' => '</div>',
	'preview_start' => '<div class="bComment" id="comment_preview">',
	'preview_end' => '</div>',
	'comment_template' => '_item_comment.inc.php',
	'form_title_start' => '<h3>',
	'form_title_end' => '</h3>',
	), $params );

global $c, $tb;

if( ! $Item->can_see_comments() )
{ // Comments are disabled for this post
	return;
}

if( empty($c) )
{ // Comments not requested
	$params['disp_comments'] = false;
	$params['disp_comment_form'] = false;
}

if( empty($tb) || !$Blog->get( 'allowtrackbacks' ) )
{ // Trackback not requested or not allowed
	$params['disp_trackbacks'] = false;
	$params['disp_trackback_url'] = false;
}

if( ! ($params['disp_comments'] || $params['disp_comment_form'] || $params['disp_trackbacks'] || $params['disp_trackback_url'] ) )
{ // Nothing more to do....
	return false;
}

echo '<a id="feedbacks"></a>';

$type_list = array();
$disp_title = array();

// We requested to display comments?
if( $params['disp_comments'] )
{
	if( $Item->can_see_comments() )
	{
		$type_list[] = "'comment'";
		if( $title = $Item->get_feedback_title( 'comments' ) )
		{
			$disp_title[] = $title;
		}
	}
	else
	{
		$params['disp_comments'] = false;
	}
	echo '<a id="comments"></a>';
}

// We requested to display trackbacks?
if( $params['disp_trackbacks'] )
{
	$type_list[] = "'trackback'";
	if( $title = $Item->get_feedback_title( 'trackbacks' ) )
	{
		$disp_title[] = $title;
	}
	echo '<a id="trackbacks"></a>';
}

// We want to display the trackback URL?
if( $params['disp_trackback_url'] )
{
	echo $params['before_section_title'];
	echo T_('Trackback address for this post');
	echo $params['after_section_title'];
	// Trigger plugin event ...
	if( ! $Plugins->trigger_event_first_true( 'DisplayTrackbackAddr', array('Item' => & $Item, 'template' => '<code>%url%</code>') ) )
	{
		// if no plugin displayed a payload we just display the default
		echo '<p class="trackback_url"><a href="'.$Item->get_trackback_url().'">'.T_('Trackback URL (right click and copy shortcut/link location)').'</a></p>';
	}
}

// if we have something to display ...
if( $params['disp_comments'] || $params['disp_trackbacks'] )
{
	// ... first we make a title ...
	if( empty($disp_title) )
	{
		if( $title = $Item->get_feedback_title( 'feedbacks', '', T_('Feedback awaiting moderation'), T_('Feedback awaiting moderation'), 'draft' ) )
		{
			$disp_title[] = $title;
		}
	}
	// still no title?
	if( empty($disp_title) )
	{
		$disp_title[] = T_('No feedback yet');
	}

	// show the title :)
	echo $params['before_section_title'];
	echo implode( ', ', $disp_title);
	echo $params['after_section_title'];

	// spark off a comment list...
	$CommentList = new CommentList( NULL, implode(',', $type_list), array('published'), $Item->ID, '', 'ASC' );

	// loop through comments...
	echo $params['comment_list_start'];
	while( $Comment = & $CommentList->get_next() )
	{
		// --- --- --- --- --- --- --- --- --- --- ---
		// --- A SINGLE COMMENT INCLUDED HERE ---
		template_include( $params['comment_template'], array(
			'Comment' => & $Comment,
			'comment_start' => $params['comment_start'],
			'comment_end' => $params['comment_end'],
		) );
	}
	echo $params['comment_list_end'];

	// display count of comments to be moderated
	$Item->feedback_moderation( 'feedbacks', '<div class="moderation_msg"><p>', '</p></div>', '',
		T_('This post has 1 feedback awaiting moderation... %s'),
		T_('This post has %d feedbacks awaiting moderation... %s') );

	// display link for comments feed?
	if( $Blog->get_setting( 'feed_content' ) != 'none' )
	{
		$Item->feedback_feed_link( '_rss2', '<div class="feedback_feed_msg"><p>', '</p></div>' );
	}

}

// --- --- --- --- --- --- --- --- --- --- ---
// --- COMMENT FORM INCLUDED HERE ---
template_include( '_item_comment_form.inc.php', $params );
?>