ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
Border.php
Go to the documentation of this file.
1 <?php
2 
7 {
8 
12  protected $info = array();
13 
14  public function __construct($config) {
15  $def = $config->getCSSDefinition();
16  $this->info['border-width'] = $def->info['border-width'];
17  $this->info['border-style'] = $def->info['border-style'];
18  $this->info['border-top-color'] = $def->info['border-top-color'];
19  }
20 
21  public function validate($string, $config, $context) {
22  $string = $this->parseCDATA($string);
23  $string = $this->mungeRgb($string);
24  $bits = explode(' ', $string);
25  $done = array(); // segments we've finished
26  $ret = ''; // return value
27  foreach ($bits as $bit) {
28  foreach ($this->info as $propname => $validator) {
29  if (isset($done[$propname])) continue;
30  $r = $validator->validate($bit, $config, $context);
31  if ($r !== false) {
32  $ret .= $r . ' ';
33  $done[$propname] = true;
34  break;
35  }
36  }
37  }
38  return rtrim($ret);
39  }
40 
41 }
42 
43 // vim: et sw=4 sts=4
Base class for all validating attribute definitions.
Definition: AttrDef.php:13
validate($string, $config, $context)
Definition: Border.php:21
$info
Local copy of properties this property is shorthand for.
Definition: Border.php:12
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
Definition: AttrDef.php:58
Validates the border property as defined by CSS.
Definition: Border.php:6
mungeRgb($string)
Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work properly.
Definition: AttrDef.php:81
$r