mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 01:04:16 +02:00
Fix issue processwire/processwire-issues#1442
This commit is contained in:
@@ -351,7 +351,11 @@ class LanguageParser extends Wire {
|
||||
*/
|
||||
protected function unescapeText($text) {
|
||||
if(strpos($text, '\\') !== false) {
|
||||
$text = str_replace(array('\\"', '\\\'', '\\$', '\\'), array('"', "'", '$', '\\'), $text);
|
||||
$text = str_replace(
|
||||
array('\\"', '\\\'', '\\$', '\\n', '\\'),
|
||||
array('"', "'", '$', "\n", '\\'),
|
||||
$text
|
||||
);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
@@ -467,6 +467,7 @@ class LanguageTranslator extends Wire {
|
||||
*
|
||||
*/
|
||||
protected function getTextHash($text) {
|
||||
if(strpos($text, '\\n') !== false) $text = str_replace('\\n', "\n", $text);
|
||||
return md5($text);
|
||||
}
|
||||
|
||||
@@ -597,15 +598,15 @@ class LanguageTranslator extends Wire {
|
||||
/**
|
||||
* JSON encode language translation data
|
||||
*
|
||||
* @param string $str
|
||||
* @param array|string $value
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function encodeJSON($str) {
|
||||
public function encodeJSON($value) {
|
||||
if(defined("JSON_PRETTY_PRINT")) {
|
||||
return json_encode($str, JSON_PRETTY_PRINT);
|
||||
return json_encode($value, JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
return json_encode($str);
|
||||
return json_encode($value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -377,9 +377,15 @@ class ProcessLanguageTranslator extends Process {
|
||||
|
||||
protected function executeEditField($hash, $untranslated, $translated, $alternates) {
|
||||
|
||||
/** @var InputfieldText $field */
|
||||
/** @var InputfieldText|InputfieldTextarea $field */
|
||||
|
||||
if(strlen($untranslated) < 128) {
|
||||
if(strpos($untranslated, "\n") !== false) {
|
||||
$qty = substr_count($untranslated, "\n")+1;
|
||||
$qty2 = substr_count($translated, "\n")+1;
|
||||
if($qty2 > $qty) $qty = $qty2;
|
||||
$field = $this->modules->get("InputfieldTextarea");
|
||||
$field->attr('rows', $qty > 2 ? $qty : 2);
|
||||
} else if(strlen($untranslated) < 128) {
|
||||
$field = $this->modules->get("InputfieldText");
|
||||
} else {
|
||||
$field = $this->modules->get("InputfieldTextarea");
|
||||
|
Reference in New Issue
Block a user