Example #1
0
 /**
  * Display the view.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  *
  * @since   1.0.0
  */
 public function display($tpl = null)
 {
     $jinput = JFactory::getApplication()->input;
     $campaignId = $jinput->get('campaign', 0, 'integer');
     $campaigns = JModelLegacy::getInstance('Campaigns', 'CMDonationModel')->getCampaignsForFilter();
     $campaignList = array();
     $campaign = array();
     if (!empty($campaigns)) {
         foreach ($campaigns as $camp) {
             $campaignList[$camp->id] = htmlspecialchars($camp->name);
             if ($camp->id == $campaignId) {
                 $campaign = $camp;
             }
         }
     }
     $statistics = array();
     if (!empty($campaign)) {
         $statistics = CMDonationHelper::generateStatistics($campaignId);
     }
     $params = JComponentHelper::getParams('com_cmdonation');
     // Get payment methods.
     $paymentMethods = CMDonationHelper::getPaymentMethods();
     $this->assignRef('paymentMethods', $paymentMethods);
     $this->assignRef('params', $params);
     $this->assignRef('campaignList', $campaignList);
     $this->assignRef('campaignId', $campaignId);
     $this->assignRef('campaign', $campaign);
     $this->assignRef('statistics', $statistics);
     $this->submenu = CMDonationHelper::addSubmenu('statistics');
     $this->addToolbar($campaign, $statistics);
     parent::display($tpl);
 }
Example #2
0
 /**
  * Display the view.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  *
  * @since   1.0.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');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Get payment methods.
     $paymentMethods = CMDonationHelper::getPaymentMethods();
     // Get campaigns.
     $campaigns = JModelList::getInstance('Campaigns', 'CMDonationModel')->getCampaignsForFilter();
     // Build campaign options for filter and index for displaying campaign name.
     $campaignOptions = array();
     $campaignIndex = array();
     if (!empty($campaigns)) {
         foreach ($campaigns as $campaign) {
             $campaignOptions[] = JHtml::_('select.option', $campaign->id, htmlspecialchars($campaign->name));
             $campaignIndex[$campaign->id] = $campaign->name;
         }
     }
     $this->assignRef('paymentMethods', $paymentMethods);
     $this->assignRef('campaigns', $campaigns);
     $this->assignRef('campaignOptions', $campaignOptions);
     $this->assignRef('campaignIndex', $campaignIndex);
     $this->submenu = CMDonationHelper::addSubmenu('donations');
     $this->addToolbar();
     parent::display($tpl);
 }
 /**
  * Method to get the field input for a list of content types.
  *
  * @return  string  The field input.
  *
  * @since   1.0.0
  */
 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'] . '"' : '';
     $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     $readonly = (string) $this->element['readonly'] == 'true' ? ' readonly="readonly"' : '';
     $disabled = (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : '';
     $required = $this->required ? ' required="required" aria-required="true"' : '';
     // Initialize JavaScript field attributes.
     $onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     $input = '<input type="text" name="' . $this->name . '" id="' . $this->id . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $class . $size . $disabled . $readonly . $onchange . $maxLength . $required . '/>';
     $instruction = '<p></p><p>' . JText::_('COM_CMDONATION_PAYMENT_METHOD_INSTRUCTION_ENTER');
     $instruction .= '<ul>';
     $paymentMethods = CMDonationHelper::getPaymentMethods();
     if (!empty($paymentMethods)) {
         foreach ($paymentMethods as $method) {
             $instruction .= '<li>' . JText::sprintf('COM_CMDONATION_PAYMENT_METHOD_INSTRUCTION_FOR', $method->name, $method->title) . '</li>';
         }
     }
     $instruction .= '<li>' . JText::_('COM_CMDONATION_PAYMENT_METHOD_INSTRUCTION_CUSTOM') . '</li>';
     $instruction .= '</ul></p>';
     return $input . $instruction;
 }
 /**
  * Genarate donation form's HTML.
  *
  * @param   integer  $campaignId  Campaign ID.
  *
  * @return  string   HTML.
  *
  * @since   1.0.0
  */
 function buildDonationForm($campaignId)
 {
     require_once JPATH_ROOT . '/administrator/components/com_cmdonation/helpers/cmdonation.php';
     $postUrl = 'index.php?option=com_cmdonation&task=donation.submit';
     $langAmount = JText::_('COM_CMDONATION_AMOUNT');
     $langAnonymous = JText::_('COM_CMDONATION_ANONYMOUS_CHECKBOX');
     $langDonate = JText::_('COM_CMDONATION_DONATE');
     $langPaymentMethod = JText::_('COM_CMDONATION_PAYMENT_METHOD');
     $langRecurringDonation = JText::_('COM_CMDONATION_RECURRING_DONATION');
     $langRecurringCycle = JText::_('COM_CMDONATION_RECURRING_CYCLE');
     $returnUrl = $this->getErrorReturnUrl();
     $paymentMethods = CMDonationHelper::getPaymentMethods();
     $htmlPaymentMethods = '';
     $loneOption = count($paymentMethods) == 1 ? true : false;
     $params = JComponentHelper::getParams('com_cmdonation');
     $hideLoneOption = $params->get('hide_lone_payment_option', '0');
     $currencySign = $params->get('currency_sign', '');
     $currencySignPosition = $params->get('currency_sign_position', 'before');
     $anonymous = $params->get('anonymous_donation', false, 'boolean');
     $recurring = $params->get('recurring_donation', false, 'boolean');
     $recurringCycles = $params->get('recurring_cycles', array(), 'array');
     @ob_start();
     if (file_exists($this->layoutPath . 'override/donation_form.php')) {
         include $this->layoutPath . 'override/donation_form.php';
     } else {
         include $this->layoutPath . 'donation_form.php';
     }
     $html = @ob_get_clean();
     return $html;
 }