public function __construct($config = array())
 {
     parent::__construct($config);
     $this->app = JFactory::getApplication();
     // Get project ID.
     $this->projectId = $this->input->getUint('pid');
     // Prepare log object.
     $this->log = new Prism\Log\Log();
     // Set database log adapter if Joomla! debug is enabled.
     if ($this->logTable !== null and $this->logTable !== '' and JDEBUG) {
         $this->log->addAdapter(new Prism\Log\Adapter\Database(\JFactory::getDbo(), $this->logTable));
     }
     // Set file log adapter.
     if ($this->logFile !== null and $this->logFile !== '') {
         $file = \JPath::clean($this->app->get('log_path') . DIRECTORY_SEPARATOR . basename($this->logFile));
         $this->log->addAdapter(new Prism\Log\Adapter\File($file));
     }
     // Prepare context
     $filter = new JFilterInput();
     $paymentService = $filter->clean(trim(strtolower($this->input->getCmd('payment_service'))), 'ALNUM');
     $this->context = Joomla\String\StringHelper::strlen($paymentService) > 0 ? 'com_crowdfunding.notify.' . $paymentService : 'com_crowdfunding.notify';
     // Prepare params
     $this->params = JComponentHelper::getParams('com_crowdfunding');
     // Prepare container and some of the most used objects.
     $this->container = Prism\Container::getContainer();
     $this->prepareCurrency($this->container, $this->params);
     $this->prepareMoneyFormatter($this->container, $this->params);
 }
 public function display($tpl = null)
 {
     $this->app = JFactory::getApplication();
     $this->option = $this->app->input->get('option');
     $userId = JFactory::getUser()->get('id');
     if (!$userId) {
         $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_NOT_LOG_IN'), 'notice');
         $this->app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
         return;
     }
     // Initialise variables
     $this->items = $this->get('Items');
     $this->state = $this->get('State');
     $this->params = $this->state->get('params');
     if (is_array($this->items) and count($this->items) > 0) {
         $container = Prism\Container::getContainer();
         $this->money = $this->getMoneyFormatter($container, $this->params);
     }
     // Prepare filters
     $this->listOrder = $this->escape($this->state->get('list.ordering'));
     $this->listDirn = $this->escape($this->state->get('list.direction'));
     $this->saveOrder = (bool) (strcmp($this->listOrder, 'a.ordering') !== 0);
     $this->dateFormat = $this->params->get('date_format_views', JText::_('DATE_FORMAT_LC3'));
     $this->prepareDocument();
     parent::display($tpl);
 }
 public function display($tpl = null)
 {
     $this->option = JFactory::getApplication()->input->getCmd('option');
     $container = Prism\Container::getContainer();
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     // Get params
     $this->params = $this->state->get('params');
     /** @var  $this->params Joomla\Registry\Registry */
     $this->numberInRow = (int) $this->params->get('featured_items_row', 3);
     $helperBus = new Prism\Helper\HelperBus($this->items);
     $helperBus->addCommand(new Crowdfunding\Helper\PrepareItemsHelper());
     $helperBus->handle();
     $this->displayCreator = (bool) $this->params->get('integration_display_creator', true);
     // Prepare integration. Load avatars and profiles.
     if ($this->displayCreator) {
         $userIds = Prism\Utilities\ArrayHelper::getIds($this->items, 'user_id');
         $this->socialProfiles = CrowdfundingHelper::prepareIntegration($this->params->get('integration_social_platform'), $userIds);
     }
     $this->layoutData = new stdClass();
     $this->layoutData->items = $this->items;
     $this->layoutData->params = $this->params;
     $this->layoutData->money = $this->getMoneyFormatter($container, $this->params);
     $this->layoutData->socialProfiles = $this->socialProfiles;
     $this->layoutData->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
     $this->prepareDocument();
     parent::display($tpl);
 }
 public function display($tpl = null)
 {
     $this->app = JFactory::getApplication();
     $this->option = JFactory::getApplication()->input->get('option');
     // Get model state.
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     // Get params
     $this->params = $this->state->get('params');
     /** @var  $this->params Joomla\Registry\Registry */
     $model = $this->getModel();
     $userId = JFactory::getUser()->get('id');
     if (!$this->item or $model->isRestricted($this->item, $userId)) {
         $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice');
         $this->app->redirect(JRoute::_('index.php?option=com_crowdfunding&view=discover', false));
         return;
     }
     $this->container = Prism\Container::getContainer();
     $this->prepareMoneyFormatter($this->container, $this->params);
     // Get the path to the images.
     $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
     $this->defaultAvatar = JUri::base() . $this->params->get('integration_avatars_default');
     $this->avatarsSize = $this->params->get('integration_avatars_size', 'small');
     // Prepare the link that points to project page.
     $host = JUri::getInstance()->toString(array('scheme', 'host'));
     $this->item->link = $host . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug));
     // Prepare the link that points to project image.
     $this->item->link_image = $host . '/' . $this->imageFolder . '/' . $this->item->image;
     // Get the current screen.
     $this->screen = $this->app->input->getCmd('screen', 'home');
     $this->prepareDocument();
     // Import content plugins
     JPluginHelper::importPlugin('content');
     switch ($this->screen) {
         case 'updates':
             $this->prepareUpdatesScreen();
             break;
         case 'comments':
             $this->prepareCommentsScreen();
             break;
         case 'funders':
             $this->prepareFundersScreen();
             break;
         default:
             // Home
             break;
     }
     // Events
     $dispatcher = JEventDispatcher::getInstance();
     $this->item->event = new stdClass();
     $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_crowdfunding.details', &$this->item, &$this->params));
     $this->item->event->beforeDisplayContent = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentAfterDisplayMedia', array('com_crowdfunding.details', &$this->item, &$this->params));
     $this->item->event->onContentAfterDisplayMedia = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentAfterDisplay', array('com_crowdfunding.details', &$this->item, &$this->params));
     $this->item->event->onContentAfterDisplay = trim(implode("\n", $results));
     // Count hits
     $model->hit($this->item->id);
     parent::display($tpl);
 }
