本文整理汇总了PHP中language::load方法的典型用法代码示例。如果您正苦于以下问题:PHP language::load方法的具体用法?PHP language::load怎么用?PHP language::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类language
的用法示例。
在下文中一共展示了language::load方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nvweb_contact
function nvweb_contact($vars = array())
{
global $website;
global $DB;
global $current;
global $webgets;
global $dictionary;
global $webuser;
global $theme;
global $events;
$webget = 'contact';
if (!isset($webgets[$webget])) {
$webgets[$webget] = array();
global $lang;
if (empty($lang)) {
$lang = new language();
$lang->load($current['lang']);
}
// default translations
$webgets[$webget]['translations'] = array('name' => t(159, 'Name'), 'email' => t(44, 'E-Mail'), 'message' => t(380, 'Message'), 'fields_blank' => t(444, 'You left some required fields blank.'), 'contact_request_sent' => t(445, 'Your contact request has been sent. We will contact you shortly.'), 'contact_request_failed' => t(446, 'We\'re sorry. Your contact request could not be sent. Please try again or find another way to contact us.'), 'receipt_confirmation' => t(650, 'Receipt confirmation'));
// theme translations
// if the web theme has custom translations for this string subtypes, use it (for the user selected language)
/* just add the following translations to your json theme dictionary:
"name": "Name",
"email": "E-Mail",
"message": "Message",
"fields_blank": "You left some required fields blank.",
"contact_request_sent": "Your contact request has been sent. We will contact you shortly.",
"contact_request_failed": "We're sorry. Your contact request could not be sent. Please try again or find another way to contact us.",
"receipt_confirmation": "Receipt confirmation"
*/
if (!empty($website->theme) && method_exists($theme, 't')) {
foreach ($webgets[$webget]['translations'] as $code => $text) {
$theme_translation = $theme->t($code);
if (!empty($theme_translation) && $code != $theme_translation) {
$webgets[$webget]['translations'][$code] = $theme_translation;
}
}
}
}
if (empty($vars['notify'])) {
$vars['notify'] = 'alert';
}
$out = '';
switch (@$vars['mode']) {
case 'send':
if (!empty($_POST)) {
// a page may have several forms, which one do we have to check?
if (!empty($vars['form'])) {
list($field_name, $field_value) = explode('=', $vars['form']);
$field_name = trim($field_name);
$field_value = trim($field_value);
if ($_POST[$field_name] != $field_value) {
return;
}
}
// try to check if this send request really comes from the website and not from a spambot
if (parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) != $website->subdomain . '.' . $website->domain && parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) != $website->domain) {
return;
}
// prepare fields and labels
$fields = explode(',', @$vars['fields']);
$labels = explode(',', @$vars['labels']);
if (empty($labels)) {
$labels = $fields;
}
$labels = array_map(function ($key) {
global $webgets;
global $theme;
$key = trim($key);
$tmp = $theme->t($key);
if (!empty($tmp)) {
return $tmp;
} else {
return $webgets['contact']['translations'][$key];
}
}, $labels);
$fields = array_combine($fields, $labels);
// $fields = array( 'field_name' => 'field_label', ... )
// check required fields
$errors = array();
$required = array();
if (!empty($vars['required'])) {
$required = explode(',', $vars['required']);
}
if (!empty($required)) {
foreach ($required as $field) {
$field = trim($field);
$value = trim($_POST[$field]);
if (empty($value)) {
$errors[] = $fields[$field];
}
}
if (!empty($errors)) {
return nvweb_contact_notify($vars, true, $webgets[$webget]['translations']['fields_blank'] . ' (' . implode(", ", $errors) . ')');
}
}
// create e-mail message and send it
//.........这里部分代码省略.........
示例2: time
if ($debug || $session->cronCheck < time() - 3) {
cron::$crondir = root . 'cron/';
cron::$maxRuns = 16;
cron::checkAll();
$session->cronCheck = time();
}
// url routing
router::$views = root . 'views/';
router::$index = 'index';
router::$error = '404';
$uri = $_SERVER['REQUEST_URI'];
$page = router::path($uri);
// auto-html template
$tpl = new template();
$tpl->url = $_SERVER['REQUEST_URI'];
$css = ['/style/main.css', '/style/' . $session->theme . '.css'];
$js = ['http://code.jquery.com/jquery-1.10.2.min.js'];
$favicon = '/style/favicon.ico';
// translate with vars
language::$dir = root . 'lang/';
$language = new language($session->language);
$language->load($page);
require router::$views . $page . '.php';
$tpl->title = 'CSO - ' . ucwords(str_replace('/', ' ', $page));
$language->translate($tpl);
$tpl->end($css, $js, $favicon);
if ($page != router::$error) {
$session->lastpage = $_SERVER['REQUEST_URI'];
}
// millisecond counter (view source)
exit('<!--' . round(microtime(true) - start, 5) * 1000 . 'ms-->');
示例3: nvweb_webuser
function nvweb_webuser($vars = array())
{
global $website;
global $theme;
global $current;
global $webgets;
global $webuser;
global $DB;
$webget = "webuser";
if (!isset($webgets[$webget])) {
$webgets[$webget] = array();
global $lang;
if (empty($lang)) {
$lang = new language();
$lang->load($current['lang']);
}
// default translations
$webgets[$webget]['translations'] = array('login_incorrect' => t(4, 'Login incorrect.'), 'subscribed_ok' => t(541, 'Your email has been successfully subscribed to the newsletter.'), 'subscribe_error' => t(542, 'There was a problem subscribing your email to the newsletter.'), 'email_confirmation' => t(454, "An e-mail with a confirmation link has been sent to your e-mail account."), 'click_to_confirm_account' => t(607, "Click on the link below to confirm your account"), 'email_confirmation_notice' => t(608, "This is an automated e-mail sent as a result of a newsletter subscription request. If you received this e-mail by error just ignore it."), 'forgot_password_success' => t(648, "An e-mail with a temporary password has been sent to your e-mail account."), 'forgot_password_error' => t(446, "We're sorry. Your contact request could not be sent. Please try again or find another way to contact us."));
// theme translations
// if the web theme has custom translations for this string subtypes, use it (for the user selected language)
/* just add the following translations to your json theme dictionary:
"login_incorrect": "Login incorrect.",
"subscribed_ok": "Your email has been successfully subscribed to the newsletter.",
"subscribe_error": "There was a problem subscribing your email to the newsletter.",
"email_confirmation": "An e-mail with a confirmation link has been sent to your e-mail account.",
"click_to_confirm_account": "Click on the link below to confirm your account",
"email_confirmation_notice": "This is an automated e-mail sent as a result of a newsletter subscription request. If you received this e-mail by error just ignore it."
"forgot_password_success": "An e-mail with a temporary password has been sent to your e-mail account.",
"forgot_password_error": "We're sorry. Your contact request could not be sent. Please try again or find another way to contact us."
*/
if (!empty($website->theme) && method_exists($theme, 't')) {
foreach ($webgets[$webget]['translations'] as $code => $text) {
$theme_translation = $theme->t($code);
if (!empty($theme_translation) && $code != $theme_translation) {
$webgets[$webget]['translations'][$code] = $theme_translation;
}
}
}
}
$out = '';
switch ($vars['mode']) {
case 'id':
if (!empty($webuser->id)) {
$out = $webuser->id;
}
break;
case 'username':
if (!empty($webuser->username)) {
$out = $webuser->username;
}
break;
case 'fullname':
if (!empty($webuser->fullname)) {
$out = $webuser->fullname;
}
break;
case 'gender':
if (!empty($webuser->gender)) {
$out = $webuser->gender;
}
break;
case 'newsletter':
$out = $webuser->newsletter;
break;
case 'email':
if (!empty($webuser->email)) {
$out = $webuser->email;
}
break;
case 'authenticate':
$webuser_website = $vars['website'];
if (empty($webuser_website)) {
$webuser_website = $website->id;
}
$signin_username = $_REQUEST[empty($vars['username_field']) ? 'signin_username' : $vars['username_field']];
$signin_password = $_REQUEST[empty($vars['password_field']) ? 'signin_password' : $vars['password_field']];
// a page may have several forms, which one do we have to check?
if (!empty($vars['form'])) {
list($field_name, $field_value) = explode('=', $vars['form']);
if ($_POST[$field_name] != $field_value) {
return;
}
}
// ignore empty (or partial empty) forms
if (!empty($signin_username) && !empty($signin_password)) {
$signed_in = $webuser->authenticate($webuser_website, $signin_username, $signin_password);
if (!$signed_in) {
$message = $webgets[$webget]['translations']['login_incorrect'];
if (empty($vars['notify'])) {
$vars['notify'] = 'inline';
}
switch ($vars['notify']) {
case 'alert':
nvweb_after_body('js', 'alert("' . $message . '");');
break;
case 'inline':
$out = '<div class="nvweb-signin-form-error">' . $message . '</div>';
break;
// javascript callback
// javascript callback
//.........这里部分代码省略.........
示例4: define
if (!defined('DIR_BASE')) {
define('DIR_BASE', getbasepath());
}
if (!defined('HTTP_BASE')) {
define('HTTP_BASE', getbaseurl());
}
require '../common.php';
$errors = array();
$language = new language();
$language->get_languages();
$language->check_default();
$database = new Database();
if ($language->error) {
$errors[] = $language->error;
}
$language->load(isset($_POST['language']) ? $_POST['language'] : ($language->detect() ? $language->detect() : 'en'));
$languages = $language->langs;
$step = isset($_REQUEST['step']) ? $_REQUEST['step'] : 1;
$files = array('config.php');
//,'admin'.DIRECTORY_SEPARATOR.'config.php' Not Required
foreach ($files as $file) {
$file = DIR_BASE . $file;
if (!file_exists($file)) {
$errors[] = $language->get('error_not_found', $file);
} elseif (!is_writable($file)) {
@chmod($file, 0666);
if (!is_writable($file)) {
$errors[] = $language->get('error_not_666', $file);
}
}
}
示例5: foreach
foreach ($languages_available as $foo => $language_available) {
if ($language_available == $language_browser) {
$language_default = $language_browser;
$found = true;
break;
}
}
if ($found) {
break;
}
}
}
}
/* LOAD LANGUAGE */
$lang = new language();
$lang->load($language_default);
// is a recover password request?
if ($_REQUEST['action'] == 'forgot-password') {
$value = mb_strtolower(trim($_REQUEST['value']));
// look for an existing username or e-mail in Navigate CMS users table
$found_id = $DB->query_single('id', 'nv_users', ' username = ' . protect($value) . ' OR
email = ' . protect($value));
if (!$found_id) {
echo 'not_found';
} else {
$user->load($found_id);
$sent = $user->forgot_password();
if (!$sent) {
echo 'not_sent';
} else {
echo 'sent';
示例6: nvweb_blocks_init
function nvweb_blocks_init()
{
global $webgets;
global $website;
global $theme;
global $current;
$webget = 'blocks';
if (!isset($webgets[$webget])) {
$webgets[$webget] = array();
global $lang;
if (empty($lang)) {
$lang = new language();
$lang->load($current['lang']);
}
// default translations
$webgets[$webget]['translations'] = array('vote' => t(560, 'Vote'), 'votes' => t(352, 'Votes'), 'results' => t(562, 'Results'));
// theme translations
// if the web theme has custom translations for this string subtypes, use it (for the user selected language)
/* just add the following translations to your json theme dictionary:
"vote": "Vote",
"results": "Results",
*/
if (!empty($website->theme) && method_exists($theme, 't')) {
foreach ($webgets[$webget]['translations'] as $code => $text) {
$theme_translation = $theme->t($code);
if (!empty($theme_translation) && $theme_translation != $code) {
$webgets[$webget]['translations'][$code] = $theme_translation;
}
}
}
}
}
示例7: nvweb_comments
function nvweb_comments($vars = array())
{
global $website;
global $DB;
global $current;
global $webgets;
global $dictionary;
global $webuser;
global $theme;
global $events;
global $session;
$webget = 'comments';
if (!isset($webgets[$webget])) {
$webgets[$webget] = array();
global $lang;
if (empty($lang)) {
$lang = new language();
$lang->load($current['lang']);
}
// default translations
$webgets[$webget]['translations'] = array('post_a_comment' => t(379, 'Post a comment'), 'name' => t(159, 'Name'), 'email' => t(44, 'E-Mail'), 'website' => t(177, 'Website'), 'message' => t(380, 'Message'), 'email_will_not_be_published' => t(381, 'E-Mail will not be published'), 'submit' => t(382, 'Submit'), 'sign_in_or_sign_up_to_post_a_comment' => t(383, 'Sign in or Sign up to post a comment'), 'comments_on_this_entry_are_closed' => t(384, 'Comments on this entry are closed'), 'please_dont_leave_any_field_blank' => t(385, 'Please don\'t leave any field blank'), 'your_comment_has_been_received_and_will_be_published_shortly' => t(386, 'Your comment has been received and will be published shortly'), 'new_comment' => t(387, 'New comment'), 'review_comments' => t(388, 'Review comments'));
// theme translations
// if the web theme has custom translations for this string subtypes, use it (for the user selected language)
/* just add the following translations to your json theme dictionary:
"post_a_comment": "Post a comment",
"name": "Name",
"email": "E-Mail",
"website": "Website",
"message": "Message",
"email_will_not_be_published": "E-Mail will not be published",
"submit": "Submit",
"sign_in_or_sign_up_to_post_a_comment": "Sign in or Sign up to post a comment",
"comments_on_this_entry_are_closed": "Comments on this entry are closed",
"please_dont_leave_any_field_blank": "Please don't leave any field blank",
"your_comment_has_been_received_and_will_be_published_shortly": "Your comment has been received and will be published shortly",
"new_comment": "New comment",
"review_comments": "Review comments"
*/
if (!empty($website->theme) && method_exists($theme, 't')) {
foreach ($webgets[$webget]['translations'] as $code => $text) {
$theme_translation = $theme->t($code);
if (!empty($theme_translation) && $theme_translation != $code) {
$webgets[$webget]['translations'][$code] = $theme_translation;
}
}
}
}
// set default callback
if (empty($vars['callback'])) {
$vars['callback'] = 'alert';
}
// check callback attributes
$callback = $vars['callback'];
if (!empty($vars['alert_callback'])) {
$callback = $vars['alert_callback'];
} else {
if (!empty($vars['callback_alert'])) {
$callback = $vars['callback_alert'];
}
}
$callback_error = $callback;
if (!empty($vars['error_callback'])) {
$callback_error = $vars['error_callback'];
} else {
if (!empty($vars['callback_error'])) {
$callback_error = $vars['callback_error'];
}
}
$out = '';
// if the current page belongs to a structure entry
// we need to get the associated elements to retrieve and post its comments
// (because structure entry pages can't have associated comments)
// so, ONLY the FIRST element associated to a category can have comments in a structure entry page
// (of course if the element has its own page, it can have its own comments)
$element = $current['object'];
if ($current['type'] == 'structure') {
if (empty($current['structure_elements'])) {
$current['structure_elements'] = $element->elements();
}
$element = $current['structure_elements'][0];
}
switch (@$vars['mode']) {
case 'process':
if (isset($_GET['nv_approve_comment'])) {
// process 1-click comment approval
$comment = new comment();
$comment->load($_GET['id']);
if (!empty($comment->id) && $comment->status == -1) {
$hash = $_GET['hash'];
if ($hash == sha1($comment->id . $comment->email . APP_UNIQUE . serialize($website->contact_emails))) {
// hash check passed
$comment->status = 0;
$comment->save();
$response = t(555, "Item has been successfully published.");
if ($vars['notify'] == 'inline' || $callback == 'inline') {
$out = '<div class="comment-success">' . $response . '</div>';
} else {
if (!isset($vars['notify']) || $vars['notify'] == 'callback') {
nvweb_after_body("js", $callback . '("' . $response . '");');
//.........这里部分代码省略.........
示例8: nvweb_liveedit
function nvweb_liveedit($vars = array())
{
global $website;
global $current;
global $DB;
global $lang;
global $theme;
global $session;
global $webuser;
$out = array();
$url = '';
if (!empty($_SESSION['APP_USER#' . APP_UNIQUE])) {
switch ($current['type']) {
case 'item':
$url = NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=10&act=2&id=' . $current['object']->id . '&tab=2&tab_language=' . $current['lang'] . '&quickedit=true&wid=' . $website->id;
break;
case 'structure':
// load the first item
$DB->query(' SELECT id
FROM nv_items
WHERE category = ' . protect($current['category']) . '
AND permission < 2
AND website = ' . $website->id . '
');
$rs = $DB->first();
$url = NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=10&act=2&id=' . $rs->id . '&tab=2&quickedit=true&wid=' . $website->id;
break;
default:
}
if (empty($lang)) {
$lang = new language();
$lang->load($current['lang']);
}
// add jQuery if has not already been loaded in the template
$includes = array();
if (strpos($vars['nvweb_html'], 'jquery') === false) {
$includes[] = '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>';
}
$includes[] = '<script language="javascript" type="text/javascript" src="' . NAVIGATE_URL . '/js/navigate_liveedit.js"></script>';
$includes[] = '<link rel="stylesheet" type="text/css" href="' . NAVIGATE_URL . '/css/tools/navigate_liveedit.css" />';
nvweb_after_body('html', implode("\n", $includes) . "\n");
$comments = comment::pending_count();
// TODO: check user permissions before allowing "Create", "Edit" and other functions
$out[] = '<div id="navigate_liveedit_bar" style="display: none;">';
$out[] = ' <a href="' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '" target="_blank"><img src="' . NAVIGATE_URL . '/img/navigatecms/navigatecms_logo_52x24_white.png" width="52" height="24" /></a>';
$out[] = '
<div>
<ul class="navigate_liveedit_bar_menu">
<li><a href="' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=blocks&act=create" target="_blank"><img src="' . NAVIGATE_URL . '/img/icons/silk/brick.png" /> ' . t(437, 'Block') . '</a></li>
<li><a href="' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=structure&act=create" target="_blank"><img src="' . NAVIGATE_URL . '/img/icons/silk/sitemap_color.png" /> ' . t(479, 'Structure entry') . '</a></li>
<li><a href="' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=items&act=create" target="_blank"><img src="' . NAVIGATE_URL . '/img/icons/silk/page.png" /> ' . t(180, 'Item') . '</a></li>
</ul>
<a href="' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=items&act=create" target="_blank"><img src="' . NAVIGATE_URL . '/img/icons/silk/page_add.png" /> ' . t(38, 'Create') . '</a>
</div>
';
$out[] = ' <a href="' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=comments" target="_blank"><img src="' . NAVIGATE_URL . '/img/icons/silk/comments.png" /> ' . $comments . '</a>';
//$out[] = ' <div id="navigate_liveedit_bar_liveedit_button"><img src="'.NAVIGATE_URL.'/img/icons/silk/shape_square_select.png" /> '.t(458, 'Edit in place').'</div>';
$out[] = ' <div id="navigate_liveedit_bar_hide_button" style=" float: right; " title="' . t(554, 'Hide') . '">x</div>';
if (!empty($url)) {
$out[] = '<a style="float: right;" href="' . $url . '" target="_blank">
<img src="' . NAVIGATE_URL . '/img/icons/silk/application_double.png" />
' . t(456, 'Edit in Navigate CMS') . '
</a>';
}
$out[] = ' <div id="navigate_liveedit_bar_information_button" style=" float: right; "><img src="' . NAVIGATE_URL . '/img/icons/silk/information.png" /> ' . t(457, 'Information') . '</div>';
$page_type = array('item' => t(180, 'Item'), 'structure' => t(16, 'Structure'));
$page_type = $page_type[$current['type']];
$out[] = ' <div id="navigate_liveedit_bar_information">';
$out[] = ' <span>' . t(368, 'Theme') . ' <strong>' . $theme->title . '</strong></span>';
$out[] = ' <span>' . t(79, 'Template') . ' <strong>' . $theme->template_title($current['template'], false) . '</strong></span>';
$out[] = ' <span>' . t(160, 'Type') . ' <strong>' . $page_type . '</strong></span>';
$out[] = ' <span>ID <strong>' . $current['id'] . '</strong></span>';
$out[] = ' <span>' . t(46, 'Language') . ' <strong>' . language::name_by_code($session['lang']) . '</strong></span>';
$out[] = ' <span>' . t(647, 'Webuser') . ' <strong>' . (empty($webuser->id) ? '(' . mb_strtolower(t(581, "None")) . ')' : $webuser->username . ' (' . $webuser->id . ')') . '</strong></span>';
/* elements associated to this structure entry
if($current['type']=='structure')
{
if(empty($current['structure_elements']))
$current['structure_elements'] = $current['object']->elements();
$se_ids = array();
for($se=0; $se < count($current['structure_elements']); $se++)
$se_ids[] = $current['structure_elements'][$se]->id;
if(!empty($se_ids))
$out[] = ' <span>'.t(22, 'Elements').' <strong>'.implode(', ', $se_ids).'</strong></span>';
}
*/
$out[] = ' </div>';
$out[] = '</div>';
}
return implode("\n", $out);
}
示例9: user
$user = new user();
$user->load($_SESSION['APP_USER#' . APP_UNIQUE]);
if (empty($user->id)) {
header('location: ' . NAVIGATE_MAIN . '?logout');
}
}
$current_version = update::latest_installed();
// new updates check -> only Administrator (profile=1)
if ($user->profile == 1 && empty($_SESSION['latest_update']) && NAVIGATECMS_UPDATES !== false) {
$_SESSION['latest_update'] = @update::latest_available();
$_SESSION['extensions_updates'] = @extension::latest_available();
$_SESSION['themes_updates'] = @theme::latest_available();
}
$idn = new idna_convert();
$lang = new language();
$lang->load($user->language);
if (@$_COOKIE['navigate-language'] != $user->language) {
setcookie('navigate-language', $user->language, time() + 86400 * 30);
}
set_time_limit(0);
$menu_layout = new menu_layout();
$menu_layout->load();
// load the working website
$website = new Website();
if ((@$_GET['act'] == '0' || @$_GET['quickedit'] == 'true') && !empty($_GET['wid'])) {
$website->load(intval($_GET['wid']));
} else {
if (!empty($_SESSION['website_active'])) {
$website->load($_SESSION['website_active']);
} else {
$url = nvweb_self_url();