Esempio n. 1
0
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->params = $this->state->get("params");
     jimport("crowdfunding.currency");
     $currencyId = $this->state->params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     // Get projects IDs
     $projectsIds = array();
     foreach ($this->items as $item) {
         $projectsIds[] = $item->id;
     }
     // Get number of rewards.
     jimport("crowdfunding.projects");
     $projects = new CrowdFundingProjects(JFactory::getDbo());
     $this->rewards = $projects->getRewardsNumber($projectsIds);
     // Add submenu
     CrowdFundingHelper::addSubmenu($this->getName());
     // Prepare sorting data
     $this->prepareSorting();
     // Prepare actions
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
Esempio n. 2
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->form = $this->get('Form');
     $this->importType = $this->state->get("import.context");
     switch ($this->importType) {
         case "locations":
             $this->legend = JText::_("COM_CROWDFUNDING_IMPORT_LOCATIONS_DATA");
             $this->uploadTask = "import.locations";
             break;
         case "countries":
             $this->legend = JText::_("COM_CROWDFUNDING_IMPORT_COUNTRIES_DATA");
             $this->uploadTask = "import.countries";
             break;
         case "states":
             $this->legend = JText::_("COM_CROWDFUNDING_IMPORT_STATES_DATA");
             $this->uploadTask = "import.states";
             break;
         default:
             // Currencies
             $this->legend = JText::_("COM_CROWDFUNDING_IMPORT_CURRENCY_DATA");
             $this->uploadTask = "import.currencies";
             break;
     }
     // Add submenu
     CrowdFundingHelper::addSubmenu($this->importType);
     // Prepare actions
     $this->addToolbar();
     $this->setDocument();
     parent::display($tpl);
 }
Esempio n. 3
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. 4
0
 /**
  * Method to get the data that should be injected in the form.
  *
  * @return    mixed    The data for the form.
  * @since    1.6
  */
 protected function loadFormData()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $data = $app->getUserState($this->option . '.edit.funding.data', array());
     if (!$data) {
         $itemId = (int) $this->getState($this->getName() . '.id');
         $userId = JFactory::getUser()->get("id");
         $data = $this->getItem($itemId, $userId);
         // Prepare date format.
         $dateFormat = CrowdFundingHelper::getDateFormat();
         $dateValidator = new ITPrismValidatorDate($data->funding_end);
         // Validate end date. If the date is not valid, generate a valid one.
         // Use minimum allowed days to generate end funding date.
         if (!$dateValidator->isValid()) {
             // Get minimum days.
             $params = $this->getState("params");
             $minDays = $params->get("project_days_minimum", 30);
             // Generate end date.
             $today = new CrowdFundingDate();
             $fundingEndDate = $today->calculateEndDate($minDays);
             $data->funding_end = $fundingEndDate->format("Y-m-d");
         }
         $date = new JDate($data->funding_end);
         $data->funding_end = $date->format($dateFormat);
     }
     return $data;
 }
Esempio n. 5
0
 /**
  * Pre-processor for $table->delete($pk)
  *
  * @param   mixed $pk An optional primary key value to delete.  If not set the instance property value is used.
  *
  * @return  void
  *
  * @since   3.1.2
  * @throws  UnexpectedValueException
  */
 public function onBeforeDelete($pk)
 {
     $userId = CrowdFundingHelper::getUserIdByRewardId($this->table->id);
     $imagesFolder = CrowdFundingHelper::getImagesFolder($userId);
     // Remove image.
     if (!empty($this->table->image)) {
         $fileSource = $imagesFolder . DIRECTORY_SEPARATOR . $this->table->image;
         if (JFile::exists($fileSource)) {
             JFile::delete($fileSource);
         }
     }
     // Remove thumbnail.
     if (!empty($this->table->image_thumb)) {
         $fileSource = $imagesFolder . DIRECTORY_SEPARATOR . $this->table->image_thumb;
         if (JFile::exists($fileSource)) {
             JFile::delete($fileSource);
         }
     }
     // Remove square image.
     if (!empty($this->table->image_square)) {
         $fileSource = $imagesFolder . DIRECTORY_SEPARATOR . $this->table->image_square;
         if (JFile::exists($fileSource)) {
             JFile::delete($fileSource);
         }
     }
 }
