1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # This file is part of dcRevisions, a plugin for Dotclear. |
---|
4 | # |
---|
5 | # Copyright (c) 2010 Tomtom and contributors |
---|
6 | # http://blog.zenstyle.fr/ |
---|
7 | # |
---|
8 | # Licensed under the GPL version 2.0 license. |
---|
9 | # A copy of this license is available in LICENSE file or at |
---|
10 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
11 | # -- END LICENSE BLOCK ------------------------------------ |
---|
12 | |
---|
13 | class dcRevisionsList |
---|
14 | { |
---|
15 | protected $rs = null; |
---|
16 | |
---|
17 | public function __construct($rs) |
---|
18 | { |
---|
19 | $this->rs = $rs; |
---|
20 | $this->core = $rs->core; |
---|
21 | } |
---|
22 | |
---|
23 | public function display($url) |
---|
24 | { |
---|
25 | $res = ''; |
---|
26 | |
---|
27 | if (!$this->rs->isEmpty()) { |
---|
28 | $html_block = |
---|
29 | '<table id="revisions-list" summary="'.__('Revisions').'" class="clear maximal" style="display: none;">'. |
---|
30 | '<thead>'. |
---|
31 | '<tr>'. |
---|
32 | '<th>'.__('Id').'</th>'. |
---|
33 | '<th class="nowrap">'.__('Author').'</th>'. |
---|
34 | '<th class="nowrap">'.__('Date').'</th>'. |
---|
35 | '<th class="nowrap">'.__('Status').'</th>'. |
---|
36 | '<th class="nowrap">'.__('Actions').'</th>'. |
---|
37 | '</tr>'. |
---|
38 | '</thead>'. |
---|
39 | '<tbody>%s</tbody>'. |
---|
40 | '</table>'; |
---|
41 | |
---|
42 | $res .= sprintf($html_block,$this->getLines($url)); |
---|
43 | } |
---|
44 | else { |
---|
45 | $res .= '<p style="display:none">'.__('No revision').'</p>'; |
---|
46 | } |
---|
47 | |
---|
48 | return $res; |
---|
49 | } |
---|
50 | |
---|
51 | private function getLines($url) |
---|
52 | { |
---|
53 | $res = ''; |
---|
54 | $p_img = '<img src="%1$s" alt="%2$s" title="%2$s" />'; |
---|
55 | $p_link = '<a href="%1$s" title="%3$s" class="patch"><img src="%2$s" alt="%3$s" /></a>'; |
---|
56 | |
---|
57 | while ($this->rs->fetch()) { |
---|
58 | $res .= |
---|
59 | '<tr class="line wide'.(!$this->rs->canPatch() ? ' offline' : '').'" id="r'.$this->rs->revision_id.'">'."\n". |
---|
60 | '<td class="maximal nowrap rid">'. |
---|
61 | '<strong>'.sprintf(__('Revision #%s'),$this->rs->revision_id).'</strong>'. |
---|
62 | "</td>\n". |
---|
63 | '<td class="minimal nowrap">'. |
---|
64 | $this->rs->getAuthorLink(). |
---|
65 | "</td>\n". |
---|
66 | '<td class="minimal nowrap">'. |
---|
67 | $this->rs->getDate().' - '.$this->rs->getTime(). |
---|
68 | "</td>\n". |
---|
69 | '<td class="minimal nowrap status">'. |
---|
70 | sprintf( |
---|
71 | $p_img, |
---|
72 | ('images/'.($this->rs->canPatch() ? 'check-on.png' : 'locker.png')), |
---|
73 | ($this->rs->canPatch() ? __('Revision allowed') : __('Revision blocked')) |
---|
74 | ). |
---|
75 | "</td>\n". |
---|
76 | '<td class="minimal nowrap status">'. |
---|
77 | ($this->rs->canPatch() ? sprintf($p_link,sprintf($url,$this->rs->revision_id),'index.php?pf=dcRevisions/images/apply.png',__('Apply patch')) : ''). |
---|
78 | "</td>\n". |
---|
79 | "</tr>\n"; |
---|
80 | } |
---|
81 | |
---|
82 | return $res; |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | ?> |
---|