mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Merge pull request #180 from Jmeyering/master
Allow converting of r/n to /n when editing files in October backend
This commit is contained in:
commit
e96a4c684f
@ -169,4 +169,17 @@ return array(
|
||||
|
||||
'defaultMask' => ['file' => null, 'folder' => null],
|
||||
|
||||
);
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Convert Line Endings
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Determines if October should convert line endings from the windows style
|
||||
| \r\n to the unix style \n.
|
||||
|
|
||||
*/
|
||||
|
||||
'convertLineEndings' => false,
|
||||
|
||||
|
||||
);
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php namespace Cms\Controllers;
|
||||
|
||||
use Config;
|
||||
use URL;
|
||||
use Lang;
|
||||
use Flash;
|
||||
@ -143,6 +144,11 @@ class Index extends Controller
|
||||
$templateData[$field] = Request::input($field);
|
||||
}
|
||||
|
||||
if (!empty($templateData['markup']) && Config::get('cms.convertLineEndings', false) === true) {
|
||||
$templateData['markup'] = $this->convertLineEndings($templateData['markup']);
|
||||
}
|
||||
|
||||
|
||||
if (!Request::input('templateForceSave') && $template->mtime) {
|
||||
if (Request::input('templateMtime') != $template->mtime)
|
||||
throw new ApplicationException('mtime-mismatch');
|
||||
@ -361,4 +367,20 @@ class Index extends Controller
|
||||
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* convertLineEndings Replaces Windows style (/r/n) line endings with unix style (/n)
|
||||
* line endings.
|
||||
*
|
||||
* @param string $markup The markup to convert to unix style endings
|
||||
*
|
||||
* @return string $markup
|
||||
*/
|
||||
private function convertLineEndings($markup)
|
||||
{
|
||||
$markup = str_replace("\r\n", "\n", $markup);
|
||||
$markup = str_replace("\r", "\n", $markup);
|
||||
return $markup;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user