]> git.wh0rd.org Git - tt-rss.git/commitdiff
add tagwall
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 19 May 2007 07:34:02 +0000 (08:34 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 19 May 2007 07:34:02 +0000 (08:34 +0100)
15 files changed:
tw/error/FOO_error.php [new file with mode: 0644]
tw/error/LINK_error.php [new file with mode: 0644]
tw/error/__Template_error.php [new file with mode: 0644]
tw/filter-setup/paranoya.php [new file with mode: 0644]
tw/lang/TW_base.php [new file with mode: 0644]
tw/lang/TW_lang.php [new file with mode: 0644]
tw/localization/EN_errors.php [new file with mode: 0644]
tw/output/HL_DEBUG_output.php [new file with mode: 0644]
tw/output/HTML_output.php [new file with mode: 0644]
tw/output/XHTML_output.php [new file with mode: 0644]
tw/tw-config.php [new file with mode: 0644]
tw/tw-errors.php [new file with mode: 0644]
tw/tw-tags.php [new file with mode: 0644]
tw/tw.php [new file with mode: 0644]
tw/tw_cache/TW_lang.php [new file with mode: 0644]

diff --git a/tw/error/FOO_error.php b/tw/error/FOO_error.php
new file mode 100644 (file)
index 0000000..3924768
--- /dev/null
@@ -0,0 +1,43 @@
+<?\r
+/*\r
+ * tag|wall                                            | PHP Tag Filter|\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  www.designia.sk\r
+   \r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * tag|wall error module \r
+ *\r
+ * description:\r
+ * - this is default error module.\r
+ */\r
+class FOO_error extends TW_errors\r
+{\r
+       function FOO_error($options = 0)\r
+       {\r
+               $this->TW_errors($options);\r
+       }\r
+       \r
+       function add($errval, $position, $show_code, $param1=null, $param2=null )\r
+       {\r
+               $this->ErrorArray["TW_err_".$this->identifier++] = array($errval, $param1, $param2, $position, $show_code);\r
+               if($errval & 0xff00) $this->IsError = 1;\r
+               return null;\r
+       }\r
+}\r
+?>
\ No newline at end of file
diff --git a/tw/error/LINK_error.php b/tw/error/LINK_error.php
new file mode 100644 (file)
index 0000000..580e15f
--- /dev/null
@@ -0,0 +1,94 @@
+<?\r
+/*\r
+ * tag|wall                                            | PHP Tag Filter|\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  www.designia.sk\r
+   \r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * tag|wall error module\r
+ *\r
+ * description:\r
+ * - this module appending automatic links and colored piece of bad code.\r
+ *\r
+ * - Module using following CSS classes (you must define it in your CSS stylesheet)\r
+ *\r
+ *   .tw-err-int       - internal error        (in output string)\r
+ *   .tw-err-err       - standard error\r
+ *   .tw-err-war       - warning\r
+ *   .tw-err-com       - comment\r
+ *\r
+ *   .tw-err-int-l     - internal error        (in error list)\r
+ *   .tw-err-err-l     - standard error\r
+ *   .tw-err-war-l     - warning\r
+ *   .tw-err-com-l     - comment\r
+\r
+ */\r
+class LINK_error extends TW_errors\r
+{\r
+       function LINK_error($options = 0)\r
+       {\r
+               $this->TW_errors($options);\r
+       }\r
+       \r
+       function add($errval, $position, $show_code, $param1=null, $param2=null )\r
+       {\r
+               $err_id = "TW_err_".$this->identifier++;\r
+               $this->ErrorArray[$err_id] = array($errval, $param1, $param2, $position, $show_code);\r
+               if($errval & 0xff00) $this->IsError = 1;\r
+               \r
+               // append errors and warnings\r
+               if(($errval & 0x0ff0) && $show_code != null )\r
+                       return  '<a name="'.$err_id.'"><span class="'.$this->get_error_class($errval).'">'.$show_code.'</span></a>';\r
+               \r
+               return null;\r
+       }\r
+       \r
+       // You can call this method from your project and create nice list of errors.\r
+       //\r
+       //   $lang - error string pack\r
+       //   $mask - any combination of following masks:\r
+       //              0xf000 - internal, \r
+       //              0x0f00 - errors, \r
+       //              0x00f0 - warnings, \r
+       //              0x000f - comments\r
+       //\r
+       function create_list (&$lang, $mask = 0x0ff0)\r
+       {\r
+               $errors = $this->get_by_mask($mask);\r
+               \r
+               $out = "<ul>";\r
+               foreach($errors as $key => $value)\r
+               {\r
+                       $errno = $value[TWE_ERRNO];\r
+                       $piece = '<span class="'.$this->get_error_class($errno).'">'.$value[TWE_CODE].'</span>';\r
+                       $list ='<a href="#'.$key.'">'.$this->get_error_text($key,$lang).$piece.'</a>';\r
+                       $out .= '<li class="'.$this->get_error_class($errno).'-l">'.$list.'</li>';\r
+               }               \r
+               return $out."</ul>";\r
+       }\r
+       \r
+       function get_error_class ($error)\r
+       {\r
+               if($error&0xf000) return "tw-err-int";\r
+               if($error&0x0f00) return "tw-err-err";\r
+               if($error&0x00f0) return "tw-err-war";\r
+               return "tw-err-com";\r
+       }\r
+}\r
+?>
\ No newline at end of file
diff --git a/tw/error/__Template_error.php b/tw/error/__Template_error.php
new file mode 100644 (file)
index 0000000..194f4a2
--- /dev/null
@@ -0,0 +1,69 @@
+<?\r
+/*\r
+ * tag|wall ver 0.1.0                                  | PHP Tag Filter|\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  www.designia.sk\r
+   \r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * tag|wall error module \r
+ *\r
+ * description:\r
+ * - TODO: add module description\r
+ *\r
+ * output modifications:\r
+ * - TODO: add your output modifications here\r
+ */\r
+class ???_error extends TW_errors\r
+{\r
+       // TODO: add module depended variables here\r
+       \r
+       // Class constructor\r
+       // NOTE: parser calling this with his options. See twParser constructor.\r
+       //\r
+       function ???_error($options = 0)\r
+       {\r
+               // call parent class constructor\r
+               $this->TW_errors($options);\r
+               \r
+               // TODO: add your own module initializations here\r
+       }\r
+       \r
+       // You must implement your own add method.\r
+       \r
+       function add($errval, $position, $show_code, $param1=null, $param2=null )\r
+       {\r
+               $err_id = "TW_err_".$this->identifier++;\r
+               //\r
+               // This is basic error implementation. Modify this code only if you really need it.\r
+               // \r
+               $this->ErrorArray[$err_id] = array($errval, $param1, $param2, $position, $show_code);\r
+               if($errval & 0xff00) $this->IsError = 1;\r
+\r
+               // TODO: create your output additions here, and return it as string\r
+\r
+               return null;\r
+       }\r
+       \r
+       // TODO:\r
+       // You can implement ohther methods here. \r
+       // For example: special error filters, post-parsing functions for generating \r
+       // error lists, etc...\r
+\r
+}\r
+?>
\ No newline at end of file
diff --git a/tw/filter-setup/paranoya.php b/tw/filter-setup/paranoya.php
new file mode 100644 (file)
index 0000000..0795c77
--- /dev/null
@@ -0,0 +1,59 @@
+<?\r
+       // WARNING:\r
+       //\r
+       // All tags used in configuration must be defined in tw/tw-tags.php file too.\r
+       //\r
+\r
+       $tw_paranoya_setup = array(\r
+               \r
+               "a"             =>      array(\r
+                                               "href"  => array( TW_RQ_URL ),          // value is required url \r
+                                               "name"  => array( TW_RQ_LINK ),         // value is link (link+href combination must be fixed in base)\r
+                                               "title" => null,\r
+                                               ),\r
+                                               \r
+               "hr"    =>      null,   // without attributes\r
+               "br"    =>      null,\r
+               "img"   =>      array(\r
+                                               "width" => array( TW_NUM, 80, 60, 120 ),        // 80 - default, number must be in range <60,120>\r
+                                               "height"=> array( TW_NUM, 80, 60, 120 ),\r
+                                               "src"   => array( TW_RQ_URL ),\r
+                                               "title" => null,\r
+                                               "border"=> array( TW_RQ_NUM,  0,  0,  0),\r
+                                               ),\r
+\r
+               "p"             =>      array(\r
+                                               // null - default value (null = remove attr if value not found in case array)\r
+                                               "class" => array( TW_CASE, null, array("par1","par2","par3") ),\r
+                                               ),\r
+                                               \r
+               "b"             =>      "strong",               // tag substitution <b> -> <strong>\r
+               "strong"        =>      null,                   // new tag must be configured too\r
+               "i"             =>      null,\r
+               "u"             =>      null,\r
+               "div"   =>      array(\r
+                                               "title" => null,\r
+                                               ),\r
+               \r
+               "span"  =>      array(\r
+                                               "class" => array( TW_CASE, null, array("my-class1","my-class2","my-class3") ),\r
+                                               ),\r
+                                               \r
+               "blockquote"    =>      null,\r
+               "h1"    =>      null,\r
+               "h2"    =>      null,\r
+               "h3"    =>      null,\r
+               \r
+               "table" =>      null,\r
+               "td"    =>      null,\r
+               "tr"    =>      null,\r
+               "th"    =>      null,\r
+               \r
+               "ul"    =>      null,\r
+               "ol"    =>      null,\r
+               "li"    =>      null,\r
+               "dl"    =>      null,\r
+               "dt"    =>      null,\r
+               "dd"    =>      null,\r
+       );\r
+?>
\ No newline at end of file
diff --git a/tw/lang/TW_base.php b/tw/lang/TW_base.php
new file mode 100644 (file)
index 0000000..ae84d6e
--- /dev/null
@@ -0,0 +1,471 @@
+<?\r
+/*\r
+ * tag|wall                                           | PHP Tag Filter |\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  www.designia.sk\r
+   \r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ */\r
+\r
+/*\r
+ * $this->pt   text\r
+ * $this->pti  text index\r
+ */\r
+class TW_base          // TW_lang extends this class\r
+{\r
+       var $error;             // error module object\r
+       var $output;    // output module object\r
+       var $out;               // output string\r
+       \r
+       var $content_off;\r
+       \r
+       var $tags;                      // relationships between tags\r
+       var $config;            // current configuration        (twParser::strip_tags())\r
+       var $config_tags;       // tags in current configuration\r
+       var $config_attr;       // attributes in current configuration\r
+       var $config_req_attr;   // required attributes\r
+               \r
+\r
+       var $TAG;\r
+       var $is_attributes;\r
+       var $ATTRIBUTES;                // index => array("atr","value")\r
+       var $ATTR;                              // array(atr,value)\r
+       var $VALUE;\r
+       \r
+/********************************************************************************************\r
+ * BASE CONSTRUCTOR \r
+ */\r
+       function TW_base()\r
+       {\r
+               global $tw_tag_relations;\r
+               \r
+               $this->stack();\r
+               $this->tags = &$tw_tag_relations;\r
+               $this->content_off = 0;\r
+       }\r
+/*\r
+ * BASE "DESTRUCTOR" (parser call this function if end of string is rached)\r
+ */\r
+       function base_end()\r
+       {\r
+               while( $tag = $this->stack_pop() )\r
+               {\r
+                       $this->out .= $this->output->close( $tag );\r
+               }\r
+               return null;\r
+       }\r
+\r
+\r
+/********************************************************************************************\r
+ * TAG STACK implementation\r
+ */\r
+       var $Tstack;\r
+\r
+       function stack()                                {       $this->Tstack[0] = null;        }\r
+       function stack_push( $tag )             {       array_unshift( $this->Tstack, $tag );   }\r
+       function stack_pop()                    {       return array_shift( $this->Tstack );    }\r
+       function stack_search( $tag )   {       return in_array( $tag, $this->Tstack ); }\r
+\r
+       function stack_top( $tag = null )\r
+       {\r
+               if( $tag )      return $this->Tstack[0] == $tag;\r
+               return $this->Tstack[0];\r
+       }\r
+\r
+\r
+\r
+\r
+/********************************************************************************************\r
+ *     S T A R T _ T A G _ f i l t e r                 <tag atr=value>\r
+ *\r
+ */    \r
+       \r
+       function START_TAG_filter()\r
+       {\r
+               $tag = $this->TAG;\r
+               if( $tag == null )\r
+               {\r
+                       //###### syntax error\r
+                       return;\r
+               }\r
+               if( in_array($tag,$this->config_tags) )\r
+               {\r
+                       //enabled tag\r
+\r
+                       if(is_string($this->config_attr[$tag]))\r
+                       {\r
+                               $this->TAG = $tag = $this->config_attr[$tag];\r
+                               //tag substitution warning\r
+                       }\r
+                       \r
+                       // ------- perform attribute check -----------\r
+                       \r
+                       if($this->is_attributes)\r
+                       {\r
+                               if(!$this->config_attr[$tag])\r
+                               {\r
+                                       $this->ATTRIBUTES = null;\r
+                                       // remove attribute warning\r
+                               }\r
+                               else\r
+                               {\r
+                                       foreach( $this->ATTRIBUTES as $key => $attr )\r
+                                       {\r
+                                               if( ! in_array($attr[0], $this->config_attr[$tag] ) )\r
+                                               {\r
+                                                       $this->ATTRIBUTES[$key][1] = null;\r
+                                                       // remove attribute warning\r
+                                                       continue;\r
+                                               }\r
+                                               \r
+                                               // --------- perform value check -----------\r
+                                               \r
+                                               if(($val = $attr[1])==null) continue;\r
+                                               if(($cmda = &$this->config[$tag][$attr[0]])==null) continue; //null - accept all values\r
+                                               switch($cmda[0] & 7)\r
+                                               {\r
+                                                       case TW_URL:\r
+                                                               // V0.1.2: fixed some fatal bugs, big thanx to fczbkk
+                                                               //
+                                                               // TODO: make better url check with parse_url()
+                                                               \r
+                                                               $val = strtolower($val);\r
+                                                               if(strpos($val, "http://") === false)\r
+                                                               {\r
+                                                                       if(strpos($val, "ftp://") === false)\r
+                                                                           if(strpos($val, "email:") === false)
+                                                                               if(strpos($val, "https://") === false)
+                                                                                   if(strpos($val, "./") === false)    // local relative url
+                                                                                       $val = "http://".$val;\r
+                                                               }\r
+                                                               $this->ATTRIBUTES[$key][1] = $val;\r
+                                                               break;\r
+                                                       \r
+                                                       case TW_LINK:\r
+                                                               //TODO: add link separator check here.\r
+                                                               //      Do not use this attribute in config!
+                                                               break;\r
+                                                       \r
+                                                       case TW_NUM:\r
+                                                               if( $val >= $cmda[2] && $val <= $cmda[3] ) break;\r
+                                                               $this->ATTRIBUTES[$key][1] = $cmda[1];\r
+                                                               break;\r
+                                                       \r
+                                                       case TW_CASE:\r
+                                                               if( !in_array($val, $cmda[2]) ) $this->ATTRIBUTES[$key][1] = $cmda[1];\r
+                                                               break;\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+                       // check required attributes\r
+                       if($this->config_req_attr[$tag])\r
+                       {\r
+                               if( $this->is_attributes )\r
+                                       foreach( $this->config_req_attr[$tag] as $required )\r
+                                       {\r
+                                               $req_found = 0;\r
+                                               foreach( $this->ATTRIBUTES as $val)\r
+                                                       if( $val[0] == $required )\r
+                                                       {\r
+                                                               $req_found = 1;\r
+                                                               break;\r
+                                                       }\r
+                                               if($req_found) continue;\r
+                                               \r
+                                               switch( $this->config[$tag][$required][0] & 7 )\r
+                                               {\r
+                                                       case TW_LINK:\r
+                                                       case TW_URL:\r
+                                                               // error\r
+                                                               break;\r
+                                                       \r
+                                                       default:\r
+                                                               $this->ATTRIBUTES[$required] = array($required, $this->config[$tag][$required][1]);\r
+                                                               break;\r
+                                               }\r
+                                       }\r
+                               else\r
+                               {\r
+                                       foreach( $this->config_req_attr[$tag] as $required )\r
+                                       {\r
+                                               switch( $this->config[$tag][$required][0] & 7 )\r
+                                               {\r
+                                                       case TW_LINK:\r
+                                                       case TW_URL:\r
+                                                               \r
+                                                               // required tag error\r
+                                                               \r
+                                                               break;\r
+                                                       \r
+                                                       default:\r
+                                                               $this->ATTRIBUTES[$required] = array($required, $this->config[$tag][$required][1]);\r
+                                                               break;\r
+                                               }                                               \r
+                                       }\r
+                               }\r
+                                       \r
+                       }                       \r
+                       // cross tag removal algorithm\r
+                       \r
+                       $flag = $this->tags[$tag];\r
+                       $top = $this->stack_top();\r
+                       \r
+                       if( $flag[2] != null )          // check if tag before is specified\r
+                       {\r
+                               // yes, tag before is specified, check relationship\r
+                               if(! in_array($top, $flag[2]) )\r
+                               {\r
+                                       if( $flag[0] & TW_OPT ) \r
+                                       {\r
+                                               if( $top == $tag )\r
+                                               {\r
+                                                       // End Tag is optional and current tag is the same as last tag (on stack).\r
+                                                       // Close previos for XHTML compatibility and open new the same tag.\r
+                                                       // Return, because no manipulation with stack is required.\r
+                                                       $this->out .= $this->output->close( $tag );\r
+                                                       $this->out .= $this->output->pair( $tag, $this->ATTRIBUTES );\r
+                                                       return;\r
+                                               }\r
+                                               if( $this->stack_search($tag) )\r
+                                               {\r
+                                                       // repair stack\r
+                                                       while(($top = $this->stack_pop() ) != $tag )\r
+                                                       {\r
+                                                               /*if( !($this->tags[$top][0] & TW_OPT ) )\r
+                                                               {\r
+                                                                       // auto close warning\r
+                                                               }*/\r
+                                                               $this->out .= $this->output->close( $top );\r
+                                                       }\r
+                                                       $this->stack_push($tag);\r
+                                                       $this->out .= $this->output->close( $tag );\r
+                                                       $this->out .= $this->output->pair( $tag, $this->ATTRIBUTES );\r
+                                                       return;\r
+                                               }\r
+                                       }\r
+                                       // <th>...<td>  =>> <th>...</th><td>... (<th> & <td> they have common parent tag (<tr>) )\r
+                                       if( $this->tags[$top][0] & TW_OPT )\r
+                                       {\r
+                                               if( $this->tags[$top][2] == $flag[2] )\r
+                                               {\r
+                                                       $this->out .= $this->output->close( $this->stack_pop() );\r
+                                                       $this->out .= $this->output->pair( $tag, $this->ATTRIBUTES );\r
+                                                       $this->stack_push( $tag );\r
+                                                       return;\r
+                                               }\r
+                                       }\r
+                                       // invalid relation between tags #######\r
+                                       return;\r
+                               }\r
+                               // valid relationship\r
+                       }\r
+                       if( $flag[0] & TW_NOP )\r
+                       {\r
+                               //tag without End Tag <br />\r
+                               $this->out .= $this->output->single( $tag, $this->ATTRIBUTES );\r
+                       }\r
+                       else\r
+                       {\r
+                               //Tag with End Tag, push to stack\r
+                               if( ($top == $tag) && ($flag[0] & TW_OPT) )\r
+                               {\r
+                                       // '<p><p>' => '<p></p><p>'\r
+                                       $this->out .= $this->output->close( $tag );\r
+                                       $this->out .= $this->output->pair( $tag, $this->ATTRIBUTES );\r
+                                       return;\r
+                               }\r
+                               $this->out .= $this->output->pair( $tag, $this->ATTRIBUTES );\r
+                               $this->stack_push( $tag );\r
+                       }\r
+                       return;\r
+               }\r
+               else\r
+               {\r
+                       //disabled tag (or not supported) ######\r
+                       return;\r
+               }\r
+       }\r
+       \r
+/********************************************************************************************\r
+ *     E N D _ T A G _ f i l t e r                             </tag>  \r
+ *\r
+ */\r
+       function END_TAG_filter()\r
+       {\r
+               $tag = $this->TAG;\r
+               if( $tag == null ) \r
+               {\r
+                       // </>\r
+                       if ($tag = $this->stack_pop() )\r
+                       {\r
+                               $this->out .= $this->output->close($tag);\r
+                               return;\r
+                       }\r
+                       else\r
+                       {\r
+                               // kunda underflow :)\r
+                               return;\r
+                       }\r
+               }\r
+               if(in_array($tag,$this->config_tags))\r
+               {\r
+                       // enabled tag\r
+                       if(is_string($this->config_attr[$tag]))\r
+                       {\r
+                               $this->TAG = $tag = $this->config_attr[$tag];\r
+                               //tag substitution warning\r
+                       }\r
+\r
+                       $top = $this->stack_top( $tag );\r
+                       if( $top )\r
+                       {\r
+                               $this->out .= $this->output->close( $tag );\r
+                               $this->stack_pop();\r
+                               return;\r
+                       }\r
+                       \r
+                       if( $this->stack_search($tag) )\r
+                       {\r
+                               // closing cross tags\r
+                               while( ($top = $this->stack_pop()) != $tag )\r
+                               {\r
+                                       /*if( !($this->tags[$top][0] & TW_OPT ) )\r
+                                       {\r
+                                               // auto close warning\r
+                                       }*/\r
+                                       $this->out .= $this->output->close( $top );\r
+                               }\r
+                               $this->out .= $this->output->close( $tag );\r
+                       }\r
+                       else\r
+                       {\r
+                               // ###### cross tag error\r
+                               return;\r
+                       }\r
+               }\r
+               // drop out warning             \r
+       }\r
+\r
+\r
+/*\r
+ * THERE ARE STATE IN, OUT & NEW FUNCTIONS\r
+ *\r
+ */\r
\r
+/********************************************************************************************\r
+ * STATE T_begin       '<'\r
+ */\r
+       function T_begin_in()\r
+       {\r
+               $this->tag_position = $this->pti;\r
+               $this->TAG = null;\r
+       }\r
+\r
+       // --- MAIN TAG-FILTER FUNCTION ---\r
+\r
+       function T_begin_out($word)\r
+       {\r
+               $this->START_TAG_filter();\r
+       }\r
+\r
+/********************************************************************************************\r
+ * STATE TC_begin      '</'\r
+ */\r
+       function T_Cbegin_in()\r
+       {\r
+               $this->tag_position = $this->pti;\r
+               $this->TAG = null;\r
+       }\r
+\r
+       // TAG CLOSE function\r
+       //\r
+       function T_Cbegin_out($word)\r
+       {\r
+               $this->END_TAG_filter();\r
+       }\r
+\r
+/********************************************************************************************\r
+ * STATE T_gettag      'tagname'\r
+ */\r
+       function T_gettag_in() \r
+       {\r
+               $this->is_attributes = 0;\r
+               $this->ATTRIBUTES = null;\r
+               return;\r
+       }\r
+\r
+       function T_gettag_new($word)    {       $this->TAG = strtolower($word); }       \r
+       function T_gettag_out($word)    { return; }\r
+\r
+/********************************************************************************************\r
+ * STATE A_begin       '__atr...'\r
+ */\r
+       function A_begin_in()   {               $this->ATTR = null;     }\r
+       function A_begin_new($word)     {       $this->ATTR[0] = strtolower($word);     }\r
+       function A_begin_out($word)\r
+       {\r
+               if( $this->is_attributes )\r
+               {\r
+                       foreach( $this->ATTRIBUTES as $akey => $aval )
+                       {
+                           if($this->ATTR[0] == $aval[0])
+                           {
+                               // duplicate warning
+                               $this->ATTRIBUTES[$akey] = $aval;
+                               return;
+                           }
+                       }
+               }\r
+               else\r
+               {\r
+                       $this->is_attributes = 1;\r
+               }\r
+               $this->ATTRIBUTES[] = $this->ATTR;\r
+       }\r
+\r
+/********************************************************************************************\r
+ * STATE V_begin       'atr...'\r
+ */\r
+       function V_begin_in()   {               $this->VALUE = null;    }\r
+       function V_begin_out($word)     {       $this->ATTR[1] = $this->VALUE;  }\r
+\r
+/********************************************************************************************\r
+ * STATE VALUE1\r
+ */\r
+       function VALUE1_in() { return; }\r
+       function VALUE1_out($word) { $this->VALUE = substr($word,0,strlen($word)-1); }\r
+\r
+/********************************************************************************************\r
+ * STATE VALUE2\r
+ */\r
+       function VALUE2_in() { return; }\r
+       function VALUE2_out($word) \r
+       {\r
+               $this->VALUE = str_replace("\"", "&#34", substr($word, 0, strlen($word)-1) );\r
+       }\r
+/********************************************************************************************\r
+ * STATE VALUE3\r
+ */\r
+       function VALUE3_in() { return; }\r
+       function VALUE3_out($word) { $this->VALUE = $word; }\r
+       \r
+       \r
+} // END class TW_base\r
+?>
\ No newline at end of file
diff --git a/tw/lang/TW_lang.php b/tw/lang/TW_lang.php
new file mode 100644 (file)
index 0000000..2c96221
--- /dev/null
@@ -0,0 +1,183 @@
+<?\r
+/*\r
+ * tag|wall                                           | PHP Tag Filter |\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  www.designia.sk\r
+   \r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * TW - based on SHL Language File\r
+ * \r
+ * Spolocne so SHL\r
+ * - kompatibilita s FSHL generatorom 0.4.x\r
+ * - zakladna kostra stavoveho diagramu je spolocna\r
+ *\r
+ * Rozdiely voci SHL\r
+ * - polia maju iny vyznam pretoze spracuva iny stavovy automat\r
+ * - vsetky stavy sa volaju rekurentne\r
+ *\r
+ * function STATE_in()  - vola sa pri vstupe do stavu (Ovplyvnuje flag PF_XIO)\r
+ * function STATE_out() - vola sa pri opusteni stavu (_RET) (Ovplyvnuje flag PF_XIO)\r
+ *                        tiez hned po navrate z rekurzie flag PF_XDONE sposobi zavolanie\r
+ *                        STATE_out() a opustenie aktualneho stavu (simulovany _RET)\r
+ * function STATE_new() - vola sa pri zmene stavu (Ovplyvnuje flag PF_XNEW)\r
+ */ \r
+class TW_lang\r
+{\r
+       var $states;\r
+       var $initial_state;\r
+       var $keywords;\r
+       var $version;\r
+       var $signature;\r
+\r
+       function TW_lang()\r
+       {\r
+               $this->signature = "TW";\r
+               $this->version = "1.0";\r
+               $this->initial_state="OUT";\r
+               $this->states = \r
+               array\r
+               (\r
+               "OUT" => array (\r
+                               array(\r
+                                               "<"             => array("T_tagWall",0),\r
+                                               \r
+                                               //"&"           => array("VChar",0),            // validate char (currently not implemented in base)                                            \r
+                                               ),\r
+\r
+                               PF_CLEAN,               // PF_CLEAN - znaky sa forwarduju na vystup\r
+                               0,0\r
+                               ),\r
+\r
+               "T_tagWall" => array (\r
+                               array(\r
+                                               "ALPHA" => array("T_begin",1),          // normal tag\r
+                                               "/"             => array("T_Cbegin",0),         // close tag\r
+                                               "<"             => array("T_tagWall",1),        // '<<<<<<<<' fix (faster than _RET)\r
+                                               "!--"   => array("HTML_comment",0),\r
+                                               "_ALL"  => array("_RET",0),                     // '<?' other fixes\r
+                                               ),\r
+                       \r
+                               PF_XDONE,\r
+                               0,0\r
+                               ),\r
+\r
+\r
+               "T_Cbegin" => array (\r
+                               array(\r
+                                               "ALPHA" => array("T_gettag",1),\r
+                                               "_ALL"  => array("_RET",0),\r
+                                               ),\r
+                               PF_XIO | PF_XDONE,                                              0,0\r
+                               ),\r
+\r
+\r
+               "T_begin" => array (\r
+                               array(\r
+                                               "ALPHA" => array("T_gettag",1),\r
+                                               "_ALL"  => array("_RET",0),\r
+                                               ),\r
+                               \r
+                               PF_XIO | PF_XDONE,                                              0,0\r
+                               ),\r
+\r
+                       \r
+               "T_gettag" => array (\r
+                               array(\r
+                                               "!ALNUM"=> array("T_in",1),\r
+                                               ),\r
+                                               \r
+                               PF_XIO | PF_XDONE | PF_XNEW,                    0,0\r
+                               ),\r
+\r
+\r
+               "T_in" => array(\r
+                               array(\r
+                                               "ALPHA" => array("A_begin",1),  // char back to stream\r
+                                               ">"             => array("_RET",0),\r
+                                               "/>"    => array("_RET",0),             // pozor na spracovanie v T_begin\r
+                                               ),\r
+                               \r
+                               0,0,0\r
+                               ),\r
+\r
+               "A_begin" => array (\r
+                               array(\r
+                                               "!ALPHA"=> array("V_begin",1),\r
+                                               ">"             => array("_RET",1),             // vracia string do streamu\r
+                                               "/>"    => array("_RET",1),             // pozor na spracovanie v TAGbegin\r
+                                               ),\r
+                               \r
+                               PF_XIO | PF_XDONE | PF_XNEW ,                   0,0\r
+                               ),\r
+\r
+               // this is wide attribute=value implementation\r
+               "V_begin" => array (\r
+                               array(\r
+                                               '"'             => array("VALUE1",0),\r
+                                               "'"             => array("VALUE2",0),\r
+                                               "ALNUM" => array("VALUE3",1),\r
+\r
+                                               ">"             => array("_RET",1),\r
+                                               "/>"    => array("_RET",1),\r
+                                               ),\r
+\r
+                               PF_XIO | PF_XDONE,                                              0,0\r
+                               ),\r
+                       \r
+               // "DOUBLEQUOTED VALUE"\r
+               "VALUE1" => array(\r
+                               array(\r
+                                               '"'             => array("_RET",0),\r
+                                               ),\r
+                               PF_XIO,                                                                 0,0\r
+                               ),\r
+\r
+               // 'SINGLEQUOTED VALUE'\r
+               "VALUE2" => array(\r
+                               array(\r
+                                               "'"             => array("_RET",0),\r
+                                               ),\r
+                               PF_XIO,                                                                 0,0\r
+                               ),\r
+\r
+               // UNQUOTEDVALUE99\r
+               "VALUE3" => array(\r
+                               array(\r
+/*                                             "_" => array ("VALUE3",0),      //Uncomment for better HTML4 compatibility (not recommended)\r
+                                               "." => array ("VALUE3",0), \r
+*/\r
+                                               "-" => array ("VALUE3",0),\r
+                                               "!ALNUM"=> array("_RET",1),\r
+                                               ),\r
+                               PF_XIO,                                                                 0,0\r
+                               ),\r
+\r
+               // all comment content will be removed\r
+               "HTML_comment" => array(\r
+                               array(\r
+                                               "-->"   => array("_RET",0),\r
+                                               ),\r
+                               0,0,0\r
+                               ),\r
+               );\r
+               \r
+               $this->keywords=null;\r
+       }\r
+}\r
+?>
\ No newline at end of file
diff --git a/tw/localization/EN_errors.php b/tw/localization/EN_errors.php
new file mode 100644 (file)
index 0000000..7e7a0a8
--- /dev/null
@@ -0,0 +1,57 @@
+<?\r
+/*\r
+ * tag|wall                                            | PHP Tag Filter|\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  www.designia.sk\r
+   \r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * tag|wall    error strings\r
+ *\r
+ * NOTE:\r
+ * TW not using this file directly. You can include it to your project\r
+ * at your opinion. Then you can use method TW_errors::get_error_text()\r
+ * for getting error texts. \r
+ *\r
+ * Please correct my stupid english :)\r
+ */\r
+$tw_error_strings = array(\r
+       \r
+       // comments     & tips\r
+       TWE_OK                                  => null,\r
+       TWE_VERSION                             => "Versions: parser V %s, language V%s",\r
+       TWE_CREDITS                             => "tag|wall: code Juraj Durech (hvge@cauldron.sk).",\r
+       TWE_NOTE                                => "%s",\r
+       \r
+       // warnings\r
+       TWE_STACK_UNDERFLOW             => "Stack underflow, tag '%s' was dropped out.",\r
+       TWE_STACK_NOT_EMPTY             => "There are some unclosed tags on stack.",\r
+       TWE_UNEXPECTED_EOST             => "Unexpected end of stream.",\r
+       TWE_UNEXPECTED_QUOTE    => "Unexpected quote.",\r
+       \r
+       // errors\r
+       TWE_SYNTAX                              => "HTML syntax error.",\r
+       TWE_TOO_MANY_ATTRS              => "Too many attributes in tag '%s'.",\r
+       \r
+       // internal errors\r
+       TWE_FILE_NOT_FOUND              => "File '%s' not found.",\r
+       TWE_BAD_SIGNATURE               => "Language '%s' have bad signature '%s'.",\r
+       TWE_LANG_NOT_FOUND              => "Language '%s' not found.",\r
+       \r
+       );\r
+?>
\ No newline at end of file
diff --git a/tw/output/HL_DEBUG_output.php b/tw/output/HL_DEBUG_output.php
new file mode 100644 (file)
index 0000000..4a2521b
--- /dev/null
@@ -0,0 +1,74 @@
+<?php\r
+/*\r
+ * tag|wall                                           | PHP Tag Filter |\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  designia.sk\r
+\r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * HL_DEBUG_output.php         xhtml debug output module (highlight tags)\r
+ */\r
+\r
+class HL_DEBUG_output\r
+{\r
+       function HL_DEBUG_output() { return;    }\r
+       \r
+       // input: string, array()\r
+       \r
+       function pair ($tag, &$attributes)\r
+       {\r
+               if($attributes == null)\r
+                       return $this->highlight( "<$tag>" );\r
+               $attr = null;\r
+               foreach ($attributes as $value)\r
+               {\r
+                       if($value[1])   $attr .= ' '.$value[0].'="'.$value[1].'"';\r
+               }\r
+               return $this->highlight( "<$tag$attr>" );\r
+       }\r
+       \r
+       function single ($tag, &$attributes)\r
+       {\r
+               if($attributes == null)\r
+                       return $this->highlight( "<$tag />" );\r
+               $attr = null;\r
+               foreach ($attributes as $value)\r
+               {\r
+                       if($value[1])   $attr .= $value[0].'="'.$value[1].'" ';\r
+               }\r
+               return $this->highlight( "<$tag $attr/>" );\r
+       }\r
+       \r
+       // template for end tags\r
+       function close ($tag) \r
+       {\r
+               return $this->highlight( "</$tag>" );\r
+       }\r
+\r
+       function template_end() { return null;  }\r
+\r
+       \r
+       function highlight($string)\r
+       {\r
+               $string = str_replace("&","&amp",$string);\r
+               return '<span style="background-color:yellow">'.str_replace("<","&lt;",$string).'</span>';\r
+       }\r
+       \r
+} //END class HTML_output\r
+\r
+?>
\ No newline at end of file
diff --git a/tw/output/HTML_output.php b/tw/output/HTML_output.php
new file mode 100644 (file)
index 0000000..3df2fef
--- /dev/null
@@ -0,0 +1,67 @@
+<?php\r
+/*\r
+ * tag|wall                                           | PHP Tag Filter |\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  designia.sk\r
+\r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * HTML_output.php             html output module\r
+ */\r
+\r
+class HTML_output\r
+{\r
+       function HTML_output() { return;        }\r
+       \r
+       // input: string, array()\r
+       \r
+       function pair ($tag, &$attributes)\r
+       {\r
+               if($attributes == null)\r
+                       return "<$tag>";\r
+               $attr = null;\r
+               foreach ($attributes as $value)\r
+               {\r
+                       if($value[1])   $attr .= ' '.$value[0].'="'.$value[1].'"';\r
+               }\r
+               return "<$tag$attr>";\r
+       }\r
+       \r
+       function single ($tag, &$attributes)\r
+       {\r
+               if($attributes == null)\r
+                       return "<$tag>";\r
+               $attr = null;\r
+               foreach ($attributes as $value)\r
+               {\r
+                       if($value[1])   $attr .= ' '.$value[0].'="'.$value[1].'"';\r
+               }\r
+               return "<$tag$attr>";\r
+       }\r
+       \r
+       // template for end tags\r
+       function close ($tag) \r
+       {\r
+               return "</$tag>";\r
+       }\r
+\r
+       function template_end() { return null;  }\r
+       \r
+} //END class HTML_output\r
+\r
+?>
\ No newline at end of file
diff --git a/tw/output/XHTML_output.php b/tw/output/XHTML_output.php
new file mode 100644 (file)
index 0000000..89207b6
--- /dev/null
@@ -0,0 +1,67 @@
+<?php\r
+/*\r
+ * tag|wall                                           | PHP Tag Filter |\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  designia.sk\r
+\r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * XHTML_output.php            xhtml output module\r
+ */\r
+\r
+class XHTML_output\r
+{\r
+       function XHTML_output() { return;       }\r
+       \r
+       // input: string, array()\r
+       \r
+       function pair ($tag, &$attributes)\r
+       {\r
+               if($attributes == null)\r
+                       return "<$tag>";\r
+               $attr = null;\r
+               foreach ($attributes as $value)\r
+               {\r
+                       if($value[1])   $attr .= ' '.$value[0].'="'.$value[1].'"';\r
+               }\r
+               return "<$tag$attr>";\r
+       }\r
+       \r
+       function single ($tag, &$attributes)\r
+       {\r
+               if($attributes == null)\r
+                       return "<$tag />";\r
+               $attr = null;\r
+               foreach ($attributes as $value)\r
+               {\r
+                       if($value[1])   $attr .= $value[0].'="'.$value[1].'" ';\r
+               }\r
+               return "<$tag $attr/>";\r
+       }\r
+       \r
+       // template for end tags\r
+       function close ($tag) \r
+       {\r
+               return "</$tag>";\r
+       }\r
+\r
+       function template_end() { return null;  }\r
+       \r
+} //END class XHTML_output\r
+\r
+?>
\ No newline at end of file
diff --git a/tw/tw-config.php b/tw/tw-config.php
new file mode 100644 (file)
index 0000000..63b4fb4
--- /dev/null
@@ -0,0 +1,117 @@
+<?\r
+/*\r
+ * tag|wall                                            | PHP Tag Filter|\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  designia.sk\r
+\r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * tw-config.php\r
+ *\r
+ */\r
+\r
+// paths\r
+define ('TW_PATH', 'tw/');\r
+define ('TW_LANG',                     TW_PATH.'lang/');\r
+define ('TW_CACHE',                    TW_PATH.'tw_cache/');\r
+define ('TW_SETUP',                    TW_PATH.'filter-setup/');\r
+define ('TW_ERRMODULE',                TW_PATH.'error/');\r
+define ('TW_OUTMODULE',                TW_PATH.'output/');\r
+\r
+// tag flags\r
+define ('TW_NOP',                      0x0001);\r
+define ('TW_OPT',                      0x0002);\r
+define ('TW_OVR',                      0x0004);\r
+define ('TW_DUP',                      0x0008);\r
+\r
+// attr filter commands\r
+define ('TW_ALL',              0);\r
+define ('TW_URL',              1);             // value is url\r
+define ('TW_LINK',             2);             // value is link\r
+define ('TW_NUM',              3);             // value must be between\r
+define ('TW_CASE',             4);             // value must be in case of..\r
+define ('TW_REQ',              8);             // required attribute\r
+\r
+define ('TW_RQ_ALL',   TW_REQ);\r
+define ('TW_RQ_URL',   1 | TW_REQ);\r
+define ('TW_RQ_LINK',  2 | TW_REQ);\r
+define ('TW_RQ_NUM',   3 | TW_REQ);\r
+define ('TW_RQ_CASE',  4 | TW_REQ);\r
+\r
+if(!defined('FSHL_WITH_TW_DEFINED'))\r
+{\r
+       define ('FSHL_WITH_TW_DEFINED', 1);\r
+\r
+       // debug modes (on - 1, off - 0)\r
+       // only shlParser supports DEBUG modes\r
+       define ('DEBUG_STATE',  0);     // enable debug states\r
+       define ('DEBUG_REPORT', 0);     // enable parser error reports and infos\r
+        \r
+       // fshlParser() 'option' flags (not used at this time)\r
+       define ('P_DISABLE_RECURSION',  0x0001);\r
+       define ('P_DISABLE_NEWLANG',    0x0002);\r
+       define ('P_DISABLE_EXECUTE',    0x0004);\r
+       define ('P_DISABLE_EXIT',               0x0008);\r
+       define ('P_DEFAULT',                    0x0000);\r
+       \r
+       // F/SHL state flags\r
+       define ('PF_VOID',                      0x0000);\r
+       define ('PF_KEYWORD',           0x0001);\r
+       define ('PF_RECURSION',         0x0004);\r
+       define ('PF_NEWLANG',           0x0008);\r
+       define ('PF_EXECUTE',           0x0010);        // not used\r
+       \r
+       // TW state flags\r
+       define ('PF_CLEAN',                     0x0100);\r
+       define ('PF_XIO',                       0x0200);\r
+       define ('PF_XDONE',                     0x0400);\r
+       define ('PF_XNEW',                      0x0800);\r
+       \r
+       // state field indexes\r
+       define ('XL_DIAGR',             0);\r
+       define ('XL_FLAGS',             1);\r
+       define ('XL_CLASS',             2);\r
+       define ('XL_DATA',              3);\r
+       \r
+       define ('XL_DSTATE',    0);\r
+       define ('XL_DTYPE',             1);\r
+       \r
+       // internal and special states\r
+       define ('P_RET_STATE',  '_RET');\r
+       define ('P_QUIT_STATE', '_QUIT');\r
+       \r
+       // group delimiters\r
+       $group_delimiters=array(\r
+       \r
+               "SPACE",        "!SPACE",\r
+               "NUMBER",       "!NUMBER",\r
+               "ALPHA",        "!ALPHA",\r
+               "ALNUM",        "!ALNUM",\r
+               "HEXNUM",       "!HEXNUM",\r
+               "_ALL",\r
+       \r
+               // TODO: Add special language depended groups here.\r
+               //       See function shlParser::isdelimiter()\r
+               //       and fshlGenerator::make_isdx(). You must\r
+               //       implement your new delimiters...\r
+               "PHP_DELIM",\r
+       );\r
+       \r
+       $fshl_signatures=array("SHL","TW");\r
+\r
+} //end if(!defined())\r
+?>
\ No newline at end of file
diff --git a/tw/tw-errors.php b/tw/tw-errors.php
new file mode 100644 (file)
index 0000000..59881a8
--- /dev/null
@@ -0,0 +1,118 @@
+<?\r
+/*\r
+ * tag|wall                                            | PHP Tag Filter|\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  www.designia.sk\r
+   \r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * tw-errors.php       \r
+ * \r
+ * This file containing basic error definitions and basic error handling class.\r
+ *\r
+ */\r
\r
+// comments\r
+define('TWE_OK',                               0x0000);        // null\r
+define('TWE_VERSION',                  0x0001);        // param1=parser_version, param2=lang_version\r
+define('TWE_NOTE',                             0x0002);        // param2=note / tips / etc...\r
+define('TWE_CREDITS',                  0x0003);        // null\r
+\r
+// warnings\r
+define('TWE_STACK_UNDERFLOW',  0x0010);        // param1=tag_name\r
+define('TWE_STACK_NOT_EMPTY',  0x0020);        // param1=tags, stack not empty\r
+define('TWE_UNEXPECTED_EOST',  0x0030);        // unexpected end of stream (tag completed automatically)\r
+define('TWE_UNEXPECTED_QUOTE', 0x0040);        // atr="value>...\r
+\r
+// errors\r
+define('TWE_SYNTAX',                   0x0100);        // null, HTML syntax error (for future strict bases)\r
+define('TWE_TOO_MANY_ATTRS',   0x0200);        // tag_name, too many attrs in tag ..\r
+\r
+// internal errors\r
+define('TWE_FILE_NOT_FOUND',   0x1000);        // param1 = file\r
+define('TWE_BAD_SIGNATURE',            0x2000);        // param1 = language, param2 = signature\r
+define('TWE_LANG_NOT_FOUND',   0x3000);        // param1 = language\r
+\r
+// indexes to ErrorArray\r
+define('TWE_ERRNO',            0);             // error value\r
+define('TWE_PARAM1',   1);             // parameter 1\r
+define('TWE_PARAM2',   2);             // parameter 2\r
+define('TWE_POSIT',            3);             // position in source\r
+define('TWE_CODE',             4);             // piece of bad code\r
+\r
+class TW_errors\r
+{\r
+       var $IsError;\r
+       var $ErrorArray;\r
+       var $identifier;\r
+\r
+       /* class constructor \r
+        */\r
+       function TW_errors($options = 0)\r
+       {\r
+               $this->IsError = 0;\r
+               $this->ErrorArray = null;\r
+               $this->identifier = 0;\r
+       }\r
+       \r
+       function is_error()             { return $this->IsError; }\r
+       \r
+       function get_err_array() { return $this->ErrorArray; }\r
+       \r
+       function get_comments() { return $this->get_by_mask(0x000f); }\r
+\r
+       function get_warnings() { return $this->get_by_mask(0x00f0); }\r
+\r
+       function get_errors()   { return $this->get_by_mask(0x0f00); }\r
+\r
+       function get_internal() { return $this->get_by_mask(0xf000); }\r
+               \r
+       function get_by_mask($mask)\r
+       {\r
+               $ErrTemp = null;\r
+               foreach($this->ErrorArray as $key => $value)\r
+               {\r
+                       if($value[TWE_ERRNO] & $mask) $ErrTemp[$key] = $value;\r
+               }\r
+               return $ErrTemp;\r
+       }\r
+       \r
+       /* Input: \r
+        *              id:             error id, \r
+        *              lang:   error_language_array\r
+        *\r
+        *  Outupt:\r
+        *              error text or null\r
+        */\r
+       function get_error_text ( $id, &$lang )\r
+       {\r
+               if( in_array($id, $this->ErrorArray) )\r
+               {\r
+                       $errno = $this->ErrorArray[$id][TWE_ERRNO];\r
+                       if( in_array($errno,$lang) )\r
+                               return sprintf( $lang[$errno], \r
+                                                               $this->ErrorArray[$id][TWE_PARAM1], \r
+                                                               $this->ErrorArray[$id][TWE_PARAM2] );\r
+                       else\r
+                               return sprintf( "Please translate errno 0x%x.",$errno );\r
+               }\r
+               return null;\r
+       }\r
+\r
+}      // END class TW_errors\r
+?>
\ No newline at end of file
diff --git a/tw/tw-tags.php b/tw/tw-tags.php
new file mode 100644 (file)
index 0000000..6a83be1
--- /dev/null
@@ -0,0 +1,97 @@
+<?\r
+/*\r
+ * tag|wall                                            | PHP Tag Filter|\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  www.designia.sk\r
+   \r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * tw-tags.php  - this file contains common tag definitions and \r
+ *                relationships\r
+ *\r
+ * WARNING: This is not filter configuration. Relationships are used\r
+ *          for correct cross tag fixing.\r
+ * ---------------------------------------------------------------------\r
+ * Tag flags:\r
+ *\r
+ * TW_DUP   - remove duplicates ( not implemented )\r
+ *            <i>...<i>:::</i></i> => <i>...:::</i>\r
+ *\r
+ * TW_NOP   - tag without end tag \r
+ *            <br /><hr /> etc..\r
+ *\r
+ * TW_OPT   - tag have optional end tag ( optional end tag is closed automatically )\r
+ *            <li>line1<li>line2 => <li>line1</li><li>line2</li>\r
+ *\r
+ * CONT.OFF - content off ( not implemented )\r
+ *            <tag>content-off<tag2>content-on</tag1></tag>  =>  <tag><tag2>content-on</tag1></tag>\r
+ *\r
+ * REQ.TAG  - required tag in stack\r
+ *            <ul><li>...  this is correct\r
+ *            <p><li>...   this is not correct, result is <p>...\r
+ */\r
+$tw_tag_relations = array(\r
+\r
+//  TAG                  FLAG    CONT.OFF  REQ. TAG\r
+\r
+    "a"         => array(0,      0,        null),\r
+    "b"         => array(0,      0,        null),\r
+    "blockquote"=> array(0,      0,        null),\r
+    "big"       => array(0,      0,        null),\r
+    "br"        => array(TW_NOP, 0,        null),\r
+    "code"      => array(0,      0,        null),\r
+    "dl"        => array(0,      0,        null),\r
+    "dt"        => array(TW_OPT, 0,        array("dl")),\r
+    "dd"        => array(TW_OPT, 0,        array("dl")),\r
+    "div"       => array(0,      0,        null),\r
+    "em"        => array(0,      0,        null),\r
+    "h1"        => array(0,      0,        null),\r
+    "h2"        => array(0,      0,        null),\r
+    "h3"        => array(0,      0,        null),\r
+    "h4"        => array(0,      0,        null),\r
+    "h5"        => array(0,      0,        null),\r
+    "h6"        => array(0,      0,        null),\r
+    "hr"        => array(TW_NOP, 0,        null),\r
+    "i"         => array(0,      0,        null),\r
+    "img"       => array(TW_NOP, 0,        null),\r
+    "ul"        => array(0,      1,        null),\r
+    "ol"        => array(0,      1,        null),\r
+    "li"        => array(TW_OPT, 0,        array("ul","ol")),\r
+    "object"    => array(0,      1,        null),\r
+    "p"         => array(TW_OPT, 0,        null),\r
+    "pre"       => array(0,      0,        null),\r
+    "small"     => array(0,      0,        null),\r
+    "span"      => array(0,      0,        null),\r
+    "strong"    => array(0,      0,        null),\r
+    "style"     => array(0,      1,        null),\r
+    "sub"       => array(0,      0,        null),\r
+    "sup"       => array(0,      0,        null),\r
+    "table"     => array(0,      1,        null),\r
+    "caption"   => array(0,      0,        array("table")),\r
+    "tbody"     => array(0,      0,        array("table")),\r
+    "tfoot"     => array(0,      0,        array("table")),\r
+    "thead"     => array(0,      0,        array("table")),\r
+    "tr"        => array(TW_OPT, 1,        array("table","tbody")),\r
+    "td"        => array(TW_OPT, 0,        array("tr")),\r
+    "th"        => array(TW_OPT, 0,        array("tr")),\r
+    "u"         => array(0,      0,        null),\r
+\r
+    // TODO: add your specific tags here...\r
+\r
+    );\r
+?>
\ No newline at end of file
diff --git a/tw/tw.php b/tw/tw.php
new file mode 100644 (file)
index 0000000..c4f813e
--- /dev/null
+++ b/tw/tw.php
@@ -0,0 +1,291 @@
+<?\r
+/*\r
+ * tag|wall ver 0.1.4                                 | PHP Tag Filter |\r
+ * ---------------------------------------------------------------------\r
+\r
+   Copyright (C) 2002  Juraj 'HVGE' Durech\r
+   Copyright (C) 2002  designia.sk\r
+\r
+   This program is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 2 of the License, or\r
+   (at your option) any later version.\r
+\r
+   This program is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+\r
+   You should have received a copy of the GNU General Public License\r
+   along with this program; if not, write to the Free Software\r
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \r
+   \r
+ * ---------------------------------------------------------------------\r
+ * tw.php      \r
+ *\r
+ * main tag|wall parser core\r
+ * ---------------------------------------------------------------------\r
+ *\r
+ */\r
+define ("TW_PARSER_VERSION", "0.1.4");\r
+\r
+require_once(TW_PATH."tw-tags.php");\r
+require_once(TW_PATH."tw-errors.php");\r
+\r
+class twParser\r
+{\r
+       // class variables\r
+       var $text, $textlen, $textpos;\r
+       var $lang, $options; \r
+       var $output, $err, $content_off;\r
+\r
+       var $out;\r
+       var $_trans, $_flags, $_data, $_delim, $_class, $_keywords;\r
+       var $_ret,$_quit;\r
+       \r
+       var $base, $_names;\r
+\r
+\r
+       // -----------------------------------------------------------------------\r
+       // USER LEVEL functions\r
+       //\r
+\r
+       /* twParser CLASS CONSTRUCTOR\r
+        * \r
+        * input: \r
+        *              string  $language       - TW language class name ( see directory tw/lang/ )\r
+        *              int             $options        - parser options (not used)\r
+        */\r
+       function twParser(\r
+                                               $language = "TW", \r
+                                               $options  = P_DEFAULT \r
+                                        )\r
+       {\r
+               $_lang = $language."_lang";\r
+               $_base = $language."_base";\r
+               require_once (TW_LANG."$_base.php");\r
+               require_once (TW_CACHE."$_lang.php");\r
+\r
+               $this->lang = new $_lang;\r
+               $this->base = $_base;\r
+               $this->options   = $options;\r
+               $this->_trans    = &$this->lang->trans;\r
+               $this->_flags    = &$this->lang->flags;\r
+               $this->_delim    = &$this->lang->delim;\r
+               $this->_ret      = &$this->lang->ret;\r
+               $this->_quit     = &$this->lang->quit;\r
+               $this->_names    = &$this->lang->names;\r
+\r
+               $this->content_off = &$this->lang->content_off;\r
+       }\r
+\r
+       /* STRIP TAGS\r
+        *\r
+        * input:\r
+        *              string $text                    - input string\r
+        *              array $configuration    - filter configuration array ( see files in directory tw/filter-setup/ )\r
+        *              string $output_module   - output module name ( tw/output )\r
+        *              string $error_module    - error module name ( tw/error )\r
+        *              int $offset                             - offset in $text\r
+        *\r
+        * output:\r
+        *              parsed string\r
+        */\r
+       function strip_tags (\r
+                                                       $text,\r
+                                                       &$configuration,\r
+                                                       $output_module = "XHTML",\r
+                                                       $error_module  = "FOO",                                                 \r
+                                                       $offset = 0\r
+                                               )\r
+       {\r
+               // open modules\r
+               $_err  = $error_module."_error";\r
+               require_once (TW_ERRMODULE."$_err.php");\r
+               $this->err = new $_err( $this->options );\r
+\r
+               $_out  = $output_module."_output";\r
+               require_once (TW_OUTMODULE."$_out.php");\r
+               $this->output = new $_out;\r
+\r
+               // parser init\r
+               $this->text = &$text;\r
+               $this->textlen = strlen($text);\r
+               $this->text .= "IMNOTREALLYOPTIMISTIC";\r
+               $this->textpos = $offset;\r
+               $this->out = null;\r
+               \r
+               // FSHL pointers init\r
+               $this->lang->pt         = &$this->text;\r
+               $this->lang->pti        = &$this->textpos;\r
+               $this->lang->out        = &$this->out;\r
+               $this->lang->err        = &$this->err;\r
+               $this->lang->output = &$this->output;\r
+\r
+               // base init\r
+               $base = &$this->base;\r
+               $this->lang->$base();\r
+               $this->lang->config_tags = array_keys($configuration);\r
+               // load initial configuration\r
+               foreach($configuration as $tag => $attributes)\r
+               {\r
+                       $this->lang->config_req_attr[$tag] = null;\r
+                       if(is_array($attributes))\r
+                       {\r
+                               $this->lang->config_attr[$tag] = array_keys($configuration[$tag]);\r
+                               foreach($attributes as $attr => $command)\r
+                               {\r
+                                       if( $command )\r
+                                               if( $command[0] & TW_REQ ) $this->lang->config_req_attr[$tag][] = $attr;\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               $this->lang->config_attr[$tag] = $attributes;\r
+                       }\r
+               }\r
+               $this->lang->config = &$configuration;\r
+               \r
+               // start parser\r
+               $this->parse_string ( $this->lang->initial_state );\r
+               \r
+               $this->out .= $this->lang->base_end();\r
+               $this->out .= $this->output->template_end();\r
+\r
+               return $this->out;\r
+       }\r
+\r
+       function get_position() { return $this->textpos; }\r
+\r
+       function get_out() { return $this->out; }\r
+       \r
+       // error wrapper\r
+       \r
+       function is_error() { return $this->err->is_error(); }\r
+       function get_err_array() { return $this->err->get_err_array(); }\r
+       function get_comments() { return $this->err->get_by_mask(0x000f); }\r
+       function get_warnings() { return $this->err->get_by_mask(0x00f0); }\r
+       function get_errors()   { return $this->err->get_by_mask(0x0f00); }\r
+       function get_internal() { return $this->err->get_by_mask(0xf000); }\r
+       function get_by_mask($mask) { return $this->err->get_by_mask($mask); }\r
+       function get_error_text ( $id, &$lang ) { return $this->err->get_error_text ( $id, &$lang ); }\r
+       \r
+// ---------------------------------------------------------------------------------\r
+// LOW LEVEL functions\r
+//\r
+\r
+// main parser function\r
+//\r
+function parse_string ($state)\r
+{\r
+       $flags = $this->_flags[$state];\r
+       $statename_n = $this->_names[$state]."_new";\r
+       // perform IN function if required\r
+       if( $flags & PF_XIO )\r
+       { \r
+               $statename_i = $this->_names[$state]."_in";\r
+               $statename_o = $this->_names[$state]."_out";\r
+               $this->lang->$statename_i();\r
+       }\r
+       $stateword = null;\r
+       \r
+       while( ($word = $this->getword("isd$state")) != null )\r
+       {\r
+               if(is_array($word))\r
+               {\r
+                       // word is delimiter\r
+                       $newstate = $this->_trans[$state][$word[0]][XL_DSTATE];\r
+\r
+                       // char back to stream (CB2S) if required\r
+                       if( $this->_trans[$state][$word[0]][XL_DTYPE] )\r
+                       {\r
+                               if( $newstate == $state )\r
+                               {\r
+                                       // If it is the same state, CB2S flag have different significance\r
+                                       // re-initialize state (call IN function)\r
+                                       $stateword = null;\r
+                                       if( $flags & PF_XIO ) $this->lang->$statename_i();\r
+                                       continue;\r
+                               }\r
+                               $this->textpos -= strlen($word[1]);\r
+                       }\r
+                       else\r
+                       {\r
+                               $stateword .= $word[1];         // add new parsed word to stateword\r
+                       }\r
+                       if( $newstate == $this->_ret )  // newstate is _RET from recursion\r
+                       {\r
+                               // perform NEW function if required\r
+                               if( $flags & PF_XNEW ) $this->lang->$statename_n($stateword);\r
+                               // perform OUT function if required\r
+                               if( $flags & PF_XIO ) $this->lang->$statename_o($stateword);\r
+                               // return from recursion\r
+                               return;\r
+                       }\r
+                       \r
+                       if( $state != $newstate )               // recursion - only if it is really new state\r
+                       {\r
+                               // perform NEW function if required\r
+                               if( $flags & PF_XNEW ) $this->lang->$statename_n($stateword);\r
+                               // recursion\r
+                               $this->parse_string($newstate);\r
+                               // perform OUT function if required and return.\r
+                               if( $flags & PF_XDONE )\r
+                               {\r
+                                       if( $flags & PF_XIO ) $this->lang->$statename_o(null);\r
+                                       return;\r
+                               }\r
+                               continue;\r
+                       }                       \r
+               }\r
+               else\r
+               {\r
+                       // word is not delimiter\r
+                       if( $flags & PF_CLEAN )\r
+                       {\r
+                               if(!$this->content_off)\r
+                                       $this->out .= str_replace("<","&gt",$word);\r
+                       }\r
+                       else\r
+                       {\r
+                               $stateword .= $word;\r
+                       }\r
+               }\r
+       } //END while()\r
+\r
+       // TODO: check this OUT\r
+       \r
+       // perform NEW function if required\r
+       if( $flags & PF_XNEW ) $this->lang->$statename_n($stateword);\r
+       // perform OUT function if required and return.\r
+       if( $flags & PF_XIO ) $this->lang->$statename_o($stateword);\r
+}\r
+\r
+// get word from stream\r
+//\r
+function getword ($state)\r
+{\r
+       $result = null;\r
+       if($this->textpos < $this->textlen)\r
+       {\r
+               $del = $this->lang->$state();   // call "is delimiter" isdX function\r
+               if($del != false)\r
+               {\r
+                       // actual char (or sub-string) is delimiter\r
+                       $this->textpos += strlen($del[1]);\r
+                       return $del;\r
+               }\r
+               else\r
+               {\r
+                       // Actual char/string is not delimiter.\r
+                       // Result word is between current position and first delimiter in stream\r
+                       $result = $this->text[$this->textpos++];\r
+                       while(($this->textpos < $this->textlen) && !$this->lang->$state())\r
+                               $result .= $this->text[$this->textpos++];\r
+               }\r
+       }\r
+       return $result;\r
+}\r
+\r
+} // END class twParser\r
+?>
\ No newline at end of file
diff --git a/tw/tw_cache/TW_lang.php b/tw/tw_cache/TW_lang.php
new file mode 100644 (file)
index 0000000..c510a5a
--- /dev/null
@@ -0,0 +1,177 @@
+<?php
+/* --------------------------------------------------------------- *
+ *        WARNING: ALL CHANGES IN THIS FILE WILL BE LOST
+ *
+ *   Source language file: tw/lang/TW_lang.php
+ *       Language version: 1.0 (Sign:TW)
+ *
+ *            Target file: tw/tw_cache/TW_lang.php
+ *             Build date: Wed 20.11.2002 00:29:40
+ *
+ *      Generator version: 0.4.1
+ * --------------------------------------------------------------- */
+class TW_lang extends TW_base
+{
+var $trans,$flags,$data,$delim,$class,$keywords;
+var $version,$signature,$initial_state,$ret,$quit;
+var $pt,$pti,$generator_version;
+var $names;
+
+function TW_lang ()
+{
+       $this->version="1.0";
+       $this->signature="TW";
+       $this->generator_version="0.4.1";
+       $this->initial_state=0;
+       $this->trans=array(0=>array("<"=>array(0=>1,1=>0,),),1=>array("ALPHA"=>array(0=>3,1=>1,),"/"=>array(0=>2,1=>0,),"<"=>array(0=>1,1=>1,),"!--"=>array(0=>11,1=>0,),"_ALL"=>array(0=>12,1=>0,),),2=>array("ALPHA"=>array(0=>4,1=>1,),"_ALL"=>array(0=>12,1=>0,),),3=>array("ALPHA"=>array(0=>4,1=>1,),"_ALL"=>array(0=>12,1=>0,),),4=>array("!ALNUM"=>array(0=>5,1=>1,),),5=>array("ALPHA"=>array(0=>6,1=>1,),">"=>array(0=>12,1=>0,),"/>"=>array(0=>12,1=>0,),),6=>array("!ALPHA"=>array(0=>7,1=>1,),">"=>array(0=>12,1=>1,),"/>"=>array(0=>12,1=>1,),),7=>array("\""=>array(0=>8,1=>0,),"'"=>array(0=>9,1=>0,),"ALNUM"=>array(0=>10,1=>1,),">"=>array(0=>12,1=>1,),"/>"=>array(0=>12,1=>1,),),8=>array("\""=>array(0=>12,1=>0,),),9=>array("'"=>array(0=>12,1=>0,),),10=>array("-"=>array(0=>10,1=>0,),"!ALNUM"=>array(0=>12,1=>1,),),11=>array("-->"=>array(0=>12,1=>0,),),);
+       $this->flags=array(0=>256,1=>1024,2=>1536,3=>1536,4=>3584,5=>0,6=>3584,7=>1536,8=>512,9=>512,10=>512,11=>0,);
+       $this->delim=array(0=>array(0=>"<",),1=>array(0=>"ALPHA",1=>"/",2=>"<",3=>"!--",4=>"_ALL",),2=>array(0=>"ALPHA",1=>"_ALL",),3=>array(0=>"ALPHA",1=>"_ALL",),4=>array(0=>"!ALNUM",),5=>array(0=>"ALPHA",1=>">",2=>"/>",),6=>array(0=>"!ALPHA",1=>">",2=>"/>",),7=>array(0=>"\"",1=>"'",2=>"ALNUM",3=>">",4=>"/>",),8=>array(0=>"\"",),9=>array(0=>"'",),10=>array(0=>"-",1=>"!ALNUM",),11=>array(0=>"-->",),);
+       $this->ret=12;
+       $this->quit=13;
+       $this->names=array(0=>"OUT",1=>"T_tagWall",2=>"T_Cbegin",3=>"T_begin",4=>"T_gettag",5=>"T_in",6=>"A_begin",7=>"V_begin",8=>"VALUE1",9=>"VALUE2",10=>"VALUE3",11=>"HTML_comment",12=>"_RET",13=>"_QUIT",);
+}
+
+/* OUT */
+function isd0 ()
+{
+$c1=$this->pt[$this->pti];
+if($c1=="<")
+       return array("<","<");
+return false;
+}
+
+/* T_tagWall */
+function isd1 ()
+{
+$p=$this->pti;
+$c1=$this->pt[$p++];
+$c2=$c1.$this->pt[$p++];
+$c3=$c2.$this->pt[$p];
+if(stristr("eaoinltsrvdukzmcpyhjbfgxwq",$c1))
+       return array("ALPHA",$c1);
+if($c1=="/")
+       return array("/","/");
+if($c1=="<")
+       return array("<","<");
+if($c3=="!--")
+       return array("!--","!--");
+return array("_ALL",$c1);
+}
+
+/* T_Cbegin */
+function isd2 ()
+{
+$c1=$this->pt[$this->pti];
+if(stristr("eaoinltsrvdukzmcpyhjbfgxwq",$c1))
+       return array("ALPHA",$c1);
+return array("_ALL",$c1);
+}
+
+/* T_begin */
+function isd3 ()
+{
+$c1=$this->pt[$this->pti];
+if(stristr("eaoinltsrvdukzmcpyhjbfgxwq",$c1))
+       return array("ALPHA",$c1);
+return array("_ALL",$c1);
+}
+
+/* T_gettag */
+function isd4 ()
+{
+$c1=$this->pt[$this->pti];
+if(!stristr("eaoinltsrvdukzmcpyhjbfgxwq0123456789",$c1))
+       return array("!ALNUM",$c1);
+return false;
+}
+
+/* T_in */
+function isd5 ()
+{
+$p=$this->pti;
+$c1=$this->pt[$p++];
+$c2=$c1.$this->pt[$p];
+if(stristr("eaoinltsrvdukzmcpyhjbfgxwq",$c1))
+       return array("ALPHA",$c1);
+if($c1==">")
+       return array(">",">");
+if($c2=="/>")
+       return array("/>","/>");
+return false;
+}
+
+/* A_begin */
+function isd6 ()
+{
+$p=$this->pti;
+$c1=$this->pt[$p++];
+$c2=$c1.$this->pt[$p];
+if(!stristr("eaoinltsrvdukzmcpyhjbfgxwq",$c1))
+       return array("!ALPHA",$c1);
+if($c1==">")
+       return array(">",">");
+if($c2=="/>")
+       return array("/>","/>");
+return false;
+}
+
+/* V_begin */
+function isd7 ()
+{
+$p=$this->pti;
+$c1=$this->pt[$p++];
+$c2=$c1.$this->pt[$p];
+if($c1=="\"")
+       return array("\"","\"");
+if($c1=="'")
+       return array("'","'");
+if(stristr("eaoinltsrvdukzmcpyhjbfgxwq0123456789",$c1))
+       return array("ALNUM",$c1);
+if($c1==">")
+       return array(">",">");
+if($c2=="/>")
+       return array("/>","/>");
+return false;
+}
+
+/* VALUE1 */
+function isd8 ()
+{
+$c1=$this->pt[$this->pti];
+if($c1=="\"")
+       return array("\"","\"");
+return false;
+}
+
+/* VALUE2 */
+function isd9 ()
+{
+$c1=$this->pt[$this->pti];
+if($c1=="'")
+       return array("'","'");
+return false;
+}
+
+/* VALUE3 */
+function isd10 ()
+{
+$c1=$this->pt[$this->pti];
+if($c1=="-")
+       return array("-","-");
+if(!stristr("eaoinltsrvdukzmcpyhjbfgxwq0123456789",$c1))
+       return array("!ALNUM",$c1);
+return false;
+}
+
+/* HTML_comment */
+function isd11 ()
+{
+$p=$this->pti;
+$c3=$this->pt[$p++].$this->pt[$p++].$this->pt[$p];
+if($c3=="-->")
+       return array("-->","-->");
+return false;
+}
+
+}
+?>
\ No newline at end of file