Dotclear

Changeset 2072:783d0619e389


Ignore:
Timestamp:
09/24/13 21:01:48 (11 years ago)
Author:
Dsls
Branch:
default
Message:

Handled in-plugin / out-plugin action pages display (dcPage.open vs direct html), tag_posts.php now works with new actions.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • admin/posts.php

    r2048 r2072  
    106106$posts_actions_page = new dcPostsActionsPage($core,'posts.php'); 
    107107 
    108 if (!$posts_actions_page->process()) { 
    109  
    110      /* Get posts 
    111      -------------------------------------------------------- */ 
    112      $user_id = !empty($_GET['user_id']) ?   $_GET['user_id'] : ''; 
    113      $cat_id = !empty($_GET['cat_id']) ?     $_GET['cat_id'] : ''; 
    114      $status = isset($_GET['status']) ? $_GET['status'] : ''; 
    115      $selected = isset($_GET['selected']) ?  $_GET['selected'] : ''; 
    116      $month = !empty($_GET['month']) ?       $_GET['month'] : ''; 
    117      $lang = !empty($_GET['lang']) ?         $_GET['lang'] : ''; 
    118      $sortby = !empty($_GET['sortby']) ?     $_GET['sortby'] : 'post_dt'; 
    119      $order = !empty($_GET['order']) ?       $_GET['order'] : 'desc'; 
    120  
    121      $show_filters = false; 
    122  
    123      $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; 
    124      $nb_per_page =  30; 
    125  
    126      if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { 
    127           if ($nb_per_page != $_GET['nb']) { 
    128                $show_filters = true; 
    129           } 
    130           $nb_per_page = (integer) $_GET['nb']; 
    131      } 
    132  
    133      $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); 
    134      $params['no_content'] = true; 
    135  
    136      # - User filter 
    137      if ($user_id !== '' && in_array($user_id,$users_combo)) { 
    138           $params['user_id'] = $user_id; 
     108if ($posts_actions_page->process()) { 
     109     return; 
     110} 
     111 
     112/* Get posts 
     113-------------------------------------------------------- */ 
     114$user_id = !empty($_GET['user_id']) ?   $_GET['user_id'] : ''; 
     115$cat_id = !empty($_GET['cat_id']) ?     $_GET['cat_id'] : ''; 
     116$status = isset($_GET['status']) ? $_GET['status'] : ''; 
     117$selected = isset($_GET['selected']) ?  $_GET['selected'] : ''; 
     118$month = !empty($_GET['month']) ?       $_GET['month'] : ''; 
     119$lang = !empty($_GET['lang']) ?         $_GET['lang'] : ''; 
     120$sortby = !empty($_GET['sortby']) ?     $_GET['sortby'] : 'post_dt'; 
     121$order = !empty($_GET['order']) ?       $_GET['order'] : 'desc'; 
     122 
     123$show_filters = false; 
     124 
     125$page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; 
     126$nb_per_page =  30; 
     127 
     128if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { 
     129     if ($nb_per_page != $_GET['nb']) { 
    139130          $show_filters = true; 
     131     } 
     132     $nb_per_page = (integer) $_GET['nb']; 
     133} 
     134 
     135$params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); 
     136$params['no_content'] = true; 
     137 
     138# - User filter 
     139if ($user_id !== '' && in_array($user_id,$users_combo)) { 
     140     $params['user_id'] = $user_id; 
     141     $show_filters = true; 
     142} else { 
     143     $user_id=''; 
     144} 
     145 
     146# - Categories filter 
     147if ($cat_id !== '' && isset($categories_values[$cat_id])) { 
     148     $params['cat_id'] = $cat_id; 
     149     $show_filters = true; 
     150} else { 
     151     $cat_id=''; 
     152} 
     153 
     154# - Status filter 
     155if ($status !== '' && in_array($status,$status_combo)) { 
     156     $params['post_status'] = $status; 
     157     $show_filters = true; 
     158} else { 
     159     $status=''; 
     160} 
     161 
     162# - Selected filter 
     163if ($selected !== '' && in_array($selected,$selected_combo)) { 
     164     $params['post_selected'] = $selected; 
     165     $show_filters = true; 
     166} else { 
     167     $selected=''; 
     168} 
     169 
     170# - Month filter 
     171if ($month !== '' && in_array($month,$dt_m_combo)) { 
     172     $params['post_month'] = substr($month,4,2); 
     173     $params['post_year'] = substr($month,0,4); 
     174     $show_filters = true; 
     175} else { 
     176     $month=''; 
     177} 
     178 
     179# - Lang filter 
     180if ($lang !== '' && in_array($lang,$lang_combo)) { 
     181     $params['post_lang'] = $lang; 
     182     $show_filters = true; 
     183} else { 
     184     $lang=''; 
     185} 
     186 
     187# - Sortby and order filter 
     188if ($sortby !== '' && in_array($sortby,$sortby_combo)) { 
     189     if ($order !== '' && in_array($order,$order_combo)) { 
     190          $params['order'] = $sortby.' '.$order; 
    140191     } else { 
    141           $user_id=''; 
    142      } 
    143  
    144      # - Categories filter 
    145      if ($cat_id !== '' && isset($categories_values[$cat_id])) { 
    146           $params['cat_id'] = $cat_id; 
     192          $order='desc'; 
     193     } 
     194      
     195     if ($sortby != 'post_dt' || $order != 'desc') { 
    147196          $show_filters = true; 
    148      } else { 
    149           $cat_id=''; 
    150      } 
    151  
    152      # - Status filter 
    153      if ($status !== '' && in_array($status,$status_combo)) { 
    154           $params['post_status'] = $status; 
    155           $show_filters = true; 
    156      } else { 
    157           $status=''; 
    158      } 
    159  
    160      # - Selected filter 
    161      if ($selected !== '' && in_array($selected,$selected_combo)) { 
    162           $params['post_selected'] = $selected; 
    163           $show_filters = true; 
    164      } else { 
    165           $selected=''; 
    166      } 
    167  
    168      # - Month filter 
    169      if ($month !== '' && in_array($month,$dt_m_combo)) { 
    170           $params['post_month'] = substr($month,4,2); 
    171           $params['post_year'] = substr($month,0,4); 
    172           $show_filters = true; 
    173      } else { 
    174           $month=''; 
    175      } 
    176  
    177      # - Lang filter 
    178      if ($lang !== '' && in_array($lang,$lang_combo)) { 
    179           $params['post_lang'] = $lang; 
    180           $show_filters = true; 
    181      } else { 
    182           $lang=''; 
    183      } 
    184  
    185      # - Sortby and order filter 
    186      if ($sortby !== '' && in_array($sortby,$sortby_combo)) { 
    187           if ($order !== '' && in_array($order,$order_combo)) { 
    188                $params['order'] = $sortby.' '.$order; 
    189           } else { 
    190                $order='desc'; 
    191           } 
    192            
    193           if ($sortby != 'post_dt' || $order != 'desc') { 
    194                $show_filters = true; 
    195           } 
    196      } else { 
    197           $sortby='post_dt'; 
    198           $order='desc'; 
    199      } 
    200  
    201      # Get posts 
    202      try { 
    203           $posts = $core->blog->getPosts($params); 
    204           $counter = $core->blog->getPosts($params,true); 
    205           $post_list = new adminPostList($core,$posts,$counter->f(0)); 
    206      } catch (Exception $e) { 
    207           $core->error->add($e->getMessage()); 
    208      } 
    209  
    210      /* DISPLAY 
    211      -------------------------------------------------------- */ 
    212      $starting_script = dcPage::jsLoad('js/_posts_list.js'); 
     197     } 
     198} else { 
     199     $sortby='post_dt'; 
     200     $order='desc'; 
     201} 
     202 
     203# Get posts 
     204try { 
     205     $posts = $core->blog->getPosts($params); 
     206     $counter = $core->blog->getPosts($params,true); 
     207     $post_list = new adminPostList($core,$posts,$counter->f(0)); 
     208} catch (Exception $e) { 
     209     $core->error->add($e->getMessage()); 
     210} 
     211 
     212/* DISPLAY 
     213-------------------------------------------------------- */ 
     214$starting_script = dcPage::jsLoad('js/_posts_list.js'); 
     215if (!$show_filters) { 
     216     $starting_script .= dcPage::jsLoad('js/filter-controls.js'); 
     217} 
     218 
     219dcPage::open(__('Entries'),$starting_script, 
     220     dcPage::breadcrumb( 
     221          array( 
     222               html::escapeHTML($core->blog->name) => '', 
     223               '<span class="page-title">'.__('Entries').'</span>' => '' 
     224          )) 
     225); 
     226if (!empty($_GET['upd'])) { 
     227     dcPage::success(__('Selected entries have been successfully updated.')); 
     228} elseif (!empty($_GET['del'])) { 
     229     dcPage::success(__('Selected entries have been successfully deleted.')); 
     230} 
     231if (!$core->error->flag()) 
     232{ 
     233     echo 
     234     '<p class="top-add"><a class="button add" href="post.php">'.__('New entry').'</a></p>'; 
     235      
    213236     if (!$show_filters) { 
    214           $starting_script .= dcPage::jsLoad('js/filter-controls.js'); 
    215      } 
    216  
    217      dcPage::open(__('Entries'),$starting_script, 
    218           dcPage::breadcrumb( 
    219                array( 
    220                     html::escapeHTML($core->blog->name) => '', 
    221                     '<span class="page-title">'.__('Entries').'</span>' => '' 
    222                )) 
    223      ); 
    224      if (!empty($_GET['upd'])) { 
    225           dcPage::success(__('Selected entries have been successfully updated.')); 
    226      } elseif (!empty($_GET['del'])) { 
    227           dcPage::success(__('Selected entries have been successfully deleted.')); 
    228      } 
    229      if (!$core->error->flag()) 
    230      { 
    231           echo 
    232           '<p class="top-add"><a class="button add" href="post.php">'.__('New entry').'</a></p>'; 
    233            
    234           if (!$show_filters) { 
    235                echo '<p><a id="filter-control" class="form-control" href="#">'. 
    236                __('Filter posts list').'</a></p>'; 
    237           } 
    238            
    239           echo 
    240           '<form action="posts.php" method="get" id="filters-form">'. 
    241           '<h3 class="hidden">'.__('Filter posts list').'</h3>'. 
    242  
    243           '<div class="table">'. 
    244           '<div class="cell">'. 
    245           '<h4>'.__('Filters').'</h4>'. 
    246           '<p><label for="user_id" class="ib">'.__('Author:').'</label> '. 
    247           form::combo('user_id',$users_combo,$user_id).'</p>'. 
    248           '<p><label for="cat_id" class="ib">'.__('Category:').'</label> '. 
    249           form::combo('cat_id',$categories_combo,$cat_id).'</p>'. 
    250           '<p><label for="status" class="ib">'.__('Status:').'</label> ' . 
    251           form::combo('status',$status_combo,$status).'</p> '. 
    252           '</div>'. 
    253            
    254           '<div class="cell filters-sibling-cell">'. 
    255           '<p><label for="selected" class="ib">'.__('Selected:').'</label> '. 
    256           form::combo('selected',$selected_combo,$selected).'</p>'. 
    257           '<p><label for="month" class="ib">'.__('Month:').'</label> '. 
    258           form::combo('month',$dt_m_combo,$month).'</p>'. 
    259           '<p><label for="lang" class="ib">'.__('Lang:').'</label> '. 
    260           form::combo('lang',$lang_combo,$lang).'</p> '. 
    261           '</div>'. 
    262            
    263           '<div class="cell filters-options">'. 
    264           '<h4>'.__('Display options').'</h4>'. 
    265           '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. 
    266           form::combo('sortby',$sortby_combo,$sortby).'</p>'. 
    267           '<p><label for="order" class="ib">'.__('Sort:').'</label> '. 
    268           form::combo('order',$order_combo,$order).'</p>'. 
    269           '<p><span class="label ib">'.__('Show').'</span> <label for="nb" class="classic">'. 
    270           form::field('nb',3,3,$nb_per_page).' '. 
    271           __('entries per page').'</label></p>'. 
    272           '</div>'. 
    273           '</div>'. 
    274  
    275           '<p><input type="submit" value="'.__('Apply filters and display options').'" />'. 
    276           '<br class="clear" /></p>'. //Opera sucks 
    277           '</form>'; 
    278            
    279           # Show posts 
    280           $post_list->display($page,$nb_per_page, 
    281           '<form action="posts.php" method="post" id="form-entries">'. 
    282            
    283           '%s'. 
    284            
    285           '<div class="two-cols">'. 
    286           '<p class="col checkboxes-helpers"></p>'. 
    287            
    288           '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '. 
    289           form::combo('action',$posts_actions_page->getCombo()). 
    290           '<input type="submit" value="'.__('ok').'" /></p>'. 
    291           form::hidden(array('user_id'),$user_id). 
    292           form::hidden(array('cat_id'),$cat_id). 
    293           form::hidden(array('status'),$status). 
    294           form::hidden(array('selected'),$selected). 
    295           form::hidden(array('month'),$month). 
    296           form::hidden(array('lang'),$lang). 
    297           form::hidden(array('sortby'),$sortby). 
    298           form::hidden(array('order'),$order). 
    299           form::hidden(array('page'),$page). 
    300           form::hidden(array('nb'),$nb_per_page). 
    301           $core->formNonce(). 
    302           '</div>'. 
    303           '</form>' 
    304           ); 
    305      } 
    306  
    307      dcPage::helpBlock('core_posts'); 
    308      dcPage::close(); 
    309 } 
     237          echo '<p><a id="filter-control" class="form-control" href="#">'. 
     238          __('Filter posts list').'</a></p>'; 
     239     } 
     240      
     241     echo 
     242     '<form action="posts.php" method="get" id="filters-form">'. 
     243     '<h3 class="hidden">'.__('Filter posts list').'</h3>'. 
     244 
     245     '<div class="table">'. 
     246     '<div class="cell">'. 
     247     '<h4>'.__('Filters').'</h4>'. 
     248     '<p><label for="user_id" class="ib">'.__('Author:').'</label> '. 
     249     form::combo('user_id',$users_combo,$user_id).'</p>'. 
     250     '<p><label for="cat_id" class="ib">'.__('Category:').'</label> '. 
     251     form::combo('cat_id',$categories_combo,$cat_id).'</p>'. 
     252     '<p><label for="status" class="ib">'.__('Status:').'</label> ' . 
     253     form::combo('status',$status_combo,$status).'</p> '. 
     254     '</div>'. 
     255      
     256     '<div class="cell filters-sibling-cell">'. 
     257     '<p><label for="selected" class="ib">'.__('Selected:').'</label> '. 
     258     form::combo('selected',$selected_combo,$selected).'</p>'. 
     259     '<p><label for="month" class="ib">'.__('Month:').'</label> '. 
     260     form::combo('month',$dt_m_combo,$month).'</p>'. 
     261     '<p><label for="lang" class="ib">'.__('Lang:').'</label> '. 
     262     form::combo('lang',$lang_combo,$lang).'</p> '. 
     263     '</div>'. 
     264      
     265     '<div class="cell filters-options">'. 
     266     '<h4>'.__('Display options').'</h4>'. 
     267     '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. 
     268     form::combo('sortby',$sortby_combo,$sortby).'</p>'. 
     269     '<p><label for="order" class="ib">'.__('Sort:').'</label> '. 
     270     form::combo('order',$order_combo,$order).'</p>'. 
     271     '<p><span class="label ib">'.__('Show').'</span> <label for="nb" class="classic">'. 
     272     form::field('nb',3,3,$nb_per_page).' '. 
     273     __('entries per page').'</label></p>'. 
     274     '</div>'. 
     275     '</div>'. 
     276 
     277     '<p><input type="submit" value="'.__('Apply filters and display options').'" />'. 
     278     '<br class="clear" /></p>'. //Opera sucks 
     279     '</form>'; 
     280      
     281     # Show posts 
     282     $post_list->display($page,$nb_per_page, 
     283     '<form action="posts.php" method="post" id="form-entries">'. 
     284      
     285     '%s'. 
     286      
     287     '<div class="two-cols">'. 
     288     '<p class="col checkboxes-helpers"></p>'. 
     289      
     290     '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '. 
     291     form::combo('action',$posts_actions_page->getCombo()). 
     292     '<input type="submit" value="'.__('ok').'" /></p>'. 
     293     form::hidden(array('user_id'),$user_id). 
     294     form::hidden(array('cat_id'),$cat_id). 
     295     form::hidden(array('status'),$status). 
     296     form::hidden(array('selected'),$selected). 
     297     form::hidden(array('month'),$month). 
     298     form::hidden(array('lang'),$lang). 
     299     form::hidden(array('sortby'),$sortby). 
     300     form::hidden(array('order'),$order). 
     301     form::hidden(array('page'),$page). 
     302     form::hidden(array('nb'),$nb_per_page). 
     303     $core->formNonce(). 
     304     '</div>'. 
     305     '</form>' 
     306     ); 
     307} 
     308 
     309dcPage::helpBlock('core_posts'); 
     310dcPage::close(); 
     311 
    310312?> 
  • inc/admin/actions/class.dcaction.php

    r2063 r2072  
    4949     /** @var string title for caller page title */ 
    5050     protected $caller_title; 
    51       
     51 
     52     /** @var boolean true if we are acting inside a plugin (different handling of begin/endpage) */ 
     53     protected $in_plugin;     
     54 
    5255    /** 
    5356     * Class constructor 
     
    7982               $this->redir_anchor=''; 
    8083          } 
     84          $u=explode('?',$_SERVER['REQUEST_URI']); 
     85          $this->in_plugin = (strpos($u[0],'plugin.php') !== false); 
    8186     } 
    8287      
  • inc/admin/actions/class.dcactioncomments.php

    r2071 r2072  
    3131      
    3232     public function beginPage($breadcrumb='',$head='') { 
    33           dcPage::open( 
    34                __('Comments'), 
    35                 
    36                dcPage::jsLoad('js/_comments_actions.js'). 
    37                $head, 
    38                $breadcrumb 
    39           );    
     33          if ($this->in_plugin) { 
     34               echo '<html><head><title>'.__('Comments').'</title>'. 
     35                    dcPage::jsLoad('js/_comments_actions.js'). 
     36                    $head. 
     37                    '</script></head><body>'. 
     38                    $breadcrumb; 
     39          } else { 
     40               dcPage::open( 
     41                    __('Comments'), 
     42                    dcPage::jsLoad('js/_comments_actions.js'). 
     43                    $head, 
     44                    $breadcrumb 
     45               );    
     46 
     47          } 
    4048          echo '<p><a class="back" href="'.$this->getRedirection(array(),true).'">'.__('Back to comments list').'</a></p>'; 
    4149     } 
  • inc/admin/actions/class.dcactionposts.php

    r2059 r2072  
    3030      
    3131     public function beginPage($breadcrumb='',$head='') { 
    32           dcPage::open( 
    33                __('Entries'), 
    34                 
    35                dcPage::jsLoad('js/_posts_actions.js'). 
    36                $head, 
    37                $breadcrumb 
    38           );    
     32          if ($this->in_plugin) { 
     33               echo '<html><head><title>'.__('Entries').'</title>'. 
     34                    dcPage::jsLoad('js/_posts_actions.js'). 
     35                    $head. 
     36                    '</script></head><body>'. 
     37                    $breadcrumb; 
     38          } else { 
     39               dcPage::open( 
     40                    __('Entries'), 
     41                    dcPage::jsLoad('js/_posts_actions.js'). 
     42                    $head, 
     43                    $breadcrumb 
     44               ); 
     45          } 
    3946          echo '<p><a class="back" href="'.$this->getRedirection(array(),true).'">'.__('Back to entries list').'</a></p>'; 
    4047     } 
    4148      
    4249     public function endPage() { 
    43           dcPage::close(); 
     50          if ($this->in_plugin) { 
     51               echo '</body></html>'; 
     52          } else { 
     53               dcPage::close(); 
     54          } 
    4455     } 
    4556      
  • plugins/tags/tag_posts.php

    r1912 r2072  
    6161} 
    6262 
    63 # Actions combo box 
    64 $combo_action = array(); 
    65 if ($core->auth->check('publish,contentadmin',$core->blog->id)) 
    66 { 
    67      $combo_action[__('Status')] = array( 
    68           __('Publish') => 'publish', 
    69           __('Unpublish') => 'unpublish', 
    70           __('Schedule') => 'schedule', 
    71           __('Mark as pending') => 'pending' 
    72      ); 
     63$posts_actions_page = new dcPostsActionsPage($core,'plugin.php',array('p'=>'tags', 'm'=>'tag_posts', 'tag'=> $tag)); 
     64 
     65if ($posts_actions_page->process()) { 
     66     return; 
    7367} 
    74 $combo_action[__('Mark')] = array( 
    75      __('Mark as selected') => 'selected', 
    76      __('Mark as unselected') => 'unselected' 
    77 ); 
    78 $combo_action[__('Change')] = array(__('Change category') => 'category'); 
    79 if ($core->auth->check('admin',$core->blog->id)) 
    80 { 
    81      $combo_action[__('Change')] = array_merge($combo_action[__('Change')], 
    82           array(__('Change author') => 'author')); 
    83 } 
    84 if ($core->auth->check('delete,contentadmin',$core->blog->id)) 
    85 { 
    86      $combo_action[__('Delete')] = array(__('Delete') => 'delete'); 
    87 } 
    88  
    89 # --BEHAVIOR-- adminPostsActionsCombo 
    90 $core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); 
    9168 
    9269?> 
     
    153130     echo '<h3>'.sprintf(__('List of entries with the tag “%s”'),html::escapeHTML($tag)).'</h3>'; 
    154131     $post_list->display($page,$nb_per_page, 
    155      '<form action="posts_actions.php" method="post" id="form-entries">'. 
     132     '<form action="plugin.php" method="post" id="form-entries">'. 
    156133      
    157134     '%s'. 
     
    161138      
    162139     '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '. 
    163      form::combo('action',$combo_action). 
     140     form::combo('action',$posts_actions_page->getCombo()). 
    164141     '<input type="submit" value="'.__('OK').'" /></p>'. 
    165142     form::hidden('post_type',''). 
    166      form::hidden('redir',$p_url.'&amp;m=tag_posts&amp;tag='. 
    167           str_replace('%','%%',rawurlencode($tag)).'&amp;page='.$page). 
     143     form::hidden('p','tags'). 
     144     form::hidden('m','tag_posts'). 
     145     form::hidden('tag',$tag). 
    168146     $core->formNonce(). 
    169147     '</div>'. 
Note: See TracChangeset for help on using the changeset viewer.

Sites map