/** * Builds all data from the template table into the fields in the style table * * @param boolean If true, will drop the template table and rebuild, so that template ids are renumbered from zero * @param boolean If true, will fix styles with no parent style specified * @param string If set, will redirect to specified URL on completion */ function build_all_styles($renumber = 0, $install = 0, $goto = '') { global $vbulletin, $template_table_query, $template_table_fields, $vbphrase; // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // this bit of text is used for upgrade scripts where the phrase system // is not available it should NOT be converted into phrases!!! $phrases = array('master_style' => 'MASTER STYLE', 'done' => 'Done', 'style' => 'Style', 'styles' => 'Styles', 'templates' => 'Templates', 'css' => 'CSS', 'stylevars' => 'Stylevars', 'replacement_variables' => 'Replacement Variables', 'controls' => 'Controls', 'rebuild_style_information' => 'Rebuild Style Information', 'updating_style_information_for_each_style' => 'Updating style information for each style', 'updating_styles_with_no_parents' => 'Updating style sets with no parent information', 'updated_x_styles' => 'Updated %1$s Styles', 'no_styles_needed_updating' => 'No Styles Needed Updating'); foreach ($phrases as $key => $val) { if (!isset($vbphrase["{$key}"])) { $vbphrase["{$key}"] = $val; } } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- if (!empty($goto)) { $form_tags = true; } echo "<!--<p> </p>-->\n\t<blockquote>" . iif($form_tags, "<form>") . "<div class=\"tborder\">\n\t<div class=\"tcat\" style=\"padding:4px\" align=\"center\"><b>" . $vbphrase['rebuild_style_information'] . "</b></div>\n\t<div class=\"alt1\" style=\"padding:4px\">\n<blockquote>\n\t"; vbflush(); // useful for restoring utterly broken (or pre vb3) styles if ($install) { echo "<p><b>" . $vbphrase['updating_styles_with_no_parents'] . "</b></p>\n<ul class=\"smallfont\">\n"; vbflush(); $vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "style\n\t\t\tSET parentid = -1,\n\t\t\tparentlist = CONCAT(styleid,',-1')\n\t\t\tWHERE parentid = 0\n\t\t"); $affected = $vbulletin->db->affected_rows(); if ($affected) { echo "<li>" . construct_phrase($vbphrase['updated_x_styles'], $affected) . "</li>\n"; vbflush(); } else { echo "<li>" . $vbphrase['no_styles_needed_updating'] . "</li>\n"; vbflush(); } echo "</ul>\n"; vbflush(); } // creates a temporary table in order to renumber all templates from 1 to n sequentially if ($renumber) { echo "<p><b>" . $vbphrase['updating_template_ids'] . "</b></p>\n<ul class=\"smallfont\">\n"; vbflush(); $vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "template_temp"); $vbulletin->db->query_write($template_table_query); echo "<li>" . $vbphrase['temporary_template_table_created'] . "</li>\n"; vbflush(); /*insert query*/ $vbulletin->db->query_write("\n\t\t\tINSERT INTO " . TABLE_PREFIX . "template_temp\n\t\t\t({$template_table_fields})\n\t\t\tSELECT {$template_table_fields} FROM " . TABLE_PREFIX . "template ORDER BY styleid, templatetype, title\n\t\t"); $rows = $vbulletin->db->affected_rows(); echo "<li>" . construct_phrase($vbphrase['temporary_template_table_populated_with_x_templates'], $rows) . "</li>\n"; vbflush(); $vbulletin->db->query_write("DROP TABLE " . TABLE_PREFIX . "template"); echo "<li>" . $vbphrase['old_template_table_dropped'] . "</li>\n"; vbflush(); $vbulletin->db->query_write("ALTER TABLE " . TABLE_PREFIX . "template_temp RENAME " . TABLE_PREFIX . "template"); echo "<li>" . $vbphrase['temporary_template_table_renamed'] . "</li>\n"; vbflush(); echo "</ul>\n"; vbflush(); } // the main bit. echo "<p><b>" . $vbphrase['updating_style_information_for_each_style'] . "</b></p>\n"; vbflush(); build_template_parentlists(); $styleactions = array('docss' => 1, 'dostylevars' => 1, 'doreplacements' => 1, 'doposteditor' => 1); if (defined('NO_POST_EDITOR_BUILD')) { $styleactions['doposteditor'] = 0; } build_style(-1, $vbphrase['master_style'], $styleactions); echo "</blockquote></div>"; if ($form_tags) { echo "\n\t\t<div class=\"tfoot\" style=\"padding:4px\" align=\"center\">\n\t\t<input type=\"button\" class=\"button\" value=\" " . $vbphrase['done'] . " \" onclick=\"window.location='{$goto}';\" />\n\t\t</div>"; } echo "</div>" . iif($form_tags, "</form>") . "</blockquote>\n\t"; vbflush(); build_style_datastore(); }
// ############################################################################# // update display order values if ($_POST['do'] == 'dodisplayorder') { $vbulletin->input->clean_array_gpc('p', array('displayorder' => TYPE_ARRAY_INT, 'userselect' => TYPE_ARRAY_INT)); $styles = $db->query_read("SELECT styleid, parentid, title, displayorder, userselect FROM " . TABLE_PREFIX . "style"); if ($db->num_rows($styles)) { while ($style = $db->fetch_array($styles)) { $order = $vbulletin->GPC['displayorder']["{$style['styleid']}"]; $uperm = intval($vbulletin->GPC['userselect']["{$style['styleid']}"]); if ($style['displayorder'] != $order or $style['userselect'] != $uperm) { $db->query_write("\n\t\t\t\t\tUPDATE " . TABLE_PREFIX . "style\n\t\t\t\t\tSET displayorder = {$order},\n\t\t\t\t\tuserselect = {$uperm}\n\t\t\t\t\tWHERE styleid = {$style['styleid']}\n\t\t\t\t"); } } } $_REQUEST['do'] = "modify"; build_style_datastore(); } // ############################################################################# // main template list display if ($_REQUEST['do'] == 'modify') { $vbulletin->input->clean_array_gpc('r', array('searchset' => TYPE_INT, 'expandset' => TYPE_NOHTML, 'searchstring' => TYPE_STR, 'titlesonly' => TYPE_BOOL, 'group' => TYPE_NOHTML)); // populate the stylecache cache_styles(); // sort out parameters for searching if ($vbulletin->GPC['searchstring']) { $vbulletin->GPC['group'] = 'all'; if ($vbulletin->GPC['searchset'] > 0) { $vbulletin->GPC['expandset'] =& $vbulletin->GPC['searchset']; } else { $parentlist = '-1'; $vbulletin->GPC['expandset'] = 'all';
/** * Converts vBulletin 3 style information to vBulletin 4 Stylevars for the given style. * * @param array Style Information */ public function convert($style) { global $vbphrase; $this->styleid = intval($style['styleid']); $this->masterstyleid = $style['type'] == 'mobile' ? -2 : -1; if ($this->styleid < 1) { print_stop_message('invalid_style_specified'); } if ($this->options['create_new_style']) { // Make a copy of the style and change our styleid to the new one $this->styleid = $this->duplicate_style($this->styleid); } $this->display_begin(); $this->display("<b>" . $vbphrase['mapping_stylevars'] . "</b>\n<ul>"); foreach ($this->map as $vb3_stylevar_type => $values) { foreach ($values as $source_stylevar_name => $target_mapping_data) { $this->convert_vb3_stylevar($vb3_stylevar_type, $source_stylevar_name, $target_mapping_data); } } $this->display('</ul>'); if ($this->options['revert_templates']) { $this->revert_templates(); } $this->display_end(); require_once DIR . '/includes/adminfunctions_template.php'; cache_styles(); build_all_styles(); build_style_datastore(); if ($this->options['output_progress']) { print_form_header('template', 'modify', false, true, 'cpform', '90%', '', false, 'get'); construct_hidden_code('expandset', $this->styleid); print_submit_row($vbphrase['done'], false); } }