/** * Draws the subscription for registrations and profile views * * @param string $plansTitle Title field of the plans (for validation texts) * @param string $selectionId html input tag attribute id='' field for the input * @param string $selectionName html input tag attribute name='' field for the input * @param string $selectionValue html input tag attribute value='' field for the input * @param string $insertBeforePrice HTML text to insert after description of this item but before price * @param string $insertAfterDescription HTML text to insert after this item as sub-items * @param boolean $selected TRUE if the item is selected * @param string $reason Payment reason: 'N'=new subscription (default), 'R'=renewal, 'U'=update * @param boolean $displayDescription TRUE: display description also * @param boolean $displayPrice TRUE: display price/price selection also * @param int $user_id User-id for whom the plan is drawn * @return string HTML */ public function drawProduct($plansTitle, $selectionId, $selectionName, $selectionValue, $insertBeforePrice, $insertAfterDescription, $selected, $reason, $displayDescription, $displayPrice, $user_id) { parent::drawProduct($plansTitle, $selectionId, $selectionName, $selectionValue, $insertBeforePrice, $insertAfterDescription, $selected, $reason, $displayDescription, $displayPrice, $user_id); $this->periodPrice = null; if ($displayPrice) { $this->_setOptionNames($selectionId, $selectionName, true); $this->currency = $this->_model->get('currency'); if (!$this->currency) { $this->currency = cbpaidApp::settingsParams()->get('currency_code'); } $cbpaidMoney = cbpaidMoney::getInstance(); $currencySymbol = $cbpaidMoney->renderCurrencySymbol($this->currency, true); if ($cbpaidMoney->currencyAfterOrNotBefore()) { $currencySymbolAfter = ' ' . $currencySymbol; $currencySymbolBefore = ''; } else { $currencySymbolAfter = ''; $currencySymbolBefore = $currencySymbol . ' '; } $this->fixedchoices = $this->_model->getParam('fixedchoices', 1); $this->defaultchoice = $this->_model->getParam('defaultchoice', ''); $this->donateamounts = explode(',', $this->_model->getParam('donateamount', '')); $this->_trimArray($this->donateamounts); if ($this->fixedchoices == 2 && count($this->donateamounts) == 1) { $this->periodPrice = '<input type="hidden" name="' . $this->_donselName . '" value="' . $this->donateamounts[0] . '" />' . '<span class="cbregDonationRate">' . $this->_model->displayPeriodPrice($reason, 'I', 0, null, null, true) . '</span>'; } elseif ($this->fixedchoices > 1) { $options = array(); $options[] = moscomprofilerHTML::makeOption('', htmlspecialchars(CBPTXT::T("--- Select amount ---"))); $this->_valuesToOptions($options, $this->donateamounts, $this->currency); if ($this->fixedchoices == 3) { $options[] = moscomprofilerHTML::makeOption('0', htmlspecialchars(CBPTXT::T("Other..."))); } $this->periodPrice = moscomprofilerHTML::selectList($options, $this->_donselName, 'class="inputbox cbregDonationSelector"', 'value', 'text', $this->defaultchoice, 2, false); } if ($this->fixedchoices == 3) { $this->periodPrice = '<span class="cbregDonationSelect">' . $this->periodPrice . '</span>'; } $hiddenStyle = ''; if ($this->fixedchoices != 2) { if ($this->fixedchoices == 3 && (in_array($this->defaultchoice, $this->donateamounts) || $this->defaultchoice == '')) { $hiddenStyle = ' style="display:none;"'; $defaultDonateValue = ''; } else { $defaultDonateValue = $this->defaultchoice; } /* if ( ( $this->fixedchoices == 1 ) { $defaultDonateValue = $this->defaultchoice; } */ $this->periodPrice .= '<span class="cbregDonationValue" id="' . $selectionId . 'donspan' . '"' . $hiddenStyle . '>' . $currencySymbolBefore . '<input type="text" size="12" name="' . $this->_donvalName . '" id="' . $selectionId . 'donval' . '" class="inputbox cbregDonationFreeValue" value="' . htmlspecialchars($defaultDonateValue) . '"' . ' />' . $currencySymbolAfter . '</span>'; } } return $this->display(); }
/** * Draws the subscription for registrations and profile views * * @param string $plansTitle Title field of the plans (for validation texts) * @param string $selectionId html input tag attribute id='' field for the input * @param string $selectionName html input tag attribute name='' field for the input * @param string $selectionValue html input tag attribute value='' field for the input * @param string $insertBeforePrice HTML text to insert after description of this item but before price * @param string $insertAfterDescription HTML text to insert after this item as sub-items * @param boolean $selected TRUE if the item is selected * @param string $reason Payment reason: 'N'=new subscription (default), 'R'=renewal, 'U'=update * @param boolean $displayDescription TRUE: display description also * @param boolean $displayPrice TRUE: display price/price selection also * @param int $user_id User id * @return string */ public function drawProduct($plansTitle, $selectionId, $selectionName, $selectionValue, $insertBeforePrice, $insertAfterDescription, $selected, $reason, $displayDescription, $displayPrice, $user_id) { parent::drawProduct($plansTitle, $selectionId, $selectionName, $selectionValue, $insertBeforePrice, $insertAfterDescription, $selected, $reason, $displayDescription, $displayPrice, $user_id); if ($displayPrice) { $this->periodPrice = $this->_model->displayPeriodPrice($reason, 'I', 0, null, null, true); if (strtolower($this->_model->get('pricedisplay')) == '[automatic]') { $this->periodPrice .= '.'; } } else { $this->periodPrice = null; } return $this->display(); }
/** * Gets the viewer class for the rendering, keeps it in cache. * * @return cbpaidProductView */ public function & getViewer( ) { if ( ! isset( $this->_viewer ) ) { $template = $this->getTemplateOutoutCss(); $view = 'product' . $this->item_type; $output = 'html'; // For now... $this->_viewer = cbpaidTemplateHandler::getViewer( $template, $view, $output ); $this->_viewer->setModel( $this ); } return $this->_viewer; }