forked from jquery/themeroller.jquerymobile.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.php
66 lines (58 loc) · 1.79 KB
/
version.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
function versionCompare( $version1, $version2 ) {
$empty = array( null, null, null, null, null );
$ver1 = array_replace( $empty, preg_split( "/\.|-/", $version1 ) );
$ver2 = array_replace( $empty, preg_split( "/\.|-/", $version2 ) );
if ( $ver1[0] > $ver2[0] ) {
return true;
} else if ( $ver1[0] < $ver2[0] ) {
return false;
} else {
//tie
if ( $ver1[1] > $ver2[1] ) {
return true;
} else if ( $ver1[1] < $ver2[1] ) {
return false;
} else {
//tie
if ( $ver1[2] > $ver2[2] ) {
return true;
} else if ( $ver1[2] < $ver2[2] ) {
return false;
} else {
//tie
$types = array( "alpha" => 0, "beta" => 1, "rc" => 2 );
$ver1[3] = $types[ $ver1[3] ? $ver1[3] : "alpha" ];
$ver2[3] = $types[ $ver2[3] ? $ver2[3] : "alpha" ];
if ( $ver1[3] > $ver2[3] ) {
return true;
} else if ( $ver1[3] < $ver2[3] ) {
return false;
} else {
//tie
if ( $ver1[4] >= $ver2[4] ) {
return true;
} else if ( $ver1[4] < $ver2[4] ) {
return false;
}
}
}
}
}
}
$ALL_JQUERY_VERSIONS = array(
"1.0.1" => "1.6.4",
"1.1.2" => "1.7.2",
"1.2.1" => "1.8.3",
"1.3.2" => "1.9.1",
"1.4.5" => "1.11.1"
);
$VERSION_LIST = array_keys( $ALL_JQUERY_VERSIONS );
$VERSION_LIST = array_reverse( $VERSION_LIST );
$JQM_VERSION = "";
foreach( $VERSION_LIST as $VERSION ) {
if ( versionCompare( $VERSION, $JQM_VERSION ) ) {
$JQM_VERSION = $VERSION;
}
}
?>