ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Multiple.php
Go to the documentation of this file.
1<?php
2
15{
21 public $single;
22
27 public $max;
28
33 public function __construct($single, $max = 4)
34 {
35 $this->single = $single;
36 $this->max = $max;
37 }
38
45 public function validate($string, $config, $context)
46 {
47 $string = $this->mungeRgb($this->parseCDATA($string));
48 if ($string === '') {
49 return false;
50 }
51 $parts = explode(' ', $string); // parseCDATA replaced \r, \t and \n
52 $length = count($parts);
53 $final = '';
54 for ($i = 0, $num = 0; $i < $length && $num < $this->max; $i++) {
55 if (ctype_space($parts[$i])) {
56 continue;
57 }
58 $result = $this->single->validate($parts[$i], $config, $context);
59 if ($result !== false) {
60 $final .= $result . ' ';
61 $num++;
62 }
63 }
64 if ($final === '') {
65 return false;
66 }
67 return rtrim($final);
68 }
69}
70
71// vim: et sw=4 sts=4
$result
An exception for terminatinating execution or to throw for unit testing.
Framework class for strings that involve multiple values.
Definition: Multiple.php:15
__construct($single, $max=4)
Definition: Multiple.php:33
$single
Instance of component definition to defer validation to.
Definition: Multiple.php:21
$max
Max number of values allowed.
Definition: Multiple.php:27
validate($string, $config, $context)
Definition: Multiple.php:45
Base class for all validating attribute definitions.
Definition: AttrDef.php:14
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
Definition: AttrDef.php:60
mungeRgb($string)
Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work properly.
Definition: AttrDef.php:87
$i
Definition: disco.tpl.php:19
$config
Definition: bootstrap.php:15
$context
Definition: webdav.php:25