Dotclear


Ignore:
Timestamp:
03/08/18 17:58:39 (8 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Code formatting (PSR-2)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/maintenance/inc/tasks/class.dc.maintenance.synchpostsmeta.php

    r3340 r3730  
    1010# 
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    12 if (!defined('DC_RC_PATH')) { return; } 
     12if (!defined('DC_RC_PATH')) {return;} 
    1313 
    1414class dcMaintenanceSynchpostsmeta extends dcMaintenanceTask 
    1515{ 
    16      protected $ajax = true; 
    17      protected $group = 'index'; 
    18      protected $limit = 100; 
    19      protected $step_task; 
     16    protected $ajax = true; 
     17    protected $group = 'index'; 
     18    protected $limit = 100; 
     19    protected $step_task; 
    2020 
    21      protected function init() 
    22      { 
    23           $this->name         = __('Entries metadata'); 
    24           $this->task         = __('Synchronize entries metadata'); 
    25           $this->step_task    = __('Next'); 
    26           $this->step         = __('Synchronize entry %d to %d.'); 
    27           $this->success           = __('Entries metadata synchronize done.'); 
    28           $this->error        = __('Failed to synchronize entries metadata.'); 
     21    protected function init() 
     22    { 
     23        $this->name      = __('Entries metadata'); 
     24        $this->task      = __('Synchronize entries metadata'); 
     25        $this->step_task = __('Next'); 
     26        $this->step      = __('Synchronize entry %d to %d.'); 
     27        $this->success   = __('Entries metadata synchronize done.'); 
     28        $this->error     = __('Failed to synchronize entries metadata.'); 
    2929 
    30           $this->description = __('Synchronize all entries metadata could be useful after importing content in your blog or do bad operation on database tables.'); 
    31      } 
     30        $this->description = __('Synchronize all entries metadata could be useful after importing content in your blog or do bad operation on database tables.'); 
     31    } 
    3232 
    33      public function execute() 
    34      { 
    35           $this->code = $this->synchronizeAllPostsmeta($this->code, $this->limit); 
     33    public function execute() 
     34    { 
     35        $this->code = $this->synchronizeAllPostsmeta($this->code, $this->limit); 
    3636 
    37           return $this->code ?: true; 
    38      } 
     37        return $this->code ?: true; 
     38    } 
    3939 
    40      public function task() 
    41      { 
    42           return $this->code ? $this->step_task : $this->task; 
    43      } 
     40    public function task() 
     41    { 
     42        return $this->code ? $this->step_task : $this->task; 
     43    } 
    4444 
    45      public function step() 
    46      { 
    47           return $this->code ? sprintf($this->step, $this->code - $this->limit, $this->code) : null; 
    48      } 
     45    public function step() 
     46    { 
     47        return $this->code ? sprintf($this->step, $this->code - $this->limit, $this->code) : null; 
     48    } 
    4949 
    50      public function success() 
    51      { 
    52           return $this->code ? sprintf($this->step, $this->code - $this->limit, $this->code) : $this->success; 
    53      } 
     50    public function success() 
     51    { 
     52        return $this->code ? sprintf($this->step, $this->code - $this->limit, $this->code) : $this->success; 
     53    } 
    5454 
    55      protected function synchronizeAllPostsmeta($start=null,$limit=null) 
    56      { 
    57           // Get number of posts 
    58           $rs = $this->core->con->select('SELECT COUNT(post_id) FROM '.$this->core->prefix.'post'); 
    59           $count = $rs->f(0); 
     55    protected function synchronizeAllPostsmeta($start = null, $limit = null) 
     56    { 
     57        // Get number of posts 
     58        $rs    = $this->core->con->select('SELECT COUNT(post_id) FROM ' . $this->core->prefix . 'post'); 
     59        $count = $rs->f(0); 
    6060 
    61           // Get posts ids to update 
    62           $req_limit = $start !== null && $limit !== null ? $this->core->con->limit($start, $limit) : ''; 
    63           $rs = $this->core->con->select('SELECT post_id FROM '.$this->core->prefix.'post '.$req_limit, true); 
     61        // Get posts ids to update 
     62        $req_limit = $start !== null && $limit !== null ? $this->core->con->limit($start, $limit) : ''; 
     63        $rs        = $this->core->con->select('SELECT post_id FROM ' . $this->core->prefix . 'post ' . $req_limit, true); 
    6464 
    65           // Update posts meta 
    66           while ($rs->fetch()) { 
    67                $rs_meta = $this->core->con->select('SELECT meta_id, meta_type FROM '.$this->core->prefix.'meta WHERE post_id = '.$rs->post_id.' '); 
     65        // Update posts meta 
     66        while ($rs->fetch()) { 
     67            $rs_meta = $this->core->con->select('SELECT meta_id, meta_type FROM ' . $this->core->prefix . 'meta WHERE post_id = ' . $rs->post_id . ' '); 
    6868 
    69                $meta = array(); 
    70                while ($rs_meta->fetch()) { 
    71                     $meta[$rs_meta->meta_type][] = $rs_meta->meta_id; 
    72                } 
     69            $meta = array(); 
     70            while ($rs_meta->fetch()) { 
     71                $meta[$rs_meta->meta_type][] = $rs_meta->meta_id; 
     72            } 
    7373 
    74                $cur = $this->core->con->openCursor($this->core->prefix.'post'); 
    75                $cur->post_meta = serialize($meta); 
    76                $cur->update('WHERE post_id = '.$rs->post_id); 
    77           } 
    78           $this->core->blog->triggerBlog(); 
     74            $cur            = $this->core->con->openCursor($this->core->prefix . 'post'); 
     75            $cur->post_meta = serialize($meta); 
     76            $cur->update('WHERE post_id = ' . $rs->post_id); 
     77        } 
     78        $this->core->blog->triggerBlog(); 
    7979 
    80           // Return next step 
    81           return $start + $limit > $count ? null : $start + $limit; 
    82      } 
     80        // Return next step 
     81        return $start + $limit > $count ? null : $start + $limit; 
     82    } 
    8383} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map