public function execute()
 {
     $this->loadQueryStringPagingVariable();
     $params = $this->params;
     $params['version'] = APP_VERSION;
     $params['itemsPerPage'] = $this->itemsPerPage;
     $mi = Marketplace::getInstance();
     $params['csToken'] = $mi->getSiteToken();
     if ($this->includeInstalledItems) {
         $params['includeInstalledItems'] = 1;
     } else {
         $params['includeInstalledItems'] = 0;
         $list = Package::getInstalledList();
         foreach ($list as $pkg) {
             $params['installedPackages'][] = $pkg->getPackageHandle();
         }
     }
     if (isset($_REQUEST[$this->queryStringPagingVariable])) {
         $params[$this->queryStringPagingVariable] = $_REQUEST[$this->queryStringPagingVariable];
     }
     $uh = Core::make('helper/url');
     $url = Config::get('concrete.urls.concrete5') . Config::get('concrete.urls.paths.marketplace.remote_item_list');
     $url = $uh->buildQuery($url . $this->type . '/-/get_remote_list', $params);
     if (Config::get('concrete.marketplace.log_requests')) {
         Log::info($url);
     }
     $r = Core::make('helper/file')->getContents($url);
     $r2 = @Core::make('helper/json')->decode($r);
     $total = 0;
     $items = array();
     if (is_object($r2)) {
         $items = $r2->items;
         $total = $r2->total;
     }
     $this->total = $total;
     $this->setItems($items);
 }
 public function download()
 {
     $file = Marketplace::downloadRemoteFile($this->getRemoteFileURL());
     if (empty($file) || $file == Package::E_PACKAGE_DOWNLOAD) {
         return array(Package::E_PACKAGE_DOWNLOAD);
     } else {
         if ($file == Package::E_PACKAGE_SAVE) {
             return array($file);
         } else {
             if ($file == Package::E_PACKAGE_INVALID_APP_VERSION) {
                 return array($file);
             }
         }
     }
     try {
         $am = new PackageArchive($this->getHandle());
         $am->install($file, true);
     } catch (Exception $e) {
         return array($e->getMessage());
     }
     if ($install) {
         $tests = Package::testForInstall($this->getHandle());
         if (is_array($tests)) {
             return $tests;
         } else {
             $p = Loader::package($this->getHandle());
             try {
                 $p->install();
             } catch (Exception $e) {
                 return array(Package::E_PACKAGE_INSTALL);
             }
         }
     }
 }
 public function on_start()
 {
     parent::on_start();
     $this->marketplace = Marketplace::getInstance();
     $this->item = RemoteItem::getByID($this->request->query->get('mpID'));
 }
 /**
  * Given the current update object, sends information to concrete5.org to determine updatability
  * @return \Concrete\Core\Updater\ApplicationUpdateDiagnostic
  */
 public function getDiagnosticObject()
 {
     $request = new Request();
     $request->setUri(Config::get('concrete.updates.services.inspect_update'));
     $request->setMethod('POST');
     $request->getPost()->set('current_version', Config::get('concrete.version_installed'));
     $request->getPost()->set('requested_version', $this->getVersion());
     $request->getPost()->set('site_url', (string) \Core::getApplicationURL());
     $mi = Marketplace::getInstance();
     if ($mi->isConnected() && !$mi->hasConnectionError()) {
         $config = \Core::make('config/database');
         $request->getPost()->set('marketplace_token', $config->get('concrete.marketplace.token'));
         $list = Package::getInstalledList();
         $packages = array();
         foreach ($list as $pkg) {
             $packages[] = array('version' => $pkg->getPackageVersion(), 'handle' => $pkg->getPackageHandle());
         }
         $request->getPost()->set('packages', $packages);
     }
     $overrides = id(Environment::get())->getOverrideList();
     $request->getPost()->set('overrides', $overrides);
     $client = new Client();
     $client->setMethod('POST');
     $response = $client->send($request);
     $body = $response->getBody();
     $diagnostic = DiagnosticFactory::getFromJSON($body);
     return $diagnostic;
 }
