Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-07-18 14:21:19 +02:00
commit 5db9a3eed2
3 changed files with 62 additions and 26 deletions

View File

@ -40,6 +40,7 @@ phpMyAdmin - ChangeLog
- issue #13468 Avoid breakage if set_time_limit is disabled
- issue #13471 Fail if ini_set/ini_get are disabled
- issue #13436 Automatically connect using SSL when server is configured so
- issue #13478 Fixed usage of some browser transformations
4.7.2 (2017-06-29)
- issue #13314 Make theme selection keep current server

View File

@ -209,6 +209,32 @@ class Transformations
return $class_name::getName();
}
/**
* Fixups old MIME or tranformation name to new one
*
* - applies some hardcoded fixups
* - adds spaces after _ and numbers
* - capitalizes words
* - removes back spaces
*
* @param string $value Value to fixup
*
* @return string
*/
static function fixupMIME($value)
{
$value = str_replace(
array("jpeg", "png"), array("JPEG", "PNG"), $value
);
return str_replace(
' ',
'',
ucwords(
preg_replace('/([0-9_]+)/', '$1 ', $value)
)
);
}
/**
* Gets the mimetypes for all columns of a table
*
@ -256,24 +282,10 @@ class Transformations
);
foreach ($result as $column => $values) {
// replacements in mimetype and transformation
$values = str_replace("jpeg", "JPEG", $values);
$values = str_replace("png", "PNG", $values);
// convert mimetype to new format (f.e. Text_Plain, etc)
$delimiter_space = '- ';
$delimiter = "_";
$values['mimetype'] = str_replace(
$delimiter_space,
$delimiter,
ucwords(
str_replace(
$delimiter,
$delimiter_space,
$values['mimetype']
)
)
);
$values['mimetype'] = self::fixupMIME($values['mimetype']);
// For transformation of form
// output/image_jpeg__inline.inc.php
@ -285,17 +297,7 @@ class Transformations
$values['transformation'] = $dir[1];
}
$values['transformation'] = str_replace(
$delimiter_space,
$delimiter,
ucwords(
str_replace(
$delimiter,
$delimiter_space,
$values['transformation']
)
)
);
$values['transformation'] = self::fixupMIME($values['transformation']);
$values['transformation'] = $subdir . $values['transformation'];
$result[$column] = $values;
}

View File

@ -254,4 +254,37 @@ class TransformationsTest extends PHPUnit_Framework_TestCase
$actual
);
}
/**
* @dataProvider fixupData
*/
public function testFixup($value, $expected)
{
$this->assertEquals(
$expected,
Transformations::fixupMIME($value)
);
}
public function fixupData()
{
return array(
array(
'text_plain_bool2text.php',
'Text_Plain_Bool2Text.php'
),
array(
'application_octetstream_download.php',
'Application_Octetstream_Download.php'
),
array(
'text_plain_json.php',
'Text_Plain_Json.php'
),
array(
'image_jpeg_link.php',
'Image_JPEG_Link.php'
),
);
}
}