本文整理汇总了PHP中Currency::Format方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::Format方法的具体用法?PHP Currency::Format怎么用?PHP Currency::Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::Format方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GenerateEmail
public function GenerateEmail()
{
global $locale;
$sText = NewTemplater::Render("email/change.txt", $locale->strings, array("campaign-name" => $this->sCampaign->sName, "confirmation-url" => "http://redonate.net/change/{$this->sSubscription->sEmailAddress}/{$this->sId}/{$this->sKey}", "unsubscribe-url" => "http://redonate.net/manage/{$this->sSubscription->sEmailAddress}/{$this->sSubscription->sSettingsKey}", "old" => Currency::Format($this->sOldCurrency, $this->sOldAmount), "new" => Currency::Format($this->sNewCurrency, $this->sNewAmount)));
$sHtml = NewTemplater::Render("email/layout.html", $locale->strings, array("contents" => NewTemplater::Render("email/change.html", $locale->strings, array("campaign-name" => $this->sCampaign->sName, "confirmation-url" => "http://redonate.net/change/{$this->sSubscription->sEmailAddress}/{$this->sId}/{$this->sKey}", "unsubscribe-url" => "http://redonate.net/manage/{$this->sSubscription->sEmailAddress}/{$this->sSubscription->sSettingsKey}", "old" => Currency::Format($this->sOldCurrency, $this->sOldAmount), "new" => Currency::Format($this->sNewCurrency, $this->sNewAmount)))));
return array("text" => $sText, "html" => $sHtml);
}
示例2: GenerateEmail
public function GenerateEmail()
{
global $locale;
$sMethods = array();
foreach ($this->sCampaign->GetPaymentMethods() as $sPaymentMethod) {
$sMethods[] = array("name" => $sPaymentMethod->GetName(), "url" => $sPaymentMethod->GenerateUrl($this));
}
$sText = NewTemplater::Render("email/reminder.txt", $locale->strings, array("campaign-name" => $this->sCampaign->sName, "amount" => Currency::Format($this->sCurrency, $this->sAmount), "skip-url" => "http://redonate.net/pay/{$this->sSubscription->sEmailAddress}/{$this->sId}/{$this->sKey}/skip", "unsubscribe-url" => "http://redonate.net/manage/{$this->sSubscription->sEmailAddress}/{$this->sSubscription->sSettingsKey}", "methods" => $sMethods));
$sHtml = NewTemplater::Render("email/layout.html", $locale->strings, array("contents" => NewTemplater::Render("email/reminder.html", $locale->strings, array("campaign-name" => $this->sCampaign->sName, "amount" => Currency::Format($this->sCurrency, $this->sAmount), "skip-url" => "http://redonate.net/pay/{$this->sSubscription->sEmailAddress}/{$this->sId}/{$this->sKey}/skip", "unsubscribe-url" => "http://redonate.net/manage/{$this->sSubscription->sEmailAddress}/{$this->sSubscription->sSettingsKey}", "methods" => $sMethods))));
return array("text" => $sText, "html" => $sHtml);
}
示例3: urlencode
$sAmount = urlencode($_POST['amount']);
}
$sQuotedRecipient = urlencode($sPaymentMethod->sAddress);
$sQuotedName = urlencode("{$sCampaign->sName} (via ReDonate.net)");
$sQuotedNumber = urlencode("0");
$sQuotedReturnUrl = urlencode("http://redonate.net/thanks/{$sCampaign->sUrlName}");
if (filter_var($sPaymentMethod->sAddress, FILTER_VALIDATE_EMAIL)) {
$target = "https://www.paypal.com/cgi-bin/webscr?business={$sQuotedRecipient}&cmd=_donations&item_name={$sQuotedName}&item_number={$sQuotedNumber}¤cy_code={$sCurrency}&amount={$sAmount}&return={$sQuotedReturnUrl}";
} else {
/* This is most likely a hosted button ID. We can only provide limited information in this case - we can really only set the item description.
* Not sure if setting the return URL will work, but we might as well try. */
$target = "https://www.paypal.com/cgi-bin/webscr?hosted_button_id={$sQuotedRecipient}&cmd=_s-xclick&item_name={$sQuotedName}&return={$sQuotedReturnUrl}";
}
redirect($target);
return;
case PaymentMethod::BITCOIN:
if ($sPaymentRequest->sCurrency != "btc") {
$sAmount = Currency::Convert("btc", $_POST['currency'], $_POST['amount']);
} else {
$sAmount = htmlspecialchars($_POST['amount']);
}
$sPageContents = NewTemplater::Render("payment/bitcoin", $locale->strings, array("address" => $sPaymentMethod->sAddress, "amount" => Currency::Format("btc", $sAmount), "done-url" => "/thanks/{$sCampaign->sUrlName}"));
return;
default:
$sPageContents = NewTemplater::Render("payment/other", $locale->strings, array("name" => $sPaymentMethod->sCustomName, "address" => $sPaymentMethod->sAddress, "amount" => Currency::Format($_POST['currency'], $_POST['amount']), "done-url" => "/thanks/{$sCampaign->sUrlName}"));
return;
}
}
}
$sPageTitle = "Donate to {$sCampaign->sName} once";
$sPageContents = NewTemplater::Render("donate", $locale->strings, array("campaign-name" => $sCampaign->sName, "method-id" => $sPaymentMethod->sId, "urlname" => $sCampaign->sUrlName, "method-name" => $sMethodName));
示例4: die
<?php
/*
* ReDonate is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if (!isset($_APP)) {
die("Unauthorized.");
}
try {
$sPaymentMethod = $sPaymentRequest->sCampaign->GetPaymentMethod(PaymentMethod::BITCOIN);
} catch (NotFoundException $e) {
throw new RouterException("No such payment method found.");
}
if ($sPaymentRequest->sCurrency != "btc") {
$sAmount = Currency::Convert("btc", $sPaymentRequest->sCurrency, $sPaymentRequest->sAmount);
} else {
$sAmount = $sPaymentRequest->sAmount;
}
$sPageContents = NewTemplater::Render("payment/bitcoin", $locale->strings, array("address" => $sPaymentMethod->sAddress, "amount" => Currency::Format("btc", $sAmount), "done-url" => "/pay/{$sPaymentRequest->sSubscription->sEmailAddress}/{$sPaymentRequest->sId}/{$sPaymentRequest->sKey}/bitcoin/done"));
示例5: die
<?php
/*
* ReDonate is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if (!isset($_APP)) {
die("Unauthorized.");
}
try {
$sPaymentMethod = PaymentMethod::CreateFromQuery("SELECT * FROM payment_methods WHERE `CampaignId` = :CampaignId AND `Id` = :Id", array(":CampaignId" => $sPaymentRequest->sCampaign->sId, ":Id" => $router->uParameters[4]), 0, true);
} catch (NotFoundException $e) {
throw new RouterException("No such payment method found.");
}
$sPageContents = NewTemplater::Render("payment/other", $locale->strings, array("name" => $sPaymentMethod->sCustomName, "address" => $sPaymentMethod->sAddress, "amount" => Currency::Format($sPaymentRequest->sCurrency, $sPaymentRequest->sAmount), "done-url" => "/pay/{$sPaymentRequest->sSubscription->sEmailAddress}/{$sPaymentRequest->sId}/{$sPaymentRequest->sKey}/{$sPaymentMethod->sId}/done"));
示例6: die
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if (!isset($_APP)) {
die("Unauthorized.");
}
$sOtherSubscriptions = array();
foreach (Subscription::FindByEmail($sSubscription->sEmailAddress) as $sOtherSubscription) {
/* We don't want to add the currently visible subscription to the
* list of other subscriptions. */
if ($sOtherSubscription->sId != $sSubscription->sId) {
if ($sOtherSubscription->sIsConfirmed == false) {
$sStatus = "Awaiting confirmation";
} elseif ($sOtherSubscription->sIsActive == true) {
$sStatus = "Active";
} else {
$sStatus = "Cancelled";
}
$sOtherSubscriptions[] = array("name" => $sOtherSubscription->sCampaign->sName, "amount" => Currency::Format($sOtherSubscription->sCurrency, $sOtherSubscription->sAmount), "key" => $sOtherSubscription->sSettingsKey, "status" => $sStatus);
}
}
if ($sSubscription->sIsConfirmed == false) {
$sStatus = "Awaiting confirmation";
} elseif ($sSubscription->sIsActive == true) {
$sStatus = "Active";
} else {
$sStatus = "Cancelled";
}
$sPageTitle = "Manage your subscriptions";
$sPageContents = NewTemplater::Render("subscription/manage", $locale->strings, array("name" => $sSubscription->sCampaign->sName, "amount" => Currency::Format($sSubscription->sCurrency, $sSubscription->sAmount), "email" => $sSubscription->sEmailAddress, "key" => $sSubscription->sSettingsKey, "status" => $sStatus, "other" => $sOtherSubscriptions));
示例7: time
$sChangeRequest->uSubscriptionId = $sExistingSubscription->sId;
$sChangeRequest->uCampaignId = $sExistingSubscription->sCampaign->sId;
$sChangeRequest->uIsConfirmed = false;
$sChangeRequest->uDate = time();
$sChangeRequest->InsertIntoDatabase();
$sEmail = $sChangeRequest->GenerateEmail();
send_mail($sExistingSubscription->sEmailAddress, "Changes to your pledge to {$sExistingSubscription->sCampaign->sName}", $sEmail['text'], $sEmail['html']);
return;
}
$sLogEntry = new LogEntry(0);
$sLogEntry->uType = LogEntry::SUBSCRIPTION;
$sLogEntry->uIp = $_SERVER['REMOTE_ADDR'];
$sLogEntry->uData = json_encode(array("email" => $_POST['email']));
$sLogEntry->uCampaignId = $sCampaign->sId;
$sLogEntry->uDate = time();
$sLogEntry->uSessionId = session_id();
$sLogEntry->InsertIntoDatabase();
$sSubscription = new Subscription(0);
$sSubscription->uEmailAddress = $_POST['email'];
$sSubscription->uConfirmationKey = random_string(25);
$sSubscription->uSettingsKey = random_string(25);
$sSubscription->uCurrency = $_POST['currency'];
$sSubscription->uAmount = str_replace(",", ".", $_POST['amount']);
$sSubscription->uSubscriptionDate = time();
$sSubscription->uIsConfirmed = false;
$sSubscription->uIsActive = false;
$sSubscription->uCampaignId = $sCampaign->sId;
$sSubscription->InsertIntoDatabase();
send_mail($_POST['email'], "Please confirm your ReDonate pledge.", NewTemplater::Render("email/confirm.txt", $locale->strings, array("project-name" => $sCampaign->sName, "confirmation-url" => "http://redonate.net/confirm/{$sSubscription->sEmailAddress}/{$sSubscription->sConfirmationKey}/", "amount" => Currency::Format($sSubscription->sCurrency, $sSubscription->sAmount))), NewTemplater::Render("email/layout.html", $locale->strings, array("contents" => NewTemplater::Render("email/confirm.html", $locale->strings, array("project-name" => $sCampaign->sName, "confirmation-url" => "http://redonate.net/confirm/{$sSubscription->sEmailAddress}/{$sSubscription->sConfirmationKey}/", "amount" => Currency::Format($sSubscription->sCurrency, $sSubscription->sAmount))))));
$sPageContents = NewTemplater::Render("subscription/success", $locale->strings, array());
$sPageTitle = "Thanks for your pledge!";
示例8: array
$sProjections = array();
$sSubscribers = array();
try {
foreach (Campaign::CreateFromQuery("SELECT * FROM campaigns WHERE `OwnerId` = :UserId", array(":UserId" => $sCurrentUser->sId)) as $sCampaign) {
$sCampaign->UpdateStatistics();
$sPaymentMethods = array();
try {
foreach (PaymentMethod::CreateFromQuery("SELECT * FROM payment_methods WHERE `CampaignId` = :CampaignId", array(":CampaignId" => $sCampaign->sId)) as $sPaymentMethod) {
$sPaymentMethods[] = $sPaymentMethod->GetLogo();
}
} catch (NotFoundException $e) {
/* No payment methods...? */
}
if ($sCampaign->sHaveData) {
$sPercentages[] = $sCampaign->sDonationRate;
$sTotals[] = $sCampaign->sMonthlyTotal;
$sProjections[] = $sCampaign->sMonthlyProjection;
}
$sSubscribers[] = $sCampaign->sSubscriberCount;
$sCampaigns[] = array("name" => $sCampaign->sName, "urlname" => $sCampaign->sUrlName, "subscribers" => number_format($sCampaign->sSubscriberCount, 0), "rate" => number_format($sCampaign->sDonationRate, 2), "total" => Currency::Format("usd", $sCampaign->sMonthlyTotal), "projection" => Currency::Format("usd", $sCampaign->sMonthlyProjection), "one-off" => $sCampaign->sAllowOneTime, "payment-methods" => $sPaymentMethods, "have-data" => $sCampaign->sHaveData);
}
} catch (NotFoundException $e) {
/* pass */
}
$sPercentages = empty($sPercentages) ? array(0) : $sPercentages;
$sTotals = empty($sTotals) ? array(0) : $sTotals;
$sProjections = empty($sProjections) ? array(0) : $sProjections;
$sSubscribers = empty($sSubscribers) ? array(0) : $sSubscribers;
$sPageTitle = "Dashboard";
$sPageContents = NewTemplater::Render("dashboard", $locale->strings, array("campaigns" => $sCampaigns, "total-rate" => number_format(array_sum($sPercentages) / count($sPercentages), 2), "total-subscribers" => number_format(array_sum($sSubscribers), 0), "total-total" => Currency::Format("usd", array_sum($sTotals)), "total-projection" => Currency::Format("usd", array_sum($sProjections))));