示例#5
0
 public function getMarketplaceFrame($width = '100%', $height = '300', $completeURL = false, $connectMethod = 'view')
 {
     // if $mpID is passed, we are going to either
     // a. go to its purchase page
     // b. pass you through to the page AFTER connecting.
     $tp = new TaskPermission();
     $frameURL = Config::get('concrete.urls.concrete5');
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
         $frameURL = Config::get('concrete.urls.concrete5_secure');
     }
     if ($tp->canInstallPackages()) {
         if (!$this->isConnected()) {
             if (!$completeURL) {
                 $completeURL = URL::to('/dashboard/extend/connect', 'connect_complete');
             }
             $csReferrer = urlencode($completeURL);
             $csiURL = urlencode(\Core::getApplicationURL());
             // this used to be the BASE_URL and not BASE_URL . DIR_REL but I don't have a method for that
             // and honestly I'm not sure why it needs to be that way
             $csiBaseURL = urlencode(\Core::getApplicationURL());
             if ($this->hasConnectionError()) {
                 if ($this->connectionError == Marketplace::E_DELETED_SITE_TOKEN) {
                     $connectMethod = 'view';
                     $csToken = Marketplace::generateSiteToken();
                 } else {
                     $csToken = $this->getSiteToken();
                 }
             } else {
                 // new connection
                 $csToken = Marketplace::generateSiteToken();
             }
             $url = $frameURL . Config::get('concrete.urls.paths.marketplace.connect') . '/-/' . $connectMethod;
             $url = $url . '?ts=' . time() . '&csiBaseURL=' . $csiBaseURL . '&csiURL=' . $csiURL . '&csToken=' . $csToken . '&csReferrer=' . $csReferrer . '&csName=' . htmlspecialchars(Config::get('concrete.site'), ENT_QUOTES, APP_CHARSET);
         } else {
             $csiBaseURL = urlencode(\Core::getApplicationURL());
             $url = $frameURL . Config::get('concrete.urls.paths.marketplace.connect_success') . '?csToken=' . $this->getSiteToken() . '&csiBaseURL=' . $csiBaseURL;
         }
         if ($csToken == false && !$this->isConnected()) {
             return '<div class="ccm-error">' . t('Unable to generate a marketplace token. Please ensure that allow_url_fopen is turned on, or that cURL is enabled on your server. If these are both true, It\'s possible your site\'s IP address may be blacklisted for some reason on our server. Please ask your webhost what your site\'s outgoing cURL request IP address is, and email it to us at <a href="mailto:help@concrete5.org">help@concrete5.org</a>.') . '</div>';
         } else {
             $time = time();
             $ifr = '<script type="text/javascript">
                 window.addEventListener("message", function(e) {
                     jQuery.fn.dialog.hideLoader();
                     if (e.data == "loading") {
                         jQuery.fn.dialog.showLoader();
                     } else {
                         var eh = e.data;
                         eh = parseInt(eh) + 100;
                         $("#ccm-marketplace-frame-' . $time . '").attr("height", eh);
                     }
                     });
                 </script>';
             $ifr .= '<iframe class="ccm-marketplace-frame-connect" id="ccm-marketplace-frame-' . $time . '" frameborder="0" width="' . $width . '" height="' . $height . '" src="' . $url . '"></iframe>';
             return $ifr;
         }
     } else {
         return '<div class="ccm-error">' . t('You do not have permission to connect this site to the marketplace.') . '</div>';
     }
 }
示例#6
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
?>

<div class="ccm-ui">
    <?php 
$mi = \Concrete\Core\Marketplace\Marketplace::getInstance();
echo $mi->getMarketplacePurchaseFrame($mri, '100%', '100%');
?>
</div>
示例#7
0
 public function getMarketplacePurchaseFrame($mp, $width = "100%", $height = "530")
 {
     return parent::getMarketplacePurchaseFrame($mp, $width, $height);
 }
示例#8
0
 public function download()
 {
     $file = Marketplace::downloadRemoteFile($this->getRemoteFileURL());
     if ($file instanceof ErrorList) {
         return $file;
     } else {
         try {
             $am = new PackageArchive($this->getHandle());
             $am->install($file, true);
         } catch (Exception $e) {
             $error = \Core::make('error');
             $error->add($e);
             return $e;
         }
     }
 }