Esempio n. 1
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     // Prepare parameters
     $params = $this->state->get("params");
     /** @var $params Joomla\Registry\Registry */
     $this->params = $params;
     $imagesFolder = $this->params->get("images_directory", "images/crowdfunding");
     $this->imagesUrl = JUri::root() . $imagesFolder;
     // Set minimum values - days, amount,...
     $this->minAmount = $this->params->get("project_amount_minimum", 100);
     $this->maxAmount = $this->params->get("project_amount_maximum");
     $this->minDays = $this->params->get("project_days_minimum", 30);
     $this->maxDays = $this->params->get("project_days_maximum");
     $this->prepareFundingDurationType();
     jimport("crowdfunding.images");
     $this->extraImages = new CrowdFundingImages(JFactory::getDbo());
     $this->extraImages->load($this->item->id);
     $this->extraImagesUri = "../" . CrowdFundingHelper::getImagesFolderUri($this->item->user_id);
     // Prepare actions, behaviors, scripts and document
     $this->addToolbar();
     $this->setDocument();
     parent::display($tpl);
 }
Esempio n. 2
0
 public function addExtraImage()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     jimport("itprism.response.json");
     $response = new ITPrismResponseJson();
     $userId = JFactory::getUser()->get("id");
     if (!$userId) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_NOT_LOG_IN'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     $projectId = $this->input->post->get("id");
     // Get the model
     $model = $this->getModel();
     /** @var $model CrowdFundingModelStory * */
     // Validate project owner.
     jimport("crowdfunding.validator.project.owner");
     $validator = new CrowdFundingValidatorProjectOwner(JFactory::getDbo(), $projectId, $userId);
     if (!$projectId or !$validator->isValid()) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     $files = $this->input->files->get("files");
     if (!$files) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_FILE_CANT_BE_UPLOADED'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     // Get component parameters
     $params = $app->getParams("com_crowdfunding");
     /** @var  $params Joomla\Registry\Registry */
     // Prepare the size of additional thumbnails
     $thumbWidth = $params->get("extre_image_thumb_width", 100);
     $thumbHeight = $params->get("extre_image_thumb_height", 100);
     if ($thumbWidth < 25 or $thumbHeight < 25) {
         $thumbWidth = 50;
         $thumbHeight = 50;
     }
     $scale = $app->input->post->get("extra_images_thumb_scale", JImage::SCALE_INSIDE);
     $images = array();
     try {
         // Get the folder where the images will be stored
         $destination = CrowdFundingHelper::getImagesFolder($userId);
         $options = array("thumb_width" => $thumbWidth, "thumb_height" => $thumbHeight, "thumb_scale" => $scale, "destination" => $destination);
         // Get the folder where the images will be stored
         $imagesUri = CrowdFundingHelper::getImagesFolderUri($userId);
         $images = $model->uploadExtraImages($files, $options);
         $images = $model->storeExtraImage($images, $projectId, $imagesUri);
     } catch (Exception $e) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     $response->setTitle(JText::_('COM_CROWDFUNDING_SUCCESS'))->setText(JText::_('COM_CROWDFUNDING_IMAGE_SAVED'))->setData($images)->success();
     echo $response;
     JFactory::getApplication()->close();
 }
Esempio n. 3
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Get user ID.
     $this->userId = JFactory::getUser()->get("id");
     // Get reward ID.
     $rewardId = $app->input->getInt("id");
     // Validate reward owner
     jimport("crowdfunding.validator.reward.owner");
     $validator = new CrowdFundingValidatorRewardOwner(JFactory::getDbo(), $rewardId, $this->userId);
     if (!$validator->isValid()) {
         $app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_INVALID_REWARD"), "notice");
         $app->redirect(JRoute::_(CrowdFundingHelperRoute::getDiscoverRoute()));
         return;
     }
     $this->items = $this->get('Items');
     $this->state = $this->get('State');
     $this->pagination = $this->get('Pagination');
     // Get params
     /** @var  $params Joomla\Registry\Registry */
     $params = $this->state->get("params");
     $this->params = $params;
     // Prepare an URL where user will be redirected when change the state of a reward.
     $this->redirectUrl = "index.php?option=com_crowdfunding&view=reward&id=" . $rewardId;
     // Prepare filters
     $this->listOrder = $this->escape($this->state->get('list.ordering'));
     $this->listDirn = $this->escape($this->state->get('list.direction'));
     $this->saveOrder = strcmp($this->listOrder, 'a.ordering') != 0 ? false : true;
     // Load reward data.
     jimport("crowdfunding.reward");
     $this->reward = new CrowdFundingReward(JFactory::getDbo());
     $this->reward->load($rewardId);
     // Prepare reward delivery date.
     $dateValidator = new ITPrismValidatorDate($this->reward->getDeliveryDate());
     $this->deliveryDate = $dateValidator->isValid() ? JHtml::_('date', $this->reward->getDeliveryDate(), JText::_('DATE_FORMAT_LC3')) : "--";
     // Get images folder.
     $this->imagesFolder = CrowdFundingHelper::getImagesFolderUri($this->userId);
     // Get social profile
     $socialPlatform = $this->params->get("integration_social_platform");
     if (!empty($socialPlatform)) {
         $this->prepareSocialIntegration($socialPlatform);
     }
     $this->prepareDocument();
     $this->version = new CrowdFundingVersion();
     parent::display($tpl);
 }
