/** * Restores a page. * * Specifically, this restores the page, page template, and route * information so it reflects the values present at initial install. This is meant * to be used only on the vBulletin default pages. * * @param string Page GUID * @param bool Print the Page title or not */ public function restorePage($guid, $printMessage = true) { $xmlpage = $this->xml['page'][$guid]; $xmlroute = $this->getXmlRouteByPageGuid($xmlpage['guid']); $xmlpagetemplate = $this->getXmlPageTemplateByPageGuid($xmlpage['guid']); $dbpage = $this->getMatchingPageFromDbByXmlGuid($xmlpage['guid']); $dbroute = $this->getDbRouteByRouteId($dbpage['routeid']); $dbpagetemplate = $this->getDbPageTemplateByPageTemplateId($dbpage['pagetemplateid']); if ($printMessage) { echo $xmlpage['title']; } // delete existing records $this->assertor->delete('page', array('guid' => $xmlpage['guid'])); $this->assertor->delete('pagetemplate', array('guid' => $xmlpagetemplate['guid'])); $this->assertor->delete('routenew', array('guid' => $xmlroute['guid'])); // remove name from current db route so xml route can be restored w/o an index conflict if ($dbroute['guid'] != $xmlroute['guid']) { $this->assertor->update('routenew', array('name' => vB_dB_Query::VALUE_ISNULL), array('routeid' => $dbroute['routeid'])); } // restore pagetemplate record $options = vB_Xml_Import::OPTION_OVERWRITE; $xml_importer = new vB_Xml_Import_PageTemplate('vbulletin', $options); $xml_importer->importFromFile("{$this->xmldir}/vbulletin-pagetemplates.xml", $xmlpagetemplate['guid']); $xml_importer->replacePhrasePlaceholdersInWidgetConfigs(); // restore page record $options = vB_Xml_Import::OPTION_OVERWRITE; $xml_importer = new vB_Xml_Import_Page('vbulletin', $options); $xml_importer->importFromFile("{$this->xmldir}/vbulletin-pages.xml", $xmlpage['guid']); // restore route record $options = vB_Xml_Import::OPTION_OVERWRITE; $xml_importer = new vB_Xml_Import_Route('vbulletin', $options); $xml_importer->importFromFile("{$this->xmldir}/vbulletin-routes.xml", $xmlroute['guid']); // update page route $xml_importer = new vB_Xml_Import_Page('vbulletin', 0); $parsedXML = $xml_importer->parseFile("{$this->xmldir}/vbulletin-pages.xml"); $xml_importer->updatePageRoutes($parsedXML); // get the new route $newRoute = $this->assertor->getRow('routenew', array('guid' => $xmlroute['guid'])); // set previous db route to 301 redirect if ($dbroute['guid'] != $xmlroute['guid']) { $this->assertor->update('routenew', array('redirect301' => $newRoute['routeid']), array('routeid' => $dbroute['routeid'])); } // update node routeid $this->assertor->update('vbForum:node', array('routeid' => $newRoute['routeid']), array('routeid' => $dbroute['routeid'])); // clear cache vB_Cache::resetAllCache(); }