コード例 #1
0
 public function onAfterDispatch()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     if ($app->isAdmin()) {
         return;
     }
     $document = JFactory::getDocument();
     /** @var $document JDocumentHtml */
     $type = $document->getType();
     if (strcmp('html', $type) !== 0) {
         return;
     }
     // It works only for GET and POST requests.
     $method = strtolower($app->input->getMethod());
     if (!in_array($method, array('get', 'post'), true)) {
         return;
     }
     // Check component enabled
     if (!JComponentHelper::isEnabled('com_crowdfunding')) {
         return;
     }
     $view = $app->input->getCmd('view');
     $option = $app->input->getCmd('option');
     $isCrowdfundingComponent = strcmp($option, 'com_crowdfunding') === 0;
     $isDetailsPage = (strcmp($option, 'com_crowdfunding') === 0 and strcmp($view, 'details') === 0);
     // Allowed views for the module Crowdfunding Details
     $allowedViewsModuleDetails = array('backing', 'embed', 'report', 'friendmail');
     $allowedViewsModuleFilters = array('discover', 'category');
     // Hide some modules if it is not details page.
     if (!$isDetailsPage) {
         $this->hideModule('mod_crowdfundinginfo');
         $this->hideModule('mod_crowdfundingprofile');
         $this->hideModule('mod_crowdfundingreporting');
     }
     // Module Crowdfunding Rewards (mod_crowdfundingrewards).
     if (!$isDetailsPage) {
         $this->hideModule('mod_crowdfundingrewards');
     } else {
         // Check project type. If the rewards are disable, hide the module.
         $projectId = $app->input->getInt('id');
         if ($projectId > 0 and !CrowdfundingHelper::isRewardsEnabled($projectId)) {
             // Hide the module Crowdfunding Rewards, if rewards are disabled.
             $this->hideModule('mod_crowdfundingrewards');
         }
     }
     // Module Crowdfunding Details (mod_crowdfundingdetails) on backing and embed pages.
     if (!$isCrowdfundingComponent or strcmp($option, 'com_crowdfunding') === 0 and !in_array($view, $allowedViewsModuleDetails, true)) {
         $this->hideModule('mod_crowdfundingdetails');
     }
     // Module Crowdfunding Filters (mod_crowdfundingfilters).
     if (!$isCrowdfundingComponent or strcmp($option, 'com_crowdfunding') === 0 and !in_array($view, $allowedViewsModuleFilters, true)) {
         $this->hideModule('mod_crowdfundingfilters');
     }
     // Module Crowdfunding Filters (mod_crowdfundingsearch).
     if (!$isCrowdfundingComponent or strcmp($option, 'com_crowdfunding') === 0 and !in_array($view, $allowedViewsModuleFilters, true)) {
         $this->hideModule('mod_crowdfundingsearch');
     }
 }
コード例 #2
0
 public function onAfterDispatch()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     if ($app->isAdmin()) {
         return;
     }
     $document = JFactory::getDocument();
     /** @var $document JDocumentHtml */
     $type = $document->getType();
     if (strcmp("html", $type) != 0) {
         return;
     }
     // It works only for GET and POST requests.
     $method = JString::strtolower($app->input->getMethod());
     if (!in_array($method, array("get", "post"))) {
         return;
     }
     // Check component enabled
     if (!JComponentHelper::isEnabled('com_crowdfunding', true)) {
         return;
     }
     $view = $app->input->getCmd("view");
     $option = $app->input->getCmd("option");
     $isCrowdfundingComponent = strcmp($option, "com_crowdfunding") == 0;
     $isDetailsPage = (strcmp($option, "com_crowdfunding") == 0 and strcmp($view, "details") == 0);
     // Allowed views for the module Crowdfunding Details
     $allowedViewsModuleDetails = array("backing", "embed", "report");
     $allowedViewsModuleFilters = array("discover", "category");
     // Hide some modules if it is not details page.
     if (!$isDetailsPage) {
         $this->hideModule("mod_crowdfundinginfo");
         $this->hideModule("mod_crowdfundingprofile");
         $this->hideModule("mod_crowdfundingreporting");
     }
     // Module Crowdfunding Rewards (mod_crowdfundingrewards).
     if (!$isDetailsPage) {
         $this->hideModule("mod_crowdfundingrewards");
     } else {
         // Check project type. If the rewards are disable, hide the module.
         $projectId = $app->input->getInt("id");
         if (!empty($projectId)) {
             // Hide the module Crowdfunding Rewards, if rewards are disabled.
             if (!CrowdfundingHelper::isRewardsEnabled($projectId)) {
                 $this->hideModule("mod_crowdfundingrewards");
             }
         }
     }
     // Module Crowdfunding Details (mod_crowdfundingdetails) on backing and embed pages.
     if (!$isCrowdfundingComponent or strcmp($option, "com_crowdfunding") == 0 and !in_array($view, $allowedViewsModuleDetails)) {
         $this->hideModule("mod_crowdfundingdetails");
     }
     // Module Crowdfunding Filters (mod_crowdfundingfilters).
     if (!$isCrowdfundingComponent or strcmp($option, "com_crowdfunding") == 0 and !in_array($view, $allowedViewsModuleFilters)) {
         $this->hideModule("mod_crowdfundingfilters");
     }
 }
