예제 #1
0
 public function display($tpl = null)
 {
     // Get model state.
     $this->state = $this->get('State');
     $this->item = $this->get("Item");
     // Get params
     $this->params = $this->state->get("params");
     if (!$this->item) {
         $this->app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_INVALID_PROJECT"), "notice");
         $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false));
         return;
     }
     // Create an object that will contain the data during the payment process.
     $this->paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $this->item->id;
     $paymentSession = $this->app->getUserState($this->paymentSessionContext);
     // Create payment session object.
     if (!$paymentSession or !isset($paymentSession->step1)) {
         $paymentSession = new JData();
         $paymentSession->step1 = false;
     }
     // Images
     $this->imageFolder = $this->params->get("images_directory", "images/crowdfunding");
     // Get currency
     $this->currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency"));
     $this->amount = new Crowdfunding\Amount($this->params);
     $this->amount->setCurrency($this->currency);
     // Set a link that points to project page
     $filter = JFilterInput::getInstance();
     $host = JUri::getInstance()->toString(array('scheme', 'host'));
     $host = $filter->clean($host);
     $this->item->link = $host . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug), false);
     // Set a link to image
     $this->item->link_image = $host . "/" . $this->imageFolder . "/" . $this->item->image;
     // Get wizard type
     $this->wizardType = $this->params->get("backing_wizard_type", "three_steps");
     $this->fourSteps = strcmp("four_steps", $this->wizardType) != 0 ? false : true;
     // Import "crowdfundingpayment" plugins.
     JPluginHelper::importPlugin('crowdfundingpayment');
     $this->layout = $this->getLayout();
     switch ($this->layout) {
         case "step2":
             $this->prepareStep2();
             break;
         case "payment":
             $this->preparePayment($paymentSession);
             break;
         case "share":
             $this->prepareShare($paymentSession);
             break;
         default:
             //  Pledge and Rewards
             $this->prepareRewards($paymentSession);
             break;
     }
     // Get project type and check for enabled rewards.
     $this->rewardsEnabled = true;
     if (!empty($this->item->type_id)) {
         $type = new Crowdfunding\Type(JFactory::getDbo());
         $type->load($this->item->type_id);
         if ($type->getId() and !$type->isRewardsEnabled()) {
             $this->rewardsEnabled = false;
         }
     }
     // Check days left. If there is no days, disable the button.
     $this->disabledButton = "";
     if (!$this->item->days_left) {
         $this->disabledButton = 'disabled="disabled"';
     }
     $this->paymentSession = $paymentSession;
     // Prepare the data of the layout
     $this->layoutData = new JData(array("layout" => $this->layout, "item" => $this->item, "paymentSession" => $paymentSession));
     $this->prepareDebugMode($paymentSession);
     $this->prepareDocument();
     parent::display($tpl);
 }
예제 #2
0
 /**
  * Check the system for debug mode.
  */
 protected function prepareProjectType()
 {
     $this->rewardsEnabledViaType = true;
     if (!empty($this->item->type_id)) {
         $type = new Crowdfunding\Type(JFactory::getDbo());
         $type->load($this->item->type_id);
         if ($type->getId() and !$type->isRewardsEnabled()) {
             $this->rewardsEnabledViaType = false;
             $this->disabledButton = 'disabled="disabled"';
         }
     }
 }