Esempio n. 6
0
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->params = $this->state->get("params");
     // Get currencies
     foreach ($this->items as $item) {
         $currencies[] = $item->txn_currency;
         $currencies = array_unique($currencies);
     }
     if (!empty($currencies)) {
         jimport("crowdfunding.currencies");
         $this->currencies = new CrowdFundingCurrencies(JFactory::getDbo());
         $this->currencies->loadByAbbr($currencies);
     }
     // Get enabled specefic plugins.
     jimport("itprism.extensions");
     $extensions = new ITPrismExtensions(JFactory::getDbo(), $this->speceficPlugins);
     $this->enabledSpeceficPlugins = $extensions->getEnabled();
     // Add submenu
     CrowdFundingHelper::addSubmenu($this->getName());
     // Prepare sorting data
     $this->prepareSorting();
     // Prepare actions
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
Esempio n. 7
0
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     // Add submenu
     CrowdFundingHelper::addSubmenu($this->getName());
     // Prepare sorting data
     $this->prepareSorting();
     // Prepare actions
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
Esempio n. 8
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. 9
0
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     // Get log files and count them.
     jimport("crowdfunding.log.files");
     $logFiles = new CrowdFundingLogFiles($this->includeFiles);
     $logFiles->load();
     $this->numberLogFilse = count($logFiles);
     // Add submenu
     CrowdFundingHelper::addSubmenu($this->getName());
     // Prepare sorting data
     $this->prepareSorting();
     // Prepare actions
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
Esempio n. 10
0
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->params = $this->state->get("params");
     jimport("crowdfunding.currency");
     $currencyId = $this->state->params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     // Add submenu
     CrowdFundingHelper::addSubmenu("projects");
     $projectId = $this->state->get("project_id");
     $this->projectTitle = CrowdFundingHelper::getProjectTitle($projectId);
     // Prepare sorting data
     $this->prepareSorting();
     // Prepare actions
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
Esempio n. 11
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);
 }