Exemplo n.º 5
0
 /**
  * @param int $projectId
  * @param Joomla\Registry\Registry $params
  * @param stdClass $paymentSession
  *
  * @throws UnexpectedValueException
  * @throws InvalidArgumentException
  * @throws OutOfBoundsException
  * @throws RuntimeException
  *
  * @return stdClass
  */
 public function prepareItem($projectId, $params, $paymentSession)
 {
     $container = Prism\Container::getContainer();
     $containerHelper = new Crowdfunding\Container\Helper();
     $project = $containerHelper->fetchProject($container, $projectId);
     if (!$project->getId()) {
         throw new UnexpectedValueException(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'));
     }
     if ($project->isCompleted()) {
         throw new UnexpectedValueException(JText::_('COM_CROWDFUNDING_ERROR_COMPLETED_PROJECT'));
     }
     // Get currency
     $money = $containerHelper->fetchMoneyFormatter($container, $params);
     $currency = $money->getCurrency();
     $item = new stdClass();
     $item->id = $project->getId();
     $item->title = $project->getTitle();
     $item->slug = $project->getSlug();
     $item->catslug = $project->getCatSlug();
     $item->starting_date = $project->getFundingStart();
     $item->ending_date = $project->getFundingEnd();
     $item->user_id = $project->getUserId();
     $item->rewardId = $paymentSession->rewardId;
     $item->amount = $paymentSession->amount;
     $item->currencyCode = $currency->getCode();
     $item->amountFormated = $money->setAmount($item->amount)->format();
     $item->amountCurrency = $money->setAmount($item->amount)->formatCurrency();
     return $item;
 }
 public function display($tpl = null)
 {
     $this->app = JFactory::getApplication();
     /** @var $this->app JApplicationSite */
     $this->option = JFactory::getApplication()->input->get('option');
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     // Get params
     $this->params = $this->state->get('params');
     /** @var  $this->params Joomla\Registry\Registry */
     $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
     if (!$this->item) {
         $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice');
         $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false));
         return;
     }
     $container = Prism\Container::getContainer();
     $this->money = $this->getMoneyFormatter($container, $this->params);
     // Integrate with social profile.
     $this->displayCreator = $this->params->get('integration_display_creator', true);
     // Prepare integration. Load avatars and profiles.
     if ($this->displayCreator and (is_object($this->item) and $this->item->user_id > 0)) {
         $socialProfile = CrowdfundingHelper::prepareIntegration($this->params->get('integration_social_platform'), $this->item->user_id);
         $this->socialProfileLink = !$socialProfile ? null : $socialProfile->getLink();
     }
     // Set a link to project page
     $uri = JUri::getInstance();
     $host = $uri->toString(array('scheme', '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;
     $this->embedCode = $this->prepareEmbedCode($this->item, $host);
     $this->prepareDocument();
     parent::display($tpl);
 }
 public function display($tpl = null)
 {
     $this->app = JFactory::getApplication();
     $this->option = $this->app->input->get('option');
     $userId = JFactory::getUser()->get('id');
     if (!$userId) {
         $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_NOT_LOG_IN'), 'notice');
         $this->app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
         return;
     }
     $this->items = $this->get('Items');
     $this->state = $this->get('State');
     $this->pagination = $this->get('Pagination');
     $this->params = $this->state->get('params');
     /** @var  $params Joomla\Registry\Registry */
     if (is_array($this->items) and count($this->items) > 0) {
         $container = Prism\Container::getContainer();
         $this->money = $this->getMoneyFormatter($container, $this->params);
     }
     // 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;
     $this->userId = JFactory::getUser()->get('id');
     $this->redirectUrl = CrowdfundingHelperRoute::getTransactionsRoute();
     $this->prepareDocument();
     parent::display($tpl);
 }
Exemplo n.º 8
0
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @throws \OutOfBoundsException
  */
 protected function getInput()
 {
     // Initialize some field attributes.
     $size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
     $readonly = (string) $this->element['readonly'] === 'true' ? ' readonly="readonly"' : '';
     $disabled = (string) $this->element['disabled'] === 'true' ? ' disabled="disabled"' : '';
     $class = !empty($this->element['class']) ? ' class="' . (string) $this->element['class'] . '"' : '';
     $required = $this->required ? ' required aria-required="true"' : '';
     $cssLayout = !empty($this->element['css_layout']) ? (string) $this->element['css_layout'] : 'Bootstrap 2';
     // Initialize JavaScript field attributes.
     $onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     $params = JComponentHelper::getParams('com_crowdfunding');
     /** @var  $params Joomla\Registry\Registry */
     // Get the currency and money formatter from the container.
     $container = Prism\Container::getContainer();
     $containerHelper = new Crowdfunding\Container\Helper();
     $moneyFormatter = $containerHelper->fetchMoneyFormatter($container, $params);
     $moneyFormatter->setAmount($this->value);
     $currency = $moneyFormatter->getCurrency();
     $html = array();
     if ($cssLayout === 'Bootstrap 3') {
         $html[] = '<div class="input-group">';
         if ($currency->getSymbol()) {
             // Prepended
             $html[] = '<div class="input-group-addon">' . $currency->getSymbol() . '</div>';
         }
         $html[] = '<input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . $moneyFormatter->format() . '"' . $class . $size . $disabled . $readonly . $maxLength . $onchange . $required . '/>';
         // Prepend
         $html[] = '<div class="input-group-addon">' . $currency->getCode() . '</div>';
         $html[] = '</div>';
     } else {
         // Bootstrap 2
         if ($currency->getSymbol()) {
             // Prepended
             $html[] = '<div class="input-prepend input-append"><span class="add-on">' . $currency->getSymbol() . '</span>';
         } else {
             // Append
             $html[] = '<div class="input-append">';
         }
         $html[] = '<input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . $moneyFormatter->format() . '"' . $class . $size . $disabled . $readonly . $maxLength . $onchange . $required . '/>';
         // Appended
         $html[] = '<span class="add-on">' . $currency->getCode() . '</span></div>';
     }
     return implode("\n", $html);
 }
 public function display($tpl = null)
 {
     $container = Prism\Container::getContainer();
     $this->option = JFactory::getApplication()->input->getCmd('option');
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->params = $this->state->get('params');
     $this->prepareItems($this->items);
     // Prepare social integration.
     $showAuthor = CrowdfundingHelper::isShowAuthor($this->items, $this->params);
     if ($showAuthor) {
         $usersIds = Prism\Utilities\ArrayHelper::getIds($this->items, 'user_id');
         $this->socialProfiles = CrowdfundingHelper::prepareIntegration($this->params->get('integration_social_platform'), $usersIds);
     }
     $this->layoutData = new stdClass();
     $this->layoutData->items = $this->items;
     $this->layoutData->params = $this->params;
     $this->layoutData->money = $this->getMoneyFormatter($container, $this->params);
     $this->layoutData->socialProfiles = $this->socialProfiles;
     $this->layoutData->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
     $this->prepareDocument();
     parent::display($tpl);
 }
Exemplo n.º 10
0
 public function display($tpl = null)
 {
     $this->app = JFactory::getApplication();
     $this->option = JFactory::getApplication()->input->getCmd('option');
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     // Get params
     $this->params = $this->state->get('params');
     /** @var  $this->params Joomla\Registry\Registry */
     // Prepare subcategories.
     $this->displaySubcategories = (bool) $this->params->get('category_show_subcategories', Prism\Constants::DO_NOT_DISPLAY);
     if ($this->displaySubcategories) {
         $this->prepareSubcategories();
     }
     $this->prepareItems($this->items);
     $container = Prism\Container::getContainer();
     // Prepare social integration.
     $showAuthor = CrowdfundingHelper::isShowAuthor($this->items, $this->params);
     if ($showAuthor) {
         $usersIds = Prism\Utilities\ArrayHelper::getIds($this->items, 'user_id');
         $this->socialProfiles = CrowdfundingHelper::prepareIntegration($this->params->get('integration_social_platform'), $usersIds);
     }
     $this->layoutData = new stdClass();
     $this->layoutData->items = $this->items;
     $this->layoutData->params = $this->params;
     $this->layoutData->money = $this->getMoneyFormatter($container, $this->params);
     $this->layoutData->socialProfiles = $this->socialProfiles;
     $this->layoutData->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
     // Get current category
     $categoryId = $this->app->input->getInt('id');
     $categories = Crowdfunding\Categories::getInstance('crowdfunding');
     $this->item = $categories->get($categoryId);
     $this->prepareDocument();
     parent::display($tpl);
 }
jimport('Crowdfunding.init');
$moduleclassSfx = htmlspecialchars($params->get('moduleclass_sfx'));
$option = $app->input->get('option');
$view = $app->input->get('view');
$allowedViews = array('backing', 'embed', 'report', 'friendmail');
// If option is not 'com_crowdfunding' and view is not one of allowed,
// do not display anything.
if (strcmp($option, 'com_crowdfunding') !== 0 or !in_array($view, $allowedViews, true)) {
    echo JText::_('MOD_CROWDFUNDINGDETAILS_ERROR_INVALID_VIEW');
    return;
}
$projectId = $app->input->getInt('id');
if (!$projectId) {
    return;
}
$container = Prism\Container::getContainer();
/** @var  $container Joomla\DI\Container */
$containerHelper = new Crowdfunding\Container\Helper();
// Get Project object from the container.
$project = $containerHelper->fetchProject($container, $projectId);
if (!$project->getId()) {
    return;
}
// Get component params
$componentParams = JComponentHelper::getParams('com_crowdfunding');
/** @var  $componentParams Joomla\Registry\Registry */
$money = $containerHelper->fetchMoneyFormatter($container, $componentParams);
$socialPlatform = $componentParams->get('integration_social_platform');
$imageFolder = $componentParams->get('images_directory', 'images/crowdfunding');
$imageWidth = $componentParams->get('image_width', 200);
$imageHeight = $componentParams->get('image_height', 200);
Exemplo n.º 12
0
 protected function prepareManager()
 {
     $model = JModelLegacy::getInstance('Manager', 'CrowdfundingModel', $config = array('ignore_request' => false));
     /** @var $model CrowdfundingModelManager */
     // Get state
     $this->state = $model->getState();
     /** @var  $state Joomla\Registry\Registry */
     $this->imageWidth = $this->params->get('image_width', 200);
     $this->imageHeight = $this->params->get('image_height', 200);
     $this->titleLength = $this->params->get('discover_title_length', 0);
     $this->descriptionLength = $this->params->get('discover_description_length', 0);
     // Get the folder with images
     $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
     // Filter the URL.
     $uri = JUri::getInstance();
     $filter = JFilterInput::getInstance();
     $this->returnUrl = $filter->clean($uri->toString());
     // Get item
     $itemId = $this->state->get('manager.id');
     // Get money formatter.
     $container = Prism\Container::getContainer();
     $this->money = $this->getMoneyFormatter($container, $this->params);
     $this->item = $model->getItem($itemId, $this->userId);
     // Check if the item exists.
     if (!CrowdfundingHelper::isAuthorized($this->userId, $this->item, 'manager')) {
         $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_SOMETHING_WRONG'), 'notice');
         $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute()));
         return;
     }
     $statistics = new Crowdfunding\Statistics\Project(JFactory::getDbo(), $this->item->id);
     $this->statistics = array('updates' => $statistics->getUpdatesNumber(), 'comments' => $statistics->getCommentsNumber(), 'funders' => $statistics->getTransactionsNumber());
     // Get rewards
     $this->rewards = new Crowdfunding\Rewards(JFactory::getDbo());
     $this->rewards->load(array('project_id' => $this->item->id));
     $this->pathwayName = JText::_('COM_CROWDFUNDING_STEP_MANAGER');
 }
