本文整理汇总了PHP中CrowdfundingHelperRoute::getDetailsRoute方法的典型用法代码示例。如果您正苦于以下问题:PHP CrowdfundingHelperRoute::getDetailsRoute方法的具体用法?PHP CrowdfundingHelperRoute::getDetailsRoute怎么用?PHP CrowdfundingHelperRoute::getDetailsRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CrowdfundingHelperRoute
的用法示例。
在下文中一共展示了CrowdfundingHelperRoute::getDetailsRoute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
public function display($tpl = null)
{
$this->app = JFactory::getApplication();
/** @var $this->app JApplicationSite */
$this->option = JFactory::getApplication()->input->get('option');
$this->state = $this->get('State');
$this->item = $this->get('Item');
// Get params
$this->params = $this->state->get('params');
/** @var $this->params Joomla\Registry\Registry */
$this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
if (!$this->item) {
$this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice');
$this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false));
return;
}
$container = Prism\Container::getContainer();
$this->money = $this->getMoneyFormatter($container, $this->params);
// Integrate with social profile.
$this->displayCreator = $this->params->get('integration_display_creator', true);
// Prepare integration. Load avatars and profiles.
if ($this->displayCreator and (is_object($this->item) and $this->item->user_id > 0)) {
$socialProfile = CrowdfundingHelper::prepareIntegration($this->params->get('integration_social_platform'), $this->item->user_id);
$this->socialProfileLink = !$socialProfile ? null : $socialProfile->getLink();
}
// Set a link to project page
$uri = JUri::getInstance();
$host = $uri->toString(array('scheme', '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;
$this->embedCode = $this->prepareEmbedCode($this->item, $host);
$this->prepareDocument();
parent::display($tpl);
}
示例2: display
public function display($tpl = null)
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
// Get model state.
$this->state = $this->get('State');
$this->item = $this->get("Item");
// Get params
/** @var $params Joomla\Registry\Registry */
$params = $this->state->get("params");
$this->params = $params;
$this->imageFolder = $this->params->get("images_directory", "images/crowdfunding");
if (!$this->item) {
$app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_INVALID_PROJECT"), "notice");
$app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false));
return;
}
// Get currency
// Get currency
$currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency"));
$this->amount = new Crowdfunding\Amount($this->params);
$this->amount->setCurrency($currency);
// Integrate with social profile.
$this->displayCreator = $this->params->get("integration_display_creator", true);
// Prepare integration. Load avatars and profiles.
if ($this->displayCreator and !empty($this->item->user_id)) {
$socialProfilesBuilder = new Prism\Integration\Profile\Builder(array("social_platform" => $this->params->get("integration_social_platform"), "user_id" => $this->item->user_id));
$socialProfilesBuilder->build();
$socialProfile = $socialProfilesBuilder->getProfile();
$this->socialProfileLink = !$socialProfile ? null : $socialProfile->getLink();
}
// Set a link to project page
$uri = JUri::getInstance();
$host = $uri->toString(array("scheme", "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;
$layout = $this->getLayout();
switch ($layout) {
case "email":
if (!$this->params->get("security_display_friend_form", 0)) {
$app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_CANT_SEND_MAIL"), "notice");
$app->redirect(JRoute::_($this->item->link, false));
return;
}
$this->prepareEmailForm($this->item);
break;
default:
// Embed HTML code
$this->embedCode = $this->prepareEmbedCode($this->item, $host);
break;
}
$this->prepareDocument();
parent::display($tpl);
}
示例3: display
public function display($tpl = null)
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
$this->option = JFactory::getApplication()->input->get('option');
$this->state = $this->get('State');
$this->item = $this->get('Item');
// Get params
$this->params = $this->state->get('params');
/** @var $this->params Joomla\Registry\Registry */
$this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
if (!$this->item) {
$app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice');
$app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false));
return;
}
// Get currency
// Get currency
$currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency'));
$this->amount = new Crowdfunding\Amount($this->params);
$this->amount->setCurrency($currency);
// Integrate with social profile.
$this->displayCreator = $this->params->get('integration_display_creator', true);
// Prepare integration. Load avatars and profiles.
if ($this->displayCreator and (is_object($this->item) and $this->item->user_id > 0)) {
$socialProfilesBuilder = new Prism\Integration\Profile\Builder(array('social_platform' => $this->params->get('integration_social_platform'), 'user_id' => $this->item->user_id));
$socialProfilesBuilder->build();
$socialProfile = $socialProfilesBuilder->getProfile();
$this->socialProfileLink = !$socialProfile ? null : $socialProfile->getLink();
}
// Set a link to project page
$uri = JUri::getInstance();
$host = $uri->toString(array('scheme', '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;
$layout = $this->getLayout();
if ($this->getLayout() === 'email') {
if (!$this->params->get('security_display_friend_form', 0)) {
$app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_CANT_SEND_MAIL'), 'notice');
$app->redirect(JRoute::_($this->item->link, false));
return;
}
$this->prepareEmailForm($this->item);
} else {
$this->embedCode = $this->prepareEmbedCode($this->item, $host);
}
$this->prepareDocument();
parent::display($tpl);
}
示例4: save
public function save($key = null, $urlVar = null)
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$userId = (int) JFactory::getUser()->get('id');
if (!$userId) {
$redirectOptions = array('force_direction' => 'index.php?option=com_users&view=login');
$this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_NOT_LOG_IN'), $redirectOptions);
return;
}
// Get the data from the form POST
$data = $this->input->post->get('jform', array(), 'array');
$itemId = Joomla\Utilities\ArrayHelper::getValue($data, 'project_id', 0, 'int');
// Get project
$item = Crowdfunding\Project::getInstance(JFactory::getDbo(), $itemId);
$redirectOptions = array('force_direction' => CrowdfundingHelperRoute::getDetailsRoute($item->getSlug(), $item->getCatSlug(), 'updates'));
// Check for valid owner.
if ($userId !== $item->getUserId()) {
$this->displayWarning(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), $redirectOptions);
return;
}
$model = $this->getModel();
/** @var $model CrowdfundingModelUpdate */
$form = $model->getForm($data, false);
/** @var $form JForm */
if (!$form) {
throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_FORM_CANNOT_BE_LOADED'));
}
// Test if the data is valid.
$validData = $model->validate($form, $data);
// Check for validation errors.
if ($validData === false) {
$errors = $form->getErrors();
$error = array_shift($errors);
$msg = $error->getMessage();
$this->displayNotice($msg, $redirectOptions);
return;
}
try {
$model->save($validData);
} catch (Exception $e) {
JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
}
// Redirect to next page
$this->displayMessage(JText::_('COM_CROWDFUNDING_UPDATE_SUCCESSFULLY_SAVED'), $redirectOptions);
}
示例5: loadFormData
/**
* Method to get the data that should be injected in the form.
*
* @throws \Exception
* @return mixed The data for the form.
* @since 1.6
*/
protected function loadFormData()
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
$data = $app->getUserState($this->option . '.edit.friendmail.data', array());
if (!$data) {
$item = $this->getItem();
// Prepare default content of the form
if ((int) $item->id > 0) {
$link = JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($item->slug, $item->catslug));
$data = array('id' => $item->id, 'subject' => JText::sprintf('COM_CROWDFUNDING_SEND_FRIEND_DEFAULT_SUBJECT', $item->title), 'message' => JText::sprintf('COM_CROWDFUNDING_SEND_FRIEND_DEFAULT_MESSAGE', $link));
// Set user data
$user = JFactory::getUser();
if ((int) $user->get('id') > 0) {
$data['sender_name'] = $user->name;
$data['sender'] = $user->email;
}
}
}
return $data;
}
示例6: onContentBeforeDisplay
/**
* @param string $context
* @param object $article
* @param Joomla\Registry\Registry $params
* @param int $page
*
* @return null|string
* @throws Exception
*/
public function onContentBeforeDisplay($context, &$article, &$params, $page = 0)
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
if ($app->isAdmin()) {
return null;
}
$doc = JFactory::getDocument();
/** @var $doc JDocumentHtml */
// Check document type
$docType = $doc->getType();
if (strcmp("html", $docType) != 0) {
return null;
}
if (strcmp("com_crowdfunding.details", $context) != 0) {
return null;
}
// Load language
$this->loadLanguage();
$itemId = $app->input->getInt("id");
$stats = CrowdfundingHelper::getProjectData($itemId);
$screen = $app->input->getCmd("screen", "home");
$html = '<ul class="nav nav-pills cf-plg-navigation">';
if ($this->params->get("display_home")) {
$class = 'class="cf-plg-nav-home';
if (strcmp($screen, "home") == 0) {
$class .= ' active';
}
$class .= '"';
$html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug)) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_HOME") . "</a></li>";
}
if ($this->params->get("display_updates")) {
$class = 'class="cf-plg-nav-updates';
if (strcmp($screen, "updates") == 0) {
$class .= ' active';
}
$class .= '"';
$stat = '<span class="badge">' . Joomla\Utilities\ArrayHelper::getValue($stats, "updates", 0) . '</span>';
$html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "updates")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_UPDATES") . ' ' . $stat . '</a></li>';
}
if ($this->params->get("display_comments")) {
$class = 'class="cf-plg-nav-comments';
if (strcmp($screen, "comments") == 0) {
$class .= ' active';
}
$class .= '"';
if (!$params->get("comments_enabled", 1)) {
$stat = '<span class="cf-dclabel"> </span>';
} else {
$stat = '<span class="badge">' . Joomla\Utilities\ArrayHelper::getValue($stats, "comments", 0) . '</span>';
}
$html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "comments")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_COMMENTS") . ' ' . $stat . '</a></li>';
}
if ($this->params->get("display_funders")) {
$class = 'class="cf-plg-nav-funders';
if (strcmp($screen, "funders") == 0) {
$class .= ' active';
}
$class .= '"';
$stat = '<span class="badge">' . Joomla\Utilities\ArrayHelper::getValue($stats, "funders", 0) . '</span>';
$html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "funders")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_FUNDERS") . ' ' . $stat . '</a></li>';
}
$html .= '</ul>';
return $html;
}
示例7: sendMails
/**
* Send emails to the administrator, project owner and the user who have made a donation.
*
* @param object $project
* @param object $transaction
* @param Registry $params
*/
protected function sendMails($project, $transaction, $params)
{
$app = \JFactory::getApplication();
/** @var $app \JApplicationSite */
// Get website
$uri = \JUri::getInstance();
$website = $uri->toString(array("scheme", "host"));
$emailMode = $this->params->get("email_mode", "plain");
$componentParams = \JComponentHelper::getParams("com_crowdfunding");
$currency = Crowdfunding\Currency::getInstance(\JFactory::getDbo(), $componentParams->get("project_currency"));
$amount = new Crowdfunding\Amount($componentParams);
$amount->setCurrency($currency);
// Prepare data for parsing.
$data = array("site_name" => $app->get("sitename"), "site_url" => \JUri::root(), "item_title" => $project->title, "item_url" => $website . \JRoute::_(\CrowdfundingHelperRoute::getDetailsRoute($project->slug, $project->catslug)), "amount" => $amount->setValue($transaction->txn_amount)->formatCurrency(), "transaction_id" => $transaction->txn_id);
// Prepare data about payer if he is NOT anonymous ( is registered user with profile ).
if (!empty($transaction->investor_id)) {
$investor = \JFactory::getUser($transaction->investor_id);
$data["payer_email"] = $investor->get("email");
$data["payer_name"] = $investor->get("name");
}
// Send mail to the administrator
$emailId = $this->params->get("admin_mail_id", 0);
if (!empty($emailId)) {
$email = new EmailTemplates\Email();
$email->setDb(\JFactory::getDbo());
$email->load($emailId);
if (!$email->getSenderName()) {
$email->setSenderName($app->get("fromname"));
}
if (!$email->getSenderEmail()) {
$email->setSenderEmail($app->get("mailfrom"));
}
// Prepare recipient data.
$componentParams = \JComponentHelper::getParams("com_crowdfunding");
/** @var $componentParams Registry */
$recipientId = $componentParams->get("administrator_id");
if (!empty($recipientId)) {
$recipient = \JFactory::getUser($recipientId);
$recipientName = $recipient->get("name");
$recipientMail = $recipient->get("email");
} else {
$recipientName = $app->get("fromname");
$recipientMail = $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;
$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->debugType, $mailer->ErrorInfo);
}
}
// Send mail to project owner.
$emailId = $this->params->get("creator_mail_id", 0);
if (!empty($emailId)) {
$email = new EmailTemplates\Email();
$email->setDb(\JFactory::getDbo());
$email->load($emailId);
if (!$email->getSenderName()) {
$email->setSenderName($app->get("fromname"));
}
if (!$email->getSenderEmail()) {
$email->setSenderEmail($app->get("mailfrom"));
}
$user = \JFactory::getUser($transaction->receiver_id);
$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;
$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 {
//.........这里部分代码省略.........
示例8: array
?>
"
width="<?php
echo $this->params->get('image_width');
?>
"
height="<?php
echo $this->params->get('image_height');
?>
">
</a>
<div class="caption">
<h3>
<a href="<?php
echo JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug));
?>
" target="_blank">
<?php
echo $this->escape($this->item->title);
?>
</a>
</h3>
<?php
if (!is_null($this->socialProfileLink)) {
?>
<div class="font-xxsmall">
<?php
echo JText::sprintf('COM_CROWDFUNDING_BY_S', JHtml::_('crowdfunding.socialProfileLink', $this->socialProfileLink, $this->item->user_name, array('target' => '_blank')));
?>
</div>
示例9: siteRoute
/**
* Route URI to front-end.
*
* @param object $item
* @param string $website
* @param JRouter $routerSite
*
* @return string
*/
public static function siteRoute($item, $website, $routerSite)
{
$routedUri = $routerSite->build(CrowdfundingHelperRoute::getDetailsRoute($item->slug, $item->catslug));
if ($routedUri instanceof JUri) {
$routedUri = $routedUri->toString();
}
if (false !== strpos($routedUri, "/administrator")) {
$routedUri = str_replace("/administrator", "", $routedUri);
}
return $website . $routedUri;
}
示例10: sendMail
protected function sendMail($project, $emailId)
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
// Get website
$uri = JUri::getInstance();
$website = $uri->toString(array("scheme", "host"));
$emailMode = $this->params->get("email_mode", "plain");
// Route project URI
$appSite = JApplicationCms::getInstance('site');
$router = $appSite->getRouter('site');
$routedUri = $router->build(CrowdfundingHelperRoute::getDetailsRoute($project->slug, $project->catslug));
if ($routedUri instanceof JUri) {
$routedUri = $routedUri->toString();
}
if (0 === strpos($routedUri, "/administrator")) {
$routedUri = str_replace("/administrator", "", $routedUri);
}
// Prepare data for parsing
$data = array("site_name" => $app->get("sitename"), "site_url" => JUri::root(), "item_title" => $project->title, "item_url" => $website . $routedUri);
// Send mail to the administrator
if (!$emailId) {
return false;
}
$email = new EmailTemplates\Email();
$email->setDb(JFactory::getDbo());
$email->load($emailId);
if (!$email->getSenderName()) {
$email->setSenderName($app->get("fromname"));
}
if (!$email->getSenderEmail()) {
$email->setSenderEmail($app->get("mailfrom"));
}
$recipientName = $project->name;
$recipientMail = $project->email;
// Prepare data for parsing
$data["sender_name"] = $email->getSenderName();
$data["sender_email"] = $email->getSenderEmail();
$data["recipient_name"] = $recipientName;
$data["recipient_email"] = $recipientMail;
$email->parse($data);
$subject = $email->getSubject();
$body = $email->getBody($emailMode);
$mailer = JFactory::getMailer();
if (strcmp("html", $emailMode) == 0) {
// Send as HTML message
$result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML);
} else {
// Send as plain text.
$result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN);
}
// Log the error.
if ($result !== true) {
$this->log->add(JText::sprintf("PLG_CONTENT_CROWDFUNDINGUSERMAIL_ERROR_SEND_MAIL", $this->name), "PLG_CONTENT_USERE_MAIL_ERROR", JText::sprintf("PLG_CONTENT_CROWDFUNDINGUSERMAIL_ERROR_SEND_MAIL_NOTE", $mailer->ErrorInfo));
return false;
}
return true;
}
示例11: sendMail
/**
* @param stdClass $project
* @param int $emailId
*
* @return bool
*/
protected function sendMail($project, $emailId)
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
// Get website
$uri = JUri::getInstance();
$website = $uri->toString(array('scheme', 'host'));
$emailMode = $this->params->get('email_mode', 'plain');
// Route project URI
$appSite = JApplicationCms::getInstance('site');
$router = $appSite->getRouter('site');
$routedUri = $router->build(CrowdfundingHelperRoute::getDetailsRoute($project->slug, $project->catslug));
if ($routedUri instanceof JUri) {
$routedUri = $routedUri->toString();
}
if (0 === strpos($routedUri, '/administrator')) {
$routedUri = str_replace('/administrator', '', $routedUri);
}
// Prepare data for parsing
$data = array('site_name' => $app->get('sitename'), 'site_url' => JUri::root(), 'item_title' => $project->title, 'item_url' => $website . $routedUri);
$email = new Emailtemplates\Email();
$email->setDb(JFactory::getDbo());
$email->load($emailId);
if (!$email->getSenderName()) {
$email->setSenderName($app->get('fromname'));
}
if (!$email->getSenderEmail()) {
$email->setSenderEmail($app->get('mailfrom'));
}
$recipientName = $project->name;
$recipientMail = $project->email;
// Prepare data for parsing
$data['sender_name'] = $email->getSenderName();
$data['sender_email'] = $email->getSenderEmail();
$data['recipient_name'] = $recipientName;
$data['recipient_email'] = $recipientMail;
$email->parse($data);
$subject = $email->getSubject();
$body = $email->getBody($emailMode);
$mailer = JFactory::getMailer();
if (strcmp('html', $emailMode) === 0) {
// Send as HTML message
$result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML);
} else {
// Send as plain text.
$result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN);
}
// Log the error.
if ($result !== true) {
JLog::add($this->errorPrefix . $mailer->ErrorInfo, JLog::WARNING, 'com_crowdfunding');
return false;
}
return true;
}
示例12: display
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 = true;
if (!empty($this->item->type_id)) {
$type = new Crowdfunding\Type(JFactory::getDbo());
$type->load($this->item->type_id);
if ($type->getId() and !$type->isRewardsEnabled()) {
$this->rewardsEnabled = false;
}
}
// 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));
$this->prepareDebugMode($paymentSession);
$this->prepareDocument();
parent::display($tpl);
}
示例13: sendReportMail
protected function sendReportMail($report, $emailId)
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
// Send mail to the administrator
if (!$emailId) {
return false;
}
// Get website
$uri = JUri::getInstance();
$website = $uri->toString(array('scheme', 'host'));
$emailMode = $this->params->get('email_mode', 'plain');
// Get project
$project = Crowdfunding\Project::getInstance(JFactory::getDbo(), $report->project_id);
// Prepare data for parsing
$data = array('site_name' => $app->get('sitename'), 'site_url' => JUri::root(), 'item_title' => $project->getTitle(), 'item_url' => $website . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($project->getSlug(), $project->getCatSlug())), 'report_subject' => $report->subject, 'report_description' => $report->description);
$email = new Emailtemplates\Email();
$email->setDb(JFactory::getDbo());
$email->load($emailId);
if (!$email->getSenderName()) {
$email->setSenderName($app->get('fromname'));
}
if (!$email->getSenderEmail()) {
$email->setSenderEmail($app->get('mailfrom'));
}
// Prepare recipient data.
$componentParams = JComponentHelper::getParams('com_crowdfunding');
/** @var $componentParams Joomla\Registry\Registry */
$recipientId = (int) $componentParams->get('administrator_id');
if ($recipientId > 0) {
$recipient = JFactory::getUser($recipientId);
$recipientName = $recipient->get('name');
$recipientMail = $recipient->get('email');
} else {
$recipientName = $app->get('fromname');
$recipientMail = $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;
$email->parse($data);
$subject = $email->getSubject();
$body = $email->getBody($emailMode);
$mailer = JFactory::getMailer();
if (strcmp('html', $emailMode) === 0) {
// Send as HTML message
$result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML);
} else {
// Send as plain text.
$result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN);
}
// Log the error.
if ($result !== true) {
$this->log->add(JText::sprintf('PLG_CONTENT_CROWDFUNDINGADMINMAIL_ERROR_SEND_MAIL', $this->name), 'PLG_CONTENT_ADMIN_EMAIL_ERROR', JText::sprintf('PLG_CONTENT_CROWDFUNDINGADMINMAIL_ERROR_SEND_MAIL_NOTE', $mailer->ErrorInfo));
return false;
}
return true;
}
示例14: projectTitle
public static function projectTitle($title, $categoryState, $slug, $catSlug)
{
$html = array();
if (!$categoryState) {
$html[] = htmlspecialchars($title, ENT_QUOTES, "utf-8");
$html[] = '<button type="button" class="hasTooltip" title="' . htmlspecialchars(JText::_("COM_CROWDFUNDING_SELECT_OTHER_CATEGORY_TOOLTIP"), ENT_QUOTES, "utf-8") . '">';
$html[] = '<span class="glyphicon glyphicon-info-sign"></span>';
$html[] = '</button>';
} else {
$html[] = '<a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($slug, $catSlug)) . '">';
$html[] = htmlspecialchars($title, ENT_QUOTES, "utf-8");
$html[] = '</a>';
}
return implode("\n", $html);
}
示例15: display
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);
}