Exemplo n.º 1
0
 /**
  * 'bootstrap_loaded' hook
  *
  * @param bool $themeLoaded
  * @return bool
  */
 public function hookBootstrapLoaded($themeLoaded)
 {
     if ($themeLoaded && $this->_router->getSiteType() == 'admin' && is_array($this->versions)) {
         $curVerType = zula_version_type(_PROJECT_VERSION);
         if (version_compare(_PROJECT_VERSION, $this->versions[$curVerType], '<')) {
             $this->_event->success(sprintf(t('A new TangoCMS version (%1$s) is available', _PROJECT_ID . '-sysinfo'), $this->versions[$curVerType]));
             return true;
         }
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Gets the latest versions of TangoCMS and compare
  *
  * @return string
  */
 public function updateSection()
 {
     $this->setTitle(t('Update checker'));
     $this->setOutputType(self::_OT_INFORMATIVE);
     // Gather the latest stable and unstable versions
     $versions = array('stable' => t('Unknown'), 'unstable' => t('Unknown'));
     if (ini_get('allow_url_fopen')) {
         $stream = stream_context_create(array('http' => array('method' => 'GET', 'header' => 'X-TangoCMS-Version: ' . _PROJECT_VERSION . "\r\n" . 'X-TangoCMS-USI: ' . zula_hash($_SERVER['HTTP_HOST']) . "\r\n", 'timeout' => 6)));
         foreach ($versions as $type => $ver) {
             $tmpVer = @file_get_contents('http://releases.tangocms.org/latest/' . $type, false, $stream);
             if (isset($http_response_header[0]) && strpos($http_response_header[0], '200') !== false) {
                 $versions[$type] = trim($tmpVer);
             }
         }
         file_put_contents($this->_zula->getDir('tmp') . '/sysinfo/versions', serialize($versions));
     }
     $view = $this->loadView('index/update.html');
     $view->assign(array('TCM_VERSION' => _PROJECT_VERSION, 'VERSION_TYPE' => zula_version_type(_PROJECT_VERSION), 'LATEST' => $versions));
     return $view->getOutput();
 }
Exemplo n.º 3
0
/**
 * Map a development version onto the previous milestone
 * Eg. 2.5.63 => 2.6.0-alpha1
 *
 * Stable versions remain the same, .5x map to 'latest'
 *
 * @param string $version
 * @return string
 */
function zula_version_map($version)
{
    if (zula_version_type($version) == 'unstable') {
        if (strpos($version, '-') !== false) {
            return $version;
        } else {
            list($major, $minor, $rev) = explode('.', $version);
            if ($rev >= 90) {
                return sprintf('%s.%d.0-rc1', $major, $minor + 1);
            } else {
                if ($rev >= 80) {
                    return sprintf('%s.%d.0-beta1', $major, $minor + 1);
                } else {
                    if ($rev >= 70) {
                        return sprintf('%s.%d.0-alpha2', $major, $minor + 1);
                    } else {
                        if ($rev >= 60) {
                            return sprintf('%s.%d.0-alpha1', $major, $minor + 1);
                        }
                    }
                }
            }
            return 'latest';
        }
    } else {
        return $version;
    }
}