<?php if (!$this->rewardsEnabledViaType) { // Get next layout $nextLayout = strcmp($this->params->get("project_wizard_type", "five_steps"), "five_steps") == 0 ? "manager" : "extras"; ?> <p class="alert alert-info mt-10"> <span class="glyphicon glyphicon-info"></span> <?php echo JText::_("COM_CROWDFUNDING_NOTE_REWARDS_CREATING_NOT_ALLOWED"); ?> </p> <div class="cf-rewards-submit-btn"> <a class="btn btn-primary" href="<?php echo JRoute::_(CrowdfundingHelperRoute::getFormRoute($this->item->id, $nextLayout)); ?> "> <span class="glyphicon glyphicon-ok"></span> <?php echo JText::_("COM_CROWDFUNDING_CONTINUE"); ?> </a> </div> <?php } else { ?> <div class="cf-rewards-submit-btn"> <button class="btn btn-primary" <?php
echo JHtml::_('crowdfunding.approved', $item->approved); ?> </td> <td class="text-center hidden-phone"> <a href="<?php echo JRoute::_(CrowdfundingHelperRoute::getFormRoute($item->id)); ?> " class="btn btn-primary btn-sm"> <span class="fa fa-edit"></span> <?php echo JText::_('COM_CROWDFUNDING_EDIT'); ?> </a> <a href="<?php echo JRoute::_(CrowdfundingHelperRoute::getFormRoute($item->id, 'manager')); ?> " class="btn btn-default btn-sm"> <span class="fa fa-wrench"></span> <?php echo JText::_('COM_CROWDFUNDING_MANAGER'); ?> </a> </td> </tr> <?php } ?> </tbody>
/** * This method prepares a code that will be included to step "Extras" on project wizard. * * @param string $context This string gives information about that where it has been executed the trigger. * @param stdClass $item A project data. * @param Joomla\Registry\Registry $params The parameters of the component * * @return null|string */ public function onExtrasDisplay($context, $item, $params) { if (strcmp('com_crowdfunding.project.extras', $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; } if (!isset($item->user_id) or !$item->user_id) { return null; } // A flag that shows the options are active. if (!$this->params->get('display_paypal', 0) and !$this->params->get('display_banktransfer', 0) and !$this->params->get('display_stripe', 0)) { return ''; } $activeTab = ''; if ($this->params->get('display_paypal', 0)) { $activeTab = 'paypal'; } elseif ($this->params->get('display_banktransfer', 0)) { $activeTab = 'banktransfer'; } elseif ($this->params->get('display_stripe', 0)) { $activeTab = 'stripe'; } $payout = new Crowdfundingfinance\Payout(JFactory::getDbo()); $payout->setSecretKey($this->app->get('secret')); $payout->load(array('project_id' => $item->id)); // Create payout record, if it does not exists. if (!$payout->getId()) { $payout->setProjectId($item->id); $payout->store(); } // Check if Stripe connected. if ($this->params->get('display_stripe', 0)) { $stripeWarning = null; $stripeButton = array(); $cfFinanceParams = JComponentHelper::getParams('com_crowdfundingfinance'); // Get keys. $apiKeys = Crowdfundingfinance\Stripe\Helper::getKeys($cfFinanceParams); if (!$apiKeys['client_id']) { $stripeWarning = JText::_('PLG_CROWDFUNDING_PAYOUTOPTIONS_ERROR_STRIPE_NOT_CONFIGURED'); } $token = Crowdfundingfinance\Stripe\Helper::getPayoutAccessToken($apiKeys, $payout, $cfFinanceParams->get('stripe_expiration_period', 7)); // Generate state HASH and use it as a session key that contains redirect URL. $state = Prism\Utilities\StringHelper::generateRandomString(32); $stateData = array('redirect_url' => base64_encode(JRoute::_(CrowdfundingHelperRoute::getFormRoute($item->id, 'extras'), false)), 'project_id' => $item->id); $this->app->setUserState($state, $stateData); if (!$token) { $stripeButton[] = '<div class="mt-20">'; $stripeButton[] = '<a href="https://connect.stripe.com/oauth/authorize?response_type=code&client_id=' . $apiKeys['client_id'] . '&scope=read_write&state=' . $state . '&redirect_uri=' . rawurlencode($this->params->get('stripe_redirect_uri')) . '">'; $stripeButton[] = '<img src="media/com_crowdfundingfinance/images/stripe/' . $cfFinanceParams->get('button', 'blue-on-dark') . '.png" width="190" height="33" />'; $stripeButton[] = '</a>'; $stripeButton[] = '</div>'; } else { $url = JRoute::_('index.php?option=com_crowdfundingfinance&task=payouts.deauthorize&payment_service=stripeconnect&pid=' . (int) $item->id . '&state=' . $state . '&' . JSession::getFormToken() . '=1'); $stripeButton[] = '<div class="mt-20">'; $stripeButton[] = '<p class="alert alert-info"><span class="fa fa-info-circle"></span> ' . JText::_('PLG_CROWDFUNDING_PAYOUTOPTIONS_STRIPE_CONNECTED') . '</p>'; $stripeButton[] = '<a href="' . $url . '" class="btn btn-danger" id="js-cff-btn-stripe-disconnect">'; $stripeButton[] = '<span class="fa fa-chain-broken"></span> ' . JText::_('PLG_CROWDFUNDING_PAYOUTOPTIONS_DISCONNECT_STRIPE'); $stripeButton[] = '</a>'; $stripeButton[] = '</div>'; } } // Load jQuery JHtml::_('jquery.framework'); JHtml::_('Prism.ui.pnotify'); JHtml::_('Prism.ui.joomlaHelper'); // Get the path for the layout file $path = JPath::clean(JPluginHelper::getLayoutPath('crowdfunding', 'payoutoptions')); // Render the login form. ob_start(); include $path; $html = ob_get_clean(); return $html; }
protected function prepareRewards() { $model = JModelLegacy::getInstance("Rewards", "CrowdfundingModel", $config = array('ignore_request' => false)); // Get state $this->state = $model->getState(); // Get params $this->projectId = $this->state->get("rewards.project_id"); // Check if rewards are enabled. if (!$this->rewardsEnabled) { $this->app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_REWARDS_DISABLED"), "notice"); $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getFormRoute($this->projectId, "manager"), false)); return; } $this->items = $model->getItems($this->projectId); // Get project and validate it $project = Crowdfunding\Project::getInstance(JFactory::getDbo(), $this->projectId); $project = $project->getProperties(); $this->item = Joomla\Utilities\ArrayHelper::toObject($project); // Check if the item exists. if (!$this->isValid()) { return; } // Create a currency object. $this->currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency")); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($this->currency); // Get date format $this->dateFormat = CrowdfundingHelper::getDateFormat(); $this->dateFormatCalendar = CrowdfundingHelper::getDateFormat(true); $language = JFactory::getLanguage(); $languageTag = $language->getTag(); $js = ' // Rewards calendar date format. var projectWizard = { dateFormat: "' . $this->dateFormatCalendar . '", locale: "' . substr($languageTag, 0, 2) . '" }; '; $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"); }
?> </td> <td> <?php echo $this->deliveryDate; ?> </td> </tr> </tbody> </table> </div> </div> </div> <a href="<?php echo JRoute::_(CrowdfundingHelperRoute::getFormRoute($this->reward->getProjectId(), "manager")); ?> " class="btn btn-default"> <span class="glyphicon glyphicon-menu-left"></span> <?php echo JText::_("COM_CROWDFUNDING_BACK_PROJECT_MANAGER"); ?> </a> <?php if (($this->params->def('show_pagination', 1) == 1 || $this->params->get('show_pagination') == 2) && $this->pagination->get('pages.total') > 1) { ?> <div class="pagination"> <?php if ($this->params->def('show_pagination_results', 1)) { ?> <p class="counter pull-right"> <?php
protected function prepareRewards() { $model = JModelLegacy::getInstance('Rewards', 'CrowdfundingModel', $config = array('ignore_request' => false)); // Get state $this->state = $model->getState(); // Get params $this->projectId = $this->state->get('rewards.project_id'); // Check if rewards are enabled. if (!$this->rewardsEnabled) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_REWARDS_DISABLED'), 'notice'); $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getFormRoute($this->projectId, 'manager'), false)); return; } $this->items = $model->getItems($this->projectId); // Get project and validate it $project = Crowdfunding\Project::getInstance(JFactory::getDbo(), $this->projectId); $project = $project->getProperties(); $this->item = Joomla\Utilities\ArrayHelper::toObject($project); // Check if the item exists. if (!CrowdfundingHelper::isAuthorized($this->userId, $this->item, 'rewards')) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_SOMETHING_WRONG'), 'notice'); $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute())); return; } // Create a currency object. $this->currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency')); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($this->currency); // Get date format $this->dateFormat = CrowdfundingHelper::getDateFormat(); $this->dateFormatCalendar = CrowdfundingHelper::getDateFormat(true); $language = JFactory::getLanguage(); $languageTag = $language->getTag(); $js = ' // Rewards calendar date format. var projectWizard = { dateFormat: "' . $this->dateFormatCalendar . '", locale: "' . substr($languageTag, 0, 2) . '" }; '; $this->document->addScriptDeclaration($js); // Prepare rewards images. $this->rewardsImagesEnabled = (bool) $this->params->get('rewards_images', 0); $this->rewardsImagesUri = CrowdfundingHelper::getImagesFolderUri($this->userId); $this->options['column_left'] = (!$this->rewardsImagesEnabled or count($this->items) === 0) ? 12 : 8; $this->options['column_right'] = (!$this->rewardsImagesEnabled or count($this->items) === 0) ? 0 : 4; $this->prepareProjectType(); $this->pathwayName = JText::_('COM_CROWDFUNDING_STEP_REWARDS'); }
private function getToolbar($project) { // Get current URL. $returnUrl = JUri::current(); // Filter the URL. $filter = JFilterInput::getInstance(); $returnUrl = $filter->clean($returnUrl); $html = array(); $html[] = '<div class="cf-pm-toolbar">'; if ($project->published and !$project->approved) { $html[] = '<p class="bg-info">' . JText::_("PLG_CONTENT_CROWDFUNDINGMANAGER_NOT_APPROVED_NOTIFICATION") . '</p>'; } // Edit $html[] = '<a href="' . JRoute::_(CrowdfundingHelperRoute::getFormRoute($project->id)) . '" class="btn btn-default" role="button">'; $html[] = '<span class="glyphicon glyphicon-edit"></span>'; $html[] = JText::_("PLG_CONTENT_CROWDFUNDINGMANAGER_EDIT"); $html[] = '</a>'; if (!$project->published) { // Display "Publish" button $html[] = '<a href="' . JRoute::_("index.php?option=com_crowdfunding&task=projects.savestate&id=" . $project->id . "&state=1&" . JSession::getFormToken() . "=1&return=" . base64_encode($returnUrl)) . '" class="btn btn-default" role="button" id="js-cfmanager-launch">'; $html[] = '<span class="glyphicon glyphicon-ok-sign"></span>'; $html[] = JText::_("PLG_CONTENT_CROWDFUNDINGMANAGER_LAUNCH"); $html[] = '</a>'; } else { // Display "Unpublish" button $html[] = '<a href="' . JRoute::_("index.php?option=com_crowdfunding&task=projects.savestate&id=" . $project->id . "&state=0&" . JSession::getFormToken() . "=1&return=" . base64_encode($returnUrl)) . '" class="btn btn-danger" role="button" id="js-cfmanager-launch">'; $html[] = '<span class="glyphicon glyphicon-remove-sign"></span>'; $html[] = JText::_("PLG_CONTENT_CROWDFUNDINGMANAGER_STOP"); $html[] = '</a>'; } // Manager $html[] = '<a href="' . JRoute::_(CrowdfundingHelperRoute::getFormRoute($project->id, "manager")) . '" class="btn btn-default" role="button">'; $html[] = '<span class="glyphicon glyphicon-wrench"></span>'; $html[] = JText::_("PLG_CONTENT_CROWDFUNDINGMANAGER_MANAGER"); $html[] = '</a>'; $html[] = '</div>'; return implode("\n", $html); }
} ?> <?php if (!$this->rewardsEnabled) { ?> <p class="alert alert-info mt-10"> <span class="glyphicon glyphicon-info"></span> <?php echo JText::_("COM_CROWDFUNDING_NOTE_REWARDS_CREATING_NOT_ALLOWED"); ?> </p> <div class="cf-rewards-submit-btn"> <a class="btn" href="<?php echo JRoute::_(CrowdfundingHelperRoute::getFormRoute($this->item->id, "manager")); ?> "> <span class="glyphicon glyphicon-arrow-right"></span> <?php echo JText::_("COM_CROWDFUNDING_CONTINUE"); ?> </a> </div> <?php } else { ?> <div class="cf-rewards-submit-btn"> <button class="btn btn-primary" <?php