本文整理汇总了PHP中Marketplace::checkPackageUpdates方法的典型用法代码示例。如果您正苦于以下问题:PHP Marketplace::checkPackageUpdates方法的具体用法?PHP Marketplace::checkPackageUpdates怎么用?PHP Marketplace::checkPackageUpdates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Marketplace
的用法示例。
在下文中一共展示了Marketplace::checkPackageUpdates方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLatestAvailableVersionNumber
public function getLatestAvailableVersionNumber() {
if (defined('MULTI_SITE') && MULTI_SITE == 1) {
$updates = Update::getLocalAvailableUpdates();
$multiSiteVersion = 0;
foreach($updates as $up) {
if (version_compare($up->getUpdateVersion(), $multiSiteVersion, '>')) {
$multiSiteVersion = $up->getUpdateVersion();
}
}
Config::save('APP_VERSION_LATEST', $multiSiteVersion);
return $multiSiteVersion;
}
$d = Loader::helper('date');
// first, we check session
$queryWS = false;
Cache::disableCache();
$vNum = Config::get('APP_VERSION_LATEST', true);
Cache::enableCache();
if (is_object($vNum)) {
$seconds = strtotime($vNum->timestamp);
$version = $vNum->value;
if (is_object($version)) {
$versionNum = $version->version;
} else {
$versionNum = $version;
}
$diff = time() - $seconds;
if ($diff > APP_VERSION_LATEST_THRESHOLD) {
// we grab a new value from the service
$queryWS = true;
}
} else {
$queryWS = true;
}
if ($queryWS) {
Loader::library('marketplace');
$mi = Marketplace::getInstance();
if ($mi->isConnected()) {
Marketplace::checkPackageUpdates();
}
$update = Update::getLatestAvailableUpdate();
$versionNum = $update->version;
if ($versionNum) {
Config::save('APP_VERSION_LATEST', $versionNum);
if (version_compare($versionNum, APP_VERSION, '>')) {
Loader::model('system_notification');
SystemNotification::add(SystemNotification::SN_TYPE_CORE_UPDATE, t('A new version of concrete5 is now available.'), '', $update->notes, View::url('/dashboard/system/update'));
}
} else {
// we don't know so we're going to assume we're it
Config::save('APP_VERSION_LATEST', APP_VERSION);
}
}
return $versionNum;
}
示例2: view
public function view() {
$tp = new TaskPermission();
if ($tp->canInstallPackages()) {
$mi = Marketplace::getInstance();
if ($mi->isConnected()) {
Marketplace::checkPackageUpdates();
}
}
}
示例3: update
public function update($pkgHandle = false) {
$tp = new TaskPermission();
if ($tp->canInstallPackages()) {
if ($pkgHandle) {
$tests = Package::testForInstall($pkgHandle, false);
if (is_array($tests)) {
$tests = Package::mapError($tests);
$this->set('error', $tests);
} else {
$p = Package::getByHandle($pkgHandle);
try {
$p->upgradeCoreData();
$p->upgrade();
$this->set('message', t('The package has been updated successfully.'));
} catch(Exception $e) {
$this->set('error', $e);
}
}
} else {
$mi = Marketplace::getInstance();
if ($mi->isConnected()) {
Marketplace::checkPackageUpdates();
}
}
}
}