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
d2fcc69b
Commit
d2fcc69b
authored
Mar 08, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Html WIP
parent
d1a5bb2a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
ArrayHelper.php
framework/util/ArrayHelper.php
+33
-0
Html.php
framework/util/Html.php
+0
-0
No files found.
framework/util/ArrayHelper.php
View file @
d2fcc69b
...
...
@@ -7,6 +7,7 @@
namespace
yii\util
;
use
Yii
;
use
yii\base\InvalidParamException
;
/**
...
...
@@ -279,4 +280,35 @@ class ArrayHelper
$args
[]
=
&
$array
;
call_user_func_array
(
'array_multisort'
,
$args
);
}
/**
* Encodes special characters in an array of strings into HTML entities.
* Both the array keys and values will be encoded if needed.
* If a value is an array, this method will also encode it recursively.
* @param array $data data to be encoded
* @param string $charset the charset that the data is using. If not set,
* [[\yii\base\Application::charset]] will be used.
* @return array the encoded data
* @see http://www.php.net/manual/en/function.htmlspecialchars.php
*/
public
static
function
htmlEncode
(
$data
,
$charset
=
null
)
{
if
(
$charset
===
null
)
{
$charset
=
Yii
::
$app
->
charset
;
}
$d
=
array
();
foreach
(
$data
as
$key
=>
$value
)
{
if
(
is_string
(
$key
))
{
$key
=
htmlspecialchars
(
$key
,
ENT_QUOTES
,
$charset
);
}
if
(
is_string
(
$value
))
{
$value
=
htmlspecialchars
(
$value
,
ENT_QUOTES
,
$charset
);
}
elseif
(
is_array
(
$value
))
{
$value
=
static
::
htmlEncode
(
$value
);
}
$d
[
$key
]
=
$value
;
}
return
$d
;
}
}
\ No newline at end of file
framework/util/Html.php
View file @
d2fcc69b
This diff is collapsed.
Click to expand it.
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