$vbulletin->input->clean_array_gpc('p', array('delete' => TYPE_ARRAY_INT, 'dostyleid' => TYPE_INT, 'title' => TYPE_STR)); if ($vbulletin->GPC['delete']) { $ids = implode(', ', $vbulletin->GPC['delete']); $db->query_write("DELETE FROM " . TABLE_PREFIX . "templatehistory WHERE templatehistoryid IN ({$ids})"); } define('CP_REDIRECT', 'template.php?do=history&dostyleid=' . $vbulletin->GPC['dostyleid'] . '&title=' . urlencode($vbulletin->GPC['title'])); print_stop_message('template_history_entries_deleted'); } // ############################################################################# // generate a diff between two templates (current or historical versions) if ($_POST['do'] == 'docompare') { $vbulletin->input->clean_array_gpc('p', array('left_template' => TYPE_STR, 'right_template' => TYPE_STR, 'wrap' => TYPE_BOOL)); list($left_id, $left_type) = explode('|', $vbulletin->GPC['left_template']); list($right_id, $right_type) = explode('|', $vbulletin->GPC['right_template']); $left_template = fetch_template_current_historical($left_id, $left_type); $right_template = fetch_template_current_historical($right_id, $right_type); if (!$left_template or !$right_template) { exit; } require_once DIR . '/includes/class_diff.php'; $diff =& new vB_Text_Diff($left_template['templatetext'], $right_template['templatetext']); $entries =& $diff->fetch_diff(); print_form_header('template', 'docompare'); print_table_header(construct_phrase($vbphrase['comparing_versions_of_x'], htmlspecialchars_uni($left_template['title']))); print_cells_row(array($vbphrase['old_version'], $vbphrase['new_version']), true, false, 1); foreach ($entries as $diff_entry) { // possible classes: unchanged, notext, deleted, added, changed echo "<tr>\n\t"; echo '<td width="50%" valign="top" class="diff-' . $diff_entry->fetch_data_old_class() . '" dir="ltr">' . $diff_entry->prep_diff_text($diff_entry->fetch_data_old(), $vbulletin->GPC['wrap']) . "</td>\n\t"; echo '<td width="50%" valign="top" class="diff-' . $diff_entry->fetch_data_new_class() . '" dir="ltr">' . $diff_entry->prep_diff_text($diff_entry->fetch_data_new(), $vbulletin->GPC['wrap']) . "</td>\n"; echo "</tr>\n\n";
/** * Fetch current or historical uncompiled version of a template * * @param integer The ID (in the appropriate table) of the record you want to fetch. * @param string Type of template you want to fetch; should be "current" or "historical" */ public function fetchVersion($historyid, $type) { $this->checkHasAdminPermission('canadmintemplates'); require_once DIR . '/includes/adminfunctions_template.php'; $template = fetch_template_current_historical($historyid, $type); return $template; }