Esempio n. 4
0
 protected function prepareDefaultLayout()
 {
     jimport("crowdfunding.user.rewards");
     $this->rewards = new CrowdFundingUserRewards(JFactory::getDbo());
     $this->rewards->loadByRewardId($this->item->id);
     $this->rewardOwnerId = CrowdFundingHelper::getUserIdByRewardId($this->item->id);
     $dateValidator = new ITPrismValidatorDate($this->item->delivery);
     $this->deliveryDate = $dateValidator->isValid() ? JHtml::_('date', $this->item->delivery, JText::_('DATE_FORMAT_LC3')) : "--";
     $this->imagesFolder = CrowdFundingHelper::getImagesFolderUri($this->rewardOwnerId);
     // Get social profile
     $socialPlatform = $this->params->get("integration_social_platform");
     if (!empty($socialPlatform)) {
         $options = array("social_platform" => $socialPlatform, "user_id" => $this->rewardOwnerId);
         jimport("itprism.integrate.profile.builder");
         $profileBuilder = new ITPrismIntegrateProfileBuilder($options);
         $profileBuilder->build();
         $this->socialProfile = $profileBuilder->getProfile();
         $this->profileLink = $this->socialProfile->getLink();
     }
     $this->returnUrl = base64_encode("index.php?option=com_crowdfunding&view=reward&id=" . $this->item->id);
 }
    return;
}
$componentParams = JComponentHelper::getParams("com_crowdfunding");
/** @var  $componentParams Joomla\Registry\Registry */
// Get currency
jimport("crowdfunding.currency");
$currencyId = $componentParams->get("project_currency");
$currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $componentParams);
jimport("crowdfunding.project");
jimport("crowdfunding.rewards");
$project = CrowdFundingProject::getInstance(JFactory::getDbo(), $projectId);
$rewards = $project->getRewards(array("state" => 1));
$layout = $params->get('layout', 'default');
switch ($layout) {
    case "_:square":
    case "_:thumbnail":
        // Get the folder where the images are saved.
        $userId = $project->getUserId();
        $rewardsImagesUri = CrowdFundingHelper::getImagesFolderUri($userId);
        JHtml::_("crowdfunding.jquery_fancybox");
        $js = '
jQuery(document).ready(function() {
    jQuery("a.js-rewards-images-gallery").fancybox();
});';
        $doc = JFactory::getDocument();
        $doc->addScriptDeclaration($js);
        break;
    default:
        break;
}
require JModuleHelper::getLayoutPath('mod_crowdfundingrewards', $layout);
Esempio n. 6
0
    protected function prepareRewards()
    {
        $model = JModelLegacy::getInstance("Rewards", "CrowdFundingModel", $config = array('ignore_request' => false));
        // Initialise variables
        // Get state
        /** @var  $state Joomla\Registry\Registry */
        $state = $model->getState();
        $this->state = $state;
        // Get params
        /** @var  $params Joomla\Registry\Registry */
        $params = $this->state->get("params");
        $this->params = $params;
        $this->projectId = $this->state->get("rewards.id");
        $this->items = $model->getItems($this->projectId);
        // Get project and validate it
        jimport("crowdfunding.project");
        $project = CrowdFundingProject::getInstance(JFactory::getDbo(), $this->projectId);
        $project = $project->getProperties();
        $this->item = JArrayHelper::toObject($project);
        if (!$this->item->id or $this->item->user_id != $this->userId) {
            throw new Exception(JText::_("COM_CROWDFUNDING_ERROR_INVALID_PROJECT"));
        }
        // Create a currency object.
        jimport("crowdfunding.currency");
        $currencyId = $this->params->get("project_currency");
        $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
        // Get date format
        $this->dateFormat = CrowdFundingHelper::getDateFormat();
        $this->dateFormatCalendar = CrowdFundingHelper::getDateFormat(true);
        $js = '
	        // Rewards calendar date format.
            var projectWizard = {
                dateFormat: "' . $this->dateFormatCalendar . '"
            };
        ';
        $this->document->addScriptDeclaration($js);
        // Prepare rewards images.
        $this->rewardsImagesEnabled = $this->params->get("rewards_images", 0);
        $this->rewardsImagesUri = CrowdFundingHelper::getImagesFolderUri($this->userId);
        $this->prepareProjectType();
        $this->pathwayName = JText::_("COM_CROWDFUNDING_STEP_REWARDS");
    }