Dotclear

source: plugins/pages/list.php @ 1179:a43a29427ef3

Revision 1179:a43a29427ef3, 5.8 KB checked in by franck <carnet.franck.paul@…>, 11 years ago (diff)

Update copyright notice

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

Sites map