Upgrade to 3.2.0

This commit is contained in:
Bastian Allgeier
2019-06-25 09:56:08 +02:00
parent 9e18cf635d
commit 9c89153d35
296 changed files with 14408 additions and 2504 deletions

View File

@@ -9,9 +9,9 @@ use Kirby\Toolkit\Str;
*
* @package Kirby Data
* @author Bastian Allgeier <bastian@getkirby.com>
* @link http://getkirby.com
* @copyright Bastian Allgeier
* @license MIT
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @license https://opensource.org/licenses/MIT
*/
class Txt extends Handler
{
@@ -40,9 +40,9 @@ class Txt extends Handler
}
/**
* Helper for converting value
* Helper for converting the value
*
* @param array|string $value
* @param array|string $value
* @return string
*/
protected static function encodeValue($value): string
@@ -56,13 +56,13 @@ class Txt extends Handler
}
// escape accidental dividers within a field
$value = preg_replace('!(\n|^)----(.*?\R*)!', '$1\\----$2', $value);
$value = preg_replace('!(?<=\n|^)----!', '\\----', $value);
return $value;
}
/**
* Helper for converting key and value to result string
* Helper for converting the key and value to the result string
*
* @param string $key
* @param string $value
@@ -70,11 +70,13 @@ class Txt extends Handler
*/
protected static function encodeResult(string $key, string $value): string
{
$result = $key . ': ';
$result = $key . ':';
// multi-line content
if (preg_match('!\R!', $value) === 1) {
$result .= "\n\n";
} else {
$result .= ' ';
}
$result .= trim($value);
@@ -107,7 +109,10 @@ class Txt extends Handler
continue;
}
$data[$key] = trim(substr($field, $pos + 1));
$value = trim(substr($field, $pos + 1));
// unescape escaped dividers within a field
$data[$key] = preg_replace('!(?<=\n|^)\\\\----!', '----', $value);
}
return $data;