Пример #1
0
 /**
  * Load types data from database.
  *
  * <code>
  * $options = array(
  *  "order_column" => "title", // id or title
  *  "order_direction" => "DESC",
  * );
  *
  * $types    = new CrowdFundingTypes();
  * $types->setDb(JFactory::getDbo());
  * $types->load($options);
  *
  * foreach ($types as $type) {
  *      echo $type["title"];
  *      echo $type["description"];
  * }
  * </code>
  *
  * @param array $options
  */
 public function load($options = array())
 {
     $query = $this->db->getQuery(true);
     $query->select("a.id, a.title, a.description, a.params")->from($this->db->quoteName("#__crowdf_types", "a"));
     // Order by column
     if (isset($options["order_column"])) {
         $orderString = $this->db->quoteName($options["order_column"]);
         // Order direction
         if (isset($options["order_direction"])) {
             $orderString .= strcmp("DESC", $options["order_direction"]) ? " DESC" : " ASC";
         }
         $query->order($orderString);
     }
     $this->db->setQuery($query);
     $results = $this->db->loadAssocList();
     if (!empty($results)) {
         foreach ($results as $result) {
             $type = new CrowdFundingType();
             $type->bind($result);
             $this->types[] = $type;
         }
     } else {
         $this->types = array();
     }
 }
Пример #2
0
 public function display($tpl = null)
 {
     // Get model state.
     $this->state = $this->get('State');
     $this->item = $this->get("Item");
     // Get params
     /** @var  $params Joomla\Registry\Registry */
     $params = $this->state->get("params");
     $this->params = $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 = CrowdFundingConstants::PAYMENT_SESSION_CONTEXT . $this->item->id;
     $paymentSession = $this->app->getUserState($this->paymentSessionContext);
     // Create payment session object.
     if (!$paymentSession) {
         $paymentSession = new JData();
         $paymentSession->step1 = false;
     }
     // Images
     $this->imageFolder = $this->params->get("images_directory", "images/crowdfunding");
     // Get currency
     jimport("crowdfunding.currency");
     $currencyId = $this->params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     // 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 params
     $params = JComponentHelper::getParams("com_crowdfunding");
     // Get wizard type
     $this->wizardType = $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)) {
         jimport("crowdfunding.type");
         $type = new CrowdFundingType(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();
     $this->version = new CrowdFundingVersion();
     parent::display($tpl);
 }
Пример #3
0
 /**
  * Check the system for debug mode
  */
 protected function prepareProjectType()
 {
     // Get project type and check for enabled rewards.
     $this->rewardsEnabled = true;
     if (!empty($this->item->type_id)) {
         jimport("crowdfunding.type");
         $type = new CrowdFundingType(JFactory::getDbo());
         $type->load($this->item->type_id);
         if ($type->getId() and !$type->isRewardsEnabled()) {
             $this->rewardsEnabled = false;
             $this->disabledButton = 'disabled="disabled"';
         }
     }
 }