Dotclear


Ignore:
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • admin/posts_actions.php

    r1473 r1468  
    1616 
    1717$params = array(); 
    18  
    19 /** 
    20 * FieldsList - Compatibility class for hidden fields & entries[] fields 
    21 * 
    22 */ 
    23 class FieldsList { 
    24      /** @var array list of hidden fields */ 
    25      protected $hidden; 
    26      /** @var array list of selected entries */ 
    27      protected $entries; 
    28  
    29  
    30    /** 
    31      * Class constructor 
    32      */ 
    33      public function __construct() { 
    34           $this->hidden=array(); 
    35           $this->entries =array(); 
    36      } 
    37  
    38     /** 
    39      * addHidden - adds a hidden field 
    40      *  
    41      * @param string $name the field name. 
    42      * @param mixed $value the field value. 
    43      * 
    44      * @access public 
    45       * @return the FieldsList instance, enabling to chain requests 
    46      */    
    47       public function addHidden($name,$value) { 
    48           $this->hidden[] = form::hidden($name,$value); 
    49           return $this; 
    50      } 
    51  
    52     /** 
    53      * addEntry - adds a antry field 
    54      *  
    55      * @param string $id the entry id. 
    56      * @param mixed $title the entry title. 
    57      * 
    58      * @access public 
    59       * @return the FieldsList instance, enabling to chain requests 
    60      */    
    61       public function addEntry($id,$title) { 
    62           $this->entries[$id]=$title; 
    63           return $this; 
    64      } 
    65  
    66     /** 
    67      * getHidden - returns the list of hidden fields, html encoded 
    68      * 
    69      * @access public 
    70       * @return the list of hidden fields, html encoded 
    71      */ 
    72       public function getHidden() { 
    73           return join('',$this->hidden); 
    74      } 
    75       
    76     /** 
    77      * getEntries - returns the list of entry fields, html encoded 
    78      * 
    79       * @param boolean $hidden if set to true, returns entries as a list of hidden field 
    80       *                if set to false, returns html code displaying the list of entries 
    81       *                with a list of checkboxes to enable to select/deselect entries 
    82      * @access public 
    83       * @return the list of entry fields, html encoded 
    84      */ 
    85      public function getEntries ($hidden=false) { 
    86           $ret = ''; 
    87           if ($hidden) { 
    88                foreach ($this->entries as $id=> $e) { 
    89                     $ret .= form::hidden('entries[]',$id); 
    90                } 
    91           } else { 
    92                $ret =  
    93                     '<table class="posts-list"><tr>'. 
    94                     '<th colspan="2">'.__('Title').'</th>'. 
    95                     '</tr>'; 
    96                foreach ($this->entries as $id=>$title) { 
    97                     $ret .=  
    98                          '<tr><td>'. 
    99                          form::checkbox(array('entries[]'),$id,true,'','').'</td>'. 
    100                          '<td>'.   $title.'</td></tr>'; 
    101                } 
    102                $ret .= '</table>'; 
    103           } 
    104           return $ret; 
    105      } 
    106       
    107     /** 
    108      * __toString - magic method. -- DEPRECATED here 
    109       *              This method is only used to preserve compatibility with plugins  
    110       *                  relying on previous versions of adminPostsActionsContent behavior,  
    111       * 
    112      * @access public 
    113       * @return the list of hidden fields and entries (as hidden fields too), html encoded 
    114      */ 
    115      public function __toString() { 
    116           return join('',$this->hidden).$this->getEntries(true); 
    117      } 
    118 } 
    119  
    120  
    121 function listEntries($titles) { 
    122      $ret =  
    123           '<table class="posts-list"><tr>'. 
    124           '<th colspan="2">'.__('Title').'</th>'. 
    125           '</tr>'; 
    126      foreach ($titles as $id=>$title) { 
    127           $ret .=  
    128                '<tr><td>'. 
    129                form::checkbox(array('entries[]'),$id,true,'','').'</td>'. 
    130                '<td>'.   $title.'</td></tr>'; 
    131      } 
    132      $ret .= '</table>'; 
    133      return $ret; 
    134 } 
     18$action = ''; 
    13519 
    13620/* Actions 
     
    311195          } 
    312196     } 
    313 } else { 
    314      if (empty($_POST['entries'])) { 
    315           $core->error->add(__('At least one entry should be selected')); 
    316      } else { 
    317           $core->error->add(__('No action specified.')); 
    318      } 
    319      dcPage::open( 
    320           __('Entries'),'',dcPage::breadcrumb( 
    321           array( 
    322                html::escapeHTML($core->blog->name) => '', 
    323                __('Entries') => 'posts.php', 
    324                '<span class="page-title">'.__('Entries actions').'</span>' => '' 
    325           )) 
    326      ); 
    327  
    328      dcPage::close(); 
    329      exit; 
    330 } 
     197} 
     198 
    331199/* DISPLAY 
    332200-------------------------------------------------------- */ 
     
    363231} 
    364232 
    365 $fields = new FieldsList(); 
     233$hidden_fields = ''; 
    366234while ($posts->fetch()) { 
    367      $fields->addEntry($posts->post_id,$posts->post_title); 
     235     $hidden_fields .= form::hidden(array('entries[]'),$posts->post_id); 
    368236} 
    369237 
    370238if (isset($_POST['redir']) && strpos($_POST['redir'],'://') === false) 
    371239{ 
    372      $fields->addHidden(array('redir'),html::escapeURL($_POST['redir'])); 
     240     $hidden_fields .= form::hidden(array('redir'),html::escapeURL($_POST['redir'])); 
    373241} 
    374242else 
    375243{ 
    376      $fields 
    377           ->addHidden(array('user_id'),$_POST['user_id']) 
    378           ->addHidden(array('cat_id'),$_POST['cat_id']) 
    379           ->addHidden(array('status'),$_POST['status']) 
    380           ->addHidden(array('selected'),$_POST['selected']) 
    381           ->addHidden(array('month'),$_POST['month']) 
    382           ->addHidden(array('lang'),$_POST['lang']) 
    383           ->addHidden(array('sortby'),$_POST['sortby']) 
    384           ->addHidden(array('order'),$_POST['order']) 
    385           ->addHidden(array('page'),$_POST['page']) 
    386           ->addHidden(array('nb'),$_POST['nb']) 
    387      ; 
     244     $hidden_fields .= 
     245     form::hidden(array('user_id'),$_POST['user_id']). 
     246     form::hidden(array('cat_id'),$_POST['cat_id']). 
     247     form::hidden(array('status'),$_POST['status']). 
     248     form::hidden(array('selected'),$_POST['selected']). 
     249     form::hidden(array('month'),$_POST['month']). 
     250     form::hidden(array('lang'),$_POST['lang']). 
     251     form::hidden(array('sortby'),$_POST['sortby']). 
     252     form::hidden(array('order'),$_POST['order']). 
     253     form::hidden(array('page'),$_POST['page']). 
     254     form::hidden(array('nb'),$_POST['nb']); 
    388255} 
    389256 
    390257if (isset($_POST['post_type'])) { 
    391      $fields->addHidden(array('post_type'),$_POST['post_type']); 
     258     $hidden_fields .= form::hidden(array('post_type'),$_POST['post_type']); 
    392259} 
    393260 
    394261# --BEHAVIOR-- adminPostsActionsContent 
    395 $core->callBehavior('adminPostsActionsContent',$core,$action,$fields); 
     262$core->callBehavior('adminPostsActionsContent',$core,$action,$hidden_fields); 
    396263 
    397264if ($action == 'category') 
    398265{ 
    399      echo dcPage::breadcrumb( 
    400           array( 
    401                html::escapeHTML($core->blog->name) => '', 
    402                __('Entries') => 'posts.php', 
    403                __('Change category for entries') => '' 
    404      )); 
    405  
    406      # categories list 
     266     echo '<h2 class="page-title">'.__('Change category for entries').'</h2>'; 
     267      
    407268     # Getting categories 
    408269     $categories_combo = array(__('(No cat)') => ''); 
     
    410271          $categories = $core->blog->getCategories(array('post_type'=>'post')); 
    411272          if (!$categories->isEmpty()) { 
    412           while ($categories->fetch()) { 
     273               while ($categories->fetch()) { 
    413274                    $catparents_combo[] = $categories_combo[] = new formSelectOption( 
    414275                         str_repeat('&nbsp;&nbsp;',$categories->level-1).($categories->level-1 == 0 ? '' : '&bull; ').html::escapeHTML($categories->cat_title), 
    415                     $categories->cat_id 
    416                ); 
    417           } 
     276                         $categories->cat_id 
     277                    ); 
     278               } 
    418279          } 
    419280     } catch (Exception $e) { } 
     
    421282     echo 
    422283     '<form action="posts_actions.php" method="post">'. 
    423      $fields->getEntries(). 
    424284     '<p><label for="new_cat_id" class="classic">'.__('Category:').'</label> '. 
    425285     form::combo('new_cat_id',$categories_combo,''); 
     
    438298      
    439299     echo 
    440      $fields->getHidden(). 
     300     $hidden_fields. 
    441301     $core->formNonce(). 
    442302     form::hidden(array('action'),'category'). 
     
    446306elseif ($action == 'lang') 
    447307{ 
    448      echo dcPage::breadcrumb( 
    449           array( 
    450                html::escapeHTML($core->blog->name) => '', 
    451                __('Entries') => 'posts.php', 
    452                '<span class="page-title">'.__('Change language for entries').'</span>' => '' 
    453      )); 
     308     echo '<h2 class="page-title">'.__('Change language for entries').'</h2>'; 
    454309      
    455310     # lang list 
     
    471326     echo 
    472327     '<form action="posts_actions.php" method="post">'. 
    473      $fields->getEntries(). 
    474       
    475328     '<p><label for="new_lang" class="classic">'.__('Entry lang:').'</label> '. 
    476329     form::combo('new_lang',$lang_combo,''); 
    477330      
    478331     echo 
    479      $fields->getHidden(). 
     332     $hidden_fields. 
    480333     $core->formNonce(). 
    481334     form::hidden(array('action'),'lang'). 
     
    486339elseif ($action == 'author' && $core->auth->check('admin',$core->blog->id)) 
    487340{ 
    488      echo dcPage::breadcrumb( 
    489           array( 
    490                html::escapeHTML($core->blog->name) => '', 
    491                __('Entries') => 'posts.php', 
    492                '<span class="page-title">'.__('Change author for entries').'</span>' => '' 
    493      )); 
     341     echo '<h2 class="page-title">'.__('Change author for entries').'</h2>'; 
    494342      
    495343     echo 
    496344     '<form action="posts_actions.php" method="post">'. 
    497      $fields->getEntries(). 
    498345     '<p><label for="new_auth_id" class="classic">'.__('Author ID:').'</label> '. 
    499346     form::field('new_auth_id',20,255); 
    500347      
    501348     echo 
    502      $fields->getHidden(). 
     349     $hidden_fields. 
    503350     $core->formNonce(). 
    504351     form::hidden(array('action'),'author'). 
  • plugins/tags/_admin.php

    r1471 r1454  
    229229          if ($action == 'tags') 
    230230          { 
    231                echo dcPage::breadcrumb( 
    232                     array( 
    233                          html::escapeHTML($core->blog->name) => '', 
    234                          __('Entries') => 'posts.php', 
    235                          '<span class="page-title">'.__('Add tags to entries').'</span>' => '' 
    236                )). 
     231               echo 
     232               '<h2 class="page-title">'.__('Add tags to entries').'</h2>'. 
    237233               '<form action="'.$form_uri.'" method="post">'. 
    238                $hidden_fields->getEntries(). 
    239234               '<div><label for="new_tags" class="area">'.__('Tags to add:').'</label> '. 
    240235               form::textarea('new_tags',60,3). 
    241236               '</div>'. 
    242                $hidden_fields->getHidden(). 
     237               $hidden_fields. 
    243238               $core->formNonce(). 
    244239               form::hidden(array('action'),'tags'). 
     
    264259                    } 
    265260               } 
    266                echo dcPage::breadcrumb( 
    267                     array( 
    268                          html::escapeHTML($core->blog->name) => '', 
    269                          __('Entries') => 'posts.php', 
    270                          '<span class="page-title">'.__('Remove selected tags from entries').'</span>' => '' 
    271                )); 
     261                
     262               echo '<h2 class="page-title">'.__('Remove selected tags from entries').'</h2>'; 
    272263                
    273264               if (empty($tags)) { 
Note: See TracChangeset for help on using the changeset viewer.

Sites map