[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 /** 4 * URL pointing to the project page 5 */ 6 define( "LIFETYPE_PROJECT_PAGE", "http://www.lifetype.net" ); 7 8 /** 9 * This needs to be udpated after every major release, so that the version feed 10 * is fetched from the right place 11 */ 12 define( "LIFETYPE_DEFAULT_VERSION_FEED", "http://www.lifetype.net/feeds/1.2/lifetype.xml" ); 13 14 /** 15 * This needs to be udpated after every major release, so that the plugin feed 16 * is fetched from the right place 17 */ 18 define( "LIFETYPE_DEFAULT_PLUGIN_VERSION_FEED", "http://www.lifetype.net/feeds/1.2/plugins.xml" ); 19 20 /** 21 * File where the version string is stored 22 */ 23 if ( !defined("DEFAULT_VERSION_FILE") ) 24 define( "DEFAULT_VERSION_FILE", PLOG_CLASS_PATH . "version.php" ); 25 26 /** 27 * \ingroup Misc 28 * 29 * Returns the current version of plog as well as a link to the project page 30 */ 31 class Version 32 { 33 34 /** 35 * Returns the current version of pLog, determined by the value of the $version 36 * variable in the version.php file. 37 * If the file is not available, the result is unknown. 38 * @static 39 * @return The version identifier. 40 */ 41 function getVersion() 42 { 43 lt_include( PLOG_CLASS_PATH."class/file/file.class.php" ); 44 $versionFile = PLOG_CLASS_PATH."version.php"; 45 $version = "undefined"; 46 47 if( File::isReadable( $versionFile )) { 48 // NOTE: this is a valid use of include() 49 include( $versionFile ); 50 } else { 51 $version = "UNKNOWN"; 52 } 53 return $version; 54 } 55 56 /** 57 * Returns the official page of the project. 58 * 59 * @return The official project page. 60 * @static 61 */ 62 function getProjectPage() 63 { 64 return LIFETYPE_PROJECT_PAGE; 65 } 66 67 /** 68 * Returns the link to the current Lifetype version feed 69 * 70 * @static 71 */ 72 function getLifetypeVersionFeed() 73 { 74 return( LIFETYPE_DEFAULT_VERSION_FEED ); 75 } 76 77 /** 78 * Returns the link to the current Lifetype version feed 79 * 80 * @static 81 */ 82 function getPluginVersionFeed() 83 { 84 return( LIFETYPE_DEFAULT_PLUGIN_VERSION_FEED ); 85 } 86 87 /** 88 * Returns true if the current version is a development version 89 * 90 * @static 91 */ 92 function isDevelopment( $version = "" ) 93 { 94 if( $version == "" ) 95 $version = Version::getVersion(); 96 97 return( substr( $version, -3, 3 ) == "dev" ); 98 } 99 100 /** 101 * Compares two LT versions 102 * 103 * @param v1 104 * @param v2 105 * @return 1 if v1>v2, 0 if v1==v2 and -1 if v1<v2 106 * @see http://www.php.net/manual/en/function.version-compare.php 107 * @static 108 */ 109 function compare( $v1, $v2 ) 110 { 111 // remove the "lifetype-" string from both versions in case if it's there 112 // as it will make it easier for version_compare to work 113 $v1 = str_replace( "lifetype-", "", $v1 ); 114 $v2 = str_replace( "lifetype-", "", $v2 ); 115 116 return( version_compare( $v1, $v2 )); 117 } 118 119 /** 120 * Returns true if the given version is newer than the current one 121 * 122 * @param v1 The version that we'd like to compare to 123 * @param v1 If specified, the version that we should check whether it's older than v1 or not. 124 * If not specified, the current version will be used. 125 * @return True if the given version is newer than the current one or false otherwise 126 */ 127 function isNewer( $v1, $v2 = "" ) 128 { 129 if( $v2 == "" ) 130 $v2 = Version::getVersion(); 131 132 return( Version::compare( $v2, $v1 ) == -1 ); 133 } 134 } 135 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |