This repository was archived by the owner on Sep 5, 2021. It is now read-only.
Repository navigation
Expand file tree
/
Copy path_public.php
More file actions
154 lines (118 loc) · 3.75 KB
/
Copy path_public.php
File metadata and controls
154 lines (118 loc) · 3.75 KB
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
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of myBlogNumbers, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
}
require dirname(__FILE__).'/_widgets.php';
function myBlogNumbersWidgetPublic($w)
{
global $core;
$content = $addons = '';
$s_line = '<li>%s%s</li>';
$s_title = '<strong>%s</strong> ';
if ($w->offline)
return;
# Home only
if ($w->homeonly == 1 && $core->url->type != 'default'
|| $w->homeonly == 2 && $core->url->type == 'default'
) {
return;
}
# Entry
if ($w->entry_show) {
$title = $w->entry_title ?
sprintf($s_title, html::escapeHTML($w->entry_title)) : '';
$count = $core->blog->getPosts(array(), true)->f(0);
$text = $count == 0 ?
sprintf(__('no entries'), $count) :
sprintf(__('one entry', '%s entries', $count), $count);
$content .= sprintf($s_line, $title, $text);
}
# Cat
if ($w->cat_show) {
$title = $w->cat_title ?
sprintf($s_title, html::escapeHTML($w->cat_title)) : '';
$count = $core->blog->getCategories(array())->count();
$text = $count == 0 ?
sprintf(__('no categories'), $count) :
sprintf(__('one category', '%s categories', $count), $count);
$content .= sprintf($s_line, $title, $text);
}
# Comment
if ($w->comment_show) {
$title = $w->comment_title ?
sprintf($s_title, html::escapeHTML($w->comment_title)) : '';
$params = array(
'post_type' => 'post',
'comment_status' => 1,
'comment_trackback' => 0
);
$count = $core->blog->getComments($params, true)->f(0);
$text = $count == 0 ?
sprintf(__('no comments'),$count) :
sprintf(__('one comment', '%s comments', $count), $count);
$content .= sprintf($s_line,$title,$text);
}
# Trackback
if ($w->trackback_show) {
$title = $w->trackback_title ?
sprintf($s_title, html::escapeHTML($w->trackback_title)) : '';
$params = array(
'post_type' => 'post',
'comment_status' => 1,
'comment_trackback' => 1
);
$count = $core->blog->getComments($params, true)->f(0);
$text = $count == 0 ?
sprintf(__('no trackbacks'),$count) :
sprintf(__('one trackback', '%s trackbacks', $count), $count);
$content .= sprintf($s_line,$title,$text);
}
# Tag
if ($core->plugins->moduleExists('tags') && $w->tag_show) {
$title = $w->tag_title ?
sprintf($s_title,html::escapeHTML($w->tag_title)) : '';
$count = $core->con->select(
'SELECT count(M.meta_id) AS count '.
'FROM '.$core->prefix.'meta M '.
'LEFT JOIN '.$core->prefix.'post P ON P.post_id=M.post_id '.
"WHERE M.meta_type='tag' ".
"AND P.blog_id='".$core->blog->id."' "
)->f(0);
$text = $count == 0 ?
sprintf(__('no tags'), $count) :
sprintf(__('one tag', '%s tags', $count), $count);
$content .= sprintf($s_line, $title, $text);
}
# User (that post)
if ($w->user_show) {
$title = $w->user_title ?
sprintf($s_title, html::escapeHTML($w->user_title)) : '';
$count = $core->blog->getPostsUsers(array(),true)->count();
$text = $count == 0 ?
sprintf(__('no author'), $count) :
sprintf(__('one author', '%s authors', $count), $count);
$content .= sprintf($s_line,$title,$text);
}
# --BEHAVIOR-- myBlogNumbersWidgetParse
$addons = $core->callBehavior('myBlogNumbersWidgetParse', $core, $w);
# Nothing to display
if (!$content && !$addons) {
return null;
}
# Display
$res =
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'<ul>'.$content.$addons.'</ul>';
return $w->renderDiv($w->content_only,'myblognumbers '.$w->class,'',$res);
}