本文整理汇总了PHP中Languages::get_locale方法的典型用法代码示例。如果您正苦于以下问题:PHP Languages::get_locale方法的具体用法?PHP Languages::get_locale怎么用?PHP Languages::get_locale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Languages
的用法示例。
在下文中一共展示了Languages::get_locale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remindersEmail
/**
* reminderAction
* This action send to every customers an email
* reminder about their expiring services and domains
*/
public static function remindersEmail()
{
$i = 0;
$customers = array();
$translator = Shineisp_Registry::getInstance()->Zend_Translate;
/* We have to start to get all the domains that them expiring date is today
then we have to create a custom array sorted by customerID in order to
group services and domains of a particular customer.
*/
// Get all the active domains that expire in 1 day
$domains = Domains::getExpiringDomainsByRange(0, 30, Statuses::id('active', 'domains'));
if ($domains) {
// Create the customer group list for the email summary
foreach ($domains as $domain) {
if ($domain['reseller']) {
$invoice_dest = Customers::getAllInfo($domain['reseller']);
$customers[$domain['customer_id']]['id'] = $invoice_dest['customer_id'];
$customers[$domain['customer_id']]['fullname'] = $invoice_dest['firstname'] . " " . $invoice_dest['lastname'] . " " . $invoice_dest['company'];
$customers[$domain['customer_id']]['email'] = $invoice_dest['email'];
$customers[$domain['customer_id']]['language_id'] = $invoice_dest['language_id'];
} else {
$customers[$domain['customer_id']]['id'] = $domain['customer_id'];
$customers[$domain['customer_id']]['fullname'] = $domain['fullname'];
$customers[$domain['customer_id']]['email'] = $domain['email'];
$customers[$domain['customer_id']]['language_id'] = $domain['language_id'];
}
$customers[$domain['customer_id']]['products'][$i]['name'] = $domain['domain'];
$customers[$domain['customer_id']]['products'][$i]['type'] = "domain";
$customers[$domain['customer_id']]['products'][$i]['renew'] = $domain['renew'];
$customers[$domain['customer_id']]['products'][$i]['expiring_date'] = $domain['expiringdate'];
$customers[$domain['customer_id']]['products'][$i]['days'] = $domain['days'];
$customers[$domain['customer_id']]['products'][$i]['oldorderitemid'] = $domain['detail_id'];
$i++;
}
}
/*
* Now we have to get the services expired and we have to sum the previous $customers array with these
* new information.
*/
// Get all the services active that expire the day after
$services = OrdersItems::getExpiringServicesByRange(0, 30, Statuses::id("complete", "orders"));
if ($services) {
// Create the customer group list for the email summary
foreach ($services as $service) {
if ($service['reseller']) {
$invoice_dest = Customers::getAllInfo($service['reseller']);
$customers[$service['customer_id']]['id'] = $invoice_dest['customer_id'];
$customers[$service['customer_id']]['fullname'] = $invoice_dest['firstname'] . " " . $invoice_dest['lastname'] . " " . $invoice_dest['company'];
$customers[$service['customer_id']]['email'] = $customer_email = Contacts::getEmails($invoice_dest['customer_id']);
$customers[$service['customer_id']]['password'] = $invoice_dest['password'];
$customers[$service['customer_id']]['language_id'] = $invoice_dest['language_id'];
} else {
$customers[$service['customer_id']]['id'] = $service['id'];
$customers[$service['customer_id']]['fullname'] = $service['fullname'];
$customers[$service['customer_id']]['email'] = $customer_email = Contacts::getEmails($service['id']);
$customers[$service['customer_id']]['password'] = $service['password'];
$customers[$service['customer_id']]['language_id'] = $service['language_id'];
}
$customers[$service['customer_id']]['products'][$i]['name'] = $service['product'];
$customers[$service['customer_id']]['products'][$i]['type'] = "service";
$customers[$service['customer_id']]['products'][$i]['renew'] = $service['renew'];
$customers[$service['customer_id']]['products'][$i]['expiring_date'] = $service['expiringdate'];
$customers[$service['customer_id']]['products'][$i]['days'] = $service['days'];
$customers[$service['customer_id']]['products'][$i]['oldorderitemid'] = $service['detail_id'];
$i++;
}
}
// EMAIL SUMMARY FOR ALL THE EXPIRED AND NOT AUTORENEWABLE DOMAINS/SERVICES
// =========================================================================
// Create the emailS for the customers
if (count($customers) > 0) {
// For each client do ...
foreach ($customers as $customer) {
$items = array();
$translator->setLocale(Languages::get_locale($customer['language_id']));
// Check if there are some product to be expired
if (count($customer['products']) > 0) {
$i = 0;
// For each product do ...
foreach ($customer['products'] as $product) {
$items[$i][$translator->translate("Expiry Date")] = $product['expiring_date'];
$items[$i][$translator->translate("Days")] = $product['days'];
$items[$i][$translator->translate("Description")] = $product['name'];
if ($product['renew']) {
$items[$i][$translator->translate("Auto Renewal")] = $translator->translate("Active");
} else {
$items[$i][$translator->translate("Auto Renewal")] = $translator->translate("Not Active");
}
$i++;
}
}
$items = Shineisp_Commons_Utilities::array2table($items);
if (!empty($items)) {
Shineisp_Commons_Utilities::sendEmailTemplate($customer['email'], 'reminder', array('items' => $items, 'fullname' => $customer['fullname']), null, null, null, null, $customer['language_id'], Settings::findbyParam('cron_notify'));
}
//.........这里部分代码省略.........
示例2: getEmailTemplate
public static function getEmailTemplate($template, $language_id = null)
{
$fallbackLocale = "en_US";
$subject = "";
$locale = Shineisp_Registry::get('Zend_Locale')->toString();
if (empty($language_id)) {
$language_id = Languages::get_language_id($locale);
} else {
$locale = Languages::get_locale($language_id);
}
$EmailTemplate = EmailsTemplates::findByCode($template, null, false, $language_id);
// Template missing from DB. Let's add it.
if (!is_object($EmailTemplate) || !isset($EmailTemplate->EmailsTemplatesData) || !isset($EmailTemplate->EmailsTemplatesData->{0}) || !isset($EmailTemplate->EmailsTemplatesData->{0}->subject)) {
$filename = PUBLIC_PATH . "/languages/emails/" . $locale . "/" . $template . ".htm";
// Check if the file exists
if (!file_exists($filename)) {
$filename = PUBLIC_PATH . "/languages/emails/" . $fallbackLocale . "/" . $template . ".htm";
Shineisp_Commons_Utilities::log("This email template has not been found: {$filename}");
$language_id = 1;
// set the right default language id
// Also the fallback template is missing. Something strange is going on.....
if (!file_exists($filename)) {
Shineisp_Commons_Utilities::log("The default email template has not been found: {$filename}");
return array('template' => "Template: " . $template . " not found", 'subject' => $template);
}
}
// Get the content of the file
$body = '';
foreach (file($filename) as $line) {
// Get the subject written in the template file
if (preg_match('/<!--@subject\\s*(.*?)\\s*@-->/', $line, $matches)) {
$subject = $matches[1];
// Get the subject
$subject = trim($subject);
continue;
}
// Delete all the comments
$body .= preg_replace('#\\{\\*.*\\*\\}#suU', '', $line);
}
$isp = Isp::getActiveISP();
$body = trim($body);
$subject = trim($subject);
// check if the string contains html tags and if it does not contain tags
// means that it is a simple text. In this case add the tag "<br/>" for each return carrier
if (!self::isHtml($body)) {
$body = nl2br($body);
}
// Store mail in DB
$array = array('type' => 'general', 'name' => $template, 'code' => $template, 'plaintext' => 0, 'active' => 1, 'fromname' => is_array($isp) && isset($isp['company']) ? $isp['company'] : 'ShineISP', 'fromemail' => is_array($isp) && isset($isp['email']) ? $isp['email'] : 'info@shineisp.com', 'subject' => $subject, 'html' => $body);
// Save the data
EmailsTemplates::saveAll(null, $array, $language_id);
// Return the email template
return array_merge($array, array('template' => $body, 'subject' => $subject));
}
// template is numeric but there is not template in db. something strange happened. Exit.
if (is_numeric($template) && !is_object($EmailTemplate)) {
return false;
}
$email = array('subject' => $EmailTemplate->EmailsTemplatesData->{0}->subject, 'plaintext' => intval($EmailTemplate->plaintext), 'fromname' => $EmailTemplate->EmailsTemplatesData->{0}->fromname, 'fromemail' => $EmailTemplate->EmailsTemplatesData->{0}->fromemail, 'cc' => $EmailTemplate->cc, 'bcc' => $EmailTemplate->bcc, 'template' => '');
if (!empty($EmailTemplate->EmailsTemplatesData->{0}->html) && !empty($EmailTemplate->EmailsTemplatesData->{0}->text)) {
// Both version are present
$body = intval($EmailTemplate->plaintext) ? $EmailTemplate->EmailsTemplatesData->{0}->text : $EmailTemplate->EmailsTemplatesData->{0}->html;
} else {
if (empty($EmailTemplate->EmailsTemplatesData->{0}->html) && !empty($EmailTemplate->EmailsTemplatesData->{0}->text)) {
// Only TEXT version
$body = $EmailTemplate->EmailsTemplatesData->{0}->text;
} else {
// Only HTML version
$body = $EmailTemplate->EmailsTemplatesData->{0}->html;
}
}
$email['template'] = $body;
return $email;
}