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);
 }
Ejemplo n.º 2
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->app = JFactory::getApplication();
     // Get project id.
     $this->projectId = $this->input->getUint('pid');
     // Prepare log object
     $registry = Joomla\Registry\Registry::getInstance('com_crowdfunding');
     /** @var  $registry Joomla\Registry\Registry */
     $fileName = $registry->get('logger.file');
     $tableName = $registry->get('logger.table');
     $file = JPath::clean($this->app->get('log_path') . DIRECTORY_SEPARATOR . $fileName);
     $this->log = new Prism\Log\Log();
     $this->log->addAdapter(new Prism\Log\Adapter\Database(JFactory::getDbo(), $tableName));
     $this->log->addAdapter(new Prism\Log\Adapter\File($file));
     // Create an object that contains a data used during the payment process.
     $this->paymentProcessContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $this->projectId;
     $this->paymentProcess = $this->app->getUserState($this->paymentProcessContext);
     // Prepare context
     $filter = new JFilterInput();
     $paymentService = JString::trim(JString::strtolower($this->input->getCmd('payment_service')));
     $paymentService = $filter->clean($paymentService, 'ALNUM');
     $this->context = JString::strlen($paymentService) > 0 ? 'com_crowdfunding.notify.' . $paymentService : 'com_crowdfunding.notify';
     // Prepare params
     $this->params = JComponentHelper::getParams('com_crowdfunding');
 }
Ejemplo n.º 3
0
 private function preparePageTitle()
 {
     // Prepare page title
     $title = $this->item->title;
     switch ($this->screen) {
         case 'updates':
             $title .= ' | ' . JText::_('COM_CROWDFUNDING_UPDATES');
             break;
         case 'comments':
             $title .= ' | ' . JText::_('COM_CROWDFUNDING_COMMENTS');
             break;
         case 'funders':
             $title .= ' | ' . JText::_('COM_CROWDFUNDING_FUNDERS');
             break;
     }
     // Add title before or after Site Name
     if (!$title) {
         $title = $this->app->get('sitename');
     } elseif ((int) $this->app->get('sitename_pagetitles', 0) === 1) {
         $title = JText::sprintf('JPAGETITLE', $this->app->get('sitename'), $title);
     } elseif ((int) $this->app->get('sitename_pagetitles', 0) === 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $this->app->get('sitename'));
     }
     $this->document->setTitle($title);
 }
Ejemplo n.º 4
0
 private function preparePageTitle()
 {
     // Prepare page title
     $title = $this->params->get('page_title', '');
     // Add title before or after Site Name
     if (!$title) {
         $title = $this->app->get('sitename');
     } elseif ((int) $this->app->get('sitename_pagetitles', 0) === 1) {
         $title = JText::sprintf('JPAGETITLE', $this->app->get('sitename'), $title);
     } elseif ((int) $this->app->get('sitename_pagetitles', 0) === 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $this->app->get('sitename'));
     }
     $this->document->setTitle($title);
 }
Ejemplo n.º 5
0
 private function preparePageTitle()
 {
     // Prepare page title
     $title = $this->item->title . ' | ' . JText::_('COM_CROWDFUNDING_EMAIL_TO_FRIEND');
     // Add title before or after Site Name
     if (!$title) {
         $title = $this->app->get('sitename');
     } elseif ((int) $this->app->get('sitename_pagetitles', 0) === 1) {
         $title = JText::sprintf('JPAGETITLE', $this->app->get('sitename'), $title);
     } elseif ((int) $this->app->get('sitename_pagetitles', 0) === 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $this->app->get('sitename'));
     }
     $this->document->setTitle($title);
 }
 private function preparePageTitle()
 {
     // Because the application sets a default page title,
     // we need to get it from the menu item itself.
     //        $menus = $this->app->getMenu();
     //        $menu  = $menus->getActive();
     // Prepare page title
     $title = $this->documentTitle;
     // Add title before or after Site Name
     if (!$title) {
         $title = $this->app->get('sitename');
     } elseif ((int) $this->app->get('sitename_pagetitles', 0) === 1) {
         $title = JText::sprintf('JPAGETITLE', $this->app->get('sitename'), $title);
     } elseif ((int) $this->app->get('sitename_pagetitles', 0) === 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $this->app->get('sitename'));
     }
     $this->document->setTitle($title);
 }
