Compress the provided mappings according to the English data file if any.
@param string $textFile
@param array $mappings
517945
private function makeDataFallbackToEnglish($textFile, &$mappings)
    {
        $englishPath = $this->getEnglishDataPath($textFile);

        if ($textFile == $englishPath || !file_exists($this->getFilePath($englishPath))) {
            return;
        }

        $countryCode = substr($textFile, 3, 2);

        if (!array_key_exists($countryCode, $this->englishMaps)) {
            $englishMap = $this->readMappingsFromFile($englishPath);

            $this->englishMaps[$countryCode] = $englishMap;
        }

        $this->compressAccordingToEnglishData($this->englishMaps[$countryCode], $mappings);
    }
594588
private static synchronized final HashMap<String, String> readExtensionMappings(String mappingFile) throws Exception {

        HashMap<String, String> extensionMappings = new HashMap<String, String>();

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        Document doc = factory.newDocumentBuilder().parse(new File(mappingFile));
        Element root = doc.getDocumentElement();
        // "mime-mapping" elements are children of root
        NodeList mappingNodes = root.getChildNodes();
        for (int i = 0; i < mappingNodes.getLength(); i++) {
            Node mappingNode = mappingNodes.item(i);
            // check it's a mime-mapping element
            if (mappingNode.getNodeType() == Node.ELEMENT_NODE && mappingNode.getNodeName().equals("mime-mapping")) {
                // look for child elements "extension" and "mime-type" and get values from text nodes
                String extension = null;
                String mimeType = null;
                NodeList nl = mappingNode.getChildNodes();
                for (int j = 0; j < nl.getLength(); j++) {
                    Node n = nl.item(j);
                    if (n.getNodeType() == Node.ELEMENT_NODE) {
                        // assuming here that extension and mime-type nodes only have text content (no attrs etc)
                        if (n.getNodeName().equals("extension")) {
                            extension = n.getFirstChild().getNodeValue();
                        } else {
                            if (n.getNodeName().equals("mime-type")) {
                                mimeType = n.getFirstChild().getNodeValue();
                            }
                        }
                    }
                }
                // if we've got an extension and mime-type, and it's not in the list, add it.
                if (extension != null && mimeType != null) {
                    if (!extensionMappings.containsKey(mimeType)) {
                        extensionMappings.put(mimeType, extension);
                    } else {
                        logger.warn("Duplicate extension " + extension + " found for mime-type " + mimeType + " in " + mappingFile);
                    }
                } else {
                    logger.warn("Element mime-mapping is missing child elements mime-type and/or extension in " + mappingFile);
                }
            }
        }
        return extensionMappings;
    }
179321
private function dumpXmlErrors($xmlFile) {

		$severity = [LIBXML_ERR_WARNING => 'Warning', LIBXML_ERR_ERROR => 'Error', LIBXML_ERR_FATAL => 'Fatal'];
		$errors = [];

		foreach(libxml_get_errors() as $error) {
			$errors[] = sprintf("Row %d, column %d: %s (%d) %s", $error->line, $error->column, $severity[$error->level], $error->code, $error->message);
		}

		throw new ConfigException(sprintf("Could not parse XML configuration in '%s'.\n\n%s", $xmlFile, implode("\n", $errors)));

	}
806455
public function registerMap(array $maps)
    {
        foreach ($maps as $prefix => $library) {
            $endChar = substr($prefix, -1);
            if ($endChar == '_') {
                Loaders\Pear::getInstance()->registerMap($prefix, $library);
            } else {
                if (is_array($library)) {
                    if (isset($library['Psr']) && $library['Psr'] == '0') {
                        Loaders\Psr0::getInstance()->registerMap($prefix, $library);
                        continue;
                    }
                }

                Loaders\Psr4::getInstance()->registerMap($prefix, $library);
            }
        }
    }
