コード例 #1
0
ファイル: PackageManager.php プロジェクト: varvanin/currycms
 /**
  * Show package grid json.
  */
 public function showJson()
 {
     $entries = array();
     foreach (Curry_PackageManager::getPackages() as $packageInfo) {
         $packageInfo = array_shift($packageInfo);
         $installedPackage = PackageQuery::create()->findPk($packageInfo['name']);
         $hasUpgrade = $installedPackage ? version_compare($installedPackage->getVersion(), $packageInfo['version']) < 0 : false;
         $icon = '<img src="shared/images/icons/' . ($hasUpgrade ? 'package_go' : 'package') . '.png" alt="" title="' . ($hasUpgrade ? 'You can upgrade this package' : 'This package is up to date') . '" /> ';
         $entries[] = array('id' => $packageInfo['name'], 'cell' => array($icon, $packageInfo['name'], $installedPackage ? $installedPackage->getVersion() : 'Not installed', $packageInfo['version'], isset($packageInfo['filesize']) ? Curry_Util::humanReadableBytes($packageInfo['filesize']) : 'n/a', $packageInfo['summary']));
     }
     $this->returnJson(array('page' => 1, 'total' => count($entries), 'rows' => $entries));
 }
コード例 #2
0
ファイル: PackageManager.php プロジェクト: varvanin/currycms
 /**
  * Remove package.
  * 
  * @param string $name
  * @param bool $simulate
  * @return bool
  */
 public static function removePackage($name, $simulate = false)
 {
     $installedPackage = PackageQuery::create()->findPk($name);
     if (!$installedPackage) {
         return false;
     }
     $package = Curry_PackageManager::getPackage($installedPackage->getName(), $installedPackage->getVersion());
     if (!$package) {
         return false;
     }
     if (!$simulate && !self::execTask($package, 'preRemove', true)) {
         return false;
     }
     foreach ($installedPackage->getPackageFiles() as $file) {
         $filename = $file->getRealpath();
         if (!file_exists($filename)) {
             self::log('Skipping non-existent file: ' . $file->getFilename(), Curry_Backend::MSG_WARNING);
             if (!$simulate) {
                 $file->delete();
             }
             continue;
         }
         self::log('Removing: ' . $file->getFilename(), Curry_Backend::MSG_SUCCESS);
         if (!$simulate) {
             if ($file->fileIsModified()) {
                 $file->backup();
             } else {
                 unlink($filename);
             }
             $file->delete();
         }
     }
     if (!$simulate) {
         $installedPackage->delete();
         self::execTaskWithReload($package, 'postRemove');
     }
     self::$installed = null;
     return true;
 }