本文整理汇总了PHP中build_language函数的典型用法代码示例。如果您正苦于以下问题:PHP build_language函数的具体用法?PHP build_language怎么用?PHP build_language使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了build_language函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_notice
function save_notice($noticeid, $title, $html, $displayorder, $active, $persistent, $dismissible, $criteria_array, $username, $templateversion)
{
$noticeid = save_notice_info($noticeid, $title, $displayorder, $active, $persistent, $dismissible, $criteria_array);
save_notice_phrase($noticeid, $html, $username, $templateversion);
// update the datastore notice cache
build_notice_datastore();
// rebuild languages
require_once DIR . '/includes/adminfunctions_language.php';
build_language();
}
示例2: step_3
/**
* Step #3 - Import Language XML
*
*/
function step_3()
{
$this->show_message($this->phrase['final']['import_latest_language']);
require_once DIR . '/includes/adminfunctions_language.php';
if (!($xml = file_read(DIR . '/install/vbulletin-language.xml'))) {
$this->add_error(sprintf($this->phrase['vbphrase']['file_not_found'], 'vbulletin-language.xml'), self::PHP_TRIGGER_ERROR, true);
return;
}
$this->show_message(sprintf($this->phrase['vbphrase']['importing_file'], 'vbulletin-language.xml'));
xml_import_language($xml, -1, '', false, true, !defined('SUPPRESS_KEEPALIVE_ECHO'));
build_language();
build_language_datastore();
$this->show_message($this->phrase['core']['import_done']);
}
示例3: delete
/**
* Delete a cron
*
* @param int $cronid Cron ID to be deleted
*
* @return void
*/
public function delete($cronid)
{
$this->checkHasAdminPermission('canadmincron');
$cronid = intval($cronid);
$cron = vB::getDbAssertor()->getRow('cron', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'cronid' => $cronid));
// delete phrases
vB::getDbAssertor()->assertQuery('phrase', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, 'fieldname' => 'cron', 'varname' => array('task_{$escaped_varname}_title', 'task_{$escaped_varname}_desc', 'task_{$escaped_varname}_log')));
vB::getDbAssertor()->assertQuery('cron', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, 'cronid' => $cronid));
require_once DIR . '/includes/adminfunctions_language.php';
build_language();
}
示例4: array
} else {
$sellanguages = array();
while ($language = $db->fetch_array($languages)) {
$sellanguages[$language['languageid']] = $language['title'];
}
$languageids = implode(',', array_keys($sellanguages));
$db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "user\n\t\t\tSET languageid = 0\n\t\t\tWHERE languageid NOT IN ({$languageids})\n\t\t");
if (empty($vbulletin->GPC['languageid'])) {
print_form_header('tools', 'language');
print_table_header('Select the new default language');
print_select_row('Language', 'languageid', $sellanguages, $vbulletin->options['languageid']);
print_submit_row('Submit', '');
} else {
$db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "setting\n\t\t\t\tSET value = " . $vbulletin->GPC['languageid'] . "\n\t\t\t\tWHERE varname = 'languageid'\n\t\t\t");
build_options();
build_language($vbulletin->GPC['languageid']);
build_language_datastore();
define('SCRIPT_REDIRECT', true);
}
}
}
}
}
if (defined('SCRIPT_REDIRECT')) {
echo '<p align="center" class="smallfont"><a href="tools.php" onclick="javascript:clearTimeout(timerID);">' . $vbphrase['processing_complete_proceed'] . '</a></p>';
echo "\n<script type=\"text/javascript\">\n";
echo "myvar = \"\"; timeout = " . 10 . ";\n\tfunction exec_refresh()\n\t{\n\t\twindow.status=\"" . $vbphrase['redirecting'] . "\"+myvar; myvar = myvar + \" .\";\n\t\ttimerID = setTimeout(\"exec_refresh();\", 100);\n\t\tif (timeout > 0)\n\t\t{ timeout -= 1; }\n\t\telse { clearTimeout(timerID); window.status=\"\"; window.location=\"tools.php\"; }\n\t}\n\texec_refresh();";
echo "\n</script>\n";
}
?>
<!-- START CONTROL PANEL FOOTER -->
示例5: post_install
//.........这里部分代码省略.........
$cron['active'] = $cron['active'] ? 1 : 0;
$cron['loglevel'] = $cron['loglevel'] ? 1 : 0;
$scheduling = $cron['scheduling'];
$scheduling['weekday'] = intval($scheduling['weekday']);
$scheduling['day'] = intval($scheduling['day']);
$scheduling['hour'] = intval($scheduling['hour']);
$scheduling['minute'] = explode(',', preg_replace('#[^0-9,-]#i', '', $scheduling['minute']));
if (count($scheduling['minute']) == 0) {
$scheduling['minute'] = array(0);
} else {
$scheduling['minute'] = array_map('intval', $scheduling['minute']);
}
/*insert query*/
$this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "cron\n\t\t\t\t\t\t(weekday, day, hour, minute, filename, loglevel, active, varname, volatile, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t({$scheduling['weekday']},\n\t\t\t\t\t\t{$scheduling['day']},\n\t\t\t\t\t\t{$scheduling['hour']},\n\t\t\t\t\t\t'" . $this->db->escape_string(serialize($scheduling['minute'])) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($cron['filename']) . "',\n\t\t\t\t\t\t{$cron['loglevel']},\n\t\t\t\t\t\t{$cron['active']},\n\t\t\t\t\t\t'" . $this->db->escape_string($cron['varname']) . "',\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t");
$cronid = $this->db->insert_id();
// replace either inserts, or deletes+inserts
if ($cronid) {
build_cron_item($cronid);
}
$rebuild['cron'] = true;
}
}
// ############## import faq
if (!empty($this->productobj['faqentries']['faq']) and is_array($this->productobj['faqentries']['faq'])) {
$faq_entries =& $this->productobj['faqentries']['faq'];
if (!isset($faq_entries[0])) {
$faq_entries = array($faq_entries);
}
$sql = array();
foreach ($faq_entries as $faq) {
$sql[] = "\n\t\t\t\t\t('" . $this->db->escape_string($faq['faqname']) . "',\n\t\t\t\t\t'" . $this->db->escape_string($faq['faqparent']) . "',\n\t\t\t\t\t" . intval($faq['displayorder']) . ",\n\t\t\t\t\t1,\n\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t";
}
if ($sql) {
/*insert query*/
$this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "faq\n\t\t\t\t\t\t(faqname, faqparent, displayorder, volatile, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(',', $sql) . "\n\t\t\t\t");
}
}
$this->productinfo['process'] = VB_AREA;
$this->productinfo['username'] = 'Product-' . VB_AREA;
import_navigation($this->productobj, $this->productinfo);
$products = fetch_product_list(true);
// Check if the plugin system is disabled. If it is, enable it if this product isn't installed.
if (!$this->registry->options['enablehooks'] and !$products[$this->productinfo['productid']]) {
$this->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "setting\n\t\t\t\tSET value = '1'\n\t\t\t\tWHERE varname = 'enablehooks'\n\t\t\t");
$rebuild['options'] = true;
}
// Now rebuild everything we need...
if ($rebuild['plugins']) {
vBulletinHook::build_datastore($this->db);
if ($this->active) {
$plugin_data = $this->db->query_read("\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM " . TABLE_PREFIX . "datastore\n\t\t\t\t\tWHERE title IN ('pluginlist', 'pluginlistadmin')\n\t\t\t\t");
while ($plugin_info = $this->db->fetch_array($plugin_data)) {
if ($plugin_info['title'] == 'pluginlist') {
$this->registry->pluginlist = unserialize($plugin_info['data']);
} else {
if ($plugin_info['title'] == 'pluginlistadmin') {
$this->registry->pluginlistadmin = unserialize($plugin_info['data']);
}
}
}
// enable any hooks -- this is mainly necessary for importing templates (template_safe_functions hook)
if (!defined('DISABLE_HOOKS') and VB_AREA != 'Upgrade') {
if (!empty($this->registry->pluginlistadmin) and is_array($this->registry->pluginlistadmin)) {
$this->registry->pluginlist = array_merge($this->registry->pluginlist, $this->registry->pluginlistadmin);
unset($this->registry->pluginlistadmin);
}
vBulletinHook::set_pluginlist($this->registry->pluginlist, $vbulletin->options['hookerrors']);
}
}
}
if ($rebuild['templates']) {
if ($error = build_all_styles(0, 0, '', false, 'standard')) {
return $error;
}
if ($error = build_all_styles(0, 0, '', false, 'mobile')) {
return $error;
}
}
if ($rebuild['phrases']) {
require_once DIR . '/includes/adminfunctions_language.php';
build_language();
}
if ($rebuild['options']) {
build_options();
}
if ($rebuild['cron']) {
require_once DIR . '/includes/functions_cron.php';
build_cron_next_run();
}
build_product_datastore();
build_activitystream_datastore();
// build bitfields to remove/add this products bitfields
vB_Bitfield_Builder::save($this->db);
// reload block types
$blockmanager = vB_BlockManager::create($this->registry);
$blockmanager->reloadBlockTypes();
print_dots_stop();
$this->productinfo['need_merge'] = ($rebuild['templates'] and $installed_version);
return $this->productinfo;
}
示例6: print_stop_message
if (empty($newlang['title']) or empty($newlang['charset'])) {
print_stop_message('please_complete_required_fields');
}
// User has defined a locale.
if ($newlang['locale'] != '') {
if (!setlocale(LC_TIME, $newlang['locale']) or !setlocale(LC_CTYPE, $newlang['locale'])) {
print_stop_message('invalid_locale', $newlang['locale']);
}
if ($newlang['dateoverride'] == '' or $newlang['timeoverride'] == '' or $newlang['registereddateoverride'] == '' or $newlang['calformat1override'] == '' or $newlang['calformat2override'] == '' or $newlang['logdateoverride'] == '') {
print_stop_message('locale_define_fill_in_all_overrides');
}
}
/*insert query*/
$db->query_write(fetch_query_sql($newlang, 'language'));
$_languageid = $db->insert_id($result);
build_language($_languageid);
build_language_datastore();
define('CP_REDIRECT', 'language.php?dolanguageid=' . $_languageid);
print_stop_message('saved_language_x_successfully', $newlang['title']);
}
// ##########################################################################
if ($_REQUEST['do'] == 'add') {
print_form_header('language', 'insert');
print_table_header($vbphrase['add_new_language']);
print_description_row($vbphrase['general_settings'], 0, 2, 'thead');
print_input_row($vbphrase['title'], 'title');
print_yes_no_row($vbphrase['allow_user_selection'], 'userselect');
print_yes_no_row($vbphrase['enable_directional_markup_fix'], 'options[dirmark]');
print_label_row($vbphrase['text_direction'], "<label for=\"rb_l2r\"><input type=\"radio\" name=\"options[direction]\" id=\"rb_l2r\" value=\"1\" tabindex=\"1\" checked=\"checked\" />{$vbphrase['left_to_right']}</label><br />\n\t\t <label for=\"rb_r2l\"><input type=\"radio\" name=\"options[direction]\" id=\"rb_r2l\" value=\"0\" tabindex=\"1\" />{$vbphrase['right_to_left']}</label>", '', 'top', 'direction');
print_input_row($vbphrase['language_code'], 'languagecode', 'en');
print_input_row($vbphrase['html_charset'] . "<code><meta http-equiv="Content-Type" content="text/html; charset=<b>ISO-8859-1</b>" /></code>", 'charset', 'ISO-8859-1');
示例7: post_save_once
/**
*
* @param boolean Do the query?
*/
function post_save_once($doquery = true)
{
require_once(DIR . '/includes/blog_functions_category.php');
build_category_genealogy($this->fetch_field('userid'));
build_blog_user_counters($this->fetch_field('userid'));
if (!$this->fetch_field('userid'))
{ // Admin Defined Category
$this->registry->db->query_write("
DELETE FROM " . TABLE_PREFIX . "phrase
WHERE
product = 'vbblog'
AND
varname IN ('category" . $this->fetch_field('blogcategoryid') . "_title', 'category" . $this->fetch_field('blogcategoryid') . "_desc')
AND
fieldname = 'vbblogcat'
AND
languageid IN (0,-1)
");
$this->registry->db->query_write("
INSERT INTO " . TABLE_PREFIX . "phrase
(languageid, fieldname, varname, text, product, username, dateline, version)
VALUES
(0,
'vbblogcat',
'category" . $this->fetch_field('blogcategoryid') . "_title',
'" . $this->registry->db->escape_string($this->fetch_field('title')) . "',
'vbblog',
'" . $this->registry->db->escape_string($this->registry->userinfo['username']) . "',
" . TIMENOW . ",
'" . $this->registry->db->escape_string($this->registry->options['templateversion']) . "'
),
(0,
'vbblogcat',
'category" . $this->fetch_field('blogcategoryid') . "_desc',
'" . $this->registry->db->escape_string($this->fetch_field('description')) . "',
'vbblog',
'" . $this->registry->db->escape_string($this->registry->userinfo['username']) . "',
" . TIMENOW . ",
'" . $this->registry->db->escape_string($this->registry->options['templateversion']) . "'
)
");
require_once(DIR . '/includes/adminfunctions_language.php');
build_language();
}
($hook = vBulletinHook::fetch_hook('blog_categorydata_postsave')) ? eval($hook) : false;
}
示例8: post_delete
/**
* Additional data to update after a delete call (such as denormalized values in other tables).
*
* @param boolean Do the query?
*/
function post_delete($doquery = true)
{
$db =& $this->registry->db;
// need to rebuild last post info in forums that use this prefix
require_once(DIR . '/includes/functions_databuild.php');
$forums = $db->query_read("
SELECT forumid
FROM " . TABLE_PREFIX . "forumprefixset
WHERE prefixsetid = '" . $db->escape_string($this->fetch_field('prefixsetid')) . "'
");
while ($forum = $db->fetch_array($forums))
{
build_forum_counters($forum['forumid']);
}
$db->query_write("
DELETE FROM " . TABLE_PREFIX . "forumprefixset
WHERE prefixsetid = '" . $db->escape_string($this->fetch_field('prefixsetid')) . "'
");
// delete this set's phrases
$db->query_write("
DELETE FROM " . TABLE_PREFIX . "phrase
WHERE varname = '" . $db->escape_string('prefixset_' . $this->fetch_field('prefixsetid') . '_title') . "'
AND fieldname = 'prefix'
");
// now find all the phrases for child prefixes to remove
$prefix_phrases = array();
$prefixids = array();
$prefix_sql = $db->query_read("
SELECT prefixid
FROM " . TABLE_PREFIX . "prefix
WHERE prefixsetid = '" . $db->escape_string($this->fetch_field('prefixsetid')) . "'
");
while ($prefix = $db->fetch_array($prefix_sql))
{
$prefix_phrases[] = "'" . $db->escape_string("prefix_$prefix[prefixid]_title_plain") . "'";
$prefix_phrases[] = "'" . $db->escape_string("prefix_$prefix[prefixid]_title_rich") . "'";
$prefixids[] = "'" . $db->escape_string($prefix['prefixid']) . "'";
}
if ($prefix_phrases)
{
$db->query_write("
DELETE FROM " . TABLE_PREFIX . "phrase
WHERE varname IN (" . implode(',', $prefix_phrases) . ")
AND fieldname = 'global'
");
$db->query_write("
UPDATE " . TABLE_PREFIX . "thread SET
prefixid = ''
WHERE prefixid IN (" . implode(',', $prefixids) . ")
");
}
// now delete the child prefixes themselves
$db->query_write("
DELETE FROM " . TABLE_PREFIX . "prefix
WHERE prefixsetid = '" . $db->escape_string($this->fetch_field('prefixsetid')) . "'
");
require_once(DIR . '/includes/adminfunctions_language.php');
build_language();
require_once(DIR . '/includes/adminfunctions_prefix.php');
build_prefix_datastore();
($hook = vBulletinHook::fetch_hook('prefixsetdata_delete')) ? eval($hook) : false;
return true;
}
示例9: post_delete
/**
* Additional data to update after a delete call (such as denormalized values in other tables).
*
* @param boolean Do the query?
*/
function post_delete($doquery = true)
{
$db =& $this->registry->db;
$escaped_type = $db->escape_string($this->fetch_field('issuetypeid'));
$db->query_write("\r\n\t\t\tDELETE FROM " . TABLE_PREFIX . "pt_projectpermission WHERE issuetypeid = '{$escaped_type}'\r\n\t\t");
$db->query_write("\r\n\t\t\tDELETE FROM " . TABLE_PREFIX . "pt_projecttype WHERE issuetypeid = '{$escaped_type}'\r\n\t\t");
$db->query_write("\r\n\t\t\tDELETE FROM " . TABLE_PREFIX . "pt_projecttypeprivatelastpost WHERE issuetypeid = '{$escaped_type}'\r\n\t\t");
$del_phrases = array();
foreach ($this->info_phrase as $phrase_name) {
$del_phrases[] = sprintf($phrase_name, $escaped_type);
}
$db->query_write("\r\n\t\t\tDELETE FROM " . TABLE_PREFIX . "phrase\r\n\t\t\tWHERE varname IN ('" . implode('", "', $del_phrases) . "')\r\n\t\t\t\tAND fieldname = 'projecttools'\r\n\t\t");
if ($this->info['rebuild_caches']) {
require_once DIR . '/includes/adminfunctions_language.php';
build_language();
require_once DIR . '/includes/adminfunctions_projecttools.php';
build_issue_type_cache();
}
// update any issues with this status...
if ($this->info['delete_deststatusid'] and $dest_status = $this->registry->db->query_first("\r\n\t\t\tSELECT *\r\n\t\t\tFROM " . TABLE_PREFIX . "pt_issuestatus\r\n\t\t\tWHERE issuestatusid = " . intval($this->info['delete_deststatusid']) . "\r\n\t\t")) {
// ... to the destination status
$this->registry->db->query_write("\r\n\t\t\t\tUPDATE " . TABLE_PREFIX . "pt_issue SET\r\n\t\t\t\t\tissuestatusid = {$dest_status['issuestatusid']},\r\n\t\t\t\t\tissuetypeid = '{$dest_status['issuetypeid']}'\r\n\t\t\t\tWHERE issuetypeid = '{$escaped_type}'\r\n\t\t\t");
}
($hook = vBulletinHook::fetch_hook('pt_issuetypedata_delete')) ? eval($hook) : false;
return true;
}
示例10: install_product
//.........这里部分代码省略.........
$scheduling['day'] = intval($scheduling['day']);
$scheduling['hour'] = intval($scheduling['hour']);
$scheduling['minute'] = explode(',', preg_replace('#[^0-9,-]#i', '', $scheduling['minute']));
if (count($scheduling['minute']) == 0) {
$scheduling['minute'] = array(0);
} else {
$scheduling['minute'] = array_map('intval', $scheduling['minute']);
}
/*insert query*/
$cronSql[] = array('weekday' => $scheduling['weekday'], 'day' => $scheduling['day'], 'hour' => $scheduling['hour'], 'minute' => serialize($scheduling['minute']), 'filename' => $cron['filename'], 'loglevel' => $cron['loglevel'], 'active' => $cron['active'], 'varname' => $cron['varname'], 'volatile' => 1, 'product' => $info['productid']);
$cronid = $assertor->assertQuery('replaceValues', array('values' => $cronSql, 'table' => 'cron', 'returnId' => true));
if ($cronid) {
build_cron_item($cronid);
}
$rebuild['cron'] = true;
}
}
// ############## import faq
if (isset($arr['faqentries']['faq']) and is_array($arr['faqentries']['faq'])) {
$faq_entries =& $arr['faqentries']['faq'];
if (!isset($faq_entries[0])) {
$faq_entries = array($faq_entries);
}
$sql = array();
foreach ($faq_entries as $faq) {
$sql[] = array('faqname' => $faq['faqname'], 'faqparent' => $faq['faqparent'], 'displayorder' => intval($faq['displayorder']), 'volatile' => 1, 'product' => $info['productid']);
}
if ($sql) {
/*insert query*/
$assertor->assertQuery('replaceValues', array('values' => $sql, 'table' => 'faq'));
}
}
// ############## import widgets
if (isset($arr['widgets']['widget']) and is_array($arr['widgets']['widget'])) {
$widgetImporter = new vB_Xml_Import_Widget($info['productid']);
$widgetImporter->importFromParsedXML($arr['widgets']);
}
// ############## import pagetemplates
if (isset($arr['pagetemplates']['pagetemplate']) and is_array($arr['pagetemplates']['pagetemplate'])) {
$pageTemplateImporter = new vB_Xml_Import_PageTemplate($info['productid']);
$pageTemplateImporter->importFromParsedXML($arr['pagetemplates']);
}
// ############## import page
if (isset($arr['pages']['page']) and is_array($arr['pages']['page'])) {
$pageImporter = new vB_Xml_Import_Page($info['productid']);
$pageImporter->importFromParsedXML($arr['pages']);
}
// ############## import channels
if (isset($arr['channels']['channel']) and is_array($arr['channels']['channel'])) {
$channelImporter = new vB_Xml_Import_Channel($info['productid']);
$channelImporter->importFromParsedXML($arr['channels']);
}
// ############## import routes
if (isset($arr['routes']['route']) and is_array($arr['routes']['route'])) {
$routeImporter = new vB_Xml_Import_Route($info['productid']);
$routeImporter->importFromParsedXML($arr['routes']);
}
if (isset($routeImporter)) {
// update pages and channels with new route ids
if (isset($pageImporter)) {
$pageImporter->updatePageRoutes();
}
if (isset($channelImporter)) {
$channelImporter->updateChannelRoutes();
}
}
// Check if the hook system is disabled. If it is, enable it.
if (!$vbulletin->options['enablehooks']) {
$assertor->update('setting', array('value' => 1), array('varname' => 'enablehooks'));
$rebuild['options'] = true;
}
// Now rebuild everything we need...
if ($rebuild['hooks']) {
vB_Api::instanceInternal("Hook")->buildHookDatastore();
}
if ($rebuild['templates']) {
if ($error = build_all_styles(0, 0, '', false, $verbose)) {
return $error;
}
}
if ($rebuild['phrases']) {
require_once DIR . '/includes/adminfunctions_language.php';
build_language();
}
if ($rebuild['options']) {
vB::getDatastore()->build_options();
}
if ($rebuild['cron']) {
require_once DIR . '/includes/functions_cron.php';
build_cron_next_run();
}
build_product_datastore();
// build bitfields to remove/add this products bitfields
vB_Bitfield_Builder::save();
if ($verbose) {
print_dots_stop();
}
$info['need_merge'] = ($rebuild['templates'] and $installed_version);
return $info;
}
示例11: build_language
/**
* Reads a language or languages and updates the language db table with the denormalized phrase cache
*
* @param integer ID of language to be built; if -1, build all
* @param integer Not sure actually... any ideas?
* @param boolean. Wether to reset the static vars the function uses to cache items for recursing
* when we we build the master language. Otherwise if we attempt to call this function
* twice in the same pageload we don't actually manage to update any changes after the first
* call.
* The better approach would be to use an internal function and a master function t
* hat generates the cached values once and passes them in.
* However that means unwinding this function which works but is... odd.
*/
function build_language($languageid = -1, $phrasearray = 0, $reset_static=true)
{
global $vbulletin;
static $masterlang, $jsphrases = null;
if($reset_static)
{
$masterlang = null;
$jsphrases = null;
}
// load js safe phrases
if ($jsphrases === null)
{
require_once(DIR . '/includes/class_xml.php');
$xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/js_safe_phrases.xml');
$safephrases = $xmlobj->parse();
$jsphrases = array();
if (is_array($safephrases['phrase']))
{
foreach ($safephrases['phrase'] AS $varname)
{
$jsphrases["$varname"] = true;
}
}
unset($safephrases, $xmlobj);
}
// update all languages if this is the master language
if ($languageid == -1)
{
$languages = $vbulletin->db->query_read("SELECT languageid FROM " . TABLE_PREFIX . "language");
while ($language = $vbulletin->db->fetch_array($languages))
{
build_language($language['languageid'], 0, false);
}
return;
}
// get phrase types for language update
$gettypes = array();
$getphrasetypes = $vbulletin->db->query_read("
SELECT fieldname
FROM " . TABLE_PREFIX . "phrasetype
WHERE editrows <> 0 AND
special = 0
");
while ($getphrasetype = $vbulletin->db->fetch_array($getphrasetypes))
{
$gettypes[] = "'" . $vbulletin->db->escape_string($getphrasetype['fieldname']) . "'";
}
unset($getphrasetype);
$vbulletin->db->free_result($getphrasetypes);
if (empty($masterlang))
{
$masterlang = array();
$phrases = $vbulletin->db->query_read("
SELECT fieldname, varname, text
FROM " . TABLE_PREFIX . "phrase
WHERE languageid IN(-1,0) AND
fieldname IN (" . implode(',', $gettypes) . ")
");
while ($phrase = $vbulletin->db->fetch_array($phrases))
{
if (isset($jsphrases["$phrase[varname]"]))
{
$phrase['text'] = fetch_js_safe_string($phrase['text']);
}
if (strpos($phrase['text'], '{1}') !== false)
{
$phrase['text'] = str_replace('%', '%%', $phrase['text']);
}
$phrase['text'] = str_replace(
array('', ''),
'',
$phrase['text']
);
$masterlang["{$phrase['fieldname']}"]["$phrase[varname]"] = $phrase['text'];
}
}
//.........这里部分代码省略.........
示例12: post_delete
/**
* Additional data to update after a delete call (such as denormalized values in other tables).
*
* @param boolean Do the query?
*/
function post_delete($doquery = true)
{
$db =& $this->registry->db;
$db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "thread SET\n\t\t\t\tprefixid = ''\n\t\t\tWHERE prefixid = '" . $db->escape_string($this->fetch_field('prefixid')) . "'\n\t\t");
// need to rebuild last post info in forums that use this prefix
require_once DIR . '/includes/functions_databuild.php';
// $forums = $db->query_read("
// SELECT forumid
// FROM " . TABLE_PREFIX . "forumprefixset
// WHERE prefixsetid = '" . $db->escape_string($this->fetch_field('prefixsetid')) . "'
// ");
// while ($forum = $db->fetch_array($forums))
// {
// build_forum_counters($forum['forumid']);
// }
$db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "phrase\n\t\t\tWHERE varname IN (\n\t\t\t\t\t'" . $db->escape_string('prefix_' . $this->fetch_field('prefixid') . '_title_plain') . "',\n\t\t\t\t\t'" . $db->escape_string('prefix_' . $this->fetch_field('prefixid') . '_title_rich') . "'\n\t\t\t\t)\n\t\t\t\tAND fieldname = 'global'\n\t\t");
require_once DIR . '/includes/adminfunctions_language.php';
build_language();
require_once DIR . '/includes/adminfunctions_prefix.php';
build_prefix_datastore();
// Legacy Hook 'prefixdata_delete' Removed //
return true;
}
示例13: setDefault
/**
* Set language as default language
* @param int $languageid Language ID to be set as default
* @return void
*/
public function setDefault($languageid)
{
$this->checkHasAdminPermission('canadminlanguages');
require_once DIR . '/includes/adminfunctions.php';
require_once DIR . '/includes/adminfunctions_language.php';
$languageid = intval($languageid);
vB::getDbAssertor()->assertQuery('setting', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, 'value' => $languageid, vB_dB_Query::CONDITIONS_KEY => array('varname' => 'languageid')));
vB::getDatastore()->build_options();
$vbulletin->options['languageid'] = $languageid;
build_language($languageid);
}
示例14: save
/**
* Add a new phrase or update an existing phrase
* @param string $fieldname New Phrase Type for adding, old Phrase Type for editing
* @param string $varname New Varname for adding, old Varname for editing
* @param array $data Phrase data to be added or updated
* 'text' => Phrase text array.
* 'oldvarname' => Old varname for editing only
* 'oldfieldname' => Old fieldname for editing only
* 't' =>
* 'ismaster' =>
* 'product' => Product ID of the phrase
* @return void
*/
public function save($fieldname, $varname, $data)
{
$fieldname = trim($fieldname);
$varname = trim($varname);
$vb5_config =& vB::getConfig();
$install = false;
if (defined('VBINSTALL') and VBINSTALL) {
$install = true;
}
$session = vB::getCurrentSession();
if (!empty($session)) {
$userinfo = $session->fetch_userinfo();
} else {
$userinfo = vB_User::fetchUserinfo(1);
}
require_once DIR . '/includes/adminfunctions.php';
$full_product_info = fetch_product_list(true);
if (empty($varname)) {
throw new vB_Exception_Api('please_complete_required_fields');
}
if (!preg_match('#^[' . self::VALID_CLASS . ']+$#', $varname)) {
throw new vB_Exception_Api('invalid_phrase_varname');
}
require_once DIR . '/includes/functions_misc.php';
foreach ($data['text'] as $text) {
if (!validate_string_for_interpolation($text)) {
throw new vB_Exception_Api('phrase_text_not_safe', array($varname));
}
}
// it's an update
if (!empty($data['oldvarname']) and !empty($data['oldfieldname'])) {
if (vB::getDbAssertor()->getField('phrase_fetchid', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'varname' => $varname))) {
// Don't check if we are moving a phrase to another group but keeping the same name. See VBV-4192.
if ($varname != $data['oldvarname'] and $fieldname != $data['oldfieldname']) {
throw new vB_Exception_Api('there_is_already_phrase_named_x', array($varname));
}
if ($varname != $data['oldvarname']) {
throw new vB_Exception_Api('variable_name_exists', array($data['oldvarname'], $varname));
}
}
if (!is_array($data['oldfieldname'])) {
$data['oldfieldname'] = array($data['oldfieldname']);
}
if (!in_array($fieldname, $data['oldfieldname'])) {
$data['oldfieldname'][] = $fieldname;
}
// delete old phrases
vB::getDbAssertor()->assertQuery('deleteOldPhrases', array('varname' => $data['oldvarname'], 'fieldname' => $data['oldfieldname'], 't' => $data['t'], 'debug' => empty($data['skipdebug']) && ($vb5_config['Misc']['debug'] or $install)));
$update = 1;
$this->setPhraseDate();
}
if (empty($update)) {
if (empty($data['text'][0]) and $data['text'][0] != '0' and !$data['t'] or empty($varname)) {
throw new vB_Exception_Api('please_complete_required_fields');
}
if (vB::getDbAssertor()->getField('phrase_fetchid', array('varname' => $varname, 'fieldname' => $fieldname))) {
throw new vB_Exception_Api('there_is_already_phrase_named_x', array($varname));
}
}
if ($data['ismaster']) {
if (($vb5_config['Misc']['debug'] or $install) and !$data['t']) {
/*insert query*/
vB::getDbAssertor()->assertQuery('phrase', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_REPLACE, 'languageid' => -1, 'varname' => $varname, 'text' => $data['text'][0], 'fieldname' => $fieldname, 'product' => $data['product'], 'username' => $userinfo['username'], 'dateline' => vB::getRequest()->getTimeNow(), 'version' => $full_product_info[$data['product']]['version']));
}
unset($data['text'][0]);
}
foreach ($data['text'] as $_languageid => $txt) {
$_languageid = intval($_languageid);
if (!empty($txt) or $txt == '0') {
/*insert query*/
vB::getDbAssertor()->assertQuery('phrase', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_REPLACE, 'languageid' => $_languageid, 'varname' => $varname, 'text' => $txt, 'fieldname' => $fieldname, 'product' => $data['product'], 'username' => $userinfo['username'], 'dateline' => vB::getRequest()->getTimeNow(), 'version' => $full_product_info[$data['product']]['version']));
}
}
require_once DIR . '/includes/adminfunctions.php';
require_once DIR . '/includes/adminfunctions_language.php';
build_language(-1);
}
示例15: build_language
/**
* Reads a language or languages and updates the language db table with the denormalized phrase cache
*
* @param integer ID of language to be built; if -1, build all
* @param integer Not sure actually... any ideas?
* @param boolean. Wether to reset the static vars the function uses to cache items for recursing
* when we we build the master language. Otherwise if we attempt to call this function
* twice in the same pageload we don't actually manage to update any changes after the first
* call.
* The better approach would be to use an internal function and a master function
* that generates the cached values once and passes them in.
* However that means unwinding this function which works but is... odd.
*/
function build_language($languageid = -1, $phrasearray = 0, $reset_static = true)
{
global $vbulletin;
static $masterlang, $jsphrases = null;
if ($reset_static) {
$masterlang = null;
$jsphrases = null;
}
// load js safe phrases
if ($jsphrases === null) {
require_once DIR . '/includes/class_xml.php';
$xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/js_safe_phrases.xml');
$safephrases = $xmlobj->parse();
$jsphrases = array();
if (is_array($safephrases['phrase'])) {
foreach ($safephrases['phrase'] as $varname) {
$jsphrases["{$varname}"] = true;
}
}
unset($safephrases, $xmlobj);
}
// update all languages if this is the master language
if ($languageid == -1) {
$languages = $vbulletin->db->query_read("SELECT languageid FROM " . TABLE_PREFIX . "language");
while ($language = $vbulletin->db->fetch_array($languages)) {
build_language($language['languageid'], 0, false);
}
return;
}
// get phrase types for language update
$gettypes = array();
$getphrasetypes = $vbulletin->db->query_read("\n\t\tSELECT fieldname\n\t\tFROM " . TABLE_PREFIX . "phrasetype\n\t\tWHERE editrows <> 0 AND\n\t\t\tspecial = 0\n\t");
while ($getphrasetype = $vbulletin->db->fetch_array($getphrasetypes)) {
$gettypes[] = "'" . $vbulletin->db->escape_string($getphrasetype['fieldname']) . "'";
}
unset($getphrasetype);
$vbulletin->db->free_result($getphrasetypes);
if (empty($masterlang)) {
$masterlang = array();
$phrases = $vbulletin->db->query_read("\n\t\t\tSELECT fieldname, varname, text, languageid\n\t\t\tFROM " . TABLE_PREFIX . "phrase\n\t\t\tWHERE languageid IN(-1,0) AND\n\t\t\t\tfieldname IN (" . implode(',', $gettypes) . ")\n\t\t");
while ($phrase = $vbulletin->db->fetch_array($phrases)) {
if (isset($jsphrases["{$phrase['varname']}"])) {
$phrase['text'] = fetch_js_safe_string($phrase['text']);
}
if (strpos($phrase['text'], '{1}') !== false) {
$phrase['text'] = str_replace('%', '%%', $phrase['text']);
}
$phrase['text'] = str_replace(array('', ''), '', $phrase['text']);
if (!isset($masterlang["{$phrase['fieldname']}"]["{$phrase['varname']}"]) or !$phrase['languageid']) {
$masterlang["{$phrase['fieldname']}"]["{$phrase['varname']}"] = $phrase['text'];
}
}
}
// get phrases for language update
$phrasearray = $masterlang;
$phrasetemplate = array();
$phrases = $vbulletin->db->query_read("\n\t\tSELECT varname, text, fieldname\n\t\tFROM " . TABLE_PREFIX . "phrase\n\t\tWHERE languageid = {$languageid} AND fieldname IN (" . implode(',', $gettypes) . ")\n\t");
while ($phrase = $vbulletin->db->fetch_array($phrases, DBARRAY_BOTH)) {
if (isset($jsphrases["{$phrase['varname']}"])) {
$phrase['text'] = fetch_js_safe_string($phrase['text']);
}
if (strpos($phrase['text'], '{1}') !== false) {
$phrase['text'] = str_replace('%', '%%', $phrase['text']);
}
$phrasearray["{$phrase['fieldname']}"]["{$phrase['varname']}"] = $phrase['text'];
}
unset($phrase);
$vbulletin->db->free_result($phrases);
$SQL = 'title = title';
foreach ($phrasearray as $fieldname => $phrases) {
ksort($phrases);
$cachefield = $fieldname;
$phrases = preg_replace('/\\{([0-9]+)\\}/siU', '%\\1$s', $phrases);
$cachetext = $vbulletin->db->escape_string(serialize($phrases));
$SQL .= ", phrasegroup_{$cachefield} = '{$cachetext}'";
}
// This only loads the last dateline for the ckeditor group, if this functionality is ever needed for other groups,
// just move this code block into the foreach() above
$maxdateline = $vbulletin->db->query_first("\n\t\tSELECT MAX(dateline) AS dateline\n\t\tFROM " . TABLE_PREFIX . "phrase\n\t\tWHERE\n\t\t\tlanguageid IN ({$languageid},-1)\n\t\t\t\tAND\n\t\t\tfieldname = 'ckeditor'\n\t");
$info['ckeditor'] = array('maxdateline' => $maxdateline['dateline']);
$SQL .= ", phrasegroupinfo = '" . $vbulletin->db->escape_string(serialize($info)) . "'";
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "language SET {$SQL} WHERE languageid = {$languageid}");
}