Esempio n. 12
0
 public function display($tpl = null)
 {
     $this->state = $this->get("State");
     $this->params = $this->state->get("params");
     $this->version = new CrowdFundingVersion();
     // Load ITPrism library version
     jimport("itprism.version");
     if (!class_exists("ITPrismVersion")) {
         $this->itprismVersion = JText::_("COM_CROWDFUNDING_ITPRISM_LIBRARY_DOWNLOAD");
     } else {
         $itprismVersion = new ITPrismVersion();
         $this->itprismVersion = $itprismVersion->getShortVersion();
     }
     // Get popular projects.
     jimport("crowdfunding.statistics.projects.popular");
     $this->popular = new CrowdFundingStatisticsProjectsPopular(JFactory::getDbo());
     $this->popular->load(5);
     // Get popular most funded.
     jimport("crowdfunding.statistics.projects.mostfunded");
     $this->mostFunded = new CrowdFundingStatisticsProjectsMostFunded(JFactory::getDbo());
     $this->mostFunded->load(5);
     // Get latest started.
     jimport("crowdfunding.statistics.projects.latest");
     $this->latestStarted = new CrowdFundingStatisticsProjectsLatest(JFactory::getDbo());
     $this->latestStarted->load(5);
     // Get latest created.
     $this->latestCreated = new CrowdFundingStatisticsProjectsLatest(JFactory::getDbo());
     $this->latestCreated->loadByCreated(5);
     // Get currency.
     jimport("crowdfunding.currency");
     $currencyId = $this->params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     // Add submenu
     CrowdFundingHelper::addSubmenu($this->getName());
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
Esempio n. 13
0
 /**
  * Deletes extra image.
  */
 public function removeExtraImage()
 {
     jimport("itprism.response.json");
     $response = new ITPrismResponseJson();
     $userId = $this->input->post->getInt("user_id");
     $imageId = $this->input->post->getInt("id");
     // Get the folder where the images are stored.
     $imagesFolder = CrowdFundingHelper::getImagesFolder($userId);
     try {
         jimport('joomla.filesystem.file');
         // Get the model
         $model = $this->getModel();
         $model->removeExtraImage($imageId, $imagesFolder);
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         $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_DELETED'))->setData(array("item_id" => $imageId))->success();
     echo $response;
     JFactory::getApplication()->close();
 }
Esempio n. 14
0
 * @subpackage   Components
 * @author       Todor Iliev
 * @copyright    Copyright (C) 2014 Todor Iliev <*****@*****.**>. All rights reserved.
 * @license      http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
// no direct access
defined('_JEXEC') or die;
?>
<div class="row-fluid">
    <ul class="thumbnails">
      <?php 
if (isset($this->item)) {
    $raised = $this->currency->getAmountString($this->item->funded);
    $fundedPercents = JHtml::_("crowdfunding.funded", $this->item->funded_percents);
    // Get social platform and a link to the profile
    $socialProfile = CrowdFundingHelper::getSocialProfile($this->item->user_id, $this->socialPlatform);
    $socialProfileLink = !$socialProfile ? null : $socialProfile->getLink();
    ?>
      <li class="span12">
        <div class="thumbnail">
          <img src="<?php 
    echo $this->item->link_image;
    ?>
" alt="<?php 
    echo $this->item->title;
    ?>
" width="200" height="200">
          <div class="caption">
            <h3><a href="<?php 
    echo JRoute::_(CrowdFundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug));
    ?>
Esempio n. 15
0
 /**
  * Method to remove image via AJAX.
  *
  * @throws  Exception
  *
  * @return  void
  */
 public function removeImage()
 {
     // Get the input
     $rewardId = $this->input->post->get('rid', 0, 'int');
     $userId = JFactory::getUser()->get("id");
     jimport("itprism.response.json");
     $response = new ITPrismResponseJson();
     // Validate user
     if (!$userId) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_NOT_LOG_IN'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     $params = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $params Joomla\Registry\Registry */
     if (!$params->get("rewards_images", 0)) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_INVALID_REWARD'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     // Validate reward owner.
     jimport("crowdfunding.validator.reward.owner");
     $validator = new CrowdFundingValidatorRewardOwner(JFactory::getDbo(), $rewardId, $userId);
     if (!$rewardId or !$validator->isValid()) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_INVALID_REWARD'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     // Get the model
     $model = $this->getModel();
     try {
         // Get the folder where the images will be stored
         $imagesFolder = CrowdFundingHelper::getImagesFolder($userId);
         $model->removeImage($rewardId, $imagesFolder);
     } catch (RuntimeException $e) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText($e->getMessage())->failure();
         echo $response;
         JFactory::getApplication()->close();
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         $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_REWARD_IMAGE_REMOVED_SUCCESSFULLY'))->success();
     echo $response;
     JFactory::getApplication()->close();
 }
Esempio n. 16
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");
    }
Esempio n. 17
0
 /**
  * Delete image
  */
 public function removeImage()
 {
     // Check for request forgeries.
     JSession::checkToken("get") or jexit(JText::_('JINVALID_TOKEN'));
     // Get item id
     $itemId = $this->input->get->getInt("id");
     $redirectOptions = array("view" => "reward", "layout" => "edit", "id" => $itemId);
     // Create an reward object.
     jimport("crowdfunding.reward");
     $reward = new CrowdFundingReward(JFactory::getDbo());
     $reward->load($itemId);
     // Check for registered user
     if (!$reward->getId()) {
         $this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_INVALID_IMAGE'), $redirectOptions);
         return;
     }
     $imagesFolder = CrowdFundingHelper::getImagesFolder($reward->getUserId());
     try {
         jimport('joomla.filesystem.folder');
         jimport('joomla.filesystem.file');
         jimport('joomla.filesystem.path');
         $model = $this->getModel();
         $model->removeImage($itemId, $imagesFolder);
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     $this->displayMessage(JText::_('COM_CROWDFUNDING_IMAGE_DELETED'), $redirectOptions);
 }
Esempio n. 18
0
 /**
  * Delete an extra image.
  *
  */
 public function removeExtraImage()
 {
     // Create response object
     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();
     }
     // Get image ID.
     $imageId = $this->input->post->get("id");
     // Get the folder where the images are stored.
     $imagesFolder = CrowdFundingHelper::getImagesFolder($userId);
     try {
         // Get the model
         $model = $this->getModel();
         /** @var $model CrowdFundingModelStory */
         $model->removeExtraImage($imageId, $imagesFolder, $userId);
     } catch (RuntimeException $e) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception($e->getMessage());
     }
     $response->setTitle(JText::_('COM_CROWDFUNDING_SUCCESS'))->setText(JText::_('COM_CROWDFUNDING_IMAGE_DELETED'))->setData(array("item_id" => $imageId))->success();
     echo $response;
     JFactory::getApplication()->close();
 }
