本文整理汇总了PHP中Package::compareVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::compareVersion方法的具体用法?PHP Package::compareVersion怎么用?PHP Package::compareVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::compareVersion方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readParameters
/**
* @see Page::readParameters()
*/
public function readParameters()
{
parent::readParameters();
if (!empty($_POST['action']) && $_POST['action'] == 'compare') {
if (!empty($_POST['version1']) && !empty($_POST['version2'])) {
require_once WCF_DIR . 'lib/acp/package/Package.class.php';
$this->verResult = Package::compareVersion($_POST['version1'], $_POST['version2']);
// $this->verResult = version_compare($_POST['version1'], $_POST['version2']);
$this->verFirst = $_POST['version1'];
$this->verSecond = $_POST['version2'];
if ($this->logFile) {
$entries = array();
$u = WCF::getUser()->username ? WCF::getUser()->username : 'Guest';
$t = TIME_NOW;
if (is_file(WBB_DIR . '/' . $this->logFile)) {
$entries = file(WBB_DIR . '/' . $this->logFile);
}
array_push($entries, $t . '||' . date('d.m.Y H:i:s', $t) . '||' . $u . '||' . $this->verFirst . '||' . $this->verSecond);
rsort($entries);
if (!empty($this->logMaxEntries) && $this->logMaxEntries > 0) {
$output = array_slice($entries, 0, $this->logMaxEntries);
} else {
$output = $entries;
}
if (count($output) && ($fh = @fopen(WBB_DIR . '/' . $this->logFile, 'w'))) {
foreach ($output as $k => $line) {
fwrite($fh, trim($line) . "\n");
}
fclose($fh);
}
}
}
}
}
示例2: readUpdates
/**
* Gets a list of available updates.
*/
protected function readUpdates()
{
if (WCF::getUser()->getPermission('admin.system.package.canUpdatePackage')) {
require_once WCF_DIR . 'lib/acp/package/update/PackageUpdate.class.php';
$this->updates = PackageUpdate::getAvailableUpdates();
// kick wbb 3.0 updates
if (CMS_DISABLE_WBB_UPDATES) {
foreach ($this->updates as $packageID => $package) {
if ($package['package'] == 'com.woltlab.wbb') {
foreach ($package['versions'] as $version => $packageVersion) {
if (Package::compareVersion($version, '3.0.0 Beta 1', '>=')) {
unset($this->updates[$packageID]['versions'][$version]);
}
}
if (!count($this->updates[$packageID]['versions'])) {
$this->updates = PackageUpdate::getAvailableUpdates(false);
unset($this->updates[$packageID]);
} else {
$this->updates[$packageID]['version'] = end($this->updates[$packageID]['versions']);
}
}
}
}
}
}
示例3: getExcludedPackages
/**
* Returns a list of excluded packages.
*
* @return array
*/
public function getExcludedPackages()
{
$excludedPackages = array();
if (count($this->packageInstallationStack)) {
$packageInstallations = array();
$packageIdentifier = array();
foreach ($this->packageInstallationStack as $packageInstallation) {
$packageInstallation['newVersion'] = $packageInstallation['action'] == 'update' ? $packageInstallation['toVersion'] : $packageInstallation['packageVersion'];
$packageInstallations[] = $packageInstallation;
$packageIdentifier[] = $packageInstallation['package'];
}
// check exclusions of the new packages
// get package update ids
$sql = "SELECT\tpackageUpdateID, package\n\t\t\t\tFROM\twcf" . WCF_N . "_package_update\n\t\t\t\tWHERE\tpackage IN ('" . implode("','", $packageIdentifier) . "')";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
foreach ($packageInstallations as $key => $packageInstallation) {
if ($packageInstallation['package'] == $row['package']) {
$packageInstallations[$key]['packageUpdateID'] = $row['packageUpdateID'];
}
}
}
// get exclusions of the new packages
// build conditions
$conditions = '';
foreach ($packageInstallations as $packageInstallation) {
if (!empty($conditions)) {
$conditions .= ' OR ';
}
$conditions .= "(packageUpdateID = " . $packageInstallation['packageUpdateID'] . " AND packageVersion = '" . escapeString($packageInstallation['newVersion']) . "')";
}
$sql = "SELECT\t\tpackage.*, package_update_exclusion.*,\n\t\t\t\t\t\tpackage_update.packageUpdateID,\n\t\t\t\t\t\tpackage_update.package\n\t\t\t\tFROM\t\twcf" . WCF_N . "_package_update_exclusion package_update_exclusion\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_package_update_version package_update_version\n\t\t\t\tON\t\t(package_update_version.packageUpdateVersionID = package_update_exclusion.packageUpdateVersionID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_package_update package_update\n\t\t\t\tON\t\t(package_update.packageUpdateID = package_update_version.packageUpdateID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\t\tON\t\t(package.package = package_update_exclusion.excludedPackage)\n\t\t\t\tWHERE\t\tpackage_update_exclusion.packageUpdateVersionID IN (\n\t\t\t\t\t\t\tSELECT\tpackageUpdateVersionID\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update_version\n\t\t\t\t\t\t\tWHERE\t" . $conditions . "\n\t\t\t\t\t\t)\n\t\t\t\t\t\tAND package.package IS NOT NULL";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
foreach ($packageInstallations as $key => $packageInstallation) {
if ($packageInstallation['package'] == $row['package']) {
if (!isset($packageInstallations[$key]['excludedPackages'])) {
$packageInstallations[$key]['excludedPackages'] = array();
}
$packageInstallations[$key]['excludedPackages'][$row['excludedPackage']] = array('package' => $row['excludedPackage'], 'version' => $row['excludedPackageVersion']);
// check version
if (!empty($row['excludedPackageVersion'])) {
if (Package::compareVersion($row['packageVersion'], $row['excludedPackageVersion'], '<')) {
continue;
}
}
$excludedPackages[] = array('package' => $row['package'], 'packageName' => $packageInstallations[$key]['packageName'], 'packageVersion' => $packageInstallations[$key]['newVersion'], 'action' => $packageInstallations[$key]['action'], 'conflict' => 'newPackageExcludesExistingPackage', 'existingPackage' => $row['excludedPackage'], 'existingPackageName' => $row['packageName'], 'existingPackageVersion' => $row['packageVersion']);
}
}
}
// check excluded packages of the existing packages
$sql = "SELECT\t\tpackage.*, package_exclusion.*\n\t\t\t\tFROM\t\twcf" . WCF_N . "_package_exclusion package_exclusion\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\t\tON\t\t(package.packageID = package_exclusion.packageID)\n\t\t\t\tWHERE\t\texcludedPackage IN ('" . implode("','", $packageIdentifier) . "')";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
foreach ($packageInstallations as $key => $packageInstallation) {
if ($packageInstallation['package'] == $row['excludedPackage']) {
if (!empty($row['excludedPackageVersion'])) {
// check version
if (Package::compareVersion($packageInstallation['newVersion'], $row['excludedPackageVersion'], '<')) {
continue;
}
// search exclusing package in stack
foreach ($packageInstallations as $packageUpdate) {
if ($packageUpdate['packageID'] == $row['packageID']) {
// check new exclusions
if (!isset($packageUpdate['excludedPackages']) || !isset($packageUpdate['excludedPackages'][$row['excludedPackage']]) || !empty($packageUpdate['excludedPackages'][$row['excludedPackage']]['version']) && Package::compareVersion($packageInstallation['newVersion'], $packageUpdate['excludedPackages'][$row['excludedPackage']]['version'], '<')) {
continue 2;
}
}
}
}
$excludedPackages[] = array('package' => $row['excludedPackage'], 'packageName' => $packageInstallation['packageName'], 'packageVersion' => $packageInstallation['newVersion'], 'action' => $packageInstallation['action'], 'conflict' => 'existingPackageExcludesNewPackage', 'existingPackage' => $row['package'], 'existingPackageName' => $row['packageName'], 'existingPackageVersion' => $row['packageVersion']);
}
}
}
}
return $excludedPackages;
}
示例4: getConflictedExcludedPackages
/**
* Returns a list of packages, which are excluded by this package.
*
* @return array
*/
public function getConflictedExcludedPackages()
{
$conflictedPackages = array();
if (count($this->excludedPackages) > 0) {
$sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\t\tWHERE\tpackage IN ('" . implode("','", array_keys($this->excludedPackages)) . "')";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
if (!empty($this->excludedPackages[$row['package']]['version'])) {
if (Package::compareVersion($row['packageVersion'], $this->excludedPackages[$row['package']]['version'], '<')) {
continue;
}
}
$conflictedPackages[$row['packageID']] = $row;
}
}
return $conflictedPackages;
}
示例5: checkExclusions
/**
* Checks for conflicted exclusions.
*/
protected function checkExclusions()
{
$excludedPackages = $this->packageArchive->getConflictedExcludedPackages();
if (count($excludedPackages) > 0) {
// this package exludes existing packages -> stop installation
WCF::getTPL()->assign(array('excludedPackages' => $excludedPackages));
WCF::getTPL()->display('packageInstallationExcludedPackages');
exit;
}
$excludingPackages = $this->packageArchive->getConflictedExcludingPackages();
if (count($excludingPackages) > 0) {
$stop = 1;
// this package is excluded by existing packages
$sql = "SELECT\t*\n\t\t\t\tFROM\twcf" . WCF_N . "_package_installation_queue\n\t\t\t\tWHERE\tprocessNo = " . $this->processNo . "\n\t\t\t\t\tAND packageID IN (" . implode(',', array_keys($excludingPackages)) . ")";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
$archive = new PackageArchive($row['archive']);
$archive->openArchive();
$newExclusions = $archive->getExcludedPackages();
if (!count($newExclusions) || !isset($newExclusions[$this->packageArchive->getPackageInfo('name')]) || isset($newExclusions[$this->packageArchive->getPackageInfo('name')]['version']) && Package::compareVersion($this->packageArchive->getPackageInfo('version'), $newExclusions[$this->packageArchive->getPackageInfo('name')]['version'], '<')) {
unset($excludingPackages[$row['packageID']]);
$stop = 0;
}
}
if (count($excludingPackages) > 0) {
WCF::getTPL()->assign(array('excludingPackages' => $excludingPackages, 'stop' => $stop, 'nextStep' => 'package'));
WCF::getTPL()->display('packageInstallationExcludingPackages');
exit;
}
}
}
示例6: readPackages
/**
* Gets a list of packages.
*/
protected function readPackages()
{
if ($this->items) {
$sql = "SELECT\t\t*\n\t\t\t\tFROM\t\twcf" . WCF_N . "_package_update\n\t\t\t\tWHERE\t\tpackageUpdateID IN (" . $this->search['searchData'] . ")\n\t\t\t\tORDER BY\t" . $this->sortField . " " . $this->sortOrder;
$result = WCF::getDB()->sendQuery($sql, $this->itemsPerPage, ($this->pageNo - 1) * $this->itemsPerPage);
while ($row = WCF::getDB()->fetchArray($result)) {
// default values
$row['isUnique'] = 0;
$row['updatableInstances'] = array();
$row['packageVersions'] = array();
$row['packageVersion'] = '1.0.0';
$row['instances'] = 0;
// get package versions
$sql = "SELECT\tpackageVersion\n\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update_version\n\t\t\t\t\tWHERE\tpackageUpdateID IN (\n\t\t\t\t\t\t\tSELECT\tpackageUpdateID\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update\n\t\t\t\t\t\t\tWHERE\tpackage = '" . escapeString($row['package']) . "'\n\t\t\t\t\t\t)";
$result2 = WCF::getDB()->sendQuery($sql);
while ($row2 = WCF::getDB()->fetchArray($result2)) {
$row['packageVersions'][] = $row2['packageVersion'];
}
if (count($row['packageVersions'])) {
// remove duplicates
$row['packageVersions'] = array_unique($row['packageVersions']);
// sort versions
usort($row['packageVersions'], array('Package', 'compareVersion'));
// take lastest version
$row['packageVersion'] = end($row['packageVersions']);
}
// get installed instances
$sql = "SELECT\tpackage.*, CASE WHEN instanceName <> '' THEN instanceName ELSE packageName END AS packageName\n\t\t\t\t\tFROM\twcf" . WCF_N . "_package package\n\t\t\t\t\tWHERE \tpackage.package = '" . escapeString($row['package']) . "'";
$result2 = WCF::getDB()->sendQuery($sql);
while ($row2 = WCF::getDB()->fetchArray($result2)) {
$row['instances']++;
// is already installed unique?
if ($row2['isUnique'] == 1) {
$row['isUnique'] = 1;
}
// check update support
if (Package::compareVersion($row2['packageVersion'], $row['packageVersion'], '<')) {
$row['updatableInstances'][] = $row2;
}
}
$this->packages[] = $row;
}
}
}