Ejemplo n.º 7
0
 protected function preparePageTitle()
 {
     // Prepare page title
     $title = JText::sprintf("COM_CROWDFUNDING_INVESTING_IN", $this->escape($this->item->title));
     switch ($this->getLayout()) {
         case "payment":
             $title .= " | " . JText::_("COM_CROWDFUNDING_PAYMENT_METHODS");
             break;
         case "share":
             $title .= " | " . JText::_("COM_CROWDFUNDING_SHARE");
             break;
     }
     // Add title before or after Site Name
     if (!$title) {
         $title = $this->app->get('sitename');
     } elseif ($this->app->get('sitename_pagetitles', 0) == 1) {
         $title = JText::sprintf('JPAGETITLE', $this->app->get('sitename'), $title);
     } elseif ($this->app->get('sitename_pagetitles', 0) == 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $this->app->get('sitename'));
     }
     $this->document->setTitle($title);
 }
 /**
  * Disconnect user from payment gateway.
  *
  * @param string                   $context
  * @param Joomla\Registry\Registry $params
  *
  * @return null|array
  */
 public function onPayoutsDeauthorize($context, $params)
 {
     if (strcmp('com_crowdfundingfinance.payouts.deauthorize.stripeconnect', $context) !== 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp('html', $docType) !== 0) {
         return null;
     }
     // Prepare output data.
     $output = array('redirect_url' => '', 'message' => '');
     $errorOutput = array('redirect_url' => JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute()), 'message' => '');
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . '_DEBUG_GET_RESPONSE_AUTHORIZE'), $this->debugType, $_GET) : null;
     $userId = JFactory::getUser()->get('id');
     if (!$userId) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_NOT_REGISTERED_USER');
         return $errorOutput;
     }
     // Get token
     $state = $this->app->input->get('state');
     if (!$state) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_INVALID_AUTHORIZATION_DATA');
         return $errorOutput;
     }
     // Get project ID and redirect URL from the session.
     $stateData = $this->app->getUserState($state);
     if (count($stateData) === 0 or (!$stateData['redirect_url'] or !$stateData['project_id'])) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_INVALID_AUTHORIZATION_DATA');
         return $errorOutput;
     }
     $cfFinanceParams = JComponentHelper::getParams('com_crowdfundingfinance');
     $apiKeys = Crowdfundingfinance\Stripe\Helper::getKeys($cfFinanceParams);
     if (!$apiKeys['client_id'] or !$apiKeys['secret_key']) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_CONFIGURATION');
         return $errorOutput;
     }
     $payout = new Crowdfundingfinance\Payout(JFactory::getDbo());
     $payout->setSecretKey($this->app->get('secret'));
     $payout->load(array('project_id' => (int) $stateData['project_id']));
     if (!$payout->getId()) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_INVALID_PAYOUT');
         return $errorOutput;
     }
     $alias = !$apiKeys['test'] ? 'production' : 'test';
     $stripeData = $payout->getStripe();
     if (!$stripeData->get('stripeconnect.' . $alias . '.account_id')) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_NOT_CONNECTED');
         return $errorOutput;
     }
     Crowdfundingfinance\Stripe\Helper::deauthorize($apiKeys, $stripeData->get('stripeconnect.' . $alias . '.account_id'));
     $stripeData->set('stripeconnect.' . $alias . '.access_token', '');
     $stripeData->set('stripeconnect.' . $alias . '.refresh_token', '');
     $stripeData->set('stripeconnect.' . $alias . '.account_id', '');
     $stripeData->set('stripeconnect.' . $alias . '.expires', 0);
     $payout->setStripe($stripeData);
     $payout->storeStripe();
     // Get next URL.
     $output['redirect_url'] = base64_decode($stateData['redirect_url']);
     return $output;
 }
