00001 <?php
00002
00008 class HTMLPurifier_AttrTransform_NameSync extends HTMLPurifier_AttrTransform
00009 {
00010
00011 public function __construct() {
00012 $this->idDef = new HTMLPurifier_AttrDef_HTML_ID();
00013 }
00014
00015 public function transform($attr, $config, $context) {
00016 if (!isset($attr['name'])) return $attr;
00017 $name = $attr['name'];
00018 if (isset($attr['id']) && $attr['id'] === $name) return $attr;
00019 $result = $this->idDef->validate($name, $config, $context);
00020 if ($result === false) unset($attr['name']);
00021 else $attr['name'] = $result;
00022 return $attr;
00023 }
00024
00025 }
00026
00027