本文整理汇总了PHP中install_language_from_file函数的典型用法代码示例。如果您正苦于以下问题:PHP install_language_from_file函数的具体用法?PHP install_language_from_file怎么用?PHP install_language_from_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了install_language_from_file函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mysql_error
if (!$result) {
$GLOBALS['txp_err_count']++;
echo "<b>" . $GLOBALS['txp_err_count'] . ".</b> " . mysql_error() . "<br />\n";
echo "<!--\n {$query} \n-->\n";
$GLOBALS['txp_install_successful'] = false;
}
}
# Skip the RPC language fetch when testing
if (defined('TXP_TEST')) {
return;
}
require_once txpath . '/lib/IXRClass.php';
$client = new IXR_Client('http://rpc.textpattern.com');
if (!$client->query('tups.getLanguage', $prefs['blog_uid'], LANG)) {
# If cannot install from lang file, setup the english lang
if (!install_language_from_file(LANG)) {
$lang = 'en-gb';
include_once txpath . '/setup/en-gb.php';
if (!@$lastmod) {
$lastmod = '0000-00-00 00:00:00';
}
foreach ($en_gb_lang as $evt_name => $evt_strings) {
foreach ($evt_strings as $lang_key => $lang_val) {
$lang_val = doSlash($lang_val);
if (@$lang_val) {
mysql_query("INSERT DELAYED INTO `" . PFX . "txp_lang` SET lang='en-gb', name='" . $lang_key . "', event='" . $evt_name . "', data='" . $lang_val . "', lastmod='" . $lastmod . "'");
}
}
}
}
} else {
示例2: mysql_error
if (!$result) {
$GLOBALS['txp_err_count']++;
echo "<b>" . $GLOBALS['txp_err_count'] . ".</b> " . mysql_error() . "<br />\r\n";
echo "<!--\r\n {$query} \r\n-->\r\n";
$GLOBALS['txp_install_successful'] = false;
}
}
# Skip the RPC language fetch when testing
if (defined('TXP_TEST')) {
return;
}
require_once txpath . '/lib/IXRClass.php';
$client = new IXR_Client('http://rpc.textpattern.com');
if (!$client->query('tups.getLanguage', $prefs['blog_uid'], $lang)) {
# If cannot install from lang file, setup the english lang
if (!install_language_from_file($lang)) {
$lang = 'en-gb';
include_once txpath . '/setup/en-gb.php';
if (!@$lastmod) {
$lastmod = '0000-00-00 00:00:00';
}
foreach ($en_gb_lang as $evt_name => $evt_strings) {
foreach ($evt_strings as $lang_key => $lang_val) {
$lang_val = addslashes($lang_val);
if (@$lang_val) {
mysql_query("INSERT DELAYED INTO `" . PFX . "txp_lang` SET `lang`='en-gb',`name`='{$lang_key}',`event`='{$evt_name}',`data`='{$lang_val}',`lastmod`='{$lastmod}'");
}
}
}
}
} else {
示例3: get_language
/**
* Installs a language from the RPC server or from a file.
*
* This function fetches language strings for the given language code from
* either the RPC server or a file.
*
* Action is taken based on three HTTP POST parameters: 'lang_code', 'force' and
* 'updating'. The 'lang_code' is the installed langauge, e.g. 'en-gb', 'fi-fi'.
* The 'force' when set to 'file' can be used force an installation from a local
* file. The 'updating' specifies whether only to install (0) or to update (1).
*/
function get_language()
{
global $prefs, $textarray;
require_once txpath . '/lib/IXRClass.php';
$lang_code = gps('lang_code');
$client = new IXR_Client(RPC_SERVER);
// $client->debug = true;
@set_time_limit(90);
// TODO: 90 seconds: seriously?
if (gps('force') == 'file' || !$client->query('tups.getLanguage', $prefs['blog_uid'], $lang_code)) {
if ((gps('force') == 'file' || gps('updating') !== '1') && install_language_from_file($lang_code)) {
if (defined('LANG')) {
$textarray = load_lang(LANG);
}
callback_event('lang_installed', 'file', false, $lang_code);
return list_languages(gTxt($lang_code) . sp . gTxt('updated'));
} else {
pagetop(gTxt('installing_language'));
echo graf('<span class="ui-icon ui-icon-closethick"></span> ' . gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->", array('class' => 'alert-block error'));
}
} else {
$response = $client->getResponse();
$lang_struct = unserialize($response);
if ($lang_struct === false) {
$errors = $size = 1;
} else {
array_walk($lang_struct, 'install_lang_key');
$size = count($lang_struct);
$errors = 0;
for ($i = 0; $i < $size; $i++) {
$errors += !$lang_struct[$i]['ok'];
}
if (defined('LANG')) {
$textarray = load_lang(LANG);
}
}
$msg = gTxt($lang_code) . sp . gTxt('updated');
callback_event('lang_installed', 'remote', false, $lang_code);
if ($errors > 0) {
$msg = array($msg . sprintf(" (%s errors, %s ok)", $errors, $size - $errors), E_ERROR);
}
list_languages($msg);
}
}
示例4: get_language
function get_language()
{
global $prefs, $txpcfg, $textarray;
require_once txpath . '/lib/IXRClass.php';
$lang_code = gps('lang_code');
$client = new IXR_Client(RPC_SERVER);
// $client->debug = true;
@set_time_limit(90);
if (gps('force') == 'file' || !$client->query('tups.getLanguage', $prefs['blog_uid'], $lang_code)) {
if ((gps('force') == 'file' || gps('updating') !== '1') && install_language_from_file($lang_code)) {
if (defined('LANG')) {
$textarray = load_lang(LANG);
}
return list_languages(gTxt($lang_code) . sp . gTxt('updated'));
} else {
$install_langfile = gTxt('install_langfile', array('{url}' => strong('<a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a>')));
if ($install_langfile == 'install_langfile') {
$install_langfile = 'To install new languages from file you can download them from <b><a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a></b> and place them inside your ./textpattern/lang/ directory.';
}
pagetop(gTxt('installing_language'));
echo tag(gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->", 'p', ' style="text-align:center;color:red;width:50%;margin: 2em auto"');
echo tag($install_langfile, 'p', ' style="text-align:center;width:50%;margin: 2em auto"');
}
} else {
$response = $client->getResponse();
$lang_struct = unserialize($response);
function install_lang_key(&$value, $key)
{
extract(gpsa(array('lang_code', 'updating')));
$exists = safe_field('name', 'txp_lang', "name='" . doSlash($value['name']) . "' AND lang='" . doSlash($lang_code) . "'");
$q = "name='" . doSlash($value['name']) . "', event='" . doSlash($value['event']) . "', data='" . doSlash($value['data']) . "', lastmod='" . doSlash(strftime('%Y%m%d%H%M%S', $value['uLastmod'])) . "'";
if ($exists) {
$value['ok'] = safe_update('txp_lang', $q, "lang='" . doSlash($lang_code) . "' AND name='" . doSlash($value['name']) . "'");
} else {
$value['ok'] = safe_insert('txp_lang', $q . ", lang='" . doSlash($lang_code) . "'");
}
}
array_walk($lang_struct, 'install_lang_key');
$size = count($lang_struct);
$errors = 0;
for ($i = 0; $i < $size; $i++) {
$errors += !$lang_struct[$i]['ok'];
}
if (defined('LANG')) {
$textarray = load_lang(LANG);
}
$msg = gTxt($lang_code) . sp . gTxt('updated');
if ($errors > 0) {
$msg .= sprintf(" (%s errors, %s ok)", $errors, $size - $errors);
}
return list_languages($msg);
}
}
示例5: get_language
function get_language()
{
global $prefs, $textarray;
require_once txpath . '/lib/IXRClass.php';
$lang_code = gps('lang_code');
$client = new IXR_Client(RPC_SERVER);
// $client->debug = true;
@set_time_limit(90);
if (gps('force') == 'file' || !$client->query('tups.getLanguage', $prefs['blog_uid'], $lang_code)) {
if ((gps('force') == 'file' || gps('updating') !== '1') && install_language_from_file($lang_code)) {
if (defined('LANG')) {
$textarray = load_lang(LANG);
}
return list_languages(gTxt($lang_code) . sp . gTxt('updated'));
} else {
pagetop(gTxt('installing_language'));
echo tag(gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->", 'p', ' class="error lang-msg"');
}
} else {
$response = $client->getResponse();
$lang_struct = unserialize($response);
if ($lang_struct === false) {
$errors = $size = 1;
} else {
function install_lang_key(&$value, $key)
{
extract(gpsa(array('lang_code', 'updating')));
$exists = safe_field('name', 'txp_lang', "name='" . doSlash($value['name']) . "' AND lang='" . doSlash($lang_code) . "'");
$q = "name='" . doSlash($value['name']) . "', event='" . doSlash($value['event']) . "', data='" . doSlash($value['data']) . "', lastmod='" . doSlash(strftime('%Y%m%d%H%M%S', $value['uLastmod'])) . "'";
if ($exists) {
$value['ok'] = safe_update('txp_lang', $q, "lang='" . doSlash($lang_code) . "' AND name='" . doSlash($value['name']) . "'");
} else {
$value['ok'] = safe_insert('txp_lang', $q . ", lang='" . doSlash($lang_code) . "'");
}
}
array_walk($lang_struct, 'install_lang_key');
$size = count($lang_struct);
$errors = 0;
for ($i = 0; $i < $size; $i++) {
$errors += !$lang_struct[$i]['ok'];
}
if (defined('LANG')) {
$textarray = load_lang(LANG);
}
}
$msg = gTxt($lang_code) . sp . gTxt('updated');
if ($errors > 0) {
$msg = array($msg . sprintf(" (%s errors, %s ok)", $errors, $size - $errors), E_ERROR);
}
return list_languages($msg);
}
}
示例6: get_language
function get_language()
{
global $prefs;
require_once txpath . '/lib/IXRClass.php';
$lang_code = gps('lang_code');
$client = new IXR_Client(RPC_SERVER);
// $client->debug = true;
if (gps('force') == 'file' || !$client->query('tups.getLanguage', $prefs['blog_uid'], $lang_code)) {
include_once txpath . '/lib/txplib_update.php';
if ((gps('force') == 'file' || gps('updating') !== '1') && install_language_from_file($lang_code)) {
return list_languages(gTxt($lang_code) . sp . gTxt('updated'));
} else {
$install_langfile = str_replace('{url}', strong('<a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a>'), gTxt('install_langfile'));
if ($install_langfile == 'install_langfile') {
$install_langfile = 'To install new languages from file you can download them from <b><a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a></b> and place them inside your ./textpattern/lang/ directory.';
}
pagetop(gTxt('installing_language'));
echo tag(gTxt('rpc_connect_error'), 'p', ' style="text-align:center;color:red;width:50%;margin: 2em auto"');
echo tag($install_langfile, 'p', ' style="text-align:center;width:50%;margin: 2em auto"');
}
} else {
$response = $client->getResponse();
$lang_struct = unserialize($response);
function install_lang_key($value, $key)
{
extract(gpsa(array('lang_code', 'updating')));
$exists = safe_field('name', 'txp_lang', "name='{$value['name']}' AND lang='{$lang_code}'");
$q = "name='" . doSlash($value['name']) . "', event='" . doSlash($value['event']) . "', data='" . doSlash($value['data']) . "', lastmod='" . strftime('%Y%m%d%H%M%S', $value['uLastmod']) . "'";
if ($exists) {
safe_update('txp_lang', $q, "lang='{$lang_code}' AND name='{$value['name']}'");
} else {
safe_insert('txp_lang', $q . ", lang='{$lang_code}'");
}
}
array_walk($lang_struct, 'install_lang_key');
return list_languages(gTxt($lang_code) . sp . gTxt('updated'));
}
}