1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51:
<?php
class FormFieldConstraintMaxLinks extends AbstractFormFieldConstraint
{
private $number_links_authorized;
private $has_html_content;
public function __construct($number_links_authorized, $has_html_links = false, $error_message = '')
{
$this->number_links_authorized = $number_links_authorized;
$this->has_html_links = $has_html_links;
if (empty($error_message))
{
$error_message = sprintf(LangLoader::get_message('e_l_flood', 'errors'), $this->number_links_authorized);
}
$this->set_validation_error_message($error_message);
}
public function validate(FormField $field)
{
return $this->exceeding_links($field);
}
public function get_js_validation(FormField $field)
{
return '';
}
public function exceeding_links($field)
{
return TextHelper::check_nbr_links($field->get_value(), $this->number_links_authorized, $this->has_html_links);
}
}
?>