if (!$projectId) {
    echo JText::_("MOD_CROWDFUNDINGDETAILS_ERROR_INVALID_PROJECT");
    return;
}
// Get project
jimport("crowdfunding.project");
$project = CrowdFundingProject::getInstance(JFactory::getDbo(), $projectId);
if (!$project->getId()) {
    echo JText::_("MOD_CROWDFUNDINGDETAILS_ERROR_INVALID_PROJECT");
    return;
}
// Get component params
$componentParams = JComponentHelper::getParams("com_crowdfunding");
/** @var  $componentParams Joomla\Registry\Registry */
$socialPlatform = $componentParams->get("integration_social_platform");
$imageFolder = $componentParams->get("images_directory", "images/crowdfunding");
// Get currency
jimport("crowdfunding.currency");
$currencyId = $componentParams->get("project_currency");
$currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $componentParams);
// Get social platform and a link to the profile
jimport("itprism.integrate.profile." . JString::strtolower($socialPlatform));
$socialProfile = CrowdFundingHelper::getSocialProfile($project->getUserId(), $socialPlatform);
$socialProfileLink = !$socialProfile ? null : $socialProfile->getLink();
// Get amounts
$fundedAmount = $currency->getAmountString($project->getGoal());
$raised = $currency->getAmountString($project->getFunded());
// Prepare the value that I am going to display
$fundedPercents = JHtml::_("crowdfunding.funded", $project->getFundedPercent());
$user = JFactory::getUser($project->getUserId());
require JModuleHelper::getLayoutPath('mod_crowdfundingdetails', $params->get('layout', 'default'));
Esempio n. 20
0
 public function save()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $userId = JFactory::getUser()->id;
     if (!$userId) {
         $redirectOptions = array("force_direction" => "index.php?option=com_users&view=login");
         $this->displayNotice(JText::_("COM_CROWDFUNDING_ERROR_NOT_LOG_IN"), $redirectOptions);
         return;
     }
     $params = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $params Joomla\Registry\Registry */
     // Get the data from the form POST
     $data = $this->input->post->get('rewards', array(), 'array');
     $projectId = $this->input->post->get('id', 0, 'int');
     $actionSubmit = $this->input->post->getCmd('btn_submit', 'save');
     $images = $this->input->files->get('images', array(), 'array');
     $userId = JFactory::getUser()->get("id");
     // Get wizard type
     $wizardType = $params->get("project_wizard_type", "five_steps");
     $fiveStepsWizard = strcmp($wizardType, "five_steps") == 0 ? true : false;
     // If it is five steps wizard type, redirect to manager.
     // If it is six steps wizard type, redirect to extras.
     if (!$fiveStepsWizard) {
         $layout = strcmp($actionSubmit, "save_continue") == 0 ? "extras" : "rewards";
     } else {
         $layout = strcmp($actionSubmit, "save_continue") == 0 ? "manager" : "rewards";
     }
     $redirectOptions = array("view" => "project", "layout" => $layout, "id" => $projectId);
     // Validate project owner.
     jimport("crowdfunding.validator.project.owner");
     $validator = new CrowdFundingValidatorProjectOwner(JFactory::getDbo(), $projectId, $userId);
     if (!$projectId or !$validator->isValid()) {
         $this->displayWarning(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), $redirectOptions);
         return;
     }
     $model = $this->getModel();
     /** @var $model CrowdFundingModelRewards */
     try {
         $validData = $model->validate($data);
         $rewardsIds = $model->save($validData, $projectId);
         $imagesAllowed = $params->get("rewards_images", 0);
         // Upload images.
         if ($imagesAllowed and !empty($images) and !empty($rewardsIds)) {
             // Get the folder where the images will be stored
             $imagesFolder = CrowdFundingHelper::getImagesFolder($userId);
             jimport("joomla.filesystem.folder");
             if (!JFolder::exists($imagesFolder)) {
                 CrowdFundingHelper::createFolder($imagesFolder);
             }
             $images = $model->uploadImages($images, $imagesFolder, $rewardsIds);
             if (!empty($images)) {
                 $model->storeImages($images, $imagesFolder);
             }
         }
     } catch (InvalidArgumentException $e) {
         $this->displayWarning($e->getMessage(), $redirectOptions);
         return;
     } catch (RuntimeException $e) {
         $this->displayWarning($e->getMessage(), $redirectOptions);
         return;
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     // Redirect to next page
     $this->displayMessage(JText::_("COM_CROWDFUNDING_REWARDS_SUCCESSFULLY_SAVED"), $redirectOptions);
 }
