Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $files = glob('*/.idea/encodings.xml');
- foreach($files as $file) {
- addProjectEncoding($file);
- }
- function addProjectEncoding($filename) {
- $dom = new DOMDocument();
- $dom->load($filename);
- $encoding = null;
- $components = $dom->getElementsByTagName('component');
- foreach($components as $component) {
- if($component->getAttribute('name') != 'Encoding') continue;
- $encoding = $component;
- break;
- }
- if(!$encoding) {
- $encoding = $dom->createElement('component');
- $encoding->setAttribute('name', 'Encoding');
- $dom->appendChild($encoding);
- }
- $encoding->setAttribute('useUTFGuessing', 'true');
- $encoding->setAttribute('native2AsciiForPropertiesFiles', 'false');
- $encoding->setAttribute('defaultCharsetForPropertiesFiles', 'UTF-8');
- $project = null;
- $files = $encoding->getElementsByTagName('file');
- foreach($files as $file) {
- if($file->getAttribute('url') != 'PROJECT') continue;
- $project = $file;
- break;
- }
- if(!$project) {
- $project = $dom->createElement('file');
- $project->setAttribute('url', 'PROJECT');
- $encoding->appendChild($project);
- }
- $project->setAttribute('charset', 'UTF-8');
- $dom->save($filename);
- echo $filename, "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement