]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - inc/3rdparty/htmlpurifier/HTMLPurifier/ErrorStruct.php
[add] HTML Purifier added to clean code
[github/wallabag/wallabag.git] / inc / 3rdparty / htmlpurifier / HTMLPurifier / ErrorStruct.php
diff --git a/inc/3rdparty/htmlpurifier/HTMLPurifier/ErrorStruct.php b/inc/3rdparty/htmlpurifier/HTMLPurifier/ErrorStruct.php
new file mode 100644 (file)
index 0000000..a6c0da2
--- /dev/null
@@ -0,0 +1,74 @@
+<?php\r
+\r
+/**\r
+ * Records errors for particular segments of an HTML document such as tokens,\r
+ * attributes or CSS properties. They can contain error structs (which apply\r
+ * to components of what they represent), but their main purpose is to hold\r
+ * errors applying to whatever struct is being used.\r
+ */\r
+class HTMLPurifier_ErrorStruct\r
+{\r
+\r
+    /**\r
+     * Possible values for $children first-key. Note that top-level structures\r
+     * are automatically token-level.\r
+     */\r
+    const TOKEN     = 0;\r
+    const ATTR      = 1;\r
+    const CSSPROP   = 2;\r
+\r
+    /**\r
+     * Type of this struct.\r
+     * @type string\r
+     */\r
+    public $type;\r
+\r
+    /**\r
+     * Value of the struct we are recording errors for. There are various\r
+     * values for this:\r
+     *  - TOKEN: Instance of HTMLPurifier_Token\r
+     *  - ATTR: array('attr-name', 'value')\r
+     *  - CSSPROP: array('prop-name', 'value')\r
+     * @type mixed\r
+     */\r
+    public $value;\r
+\r
+    /**\r
+     * Errors registered for this structure.\r
+     * @type array\r
+     */\r
+    public $errors = array();\r
+\r
+    /**\r
+     * Child ErrorStructs that are from this structure. For example, a TOKEN\r
+     * ErrorStruct would contain ATTR ErrorStructs. This is a multi-dimensional\r
+     * array in structure: [TYPE]['identifier']\r
+     * @type array\r
+     */\r
+    public $children = array();\r
+\r
+    /**\r
+     * @param string $type\r
+     * @param string $id\r
+     * @return mixed\r
+     */\r
+    public function getChild($type, $id)\r
+    {\r
+        if (!isset($this->children[$type][$id])) {\r
+            $this->children[$type][$id] = new HTMLPurifier_ErrorStruct();\r
+            $this->children[$type][$id]->type = $type;\r
+        }\r
+        return $this->children[$type][$id];\r
+    }\r
+\r
+    /**\r
+     * @param int $severity\r
+     * @param string $message\r
+     */\r
+    public function addError($severity, $message)\r
+    {\r
+        $this->errors[] = array($severity, $message);\r
+    }\r
+}\r
+\r
+// vim: et sw=4 sts=4\r