Exemplo n.º 13
0
 public function display($tpl = null)
 {
     $this->app = JFactory::getApplication();
     $this->option = $this->app->input->get('option');
     $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;
     }
     $this->container = Prism\Container::getContainer();
     $this->prepareCurrency($this->container, $this->params);
     $this->prepareMoneyFormatter($this->container, $this->params);
     // Create an object that will contain the data during the payment process.
     $this->paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $this->item->id;
     $paymentSessionLocal = $this->app->getUserState($this->paymentSessionContext);
     // Create payment session object.
     if (!$paymentSessionLocal or !isset($paymentSessionLocal->step1)) {
         $paymentSessionLocal = $this->createPaymentSession();
     }
     // Images
     $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
     // Get money formatter.
     $this->money = $this->getMoneyFormatter($this->container, $this->params);
     $this->currency = $this->money->getCurrency();
     // 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;
     // Import 'crowdfundingpayment' plugins.
     JPluginHelper::importPlugin('crowdfundingpayment');
     $this->layout = $this->getLayout();
     switch ($this->layout) {
         case 'step2':
             // Step 2 on wizard in four steps.
             $this->prepareStep2();
             break;
         case 'payment':
             // Step 2
             $paymentSessionLocal = $this->preparePayment($paymentSessionLocal);
             break;
         case 'share':
             // Step 3
             $paymentSessionLocal = $this->prepareShare($paymentSessionLocal);
             break;
         default:
             //  Step 1 ( Rewards )
             $paymentSessionLocal = $this->prepareRewards($paymentSessionLocal);
             break;
     }
     // Get project type and check for enabled rewards.
     $this->rewardsEnabled = CrowdfundingHelper::isRewardsEnabled($this->item->id);
     // Check days left. If there is no days, disable the button.
     $this->disabledButton = '';
     if (!$this->item->days_left) {
         $this->disabledButton = 'disabled="disabled"';
     }
     // Prepare the data of the layout
     $this->layoutData = new JData(array('layout' => $this->layout, 'item' => $this->item, 'paymentSession' => $paymentSessionLocal, 'rewards_enabled' => $this->rewardsEnabled));
     $this->prepareDebugMode($paymentSessionLocal);
     $this->prepareDocument();
     $this->paymentSession = $paymentSessionLocal;
     // Store the new values of the payment process to the user session.
     $this->app->setUserState($this->paymentSessionContext, $paymentSessionLocal);
     parent::display($tpl);
 }
 public static function isRewardsEnabled($projectId)
 {
     // Check for enabled rewards by component options.
     $componentParams = JComponentHelper::getParams('com_crowdfunding');
     if (!$componentParams->get('rewards_enabled', 1)) {
         return false;
     }
     $container = Prism\Container::getContainer();
     /** @var  $container Joomla\DI\Container */
     $containerHelper = new Crowdfunding\Container\Helper();
     // Get Project object from the container.
     $project = $containerHelper->fetchProject($container, $projectId);
     $type = $project->getType();
     if ($type === null) {
         return true;
     }
     return (bool) ($type instanceof Crowdfunding\Type and $type->isRewardsEnabled());
 }