Dotclear

Changeset 2388:731ff8ef9ded


Ignore:
Timestamp:
10/16/13 17:47:56 (10 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
2.6
Message:

Add custom versions comparison, now can install module that required version x.y on a x.y-RC, x.y-dev, etc..

Location:
inc/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.store.parser.php

    r2222 r2388  
    8989                
    9090               # First filter right now. If DC_DEV is set all modules are parse 
    91                if (defined('DC_DEV') && DC_DEV === true || version_compare(DC_VERSION,$item['dc_min'],'>=')) { 
     91               if (defined('DC_DEV') && DC_DEV === true || dcUtils::versionsCompare(DC_VERSION, $item['dc_min'], '>=', false)) { 
    9292                    $this->items[$item['id']] = $item; 
    9393               } 
  • inc/core/class.dc.store.php

    r2270 r2388  
    8282          foreach ($current as $p_id => $p_infos) { 
    8383               if (isset($raw_datas[$p_id])) { 
    84                     if (self::compare($raw_datas[$p_id]['version'],$p_infos['version'],'>')) { 
     84                    if (dcUtils::versionsCompare($raw_datas[$p_id]['version'],$p_infos['version'],'>')) { 
    8585                         $updates[$p_id] = $raw_datas[$p_id]; 
    8686                         $updates[$p_id]['root'] = $p_infos['root']; 
  • inc/core/class.dc.utils.php

    r1179 r2388  
    7474          return $clean_ids; 
    7575     } 
     76 
     77     /** 
     78      * Compare two versions with option of using only main numbers. 
     79      * 
     80      * @param  string   $current_version    Current version 
     81      * @param  string   $required_version   Required version 
     82      * @param  string   $operator           Comparison operand 
     83      * @param  boolean  $strict                  Use full version 
     84      * @return boolean  True if comparison success 
     85      */ 
     86     public static function versionsCompare($current_version, $required_version, $operator='>=', $strict=true) 
     87     { 
     88          if ($strict) { 
     89               $current_version = preg_replace('!-r(\d+)$!', '-p$1', $current_version); 
     90               $required_version = preg_replace('!-r(\d+)$!', '-p$1', $required_version); 
     91          } 
     92          else { 
     93               $current_version = preg_replace('/^([0-9\.]+)(.*?)$/', '$1', $current_version); 
     94               $required_version = preg_replace('/^([0-9\.]+)(.*?)$/', '$1', $required_version); 
     95          } 
     96 
     97          return (boolean) version_compare($current_version, $required_version, $operator); 
     98     } 
    7699} 
    77100 
Note: See TracChangeset for help on using the changeset viewer.

Sites map