本文整理汇总了PHP中locale_temp_switch函数的典型用法代码示例。如果您正苦于以下问题:PHP locale_temp_switch函数的具体用法?PHP locale_temp_switch怎么用?PHP locale_temp_switch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了locale_temp_switch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: T_
function T_($string, $req_locale = '')
{
global $current_locale, $locales, $evo_charset;
if (empty($req_locale)) {
if (empty($current_locale)) {
// don't translate if we have no locale
return $string;
}
$req_locale = $current_locale;
}
if ($req_locale == $current_locale) {
// We have not asked for a different locale than the currently active one:
$r = _($string);
$messages_charset = $locales[$req_locale]['charset'];
} else {
// We have asked for another locale...
if (locale_temp_switch($req_locale)) {
global $current_charset;
$r = _($string);
$messages_charset = $current_charset;
locale_restore_previous();
} else {
// Locale could not be activated:
$r = $string;
$messages_charset = 'iso-8859-1';
// charset of our .php files
}
}
if (!empty($evo_charset)) {
$r = convert_charset($r, $evo_charset, $messages_charset);
}
return $r;
}
示例2: newsletter_send
/**
* Send newsletter emails
*/
function newsletter_send()
{
global $DB, $Session;
load_class('users/model/_userlist.class.php', 'UserList');
// Initialize users list from session cache in order to get users IDs for newsletter
$UserList = new UserList('admin');
$UserList->memorize = false;
$UserList->load_from_Request();
$users_IDs = $UserList->filters['users'];
// Get all active users which accept newsletter email
$SQL = get_newsletter_users_sql($users_IDs);
$users = $DB->get_col($SQL->get());
echo sprintf(T_('Newsletter is sending for %s users...'), count($users)) . '<br /><br />';
evo_flush();
$email_newsletter_params = array('message' => $Session->get('newsletter_message'));
foreach ($users as $user_ID) {
$UserCache =& get_UserCache();
$User = $UserCache->get_by_ID($user_ID);
echo sprintf(T_('Email is sending for %s (%s)...'), $User->get_identity_link(), $User->get('email')) . ' ';
// Send a newsletter in user's locale
locale_temp_switch($User->get('locale'));
$email_result = send_mail_to_User($user_ID, $Session->get('newsletter_title'), 'newsletter', $email_newsletter_params);
locale_restore_previous();
if ($email_result) {
// Success sending
echo T_('OK');
} else {
// Failed sending
echo '<span class="red">' . T_('Failed') . '</span>';
}
echo '<br />';
evo_flush();
}
}
示例3: send_validate_email
/**
* Send an email to the user with a link to validate/confirm his email address.
*
* If the email could get sent, it saves the used "request_id" into the user's Session.
*
* @param string URL, where to redirect the user after he clicked the validation link (gets saved in Session).
* @return boolean True, if the email could get sent; false if not
*/
function send_validate_email($redirect_to_after, $blog = NULL, $email_changed = false)
{
global $app_name, $Session, $secure_htsrv_url, $baseurl, $servertimenow;
global $Settings, $UserSettings;
// Display messages depending on user email status
display_user_email_status_message($this->ID);
if ($Settings->get('validation_process') == 'easy') {
// validation process is set to easy, send and easy activation email
return send_easy_validate_emails(array($this->ID), false, $email_changed);
}
if (mail_is_blocked($this->email)) {
// prevent trying to send an email to a blocked email address ( Note this is checked in the send_easy_validate_emails too )
return false;
}
if (empty($redirect_to_after)) {
// redirect to was not set
$redirect_to_after = param('redirect_to', 'url', '');
if (empty($redirect_to_after)) {
if (is_admin_page()) {
$redirect_to_after = regenerate_url('action');
} else {
$redirect_to_after = $this->get_userpage_url();
}
}
}
$request_id = generate_random_key(22);
$blog_param = empty($blog) ? '' : '&inskin=1&blog=' . $blog;
// Change locale here to localize the email subject and content
locale_temp_switch($this->get('locale'));
$email_template_params = array('status' => $this->status, 'blog_param' => $blog_param, 'request_id' => $request_id);
$r = send_mail_to_User($this->ID, T_('Activate your account: $login$'), 'account_activate', $email_template_params, true);
locale_restore_previous();
if ($r) {
// save request_id into Session
$request_ids = $Session->get('core.validatemail.request_ids');
if (!is_array($request_ids) || $email_changed) {
// create new request ids array if it doesn't exist yet, or if user email changed ( this way the old request into the old email address won't be valid )
$request_ids = array();
}
$request_ids[] = $request_id;
$Session->set('core.validatemail.request_ids', $request_ids, 86400 * 2);
// expires in two days (or when clicked)
// set a redirect_to session variable because this way after the account will be activated we will know where to redirect
$Session->set('core.validatemail.redirect_to', $redirect_to_after);
$Session->dbsave();
// save immediately
// update last activation email timestamp
$UserSettings->set('last_activation_email', date2mysql($servertimenow), $this->ID);
$UserSettings->dbupdate();
}
return $r;
}
示例4: send_email_notifications
/**
* Send email notifications to subscribed users:
*
* @todo fp> SEPARATE MODERATION notifications from SUBSCRIPTION notifications
* @todo shall we notify suscribers of blog were this is in extra-cat?
* @todo cache message by locale like {@link Item::send_email_notifications()}
* @todo dh> Indicator in url to see where the user came from (&from=subnote ["subscription notification"]) - Problem: too long urls.
* @todo dh> "Beautify" like {@link Item::send_email_notifications()} ? fp > sure
* @todo Should include "visibility status" in the mail to the Item's Author
*/
function send_email_notifications()
{
global $DB, $admin_url, $debug, $Debuglog;
$edited_Item =& $this->get_Item();
$edited_Blog =& $edited_Item->get_Blog();
$notify_array = array();
if ($edited_Blog->get_setting('allow_subscriptions')) {
// Get list of users who want to be notfied:
// TODO: also use extra cats/blogs??
// So far you get notifications for everything. We'll need a setting to decide if you want to received unmoderated (aka unpublished) comments or not.
// Note: users receive comments on their own posts. This is done on purpose. Otherwise they think it's broken when they test the app.
$sql = 'SELECT DISTINCT user_email, user_locale
FROM T_subscriptions INNER JOIN T_users ON sub_user_ID = user_ID
WHERE sub_coll_ID = ' . $this->Item->blog_ID . '
AND sub_comments <> 0
AND LENGTH(TRIM(user_email)) > 0';
$notify_list = $DB->get_results($sql);
// Preprocess list:
foreach ($notify_list as $notification) {
$notify_array[$notification->user_email] = $notification->user_locale;
}
}
// Check if we need to include the author:
$item_author_User =& $edited_Item->get_creator_User();
if ($item_author_User->notify && !empty($item_author_User->email)) {
// Author wants to be notified...
if (!($this->get_author_User() && $item_author_User->login == $this->author_User->login)) {
// Author is not commenting on his own post...
$notify_array[$item_author_User->email] = $item_author_User->locale;
}
}
if (!count($notify_array)) {
// No-one to notify:
return false;
}
/*
* We have a list of email addresses to notify:
*/
// TODO: dh> this reveals the comments author's email address to all subscribers!!
// $notify_from should get used by default, unless the user has opted in to be the sender!
// fp>If the subscriber has permission to moderate the comments, he SHOULD receive the email address.
if ($this->get_author_User()) {
// Comment from a registered user:
$mail_from = '"' . $this->author_User->get('preferredname') . '" <' . $this->author_User->get('email') . '>';
} elseif (!empty($this->author_email)) {
// non-member, but with email address:
$mail_from = "\"{$this->author}\" <{$this->author_email}>";
} else {
// Fallback (we have no email address): fp>TODO: or the subscriber is not allowed to view it.
global $notify_from;
$mail_from = $notify_from;
}
// Send emails:
foreach ($notify_array as $notify_email => $notify_locale) {
locale_temp_switch($notify_locale);
switch ($this->type) {
case 'trackback':
/* TRANS: Subject of the mail to send on new trackbacks. First %s is the blog's shortname, the second %s is the item's title. */
$subject = T_('[%s] New trackback on "%s"');
break;
default:
/* TRANS: Subject of the mail to send on new comments. First %s is the blog's shortname, the second %s is the item's title. */
$subject = T_('[%s] New comment on "%s"');
}
$subject = sprintf($subject, $edited_Blog->get('shortname'), $edited_Item->get('title'));
$notify_message = T_('Blog') . ': ' . $edited_Blog->get('shortname') . "\n" . T_('Post') . ': ' . $edited_Item->get('title') . "\n";
// Mail bloat: .' ( '.str_replace('&', '&', $edited_Item->get_permanent_url())." )\n";
// TODO: fp> We MAY want to force short URL and avoid it to wrap on a new line in the mail which may prevent people from clicking
switch ($this->type) {
case 'trackback':
$user_domain = gethostbyaddr($this->author_IP);
$notify_message .= T_('Website') . ": {$this->author} (IP: {$this->author_IP}, {$user_domain})\n";
$notify_message .= T_('Url') . ": {$this->author_url}\n";
break;
default:
if ($this->get_author_User()) {
// Comment from a registered user:
$notify_message .= T_('Author') . ': ' . $this->author_User->get('preferredname') . ' (' . $this->author_User->get('login') . ")\n";
} else {
// Comment from visitor:
$user_domain = gethostbyaddr($this->author_IP);
$notify_message .= T_('Author') . ": {$this->author} (IP: {$this->author_IP}, {$user_domain})\n";
$notify_message .= T_('Email') . ": {$this->author_email}\n";
$notify_message .= T_('Url') . ": {$this->author_url}\n";
}
}
$notify_message .= T_('Comment') . ': ' . str_replace('&', '&', $this->get_permanent_url()) . "\n" . $this->get('content') . "\n\n" . T_('Edit/Delete') . ': ' . $admin_url . '?ctrl=items&blog=' . $edited_Blog->ID . '&p=' . $edited_Item->ID . '&c=1#c' . $this->ID . "\n\n" . T_('Edit your subscriptions/notifications') . ': ' . str_replace('&', '&', url_add_param($edited_Blog->gen_blogurl(), 'disp=subs')) . "\n";
if ($debug) {
$mail_dump = "Sending notification to {$notify_email}:<pre>Subject: {$subject}\n{$notify_message}</pre>";
if ($debug >= 2) {
//.........这里部分代码省略.........
示例5: display_if_empty
'prev_start' => '<td>',
'prev_end' => '</td>',
'next_start' => '<td class="right">',
'next_end' => '</td>',
'block_end' => '</tr></table>' ) );
}*/
?>
<!-- =================================== START OF MAIN AREA =================================== -->
<?php
// ------------------------------------ START OF POSTS ----------------------------------------
// Display message if no post:
display_if_empty();
while ($Item =& $MainList->get_item()) {
locale_temp_switch($Item->locale);
// Temporarily switch to post locale
?>
<div class="bTitle"><h3 class="bTitle"><?php
$Item->title();
?>
</h3></div>
<div class="bPost" lang="<?php
$Item->lang();
?>
">
<?php
$Item->anchor();
// Anchor for permalinks to refer to
示例6: param
/* exited */
}
break;
case 'updatepwd':
// Update password(The submit action of the change password form)
param('reqID', 'string', '');
if (!is_logged_in()) {
// Don't allow not logged in user here, because it must be logged in on the action 'changepwd' above
$Messages->add(T_('Invalid password change request! Please try again...'), 'error');
$action = 'lostpassword';
$login_required = true;
// Do not display "Without login.." link on the form
break;
}
$forgetful_User =& $current_User;
locale_temp_switch($forgetful_User->locale);
if (!$forgetful_User || empty($reqID)) {
// This was not requested
$Messages->add(T_('Invalid password change request! Please try again...'), 'error');
$action = 'lostpassword';
$login_required = true;
// Do not display "Without login.." link on the form
break;
}
// Validate provided reqID against the one stored in the user's session
if ($Session->get('core.changepwd.request_id') != $reqID) {
$Messages->add(T_('Invalid password change request! Please try again...'), 'error');
$action = 'lostpassword';
$login_required = true;
// Do not display "Without login.." link on the form
break;
示例7: mail_template
/**
* Get a mail message text by template name
*
* @param string Template name
* @param string Email format ( auto | html | text )
* @param array Params
* @param object User
* @return string Mail message
*/
function mail_template($template_name, $format = 'auto', $params = array(), $User = NULL)
{
global $current_charset, $is_admin_page;
if (!empty($params['locale'])) {
// Switch to locale for current email template
locale_temp_switch($params['locale']);
}
$value_is_admin_page = $is_admin_page;
// Set TRUE to use gender settings from back office
$is_admin_page = true;
// Set extension of template
$template_exts = array();
switch ($format) {
case 'auto':
// $template_exts['non-mime'] = '.txt.php'; // The area that is ignored by MIME-compliant clients
$template_exts['text'] = '.txt.php';
$template_exts['html'] = '.html.php';
$boundary = $params['boundary'];
$boundary_alt = 'b2evo-alt-' . md5(rand());
$template_headers = array('text' => 'Content-Type: text/plain; charset=' . $current_charset, 'html' => 'Content-Type: text/html; charset=' . $current_charset);
break;
case 'html':
$template_exts['html'] = '.html.php';
break;
case 'text':
$template_exts['text'] = '.txt.php';
break;
}
$template_message = '';
if (isset($boundary, $boundary_alt)) {
// Start new boundary content
$template_message .= "\n" . '--' . $boundary . "\n";
$template_message .= 'Content-Type: multipart/alternative; boundary="' . $boundary_alt . '"' . "\n\n";
}
foreach ($template_exts as $format => $ext) {
if (isset($boundary, $boundary_alt) && $format != 'non-mime') {
// Start new boundary alt content
$template_message .= "\n" . '--' . $boundary_alt . "\n";
}
if (isset($template_headers[$format])) {
// Header data for each content
$template_message .= $template_headers[$format] . "\n\n";
}
// Get mail template
ob_start();
emailskin_include($template_name . $ext, $params);
$template_message .= ob_get_clean();
if (!empty($User)) {
// Replace $login$ with gender colored link + icon in HTML format,
// and with simple login text in PLAIN TEXT format
$user_login = $format == 'html' ? $User->get_colored_login(array('mask' => '$avatar$ $login$')) : $User->login;
$template_message = str_replace('$login$', $user_login, $template_message);
}
}
if (isset($boundary, $boundary_alt)) {
// End all boundary contents
$template_message .= "\n" . '--' . $boundary_alt . '--' . "\n";
$template_message .= "\n" . '--' . $boundary . '--' . "\n";
}
// Return back the value
$is_admin_page = $value_is_admin_page;
if (!empty($params['locale'])) {
// Restore previous locale
locale_restore_previous();
}
return $template_message;
}
示例8: array_keys
}
if ($allowed) {
// User has permission to edit comments with this author level
$cmt_count += $count;
}
}
}
}
if ($cmt_count > 0) {
// There are comments awaiting moderation on this blog and user has permission to moderate
$blog_comments[$blog_ID] = $cmt_count;
}
}
}
if (empty($blog_comments)) {
// There are no comments awaiting moderation that this user could moderate
continue;
}
$params['blogs'] = array_keys($blog_comments);
// This can be remvoved if this solution will remain
$params['comments'] = $blog_comments;
// Change locale here to localize the email subject and content
locale_temp_switch($moderator_User->get('locale'));
if (send_mail_to_User($moderator_ID, T_('Comment moderation reminder'), 'comments_unmoderated_reminder', $params, false)) {
$mail_sent++;
}
locale_restore_previous();
}
$result_message = sprintf(T_('%d moderator have been notified!'), $mail_sent);
return 1;
/*OK*/
示例9: T_
if (empty($users_to_remind_ids)) {
// There is no user to remind after we have filtered out those ussers who haven't logged in since a long time
$result_message = T_('It was not necessary to send any reminder!');
return 1;
}
// Set TRUE to use gender settings from back office
global $is_admin_page;
$is_admin_page = true;
// Get all those user threads and their recipients where the corresponding users have unread messages
$unread_threads = get_users_unread_threads($users_to_remind_ids, NULL, 'array', 'html');
// Get unread thread urls
list($threads_link) = get_messages_link_to();
$reminder_sent = 0;
foreach ($users_to_remind_ids as $user_ID) {
// send reminder email
$email_template_params = array('unread_threads' => $unread_threads[$user_ID], 'threads_link' => $threads_link);
$notify_User = $UserCache->get_by_ID($user_ID);
// Change locale here to localize the email subject and content
locale_temp_switch($notify_User->get('locale'));
if (send_mail_to_User($user_ID, T_('You have unread messages!'), 'private_messages_unread_reminder', $email_template_params)) {
// Update users last unread message reminder timestamp
$UserSettings->set('last_unread_messages_reminder', date2mysql($servertimenow), $user_ID);
// save UserSettings after each email, because the cron task mail fail and users won't be updated!
$UserSettings->dbupdate();
$reminder_sent++;
}
locale_restore_previous();
}
$result_message = sprintf(T_('%d reminder emails were sent!'), $reminder_sent);
return 1;
/* ok */
示例10: send_email_notifications
/**
* Send email notifications to subscribed users
*
* @todo fp>> shall we notify suscribers of blog were this is in extra-cat? blueyed>> IMHO yes.
*/
function send_email_notifications($display = true)
{
global $DB, $admin_url, $debug, $Debuglog;
$edited_Blog =& $this->get_Blog();
if (!$edited_Blog->get_setting('allow_subscriptions')) {
// Subscriptions not enabled!
return;
}
if ($display) {
echo "<div class=\"panelinfo\">\n";
echo '<h3>', T_('Notifying subscribed users...'), "</h3>\n";
}
// Get list of users who want to be notfied:
// TODO: also use extra cats/blogs??
$sql = 'SELECT DISTINCT user_email, user_locale
FROM T_subscriptions INNER JOIN T_users ON sub_user_ID = user_ID
WHERE sub_coll_ID = ' . $this->blog_ID . '
AND sub_items <> 0
AND LENGTH(TRIM(user_email)) > 0';
$notify_list = $DB->get_results($sql);
// Preprocess list: (this comes form Comment::send_email_notifications() )
$notify_array = array();
foreach ($notify_list as $notification) {
$notify_array[$notification->user_email] = $notification->user_locale;
}
if (empty($notify_array)) {
// No-one to notify:
if ($display) {
echo '<p>', T_('No-one to notify.'), "</p>\n</div>\n";
}
return false;
}
/*
* We have a list of email addresses to notify:
*/
$this->get_creator_User();
$mail_from = '"' . $this->creator_User->get('preferredname') . '" <' . $this->creator_User->get('email') . '>';
// Send emails:
$cache_by_locale = array();
foreach ($notify_array as $notify_email => $notify_locale) {
if (!isset($cache_by_locale[$notify_locale])) {
// No message for this locale generated yet:
locale_temp_switch($notify_locale);
// Calculate length for str_pad to align labels:
$pad_len = max(strlen(T_('Blog')), strlen(T_('Author')), strlen(T_('Title')), strlen(T_('Url')), strlen(T_('Content')));
$cache_by_locale[$notify_locale]['subject'] = sprintf(T_('[%s] New post: "%s"'), $edited_Blog->get('shortname'), $this->get('title'));
$cache_by_locale[$notify_locale]['message'] = str_pad(T_('Blog'), $pad_len) . ': ' . $edited_Blog->get('shortname') . ' ( ' . str_replace('&', '&', $edited_Blog->gen_blogurl()) . " )\n" . str_pad(T_('Author'), $pad_len) . ': ' . $this->creator_User->get('preferredname') . ' (' . $this->creator_User->get('login') . ")\n" . str_pad(T_('Title'), $pad_len) . ': ' . $this->get('title') . "\n" . str_pad(T_('Url'), $pad_len) . ': ' . (empty($this->url) ? '-' : str_replace('&', '&', $this->get('url'))) . "\n" . str_pad(T_('Content'), $pad_len) . ': ' . str_replace('&', '&', $this->get_permanent_url()) . "\n\n" . $this->get('content') . "\n" . "\n-- \n" . T_('Edit/Delete') . ': ' . $admin_url . '?ctrl=items&blog=' . $this->blog_ID . '&p=' . $this->ID . "\n\n" . T_('Edit your subscriptions/notifications') . ': ' . str_replace('&', '&', url_add_param($edited_Blog->gen_blogurl(), 'disp=subs')) . "\n";
locale_restore_previous();
}
if ($display) {
echo T_('Notifying:') . $notify_email . "<br />\n";
}
if ($debug >= 2) {
echo "<p>Sending notification to {$notify_email}:<pre>{$cache_by_locale[$notify_locale]}['message']</pre>";
}
send_mail($notify_email, $cache_by_locale[$notify_locale]['subject'], $cache_by_locale[$notify_locale]['message'], $mail_from);
}
if ($display) {
echo '<p>', T_('Done.'), "</p>\n</div>\n";
}
}
示例11: load_class
global $locale_from_get, $disp_handler, $disp_handler_custom, $disp_handler_custom_found;
global $Session;
load_class('_core/ui/_menu.class.php', 'Menu');
/**
* @global Menu Evobar menu on the top left (should be useed for content & system management features)
*/
global $topleft_Menu;
$topleft_Menu = new Menu();
/**
* @global Menu Evobar menu on the top right (should be used for current user's session, profile & prefs features)
*/
global $topright_Menu;
$topright_Menu = new Menu();
// Switch to users locale (if not overridden via REQUEST):
if (!$locale_from_get) {
locale_temp_switch($current_User->locale);
}
// Let the modules construct the menu:
modules_call_method('build_evobar_menu');
// Call AdminAfterToolbarInit to notify Plugins that the toolbar menus are initialized. Plugins can add entries.
$Plugins->trigger_event('AdminAfterEvobarInit');
?>
<div id="evo_toolbar" class="evo_toolbar_<?php
echo $Hit->get_agent_name();
?>
">
<div class="actions_right">
<?php
// Display evobar menu:
echo $topright_Menu->get_html_menu(NULL, 'evobar-menu-right');
示例12: mail_template
/**
* Get a mail message text by template name
*
* @param string Template name
* @param string Email format ( auto | html | text )
* @param array Params
* @param object User
* @return string|array Mail message OR Array of the email contents when message is multipart content
*/
function mail_template($template_name, $format = 'auto', $params = array(), $User = NULL)
{
global $current_charset;
if (!empty($params['locale'])) {
// Switch to locale for current email template
locale_temp_switch($params['locale']);
}
// Set extension of template
$template_exts = array();
switch ($format) {
case 'auto':
// $template_exts['non-mime'] = '.txt.php'; // The area that is ignored by MIME-compliant clients
$template_exts['text'] = '.txt.php';
$template_exts['html'] = '.html.php';
$boundary = $params['boundary'];
$boundary_alt = 'b2evo-alt-' . md5(rand());
$template_headers = array('text' => 'Content-Type: text/plain; charset=' . $current_charset, 'html' => 'Content-Type: text/html; charset=' . $current_charset);
// Store all contents in this array for multipart message
$template_contents = array('charset' => $current_charset, 'full' => '', 'html' => '', 'text' => '');
break;
case 'html':
$template_exts['html'] = '.html.php';
break;
case 'text':
$template_exts['text'] = '.txt.php';
break;
}
$template_message = '';
if (isset($boundary, $boundary_alt)) {
// Start new boundary content
$template_message .= "\n" . '--' . $boundary . "\n";
$template_message .= 'Content-Type: multipart/alternative; boundary="' . $boundary_alt . '"' . "\n\n";
}
foreach ($template_exts as $format => $ext) {
$formated_message = '';
if (isset($boundary, $boundary_alt) && $format != 'non-mime') {
// Start new boundary alt content
$template_message .= "\n" . '--' . $boundary_alt . "\n";
}
if (isset($template_headers[$format])) {
// Header data for each content
$template_message .= $template_headers[$format] . "\n\n";
}
// Get mail template
ob_start();
emailskin_include($template_name . $ext, $params);
$formated_message .= ob_get_clean();
if (!empty($User)) {
// Replace $login$ with gender colored link + icon in HTML format,
// and with simple login text in PLAIN TEXT format
$user_login = $format == 'html' ? $User->get_colored_login(array('mask' => '$avatar$ $login$', 'use_style' => true)) : $User->login;
$formated_message = str_replace('$login$', $user_login, $formated_message);
}
if ($format == 'html') {
// Use "http://" for protocol-relative urls because email browsers cannot load such urls:
$formated_message = preg_replace('~(src|href)="//~', '$1="http://', $formated_message);
}
$template_message .= $formated_message;
if (isset($template_contents)) {
// Multipart content
$template_contents[$format] = $formated_message;
}
}
if (isset($boundary, $boundary_alt)) {
// End all boundary contents
$template_message .= "\n" . '--' . $boundary_alt . '--' . "\n";
$template_message .= "\n" . '--' . $boundary . '--' . "\n";
}
if (!empty($params['locale'])) {
// Restore previous locale
locale_restore_previous();
}
if (isset($template_contents)) {
// Return array for multipart content
$template_contents['full'] = $template_message;
return $template_contents;
} else {
// Return string if email message contains one content (html or text)
return $template_message;
}
}
示例13: locale_temp_switch
/**
* Template function: Temporarily switch to this post's locale or to current blog's locale depending on setting
*/
function locale_temp_switch()
{
global $Blog;
if (!empty($Blog) && $Blog->get_setting('post_locale_source') == 'blog') {
// Use locale what current blog is using now
return;
} else {
// Use locale of this post
$locale = $this->locale;
}
locale_temp_switch($locale);
}
示例14: preview_from_request
/**
* We want to preview a single post, we are going to fake a lot of things...
*/
function preview_from_request()
{
global $current_User;
if (empty($current_User)) {
// dh> only logged in user's can preview. Alternatively we need those checks where $current_User gets used below.
return;
}
global $DB, $localtimenow, $Messages, $BlogCache;
global $Plugins;
$preview_userid = param('preview_userid', 'integer', true);
$post_status = param('post_status', 'string', true);
$post_locale = param('post_locale', 'string', $current_User->locale);
$content = param('content', 'html', true);
$post_title = param('post_title', 'html', true);
$post_excerpt = param('post_excerpt', 'string', true);
$post_url = param('post_url', 'string', '');
$post_category = param('post_category', 'integer', true);
$post_views = param('post_views', 'integer', 0);
$renderers = param('renderers', 'array', array('default'));
if (!is_array($renderers)) {
// dh> workaround for param() bug. See rev 1.93 of /inc/_misc/_misc.funcs.php
$renderers = array('default');
}
$comment_Blog =& $BlogCache->get_by_ID(get_catblog($post_category));
if ($comment_Blog->allowcomments == 'post_by_post') {
// param is required
$post_comment_status = param('post_comment_status', 'string', true);
} else {
$post_comment_status = $comment_Blog->allowcomments;
}
// Get issue date, using the user's locale (because it's entered like this in the form):
locale_temp_switch($current_User->locale);
param_date('item_issue_date', T_('Please enter a valid issue date.'), false);
// TODO: dh> get_param() is always true here, also on invalid dates:
if (strlen(get_param('item_issue_date'))) {
// only set it, if a date was given:
param_time('item_issue_time');
$item_issue_date = form_date(get_param('item_issue_date'), get_param('item_issue_time'));
// TODO: cleanup...
} else {
$item_issue_date = date('Y-m-d H:i:s', $localtimenow);
}
locale_restore_previous();
if (!($item_typ_ID = param('item_typ_ID', 'integer', NULL))) {
$item_typ_ID = NULL;
}
if (!($item_st_ID = param('item_st_ID', 'integer', NULL))) {
$item_st_ID = NULL;
}
if (!($item_assigned_user_ID = param('item_assigned_user_ID', 'integer', NULL))) {
$item_assigned_user_ID = NULL;
}
if (!($item_deadline = param('item_deadline', 'string', NULL))) {
$item_deadline = NULL;
}
$item_priority = param('item_priority', 'integer', NULL);
// QUESTION: can this be also empty/NULL?
// Do some optional filtering on the content
// Typically stuff that will help the content to validate
// Useful for code display.
// Will probably be used for validation also.
$Plugins_admin =& get_Cache('Plugins_admin');
$Plugins_admin->filter_contents($post_title, $content, $renderers);
$post_title = format_to_post($post_title);
$content = format_to_post($content);
$this->sql = "SELECT\r\n\t\t\t0 AS post_ID,\r\n\t\t\t{$preview_userid} AS post_creator_user_ID,\r\n\t\t\t{$preview_userid} AS post_lastedit_user_ID,\r\n\t\t\t'{$item_issue_date}' AS post_datestart,\r\n\t\t\t'{$item_issue_date}' AS post_datecreated,\r\n\t\t\t'{$item_issue_date}' AS post_datemodified,\r\n\t\t\t'" . $DB->escape($post_status) . "' AS post_status,\r\n\t\t\t'" . $DB->escape($post_locale) . "' AS post_locale,\r\n\t\t\t'" . $DB->escape($content) . "' AS post_content,\r\n\t\t\t'" . $DB->escape($post_title) . "' AS post_title,\r\n\t\t\t'" . $DB->escape($post_excerpt) . "' AS post_excerpt,\r\n\t\t\tNULL AS post_urltitle,\r\n\t\t\t'" . $DB->escape($post_url) . "' AS post_url,\r\n\t\t\t{$post_category} AS post_main_cat_ID,\r\n\t\t\t{$post_views} AS post_views,\r\n\t\t\t'' AS post_flags,\r\n\t\t\t'noreq' AS post_notifications_status,\r\n\t\t\tNULL AS post_notifications_ctsk_ID,\r\n\t\t\t" . bpost_count_words($content) . " AS post_wordcount,\r\n\t\t\t" . $DB->quote($post_comment_status) . " AS post_comment_status,\r\n\t\t\t'" . $DB->escape(implode('.', $renderers)) . "' AS post_renderers,\r\n\t\t\t" . $DB->quote($item_assigned_user_ID) . " AS post_assigned_user_ID,\r\n\t\t\t" . $DB->quote($item_typ_ID) . " AS post_ptyp_ID,\r\n\t\t\t" . $DB->quote($item_st_ID) . " AS post_pst_ID,\r\n\t\t\t" . $DB->quote($item_deadline) . " AS post_datedeadline,\r\n\t\t\t" . $DB->quote($item_priority) . " AS post_priority";
$this->total_rows = 1;
$this->total_pages = 1;
$this->page = 1;
// ATTENTION: we skip the parent on purpose here!! fp> refactor
DataObjectList2::query(false, false, false, 'PREVIEW QUERY');
$Item =& $this->Cache->instantiate($this->rows[0]);
// Trigger plugin event, allowing to manipulate or validate the item before it gets previewed
$Plugins->trigger_event('AppendItemPreviewTransact', array('Item' => &$Item));
if ($errcontent = $Messages->display(T_('Invalid post, please correct these errors:'), '', false, 'error')) {
$Item->content = $errcontent . "\n<hr />\n" . $content;
}
// little funky fix for IEwin, rawk on that code
global $Hit;
if ($Hit->is_winIE && !isset($IEWin_bookmarklet_fix)) {
// QUESTION: Is this still needed? What about $IEWin_bookmarklet_fix? (blueyed)
$Item->content = preg_replace('/\\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10). ';'", $Item->content);
}
}
示例15: T_
<?php
if ($current_User->check_perm('options', 'edit') && $allow_po_extraction) {
echo '<th class="lastcol">' . T_('Extract') . '</th>';
}
}
?>
</tr>
<?php
$i = 0;
// counter to distinguish POSTed locales later
foreach ($locales as $lkey => $lval) {
$i++;
// Generate preview of date/time-format:
locale_temp_switch($lkey);
$datefmt_preview = date_i18n($locales[$lkey]['datefmt'], $localtimenow);
$timefmt_preview = date_i18n($locales[$lkey]['timefmt'], $localtimenow);
locale_restore_previous();
?>
<tr class="<?php
echo $i % 2 == 1 ? 'odd' : 'even';
?>
">
<td class="firstcol left" title="<?php
echo T_('Priority') . ': ' . $locales[$lkey]['priority'] . ', ' . T_('Charset') . ': ' . $locales[$lkey]['charset'] . ', ' . T_('Lang file') . ': ' . $locales[$lkey]['messages'];
?>
">
<?php
echo '<input type="hidden" name="loc_' . $i . '_locale" value="' . $lkey . '" />';
locale_flag($lkey);