ViMbAdmin_Version::getLatest PHP Method

getLatest() public static method

Fetches the version of the latest stable release
public static getLatest ( ) : string
return string
    public static function getLatest()
    {
        if (null === self::$_lastestVersion) {
            self::$_lastestVersion = 'not available';
            $handle = fopen('http://www.opensolutions.ie/open-source/vimbadmin/latest-v3', 'r');
            if ($handle !== false) {
                self::$_lastestVersion = preg_replace("/[^0-9\\.]/", "", trim(stream_get_contents($handle, 12)));
                fclose($handle);
            }
        }
        return self::$_lastestVersion;
    }

Usage Example

Exemplo n.º 1
0
 public function checkVersion()
 {
     if (isset($this->_options['skipVersionCheck']) && $this->_options['skipVersionCheck']) {
         return;
     }
     if (!$this->getAdmin()->isSuper()) {
         return;
     }
     // only check once per 24 hours per session
     if (isset($this->getSessionNamespace()->versionChecked) && $this->getSessionNamespace()->versionChecked > time() - 86400) {
         return;
     }
     // only check once in a 24h period for each user
     $lastCheck = $this->getAdmin()->getPreference('version_last_check_at');
     if ($lastCheck && $lastCheck > time() - 86400) {
         $this->getSessionNamespace()->versionChecked = $lastCheck;
         return;
     }
     // is there a new version available?
     $latest = ViMbAdmin_Version::getLatest();
     if ($latest != 'not available') {
         if (ViMbAdmin_Version::compareVersion($latest) == 1) {
             $this->addMessage(sprintf(_('Current version is: %s. There is a new version available: %s. ' . 'See the <a href="https://github.com/opensolutions/ViMbAdmin/releases/tag/' . $latest . '">releases list</a>.'), ViMbAdmin_Version::VERSION, ViMbAdmin_Version::getLatest()), OSS_Message::INFO);
         }
     }
     $this->getSessionNamespace()->versionChecked = time();
     $this->getAdmin()->setPreference('version_last_check_at', $this->getSessionNamespace()->versionChecked);
     $this->getD2EM()->flush();
 }
All Usage Examples Of ViMbAdmin_Version::getLatest