Dotclear

Changeset 2055:699a9314513f


Ignore:
Timestamp:
09/24/13 09:37:38 (12 years ago)
Author:
Dsls
Branch:
default
Message:
  • Restored previous available pages actions
  • strenghened code in actions (especially if no selection in secondary action page)
  • isolated pages plugin classes, more readable now
  • Made terms more generic in tags behaviors ("selection" instead of "entries")
Files:
2 added
6 edited

Legend:

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

    r2048 r2055  
    4444     protected $cb_title; 
    4545      
     46     /** @var string title for caller page title */ 
     47     protected $caller_title; 
     48      
    4649    /** 
    4750     * Class constructor 
     
    6669          $this->from = new ArrayObject($_POST); 
    6770          $this->field_entries = 'entries'; 
     71          $this->caller_title = __('Entries'); 
    6872     } 
    6973      
     
    194198     } 
    195199 
     200 
    196201     /** 
    197202     * getRedirection - returns redirection URL 
     
    237242     } 
    238243 
     244     /** 
     245     * getCallerTitle - returns current form URI, if any 
     246     * 
     247     * @access public 
     248      * 
     249     * @return string the form URI 
     250     */ 
     251     public function getCallerTitle() { 
     252          return $this->caller_title; 
     253     } 
     254      
    239255     /** 
    240256     * getAction - returns current action, if any 
     
    275291               } catch (Exception $e) { 
    276292                    $this->error($e); 
     293                    return true; 
    277294               } 
    278295          } 
  • inc/admin/actions/class.dcactionposts.php

    r2048 r2055  
    1919          'selected','month','lang','sortby','order','page','nb'); 
    2020          $this->loadDefaults(); 
    21           $core->callBehavior('adminPostsActionsPage',$core,$this); 
    2221     } 
    2322 
     
    2625          // to be setup first 
    2726          dcDefaultPostActions::adminPostsActionsPage($this->core,$this); 
     27          $this->core->callBehavior('adminPostsActionsPage',$this->core,$this); 
     28 
    2829     } 
    2930      
     
    4849               array( 
    4950                    html::escapeHTML($this->core->blog->name) => '', 
    50                     __('Entries') => $this->getRedirection(array(),true), 
     51                    $this->getCallerTitle() => $this->getRedirection(array(),true), 
    5152                    '<span class="page-title">'.__('Entries actions').'</span>' => '' 
    5253               )) 
     
    216217                         array( 
    217218                              html::escapeHTML($core->blog->name) => '', 
    218                               __('Entries') => $ap->getRedirection(array(),true), 
    219                               '<span class="page-title">'.__('Change category for entries').'</span>' => '' 
     219                              $ap->getCallerTitle() => $ap->getRedirection(array(),true), 
     220                              '<span class="page-title">'.__('Change category for this selection').'</span>' => '' 
    220221               ))); 
    221222               # categories list 
     
    286287                         array( 
    287288                              html::escapeHTML($core->blog->name) => '', 
    288                               __('Entries') => $ap->getRedirection(array(),true), 
    289                               '<span class="page-title">'.__('Change author for entries').'</span>' => '')), 
     289                              $ap->getCallerTitle() => $ap->getRedirection(array(),true), 
     290                              '<span class="page-title">'.__('Change author for this selection').'</span>' => '')), 
    290291                         dcPage::jsLoad('js/jquery/jquery.autocomplete.js'). 
    291292                         '<script type="text/javascript">'."\n". 
     
    297298 
    298299               echo 
    299                '<form action="posts_actions.php" method="post">'. 
     300               '<form action="'.$ap->getRedirection(array(),true).'" method="post">'. 
    300301               $ap->getCheckboxes(). 
    301302               '<p><label for="new_auth_id" class="classic">'.__('New author (author ID):').'</label> '. 
     
    327328                         array( 
    328329                              html::escapeHTML($core->blog->name) => '', 
    329                               __('Entries') => $ap->getRedirection(array(),true), 
    330                               '<span class="page-title">'.__('Change language for entries').'</span>' => '' 
     330                              $ap->getCallerTitle() => $ap->getRedirection(array(),true), 
     331                              '<span class="page-title">'.__('Change language for this selection').'</span>' => '' 
    331332               ))); 
    332333               # lang list 
     
    347348                
    348349               echo 
    349                '<form action="posts_actions.php" method="post">'. 
     350               '<form action="'.$ap->getRedirection(array(),true).'" method="post">'. 
    350351               $ap->getCheckboxes(). 
    351352                
  • plugins/dclegacy/_admin.php

    r1905 r2055  
    1313 
    1414$GLOBALS['core']->addBehavior('adminPostsActionsPage',array('dcLegacyPosts','adminPostsActionsPage')); 
     15$GLOBALS['core']->addBehavior('adminPagessActionsPage',array('dcLegacyPosts','adminPagesActionsPage')); 
    1516$GLOBALS['core']->addBehavior('adminCommentsActionsPage',array('dcLegacyComments','adminCommentsActionsPage')); 
    1617 
     
    6970     } 
    7071} 
     72/* Handle deprecated behaviors :  
     73    * adminPagesActionsCombo 
     74     * adminPagesActionsHeaders 
     75     * adminPagesActionsContent 
     76*/ 
     77class dcLegacyPages 
     78{ 
     79     public static function adminPagesActionsPage($core, dcPagesActionsPage $as) { 
     80          $stub_actions = new ArrayObject(); 
     81          $core->callBehavior('adminPagesActionsCombo',array($stub_actions)); 
     82          if (!empty($stub_actions)) { 
     83               $as->addAction($stub_actions,array('dcLegacyPages','onActionLegacy')); 
     84          } 
     85     } 
     86      
     87     public static function onActionLegacy($core, dcPagesActionsPage $as, $post) { 
     88          $core->callBehavior('adminPagesActions',$core,$as->getRS(),$as->getAction(),$as->getRedirection()); 
     89          $as->beginPage('', 
     90               dcPage::jsLoad('js/jquery/jquery.autocomplete.js'). 
     91               dcPage::jsMetaEditor(). 
     92               $core->callBehavior('adminPagesActionsHeaders'),''); 
     93          $core->callBehavior('adminPagesActionsContent',$core,$as->getAction(),$as->getHiddenFields(true)); 
     94          $as->endPage(); 
     95     } 
     96} 
  • plugins/pages/_prepend.php

    r1694 r2055  
    1212if (!defined('DC_RC_PATH')) { return; } 
    1313 
    14 global $core; 
     14global $core, $__autoload; 
     15 
     16$__autoload['dcPagesActionsPage'] = dirname(__FILE__).'/class.actionpage.php'; 
     17$__autoload['adminPageList'] = dirname(__FILE__).'/class.listpage.php'; 
    1518 
    1619$core->url->register('pages','pages','^pages/(.+)$',array('urlPages','pages')); 
  • plugins/pages/list.php

    r2049 r2055  
    1212if (!defined('DC_CONTEXT_ADMIN')) { return; } 
    1313dcPage::check('pages,contentadmin'); 
    14  
    15 /* Pager class 
    16 -------------------------------------------------------- */ 
    17 class 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 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 } 
    12314 
    12415/* Getting pages 
     
    14536} catch (Exception $e) { 
    14637     $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 reordering 
    181           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 owner 
    197                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      }     
    21138} 
    21239 
  • plugins/tags/_admin.php

    r2048 r2055  
    152152                              html::escapeHTML($core->blog->name) => '', 
    153153                              __('Entries') => $ap->getRedirection(array(),true), 
    154                               '<span class="page-title">'.__('Add tags to entries').'</span>' => '' 
     154                              '<span class="page-title">'.__('Add tags to this selection').'</span>' => '' 
    155155                    )), 
    156156                    dcPage::jsLoad('js/jquery/jquery.autocomplete.js'). 
     
    221221                    } 
    222222               } 
     223               if (empty($tags)) { 
     224                    throw new Exception(__('No tags for selected entries')); 
     225               }               
    223226               $ap->beginPage( 
    224227                    dcPage::breadcrumb( 
    225                          array( 
    226                               html::escapeHTML($core->blog->name) => '', 
    227                               __('Entries') => 'posts.php', 
    228                               '<span class="page-title">'.__('Remove selected tags from entries').'</span>' => '' 
     228                              array( 
     229                                   html::escapeHTML($core->blog->name) => '', 
     230                                   __('Entries') => 'posts.php', 
     231                                   '<span class="page-title">'.__('Remove selected tags from this selection').'</span>' => '' 
    229232               ))); 
    230                 
    231                if (empty($tags)) { 
    232                     echo '<p>'.__('No tags for selected entries').'</p>'; 
    233                     return; 
    234                } 
    235                 
    236233               $posts_count = count($_POST['entries']); 
    237234                
     
    255252               '<p><input type="submit" value="'.__('ok').'" />'. 
    256253                
    257                $core->formNonce(). 
     254               $core->formNonce().$ap->getHiddenFields(). 
    258255               form::hidden(array('action'),'tags_remove'). 
    259256               '</p></div></form>'; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map