Dotclear

Changeset 1903:931d1495a1c7


Ignore:
Timestamp:
09/16/13 10:11:39 (12 years ago)
Author:
Dsls
Branch:
actionsreloaded
Message:

Added redirection default params, tuned pages plugin for new actions handling. See #1181

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/actions/class.dcaction.php

    r1807 r1903  
    5252     * @return mixed Value. 
    5353     */ 
    54      public function __construct($core,$uri) { 
     54     public function __construct($core,$uri,$redirect_args=array()) { 
    5555          $this->core = $core; 
    5656          $this->actions = new ArrayObject(); 
    5757          $this->combo = array(); 
    5858          $this->uri = $uri; 
    59           $this->redir_args = array(); 
     59          $this->redir_args = $redirect_args; 
    6060          $this->redirect_fields = array(); 
    6161          $this->action = ''; 
    6262          $this->cb_title = __('Title'); 
     63          $this->entries = array(); 
    6364          $this->from = new ArrayObject($_POST); 
    6465     } 
  • inc/admin/actions/class.dcactionposts.php

    r1808 r1903  
    1414class dcPostsActionsPage extends dcActionsPage 
    1515{ 
    16      public function __construct($core,$uri) { 
    17           parent::__construct($core,$uri); 
     16     public function __construct($core,$uri,$redirect_args=array()) { 
     17          parent::__construct($core,$uri,$redirect_args); 
    1818          $this->redirect_fields = array('user_id','cat_id','status', 
    1919          'selected','month','lang','sortby','order','page','nb'); 
     20          $this->loadDefaults(); 
     21          $core->callBehavior('adminPostsActionsPage',$core,$this); 
     22     } 
     23 
     24     protected function loadDefaults() { 
    2025          // We could have added a behavior here, but we want default action 
    2126          // to be setup first 
    22           dcDefaultPostActions::adminPostsActionsPage($core,$this); 
    23           $core->callBehavior('adminPostsActionsPage',$core,$this); 
    24  
    25      } 
    26  
     27          dcDefaultPostActions::adminPostsActionsPage($this->core,$this); 
     28     } 
     29      
    2730     public function beginPage($breadcrumb='',$head='') { 
    2831          dcPage::open( 
  • plugins/pages/index.php

    r1888 r1903  
    1717if ($act == 'page') { 
    1818     include dirname(__FILE__).'/page.php'; 
    19 } else if ($act == 'actions') { 
    20      include dirname(__FILE__).'/pages_actions.php'; 
    2119} else { 
    2220     include dirname(__FILE__).'/list.php'; 
  • plugins/pages/list.php

    r1893 r1903  
    144144} 
    145145 
     146class dcPagesActionsPage extends dcPostsActionsPage { 
     147 
     148     public function __construct($core,$uri,$redirect_args=array()) { 
     149          parent::__construct($core,$uri,$redirect_args); 
     150          $this->redirect_fields = array(); 
     151 
     152     } 
     153      
     154     public function beginPage($breadcrumb='',$header='') { 
     155          echo '<html><head><title>'.__('Pages').'</title>'. 
     156               dcPage::jsLoad('index.php?pf=pages/list.js'). 
     157               # --BEHAVIOR-- adminBeforePostDelete 
     158               $core->callBehavior('adminPagesActionsHeaders'). 
     159               '<script type="text/javascript">'. 
     160               '//<![CDATA['. 
     161               dcPage::jsVar('dotclear.msg.confirm_delete_posts',__("Are you sure you want to delete selected pages?")). 
     162               '//]]>'. 
     163               '</script></head><body>'; 
     164     } 
     165      
     166     public function endPage() { 
     167          echo '</body></html>'; 
     168     } 
     169     public function loadDefaults() { 
     170          parent::loadDefaults(); 
     171          unset ($this->combos[__('Mark')]); 
     172          unset ($this->actions['selected']); 
     173          unset ($this->actions['unselected']); 
     174          $this->actions['reorder']=array('dcPagesActionsPage','doReorderPages'); 
     175     } 
     176     public function process() { 
     177          // fake action for pages reordering 
     178          if (!empty($this->from['reorder'])) { 
     179               $this->from['action']='reorder'; 
     180          } 
     181          parent::process(); 
     182     } 
     183      
     184     public static function doReorderPages($core, dcPostsActionsPage $ap, $post) { 
     185          foreach($post['order'] as $post_id => $value) { 
     186               if (!$core->auth->check('publish,contentadmin',$core->blog->id)) 
     187                    throw new Exception(__('You are not allowed to change this entry status')); 
     188                
     189               $strReq = "WHERE blog_id = '".$core->con->escape($core->blog->id)."' ". 
     190                         "AND post_id ".$core->con->in($post_id); 
     191                
     192               #If user can only publish, we need to check the post's owner 
     193               if (!$core->auth->check('contentadmin',$core->blog->id)) 
     194                    $strReq .= "AND user_id = '".$core->con->escape($core->auth->userID())."' "; 
     195                
     196               $cur = $core->con->openCursor($core->prefix.'post'); 
     197                
     198               $cur->post_position = (integer) $value-1; 
     199               $cur->post_upddt = date('Y-m-d H:i:s'); 
     200                
     201               $cur->update($strReq); 
     202               $core->blog->triggerBlog(); 
     203                
     204          } 
     205          $ap->redirect(array('reo'=>1),false); 
     206     }     
     207} 
     208 
    146209# Actions combo box 
    147 $combo_action = array(); 
    148 if ($core->auth->check('publish,contentadmin',$core->blog->id)) 
    149 { 
    150      $combo_action[__('Status')] = array( 
    151           __('Publish') => 'publish', 
    152           __('Unpublish') => 'unpublish', 
    153           __('Schedule') => 'schedule', 
    154           __('Mark as pending') => 'pending' 
    155      ); 
    156 } 
    157      $combo_action[__('Change')] = array( 
    158           __('Change language') => 'lang' 
    159      ); 
    160 if ($core->auth->check('admin',$core->blog->id)) 
    161 { 
    162      $combo_action[__('Change')] = array_merge($combo_action[__('Change')], array( 
    163           __('Change author') => 'author') 
    164      ); 
    165 } 
    166 if ($core->auth->check('delete,contentadmin',$core->blog->id)) 
    167 { 
    168      $combo_action[__('Delete')] = array( 
    169           __('Delete') => 'delete' 
    170      ); 
    171 } 
     210 
     211$pages_actions_page = new dcPagesActionsPage($core,'plugin.php',array('p'=>'pages')); 
     212 
     213$pages_actions_page->process(); 
     214 
    172215 
    173216# --BEHAVIOR-- adminPagesActionsCombo 
     
    199242     )); 
    200243 
     244if (!empty($_GET['upd'])) { 
     245     dcPage::success(__('Selected pages have been successfully updated.')); 
     246} elseif (!empty($_GET['del'])) { 
     247     dcPage::success(__('Selected pages have been successfully deleted.')); 
     248} elseif (!empty($_GET['reo'])) { 
     249     dcPage::success(__('Selected pages have been successfully reordered.')); 
     250} 
    201251echo 
    202252'<p class="top-add"><a class="button add" href="'.$p_url.'&amp;act=page">'.__('New page').'</a></p>'; 
     
    206256     # Show pages 
    207257     $post_list->display($page,$nb_per_page, 
    208      '<form action="plugin.php?p=pages&act=actions" method="post" id="form-entries">'. 
     258     '<form action="plugin.php" method="post" id="form-entries">'. 
    209259      
    210260     '%s'. 
     
    214264      
    215265     '<p class="col right"><label for="action" class="classic">'.__('Selected pages action:').'</label> '. 
    216      form::combo('action',$combo_action). 
     266     form::combo('action',$pages_actions_page->getCombo()). 
    217267     '<input type="submit" value="'.__('ok').'" /></p>'. 
    218268     form::hidden(array('post_type'),'page'). 
    219      form::hidden(array('redir'),html::escapeHTML($_SERVER['REQUEST_URI'])). 
     269     form::hidden(array('p'),'pages'). 
    220270     '</div>'. 
    221271     $core->formNonce(). 
Note: See TracChangeset for help on using the changeset viewer.

Sites map