XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
LinkTypes.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
13  protected $name;
14 
15  public function __construct($name) {
16  $configLookup = array(
17  'rel' => 'AllowedRel',
18  'rev' => 'AllowedRev'
19  );
20  if (!isset($configLookup[$name])) {
21  trigger_error('Unrecognized attribute name for link '.
22  'relationship.', E_USER_ERROR);
23  return;
24  }
25  $this->name = $configLookup[$name];
26  }
27 
28  public function validate($string, $config, $context) {
29 
30  $allowed = $config->get('Attr.' . $this->name);
31  if (empty($allowed)) return false;
32 
33  $string = $this->parseCDATA($string);
34  $parts = explode(' ', $string);
35 
36  // lookup to prevent duplicates
37  $ret_lookup = array();
38  foreach ($parts as $part) {
39  $part = strtolower(trim($part));
40  if (!isset($allowed[$part])) continue;
41  $ret_lookup[$part] = true;
42  }
43 
44  if (empty($ret_lookup)) return false;
45  $string = implode(' ', array_keys($ret_lookup));
46 
47  return $string;
48 
49  }
50 
51 }
52 
53 // vim: et sw=4 sts=4