function xml_import_help_topics($xml = false) { global $vbulletin, $vbphrase; print_dots_start('<b>' . $vbphrase['importing_admin_help'] . "</b>, {$vbphrase['please_wait']}", ':', 'dspan'); require_once DIR . '/includes/class_xml.php'; $xmlobj = new vB_XML_Parser($xml, $GLOBALS['path']); if ($xmlobj->error_no == 1) { print_dots_stop(); print_stop_message('no_xml_and_no_path'); } else { if ($xmlobj->error_no == 2) { print_dots_stop(); print_stop_message('please_ensure_x_file_is_located_at_y', 'vbulletin-adminhelp.xml', $GLOBALS['path']); } } if (!($arr = $xmlobj->parse())) { print_dots_stop(); print_stop_message('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line()); } if (!$arr['helpscript']) { print_dots_stop(); print_stop_message('invalid_file_specified'); } $product = empty($arr['product']) ? 'vbulletin' : $arr['product']; $has_phrases = !empty($arr['hasphrases']); $arr = $arr['helpscript']; if ($product == 'vbulletin') { $product_sql = "product IN ('vbulletin', '')"; } else { $product_sql = "product = '" . $vbulletin->db->escape_string($product) . "'"; } $vbulletin->db->query_write("\n\t\tDELETE FROM " . TABLE_PREFIX . "adminhelp\n\t\tWHERE {$product_sql}\n\t\t\t AND volatile = 1\n\t"); if ($has_phrases) { $vbulletin->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "phrase\n\t\t\tWHERE {$product_sql}\n\t\t\t\tAND fieldname = 'cphelptext'\n\t\t\t\tAND languageid = -1\n\t\t"); } // Deal with single entry if (!is_array($arr[0])) { $arr = array($arr); } foreach ($arr as $helpscript) { $help_sql = array(); $phrase_sql = array(); $help_sql_len = 0; $phrase_sql_len = 0; // Deal with single entry if (!is_array($helpscript['helptopic'][0])) { $helpscript['helptopic'] = array($helpscript['helptopic']); } foreach ($helpscript['helptopic'] as $topic) { $help_sql[] = "\n\t\t\t\t('" . $vbulletin->db->escape_string($helpscript['name']) . "',\n\t\t\t\t'" . $vbulletin->db->escape_string($topic['act']) . "',\n\t\t\t\t'" . $vbulletin->db->escape_string($topic['opt']) . "',\n\t\t\t\t" . intval($topic['disp']) . ",\n\t\t\t\t1,\n\t\t\t\t'" . $vbulletin->db->escape_string($product) . "')\n\t\t\t"; $help_sql_len += strlen(end($help_sql)); if ($has_phrases) { $phrase_name = fetch_help_phrase_short_name(array('script' => $helpscript['name'], 'action' => $topic['act'], 'optionname' => $topic['opt'])); if (isset($topic['text']['value'])) { $phrase_sql[] = "\n\t\t\t\t\t\t(-1,\n\t\t\t\t\t\t'cphelptext',\n\t\t\t\t\t\t'{$phrase_name}_text',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['text']['value']) . "',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($product) . "',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['text']['username']) . "',\n\t\t\t\t\t\t" . intval($topic['text']['date']) . ",\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['text']['version']) . "')\n\t\t\t\t\t"; $phrase_sql_len += strlen(end($phrase_sql)); } if (isset($topic['title']['value'])) { $phrase_sql[] = "\n\t\t\t\t\t\t(-1,\n\t\t\t\t\t\t'cphelptext',\n\t\t\t\t\t\t'{$phrase_name}_title',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['title']['value']) . "',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($product) . "',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['title']['username']) . "',\n\t\t\t\t\t\t" . intval($topic['title']['date']) . ",\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['title']['version']) . "')\n\t\t\t\t\t"; $phrase_sql_len += strlen(end($phrase_sql)); } } if ($phrase_sql_len > 102400) { // insert max of 100k of phrases at a time /*insert query*/ $vbulletin->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "phrase\n\t\t\t\t\t\t(languageid, fieldname, varname, text, product, username, dateline, version)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(",\n", $phrase_sql)); $phrase_sql = array(); $phrase_sql_len = 0; } if ($help_sql_len > 102400) { // insert max of 100k of phrases at a time /*insert query*/ $vbulletin->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "adminhelp\n\t\t\t\t\t\t(script, action, optionname, displayorder, volatile, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(",\n\t", $help_sql)); $help_sql = array(); $help_sql_len = 0; } } if ($help_sql) { /*insert query*/ $vbulletin->db->query_write("\n\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "adminhelp\n\t\t\t\t\t(script, action, optionname, displayorder, volatile, product)\n\t\t\t\tVALUES\n\t\t\t\t\t" . implode(",\n\t", $help_sql)); } if ($phrase_sql) { /*insert query*/ $vbulletin->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "phrase\n\t\t\t\t\t\t(languageid, fieldname, varname, text, product, username, dateline, version)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(",\n", $phrase_sql)); } } // stop the 'dots' counter feedback print_dots_stop(); require_once DIR . '/includes/adminfunctions_language.php'; build_language(); }
} unset($getscript); $db->free_result($getscripts); // query topics $topics = array(); $gettopics = $db->query_read("\n\t\tSELECT adminhelpid, script, action, optionname, displayorder\n\t\tFROM " . TABLE_PREFIX . "adminhelp\n\t\t" . iif($vbulletin->GPC['script'], "WHERE script = '" . $db->escape_string($vbulletin->GPC['script']) . "'") . "\n\t\tORDER BY script, action, displayorder\n\t"); while ($gettopic = $db->fetch_array($gettopics)) { $topics["{$gettopic['script']}"][] = $gettopic; } unset($gettopic); $db->free_result($gettopics); // build the form print_form_header('help', 'manage', false, true, 'helpform', '90%', '', true, 'get'); print_table_header($vbphrase['topic_manager'], 5); print_description_row('<div align="center">' . $vbphrase['script'] . ': <select name="script" tabindex="1" onchange="this.form.submit()" class="bginput"><option value="">' . $vbphrase['all_scripts'] . '</option>' . construct_select_options($scripts, $script) . '</select> <input type="submit" class="button" value="' . $vbphrase['go'] . '" tabindex="1" /></div>', 0, 5, 'thead'); foreach ($topics as $script => $scripttopics) { print_table_header($script . '.php', 5); print_cells_row(array($vbphrase['action'], $vbphrase['option'], $vbphrase['title'], $vbphrase['order_by'], ''), 1, 0, -5); foreach ($scripttopics as $topic) { print_cells_row(array('<span class="smallfont">' . $topic['action'] . '</span>', '<span class="smallfont">' . $topic['optionname'] . '</span>', '<span class="smallfont"><b>' . $helpphrase[fetch_help_phrase_short_name($topic, '_title')] . '</b></span>', '<span class="smallfont">' . $topic['displayorder'] . '</span>', '<span class="smallfont">' . construct_link_code($vbphrase['edit'], "help.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&adminhelpid={$topic['adminhelpid']}") . construct_link_code($vbphrase['delete'], "help.php?" . $vbulletin->session->vars['sessionurl'] . "do=delete&adminhelpid={$topic['adminhelpid']}") . '</span>'), 0, 0, -5); } } print_table_footer(); } print_cp_footer(); /*======================================================================*\ || #################################################################### || # Downloaded: 09:39, Wed Nov 5th 2008 || # CVS: $RCSfile$ - $Revision: 23895 $ || #################################################################### \*======================================================================*/
print_form_header('', ''); if ($resultcount != 1) { print_table_header($vbphrase['action_specific_topics'], 1); } foreach ($specific as $topic) { print_description_row("<a name=\"help{$topic['adminhelpid']}\">" . $helpphrase[fetch_help_phrase_short_name($topic, '_title')] . "</a>", 0, 1, 'thead'); print_description_row($helpphrase[fetch_help_phrase_short_name($topic, '_text')]); } print_table_footer(); } if (sizeof($general)) { reset($general); print_form_header('', ''); if ($resultcount != 1) { print_table_header($vbphrase['general_topics'], 1); } foreach ($general as $topic) { print_description_row("<a name=\"help{$topic['adminhelpid']}\">" . $helpphrase[fetch_help_phrase_short_name($topic, '_title')] . "</a>", 0, 1, 'thead'); print_description_row($helpphrase[fetch_help_phrase_short_name($topic, '_text')]); } print_table_footer(); } } } print_cp_footer(); /*======================================================================*\ || #################################################################### || # Downloaded: 08:19, Wed Nov 5th 2008 || # CVS: $RCSfile$ - $Revision: 13945 $ || #################################################################### \*======================================================================*/
function admincp_search_help_text_to_info($row) { $actions = explode(',', $row['action']); $urls = array(); foreach ($actions as $action) { //edit actions don't really work as links because they generally require some data. if (!in_array($action, array('edit', 'doedit'))) { $anchor = ''; if ($row['optionname']) { $anchor = '#' . $row['script'] . '_' . $action . '_' . $row['optionname']; } $urls[$action] = $row['script'] . '.php?do=' . $action . $anchor; } } $info = array('urls' => $urls, 'key' => $row['script'] . '_' . $row['actions'], 'title_phrase' => fetch_help_phrase_short_name($row) . '_title', 'map_key' => $row['map_key']); return $info; }