mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
parent
903c9db8a6
commit
011f211b8f
@ -1,35 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
// @codingStandardsIgnoreStart
|
|
||||||
|
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// TODO: Search for the best and safest quoting
|
||||||
// {{{ICINGA_LICENSE_HEADER}}}
|
// TODO: Check whether attributes are safe. Script, title in combination with
|
||||||
|
// Hover-Tips etc. Eventually create a whitelist for a few options only.
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Zend_View_Helper_Qlink
|
|
||||||
* @package Application\Views
|
|
||||||
*/
|
|
||||||
class Zend_View_Helper_Qlink extends Zend_View_Helper_Abstract
|
class Zend_View_Helper_Qlink extends Zend_View_Helper_Abstract
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @param $htmlContent
|
public function qlink($htmlContent, $urlFormat, array $uriParams = array(),
|
||||||
* @param $urlFormat
|
array $properties = array())
|
||||||
* @param array $uriParams
|
{
|
||||||
* @param array $properties
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function qlink(
|
|
||||||
$htmlContent,
|
|
||||||
$urlFormat,
|
|
||||||
array $uriParams = array(),
|
|
||||||
array $properties = array()
|
|
||||||
) {
|
|
||||||
$quote = true;
|
$quote = true;
|
||||||
$attributes = array();
|
$attributes = array();
|
||||||
$baseUrl = null;
|
$baseUrl = null;
|
||||||
foreach ($properties as $key => $val) {
|
foreach ($properties as $key => $val) {
|
||||||
if ($key === 'baseUrl' ) {
|
if ($key === 'baseUrl' ) {
|
||||||
// $baseUrl = filter_var($val, FILTER_SANITIZE_URL) . '/';
|
// $baseUrl = filter_var($val, FILTER_SANITIZE_URL) . '/';
|
||||||
$baseUrl = rawurlencode($val) . '/';
|
$baseUrl = $val; //rawurlencode($val) . '/';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($key === 'quote') {
|
if ($key === 'quote') {
|
||||||
@ -59,25 +47,29 @@ class Zend_View_Helper_Qlink extends Zend_View_Helper_Abstract
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if ($urlFormat instanceof Url) {
|
||||||
|
$url = $urlFormat;
|
||||||
|
$uriParams = $url->getParams() + $uriParams;
|
||||||
|
} else {
|
||||||
|
$url = Url::create($urlFormat);
|
||||||
|
}
|
||||||
|
$url->setParams($uriParams)->setBaseUrl($baseUrl);
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<a href="%s"%s>%s</a>',
|
'<a href="%s"%s>%s</a>',
|
||||||
$this->getFormattedUrl($urlFormat, $uriParams, $baseUrl),
|
// $this->getFormattedUrl($urlFormat, $uriParams, $baseUrl),
|
||||||
|
$url,
|
||||||
!empty($attributes) ? ' ' . implode(' ', $attributes) : '',
|
!empty($attributes) ? ' ' . implode(' ', $attributes) : '',
|
||||||
$quote ? filter_var(
|
$quote
|
||||||
|
? filter_var(
|
||||||
$htmlContent,
|
$htmlContent,
|
||||||
FILTER_SANITIZE_FULL_SPECIAL_CHARS,
|
FILTER_SANITIZE_FULL_SPECIAL_CHARS,
|
||||||
FILTER_FLAG_NO_ENCODE_QUOTES
|
FILTER_FLAG_NO_ENCODE_QUOTES
|
||||||
) : $htmlContent // Alternative: htmlentities($htmlContent)
|
)
|
||||||
|
// Alternativ: htmlentities($htmlContent)
|
||||||
|
: $htmlContent
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
/**
|
|
||||||
* @param $urlFormat
|
|
||||||
* @param $uriParams
|
|
||||||
* @param null $baseUrl
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getFormattedUrl($urlFormat, $uriParams, $baseUrl = null)
|
public function getFormattedUrl($urlFormat, $uriParams, $baseUrl = null)
|
||||||
{
|
{
|
||||||
$params = $args = array();
|
$params = $args = array();
|
||||||
@ -95,5 +87,6 @@ class Zend_View_Helper_Qlink extends Zend_View_Helper_Abstract
|
|||||||
}
|
}
|
||||||
return is_null($baseUrl) ? $this->view->baseUrl($url) : $baseUrl.$url;
|
return is_null($baseUrl) ? $this->view->baseUrl($url) : $baseUrl.$url;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
// @codingStandardsIgnoreEnd
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user