Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
c8f8f654
Commit
c8f8f654
authored
Sep 10, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed paragraph formatting
parent
d8219570
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
Formatter.php
framework/i18n/Formatter.php
+2
-2
FormatterTest.php
tests/unit/framework/i18n/FormatterTest.php
+12
-0
No files found.
framework/i18n/Formatter.php
View file @
c8f8f654
...
...
@@ -31,7 +31,7 @@ use yii\helpers\Html;
* The Formatter class is designed to format values according to a [[locale]]. For this feature to work
* the [PHP intl extension](http://php.net/manual/en/book.intl.php) has to be installed.
* Most of the methods however work also if the PHP intl extension is not installed by providing
* a fallback implementation. Without intl month and day names are in
e
nglish only.
* a fallback implementation. Without intl month and day names are in
E
nglish only.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Enrica Ruedin <e.ruedin@guggach.com>
...
...
@@ -278,7 +278,7 @@ class Formatter extends Component
if
(
$value
===
null
)
{
return
$this
->
nullDisplay
;
}
return
str_replace
(
'<p></p>'
,
''
,
'<p>'
.
preg_replace
(
'/
[\r\n]
{2,}/'
,
"</p>
\n
<p>"
,
Html
::
encode
(
$value
))
.
'</p>'
);
return
str_replace
(
'<p></p>'
,
''
,
'<p>'
.
preg_replace
(
'/
\R
{2,}/'
,
"</p>
\n
<p>"
,
Html
::
encode
(
$value
))
.
'</p>'
);
}
/**
...
...
tests/unit/framework/i18n/FormatterTest.php
View file @
c8f8f654
...
...
@@ -145,6 +145,18 @@ class FormatterTest extends TestCase
$this
->
assertSame
(
"<p>123</p>
\n
<p>456</p>"
,
$this
->
formatter
->
asParagraphs
(
$value
));
$value
=
"123
\n\n\n
456"
;
$this
->
assertSame
(
"<p>123</p>
\n
<p>456</p>"
,
$this
->
formatter
->
asParagraphs
(
$value
));
$value
=
"123
\r\n
456"
;
$this
->
assertSame
(
"<p>123
\r\n
456</p>"
,
$this
->
formatter
->
asParagraphs
(
$value
));
$value
=
"123
\r\n\r\n
456"
;
$this
->
assertSame
(
"<p>123</p>
\n
<p>456</p>"
,
$this
->
formatter
->
asParagraphs
(
$value
));
$value
=
"123
\r\n\r\n\r\n
456"
;
$this
->
assertSame
(
"<p>123</p>
\n
<p>456</p>"
,
$this
->
formatter
->
asParagraphs
(
$value
));
$value
=
"123
\r
456"
;
$this
->
assertSame
(
"<p>123
\r
456</p>"
,
$this
->
formatter
->
asParagraphs
(
$value
));
$value
=
"123
\r\r
456"
;
$this
->
assertSame
(
"<p>123</p>
\n
<p>456</p>"
,
$this
->
formatter
->
asParagraphs
(
$value
));
$value
=
"123
\r\r\r
456"
;
$this
->
assertSame
(
"<p>123</p>
\n
<p>456</p>"
,
$this
->
formatter
->
asParagraphs
(
$value
));
// null display
$this
->
assertSame
(
$this
->
formatter
->
nullDisplay
,
$this
->
formatter
->
asParagraphs
(
null
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment