Changeset 2055:699a9314513f for plugins/pages
- Timestamp:
- 09/24/13 09:37:38 (12 years ago)
- Branch:
- default
- Location:
- plugins/pages
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/pages/_prepend.php
r1694 r2055 12 12 if (!defined('DC_RC_PATH')) { return; } 13 13 14 global $core; 14 global $core, $__autoload; 15 16 $__autoload['dcPagesActionsPage'] = dirname(__FILE__).'/class.actionpage.php'; 17 $__autoload['adminPageList'] = dirname(__FILE__).'/class.listpage.php'; 15 18 16 19 $core->url->register('pages','pages','^pages/(.+)$',array('urlPages','pages')); -
plugins/pages/list.php
r2049 r2055 12 12 if (!defined('DC_CONTEXT_ADMIN')) { return; } 13 13 dcPage::check('pages,contentadmin'); 14 15 /* Pager class16 -------------------------------------------------------- */17 class adminPageList extends adminGenericList18 {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 else26 {27 $pager = new dcPager($page,$this->rs_count,$nb_per_page,10);28 $entries = array();29 if (isset($_REQUEST['entries'])) {30 foreach ($_REQUEST['entries'] as $v) {31 $entries[(integer)$v]=true;32 }33 }34 $html_block =35 '<div class="table-outer">'.36 '<table class="maximal dragable"><thead><tr>'.37 '<th colspan="3">'.__('Title').'</th>'.38 '<th>'.__('Date').'</th>'.39 '<th>'.__('Author').'</th>'.40 '<th>'.__('Comments').'</th>'.41 '<th>'.__('Trackbacks').'</th>'.42 '<th>'.__('Status').'</th>'.43 '</tr></thead><tbody id="pageslist">%s</tbody></table></div>';44 45 if ($enclose_block) {46 $html_block = sprintf($enclose_block,$html_block);47 }48 49 echo $pager->getLinks();50 51 $blocks = explode('%s',$html_block);52 53 echo $blocks[0];54 55 $count = 0;56 while ($this->rs->fetch())57 {58 echo $this->postLine($count,isset($entries[$this->rs->post_id]));59 $count ++;60 }61 62 echo $blocks[1];63 64 echo $pager->getLinks();65 }66 }67 68 private function postLine($count,$checked)69 {70 $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';71 switch ($this->rs->post_status) {72 case 1:73 $img_status = sprintf($img,__('Published'),'check-on.png');74 break;75 case 0:76 $img_status = sprintf($img,__('Unpublished'),'check-off.png');77 break;78 case -1:79 $img_status = sprintf($img,__('Scheduled'),'scheduled.png');80 break;81 case -2:82 $img_status = sprintf($img,__('Pending'),'check-wrn.png');83 break;84 }85 86 $protected = '';87 if ($this->rs->post_password) {88 $protected = sprintf($img,__('Protected'),'locker.png');89 }90 91 $selected = '';92 if ($this->rs->post_selected) {93 $selected = sprintf($img,__('Hidden'),'hidden.png');94 }95 96 $attach = '';97 $nb_media = $this->rs->countMedia();98 if ($nb_media > 0) {99 $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');100 $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');101 }102 103 $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'.104 ' id="p'.$this->rs->post_id.'">';105 106 $res .=107 '<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>'.108 '<td class="nowrap">'.109 form::checkbox(array('entries[]'),$this->rs->post_id,$checked,'','',!$this->rs->isEditable(),'title="'.__('Select this page').'"').'</td>'.110 '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'.111 html::escapeHTML($this->rs->post_title).'</a></td>'.112 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'.113 114 '<td class="nowrap">'.$this->rs->user_id.'</td>'.115 '<td class="nowrap">'.$this->rs->nb_comment.'</td>'.116 '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'.117 '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'.118 '</tr>';119 120 return $res;121 }122 }123 14 124 15 /* Getting pages … … 145 36 } catch (Exception $e) { 146 37 $core->error->add($e->getMessage()); 147 }148 149 class dcPagesActionsPage extends dcPostsActionsPage {150 151 public function __construct($core,$uri,$redirect_args=array()) {152 parent::__construct($core,$uri,$redirect_args);153 $this->redirect_fields = array();154 155 }156 157 public function beginPage($breadcrumb='',$head='') {158 echo '<html><head><title>'.__('Pages').'</title>'.159 dcPage::jsLoad('js/_posts_actions.js').160 '<script type="text/javascript">'.161 '//<![CDATA['.162 dcPage::jsVar('dotclear.msg.confirm_delete_posts',__("Are you sure you want to delete selected pages?")).163 '//]]>'.164 $head.165 '</script></head><body>'.166 $breadcrumb;167 }168 169 public function endPage() {170 echo '</body></html>';171 }172 public function loadDefaults() {173 parent::loadDefaults();174 unset ($this->combos[__('Mark')]);175 unset ($this->actions['selected']);176 unset ($this->actions['unselected']);177 $this->actions['reorder']=array('dcPagesActionsPage','doReorderPages');178 }179 public function process() {180 // fake action for pages reordering181 if (!empty($this->from['reorder'])) {182 $this->from['action']='reorder';183 }184 $this->from['post_type']='page';185 return parent::process();186 }187 188 public static function doReorderPages($core, dcPostsActionsPage $ap, $post) {189 foreach($post['order'] as $post_id => $value) {190 if (!$core->auth->check('publish,contentadmin',$core->blog->id))191 throw new Exception(__('You are not allowed to change this entry status'));192 193 $strReq = "WHERE blog_id = '".$core->con->escape($core->blog->id)."' ".194 "AND post_id ".$core->con->in($post_id);195 196 #If user can only publish, we need to check the post's owner197 if (!$core->auth->check('contentadmin',$core->blog->id))198 $strReq .= "AND user_id = '".$core->con->escape($core->auth->userID())."' ";199 200 $cur = $core->con->openCursor($core->prefix.'post');201 202 $cur->post_position = (integer) $value-1;203 $cur->post_upddt = date('Y-m-d H:i:s');204 205 $cur->update($strReq);206 $core->blog->triggerBlog();207 208 }209 $ap->redirect(array('reo'=>1),false);210 }211 38 } 212 39
Note: See TracChangeset
for help on using the changeset viewer.