Esempio n. 21
0
 public function onContentBeforeDisplay($context, &$article, &$params, $page = 0)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     if ($app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml * */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     if (strcmp("com_crowdfunding.details", $context) != 0) {
         return null;
     }
     // Load language
     $this->loadLanguage();
     $itemId = $app->input->getInt("id");
     $stats = CrowdFundingHelper::getProjectData($itemId);
     $screen = $app->input->getCmd("screen", "home");
     $html = '<ul class="nav nav-pills cf-plg-navigation">';
     if ($this->params->get("display_home")) {
         $class = 'class="cf-plg-nav-home';
         if (strcmp($screen, "home") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdFundingHelperRoute::getDetailsRoute($article->slug, $article->catslug)) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_HOME") . "</a></li>";
     }
     if ($this->params->get("display_updates")) {
         $class = 'class="cf-plg-nav-updates';
         if (strcmp($screen, "updates") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         $stat = '<span class="label">' . JArrayHelper::getValue($stats, "updates", 0) . '</span>';
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdFundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "updates")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_UPDATES") . ' ' . $stat . '</a></li>';
     }
     if ($this->params->get("display_comments")) {
         $class = 'class="cf-plg-nav-comments';
         if (strcmp($screen, "comments") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         if (!$params->get("comments_enabled", 1)) {
             $stat = '<span class="cf-dclabel">&nbsp;</span>';
         } else {
             $stat = '<span class="label">' . JArrayHelper::getValue($stats, "comments", 0) . '</span>';
         }
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdFundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "comments")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_COMMENTS") . ' ' . $stat . '</a></li>';
     }
     if ($this->params->get("display_funders")) {
         $class = 'class="cf-plg-nav-funders';
         if (strcmp($screen, "funders") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         $stat = '<span class="label">' . JArrayHelper::getValue($stats, "funders", 0) . '</span>';
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdFundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "funders")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_FUNDERS") . ' ' . $stat . '</a></li>';
     }
     $html .= '</ul>';
     return $html;
 }
    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);