Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / lib / htmlpurifier / HTMLPurifier / AttrTransform.php
blob2fa07b47555a018c111c6f782dda40a2cb0af883
1 <?php
3 /**
4 * Processes an entire attribute array for corrections needing multiple values.
5 *
6 * Occasionally, a certain attribute will need to be removed and popped onto
7 * another value. Instead of creating a complex return syntax for
8 * HTMLPurifier_AttrDef, we just pass the whole attribute array to a
9 * specialized object and have that do the special work. That is the
10 * family of HTMLPurifier_AttrTransform.
12 * An attribute transformation can be assigned to run before or after
13 * HTMLPurifier_AttrDef validation. See HTMLPurifier_HTMLDefinition for
14 * more details.
17 class HTMLPurifier_AttrTransform
20 /**
21 * Abstract: makes changes to the attributes dependent on multiple values.
23 * @param $attr Assoc array of attributes, usually from
24 * HTMLPurifier_Token_Tag::$attr
25 * @param $config Mandatory HTMLPurifier_Config object.
26 * @param $context Mandatory HTMLPurifier_Context object
27 * @returns Processed attribute array.
29 function transform($attr, $config, &$context) {
30 trigger_error('Cannot call abstract function', E_USER_ERROR);
33 /**
34 * Prepends CSS properties to the style attribute, creating the
35 * attribute if it doesn't exist.
36 * @param $attr Attribute array to process (passed by reference)
37 * @param $css CSS to prepend
39 function prependCSS(&$attr, $css) {
40 $attr['style'] = isset($attr['style']) ? $attr['style'] : '';
41 $attr['style'] = $css . $attr['style'];
44 /**
45 * Retrieves and removes an attribute
46 * @param $attr Attribute array to process (passed by reference)
47 * @param $key Key of attribute to confiscate
49 function confiscateAttr(&$attr, $key) {
50 if (!isset($attr[$key])) return null;
51 $value = $attr[$key];
52 unset($attr[$key]);
53 return $value;