Exemple #1
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>';
     }
 }
 /**
  * @return bool|string
  * @throws \Concrete\Core\File\Exception\RequestTimeoutException
  */
 public function generateSiteToken()
 {
     return parent::generateSiteToken();
 }