1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | if (!defined('DC_RC_PATH')) { return; } |
---|
13 | |
---|
14 | class adminGenericList |
---|
15 | { |
---|
16 | protected $core; |
---|
17 | protected $rs; |
---|
18 | protected $rs_count; |
---|
19 | |
---|
20 | public function __construct($core,$rs,$rs_count) |
---|
21 | { |
---|
22 | $this->core =& $core; |
---|
23 | $this->rs =& $rs; |
---|
24 | $this->rs_count = $rs_count; |
---|
25 | $this->html_prev = __('«prev.'); |
---|
26 | $this->html_next = __('next»'); |
---|
27 | } |
---|
28 | } |
---|
29 | |
---|
30 | class adminPostList extends adminGenericList |
---|
31 | { |
---|
32 | public function display($page,$nb_per_page,$enclose_block='') |
---|
33 | { |
---|
34 | if ($this->rs->isEmpty()) |
---|
35 | { |
---|
36 | echo '<p><strong>'.__('No entry').'</strong></p>'; |
---|
37 | } |
---|
38 | else |
---|
39 | { |
---|
40 | $pager = new pager($page,$this->rs_count,$nb_per_page,10); |
---|
41 | $pager->html_prev = $this->html_prev; |
---|
42 | $pager->html_next = $this->html_next; |
---|
43 | $pager->var_page = 'page'; |
---|
44 | |
---|
45 | $html_block = |
---|
46 | '<table class="clear"><tr>'. |
---|
47 | '<th colspan="2">'.__('Title').'</th>'. |
---|
48 | '<th>'.__('Date').'</th>'. |
---|
49 | '<th>'.__('Author').'</th>'. |
---|
50 | '<th>'.__('Status').'</th>'. |
---|
51 | '</tr>%s</table>'; |
---|
52 | |
---|
53 | if ($enclose_block) { |
---|
54 | $html_block = sprintf($enclose_block,$html_block); |
---|
55 | } |
---|
56 | |
---|
57 | echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
58 | |
---|
59 | $blocks = explode('%s',$html_block); |
---|
60 | |
---|
61 | echo $blocks[0]; |
---|
62 | |
---|
63 | while ($this->rs->fetch()) |
---|
64 | { |
---|
65 | echo $this->postLine(); |
---|
66 | } |
---|
67 | |
---|
68 | echo $blocks[1]; |
---|
69 | |
---|
70 | echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | private function postLine() |
---|
75 | { |
---|
76 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
77 | switch ($this->rs->post_status) { |
---|
78 | case 1: |
---|
79 | $img_status = sprintf($img,__('published'),'check-on.png'); |
---|
80 | break; |
---|
81 | case 0: |
---|
82 | $img_status = sprintf($img,__('unpublished'),'check-off.png'); |
---|
83 | break; |
---|
84 | case -1: |
---|
85 | $img_status = sprintf($img,__('scheduled'),'scheduled.png'); |
---|
86 | break; |
---|
87 | case -2: |
---|
88 | $img_status = sprintf($img,__('pending'),'check-wrn.png'); |
---|
89 | break; |
---|
90 | } |
---|
91 | |
---|
92 | $protected = ''; |
---|
93 | if ($this->rs->post_password) { |
---|
94 | $protected = sprintf($img,__('protected'),'locker.png'); |
---|
95 | } |
---|
96 | |
---|
97 | $selected = ''; |
---|
98 | if ($this->rs->post_selected) { |
---|
99 | $selected = sprintf($img,__('selected'),'selected.png'); |
---|
100 | } |
---|
101 | |
---|
102 | $attach = ''; |
---|
103 | $nb_media = $this->rs->countMedia(); |
---|
104 | if ($nb_media > 0) { |
---|
105 | $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); |
---|
106 | $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); |
---|
107 | } |
---|
108 | |
---|
109 | $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. |
---|
110 | ' id="p'.$this->rs->post_id.'">'; |
---|
111 | |
---|
112 | $res .= |
---|
113 | '<td class="nowrap">'. |
---|
114 | form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).'</td>'. |
---|
115 | '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. |
---|
116 | html::escapeHTML($this->rs->post_title).'</a></td>'. |
---|
117 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. |
---|
118 | '<td class="nowrap">'.$this->rs->user_id.'</td>'. |
---|
119 | '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. |
---|
120 | '</tr>'; |
---|
121 | |
---|
122 | return $res; |
---|
123 | } |
---|
124 | } |
---|
125 | |
---|
126 | class adminPostMiniList extends adminGenericList |
---|
127 | { |
---|
128 | public function display($page,$nb_per_page,$enclose_block='') |
---|
129 | { |
---|
130 | if ($this->rs->isEmpty()) |
---|
131 | { |
---|
132 | echo '<p><strong>'.__('No entry').'</strong></p>'; |
---|
133 | } |
---|
134 | else |
---|
135 | { |
---|
136 | $pager = new pager($page,$this->rs_count,$nb_per_page,10); |
---|
137 | $pager->html_prev = $this->html_prev; |
---|
138 | $pager->html_next = $this->html_next; |
---|
139 | $pager->var_page = 'page'; |
---|
140 | |
---|
141 | $html_block = |
---|
142 | '<table class="clear"><tr>'. |
---|
143 | '<th>'.__('Title').'</th>'. |
---|
144 | '<th>'.__('Date').'</th>'. |
---|
145 | '<th>'.__('Author').'</th>'. |
---|
146 | '<th>'.__('Status').'</th>'. |
---|
147 | '</tr>%s</table>'; |
---|
148 | |
---|
149 | if ($enclose_block) { |
---|
150 | $html_block = sprintf($enclose_block,$html_block); |
---|
151 | } |
---|
152 | |
---|
153 | echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
154 | |
---|
155 | $blocks = explode('%s',$html_block); |
---|
156 | |
---|
157 | echo $blocks[0]; |
---|
158 | |
---|
159 | while ($this->rs->fetch()) |
---|
160 | { |
---|
161 | echo $this->postLine(); |
---|
162 | } |
---|
163 | |
---|
164 | echo $blocks[1]; |
---|
165 | |
---|
166 | echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
167 | } |
---|
168 | } |
---|
169 | |
---|
170 | private function postLine() |
---|
171 | { |
---|
172 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
173 | switch ($this->rs->post_status) { |
---|
174 | case 1: |
---|
175 | $img_status = sprintf($img,__('published'),'check-on.png'); |
---|
176 | break; |
---|
177 | case 0: |
---|
178 | $img_status = sprintf($img,__('unpublished'),'check-off.png'); |
---|
179 | break; |
---|
180 | case -1: |
---|
181 | $img_status = sprintf($img,__('scheduled'),'scheduled.png'); |
---|
182 | break; |
---|
183 | case -2: |
---|
184 | $img_status = sprintf($img,__('pending'),'check-wrn.png'); |
---|
185 | break; |
---|
186 | } |
---|
187 | |
---|
188 | $protected = ''; |
---|
189 | if ($this->rs->post_password) { |
---|
190 | $protected = sprintf($img,__('protected'),'locker.png'); |
---|
191 | } |
---|
192 | |
---|
193 | $selected = ''; |
---|
194 | if ($this->rs->post_selected) { |
---|
195 | $selected = sprintf($img,__('selected'),'selected.png'); |
---|
196 | } |
---|
197 | |
---|
198 | $attach = ''; |
---|
199 | $nb_media = $this->rs->countMedia(); |
---|
200 | if ($nb_media > 0) { |
---|
201 | $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); |
---|
202 | $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); |
---|
203 | } |
---|
204 | |
---|
205 | $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. |
---|
206 | ' id="p'.$this->rs->post_id.'">'; |
---|
207 | |
---|
208 | $res .= |
---|
209 | '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '. |
---|
210 | 'title="'.html::escapeHTML($this->rs->getURL()).'">'. |
---|
211 | html::escapeHTML($this->rs->post_title).'</a></td>'. |
---|
212 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. |
---|
213 | '<td class="nowrap">'.$this->rs->user_id.'</td>'. |
---|
214 | '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. |
---|
215 | '</tr>'; |
---|
216 | |
---|
217 | return $res; |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | class adminUserList extends adminGenericList |
---|
222 | { |
---|
223 | public function display($page,$nb_per_page,$enclose_block='') |
---|
224 | { |
---|
225 | if ($this->rs->isEmpty()) |
---|
226 | { |
---|
227 | echo '<p><strong>'.__('No user').'</strong></p>'; |
---|
228 | } |
---|
229 | else |
---|
230 | { |
---|
231 | $pager = new pager($page,$this->rs_count,$nb_per_page,10); |
---|
232 | $pager->html_prev = $this->html_prev; |
---|
233 | $pager->html_next = $this->html_next; |
---|
234 | $pager->var_page = 'page'; |
---|
235 | |
---|
236 | $html_block = |
---|
237 | '<table class="clear"><tr>'. |
---|
238 | '<th colspan="2">'.__('Username').'</th>'. |
---|
239 | '<th>'.__('First Name').'</th>'. |
---|
240 | '<th>'.__('Last Name').'</th>'. |
---|
241 | '<th>'.__('Display name').'</th>'. |
---|
242 | '<th class="nowrap">'.__('Entries').'</th>'. |
---|
243 | '</tr>%s</table>'; |
---|
244 | |
---|
245 | if ($enclose_block) { |
---|
246 | $html_block = sprintf($enclose_block,$html_block); |
---|
247 | } |
---|
248 | |
---|
249 | echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
250 | |
---|
251 | $blocks = explode('%s',$html_block); |
---|
252 | |
---|
253 | echo $blocks[0]; |
---|
254 | |
---|
255 | while ($this->rs->fetch()) |
---|
256 | { |
---|
257 | echo $this->userLine(); |
---|
258 | } |
---|
259 | |
---|
260 | echo $blocks[1]; |
---|
261 | |
---|
262 | echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
263 | } |
---|
264 | } |
---|
265 | |
---|
266 | private function userLine() |
---|
267 | { |
---|
268 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
269 | $img_status = ''; |
---|
270 | |
---|
271 | $p = $this->core->getUserPermissions($this->rs->user_id); |
---|
272 | |
---|
273 | if (isset($p[$this->core->blog->id]['p']['admin'])) { |
---|
274 | $img_status = sprintf($img,__('admin'),'admin.png'); |
---|
275 | } |
---|
276 | if ($this->rs->user_super) { |
---|
277 | $img_status = sprintf($img,__('superadmin'),'superadmin.png'); |
---|
278 | } |
---|
279 | return |
---|
280 | '<tr class="line">'. |
---|
281 | '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post). |
---|
282 | form::checkbox(array('user_id[]'),$this->rs->user_id).'</td>'. |
---|
283 | '<td class="maximal"><a href="user.php?id='.$this->rs->user_id.'">'. |
---|
284 | $this->rs->user_id.'</a> '.$img_status.'</td>'. |
---|
285 | '<td class="nowrap">'.$this->rs->user_firstname.'</td>'. |
---|
286 | '<td class="nowrap">'.$this->rs->user_name.'</td>'. |
---|
287 | '<td class="nowrap">'.$this->rs->user_displayname.'</td>'. |
---|
288 | '<td class="nowrap"><a href="posts.php?user_id='.$this->rs->user_id.'">'. |
---|
289 | $this->rs->nb_post.'</a></td>'. |
---|
290 | '</tr>'; |
---|
291 | } |
---|
292 | } |
---|
293 | ?> |
---|