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
  • inc/core/class.dc.store.parser.php

    r2566 r3730  
    1010# 
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    12 if (!defined('DC_RC_PATH')) { return; } 
     12if (!defined('DC_RC_PATH')) {return;} 
    1313 
    1414/** 
     
    1818 
    1919Provides an object to parse XML feed of modules from a repository. 
    20 */ 
     20 */ 
    2121class dcStoreParser 
    2222{ 
    23      /** @var  object    XML object of feed contents */ 
    24      protected $xml; 
    25      /** @var  array     Array of feed contents */ 
    26      protected $items; 
    27      /** @var  string    XML bloc tag */ 
    28      protected static $bloc = 'http://dotaddict.org/da/'; 
     23    /** @var    object    XML object of feed contents */ 
     24    protected $xml; 
     25    /** @var    array    Array of feed contents */ 
     26    protected $items; 
     27    /** @var    string    XML bloc tag */ 
     28    protected static $bloc = 'http://dotaddict.org/da/'; 
    2929 
    30      /** 
    31       * Constructor. 
    32       * 
    33       * @param string    $data          Feed content 
    34       */ 
    35      public function __construct($data) 
    36      { 
    37           if (!is_string($data)) { 
    38                throw new Exception(__('Failed to read data feed')); 
    39           } 
     30    /** 
     31    * Constructor. 
     32    * 
     33     * @param    string    $data        Feed content 
     34    */ 
     35    public function __construct($data) 
     36    { 
     37        if (!is_string($data)) { 
     38            throw new Exception(__('Failed to read data feed')); 
     39        } 
    4040 
    41           $this->xml = simplexml_load_string($data); 
    42           $this->items = array(); 
     41        $this->xml  = simplexml_load_string($data); 
     42        $this->items = array(); 
    4343 
    44           if ($this->xml === false) { 
    45                throw new Exception(__('Wrong data feed')); 
    46           } 
     44        if ($this->xml === false) { 
     45            throw new Exception(__('Wrong data feed')); 
     46        } 
    4747 
    48           $this->_parse(); 
     48        $this->_parse(); 
    4949 
    50           unset($data); 
    51           unset($this->xml); 
    52      } 
     50        unset($data); 
     51        unset($this->xml); 
     52    } 
    5353 
    54      /** 
    55       * Parse XML into array 
    56       */ 
    57      protected function _parse() 
    58      { 
    59           if (empty($this->xml->module)) { 
    60                return; 
    61           } 
     54    /** 
     55    * Parse XML into array 
     56    */ 
     57    protected function _parse() 
     58    { 
     59        if (empty($this->xml->module)) { 
     60            return; 
     61        } 
    6262 
    63           foreach ($this->xml->module as $i) { 
    64                $attrs = $i->attributes(); 
     63        foreach ($this->xml->module as $i) { 
     64            $attrs = $i->attributes(); 
    6565 
    66                $item = array(); 
     66            $item = array(); 
    6767 
    68                # DC/DA shared markers 
    69                $item['id']         = (string) $attrs['id']; 
    70                $item['file']       = (string) $i->file; 
    71                $item['label']      = (string) $i->name; // deprecated 
    72                $item['name']       = (string) $i->name; 
    73                $item['version']    = (string) $i->version; 
    74                $item['author']     = (string) $i->author; 
    75                $item['desc']       = (string) $i->desc; 
     68            # DC/DA shared markers 
     69            $item['id']      = (string) $attrs['id']; 
     70            $item['file']    = (string) $i->file; 
     71            $item['label']   = (string) $i->name; // deprecated 
     72            $item['name']    = (string) $i->name; 
     73            $item['version'] = (string) $i->version; 
     74            $item['author']  = (string) $i->author; 
     75            $item['desc']    = (string) $i->desc; 
    7676 
    77                # DA specific markers 
    78                $item['dc_min']     = (string) $i->children(self::$bloc)->dcmin; 
    79                $item['details']    = (string) $i->children(self::$bloc)->details; 
    80                $item['section']    = (string) $i->children(self::$bloc)->section; 
    81                $item['support']    = (string) $i->children(self::$bloc)->support; 
    82                $item['sshot']      = (string) $i->children(self::$bloc)->sshot; 
     77            # DA specific markers 
     78            $item['dc_min']  = (string) $i->children(self::$bloc)->dcmin; 
     79            $item['details'] = (string) $i->children(self::$bloc)->details; 
     80            $item['section'] = (string) $i->children(self::$bloc)->section; 
     81            $item['support'] = (string) $i->children(self::$bloc)->support; 
     82            $item['sshot']   = (string) $i->children(self::$bloc)->sshot; 
    8383 
    84                $tags = array(); 
    85                foreach($i->children(self::$bloc)->tags as $t) { 
    86                     $tags[] = (string) $t->tag; 
    87                } 
    88                $item['tags']       = implode(', ',$tags); 
     84            $tags = array(); 
     85            foreach ($i->children(self::$bloc)->tags as $t) { 
     86                $tags[] = (string) $t->tag; 
     87            } 
     88            $item['tags'] = implode(', ', $tags); 
    8989 
    90                # First filter right now. If DC_DEV is set all modules are parse 
    91                if (defined('DC_DEV') && DC_DEV === true || dcUtils::versionsCompare(DC_VERSION, $item['dc_min'], '>=', false)) { 
    92                     $this->items[$item['id']] = $item; 
    93                } 
    94           } 
    95      } 
     90            # First filter right now. If DC_DEV is set all modules are parse 
     91            if (defined('DC_DEV') && DC_DEV === true || dcUtils::versionsCompare(DC_VERSION, $item['dc_min'], '>=', false)) { 
     92                $this->items[$item['id']] = $item; 
     93            } 
     94        } 
     95    } 
    9696 
    97      /** 
    98       * Get modules. 
    99       * 
    100       * @return     array          Modules list 
    101       */ 
    102      public function getModules() 
    103      { 
    104           return $this->items; 
    105      } 
     97    /** 
     98    * Get modules. 
     99    * 
     100     * @return    array        Modules list 
     101    */ 
     102    public function getModules() 
     103    { 
     104        return $this->items; 
     105    } 
    106106} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map