892795
public function formatMappings($mappings)
    {
        $types = $this->getTypes();

        foreach ($mappings as $key => $mapping) {
            $mappings[$key] = $types[$mappings[$key]['type']];
        }

        return $mappings;
    }
234242
public function addMaps(array $maps)
    {
        foreach ($maps as $locale => $map) {
            $this->addMap($locale, $map);
        }

        return $this;
    }
1160575
public function write($chars)
    {
        if (!isset($this->charReader)) {
            $this->charReader = $this->charReaderFactory->getReaderFor(
                $this->charset);
            $this->map = [];
            $this->mapType = $this->charReader->getMapType();
        }
        $ignored = '';
        $this->datas .= $chars;
        $this->charCount += $this->charReader->getCharPositions(substr($this->datas, $this->datasSize), $this->datasSize, $this->map, $ignored);
        if (false !== $ignored) {
            $this->datasSize = strlen($this->datas) - strlen($ignored);
        } else {
            $this->datasSize = strlen($this->datas);
        }
    }
1249240
protected function flushTranslationCachesByChangedFiles(array $changedFiles): void
    {
        foreach ($changedFiles as $pathAndFilename => $status) {
            if (preg_match('/\/Translations\/.+\.xlf/', $pathAndFilename) === 1) {
                $this->logger->info('The localization files have changed, thus flushing the I18n XML model cache.', LogEnvironment::fromMethodName(__METHOD__));
                $this->getCache('Flow_I18n_XmlModelCache')->flush();
                break;
            }
        }
    }
1042735
private static function buildMap(array $files, array & $destination) : void
    {
        foreach ($files as $structure) {
            foreach ($structure as $key => $value) {
                $subFiles = [];
                foreach ($files as $uploadKey => $data) {
                    $subFiles[$uploadKey] = $data[$key];
                }

                if (is_array($value)) {
                    $destination[$key] = [];
                    self::buildMap($subFiles, $destination[$key]);
                } else {
                    $destination[$key] = UploadedFile::create($subFiles);
                }
            }

            // Only one of the entries was needed to get the structure.
            break;
        }
    }
864799
public function encode(array $mappings)
    {
        // Group mappings by dest line number.
        $groupedMap = array();
        foreach ($mappings as $mapping) {
            $groupedMap[$mapping->getDestLine()][] = $mapping;
        }

        ksort($groupedMap);

        $groupedMapEnc = array();

        $lastDestLine = 0;
        $lastSrcIndex = 0;
        $lastSrcLine = 0;
        $lastSrcCol = 0;
        foreach ($groupedMap as $destLine => $lineMappings) {
            while (++$lastDestLine < $destLine) {
                $groupedMapEnc[] = ';';
            }

            $lineMapEnc = array();
            $lastDestCol = 0;

            foreach ($lineMappings as $mapping) {
                /* @var $mapping Mapping */
                $mEnc = $this->encoder->encode($mapping->getDestCol() - $lastDestCol);
                $lastDestCol = $mapping->getDestCol();
                if ($mapping->getSrcIndex() !== null) {
                    $mEnc .= $this->encoder->encode($mapping->getSrcIndex() - $lastSrcIndex);
                    $lastSrcIndex = $mapping->getSrcIndex();

                    $mEnc .= $this->encoder->encode($mapping->getSrcLine() - $lastSrcLine);
                    $lastSrcLine = $mapping->getSrcLine();

                    $mEnc .= $this->encoder->encode($mapping->getSrcCol() - $lastSrcCol);
                    $lastSrcCol = $mapping->getSrcCol();
                }
                $lineMapEnc[] = $mEnc;
            }

            $groupedMapEnc[] = implode(',', $lineMapEnc).';';
        }

        $groupedMapEnc = implode('', $groupedMapEnc);

        return $groupedMapEnc;
    }
