[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace dokuwiki; 4 5 /** 6 * Basic Information about DokuWiki 7 * 8 * @todo much of infoutils should be moved here 9 */ 10 class Info 11 { 12 13 /** 14 * Parse the given version string into its parts 15 * 16 * @param string $version 17 * @return array 18 * @throws \Exception 19 */ 20 static public function parseVersionString($version) 21 { 22 $return = [ 23 'type' => '', // stable, rc 24 'date' => '', // YYYY-MM-DD 25 'hotfix' => '', // a, b, c, ... 26 'version' => '', // sortable, full version string 27 'codename' => '', // codename 28 'raw' => $version, // raw version string as given 29 ]; 30 31 if (preg_match('/^(rc)?(\d{4}-\d{2}-\d{2})([a-z]*)/', $version, $matches)) { 32 $return['date'] = $matches[2]; 33 if ($matches[1] == 'rc') { 34 $return['type'] = 'rc'; 35 } else { 36 $return['type'] = 'stable'; 37 } 38 if ($matches[3]) { 39 $return['hotfix'] = $matches[3]; 40 } 41 } else { 42 throw new \Exception('failed to parse version string'); 43 } 44 45 [, $return['codename']] = sexplode(' ', $version, 2); 46 $return['codename'] = trim($return['codename'], ' "'); 47 48 $return['version'] = $return['date']; 49 $return['version'] .= $return['type'] == 'rc' ? 'rc' : $return['hotfix']; 50 51 return $return; 52 } 53 54 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body