00001 <?php
00002
00016
00017
00018
00019 class Version extends DataObject {
00020
00024 function Version() {
00025 parent::DataObject();
00026 }
00027
00037 function compare($version) {
00038 if (is_object($version)) {
00039 return $this->compare($version->getVersionString());
00040 }
00041 return version_compare($this->getVersionString(), $version);
00042 }
00043
00049 function &fromString($versionString) {
00050 $version = &new Version();
00051
00052 $versionArray = explode('.', $versionString);
00053 $version->setMajor(isset($versionArray[0]) ? (int) $versionArray[0] : 0);
00054 $version->setMinor(isset($versionArray[1]) ? (int) $versionArray[1] : 0);
00055 $version->setRevision(isset($versionArray[2]) ? (int) $versionArray[2] : 0);
00056 $version->setBuild(isset($versionArray[3]) ? (int) $versionArray[3] : 0);
00057 $version->setDateInstalled(null);
00058
00059 return $version;
00060 }
00061
00062
00063
00064
00065
00070 function getMajor() {
00071 return $this->getData('major');
00072 }
00073
00078 function setMajor($major) {
00079 return $this->setData('major', $major);
00080 }
00081
00086 function getMinor() {
00087 return $this->getData('minor');
00088 }
00089
00094 function setMinor($minor) {
00095 return $this->setData('minor', $minor);
00096 }
00097
00102 function getRevision() {
00103 return $this->getData('revision');
00104 }
00105
00110 function setRevision($revision) {
00111 return $this->setData('revision', $revision);
00112 }
00113
00118 function getBuild() {
00119 return $this->getData('build');
00120 }
00121
00126 function setBuild($build) {
00127 return $this->setData('build', $build);
00128 }
00129
00134 function getDateInstalled() {
00135 return $this->getData('dateInstalled');
00136 }
00137
00142 function setDateInstalled($dateInstalled) {
00143 return $this->setData('dateInstalled', $dateInstalled);
00144 }
00145
00150 function getCurrent() {
00151 return $this->getData('current');
00152 }
00153
00158 function setcurrent($current) {
00159 return $this->setData('current', $current);
00160 }
00161
00166 function getVersionString() {
00167 return sprintf('%d.%d.%d.%d', $this->getMajor(), $this->getMinor(), $this->getRevision(), $this->getBuild());
00168 }
00169
00170 }
00171
00172 ?>