private static function removeMarkedSectionHelper($strPluginName, $strFileName) { $oldContents = QFile::readFile($strFileName); $search = str_replace("\r\n", "", self::getBeginMarker($strPluginName) . ".*" . self::getEndMarker($strPluginName)); $intReplacementCount = 0; $newContents = preg_replace('|' . $search . '|s', '', $oldContents, -1, $intReplacementCount); $newContents = self::stripExtraNewlines($newContents); QFile::writeFile($strFileName, $newContents); return $intReplacementCount; }
private static function appendPluginConfigToMasterConfig($strExtractedFolderName) { $strStatus = ""; $configToAppendPath = self::getExpandedPath($strExtractedFolderName) . self::PLUGIN_CONFIG_FILE; // Get the full contents of the configuration file that we need to append $configToAppend = QFile::readFile($configToAppendPath); $strStatus .= "Plugin config read\r\n"; $search = "</plugins>"; $replace = "\r\n" . $configToAppend . "\r\n\r\n</plugins>"; self::replaceFileSection(self::getMasterConfigFilePath(), $search, $replace); $strStatus .= "Plugin config appended to master config XML file successfully\r\n"; return $strStatus; }
protected static function replaceFileSection($strFilePath, $strSearch, $strReplace) { $contents = QFile::readFile($strFilePath); $contents = str_replace($strSearch, $strReplace, $contents); QFile::writeFile($strFilePath, self::stripExtraNewlines($contents)); }