Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
e942c203
Commit
e942c203
authored
Mar 22, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added macro support to HTML class to match Form class.
parent
0455c10a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
3 deletions
+38
-3
laravel/html.php
+38
-3
No files found.
laravel/html.php
View file @
e942c203
...
...
@@ -3,6 +3,25 @@
class
HTML
{
/**
* The registered custom macros.
*
* @var array
*/
public
static
$macros
=
array
();
/**
* Registers a custom macro.
*
* @param string $name
* @param Closure $input
* @return void
*/
public
static
function
macro
(
$name
,
$macro
)
{
static
::
$macros
[
$name
]
=
$macro
;
}
/**
* Convert HTML characters to entities.
*
* The encoding specified in the application configuration file will be used.
...
...
@@ -319,7 +338,7 @@ class HTML {
{
// For numeric keys, we will assume that the key and the value are the
// same, as this will conver HTML attributes such as "required" that
// may be specified as required="required".
// may be specified as required="required"
, etc
.
if
(
is_numeric
(
$key
))
$key
=
$value
;
if
(
!
is_null
(
$value
))
...
...
@@ -345,8 +364,7 @@ class HTML {
{
// To properly obfuscate the value, we will randomly convert each
// letter to its entity or hexadecimal representation, keeping a
// bot from sniffing the randomly obfuscated letters from the
// page and guarding against e-mail harvesting.
// bot from sniffing the randomly obfuscated letters.
switch
(
rand
(
1
,
3
))
{
case
1
:
...
...
@@ -365,4 +383,21 @@ class HTML {
return
$safe
;
}
/**
* Dynamically handle calls to custom macros.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public
static
function
__callStatic
(
$method
,
$parameters
)
{
if
(
isset
(
static
::
$macros
[
$method
]))
{
return
call_user_func_array
(
static
::
$macros
[
$method
],
$parameters
);
}
throw
new
\Exception
(
"Method [
$method
] does not exist."
);
}
}
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