コード例 #3
0
ファイル: view.html.php プロジェクト: pashakiz/crowdf
 public function display($tpl = null)
 {
     // Get model state.
     $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;
     }
     // Create an object that will contain the data during the payment process.
     $this->paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $this->item->id;
     $paymentSession = $this->app->getUserState($this->paymentSessionContext);
     // Create payment session object.
     if (!$paymentSession or !isset($paymentSession->step1)) {
         $paymentSession = new JData();
         $paymentSession->step1 = false;
     }
     // Images
     $this->imageFolder = $this->params->get("images_directory", "images/crowdfunding");
     // Get currency
     $this->currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency"));
     $this->amount = new Crowdfunding\Amount($this->params);
     $this->amount->setCurrency($this->currency);
     // 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 ? false : true;
     // Import "crowdfundingpayment" plugins.
     JPluginHelper::importPlugin('crowdfundingpayment');
     $this->layout = $this->getLayout();
     switch ($this->layout) {
         case "step2":
             $this->prepareStep2();
             break;
         case "payment":
             $this->preparePayment($paymentSession);
             break;
         case "share":
             $this->prepareShare($paymentSession);
             break;
         default:
             //  Pledge and Rewards
             $this->prepareRewards($paymentSession);
             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"';
     }
     $this->paymentSession = $paymentSession;
     // Prepare the data of the layout
     $this->layoutData = new JData(array("layout" => $this->layout, "item" => $this->item, "paymentSession" => $paymentSession, "rewards_enabled" => $this->rewardsEnabled));
     $this->prepareDebugMode($paymentSession);
     $this->prepareDocument();
     parent::display($tpl);
 }
コード例 #4
0
ファイル: manager.php プロジェクト: pashakiz/crowdf
                    </div>
                </div>

            </div>
    </div>

    <div class="col-md-4">
        <?php 
echo $this->loadTemplate("basic");
?>
    </div>

    <div class="col-md-4">
        <?php 
echo $this->loadTemplate("settings");
?>
    </div>
</div>

<?php 
if (CrowdfundingHelper::isRewardsEnabled($this->item->id)) {
    ?>
<div class="row">
    <div class="col-md-12">
        <?php 
    echo $this->loadTemplate("rewards");
    ?>
    </div>
</div>
<?php 
}
コード例 #5
0
ファイル: view.html.php プロジェクト: sis-direct/CrowdFunding
 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;
     }
     // Create an object that will contain the data during the payment process.
     $this->paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $this->item->id;
     $paymentSession = $this->app->getUserState($this->paymentSessionContext);
     // Create payment session object.
     if (!$paymentSession or !isset($paymentSession->step1)) {
         $paymentSession = $this->createPaymentSession();
     }
     // Images
     $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
     // Get currency
     $this->currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency'));
     $this->amount = new Crowdfunding\Amount($this->params);
     $this->amount->setCurrency($this->currency);
     // 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
             $paymentSession = $this->preparePayment($paymentSession);
             break;
         case 'share':
             // Step 3
             $paymentSession = $this->prepareShare($paymentSession);
             break;
         default:
             //  Step 1 ( Rewards )
             $paymentSession = $this->prepareRewards($paymentSession);
             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' => $paymentSession, 'rewards_enabled' => $this->rewardsEnabled));
     $this->prepareDebugMode($paymentSession);
     $this->prepareDocument();
     $this->paymentSession = $paymentSession;
     // Store the new values of the payment process to the user session.
     $this->app->setUserState($this->paymentSessionContext, $paymentSession);
     parent::display($tpl);
 }