Dotclear

source: plugins/pages/list.php @ 1882:433e8676f9ac

Revision 1882:433e8676f9ac, 6.3 KB checked in by Lepeltier kévin, 11 years ago (diff)

Ticket #1181 : Modification de admin/plugin.php?p=pages pour ajouter les champs de réordonancement.
Nouvelle action reorder dans le menu d'action.
Javascript sortable.
Petites modifs sur la copie de _posts_list.js

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

Sites map