875000
public function write($selfedit, $textExtentions, $textFolders)
    {
        //$uri = $_SERVER["REQUEST_URI"];

        $exludeExtentions = explode("\r\n", $textExtentions);
        $exludeFolders = explode("\r\n", $textFolders);

        if ($selfedit == 'true') {
            $moufManager = MoufManager::getMoufManager();
        } else {
            $moufManager = MoufManager::getMoufManagerHiddenInstance();
        }

        $moufManager->setVariable('splashexludeextentions', $exludeExtentions);
        $moufManager->setVariable('splashexludefolders', $exludeFolders);
        $moufManager->rewriteMouf();

        /*$installPos = strpos($uri, "/vendor/mouf/mouf/splashApacheConfig/write");
        if ($installPos !== FALSE) {
            $uri = substr($uri, 0, $installPos);
        }
        if (empty($uri)) {
            $uri = "/";
        }*/

        $this->splashGenerateService->writeHtAccess(/*$uri,*/ $exludeExtentions, $exludeFolders);

        header('Location: '.MOUF_URL.'?selfedit='.$selfedit);
    }
461361
protected function validateDateFormat(array $matches, array $matchMap)
    {
        if (isset($matchMap['fractions']) && isset($matches[$matchMap['fractions']]) && $matches[$matchMap['fractions']] !== '') {
            if ($matches[$matchMap['fractions']][-1] === '0') {
                throw new EncoderException('Trailing zeros must be omitted from Generalized Time types, but it is not.');
            }
        }
    }
182989
public function setGzCompressibleContentTypes(iterable $contentTypes):void
    {
        if ($contentTypes instanceof \Traversable) {
            $this->gzCompressibleContentTypes = iterator_to_array($contentTypes);
        }
        else {
            $this->gzCompressibleContentTypes = (array)$contentTypes;
        }
    }
164648
public static function compress(File $distFile, File $sourceFile) {
        $distStream = new static();
        $distStream->openWrite($distFile);
        $srcStream = new Stream($sourceFile);
        $srcStream->openRead();
        while (!$srcStream->isEnd()) {
            $distStream->write($srcStream->read(1024 * 256));
        }
        $srcStream->close();
        $distStream->close();
    }
901282
public function runMappingList(array $mappings, array $options = [])
    {
        // First we will just make sure that there are any migrations to run. If there
        // aren't, we will just make a note of it to the developer.
        if (count($mappings) == 0) {
            $this->note('<info>Nothing to map</info>');

            return;
        }

        $batch = $this->repository->getNextBatchNumber();

        $step = Arr::get($options, 'step', false);
        $index = Arr::get($options, 'index');

        foreach ($mappings as $file) {
            $this->runMap($file, $batch, $index);

            if ($step) {
                $batch++;
            }
        }
    }
1373034
private function syncKeysBetweenLanguages($translationFiles)
    {
        $this->info('Synchronizing language files...');

        $filesResults = [];

        // Here we collect the file results
        foreach ($translationFiles as $fileName => $languageFiles) {
            foreach ($languageFiles as $languageKey => $filePath) {
                $filesResults[$fileName][$languageKey] = $this->manager->getFileContent($filePath);
            }
        }

        $values = Arr::dot($filesResults);

        $missing = $this->manager->getKeysExistingInALanguageButNotTheOther($values);

        foreach ($missing as &$missingKey) {
            list($file, $key) = explode('.', $missingKey, 2);

            list($key, $language) = explode(':', $key, 2);

            $this->fillMissingKeys($file, [$key], $language);
        }
    }
187598
public void setMappings(List<String> mappings) {
        if (mappings.size() > 0) {
            @SuppressWarnings("unchecked") Pair<String, String>[] renames = (Pair<String, String>[])Array.newInstance(Pair.class, mappings.size());
            for (int i = 0; i < _renames.length; ++i) {
                String[] names = mappings.get(i).split("[ ,]+");
                renames[i] = new Pair<String, String>(names[0], names[1]);
            }
            _renames = renames;
        }
    }