Ejemplo n.º 9
0
 /**
  * Prepares the document
  */
 protected function prepareDocument()
 {
     // Prepare page suffix
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $menus = $this->app->getMenu();
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $menu->title);
     } else {
         $this->params->def('page_heading', JText::_('COM_CROWDFUNDING_RAISE_DEFAULT_PAGE_TITLE'));
     }
     // Prepare page title
     $title = $menu->title;
     if (!$title) {
         $title = $this->app->get('sitename');
         // Set site name if it is necessary ( the option 'sitename' = 1 )
     } elseif ($this->app->get('sitename_pagetitles', 0)) {
         $title = JText::sprintf('JPAGETITLE', $this->app->get('sitename'), $title);
         // Item title to the browser title.
     } else {
         if (!empty($this->item)) {
             $title .= " | " . $this->escape($this->item->title);
         }
     }
     $this->document->setTitle($title);
     // Meta Description
     $this->document->setDescription($this->params->get('menu-meta_description'));
     // Meta keywords
     $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     // Add current layout into breadcrumbs.
     $pathway = $this->app->getPathway();
     $pathway->addItem($this->pathwayName);
     // Scripts
     if ($this->userId) {
         JHtml::_('behavior.core');
         JHtml::_('behavior.keepalive');
         if ($this->params->get("enable_chosen", 1)) {
             JHtml::_('formbehavior.chosen', '.cf-advanced-select');
         }
     }
     switch ($this->layout) {
         case "rewards":
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_REWARD');
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
             JText::script('COM_CROWDFUNDING_PICK_IMAGE');
             // Scripts
             if ($this->params->get("rewards_images", 0)) {
                 JHtml::_('prism.ui.bootstrap3Fileinput');
             }
             JHtml::_('prism.ui.pnotify');
             JHtml::_("prism.ui.joomlaHelper");
             $this->document->addScript('media/' . $this->option . '/js/site/project_rewards.js');
             break;
         case "funding":
             JHtml::_('prism.ui.parsley');
             JHtml::_('prism.ui.bootstrap3Datepicker');
             $this->document->addScript('media/' . $this->option . '/js/site/project_funding.js');
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_THIS_VALUE_IS_REQUIRED');
             break;
         case "story":
             // Scripts
             JHtml::_('prism.ui.bootstrap3FileInput');
             // Include translation of the confirmation question for image removing.
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
             JText::script('COM_CROWDFUNDING_PICK_IMAGE');
             JText::script('COM_CROWDFUNDING_REMOVE');
             $this->document->addScript('media/' . $this->option . '/js/site/project_story.js');
             break;
         case "manager":
             $this->document->addScript('media/' . $this->option . '/js/site/project_manager.js');
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_QUESTION_LAUNCH_PROJECT');
             JText::script('COM_CROWDFUNDING_QUESTION_STOP_PROJECT');
             break;
         case "extras":
             break;
         default:
             // Basic
             if ($this->userId) {
                 JHtml::_('prism.ui.bootstrapMaxLength');
                 JHtml::_('prism.ui.bootstrap3Typeahead');
                 JHtml::_('prism.ui.parsley');
                 JHtml::_('prism.ui.cropper');
                 JHtml::_('prism.ui.fileupload');
                 JHtml::_('prism.ui.pnotify');
                 JHtml::_("prism.ui.joomlaHelper");
                 $this->document->addScript('media/' . $this->option . '/js/site/project_basic.js');
                 // Load language string in JavaScript
                 JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
                 // Provide image size.
                 $js = "\r\n                    var cfImageWidth  = " . $this->params->get("image_width", 200) . ";\r\n                    var cfImageHeight = " . $this->params->get("image_height", 200) . ";\r\n                ";
                 $this->document->addScriptDeclaration($js);
             }
             break;
     }
 }
