Dotclear

Changeset 1806:6a0391e85f73


Ignore:
Timestamp:
09/13/13 11:38:14 (11 years ago)
Author:
Dsls
Branch:
actionsreloaded
Message:
  • Documented code is so much simple to understand
  • Simplified actions classes, renamed ActionSet? to ActionsPage?
  • Introduced dcLegacy plugin
  • Fixed several handling bugs
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_posts_actions.js

    r1638 r1806  
    11$(function() { 
    2      $('#new_auth_id').autocomplete(usersList, 
    3      { 
    4           delay: 1000, 
    5           matchSubset: true, 
    6           matchContains: true 
    7      }); 
     2     new_auth_id = $('#new_auth_id'); 
     3     if (new_auth_id.length) { 
     4          new_auth_id.autocomplete(usersList, 
     5          { 
     6               delay: 1000, 
     7               matchSubset: true, 
     8               matchContains: true 
     9          }); 
     10     } 
    811     $('#new_cat').toggleWithLegend($('#new_cat').parent().children().not('#new_cat'), { 
    912          // no cookie on new category as we don't use this every day 
  • admin/posts.php

    r1796 r1806  
    104104# Actions combo box 
    105105 
    106 $posts_actionset = new dcPostsActionSet($core,'posts.php'); 
    107  
    108 $posts_actionset->process(); 
     106$posts_actions_page = new dcPostsActionsPage($core,'posts.php'); 
     107 
     108$posts_actions_page->process(); 
    109109 
    110110/* Get posts 
     
    287287      
    288288     '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '. 
    289      form::combo('action',$posts_actionset->getCombo()). 
     289     form::combo('action',$posts_actions_page->getCombo()). 
    290290     '<input type="submit" value="'.__('ok').'" /></p>'. 
    291291     form::hidden(array('user_id'),$user_id). 
  • admin/posts_actions.php

    r1796 r1806  
    1818dcPage::check('usage,contentadmin'); 
    1919 
    20 $posts_actionset = new dcPostsActionSet($core,'posts.php'); 
     20$posts_actions_page = new dcPostsActionsPage($core,'posts.php'); 
    2121 
    22 $posts_actionset->process(); 
     22$posts_actions_page->process(); 
    2323 
    2424?> 
  • inc/admin/actions/class.dcaction.php

    r1796 r1806  
    1212if (!defined('DC_RC_PATH')) { return; } 
    1313 
    14 abstract class dcAction { 
    15      protected $actionset; 
    16            
    17      public function setActionSet($as) { 
    18           $this->actionset = $as; 
    19      } 
    20      abstract public function onAction($post,$actionset,$post); 
    21 } 
    22  
    23 class dcSimpleAction extends dcAction { 
    24      protected $callback; 
    25       
    26      public function __construct($callback) { 
    27           $this->callback = $callback; 
    28      } 
    29       
    30      public function onAction($core,$actionset,$post) { 
    31           return call_user_func($this->callback,$core,$actionset,$post); 
    32      } 
    33 } 
    34  
    35 class dcActionSet 
     14/** 
     15* dcActionsPage -- handler for action page on selected entries 
     16* 
     17*/ 
     18abstract class dcActionsPage 
    3619{ 
     20     /** @var string form submit uri */ 
    3721     protected $uri; 
     22     /** @var dcCore dotclear core instance */ 
    3823     protected $core; 
     24     /** @var array action combo box */ 
    3925     protected $combo; 
     26     /** @var array list of defined actions (callbacks) */ 
    4027     protected $actions; 
    41      protected $ids; 
     28     /** @var array selected entries (each key is the entry id, value contains the entry description) */ 
     29     protected $entries; 
     30     /** @var record record that challenges ids against permissions */ 
    4231     protected $rs; 
     32     /** @var array redirection $_GET arguments, if any (does not contain ids by default, ids may be merged to it) */ 
    4333     protected $redir_args; 
     34     /** @var array list of $_POST fields used to build the redirection  */ 
    4435     protected $redirect_fields; 
     36     /** @var string current action, if any */ 
    4537     protected $action; 
    4638      
     39     /** @var string title for checkboxes list, if displayed */ 
     40     protected $cb_title; 
     41      
     42    /** 
     43     * Class constructor 
     44     *  
     45     * @param mixed  $core   dotclear core 
     46     * @param mixed  $uri   form uri 
     47     * 
     48     * @access public 
     49     * 
     50     * @return mixed Value. 
     51     */ 
    4752     public function __construct($core,$uri) { 
    4853          $this->core = $core; 
     
    5358          $this->redirect_fields = array(); 
    5459          $this->action = ''; 
    55      } 
    56       
     60          $this->cb_title = __('Title'); 
     61     } 
     62      
     63    /** 
     64     * addAction - adds an action 
     65     * 
     66     * @param string $actions the actions names as if it was a standalone combo array. 
     67      *                              It will be merged with other actions. 
     68      *                              Can be bound to multiple values, if the same callback is to be called 
     69     * @param callback $callback the callback for the action. 
     70     * 
     71     * @access public 
     72      * 
     73     * @return dcActionsPage the actions page itself, enabling to chain addAction(). 
     74     */ 
    5775     public function addAction ($actions,$callback) { 
    58           if (is_array($callback)) { 
    59                $callback = new dcSimpleAction($callback); 
    60           } 
    6176          foreach ($actions as $k => $a) { 
     77               // Check each case of combo definition 
     78               // Store form values in $values 
    6279               if (is_array($a)) { 
    6380                    $values = array_values($a); 
     
    7390                    $this->combo[$k] = $a; 
    7491               } 
     92               // Associate each potential value to the callback 
    7593               foreach ($values as $v) { 
    7694                    $this->actions[$v]=$callback; 
    7795               } 
    7896          } 
    79           $callback->setActionSet($this); 
    80      } 
    81       
     97          return $this; 
     98     } 
     99      
     100    /** 
     101     * getCombo - returns the actions combo, useable through form::combo 
     102     * 
     103     * @access public 
     104      * 
     105     * @return array the actions combo 
     106     */ 
    82107     public function getCombo() { 
    83108          return $this->combo; 
    84109     } 
    85110      
     111      
     112    /** 
     113     * getIDS() - returns the list of selected entries 
     114     * 
     115     * @access public 
     116      * 
     117     * @return array the list 
     118     */ 
    86119     public function getIDs() { 
    87           return $this->ids; 
    88      } 
    89      public function getIDsHidden() { 
     120          return array_keys($this->entries); 
     121     } 
     122      
     123    /** 
     124     * getIDS() - returns the list of selected entries as HTML hidden fields string 
     125     * 
     126     * @access public 
     127      * 
     128     * @return string the HTML code for hidden fields 
     129     */ 
     130      public function getIDsHidden() { 
    90131          $ret = ''; 
    91           foreach  ($this->ids as $id) { 
     132          foreach  ($this->entries as $id->$v) { 
    92133               $ret .= form::hidden('entries[]',$id); 
    93134          } 
    94135          return $ret; 
    95136     } 
     137      
     138    /** 
     139     * getHiddenFields() - returns all redirection parameters as HTML hidden fields 
     140     * 
     141     * @param boolean $with_ids if true, also include ids in HTML code 
     142      * 
     143     * @access public 
     144      * 
     145     * @return string the HTML code for hidden fields 
     146     */    
    96147     public function getHiddenFields($with_ids = false) { 
    97148          $ret = ''; 
     
    104155          return $ret; 
    105156     } 
     157      
     158      
     159     /** 
     160     * getRS() - get record from DB Query containing requested IDs 
     161     * 
     162     * @param boolean $with_ids if true, also include ids in HTML code 
     163      * 
     164     * @access public 
     165      * 
     166     * @return string the HTML code for hidden fields 
     167     */ 
    106168     public function getRS() { 
    107169          return $this->rs; 
    108170     } 
    109171      
    110      public function setupRedir($from) { 
     172     /** 
     173     * setupRedir - setup redirection arguments 
     174      *  by default, $_POST fields as defined in redirect_fields attributes 
     175      *  are set into redirect_args. 
     176     * 
     177     * @param array $from input to parse fields from (usually $_POST) 
     178      * 
     179     * @access protected 
     180     */ 
     181     protected function setupRedir($from) { 
    111182          foreach ($this->redirect_fields as $p) { 
    112183               if (isset($from[$p])) { 
     
    115186          } 
    116187     } 
     188 
     189     /** 
     190     * getRedirection - returns redirection URL 
     191     * 
     192     * @param array $params extra parameters to append to redirection 
     193      *                            must be an array : each key is the name,  
     194      *                            each value is the wanted value 
     195     * @param boolean $with_selected_entries if true, add selected entries in url 
     196      * 
     197     * @access public 
     198      * 
     199     * @return string the redirection url 
     200     */ 
    117201     public function getRedirection($params=array(),$with_selected_entries=false) { 
    118202          $redir_args = array_merge($params,$this->redir_args); 
    119203          if ($with_selected_entries) { 
    120                $redir_args['entries'] = $this->ids; 
     204               $redir_args['entries'] = array_keys($this->entries); 
    121205          } 
    122206          return $this->uri.'?'.http_build_query($redir_args); 
    123207     } 
    124208 
     209     /** 
     210     * redirect - redirects to redirection page 
     211     * 
     212      * @see getRedirection for arguments details 
     213      * 
     214     * @access public 
     215     */ 
    125216     public function redirect($params=array(),$with_selected_entries=false) { 
    126217          http::redirect($this->getRedirection($params,$with_selected_entries)); 
    127218     }     
    128219      
    129      public function beginPage($head='') { 
    130      } 
    131       
    132      public function endPage() { 
    133      } 
     220     /** 
     221     * getAction - returns current action, if any 
     222     * 
     223      * @see getRedirection for arguments details 
     224      * 
     225     * @access public 
     226      * 
     227     * @return string the action 
     228     */ 
    134229     public function getAction() { 
    135230          return $this->action; 
    136231     } 
     232 
     233     /** 
     234     * process - proceeds action handling, if any 
     235      *             this method may issue an exit() if 
     236      *             an action is being processed. If it 
     237      *             returns, no action has been performed 
     238     * 
     239     * @access public 
     240     */ 
    137241     public function process() { 
    138242          $from = new ArrayObject($_POST); 
    139           if (isset($from['redir']) && strpos($from['redir'],'://') === false) { 
    140                $this->redir = html::escapeURL($_POST['redir']); 
    141           } else { 
    142                $this->setupRedir($from); 
    143           } 
     243          $this->setupRedir($from); 
    144244          $this->fetchEntries($from);    
    145245          if (isset($from['action'])) { 
     
    150250                         if ($from['action']==$k) { 
    151251                              $performed = true; 
    152                               $v->onAction($this->core,$this,$from); 
     252                              call_user_func($v,$this->core,$this,$from); 
    153253                         } 
    154254                    } 
     
    161261          } 
    162262     } 
    163       
     263 
     264     /** 
     265     * getcheckboxes -returns html code for selected entries 
     266      *             as a table containing entries checkboxes 
     267     * 
     268     * @access public 
     269      * 
     270     * @return string the html code for checkboxes 
     271     */ 
     272     public function getCheckboxes() { 
     273          $ret =  
     274               '<table class="posts-list"><tr>'. 
     275               '<th colspan="2">'.$this->cb_title.'</th>'. 
     276               '</tr>'; 
     277          foreach ($this->entries as $id=>$title) { 
     278               $ret .=  
     279                    '<tr><td>'. 
     280                    form::checkbox(array('entries[]'),$id,true,'','').'</td>'. 
     281                    '<td>'.   $title.'</td></tr>'; 
     282          } 
     283          $ret .= '</table>'; 
     284          return $ret; 
     285     } 
     286      
     287     /** 
     288     * beginPage, endPage - displays the beginning/ending of a page, if action does not redirects dirtectly 
     289     * 
     290      * These methods are called from the actions themselves. 
     291      * 
     292     * @param string $breadcrumb breadcrumb to display 
     293     * @param string $head    page header to include 
     294      * 
     295     * @access public 
     296     */ 
     297     abstract public function beginPage($breadcrumb='',$head=''); 
     298     abstract public function endPage(); 
     299 
     300     /** 
     301     * fetchEntries - fills-in information by requesting into db 
     302      *   this method may setup the following attributes 
     303      *   * entries : list of entries (checked against permissions) 
     304      *      entries ids are array keys, values contain entry description (if relevant) 
     305     *   * rs : record given by db request 
     306     * @access protected 
     307     */ 
     308      abstract protected function fetchEntries($from); 
     309 
    164310} 
    165311 
  • inc/admin/actions/class.dcactionposts.php

    r1796 r1806  
    1212if (!defined('DC_RC_PATH')) { return; } 
    1313 
    14 $GLOBALS['core']->addBehavior('adminPostsActionSet',array('dcDefaultPostActions','adminPostsActionSet')); 
    15 $GLOBALS['core']->addBehavior('adminPostsActionSet',array('dcLegacyPosts','adminPostsActionSet')); 
    16  
    17 class dcPostsActionSet extends dcActionSet 
     14class dcPostsActionsPage extends dcActionsPage 
    1815{ 
    1916     public function __construct($core,$uri) { 
     
    2118          $this->redirect_fields = array('user_id','cat_id','status', 
    2219          'selected','month','lang','sortby','order','page','nb'); 
    23           $core->callBehavior('adminPostsActionSet',$core,$this); 
     20          // We could have added a behavior here, but we want default action 
     21          // to be setup first 
     22          dcDefaultPostActions::adminPostsActionsPage($core,$this); 
     23          $core->callBehavior('adminPostsActionsPage',$core,$this); 
    2424 
    2525     } 
     
    2828          dcPage::open( 
    2929               __('Entries'), 
    30                dcPage::jsLoad('js/jquery/jquery.autocomplete.js'). 
     30                
    3131               dcPage::jsLoad('js/_posts_actions.js'). 
    32                dcPage::jsMetaEditor(). 
    3332               $head, 
    3433               $breadcrumb 
     
    4241      
    4342     public function error(Exception $e) { 
    44           $this->core->erorr->add($e->getMessage()); 
     43          $this->core->error->add($e->getMessage()); 
    4544          $this->beginPage(dcPage::breadcrumb( 
    4645               array( 
    47                     html::escapeHTML($core->blog->name) => '', 
     46                    html::escapeHTML($this->core->blog->name) => '', 
    4847                    __('Entries') => 'posts.php', 
    4948                    '<span class="page-title">'.__('Entries actions').'</span>' => '' 
     
    5352     } 
    5453      
    55      public function getCheckboxes() { 
    56           $ret =  
    57                '<table class="posts-list"><tr>'. 
    58                '<th colspan="2">'.__('Title').'</th>'. 
    59                '</tr>'; 
    60           foreach ($this->entries as $id=>$title) { 
    61                $ret .=  
    62                     '<tr><td>'. 
    63                     form::checkbox(array('entries[]'),$id,true,'','').'</td>'. 
    64                     '<td>'.   $title.'</td></tr>'; 
    65           } 
    66           $ret .= '</table>'; 
    67           return $ret; 
    68      } 
    69       
    70       
    71      public function fetchEntries($from) { 
     54     protected function fetchEntries($from) { 
    7255          if (!empty($from['entries'])) 
    7356          { 
     
    9073               $posts = $this->core->blog->getPosts($params); 
    9174               while ($posts->fetch())  { 
    92                     $this->ids[] = $posts->post_id; 
    9375                    $this->entries[$posts->post_id] = $posts->post_title; 
    9476               } 
     
    10284class dcDefaultPostActions  
    10385{ 
    104      public static function adminPostsActionSet($core, dcPostsActionSet $as) { 
     86     public static function adminPostsActionsPage($core, dcPostsActionsPage $ap) { 
    10587          if ($core->auth->check('publish,contentadmin',$core->blog->id)) { 
    106                $as->addAction( 
     88               $ap->addAction( 
    10789                    array(__('Status') => array( 
    10890                         __('Publish') => 'publish', 
     
    11496               ); 
    11597          } 
    116           $as->addAction( 
     98          $ap->addAction( 
    11799               array(__('Mark')=> array( 
    118100                    __('Mark as selected') => 'selected', 
     
    121103               array('dcDefaultPostActions','doUpdateSelectedPost') 
    122104          ); 
    123           $as->addAction( 
     105          $ap->addAction( 
    124106               array(__('Change') => array( 
    125107                    __('Change category') => 'category', 
     
    127109               array('dcDefaultPostActions','doChangePostCategory') 
    128110          ); 
    129           $as->addAction( 
     111          $ap->addAction( 
    130112               array(__('Change') => array( 
    131113                    __('Change language') => 'lang', 
     
    135117          if ($core->auth->check('admin',$core->blog->id)) 
    136118          { 
    137                $as->addAction( 
     119               $ap->addAction( 
    138120                    array(__('Change') => array( 
    139121                         __('Change author') => 'author')), 
    140                     array('dcDefaultPostActions','doChangePostLang') 
     122                    array('dcDefaultPostActions','doChangePostAuthor') 
    141123               ); 
    142124          } 
    143125          if ($core->auth->check('delete,contentadmin',$core->blog->id)) { 
    144                $as->addAction( 
     126               $ap->addAction( 
    145127                    array(__('Delete') => array( 
    146128                         __('Delete') => 'delete')), 
     
    150132     } 
    151133 
    152      public static function doChangePostStatus($core, dcPostsActionSet $as, $post) { 
    153           switch ($as->getAction()) { 
     134     public static function doChangePostStatus($core, dcPostsActionsPage $ap, $post) { 
     135          switch ($ap->getAction()) { 
    154136               case 'unpublish' : $status = 0; break; 
    155137               case 'schedule' : $status = -1; break; 
     
    157139               default : $status = 1; break; 
    158140          } 
    159            
    160           try 
    161           { 
    162                $posts_ids = $as->getIDs(); 
    163                if (empty($posts_ids)) { 
    164                     throw new Exception(__('No entry selected')); 
    165                } 
    166                $core->blog->updPostsStatus($posts_ids,$status); 
    167                 
    168                $as->redirect(array('upd' => 1),true); 
    169           } 
    170           catch (Exception $e) 
    171           { 
    172                $core->error->add($e->getMessage()); 
    173           }          
    174      } 
    175       
    176      public static function doUpdateSelectedPost($core, dcPostsActionSet $as, $post) { 
    177           try 
    178           { 
    179                $posts_ids = $as->getIDs(); 
    180                if (empty($posts_ids)) { 
    181                     throw new Exception(__('No entry selected')); 
    182                } 
    183                 
    184                $core->blog->updPostsSelected($posts_ids,$action == 'selected'); 
    185                 
    186                $as->redirect(array('upd' => 1),true); 
    187           } 
    188           catch (Exception $e) 
    189           { 
    190                $core->error->add($e->getMessage()); 
    191           } 
    192      } 
    193       
    194      public static function doDeletePost($core, dcPostsActionSet $as, $post) { 
    195  
    196           $posts_ids = $as->getIDs(); 
     141          $posts_ids = $ap->getIDs(); 
     142          if (empty($posts_ids)) { 
     143               throw new Exception(__('No entry selected')); 
     144          } 
     145          $core->blog->updPostsStatus($posts_ids,$status); 
     146           
     147          $ap->redirect(array('upd' => 1),true); 
     148     } 
     149      
     150     public static function doUpdateSelectedPost($core, dcPostsActionsPage $ap, $post) { 
     151          $posts_ids = $ap->getIDs(); 
     152          if (empty($posts_ids)) { 
     153               throw new Exception(__('No entry selected')); 
     154          } 
     155          $action = $ap->getAction(); 
     156          $core->blog->updPostsSelected($posts_ids,$action == 'selected'); 
     157           
     158          $ap->redirect(array('upd' => 1),true); 
     159     } 
     160      
     161     public static function doDeletePost($core, dcPostsActionsPage $ap, $post) { 
     162 
     163          $posts_ids = $ap->getIDs(); 
    197164          if (empty($posts_ids)) { 
    198165               throw new Exception(__('No entry selected')); 
     
    210177          $core->blog->delPosts($posts_ids); 
    211178           
    212           $as->redirect(array('del',1),false); 
    213      } 
    214  
    215      public static function doChangePostCategory($core, dcPostsActionSet $as, $post) { 
     179          $ap->redirect(array('del',1),false); 
     180     } 
     181 
     182     public static function doChangePostCategory($core, dcPostsActionsPage $ap, $post) { 
    216183          if (isset($post['new_cat_id'])) { 
    217                $posts_ids = $as->getIDs(); 
     184               $posts_ids = $ap->getIDs(); 
    218185               if (empty($posts_ids)) { 
    219186                    throw new Exception(__('No entry selected')); 
     
    239206               $core->blog->updPostsCategory($posts_ids, $new_cat_id); 
    240207                
    241                $as->redirect(array('upd'=>1),true); 
     208               $ap->redirect(array('upd'=>1),true); 
    242209          } else { 
    243                $as->beginPage( 
     210               $ap->beginPage( 
    244211                    dcPage::breadcrumb( 
    245212                         array( 
     
    256223               echo 
    257224               '<form action="posts.php" method="post">'. 
    258                $as->getCheckboxes(). 
     225               $ap->getCheckboxes(). 
    259226               '<p><label for="new_cat_id" class="classic">'.__('Category:').'</label> '. 
    260227               form::combo('new_cat_id',$categories_combo,''); 
     
    277244               '<input type="submit" value="'.__('Save').'" /></p>'. 
    278245               '</form>'; 
    279                $as->endPage(); 
    280  
    281           } 
    282       
    283      } 
    284      public static function doChangePostAuthor($core, dcPostsActionSet $as, $post) { 
     246               $ap->endPage(); 
     247 
     248          } 
     249      
     250     } 
     251     public static function doChangePostAuthor($core, dcPostsActionsPage $ap, $post) { 
    285252          if (isset($post['new_auth_id']) && $core->auth->check('admin',$core->blog->id)) { 
    286253               $new_user_id = $post['new_auth_id']; 
    287                $posts_ids = $as->getIDs(); 
     254               $posts_ids = $ap->getIDs(); 
    288255               if (empty($posts_ids)) { 
    289256                    throw new Exception(__('No entry selected')); 
    290257               } 
    291                 
    292                try 
    293                { 
    294                     if ($core->getUser($new_user_id)->isEmpty()) { 
    295                          throw new Exception(__('This user does not exist')); 
    296                     } 
    297                      
    298                     $cur = $core->con->openCursor($core->prefix.'post'); 
    299                     $cur->user_id = $new_user_id; 
    300                     $cur->update('WHERE post_id '.$core->con->in($posts_ids)); 
    301                      
    302                     $as->redirect(array('upd' => 1),true); 
    303                } 
    304                catch (Exception $e) 
    305                { 
    306                     $core->error->add($e->getMessage()); 
    307                } 
     258               if ($core->getUser($new_user_id)->isEmpty()) { 
     259                    throw new Exception(__('This user does not exist')); 
     260               } 
     261                
     262               $cur = $core->con->openCursor($core->prefix.'post'); 
     263               $cur->user_id = $new_user_id; 
     264               $cur->update('WHERE post_id '.$core->con->in($posts_ids)); 
     265                
     266               $ap->redirect(array('upd' => 1),true); 
    308267          } else { 
    309268               $usersList = ''; 
     
    319278                    } 
    320279               } 
    321                $as->beginPage( 
     280               $ap->beginPage( 
    322281                    dcPage::breadcrumb( 
    323282                         array( 
    324283                              html::escapeHTML($core->blog->name) => '', 
    325284                              __('Entries') => 'posts.php', 
    326                               '<span class="page-title">'.__('Change author for entries').'</span>' => '' 
    327                     )), 
    328                     '<script type="text/javascript">'."\n". 
    329                     "//<![CDATA[\n". 
    330                     'usersList = ['.$usersList.']'."\n". 
    331                     "\n//]]>\n". 
    332                     "</script>\n" 
     285                              '<span class="page-title">'.__('Change author for entries').'</span>' => '')), 
     286                         dcPage::jsLoad('js/jquery/jquery.autocomplete.js'). 
     287                         '<script type="text/javascript">'."\n". 
     288                         "//<![CDATA[\n". 
     289                         'usersList = ['.$usersList.']'."\n". 
     290                         "\n//]]>\n". 
     291                         "</script>\n" 
    333292               ); 
    334293 
    335294               echo 
    336295               '<form action="posts_actions.php" method="post">'. 
    337                $as->getCheckboxes(). 
     296               $ap->getCheckboxes(). 
    338297               '<p><label for="new_auth_id" class="classic">'.__('New author (author ID):').'</label> '. 
    339298               form::field('new_auth_id',20,255); 
     
    344303                    '<input type="submit" value="'.__('Save').'" /></p>'. 
    345304                    '</form>'; 
    346                $as->endPage(); 
    347           } 
    348      } 
    349      public static function doChangePostLang($core, dcPostsActionSet $as, $post) { 
     305               $ap->endPage(); 
     306          } 
     307     } 
     308     public static function doChangePostLang($core, dcPostsActionsPage $ap, $post) { 
    350309          if (isset($post['new_lang'])) { 
    351310               $new_lang = $post['new_lang']; 
    352                try 
    353                { 
    354                     $cur = $core->con->openCursor($core->prefix.'post'); 
    355                     $cur->post_lang = $new_lang; 
    356                     $cur->update('WHERE post_id '.$core->con->in($posts_ids)); 
    357                      
    358                     $as->redirect(array('upd' => 1),true); 
    359                } 
    360                catch (Exception $e) 
    361                { 
    362                     $core->error->add($e->getMessages()); 
    363                } 
     311               $cur = $core->con->openCursor($core->prefix.'post'); 
     312               $cur->post_lang = $new_lang; 
     313               $cur->update('WHERE post_id '.$core->con->in($posts_ids)); 
     314                
     315               $ap->redirect(array('upd' => 1),true); 
    364316          } else { 
    365                $as->beginPage( 
     317               $ap->beginPage( 
    366318                    dcPage::breadcrumb( 
    367319                         array( 
     
    388340               echo 
    389341               '<form action="posts_actions.php" method="post">'. 
    390                $as->getCheckboxes(). 
     342               $ap->getCheckboxes(). 
    391343                
    392344               '<p><label for="new_lang" class="classic">'.__('Entry lang:').'</label> '. 
     
    401353     } 
    402354} 
    403  
    404  
    405 class dcLegacyPosts 
    406 { 
    407      public static function adminPostsActionSet($core, dcPostsActionSet $as) { 
    408           $stub_actions = new ArrayObject(); 
    409           $core->callBehavior('adminPostsActionsCombo',array($stub_actions)); 
    410           if (!empty($stub_actions)) { 
    411                $as->addAction($stub_actions,array('dcLegacyPosts','onActionLegacy')); 
    412           } 
    413      } 
    414       
    415      public static function onActionLegacy($core, dcPostsActionSet $as, $post) { 
    416           $core->callBehavior('adminPostsActions',$core,$as->getRS(),$as->getAction(),$as->getRedirection()); 
    417           $as->beginPage($core->callBehavior('adminPostsActionsHeaders'),''); 
    418           $core->callBehavior('adminPostsActionsContent',$core,$as->getAction(),$as->getHiddenFields(true)); 
    419           $as->endPage(); 
    420       
    421      } 
    422 } 
  • inc/prepend.php

    r1796 r1806  
    6464$__autoload['context']                  = dirname(__FILE__).'/public/lib.tpl.context.php'; 
    6565$__autoload['dcUrlHandlers']            = dirname(__FILE__).'/public/lib.urlhandlers.php'; 
    66 $__autoload['dcPostsActionSet']              = dirname(__FILE__).'/admin/actions/class.dcactionposts.php'; 
    67 $__autoload['dcActionSet']              = dirname(__FILE__).'/admin/actions/class.dcaction.php'; 
     66$__autoload['dcPostsActionsPage']            = dirname(__FILE__).'/admin/actions/class.dcactionposts.php'; 
     67$__autoload['dcActionsPage']            = dirname(__FILE__).'/admin/actions/class.dcaction.php'; 
    6868 
    6969# Clearbricks extensions 
Note: See TracChangeset for help on using the changeset viewer.

Sites map