Display: Fix error when updating tool icon on the course homepage (introduced in 1.11.20 through security updates) - refs #4809
parent
5018a27e21
commit
14798e4314
@ -0,0 +1,31 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* InternalUrl element (URL without the domain as prefix). |
||||
* |
||||
* Class InternalUrl |
||||
*/ |
||||
class InternalUrl extends HTML_QuickForm_text |
||||
{ |
||||
/** |
||||
* InternalUrl constructor. |
||||
* |
||||
* @param string $elementName |
||||
* @param string $elementLabel |
||||
* @param array $attributes |
||||
*/ |
||||
public function __construct($elementName = null, $elementLabel = null, $attributes = null) |
||||
{ |
||||
if (!isset($attributes['id'])) { |
||||
$attributes['id'] = $elementName; |
||||
} |
||||
|
||||
$attributes['type'] = 'text'; |
||||
$attributes['class'] = 'form-control'; |
||||
|
||||
parent::__construct($elementName, $elementLabel, $attributes); |
||||
|
||||
$this->setType('text'); |
||||
} |
||||
} |
||||
@ -0,0 +1,24 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* Abstract base class for QuickForm validation rules. |
||||
*/ |
||||
|
||||
/** |
||||
* Validate internal urls (URLs without the domain). |
||||
*/ |
||||
class HTML_QuickForm_Rule_InternalUrl extends HTML_QuickForm_Rule |
||||
{ |
||||
/** |
||||
* Validates internal url. |
||||
* We cheat a little by using the adding the domain as prefix to use the domain validation process of filter_var(). |
||||
* |
||||
* @param string $url |
||||
* |
||||
* @return bool returns true if valid, false otherwise |
||||
*/ |
||||
public function validate($url, $options) |
||||
{ |
||||
return (bool) filter_var(api_get_path(WEB_PATH).$url, FILTER_VALIDATE_URL); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue