function construct_stylevar_form($title, $stylevarid, $values, $styleid, $masterstyleid) { global $vbulletin, $stylecache; cache_styles(); $editstyleid = $styleid; if (isset($values[$stylevarid][$styleid])) { // customized or master if ($styleid == -1 or $styleid == -2) { // master $hide_revert = true; } } else { // inherited while (!isset($values[$stylevarid][$styleid])) { $styleid = $stylecache[$styleid]['parentid']; if (!isset($stylecache[$styleid]) and $styleid != -1 and $styleid != -2) { trigger_error('Invalid style in tree: ' . $styleid, E_USER_ERROR); break; } } $hide_revert = true; } $stylevar = $values[$stylevarid][$styleid]; $hide_revert = $hide_revert ? 'hide_revert' : ''; if ($stylevar['value'] == '') { // blank for value? use fall back $stylevar['value'] = $stylevar['failsafe']; } $svinstance = vB_StyleVar_factory::create($stylevar['datatype']); $svinstance->set_stylevarid($stylevarid); $svinstance->set_definition($stylevar); $svinstance->set_value(unserialize($stylevar['value'])); // remember, our value in db is ALWAYS serialized! if ($stylevar['stylevarstyleid'] == -1 or $stylevar['stylevarstyleid'] == -2) { $svinstance->set_inherited(0); } else { if ($stylevar['stylevarstyleid'] == $vbulletin->GPC['dostyleid']) { // This -1 is just used to a set a Master Color so no -2 adaptation is required $svinstance->set_inherited(-1); } else { $svinstance->set_inherited(1); } } $editor = $svinstance->print_editor($masterstyleid); return $editor; }
$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'; } } else { $vbulletin->GPC['searchstring'] = ''; } if (is_numeric($vbulletin->GPC['expandset'])) { $style = $db->query_first("SELECT parentlist FROM " . TABLE_PREFIX . "style WHERE styleid = " . $vbulletin->GPC['expandset']); $parentlist = $style['parentlist'];
/** * Prints a row containing a <select> showing the available styles * * @param string Name for <select> * @param integer Selected style ID * @param string Name of top item in <select> * @param string Title of row * @param boolean Display top item? */ function print_style_chooser_row($name = 'parentid', $selectedid = -1, $topname = NULL, $title = NULL, $displaytop = true) { global $stylecache, $vbphrase; if ($topname === NULL) { $topname = $vbphrase['no_parent_style']; } if ($title === NULL) { $title = $vbphrase['parent_style']; } cache_styles(); $styles = array(); if ($displaytop) { $styles['-1'] = $topname; } foreach ($stylecache as $style) { $styles["{$style['styleid']}"] = construct_depth_mark($style['depth'], '--', iif($displaytop, '--')) . " {$style['title']}"; } print_select_row($title, $name, $styles, $selectedid); }
/** * Prints out the save options for the style generator */ function import_generated_style() { global $vbphrase, $stylecache; cache_styles(); echo " <script type=\"text/javascript\"> <!-- function js_confirm_upload(tform, filefield) { if (filefield.value == \"\") { return confirm(\"".construct_phrase($vbphrase['you_did_not_specify_a_file_to_upload'], " + tform.serverfile.value + ")."\"); } return true; } function js_fetch_style_title() { styleid = document.forms.downloadform.dostyleid.options[document.forms.downloadform.dostyleid.selectedIndex].value; document.forms.downloadform.title.value = style[styleid]; } var style = new Array(); style['-1'] = \"" . $vbphrase['master_style'] . "\""; foreach($stylecache AS $styleid => $style) { echo "\n\tstyle['$styleid'] = \"" . addslashes_js($style['title'], '"') . "\";"; $styleoptions["$styleid"] = construct_depth_mark($style['depth'], '--', iif($vbulletin->debug, '--', '')) . ' ' . $style['title']; } echo " // --> </script>"; echo '<div id="styleform">'; echo '<form id="form">'; construct_hidden_code('adid', $vbulletin->GPC['adid']); echo '<input id="form-data" type="hidden" name="data">'; echo '<div class="styledetails"><div id="title-generated-style" class="help title-generated-style">'; print_input_row($vbphrase['title_generated_style'], 'name', null, null, null, null, null, null, 'form-name'); echo '</div><div id="parent-id" class="help parent-id">'; print_style_chooser_row('parentid', -1, $vbphrase['no_parent_style'], $vbphrase['parent_style'], 1); echo '</div></div><div class="styleoptions"><div id="display-order" class="help display-order">'; print_input_row($vbphrase['display_order'], 'displayorder', 1, null, null, null, null, null, 'form-displayorder'); echo '</div><div id="allow-user-selection" class="help allow-user-selection">'; print_yes_no_row($vbphrase['allow_user_selection'], 'userselect', 1, null, null, null, null, null, 'form-userselect'); echo '</div></div></form></div>'; }
/** * Fetches an array of style titles for use in select menus * * @param string Prefix for titles * @param boolean Display top level style? * * @return array */ function fetch_style_title_options_array($titleprefix = '', $displaytop = false) { require_once DIR . '/includes/adminfunctions_template.php'; global $stylecache; cache_styles(); $out = array(); foreach ($stylecache as $style) { $out["{$style['styleid']}"] = $titleprefix . construct_depth_mark($style['depth'], '--', iif($displaytop, '--', '')) . " {$style['title']}"; } return $out; }
/** * Fetches an array of style titles for use in select menus * * @param string Prefix for titles * @param boolean Display top level style? * @param string 'both', display both master styles, 'standard', the standard styles, 'mobile', the mobile styles * * @return array */ function fetch_style_title_options_array($titleprefix = '', $displaytop = false, $type = 'both') { require_once DIR . '/includes/adminfunctions_template.php'; global $stylecache, $vbphrase; cache_styles(); $styles = array(); foreach ($stylecache as $style) { $styles[$style['type']]["{$style['styleid']}"] = $titleprefix . construct_depth_mark($style['depth'], '--', iif($displaytop, '--', '')) . " {$style['title']}"; } if ($type == 'both') { $out = array($vbphrase['standard_styles'] => $styles['standard'], $vbphrase['mobile_styles'] => $styles['mobile']); return $out; } else { $out = array($vbphrase[$type . '_styles'] => $styles[$type]); return $out; } }
/** * Prints out the save options for the style generator */ function import_generated_style() { global $vbphrase, $stylecache; cache_styles(); echo "\n\t<script type=\"text/javascript\">\n\t<!--\n\tfunction js_confirm_upload(tform, filefield)\n\t{\n\t\tif (filefield.value == \"\")\n\t\t{\n\t\t\treturn confirm(\"" . construct_phrase($vbphrase['you_did_not_specify_a_file_to_upload'], " + tform.serverfile.value + ") . "\");\n\t\t}\n\t\treturn true;\n\t}\n\tfunction js_fetch_style_title()\n\t{\n\t\tstyleid = document.forms.downloadform.dostyleid.options[document.forms.downloadform.dostyleid.selectedIndex].value;\n\t\tdocument.forms.downloadform.title.value = style[styleid];\n\t}\n\tvar style = new Array();\n\tstyle['-2'] = \"" . $vbphrase['mobile_master_style'] . "\"\n\tstyle['-1'] = \"" . $vbphrase['master_style'] . "\""; foreach ($stylecache as $styleid => $style) { echo "\n\tstyle['{$styleid}'] = \"" . addslashes_js($style['title'], '"') . "\";"; $styleoptions["{$styleid}"] = construct_depth_mark($style['depth'], '--', iif($vbulletin->debug, '--', '')) . ' ' . $style['title']; } echo "\n\t// -->\n\t</script>"; echo '<div id="styleform">'; echo '<form id="form" action="template.php?do=stylegenerator" method="post">'; construct_hidden_code('adid', $vbulletin->GPC['adid']); echo '<input id="form-data" type="hidden" name="data" />'; echo '<div class="styledetails"><div id="title-generated-style" class="help title-generated-style">'; echo $vbphrase['title_generated_style'] . '<div id="ctrl_name"><input type="text" class="bginput" name="name" id="form-name" value="" size="" dir="ltr" tabindex="1" /></div>'; echo '</div><div id="parent-id" class="help parent-id">'; echo $vbphrase['parent_style'] . '<div><select name="parentid" id="sel_parentid_1" tabindex="1" class="bginput">' . construct_select_options($styleoptions, -1, false) . '</select></div>'; echo '</div></div><div class="styleoptions"><div id="display-order" class="help display-order">'; echo $vbphrase['display_order'] . '<div id="ctrl_displayorder"><input type="text" class="bginput" name="displayorder" id="form-displayorder" value="1" size="" dir="ltr" tabindex="1" /></div>'; echo '</div><div id="allow-user-selection" class="help allow-user-selection">'; echo $vbphrase['allow_user_selection'] . '<div id="ctrl_userselect" class="smallfont" style="white-space:nowrap"> <label for="rb_1_userselect_2"><input type="radio" name="userselect" id="rb_1_userselect_2" value="1" tabindex="1" checked="checked" />' . $vbphrase['yes'] . '</label> <label for="rb_0_userselect_2"><input type="radio" name="userselect" id="rb_0_userselect_2" value="0" tabindex="1" />' . $vbphrase['no'] . '</label> </div>'; echo '</div></div></form></div>'; }
/** * 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); } }
/** * Deletes all the associated data for a specific from the database. * Only known master (volatile) data is removed. For example, customized versions * of the templates are left. * * @param string Product ID to delete * @param string Whether the deletion needs to work on a 3.5 DB (for vB upgrade scripts) * @param string True if you are calling this for a product upgrade. Old master templates will be moved instead of removed. */ function delete_product($productid, $compliant_35 = false, $for_product_upgrade = false) { global $vbulletin, $stylecache; $productid = $vbulletin->db->escape_string($productid); $check = $vbulletin->db->query_first("SELECT productid FROM " . TABLE_PREFIX . "product WHERE productid = '{$productid}'"); // not installed ... if (!$check['productid']) { return false; } // Stylevars were introduced in vB4 if (version_compare($vbulletin->options['templateversion'], 4, '>=')) { require_once DIR . '/includes/adminfunctions_template.php'; $standardstyleids = array(-1); $mobilestyleids = array(-2); if (!$for_product_upgrade) { cache_styles(); foreach ($stylecache as $styleid => $style) { if ($style['type'] == 'standard') { $standardstyleids[] = $styleid; } else { $mobilestyleids[] = $styleid; } } } $stylevarids = array(); $stylevarinfo = get_stylevars_for_export($productid, "-1"); foreach ($stylevarinfo['stylevardfns'] as $key => $value) { foreach ($value as $x => $stylevar) { $stylevarids[] = $stylevar['stylevarid']; } } if ($stylevarids) { $vbulletin->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "stylevardfn\n\t\t\t\tWHERE stylevarid IN ('" . implode("', '", $stylevarids) . "') AND styleid = -1\n\t\t\t"); $vbulletin->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "stylevar\n\t\t\t\tWHERE\n\t\t\t\t\tstylevarid IN ('" . implode("', '", $stylevarids) . "')\n\t\t\t\t\t\tAND\n\t\t\t\t\tstyleid IN (" . implode(",", $standardstyleids) . ")\n\t\t\t"); } $stylevarids = array(); $stylevarinfo = get_stylevars_for_export($productid, "-2"); foreach ($stylevarinfo['stylevardfns'] as $key => $value) { foreach ($value as $x => $stylevar) { $stylevarids[] = $stylevar['stylevarid']; } } if ($stylevarids) { $vbulletin->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "stylevardfn\n\t\t\t\tWHERE stylevarid IN ('" . implode("', '", $stylevarids) . "') AND styleid = -2\n\t\t\t"); $vbulletin->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "stylevar\n\t\t\t\tWHERE\n\t\t\t\t\tstylevarid IN ('" . implode("', '", $stylevarids) . "')\n\t\t\t\t\t\tAND\n\t\t\t\t\tstyleid IN (" . implode(",", $mobilestyleids) . ")\n\t\t\t"); } } $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "product WHERE productid = '{$productid}'"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "productcode WHERE productid = '{$productid}'"); if ($compliant_35 == false) { $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "productdependency WHERE productid = '{$productid}'"); } $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "plugin WHERE product = '{$productid}'"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "phrase WHERE product = '{$productid}' AND languageid = -1"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "phrasetype WHERE product = '{$productid}'"); $styleids = array(-10, -20); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "template WHERE product = '{$productid}' AND styleid IN (" . implode(',', $styleids) . ")"); if ($for_product_upgrade) { $vbulletin->db->query_write("\n\t\t\tDELETE t1\n\t\t\tFROM " . TABLE_PREFIX . "template AS t1\n\t\t\tINNER JOIN " . TABLE_PREFIX . "template AS t2 ON (t1.title = t2.title AND t2.product = '{$productid}' AND t2.styleid = -1)\n\t\t\tWHERE t1.styleid = -10\n\t\t"); $vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "template\n\t\t\tSET\n\t\t\t\tstyleid = -10\n\t\t\tWHERE\n\t\t\t\tproduct = '{$productid}' AND styleid = -1\n\t\t"); $vbulletin->db->query_write("\n\t\t\tDELETE t1\n\t\t\tFROM " . TABLE_PREFIX . "template AS t1\n\t\t\tINNER JOIN " . TABLE_PREFIX . "template AS t2 ON (t1.title = t2.title AND t2.product = '{$productid}' AND t2.styleid = -2)\n\t\t\tWHERE t1.styleid = -20\n\t\t"); $vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "template\n\t\t\tSET\n\t\t\t\tstyleid = -20\n\t\t\tWHERE\n\t\t\t\tproduct = '{$productid}' AND styleid = -2\n\t\t"); } else { $styleids = array(-1, -2); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "template WHERE product = '{$productid}' AND styleid IN (" . implode(',', $styleids) . ")"); $ids = array(); if (!$compliant_35) { $types = $vbulletin->db->query_read("\n\t\t\t\tSELECT contenttypeid\n\t\t\t\tFROM " . TABLE_PREFIX . "contenttype AS c\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "package AS p ON (c.packageid = p.packageid)\n\t\t\t\tWHERE\n\t\t\t\t\tp.productid = '{$productid}'\n\t\t\t\t\t\tAND\n\t\t\t\t\tc.canattach = 1\n\t\t\t"); while ($type = $vbulletin->db->fetch_array($types)) { $ids[] = $type['contenttypeid']; } if (!empty($ids)) { $attachdata =& datamanager_init('Attachment', $vbulletin, ERRTYPE_SILENT, 'attachment'); $attachdata->set_condition("a.contenttypeid IN (" . implode(",", $ids) . ")"); $attachdata->delete(true, false); } } if (is_newer_version($vbulletin->options['templateversion'], '4.2.0', true)) { $default = $vbulletin->db->query_first("\n\t\t\t\tSELECT navid\n\t\t\t\tFROM " . TABLE_PREFIX . "navigation\n\t\t\t\tWHERE\n\t\t\t\t\tstate & " . $vbulletin->bf_misc_navstate['default'] . "\n\t\t\t\t\t\tAND\n\t\t\t\t\tproductid = '" . $vbulletin->db->escape_string($productid) . "'\n\t\t\t"); if ($default) { $vbulletin->db->query_write("\n\t\t\t\t\tUPDATE " . TABLE_PREFIX . "navigation\n\t\t\t\t\tSET state = state | " . $vbulletin->bf_misc_navstate['default'] . "\n\t\t\t\t\tWHERE name = 'vbtab_whatsnew' AND productid = 'vbulletin'\n\t\t\t\t"); } $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "navigation WHERE productid = '{$productid}'"); build_navigation_datastore(); } } $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "setting WHERE product = '{$productid}' AND volatile = 1"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "settinggroup WHERE product = '{$productid}' AND volatile = 1"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "adminhelp WHERE product = '{$productid}' AND volatile = 1"); if ($compliant_35 == false) { $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "cron WHERE product = '{$productid}' AND volatile = 1"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "faq WHERE product = '{$productid}' AND volatile = 1"); } $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "moderatorlog WHERE product = '{$productid}'"); return true; }