예제 #1
0
 public function process()
 {
     $attributes = array();
     $attributesToGet = explode(',', $this->getProperty('attributes', ''));
     foreach ($attributesToGet as $attribute) {
         $attributes[$attribute] = $this->transport->getAttribute($attribute);
         /* if setup options, include setup file */
         if ($attribute == 'setup-options') {
             @ob_start();
             $options = $this->package->toArray();
             $options[xPDOTransport::PACKAGE_ACTION] = $this->package->previousVersionInstalled() ? xPDOTransport::ACTION_UPGRADE : xPDOTransport::ACTION_INSTALL;
             $attributeFile = $this->modx->getOption('core_path') . 'packages/' . $this->package->signature . '/' . $attribute . '.php';
             if (file_exists($attributeFile) && $attribute != '') {
                 $modx =& $this->modx;
                 $attributes['setup-options'] = (include $attributeFile);
             }
             @ob_end_clean();
         } else {
             if (in_array($attribute, array('readme', 'license', 'changelog'))) {
                 $attributes[$attribute] = htmlentities($attributes[$attribute], ENT_COMPAT, 'UTF-8');
             }
         }
     }
     return $this->success('', $attributes);
 }
예제 #2
0
 public function process()
 {
     $collection = array();
     $packageArray = $this->package->toArray();
     $installed = $this->package->get('installed');
     $packageArray['installed'] = $installed == null ? $this->modx->lexicon('no') : $installed;
     $collection[] = $packageArray;
     return $this->success('', $collection);
 }
 public function getPackages()
 {
     /* get current version for supportability */
     $this->modx->getVersionData();
     $productVersion = $this->modx->version['code_name'] . '-' . $this->modx->version['full_version'];
     /** @var modRestResponse $response */
     $response = $this->provider->request('package/update', 'GET', array('signature' => $this->package->get('signature'), 'supports' => $productVersion));
     if ($response->isError()) {
         return $this->modx->lexicon('provider_err_connect', array('error' => $response->getError()));
     }
     return $response->toXml();
 }
예제 #4
0
 public function process()
 {
     $this->modx->log(xPDO::LOG_LEVEL_INFO, $this->modx->lexicon('package_install_info_found'));
     $installed = $this->package->install($this->getProperties());
     $this->clearCache();
     if (!$installed) {
         $msg = $this->modx->lexicon('package_err_install', array('signature' => $this->package->get('signature')));
         $this->modx->log(modX::LOG_LEVEL_ERROR, $msg);
         $this->modx->log(modX::LOG_LEVEL_INFO, 'COMPLETED');
         return $this->failure($msg);
     } else {
         $msg = $this->modx->lexicon('package_install_info_success', array('signature' => $this->package->get('signature')));
         $this->modx->log(modX::LOG_LEVEL_WARN, $msg);
         $this->modx->log(modX::LOG_LEVEL_INFO, 'COMPLETED');
         return $this->success($msg);
     }
 }
예제 #5
0
 public function process()
 {
     $this->modx->log(xPDO::LOG_LEVEL_INFO, $this->modx->lexicon('package_remove_info_gpack'));
     $transportZip = $this->modx->getOption('core_path') . 'packages/' . $this->package->signature . '.transport.zip';
     $transportDir = $this->modx->getOption('core_path') . 'packages/' . $this->package->signature . '/';
     if (file_exists($transportZip) && file_exists($transportDir)) {
         /* remove transport package */
         if ($this->package->removePackage($this->getProperty('force')) == false) {
             $this->modx->log(xPDO::LOG_LEVEL_ERROR, $this->modx->lexicon('package_err_remove'));
             return $this->failure($this->modx->lexicon('package_err_remove', array('signature' => $this->package->getPrimaryKey())));
         }
     } else {
         /* for some reason the files were removed, so just remove the DB object instead */
         $this->package->remove();
     }
     $this->clearCache();
     $this->removeTransportZip($transportZip);
     $this->removeTransportDirectory($transportDir);
     return $this->cleanup();
 }
예제 #6
0
 public function process()
 {
     $this->modx->log(modX::LOG_LEVEL_INFO, $this->modx->lexicon('package_update_info_provider_scan', array('provider' => $this->provider->get('name'))));
     $packages = $this->provider->latest($this->getProperty('signature'));
     if (is_string($packages)) {
         return $this->failure($packages);
     }
     /* if no newer packages were found */
     if (count($packages) < 1) {
         $msg = $this->modx->lexicon('package_err_uptodate', array('signature' => $this->package->get('signature')));
         $this->modx->log(modX::LOG_LEVEL_INFO, $msg);
         return $this->failure($msg);
     }
     $list = array();
     /** @var SimpleXMLElement $package */
     foreach ($packages as $package) {
         $packageArray = array('id' => (string) $package['id'], 'package' => (string) $package['package'], 'version' => (string) $package['version'], 'release' => (string) $package['release'], 'signature' => (string) $package['signature'], 'location' => (string) $package['location'], 'info' => (string) $package['location'] . '::' . (string) $package['signature']);
         $list[] = $packageArray;
     }
     return $this->success('', $list);
 }
