Dotclear

source: plugins/pages/list.php @ 1878:03f675f55755

Revision 1878:03f675f55755, 6.3 KB checked in by Lepeltier kévin, 12 years ago (diff)

Ticket #1181
Modification du bouton de mise à jour.

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 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 -----------------------------------------
12if (!defined('DC_CONTEXT_ADMIN')) { return; }
13dcPage::check('pages,contentadmin');
14
15/* Pager class
16-------------------------------------------------------- */
17class adminPageList extends adminGenericList
18{
19     public function display($page,$nb_per_page,$enclose_block='')
20     {
21          if ($this->rs->isEmpty())
22          {
23               echo '<p><strong>'.__('No page').'</strong></p>';
24          }
25          else
26          {
27               $pager = new pager($page,$this->rs_count,$nb_per_page,10);
28               $pager->html_prev = $this->html_prev;
29               $pager->html_next = $this->html_next;
30               $pager->var_page = 'page';
31               
32               $html_block =
33               '<table class="maximal dragable"><thead><tr>'.
34               '<th scope="col"></th>'.
35               '<th colspan="2">'.__('Title').'</th>'.
36               '<th>'.__('Date').'</th>'.
37               '<th>'.__('Author').'</th>'.
38               '<th>'.__('Comments').'</th>'.
39               '<th>'.__('Trackbacks').'</th>'.
40               '<th>'.__('Status').'</th>'.
41               '</tr></thead>%s</table>';
42               
43               if ($enclose_block) {
44                    $html_block = sprintf($enclose_block,$html_block);
45               }
46               
47               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
48               
49               $blocks = explode('%s',$html_block);
50               
51               echo $blocks[0];
52               
53               $count = 0;
54               while ($this->rs->fetch())
55               {
56                    echo $this->postLine($count);
57                    $count++;
58               }
59               
60               echo $blocks[1];
61               
62               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
63          }
64     }
65     
66     private function postLine($count)
67     {
68          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
69          switch ($this->rs->post_status) {
70               case 1:
71                    $img_status = sprintf($img,__('published'),'check-on.png');
72                    break;
73               case 0:
74                    $img_status = sprintf($img,__('unpublished'),'check-off.png');
75                    break;
76               case -1:
77                    $img_status = sprintf($img,__('scheduled'),'scheduled.png');
78                    break;
79               case -2:
80                    $img_status = sprintf($img,__('pending'),'check-wrn.png');
81                    break;
82          }
83         
84          $protected = '';
85          if ($this->rs->post_password) {
86               $protected = sprintf($img,__('protected'),'locker.png');
87          }
88         
89          $selected = '';
90          if ($this->rs->post_selected) {
91               $selected = sprintf($img,__('hidden'),'hidden.png');
92          }
93         
94          $attach = '';
95          $nb_media = $this->rs->countMedia();
96          if ($nb_media > 0) {
97               $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
98               $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
99          }
100         
101          $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'.
102          ' id="p'.$this->rs->post_id.'">';
103         
104          $res .=
105          '<td class="handle minimal">'.form::field(array('order['.$count.']'),2,3,$count+1,'position','',false,'title="'.sprintf(__('position of %s'),html::escapeHTML($this->rs->post_title)).'"').
106                    form::hidden(array('dynorder[]','dynorder-'.$count),$count).'</td>'.
107          '<td class="nowrap">'.
108          form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable(),'title="'.__('select this page').'"').'</td>'.
109          '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'.
110          html::escapeHTML($this->rs->post_title).'</a></td>'.
111          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'.
112         
113          '<td class="nowrap">'.$this->rs->user_id.'</td>'.
114          '<td class="nowrap">'.$this->rs->nb_comment.'</td>'.
115          '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'.
116          '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'.
117          '</tr>';
118         
119          return $res;
120     }
121}
122
123/* Getting pages
124-------------------------------------------------------- */
125$params = array(
126     'post_type' => 'page'
127);
128
129$page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
130$nb_per_page =  30;
131
132if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
133     $nb_per_page = (integer) $_GET['nb'];
134}
135
136$params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
137$params['no_content'] = true;
138$params['order'] = 'post_position ASC, post_title ASC';
139
140try {
141     $pages = $core->blog->getPosts($params);
142     $counter = $core->blog->getPosts($params,true);
143     $post_list = new adminPageList($core,$pages,$counter->f(0));
144} catch (Exception $e) {
145     $core->error->add($e->getMessage());
146}
147
148# Actions combo box
149$combo_action = array();
150if ($core->auth->check('publish,contentadmin',$core->blog->id))
151{
152     $combo_action[__('publish')] = 'publish';
153     $combo_action[__('unpublish')] = 'unpublish';
154     $combo_action[__('schedule')] = 'schedule';
155     $combo_action[__('mark as pending')] = 'pending';
156}
157if ($core->auth->check('admin',$core->blog->id)) {
158     $combo_action[__('change author')] = 'author';
159}
160if ($core->auth->check('delete,contentadmin',$core->blog->id))
161{
162     $combo_action[__('delete')] = 'delete';
163}
164
165# --BEHAVIOR-- adminPagesActionsCombo
166$core->callBehavior('adminPagesActionsCombo',array(&$combo_action));
167
168/* Display
169-------------------------------------------------------- */
170?>
171<html>
172<head>
173  <title><?php echo __('Pages'); ?></title>
174  <script type="text/javascript" src="js/_posts_list.js"></script>
175  <script type="text/javascript">
176  //<![CDATA[
177  <?php echo dcPage::jsVar('dotclear.msg.confirm_delete_posts',__("Are you sure you want to delete selected pages?")); ?>
178  //]]>
179  </script>
180</head>
181
182<body>
183<?php
184echo dcPage::breadcrumb(
185     array(
186          html::escapeHTML($core->blog->name) => '',
187          '<span class="page-title">'.__('Pages').'</span>' => ''
188     ));
189
190echo
191'<p class="top-add"><a class="button add" href="'.$p_url.'&amp;act=page">'.__('New page').'</a></p>';
192
193if (!$core->error->flag())
194{
195     # Show pages
196     $post_list->display($page,$nb_per_page,
197     '<form action="posts_actions.php" method="post" id="form-entries">'.
198     
199     '%s'.
200     
201     '<div class="two-cols">'.
202     '<p class="col checkboxes-helpers">'.
203     '<input type="submit" name="updateaction" value="'.__('Update menu').'" />'.
204     form::hidden(array('post_type'),'page').
205     form::hidden(array('redir'),html::escapeHTML($_SERVER['REQUEST_URI'])).
206     $core->formNonce().
207     '</p>'.
208     '<p class="col right"><label for="action" class="classic">'.__('Selected pages action:').'</label> '.
209     form::combo('action',$combo_action).
210     '<input type="submit" value="'.__('ok').'" /></p>'.
211     '</div>'.
212     '</form>'.
213     '<br class="clear" />');
214}
215dcPage::helpBlock('pages');
216?>
217</body>
218</html>
Note: See TracBrowser for help on using the repository browser.

Sites map