~ubuntu-branches/ubuntu/jaunty/moodle/jaunty

« back to all changes in this revision

Viewing changes to lib/htmlpurifier/HTMLPurifier/AttrTypes.php

  • Committer: Bazaar Package Importer
  • Author(s): Jordan Mantha, Matt Oquist
  • Date: 2009-02-25 15:16:22 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090225151622-0ekt1liwhv2obfza
Tags: 1.9.4.dfsg-0ubuntu1
* Merge with Debian git (Closes LP: #322961, #239481, #334611):
  - use Ubuntu's smarty lib directory for linking
  - use internal yui library 
  - add update-notifier support back in

[Matt Oquist]
  * renamed prerm script
  * significantly rewrote postinst and other maintainer scripts to improve
    user experience and package maintainability
    (Closes LP: #225662, #325450, #327843, #303078, #234609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
require_once 'HTMLPurifier/AttrDef/Lang.php';
 
4
require_once 'HTMLPurifier/AttrDef/Enum.php';
 
5
require_once 'HTMLPurifier/AttrDef/HTML/Bool.php';
 
6
require_once 'HTMLPurifier/AttrDef/HTML/ID.php';
 
7
require_once 'HTMLPurifier/AttrDef/HTML/Length.php';
 
8
require_once 'HTMLPurifier/AttrDef/HTML/MultiLength.php';
 
9
require_once 'HTMLPurifier/AttrDef/HTML/Nmtokens.php';
 
10
require_once 'HTMLPurifier/AttrDef/HTML/Pixels.php';
 
11
require_once 'HTMLPurifier/AttrDef/HTML/Color.php';
 
12
require_once 'HTMLPurifier/AttrDef/Integer.php';
 
13
require_once 'HTMLPurifier/AttrDef/Text.php';
 
14
require_once 'HTMLPurifier/AttrDef/URI.php';
 
15
 
 
16
/**
 
17
 * Provides lookup array of attribute types to HTMLPurifier_AttrDef objects
 
18
 */
 
19
class HTMLPurifier_AttrTypes
 
20
{
 
21
    /**
 
22
     * Lookup array of attribute string identifiers to concrete implementations
 
23
     * @protected
 
24
     */
 
25
    var $info = array();
 
26
    
 
27
    /**
 
28
     * Constructs the info array, supplying default implementations for attribute
 
29
     * types.
 
30
     */
 
31
    function HTMLPurifier_AttrTypes() {
 
32
        // pseudo-types, must be instantiated via shorthand
 
33
        $this->info['Enum']    = new HTMLPurifier_AttrDef_Enum();
 
34
        $this->info['Bool']    = new HTMLPurifier_AttrDef_HTML_Bool();
 
35
        
 
36
        $this->info['CDATA']    = new HTMLPurifier_AttrDef_Text();
 
37
        $this->info['ID']       = new HTMLPurifier_AttrDef_HTML_ID();
 
38
        $this->info['Length']   = new HTMLPurifier_AttrDef_HTML_Length();
 
39
        $this->info['MultiLength'] = new HTMLPurifier_AttrDef_HTML_MultiLength();
 
40
        $this->info['NMTOKENS'] = new HTMLPurifier_AttrDef_HTML_Nmtokens();
 
41
        $this->info['Pixels']   = new HTMLPurifier_AttrDef_HTML_Pixels();
 
42
        $this->info['Text']     = new HTMLPurifier_AttrDef_Text();
 
43
        $this->info['URI']      = new HTMLPurifier_AttrDef_URI();
 
44
        $this->info['LanguageCode'] = new HTMLPurifier_AttrDef_Lang();
 
45
        $this->info['Color']    = new HTMLPurifier_AttrDef_HTML_Color();
 
46
        
 
47
        // unimplemented aliases
 
48
        $this->info['ContentType'] = new HTMLPurifier_AttrDef_Text();
 
49
        
 
50
        // number is really a positive integer (one or more digits)
 
51
        // FIXME: ^^ not always, see start and value of list items
 
52
        $this->info['Number']   = new HTMLPurifier_AttrDef_Integer(false, false, true);
 
53
    }
 
54
    
 
55
    /**
 
56
     * Retrieves a type
 
57
     * @param $type String type name
 
58
     * @return Object AttrDef for type
 
59
     */
 
60
    function get($type) {
 
61
        
 
62
        // determine if there is any extra info tacked on
 
63
        if (strpos($type, '#') !== false) list($type, $string) = explode('#', $type, 2);
 
64
        else $string = '';
 
65
        
 
66
        if (!isset($this->info[$type])) {
 
67
            trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
 
68
            return;
 
69
        }
 
70
        
 
71
        return $this->info[$type]->make($string);
 
72
        
 
73
    }
 
74
    
 
75
    /**
 
76
     * Sets a new implementation for a type
 
77
     * @param $type String type name
 
78
     * @param $impl Object AttrDef for type
 
79
     */
 
80
    function set($type, $impl) {
 
81
        $this->info[$type] = $impl;
 
82
    }
 
83
}
 
84
 
 
85