Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Yeray Santana Hualde
syncEnrollments
Commits
bf44ce81
Commit
bf44ce81
authored
Jun 17, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added asset links and improved html class.
parent
868a33fb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
24 deletions
+47
-24
html.php
system/html.php
+21
-22
url.php
system/url.php
+26
-2
No files found.
system/html.php
View file @
bf44ce81
...
@@ -21,7 +21,7 @@ class HTML {
...
@@ -21,7 +21,7 @@ class HTML {
*/
*/
public
static
function
script
(
$url
)
public
static
function
script
(
$url
)
{
{
return
'<script type="text/javascript" src="'
.
trim
(
static
::
entities
(
URL
::
to
(
$url
)),
'.js'
)
.
'.js"></script>'
.
PHP_EOL
;
return
'<script type="text/javascript" src="'
.
trim
(
static
::
entities
(
URL
::
to
_asset
(
$url
)),
'.js'
)
.
'.js"></script>'
.
PHP_EOL
;
}
}
/**
/**
...
@@ -32,7 +32,7 @@ class HTML {
...
@@ -32,7 +32,7 @@ class HTML {
*/
*/
public
static
function
style
(
$url
,
$media
=
'all'
)
public
static
function
style
(
$url
,
$media
=
'all'
)
{
{
return
'<link href="'
.
trim
(
static
::
entities
(
URL
::
to
(
$url
)),
'.css'
)
.
'.css" rel="stylesheet" type="text/css" media="'
.
$media
.
'" />'
.
PHP_EOL
;
return
'<link href="'
.
trim
(
static
::
entities
(
URL
::
to
_asset
(
$url
)),
'.css'
)
.
'.css" rel="stylesheet" type="text/css" media="'
.
$media
.
'" />'
.
PHP_EOL
;
}
}
/**
/**
...
@@ -42,11 +42,12 @@ class HTML {
...
@@ -42,11 +42,12 @@ class HTML {
* @param string $title
* @param string $title
* @param array $attributes
* @param array $attributes
* @param bool $https
* @param bool $https
* @param bool $asset
* @return string
* @return string
*/
*/
public
static
function
link
(
$url
,
$title
,
$attributes
=
array
(),
$https
=
false
)
public
static
function
link
(
$url
,
$title
,
$attributes
=
array
(),
$https
=
false
,
$asset
=
false
)
{
{
return
'<a href="'
.
static
::
entities
(
URL
::
to
(
$url
,
$https
))
.
'"'
.
static
::
attributes
(
$attributes
)
.
'>'
.
static
::
entities
(
$title
)
.
'</a>'
;
return
'<a href="'
.
static
::
entities
(
URL
::
to
(
$url
,
$https
,
$asset
))
.
'"'
.
static
::
attributes
(
$attributes
)
.
'>'
.
static
::
entities
(
$title
)
.
'</a>'
;
}
}
/**
/**
...
@@ -57,11 +58,24 @@ class HTML {
...
@@ -57,11 +58,24 @@ class HTML {
* @param array $attributes
* @param array $attributes
* @return string
* @return string
*/
*/
public
static
function
secure_link
(
$url
,
$title
,
$attributes
)
public
static
function
link_to_secure
(
$url
,
$title
,
$attributes
)
{
{
return
static
::
link
(
$url
,
$title
,
$attributes
,
true
);
return
static
::
link
(
$url
,
$title
,
$attributes
,
true
);
}
}
/**
* Generate an HTML link to an asset.
*
* @param string $url
* @param string $title
* @param array $attributes
* @return string
*/
public
static
function
link_to_asset
(
$url
,
$title
,
$attributes
)
{
return
static
::
link
(
$url
,
$title
,
$attributes
,
false
,
true
);
}
/**
/**
* Generate an HTML mailto link.
* Generate an HTML mailto link.
*
*
...
@@ -72,9 +86,6 @@ class HTML {
...
@@ -72,9 +86,6 @@ class HTML {
*/
*/
public
static
function
mailto
(
$email
,
$title
=
null
,
$attributes
=
array
())
public
static
function
mailto
(
$email
,
$title
=
null
,
$attributes
=
array
())
{
{
// -------------------------------------------------------
// Obfuscate the e-mail address.
// -------------------------------------------------------
$email
=
static
::
email
(
$email
);
$email
=
static
::
email
(
$email
);
if
(
is_null
(
$title
))
if
(
is_null
(
$title
))
...
@@ -107,7 +118,7 @@ class HTML {
...
@@ -107,7 +118,7 @@ class HTML {
public
static
function
image
(
$url
,
$alt
=
''
,
$attributes
=
array
())
public
static
function
image
(
$url
,
$alt
=
''
,
$attributes
=
array
())
{
{
$attributes
[
'alt'
]
=
static
::
entities
(
$alt
);
$attributes
[
'alt'
]
=
static
::
entities
(
$alt
);
return
'<img src="'
.
static
::
entities
(
URL
::
to
(
$url
))
.
'"'
.
static
::
attributes
(
$attributes
)
.
' />'
;
return
'<img src="'
.
static
::
entities
(
URL
::
to
_asset
(
$url
))
.
'"'
.
static
::
attributes
(
$attributes
)
.
' />'
;
}
}
/**
/**
...
@@ -166,11 +177,6 @@ class HTML {
...
@@ -166,11 +177,6 @@ class HTML {
*/
*/
private
static
function
list_elements
(
$type
,
$list
,
$attributes
)
private
static
function
list_elements
(
$type
,
$list
,
$attributes
)
{
{
if
(
!
is_array
(
$list
))
{
return
''
;
}
$html
=
''
;
$html
=
''
;
foreach
(
$list
as
$key
=>
$value
)
foreach
(
$list
as
$key
=>
$value
)
...
@@ -199,14 +205,7 @@ class HTML {
...
@@ -199,14 +205,7 @@ class HTML {
}
}
}
}
if
(
count
(
$html
)
>
0
)
return
(
count
(
$html
)
>
0
)
?
' '
.
implode
(
' '
,
$html
)
:
''
;
{
return
' '
.
implode
(
' '
,
$html
);
}
else
{
return
''
;
}
}
}
/**
/**
...
...
system/url.php
View file @
bf44ce81
...
@@ -6,9 +6,11 @@ class URL {
...
@@ -6,9 +6,11 @@ class URL {
* Generate an application URL.
* Generate an application URL.
*
*
* @param string $url
* @param string $url
* @param bool $https
* @param bool $asset
* @return string
* @return string
*/
*/
public
static
function
to
(
$url
=
''
,
$https
=
false
)
public
static
function
to
(
$url
=
''
,
$https
=
false
,
$asset
=
false
)
{
{
// ----------------------------------------------------
// ----------------------------------------------------
// Return the URL unchanged if it is already formed.
// Return the URL unchanged if it is already formed.
...
@@ -21,7 +23,17 @@ class URL {
...
@@ -21,7 +23,17 @@ class URL {
// ----------------------------------------------------
// ----------------------------------------------------
// Get the base URL and index page.
// Get the base URL and index page.
// ----------------------------------------------------
// ----------------------------------------------------
$base
=
Config
::
get
(
'application.url'
)
.
'/'
.
Config
::
get
(
'application.index'
);
$base
=
Config
::
get
(
'application.url'
);
// ----------------------------------------------------
// Assets live in the public directory, so we don't
// want to append the index file to the URL if the
// URL is to an asset.
// ----------------------------------------------------
if
(
!
$asset
)
{
$base
.=
'/'
.
Config
::
get
(
'application.index'
);
}
// ----------------------------------------------------
// ----------------------------------------------------
// Does the URL need an HTTPS protocol?
// Does the URL need an HTTPS protocol?
...
@@ -45,6 +57,18 @@ class URL {
...
@@ -45,6 +57,18 @@ class URL {
return
static
::
to
(
$url
,
true
);
return
static
::
to
(
$url
,
true
);
}
}
/**
* Generate an application URL to an asset. The index file
* will not be added to the URL.
*
* @param string $url
* @return string
*/
public
static
function
to_asset
(
$url
)
{
return
static
::
to
(
$url
,
false
,
true
);
}
/**
/**
* Generate a URL from a route name.
* Generate a URL from a route name.
*
*
...
...
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