Ejemplo n.º 10
0
 /**
  * Send emails to the administrator, project owner and the user who have made a donation.
  *
  * @param \stdClass   $paymentResult
  * @param Registry    $params
  *
  * @throws \InvalidArgumentException
  * @return void
  */
 protected function sendMails($paymentResult, $params)
 {
     if (!\JComponentHelper::isInstalled('com_emailtemplates')) {
         \JLog::add(\JText::_('LIB_CROWDFUNDING_EMAIL_TEMPLATES_INSTALLATION'), \JLog::WARNING, 'com_crowdfunding');
         return;
     }
     $transaction = $paymentResult->transaction;
     /** @var Crowdfunding\Transaction\Transaction $transaction */
     $project = $paymentResult->project;
     /** @var Crowdfunding\Project $project */
     $reward = $paymentResult->reward;
     /** @var Crowdfunding\Reward $reward */
     // Get website
     $uri = \JUri::getInstance();
     $website = $uri->toString(array('scheme', 'host'));
     $emailMode = $this->params->get('email_mode', 'plain');
     $moneyHash = Prism\Utilities\StringHelper::generateMd5Hash(Crowdfunding\Constants::CONTAINER_FORMATTER_MONEY, $params->get('project_currency'));
     $money = $this->container->get($moneyHash);
     /** @var Prism\Money\Money $money */
     // Prepare data for parsing.
     $data = array('site_name' => $this->app->get('sitename'), 'site_url' => \JUri::root(), 'item_title' => $project->getTitle(), 'item_url' => $website . \JRoute::_(\CrowdfundingHelperRoute::getDetailsRoute($project->getSlug(), $project->getCatSlug())), 'amount' => $money->setAmount($transaction->getAmount())->formatCurrency(), 'transaction_id' => $transaction->getTransactionId(), 'reward_title' => '', 'delivery_date' => '', 'payer_name' => '', 'payer_email' => '');
     // Prepare data about payer if he is NOT anonymous ( is registered user with profile ).
     if ((int) $transaction->getInvestorId() > 0) {
         $investor = \JFactory::getUser($transaction->getInvestorId());
         $data['payer_email'] = $investor->get('email');
         $data['payer_name'] = $investor->get('name');
     }
     // Set reward data.
     if (is_object($reward)) {
         $data['reward_title'] = $reward->getTitle();
         $dateValidator = new Prism\Validator\Date($reward->getDeliveryDate());
         if ($dateValidator->isValid()) {
             $date = new \JDate($reward->getDeliveryDate());
             $data['delivery_date'] = $date->format($this->params->get('date_format_views', \JText::_('DATE_FORMAT_LC3')));
         }
     }
     // Send mail to the administrator
     $emailId = (int) $this->params->get('admin_mail_id', 0);
     if ($emailId > 0) {
         $email = new Emailtemplates\Email();
         $email->setDb(\JFactory::getDbo());
         $email->load($emailId);
         if (!$email->getSenderName()) {
             $email->setSenderName($this->app->get('fromname'));
         }
         if (!$email->getSenderEmail()) {
             $email->setSenderEmail($this->app->get('mailfrom'));
         }
         $recipientId = (int) $params->get('administrator_id', 0);
         if ($recipientId > 0) {
             $recipient = \JFactory::getUser($recipientId);
             $recipientName = $recipient->get('name');
             $recipientMail = $recipient->get('email');
         } else {
             $recipientName = $this->app->get('fromname');
             $recipientMail = $this->app->get('mailfrom');
         }
         // Prepare data for parsing
         $data['sender_name'] = $email->getSenderName();
         $data['sender_email'] = $email->getSenderEmail();
         $data['recipient_name'] = $recipientName;
         $data['recipient_email'] = $recipientMail;
         // DEBUG
         JDEBUG ? $this->log->add(\JText::_($this->textPrefix . '_DEBUG_SEND_MAIL_ADMINISTRATOR'), $this->debugType, $data) : null;
         $email->parse($data);
         $subject = $email->getSubject();
         $body = $email->getBody($emailMode);
         $mailer = \JFactory::getMailer();
         if (strcmp('html', $emailMode) === 0) {
             // Send as HTML message
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML);
         } else {
             // Send as plain text.
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN);
         }
         // Check for an error.
         if ($return !== true) {
             $this->log->add(\JText::_($this->textPrefix . '_ERROR_MAIL_SENDING_ADMIN'), $this->errorType, $mailer->ErrorInfo);
         }
     }
     // Send mail to project owner.
     $emailId = (int) $this->params->get('creator_mail_id', 0);
     if ($emailId > 0) {
         $email = new Emailtemplates\Email();
         $email->setDb(\JFactory::getDbo());
         $email->load($emailId);
         if (!$email->getSenderName()) {
             $email->setSenderName($this->app->get('fromname'));
         }
         if (!$email->getSenderEmail()) {
             $email->setSenderEmail($this->app->get('mailfrom'));
         }
         $user = \JFactory::getUser($transaction->getReceiverId());
         $recipientName = $user->get('name');
         $recipientMail = $user->get('email');
         // Prepare data for parsing
         $data['sender_name'] = $email->getSenderName();
         $data['sender_email'] = $email->getSenderEmail();
         $data['recipient_name'] = $recipientName;
         $data['recipient_email'] = $recipientMail;
         // DEBUG
         JDEBUG ? $this->log->add(\JText::_($this->textPrefix . '_DEBUG_SEND_MAIL_PROJECT_OWNER'), $this->debugType, $data) : null;
         $email->parse($data);
         $subject = $email->getSubject();
         $body = $email->getBody($emailMode);
         $mailer = \JFactory::getMailer();
         if (strcmp('html', $emailMode) === 0) {
             // Send as HTML message
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML);
         } else {
             // Send as plain text.
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN);
         }
         // Check for an error.
         if ($return !== true) {
             $this->log->add(\JText::_($this->textPrefix . '_ERROR_MAIL_SENDING_PROJECT_OWNER'), $this->errorType, $mailer->ErrorInfo);
         }
     }
     // Send mail to backer.
     $emailId = (int) $this->params->get('user_mail_id', 0);
     if ($emailId > 0 and (int) $transaction->getInvestorId() > 0) {
         $email = new Emailtemplates\Email();
         $email->setDb(\JFactory::getDbo());
         $email->load($emailId);
         if (!$email->getSenderName()) {
             $email->setSenderName($this->app->get('fromname'));
         }
         if (!$email->getSenderEmail()) {
             $email->setSenderEmail($this->app->get('mailfrom'));
         }
         $user = \JFactory::getUser($transaction->getInvestorId());
         $recipientName = $user->get('name');
         $recipientMail = $user->get('email');
         // Prepare data for parsing
         $data['sender_name'] = $email->getSenderName();
         $data['sender_email'] = $email->getSenderEmail();
         $data['recipient_name'] = $recipientName;
         $data['recipient_email'] = $recipientMail;
         // DEBUG
         JDEBUG ? $this->log->add(\JText::_($this->textPrefix . '_DEBUG_SEND_MAIL_BACKER'), $this->debugType, $data) : null;
         $email->parse($data);
         $subject = $email->getSubject();
         $body = $email->getBody($emailMode);
         $mailer = \JFactory::getMailer();
         if (strcmp('html', $emailMode) === 0) {
             // Send as HTML message
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML);
         } else {
             // Send as plain text.
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN);
         }
         // Check for an error.
         if ($return !== true) {
             $this->log->add(\JText::_($this->textPrefix . '_ERROR_MAIL_SENDING_PROJECT_OWNER'), $this->errorType, $mailer->ErrorInfo);
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * Prepares the document.
  *
  * @throws \InvalidArgumentException
  */
 protected function prepareDocument()
 {
     // Prepare page suffix
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $menus = $this->app->getMenu();
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $menu->title);
     } else {
         $this->params->def('page_heading', JText::_('COM_CROWDFUNDING_RAISE_DEFAULT_PAGE_TITLE'));
     }
     // Prepare page title
     $title = $menu->title;
     if (!$title) {
         $title = $this->app->get('sitename');
         // Set site name if it is necessary ( the option 'sitename' = 1 )
     } elseif ($this->app->get('sitename_pagetitles', 0)) {
         $title = JText::sprintf('JPAGETITLE', $this->app->get('sitename'), $title);
         // Item title to the browser title.
     } else {
         if ($this->item !== null) {
             $title .= ' | ' . $this->escape($this->item->title);
         }
     }
     $this->document->setTitle($title);
     // Meta Description
     $this->document->setDescription($this->params->get('menu-meta_description'));
     // Meta keywords
     $this->document->setMetaData('keywords', $this->params->get('menu-meta_keywords'));
     // Add current layout into breadcrumbs.
     $pathway = $this->app->getPathway();
     $pathway->addItem($this->pathwayName);
     JHtml::_('jquery.framework');
     // Scripts
     if ($this->userId) {
         JHtml::_('behavior.core');
         JHtml::_('behavior.keepalive');
         if ($this->params->get('enable_chosen', 1)) {
             JHtml::_('formbehavior.chosen', '.cf-advanced-select');
         }
     }
     $version = new Crowdfunding\Version();
     switch ($this->layout) {
         case 'rewards':
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_REWARD');
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
             JText::script('COM_CROWDFUNDING_PICK_IMAGE');
             // Scripts
             if ($this->params->get('rewards_images', 0)) {
                 JHtml::_('Prism.ui.bootstrap3Fileinput');
             }
             JHtml::_('Prism.ui.pnotify');
             JHtml::_('Prism.ui.joomlaHelper');
             $this->document->addScript('media/' . $this->option . '/js/site/project_rewards.js?v=' . $version->getShortVersion());
             break;
         case 'funding':
             JHtml::_('Prism.ui.parsley');
             JHtml::_('Prism.ui.bootstrap3Datepicker');
             $this->document->addScript('media/' . $this->option . '/js/site/project_funding.js?v=' . $version->getShortVersion());
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_THIS_VALUE_IS_REQUIRED');
             break;
         case 'story':
             JHtml::_('Prism.ui.bootstrap3FileInput');
             // Include translation of the confirmation question for image removing.
             JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
             JText::script('COM_CROWDFUNDING_PICK_IMAGE');
             JText::script('COM_CROWDFUNDING_REMOVE');
             $this->document->addScript('media/' . $this->option . '/js/site/project_story.js?v=' . $version->getShortVersion());
             break;
         case 'manager':
             $this->document->addScript('media/' . $this->option . '/js/site/project_manager.js?v=' . $version->getShortVersion());
             // Load language string in JavaScript
             JText::script('COM_CROWDFUNDING_QUESTION_LAUNCH_PROJECT');
             JText::script('COM_CROWDFUNDING_QUESTION_STOP_PROJECT');
             break;
         case 'extras':
             JHtml::_('Prism.ui.serializeJson');
             break;
         default:
             // Basic
             if ($this->userId) {
                 JHtml::_('Prism.ui.bootstrapMaxLength');
                 JHtml::_('Prism.ui.bootstrap3Typeahead');
                 JHtml::_('Prism.ui.parsley');
                 JHtml::_('Prism.ui.cropper');
                 JHtml::_('Prism.ui.fileupload');
                 JHtml::_('Prism.ui.pnotify');
                 JHtml::_('Prism.ui.joomlaHelper');
                 $this->document->addScript('media/' . $this->option . '/js/site/project_basic.js?v=' . $version->getShortVersion());
                 // Load language string in JavaScript
                 JText::script('COM_CROWDFUNDING_QUESTION_REMOVE_IMAGE');
                 $js = '
                 var crowdfundingOptions = {
                     imageWidth:  ' . $this->params->get('image_width', 200) . ',
                     imageHeight: ' . $this->params->get('image_width', 200) . ',
                     aspectRatio: ' . $this->params->get('image_aspect_ratio', '""') . '
                 }';
                 $this->document->addScriptDeclaration($js);
             }
             break;
     }
 }