本文整理匯總了PHP中VersionCheck::getValidPluginVersionInfo方法的典型用法代碼示例。如果您正苦於以下問題:PHP VersionCheck::getValidPluginVersionInfo方法的具體用法?PHP VersionCheck::getValidPluginVersionInfo怎麽用?PHP VersionCheck::getValidPluginVersionInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類VersionCheck
的用法示例。
在下文中一共展示了VersionCheck::getValidPluginVersionInfo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: upgradePlugin
/**
* Upgrade a plugin to a newer version from the user's filesystem
* @param $path string path to plugin Directory
* @param $templateMgr reference to template manager
* @return boolean
*/
function upgradePlugin($path, &$templateMgr)
{
$this->validate();
$versionFile = $path . VERSION_FILE;
$templateMgr->assign('error', true);
$templateMgr->assign('path', 'upgrade');
$pluginVersion =& VersionCheck::getValidPluginVersionInfo($versionFile, $templateMgr);
if (is_null($pluginVersion)) {
return false;
}
assert(is_a($pluginVersion, 'Version'));
$versionDao =& DAORegistry::getDAO('VersionDAO');
$installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProduct(), true);
if (!$installedPlugin) {
$templateMgr->assign('message', 'manager.plugins.pleaseInstall');
return false;
}
if ($this->checkIfNewer($pluginVersion->getProduct(), $pluginVersion)) {
$templateMgr->assign('message', 'manager.plugins.installedVersionNewer');
return false;
} else {
$pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . strtr($pluginVersion->getProductType(), '.', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $pluginVersion->getProduct();
FileManager::rmtree($pluginDest);
if (FileManager::fileExists($pluginDest, 'dir')) {
$templateMgr->assign('message', 'manager.plugins.deleteError');
return false;
}
if (!FileManager::copyDir($path, $pluginDest)) {
$templateMgr->assign('message', 'manager.plugins.copyError');
return false;
}
$upgradeFile = $pluginDest . UPGRADE_FILE;
if (FileManager::fileExists($upgradeFile)) {
$params = $this->setConnectionParams();
$installer = new Upgrade($params, $upgradeFile, true);
if (!$installer->execute()) {
$templateMgr->assign('message', array('manager.plugins.upgradeFailed', $installer->getErrorString()));
return false;
}
}
$installedPlugin->setCurrent(0);
$pluginVersion->setCurrent(1);
$versionDao->insertVersion($pluginVersion, true);
$templateMgr->assign('message', array('manager.plugins.upgradeSuccessful', $pluginVersion->getVersionString()));
$templateMgr->assign('uploaded', true);
$templateMgr->assign('error', false);
return true;
}
}
示例2: upgradePlugin
/**
* Upgrade a plugin to a newer version from the user's filesystem
* @param $path string path to plugin Directory
* @param $templateMgr reference to template manager
* @param $category string
* @param $plugin string
* @return boolean
*/
function upgradePlugin($path, &$templateMgr, $category, $plugin)
{
$this->validate();
$versionFile = $path . VERSION_FILE;
$templateMgr->assign('error', true);
$templateMgr->assign('pageHierarchy', $this->setBreadcrumbs(true, $category));
$pluginVersion =& VersionCheck::getValidPluginVersionInfo($versionFile, $templateMgr);
if (is_null($pluginVersion)) {
return false;
}
assert(is_a($pluginVersion, 'Version'));
// Check whether the uploaded plug-in fits the original plug-in.
if ('plugins.' . $category != $pluginVersion->getProductType()) {
$templateMgr->assign('message', 'manager.plugins.wrongCategory');
return false;
}
if ($plugin != $pluginVersion->getProduct()) {
$templateMgr->assign('message', 'manager.plugins.wrongName');
return false;
}
$versionDao =& DAORegistry::getDAO('VersionDAO');
$installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProductType(), $pluginVersion->getProduct(), true);
if (!$installedPlugin) {
$templateMgr->assign('message', 'manager.plugins.pleaseInstall');
return false;
}
if ($this->_checkIfNewer($pluginVersion->getProductType(), $pluginVersion->getProduct(), $pluginVersion)) {
$templateMgr->assign('message', 'manager.plugins.installedVersionNewer');
return false;
} else {
$pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $plugin;
$pluginLibDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $plugin;
// Delete existing files.
if (is_dir($pluginDest)) {
FileManager::rmtree($pluginDest);
}
if (is_dir($pluginLibDest)) {
FileManager::rmtree($pluginLibDest);
}
// Check whether deleting has worked.
if (is_dir($pluginDest) || is_dir($pluginLibDest)) {
$templateMgr->assign('message', 'manager.plugins.deleteError');
return false;
}
// Copy the plug-in from the temporary folder to the
// target folder.
// Start with the library part (if any).
$libPath = $path . DIRECTORY_SEPARATOR . 'lib';
if (is_dir($libPath)) {
if (!FileManager::copyDir($libPath, $pluginLibDest)) {
$templateMgr->assign('message', 'manager.plugins.copyError');
return false;
}
// Remove the library part of the temporary folder.
FileManager::rmtree($libPath);
}
// Continue with the application-specific part (mandatory).
if (!FileManager::copyDir($path, $pluginDest)) {
$templateMgr->assign('message', 'manager.plugins.copyError');
return false;
}
// Remove the temporary folder.
FileManager::rmtree(dirname($path));
$upgradeFile = $pluginDest . UPGRADE_FILE;
if (FileManager::fileExists($upgradeFile)) {
$params = $this->_setConnectionParams();
$installer = new Upgrade($params, $upgradeFile, true);
if (!$installer->execute()) {
$templateMgr->assign('message', array('manager.plugins.upgradeFailed', $installer->getErrorString()));
return false;
}
}
$installedPlugin->setCurrent(0);
$pluginVersion->setCurrent(1);
$versionDao->insertVersion($pluginVersion, true);
$templateMgr->assign('category', $category);
$templateMgr->assign('plugin', $plugin);
$templateMgr->assign('message', array('manager.plugins.upgradeSuccessful', $pluginVersion->getVersionString()));
$templateMgr->assign('uploaded', true);
$templateMgr->assign('error', false);
return true;
}
}
示例3: upgradePlugin
/**
* Upgrade a plugin to a newer version from the user's filesystem
* @param $category string
* @param $plugin string
* @param $path string path to plugin Directory
* @param $category string
* @param $plugin string
* @return Version|null The upgraded version, on success; null on fail
*/
function upgradePlugin($category, $plugin, $path, &$errorMsg)
{
$versionFile = $path . '/' . PLUGIN_VERSION_FILE;
$pluginVersion = VersionCheck::getValidPluginVersionInfo($versionFile, $errorMsg);
if (!$pluginVersion) {
return null;
}
// Check whether the uploaded plug-in fits the original plug-in.
if ('plugins.' . $category != $pluginVersion->getProductType()) {
$errorMsg = __('manager.plugins.wrongCategory');
return null;
}
if ($plugin != $pluginVersion->getProduct()) {
$errorMsg = __('manager.plugins.wrongName');
return null;
}
$versionDao = DAORegistry::getDAO('VersionDAO');
$installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProductType(), $pluginVersion->getProduct(), true);
if (!$installedPlugin) {
$errorMsg = __('manager.plugins.pleaseInstall');
return null;
}
if ($this->_checkIfNewer($pluginVersion->getProductType(), $pluginVersion->getProduct(), $pluginVersion)) {
$errorMsg = __('manager.plugins.installedVersionNewer');
return null;
} else {
$pluginDest = Core::getBaseDir() . '/plugins/' . $category . '/' . $plugin;
$pluginLibDest = Core::getBaseDir() . '/' . PKP_LIB_PATH . '/plugins/' . $category . '/' . $plugin;
// Delete existing files.
$fileManager = new FileManager();
if (is_dir($pluginDest)) {
$fileManager->rmtree($pluginDest);
}
if (is_dir($pluginLibDest)) {
$fileManager->rmtree($pluginLibDest);
}
// Check whether deleting has worked.
if (is_dir($pluginDest) || is_dir($pluginLibDest)) {
$errorMsg = __('message', 'manager.plugins.deleteError');
return null;
}
// Copy the plug-in from the temporary folder to the
// target folder.
// Start with the library part (if any).
$libPath = $path . '/lib';
if (is_dir($libPath)) {
if (!$fileManager->copyDir($libPath, $pluginLibDest)) {
$errorMsg = __('manager.plugins.copyError');
return null;
}
// Remove the library part of the temporary folder.
$fileManager->rmtree($libPath);
}
// Continue with the application-specific part (mandatory).
if (!$fileManager->copyDir($path, $pluginDest)) {
$errorMsg = __('manager.plugins.copyError');
return null;
}
// Remove the temporary folder.
$fileManager->rmtree(dirname($path));
$upgradeFile = $pluginDest . '/' . PLUGIN_UPGRADE_FILE;
if ($fileManager->fileExists($upgradeFile)) {
$params = $this->_getConnectionParams();
$installer = new Upgrade($params, $upgradeFile, true);
if (!$installer->execute()) {
$errorMsg = __('manager.plugins.upgradeFailed', array('errorString' => $installer->getErrorString()));
return null;
}
}
$installedPlugin->setCurrent(0);
$pluginVersion->setCurrent(1);
$versionDao->insertVersion($pluginVersion, true);
return $pluginVersion;
}
}