예제 #7
0
 public function process()
 {
     $attributes = array();
     $attributesToGet = explode(',', $this->getProperty('attributes', ''));
     foreach ($attributesToGet as $attribute) {
         $attributes[$attribute] = $this->transport->getAttribute($attribute);
         /* if setup options, include setup file */
         if ($attribute == 'setup-options') {
             @ob_start();
             $options = $this->package->toArray();
             $options[xPDOTransport::PACKAGE_ACTION] = empty($this->package->installed) ? xPDOTransport::ACTION_INSTALL : xPDOTransport::ACTION_UPGRADE;
             $attributeFile = $this->modx->getOption('core_path') . 'packages/' . $this->package->signature . '/' . $attribute . '.php';
             if (file_exists($attributeFile) && $attribute != '') {
                 $modx =& $this->modx;
                 $attributes['setup-options'] = (include $attributeFile);
             }
             @ob_end_clean();
         }
     }
     return $this->success('', $attributes);
 }
예제 #8
0
 /**
  * Format the dates for readability
  * 
  * @param array $packageArray
  * @return array
  */
 public function formatDates(array $packageArray)
 {
     if ($this->object->get('updated') != '0000-00-00 00:00:00' && $this->object->get('updated') != null) {
         $packageArray['updated'] = strftime($this->dateFormat, strtotime($this->object->get('updated')));
     } else {
         $packageArray['updated'] = '';
     }
     $packageArray['created'] = strftime($this->dateFormat, strtotime($this->object->get('created')));
     if ($this->object->get('installed') == null || $this->object->get('installed') == '0000-00-00 00:00:00') {
         $packageArray['installed'] = null;
     } else {
         $packageArray['installed'] = strftime($this->dateFormat, strtotime($this->object->get('installed')));
     }
     return $packageArray;
 }
 public function process()
 {
     $requires = $this->transport->getAttribute('requires');
     $dep = $this->package->checkDependencies($requires);
     $download = $this->package->checkDownloadedDependencies($dep);
     $returnArray = array();
     foreach ($requires as $pkg => $constraints) {
         if (isset($dep[$pkg])) {
             $installed = false;
         } else {
             $installed = true;
         }
         if (isset($download[$pkg])) {
             $downloaded = true;
             $signature = $download[$pkg];
         } else {
             $downloaded = false;
             $signature = '';
         }
         //@TODO: Get downlaoded property properly from somewhere and add signature property that will be needed for running installation
         $returnArray[] = array('name' => $pkg, 'parentSignature' => $this->getProperty('signature'), 'constraints' => $constraints, 'installed' => $installed, 'downloaded' => $downloaded, 'signature' => $signature);
     }
     return $this->outputArray($returnArray, count($returnArray));
 }
예제 #10
0
 /**
  * @param modTransportPackage $package
  * @param array $packageArray
  * @return array
  */
 public function checkForUpdates(modTransportPackage $package, array $packageArray)
 {
     $updates = array('count' => 0);
     if ($package->get('provider') > 0 && $this->modx->getOption('auto_check_pkg_updates', null, false)) {
         $updateCacheKey = 'mgr/providers/updates/' . $package->get('provider') . '/' . $package->get('signature');
         $updateCacheOptions = array(xPDO::OPT_CACHE_KEY => $this->modx->cacheManager->getOption('cache_packages_key', null, 'packages'), xPDO::OPT_CACHE_HANDLER => $this->modx->cacheManager->getOption('cache_packages_handler', null, $this->modx->cacheManager->getOption(xPDO::OPT_CACHE_HANDLER)));
         $updates = $this->modx->cacheManager->get($updateCacheKey, $updateCacheOptions);
         if (empty($updates)) {
             /* cache providers to speed up load time */
             /** @var modTransportProvider $provider */
             if (!empty($this->providerCache[$package->get('provider')])) {
                 $provider =& $this->providerCache[$package->get('provider')];
             } else {
                 $provider = $package->getOne('Provider');
                 if ($provider) {
                     $this->providerCache[$provider->get('id')] = $provider;
                 }
             }
             if ($provider) {
                 $loaded = $provider->getClient();
                 if ($loaded) {
                     /** @var modRestResponse $response */
                     $response = $provider->request('package/update', 'GET', array('signature' => $package->get('signature'), 'supports' => $this->productVersion));
                     if ($response && !$response->isError()) {
                         $updates = $response->toXml();
                     }
                 }
                 $updates = array('count' => count($updates));
                 $this->modx->cacheManager->set($updateCacheKey, $updates, $this->updatesCacheExpire, $updateCacheOptions);
             }
         }
     }
     $packageArray['updateable'] = (int) $updates['count'] >= 1 ? true : false;
     return $packageArray;
 }
예제 #11
0
 public function prepareMenu(modTransportPackage $package, array $packageArray)
 {
     $notInstalled = $package->get('installed') == null || $package->get('installed') == '0000-00-00 00:00:00';
     $packageArray['iconaction'] = $notInstalled ? 'icon-install' : 'icon-uninstall';
     $packageArray['textaction'] = $notInstalled ? $this->modx->lexicon('install') : $this->modx->lexicon('uninstall');
     if ($this->currentIndex > 0 || !$package->get('installed')) {
         $packageArray['menu'] = array();
         $packageArray['menu'][] = array('text' => $this->modx->lexicon('package_version_remove'), 'handler' => 'this.removePriorVersion');
     }
     return $packageArray;
 }
예제 #12
0
 public function logManagerAction()
 {
     $this->modx->logManagerAction('package_remove', 'transport.modTransportPackage', $this->package->get('id'));
 }
예제 #13
0
 /**
  * Download the actual transport package file to this server
  * @param string $url
  * @return boolean
  */
 public function downloadPackage($url)
 {
     $_package_cache = $this->modx->getOption('core_path', null, MODX_CORE_PATH) . 'packages/';
     return $this->package->transferPackage($url, $_package_cache);
 }