Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

добавил файлы библиотеки

  • Loading branch information...
commit cf13c144310717b4d469e1947cecf5e901bd6483 1 parent ed1c903
@xBBCoder xBBCoder authored
Showing with 25,925 additions and 0 deletions.
  1. +75 −0 Xbb/Tags/A.php
  2. +35 −0 Xbb/Tags/Abbr.php
  3. +37 −0 Xbb/Tags/Acronym.php
  4. +32 −0 Xbb/Tags/Address.php
  5. +53 −0 Xbb/Tags/Align.php
  6. +41 −0 Xbb/Tags/Bbcode.php
  7. +48 −0 Xbb/Tags/Bdo.php
  8. +32 −0 Xbb/Tags/Br.php
  9. +32 −0 Xbb/Tags/Caption.php
  10. +122 −0 Xbb/Tags/Code.php
  11. +33 −0 Xbb/Tags/Color.php
  12. +55 −0 Xbb/Tags/Email.php
  13. +44 −0 Xbb/Tags/Font.php
  14. +39 −0 Xbb/Tags/Google.php
  15. +33 −0 Xbb/Tags/Hr.php
  16. +49 −0 Xbb/Tags/Img.php
  17. +36 −0 Xbb/Tags/Li.php
  18. +55 −0 Xbb/Tags/List.php
  19. +38 −0 Xbb/Tags/Nobb.php
  20. +36 −0 Xbb/Tags/P.php
  21. +40 −0 Xbb/Tags/Quote.php
  22. +41 −0 Xbb/Tags/Simple.php
  23. +49 −0 Xbb/Tags/Size.php
  24. +54 −0 Xbb/Tags/Table.php
  25. +48 −0 Xbb/Tags/Td.php
  26. +48 −0 Xbb/Tags/Th.php
  27. +36 −0 Xbb/Tags/Tr.php
  28. +83 −0 area.php
  29. +760 −0 bbcode.lib.js
  30. +1,147 −0 bbcode.lib.php
  31. +53 −0 config/editor.config.php
  32. +62 −0 config/parser.config.php
  33. +221 −0 config/tags.php
  34. +80 −0 config/xbbeditor.config.php
  35. +13 −0 i18n/default/lang.php
  36. +13 −0 i18n/ru_cp1251/lang.php
  37. +13 −0 i18n/ru_utf8/lang.php
  38. BIN  images/background.gif
  39. BIN  images/button_menu.gif
  40. BIN  images/buttons/bold.gif
  41. BIN  images/buttons/center.gif
  42. BIN  images/buttons/code.gif
  43. BIN  images/buttons/color.gif
  44. BIN  images/buttons/font.gif
  45. BIN  images/buttons/help.gif
  46. BIN  images/buttons/hr.gif
  47. BIN  images/buttons/image.gif
  48. BIN  images/buttons/italic.gif
  49. BIN  images/buttons/justify.gif
  50. BIN  images/buttons/left.gif
  51. BIN  images/buttons/link.gif
  52. BIN  images/buttons/mail.gif
  53. BIN  images/buttons/preview.gif
  54. BIN  images/buttons/quote.gif
  55. BIN  images/buttons/right.gif
  56. BIN  images/buttons/s.gif
  57. BIN  images/buttons/size.gif
  58. BIN  images/buttons/smile.gif
  59. BIN  images/buttons/sub.gif
  60. BIN  images/buttons/sup.gif
  61. BIN  images/buttons/underline.gif
  62. BIN  images/left.gif
  63. BIN  images/loader.gif
  64. BIN  images/pixel.gif
  65. BIN  images/right.gif
  66. BIN  images/separator.gif
  67. BIN  images/smiles/1.gif
  68. BIN  images/smiles/10.gif
  69. BIN  images/smiles/100.gif
  70. BIN  images/smiles/11.gif
  71. BIN  images/smiles/12.gif
  72. BIN  images/smiles/13.gif
  73. BIN  images/smiles/14.gif
  74. BIN  images/smiles/15.gif
  75. BIN  images/smiles/16.gif
  76. BIN  images/smiles/17.gif
  77. BIN  images/smiles/18.gif
  78. BIN  images/smiles/19.gif
  79. BIN  images/smiles/2.gif
  80. BIN  images/smiles/20.gif
  81. BIN  images/smiles/21.gif
  82. BIN  images/smiles/22.gif
  83. BIN  images/smiles/23.gif
  84. BIN  images/smiles/24.gif
  85. BIN  images/smiles/25.gif
  86. BIN  images/smiles/26.gif
  87. BIN  images/smiles/27.gif
  88. BIN  images/smiles/28.gif
  89. BIN  images/smiles/29.gif
  90. BIN  images/smiles/3.gif
  91. BIN  images/smiles/30.gif
  92. BIN  images/smiles/31.gif
  93. BIN  images/smiles/32.gif
  94. BIN  images/smiles/33.gif
  95. BIN  images/smiles/34.gif
  96. BIN  images/smiles/35.gif
  97. BIN  images/smiles/36.gif
  98. BIN  images/smiles/37.gif
  99. BIN  images/smiles/38.gif
  100. BIN  images/smiles/39.gif
  101. BIN  images/smiles/4.gif
  102. BIN  images/smiles/40.gif
  103. BIN  images/smiles/41.gif
  104. BIN  images/smiles/42.gif
  105. BIN  images/smiles/43.gif
  106. BIN  images/smiles/44.gif
  107. BIN  images/smiles/45.gif
  108. BIN  images/smiles/46.gif
  109. BIN  images/smiles/47.gif
  110. BIN  images/smiles/48.gif
  111. BIN  images/smiles/49.gif
  112. BIN  images/smiles/5.gif
  113. BIN  images/smiles/50.gif
  114. BIN  images/smiles/51.gif
  115. BIN  images/smiles/52.gif
  116. BIN  images/smiles/53.gif
  117. BIN  images/smiles/54.gif
  118. BIN  images/smiles/55.gif
  119. BIN  images/smiles/56.gif
  120. BIN  images/smiles/57.gif
  121. BIN  images/smiles/58.gif
  122. BIN  images/smiles/59.gif
  123. BIN  images/smiles/6.gif
  124. BIN  images/smiles/60.gif
  125. BIN  images/smiles/61.gif
  126. BIN  images/smiles/62.gif
  127. BIN  images/smiles/63.gif
  128. BIN  images/smiles/64.gif
  129. BIN  images/smiles/65.gif
  130. BIN  images/smiles/66.gif
  131. BIN  images/smiles/67.gif
  132. BIN  images/smiles/68.gif
  133. BIN  images/smiles/69.gif
  134. BIN  images/smiles/7.gif
  135. BIN  images/smiles/70.gif
  136. BIN  images/smiles/71.gif
  137. BIN  images/smiles/72.gif
  138. BIN  images/smiles/73.gif
  139. BIN  images/smiles/74.gif
  140. BIN  images/smiles/75.gif
  141. BIN  images/smiles/76.gif
  142. BIN  images/smiles/77.gif
  143. BIN  images/smiles/78.gif
  144. BIN  images/smiles/79.gif
  145. BIN  images/smiles/8.gif
  146. BIN  images/smiles/80.gif
  147. BIN  images/smiles/81.gif
  148. BIN  images/smiles/82.gif
  149. BIN  images/smiles/83.gif
  150. BIN  images/smiles/84.gif
  151. BIN  images/smiles/85.gif
  152. BIN  images/smiles/86.gif
  153. BIN  images/smiles/87.gif
  154. BIN  images/smiles/88.gif
  155. BIN  images/smiles/89.gif
  156. BIN  images/smiles/9.gif
  157. BIN  images/smiles/90.gif
  158. BIN  images/smiles/91.gif
  159. BIN  images/smiles/92.gif
  160. BIN  images/smiles/93.gif
  161. BIN  images/smiles/94.gif
  162. BIN  images/smiles/95.gif
  163. BIN  images/smiles/96.gif
  164. BIN  images/smiles/97.gif
  165. BIN  images/smiles/98.gif
  166. BIN  images/smiles/99.gif
  167. +105 −0 images/smiles/Set_Smiles_YarNET.pak
  168. BIN  images/xbb.jpg
  169. +107 −0 index.php
  170. +2,823 −0 lib/geshi.php
  171. +197 −0 lib/geshi/actionscript.php
  172. +133 −0 lib/geshi/ada.php
  173. +171 −0 lib/geshi/apache.php
  174. +134 −0 lib/geshi/applescript.php
  175. +198 −0 lib/geshi/asm.php
  176. +153 −0 lib/geshi/asp.php
  177. +453 −0 lib/geshi/autoit.php
  178. +135 −0 lib/geshi/bash.php
  179. +185 −0 lib/geshi/blitzbasic.php
  180. +130 −0 lib/geshi/bnf.php
  181. +142 −0 lib/geshi/c.php
  182. +174 −0 lib/geshi/c_mac.php
  183. +125 −0 lib/geshi/caddcl.php
  184. +185 −0 lib/geshi/cadlisp.php
  185. +125 −0 lib/geshi/cfdg.php
  186. +325 −0 lib/geshi/cfm.php
  187. +266 −0 lib/geshi/cpp-qt.php
  188. +170 −0 lib/geshi/cpp.php
  189. +231 −0 lib/geshi/csharp.php
  190. 0  lib/geshi/css-gen.cfg
  191. +207 −0 lib/geshi/css.php
  192. +285 −0 lib/geshi/d.php
  193. +270 −0 lib/geshi/delphi.php
  194. +184 −0 lib/geshi/diff.php
  195. +126 −0 lib/geshi/div.php
  196. +183 −0 lib/geshi/dos.php
  197. +394 −0 lib/geshi/eiffel.php
  198. +156 −0 lib/geshi/fortran.php
  199. +137 −0 lib/geshi/freebasic.php
  200. +502 −0 lib/geshi/gml.php
  201. +2,117 −0 lib/geshi/groovy.php
  202. +254 −0 lib/geshi/html4strict.php
  203. +119 −0 lib/geshi/idl.php
  204. +123 −0 lib/geshi/ini.php
  205. +213 −0 lib/geshi/inno.php
  206. +139 −0 lib/geshi/io.php
  207. +1,388 −0 lib/geshi/java.php
  208. +1,021 −0 lib/geshi/java5.php
  209. +144 −0 lib/geshi/javascript.php
  210. +189 −0 lib/geshi/latex.php
  211. +133 −0 lib/geshi/lisp.php
  212. +134 −0 lib/geshi/lua.php
  213. +867 −0 lib/geshi/matlab.php
  214. +125 −0 lib/geshi/mirc.php
  215. +158 −0 lib/geshi/mpasm.php
  216. +181 −0 lib/geshi/mysql.php
  217. +352 −0 lib/geshi/nsis.php
  218. +239 −0 lib/geshi/objc.php
  219. +112 −0 lib/geshi/ocaml-brief.php
  220. +161 −0 lib/geshi/ocaml.php
  221. +130 −0 lib/geshi/oobas.php
  222. +487 −0 lib/geshi/oracle8.php
  223. +143 −0 lib/geshi/pascal.php
  224. +167 −0 lib/geshi/perl.php
  225. +160 −0 lib/geshi/php-brief.php
  226. +354 −0 lib/geshi/php.php
  227. +256 −0 lib/geshi/plsql.php
  228. +227 −0 lib/geshi/python.php
  229. +145 −0 lib/geshi/qbasic.php
  230. +214 −0 lib/geshi/reg.php
  231. +98 −0 lib/geshi/robots.php
  232. +147 −0 lib/geshi/ruby.php
  233. +357 −0 lib/geshi/sas.php
  234. +170 −0 lib/geshi/scheme.php
  235. +161 −0 lib/geshi/sdlbasic.php
  236. +159 −0 lib/geshi/smalltalk.php
  237. +166 −0 lib/geshi/smarty.php
  238. +135 −0 lib/geshi/sql.php
  239. +181 −0 lib/geshi/tcl.php
  240. +81 −0 lib/geshi/text.php
  241. +639 −0 lib/geshi/thinbasic.php
  242. +382 −0 lib/geshi/tsql.php
Sorry, we could not display the entire diff because it was too big.
View
75 Xbb/Tags/A.php
@@ -0,0 +1,75 @@
+<?php
+
+/******************************************************************************
+ * *
+ * A.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тегов [a], [anchor] и [url]
+class Xbb_Tags_A extends bbcode {
+ public $behaviour = 'a';
+ function get_html($tree = null) {
+ $this -> autolinks = false;
+ $text = '';
+ foreach ($this -> tree as $val) {
+ if ('text' == $val['type']) { $text .= $val['str']; }
+ }
+ $href = '';
+ if (isset($this -> attrib['url'])) {
+ $href = $this -> attrib['url'];
+ }
+ if (! $href && isset($this -> attrib['a'])) {
+ $href = $this -> attrib['a'];
+ }
+ if (! $href && isset($this -> attrib['href'])) {
+ $href = $this -> attrib['href'];
+ }
+ if (! $href && ! isset($this -> attrib['anchor'])) { $href = $text; }
+ $href = $this -> checkUrl($href);
+ $attr = 'class="bb"';
+ if ($href) {
+ $attr .= ' href="'.$href.'"';
+ }
+ if (isset($this -> attrib['title'])) {
+ $title = $this -> attrib['title'];
+ $attr .= ' title="'.htmlspecialchars($title).'"';
+ }
+ $id = '';
+ if (isset($this -> attrib['id'])) {
+ $id = $this -> attrib['id'];
+ }
+ if (! $id && isset($this -> attrib['name'])) {
+ $id = $this -> attrib['name'];
+ }
+ if (! $id && isset($this -> attrib['anchor'])) {
+ $id = $this -> attrib['anchor'];
+ if (! $id) { $id = $text; }
+ }
+ if ($id) {
+ if ($id{0} < 'A' || $id{0} > 'z') { $id = 'bb'.$id; }
+ $attr .= ' id="'.htmlspecialchars($id).'"';
+ }
+ if (isset($this -> attrib['target'])) {
+ $target = $this -> attrib['target'];
+ $attr .= ' target="'.htmlspecialchars($target).'"';
+ }
+ return '<a '.$attr.'>'.parent::get_html($this -> tree).'</a>';
+ }
+}
+?>
View
35 Xbb/Tags/Abbr.php
@@ -0,0 +1,35 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Abbr.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [abbr]
+class Xbb_Tags_Abbr extends bbcode {
+ public $behaviour = 'span';
+ function get_html($tree = null) {
+ $attrib = 'class="bb"';
+ if ($this -> attrib['abbr']) {
+ $attrib .= ' title="'.htmlspecialchars($this -> attrib['abbr']).'"';
+ }
+ return '<abbr '.$attrib.'>'.parent::get_html($this -> tree).'</abbr>';
+ }
+}
+?>
View
37 Xbb/Tags/Acronym.php
@@ -0,0 +1,37 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Acronym.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [acronym]
+class Xbb_Tags_Acronym extends bbcode {
+ public $behaviour = 'span';
+ function get_html($tree = null) {
+ $attrib = 'class="bb"';
+ if ($this -> attrib['acronym']) {
+ $attrib .= ' title="'.htmlspecialchars($this -> attrib['acronym'])
+ .'"';
+ }
+ return '<acronym '.$attrib.'>'.parent::get_html($this -> tree)
+ .'</acronym>';
+ }
+}
+?>
View
32 Xbb/Tags/Address.php
@@ -0,0 +1,32 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Address.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [address]
+class Xbb_Tags_Address extends bbcode {
+ public $rbr = 1;
+ function get_html($tree = null) {
+ return '<address class="bb">'.parent::get_html($this -> tree)
+ .'</address>';
+ }
+}
+?>
View
53 Xbb/Tags/Align.php
@@ -0,0 +1,53 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Align.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тегов [align], [center], [justify], [left] и [right]
+class Xbb_Tags_Align extends bbcode {
+ public $rbr = 1;
+ function get_html($tree = null) {
+ $align = '';
+ if (isset($this -> attrib['justify'])) { $align = 'justify'; }
+ if (isset($this -> attrib['left'])) { $align = 'left'; }
+ if (isset($this -> attrib['right'])) { $align = 'right'; }
+ if (isset($this -> attrib['center'])) { $align = 'center'; }
+ if (! $align && isset($this -> attrib['align'])) {
+ switch (strtolower($this -> attrib['align'])) {
+ case 'left':
+ $align = 'left';
+ break;
+ case 'right':
+ $align = 'right';
+ break;
+ case 'center':
+ $align = 'center';
+ break;
+ case 'justify':
+ $align = 'justify';
+ break;
+ }
+ }
+ return '<div class="bb" align="'.$align.'">'
+ .parent::get_html($this -> tree).'</div>';
+ }
+}
+?>
View
41 Xbb/Tags/Bbcode.php
@@ -0,0 +1,41 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Bbcode.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [bbcode]
+class Xbb_Tags_Bbcode extends bbcode {
+ public $behaviour = 'code';
+ function get_html($tree = null) {
+ $str = '';
+ foreach ($this -> tree as $item) {
+ if ('item' == $item['type']) { continue; }
+ $str .= $item['str'];
+ }
+ $bb = new bbcode();
+ $bb -> tags = $this -> tags;
+ $bb -> mnemonics = $this -> mnemonics;
+ $bb -> autolinks = $this -> autolinks;
+ $bb -> parse($str);
+ return '<code class="bb_code">'.$bb -> highlight().'</code>';
+ }
+}
+?>
View
48 Xbb/Tags/Bdo.php
@@ -0,0 +1,48 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Bdo.php, v 0.00 2007/04/29 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [bdo]
+class Xbb_Tags_Bdo extends bbcode {
+ public $behaviour = 'span';
+ function get_html($tree = null) {
+ $dir = '';
+ switch (strtolower($this->attrib['bdo'])) {
+ case 'ltr':
+ $dir = 'ltr';
+ break;
+ case 'rtl':
+ $dir = 'rtl';
+ }
+ if (! $dir) {
+ return parent::get_html();
+ }
+ /* <bdo> может иметь следующие атрибуты: dir, lang, id, class, style,
+ title. */
+ $attr = 'dir="' . $dir . '" class="bb"';
+ if (isset($this->attrib['lang'])) {
+ $attr .= ' lang="' . htmlspecialchars($this->attrib['lang']) . '"';
+ }
+ return '<bdo ' . $attr . '>' . parent::get_html() . '</bdo>';
+ }
+}
+?>
View
32 Xbb/Tags/Br.php
@@ -0,0 +1,32 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Br.php, v 0.00 2007/04/29 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [br]
+class Xbb_Tags_Br extends bbcode {
+ public $is_close = true;
+ public $behaviour = 'span';
+ function get_html($tree = null) {
+ return '<br class="bb" />' . "\n";
+ }
+}
+?>
View
32 Xbb/Tags/Caption.php
@@ -0,0 +1,32 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Caption.php, v 0.00 2007/04/20 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [caption]
+class Xbb_Tags_Caption extends bbcode {
+ public $behaviour = 'caption';
+ function get_html($tree = null) {
+ return '<caption class="bb">'.parent::get_html($this -> tree)
+ .'</caption>';
+ }
+}
+?>
View
122 Xbb/Tags/Code.php
@@ -0,0 +1,122 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Code.php, v 0.06 2007/04/29 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+/* Класс для тегов подсветки синтаксиса и для тегов [code] и [pre] */
+class Xbb_Tags_Code extends bbcode {
+ /* Число разрывов строк, которые должны быть игнорированы перед тегом */
+ public $lbr = 0;
+ /* Число разрывов строк, которые должны быть игнорированы после тега */
+ public $rbr = 1;
+ public $behaviour = 'pre';
+ /* Альтернативные названия языков и их трансляция в обозначения GeSHi */
+ public $lang_synonym = array(
+ 'c++' => 'cpp',
+ 'c#' => 'csharp',
+ 'html' => 'html4strict',
+ 'html4' => 'html4strict',
+ 'js' => 'javascript',
+ 'ocaml' => 'ocaml-brief',
+ 'oracle' => 'oracle8',
+ 't-sql' => 'tsql',
+ 'vb.net' => 'vbnet',
+ );
+ /* Объект GeSHi */
+ private $_geshi;
+ /* Конструктор класса */
+ function Xbb_Tags_Code() {
+ $geshi_path = realpath(
+ dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR
+ . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'geshi.php'
+ );
+ @include_once $geshi_path;
+ @$this->_geshi = new GeSHi('', 'text');
+ $this->_geshi->set_header_type(GESHI_HEADER_NONE);
+ }
+ /* Описываем конвертацию в HTML */
+ function get_html($tree = null) {
+ // Находим язык подсветки
+ switch ($this->tag) {
+ case 'code':
+ $language = $this->attrib['code'];
+ break;
+ case 'pre':
+ $language = $this->attrib['pre'];
+ break;
+ default:
+ $language = $this->tag;
+ }
+ if (! $language) { $language = 'text'; }
+ if (isset($this->lang_synonym[$language])) {
+ $language = $this->lang_synonym[$language];
+ }
+ @$this->_geshi->set_language($language);
+ // Находим подсвечиваемый код
+ $source = '';
+ foreach ($this->tree as $item) {
+ if ('item' == $item['type']) { continue; }
+ $source .= $item['str'];
+ }
+ $this->_geshi->set_source($source);
+ // Устанавливаем нумерацию строк
+ if (isset($this->attrib['num'])) {
+ $this->_geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
+ if ('' !== $this -> attrib['num']) {
+ $num = (int) $this->attrib['num'];
+ $this->_geshi->start_line_numbers_at($num);
+ }
+ }
+ // Задаем величину табуляции
+ if (isset($this->attrib['tab'])) {
+ $this->attrib['tab'] = (int) $this->attrib['tab'];
+ if ($this->attrib['tab']) {
+ $this->_geshi -> set_tab_width($this->attrib['tab']);
+ }
+ }
+ // Устанавливаем выделение строк
+ if (isset($this->attrib['extra'])) {
+ $extra = explode(',', $this->attrib['extra']);
+ foreach ($extra as $key => $val) {
+ $extra[$key] = (int) $val;
+ }
+ $this->_geshi->highlight_lines_extra($extra);
+ }
+ // Формируем заголовок
+ $result = '<span class="bb_code_lang">'
+ . $this->_geshi->get_language_name() . '</span>';
+ if (isset($this->attrib['title'])) {
+ $result = htmlspecialchars($this->attrib['title']);
+ }
+ // Получаем подсвеченный код
+ $result = '<div class="bb_code"><div class="bb_code_header">' .$result
+ . '</div>' . $this->_geshi->parse_code();
+ // Формируем подпись под кодом
+ if (isset($this->attrib['footer'])) {
+ $content = htmlspecialchars($this->attrib['footer']);
+ $content = '<div class="bb_code_footer">' . $content . '</div>';
+ $result .= $content;
+ }
+ // Возвращаем результат
+ return $result . '</div>';
+ }
+}
+?>
View
33 Xbb/Tags/Color.php
@@ -0,0 +1,33 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Color.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [color]
+class Xbb_Tags_Color extends bbcode {
+ public $behaviour = 'span';
+ function get_html($tree = null) {
+ $color = htmlspecialchars($this -> attrib['color']);
+ return '<font color="'.$color.'">'.parent::get_html($this -> tree)
+ .'</font>';
+ }
+}
+?>
View
55 Xbb/Tags/Email.php
@@ -0,0 +1,55 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Email.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [email]
+class Xbb_Tags_Email extends bbcode {
+ public $behaviour = 'a';
+ function get_html($tree = null) {
+ $this -> autolinks = false;
+ $attr = ' class="bb_email"';
+ $href = $this -> attrib['email'];
+ if (! $href) {
+ foreach ($this -> tree as $text) {
+ if ('text' == $text['type']) { $href .= $text['str']; }
+ }
+ }
+ $protocols = array('mailto:');
+ $is_http = false;
+ foreach ($protocols as $val) {
+ if ($val == substr($href,0,strlen($val))) {
+ $is_http = true;
+ break;
+ }
+ }
+ if (! $is_http) { $href = 'mailto:'.$href; }
+ if ($href) { $attr .= ' href="'.htmlspecialchars($href).'"'; }
+ $title = isset($this -> attrib['title']) ? $this -> attrib['title'] : '';
+ if ($title) { $attr .= ' title="'.htmlspecialchars($title).'"'; }
+ $name = isset($this -> attrib['name']) ? $this -> attrib['name'] : '';
+ if ($name) { $attr .= ' name="'.htmlspecialchars($name).'"'; }
+ $target = isset($this -> attrib['target']) ? $this -> attrib['target'] : '';
+ if ($target) { $attr .= ' target="'.htmlspecialchars($target).'"'; }
+ return '<a'.$attr.'>'.parent::get_html($this -> tree).'</a>';
+ }
+}
+?>
View
44 Xbb/Tags/Font.php
@@ -0,0 +1,44 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Font.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [font]
+class Xbb_Tags_Font extends bbcode {
+ public $behaviour = 'span';
+ function get_html($tree = null) {
+ $attr = '';
+ if (isset($this -> attrib['face'])) {
+ $face = $this -> attrib['face'];
+ } else {
+ $face = $this -> attrib['font'];
+ }
+ if ($face) {
+ $attr .= ' face="'.htmlspecialchars($face).'"';
+ }
+ $color = isset($this -> attrib['color']) ? $this -> attrib['color'] : '';
+ if ($color) { $attr .= ' color="'.htmlspecialchars($color).'"'; }
+ $size = isset($this -> attrib['size']) ? $this -> attrib['size'] : '';
+ if ($size) { $attr .= ' size="'.htmlspecialchars($size).'"'; }
+ return '<font'.$attr.'>'.parent::get_html($this -> tree).'</font>';
+ }
+}
+?>
View
39 Xbb/Tags/Google.php
@@ -0,0 +1,39 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Google.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [google]
+class Xbb_Tags_Google extends bbcode {
+ public $behaviour = 'a';
+ function get_html($tree = null) {
+ $attr = htmlspecialchars(rawurlencode($this -> attrib['google']));
+ $attr = ' href="http://www.google.com/search?q='.$attr.'"';
+ $title = isset($this -> attrib['title']) ? $this -> attrib['title'] : '';
+ if ($title) { $attr .= ' title="'.htmlspecialchars($title).'"'; }
+ $name = isset($this -> attrib['name']) ? $this -> attrib['name'] : '';
+ if ($name) { $attr .= ' name="'.htmlspecialchars($name).'"'; }
+ $target = isset($this -> attrib['target']) ? $this -> attrib['target'] : '';
+ if ($target) { $attr .= ' target="'.htmlspecialchars($target).'"'; }
+ return '<a class="bb_google" '.$attr.'>'.parent::get_html($this -> tree).'</a>';
+ }
+}
+?>
View
33 Xbb/Tags/Hr.php
@@ -0,0 +1,33 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Hr.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [hr]
+class Xbb_Tags_Hr extends bbcode {
+ public $is_close = true;
+ public $rbr = 1;
+ public $behaviour = 'hr';
+ function get_html($tree = null) {
+ return '<hr class="bb" />';
+ }
+}
+?>
View
49 Xbb/Tags/Img.php
@@ -0,0 +1,49 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Img.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [img]
+class Xbb_Tags_Img extends bbcode {
+ public $behaviour = 'img';
+ function get_html($tree = null) {
+ $attr = 'alt=""';
+ if (isset($this -> attrib['width'])) {
+ $width = (int) $this -> attrib['width'];
+ $attr .= $width ? ' width="'.$width.'"' : '';
+ }
+ if (isset($this -> attrib['height'])) {
+ $height = (int) $this -> attrib['height'];
+ $attr .= $height ? ' height="'.$height.'"' : '';
+ }
+ if (isset($this -> attrib['border'])) {
+ $border = (int) $this -> attrib['border'];
+ $attr .= ' border="'.$border.'"';
+ }
+ $src = '';
+ foreach ($this -> tree as $text) {
+ if ('text' == $text['type']) { $src .= $text['str']; }
+ }
+ $src = $this -> checkUrl($src);
+ return '<img src="'.$src.'" '.$attr.' />';
+ }
+}
+?>
View
36 Xbb/Tags/Li.php
@@ -0,0 +1,36 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Li.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [*]
+class Xbb_Tags_Li extends bbcode {
+ public $behaviour = 'li';
+ function get_html($tree = null) {
+ $attrib = 'class="bb"';
+ if ('' !== $this -> attrib['*']) {
+ $this -> attrib['*'] = (int) $this -> attrib['*'];
+ $attrib .= ' value="'.$this -> attrib['*'].'"';
+ }
+ return '<li '.$attrib.'>'.parent::get_html($this -> tree).'</li>';
+ }
+}
+?>
View
55 Xbb/Tags/List.php
@@ -0,0 +1,55 @@
+<?php
+
+/******************************************************************************
+ * *
+ * List.php, v 0.01 2007/04/29 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тегов [list], [ol], [ul]
+class Xbb_Tags_List extends bbcode {
+ public $lbr = 1;
+ public $rbr = 1;
+ public $behaviour = 'ul';
+ function get_html($tree = null) {
+ $tag_name = 'ul';
+ $type = '';
+ switch ($this->tag) {
+ case 'ol':
+ $tag_name = 'ol';
+ $type = strtolower($this->attrib['ol']);
+ break;
+ case 'list':
+ if ($this->attrib['list']) {
+ $tag_name = 'ol';
+ }
+ $type = strtolower($this->attrib['list']);
+ $this->tag = 'del';
+ }
+ $attr = ' class="bb"';
+ if ('1' == $type) {
+ $attr .= ' type="1"';
+ } elseif ($type) {
+ $attr .= ' type="a"';
+ }
+ $str = '<' . $tag_name . $attr . '>' . parent::get_html() . '</'
+ . $tag_name . '>';
+ return $str;
+ }
+}
+?>
View
38 Xbb/Tags/Nobb.php
@@ -0,0 +1,38 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Nobb.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [nobb]
+class Xbb_Tags_Nobb extends bbcode {
+ public $behaviour = 'code';
+ function get_html($tree = null) {
+ $str = '';
+ foreach ($this -> tree as $item) {
+ if ('text' == $item['type']) {
+ $str .= nl2br(htmlspecialchars($item['str']));
+ }
+ }
+ $str = str_replace(' ', '&nbsp;&nbsp;', $str);
+ return $str;
+ }
+}
+?>
View
36 Xbb/Tags/P.php
@@ -0,0 +1,36 @@
+<?php
+
+/******************************************************************************
+ * *
+ * P.php, v 0.01 2007/04/29 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [p] и тегов [h1], [h2], [h3], [h4], [h5], [h6].
+class Xbb_Tags_P extends bbcode {
+ public $lbr = 2;
+ public $rbr = 2;
+ public $behaviour = 'p';
+ function get_html($tree = null) {
+ $str = "\n<" . $this->tag . ' class="bb"';
+ $align = isset($this->attrib['align']) ? $this->attrib['align'] : '';
+ if ($align) { $str .= ' align="'.htmlspecialchars($align).'"'; }
+ return $str . '>' . parent::get_html() . '</' . $this->tag . ">\n";
+ }
+}
+?>
View
40 Xbb/Tags/Quote.php
@@ -0,0 +1,40 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Quote.php, v 0.01 2007/04/29 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тегов [quote] и [blockquote]
+class Xbb_Tags_Quote extends bbcode {
+ public $rbr = 1;
+ function get_html($tree = null) {
+ if ('blockquote' == $this->tag) {
+ $author = htmlspecialchars($this->attrib['blockquote']);
+ } else {
+ $author = htmlspecialchars($this->attrib['quote']);
+ }
+ if ($author) {
+ $author = '<div class="bb_quote_author">' . $author . '</div>';
+ }
+ return '<blockquote class="bb_quote">' . $author
+ . parent::get_html($this -> tree) . '</blockquote>';
+ }
+}
+?>
View
41 Xbb/Tags/Simple.php
@@ -0,0 +1,41 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Simple.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для простейших тегов
+class Xbb_Tags_Simple extends bbcode {
+ public $behaviour = 'span';
+ function get_html($tree = null) {
+ switch ($this->tag) {
+ case 'b':
+ $this->tag = 'strong';
+ break;
+ case 's':
+ case 'strike':
+ $this->tag = 'del';
+ }
+ $html = '<' . $this->tag . ' class="bb">' . parent::get_html() . '</'
+ . $this->tag . '>';
+ return $html;
+ }
+}
+?>
View
49 Xbb/Tags/Size.php
@@ -0,0 +1,49 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Size.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [size]
+class Xbb_Tags_Size extends bbcode {
+ public $behaviour = 'span';
+ function get_html($tree = null) {
+ $sign = '';
+ if (strlen($this -> attrib['size'])) {
+ $sign = $this -> attrib['size']{0};
+ }
+ if ('+' != $sign) { $sign = ''; }
+ $size = (int) $this -> attrib['size'];
+ if (7 < $size) {
+ $size = 7;
+ $sign = '';
+ }
+ if (-6 > $size) {
+ $size = '-6';
+ $sign = '';
+ }
+ if (0 == $size) {
+ $size = 3;
+ }
+ $size = $sign.$size;
+ return '<font size="'.$size.'">'.parent::get_html($this -> tree).'</font>';
+ }
+}
+?>
View
54 Xbb/Tags/Table.php
@@ -0,0 +1,54 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Table.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [table]
+class Xbb_Tags_Table extends bbcode {
+ public $rbr = 1;
+ public $behaviour = 'table';
+ function get_html($tree = null) {
+ $attr = ' class="bb"';
+ $border = isset($this -> attrib['border'])
+ ? (int) $this -> attrib['border']
+ : null;
+ if (null !== $border) { $attr .= ' border="'.$border.'"'; }
+ $width = isset($this -> attrib['width']) ? $this -> attrib['width'] : '';
+ if ($width) { $attr .= ' width="'.htmlspecialchars($width).'"'; }
+ $cellspacing = isset($this -> attrib['cellspacing'])
+ ? (int) $this -> attrib['cellspacing']
+ : null;
+ if (null !== $cellspacing) { $attr .= ' cellspacing="'.$cellspacing.'"'; }
+ $cellpadding = isset($this -> attrib['cellpadding'])
+ ? (int) $this -> attrib['cellpadding']
+ : null;
+ if (null !== $cellpadding) { $attr .= ' cellpadding="'.$cellpadding.'"'; }
+ $align = isset($this -> attrib['align']) ? $this -> attrib['align'] : '';
+ if ($align) { $attr .= ' align="'.htmlspecialchars($align).'"'; }
+ $str = '<table'.$attr.'>';
+ foreach ($this -> tree as $key => $item) {
+ if ('text' == $item['type']) { unset($this -> tree[$key]); }
+ }
+ $str .= parent::get_html($this -> tree).'</table>';
+ return $str;
+ }
+}
+?>
View
48 Xbb/Tags/Td.php
@@ -0,0 +1,48 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Td.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [td]
+class Xbb_Tags_Td extends bbcode {
+ public $behaviour = 'td';
+ function get_html($tree = null) {
+ $attr = 'class="bb"';
+ $width = isset($this -> attrib['width']) ? $this -> attrib['width'] : '';
+ if ($width) { $attr .= ' width="'.htmlspecialchars($width).'"'; }
+ $height = isset($this -> attrib['height']) ? $this -> attrib['height'] : '';
+ if ($height) { $attr .= ' height="'.htmlspecialchars($height).'"'; }
+ $align = isset($this -> attrib['align']) ? $this -> attrib['align'] : '';
+ if ($align) { $attr .= ' align="'.htmlspecialchars($align).'"'; }
+ $valign = isset($this -> attrib['valign']) ? $this -> attrib['valign'] : '';
+ if ($valign) { $attr .= ' valign="'.htmlspecialchars($valign).'"'; }
+ if (isset($this -> attrib['colspan'])) {
+ $colspan = (int) $this -> attrib['colspan'];
+ if ($colspan) { $attr .= ' colspan="'.$colspan.'"'; }
+ }
+ if (isset($this -> attrib['rowspan'])) {
+ $rowspan = (int) $this -> attrib['rowspan'];
+ if ($rowspan) { $attr .= ' rowspan="'.$rowspan.'"'; }
+ }
+ return '<td '.$attr.'>'.parent::get_html($this -> tree).'</td>';
+ }
+}
+?>
View
48 Xbb/Tags/Th.php
@@ -0,0 +1,48 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Th.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [th]
+class Xbb_Tags_Th extends bbcode {
+ public $behaviour = 'td';
+ function get_html($tree = null) {
+ $attr = ' class="bb"';
+ $width = isset($this -> attrib['width']) ? $this -> attrib['width'] : '';
+ if ($width) { $attr .= ' width="'.htmlspecialchars($width).'"'; }
+ $height = isset($this -> attrib['height']) ? $this -> attrib['height'] : '';
+ if ($height) { $attr .= ' height="'.htmlspecialchars($height).'"'; }
+ $align = isset($this -> attrib['align']) ? $this -> attrib['align'] : '';
+ if ($align) { $attr .= ' align="'.htmlspecialchars($align).'"'; }
+ $valign = isset($this -> attrib['valign']) ? $this -> attrib['valign'] : '';
+ if ($valign) { $attr .= ' valign="'.htmlspecialchars($valign).'"'; }
+ if (isset($this -> attrib['colspan'])) {
+ $colspan = (int) $this -> attrib['colspan'];
+ if ($colspan) { $attr .= ' colspan="'.$colspan.'"'; }
+ }
+ if (isset($this -> attrib['rowspan'])) {
+ $rowspan = (int) $this -> attrib['rowspan'];
+ if ($rowspan) { $attr .= ' rowspan="'.$rowspan.'"'; }
+ }
+ return '<th'.$attr.'>'.parent::get_html($this -> tree).'</th>';
+ }
+}
+?>
View
36 Xbb/Tags/Tr.php
@@ -0,0 +1,36 @@
+<?php
+
+/******************************************************************************
+ * *
+ * Tr.php, v 0.00 2007/04/21 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+// Класс для тега [tr]
+class Xbb_Tags_Tr extends bbcode {
+ public $behaviour = 'tr';
+ function get_html($tree = null) {
+ $str = '<tr class="bb">';
+ foreach ($this -> tree as $key => $item) {
+ if ('text' == $item['type']) { unset($this -> tree[$key]); }
+ }
+ $str .= parent::get_html($this -> tree).'</tr>';
+ return $str;
+ }
+}
+?>
View
83 area.php
@@ -0,0 +1,83 @@
+<?php
+
+/******************************************************************************
+ * *
+ * area.php, v 0.00 2007/07/23 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+<title>xBBArea</title>
+<meta name="author" content="Dmitriy Skorobogatov" />
+<style type="text/css">
+body {
+ font-family: 'Monaco', 'Courier New', monospace;
+ color: #000000;
+ margin: 0px;
+ padding: 0px;
+}
+span.bb_spec_char {
+ color: #000099;
+}
+span.bb_mnemonic {
+ color: #ff0000;
+}
+span.bb_tag {
+ color: #009900;
+}
+span.bb_bracket {
+ font-weight: bold;
+}
+span.bb_slash {
+ font-weight: normal;
+}
+span.bb_tagname {
+ color: #990099;
+}
+span.bb_equal {
+ color: #999900;
+}
+span.bb_quote {
+ color: #009999;
+}
+span.bb_attrib_name {
+ color: #999900;
+}
+span.bb_attrib_val {
+ color: #009999;
+}
+span.bb_autolink {
+ color: #0000ff;
+}
+</style>
+<script type="text/javascript">
+onload = function() {
+ document.designMode = 'on';
+ // Äëÿ Gecko óñòàíàâëèâàåì òàêîé ðåæèì, ÷òîáû ôîðìàòèðîâàíèå ñòàâèëîñü
+ // òåãàìè, à íå ñòèëÿìè. ×òîáû MSIE íå âûäàâàë îøèáêó, ïðÿ÷åì ýòî â
+ // êîíñòðóêöèþ try-catch
+ try {
+ document.execCommand("useCSS", false, true);
+ } catch(e) {}
+}
+</script>
+</head>
View
760 bbcode.lib.js
@@ -0,0 +1,760 @@
+/******************************************************************************
+ * *
+ * bbcode.lib.js, v 0.00 2007/07/25 - This is part of xBB library *
+ * Copyright (C) 2006-2007 Dmitriy Skorobogatov dima@pc.uz *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ * *
+ ******************************************************************************/
+
+function bbcode(code) {
+ /* Текст BBCode */
+ this.text = code;
+ /* Результат синтаксического разбора текста BBCode. */
+ this.syntax = [];
+ /* Список поддерживаемых тегов. */
+ this.tags = [];
+ /* Флажок, включающий/выключающий автоматические ссылки. */
+ this.autolinks = true;
+ /* Массив замен для автоматических ссылок. */
+ this.preg_autolinks = {
+ pattern : [
+ /(\w+:\/\/[A-z0-9\.\?\+\-\/_=&%#:;]+[\w/=]+)/,
+ /([^/])(www\.[A-z0-9\.\?\+\-/_=&%#:;]+[\w/=]+)/,
+ /([\w]+[\w\-\.]+@[\w\-\.]+\.[\w]+)/,
+ ],
+ highlight : [
+ '<' + 'span class="bb_autolink">$1<' + '/span>',
+ '$1<' + 'span class="bb_autolink">$2<' + '/span>',
+ '<' + 'span class="bb_autolink">$1<' + '/span>',
+ ]
+ };
+ /* Подсвечиваемые смайлики и прочие мнемоники. */
+ this.mnemonics = [];
+ /* Основные смайлики, предлагаемые на выбор пользователя. */
+ this.smiles = [];
+ /* Список шрифтов, предлагаемых на выбор пользователя */
+ this.fonts = [];
+ /* Палитра цветов, предлагаемых на выбор пользователя */
+ this.colors = [];
+ /* Id ифрейма с подсвеченным bbcode */
+ this.iframeId = 'xbb_iframe';
+ /* Id textarea с текстом bbcode */
+ this.textareaId = 'xbb_textarea';
+ /*
+ div, используемый как контейнер данных,
+ передаваемых из одного фрема в другой
+ */
+ this.transportDiv = parent.document.getElementById('xbb_transport_div');
+ /*
+ Режим, в котором в данный момент находится редактор. Возможные значения:
+ 'plain' (textarea) или 'highlight' (подсветка синтаксиса)
+ */
+ this.state = 'plain';
+ /* Для нужд парсера. - Позиция очередного обрабатываемого символа. */
+ var _cursor = 0;
+ /*
+ get_token() - Функция парсит текст BBCode и возвращает очередную пару
+
+ "число (тип лексемы) - лексема"
+
+ Лексема - подстрока строки this.text, начинающаяся с позиции _cursor
+ Типы лексем могут быть следующие:
+
+ 0 - открывющая квадратная скобка ("[")
+ 1 - закрывающая квадратная cкобка ("]")
+ 2 - двойная кавычка ('"')
+ 3 - апостроф ("'")
+ 4 - равенство ("=")
+ 5 - прямой слэш ("/")
+ 6 - последовательность пробельных символов
+ (" ", "\t", "\n", "\r", "\0" или "\x0B")
+ 7 - последовательность прочих символов, не являющаяся именем тега
+ 8 - имя тега
+ */
+ this.get_token = function() {
+ var token = '';
+ var token_type = NaN;
+ var char_type = NaN;
+ var cur_char;
+ while (true) {
+ token_type = char_type;
+ if (! this.text.charAt(_cursor)) {
+ if (isNaN(char_type)) {
+ return false;
+ } else {
+ break;
+ }
+ }
+ cur_char = this.text.charAt(_cursor);
+ switch (cur_char) {
+ case '[':
+ char_type = 0;
+ break;
+ case ']':
+ char_type = 1;
+ break;
+ case '"':
+ char_type = 2;
+ break;
+ case "'":
+ char_type = 3;
+ break;
+ case "=":
+ char_type = 4;
+ break;
+ case '/':
+ char_type = 5;
+ break;
+ case ' ':
+ char_type = 6;
+ break;
+ case "\t":
+ char_type = 6;
+ break;
+ case "\n":
+ char_type = 6;
+ break;
+ case "\r":
+ char_type = 6;
+ break;
+ case "\0":
+ char_type = 6;
+ break;
+ case "\x0B":
+ char_type = 6;
+ break;
+ default:
+ char_type = 7;
+ }
+ if (isNaN(token_type)) {
+ token = cur_char;
+ } else if (5 >= token_type) {
+ break;
+ } else if (char_type == token_type) {
+ token += cur_char;
+ } else {
+ break;
+ }
+ _cursor += 1;
+ }
+ if (this.in_array(token.toLowerCase(), this.tags)) {
+ token_type = 8;
+ }
+ return [token_type, token];
+ }
+
+ this.parse = function(code) {
+ if (code) { this.text = code; }
+ /*
+ Используем метод конечных автоматов
+ Список возможных состояний автомата:
+ 0 - Начало сканирования или находимся вне тега. Ожидаем что угодно.
+ 1 - Встретили символ "[", который считаем началом тега. Ожидаем имя
+ тега, или символ "/".
+ 2 - Нашли в теге неожидавшийся символ "[". Считаем предыдущую строку
+ ошибкой. Ожидаем имя тега, или символ "/".
+ 3 - Нашли в теге синтаксическую ошибку. Текущий символ не является "[".
+ Ожидаем что угодно.
+ 4 - Сразу после "[" нашли символ "/". Предполагаем, что попали в
+ закрывающий тег. Ожидаем имя тега или символ "]".
+ 5 - Сразу после "[" нашли имя тега. Считаем, что находимся в
+ открывающем теге. Ожидаем пробел или "=" или "/" или "]".
+ 6 - Нашли завершение тега "]". Ожидаем что угодно.
+ 7 - Сразу после "[/" нашли имя тега. Ожидаем "]".
+ 8 - В открывающем теге нашли "=". Ожидаем пробел или значение атрибута.
+ 9 - В открывающем теге нашли "/", означающий закрытие тега. Ожидаем
+ "]".
+ 10 - В открывающем теге нашли пробел после имени тега или имени
+ атрибута. Ожидаем "=" или имя другого атрибута или "/" или "]".
+ 11 - Нашли '"' начинающую значение атрибута, ограниченное кавычками.
+ Ожидаем что угодно.
+ 12 - Нашли "'" начинающий значение атрибута, ограниченное апострофами.
+ Ожидаем что угодно.
+ 13 - Нашли начало незакавыченного значения атрибута. Ожидаем что угодно.
+ 14 - В открывающем теге после "=" нашли пробел. Ожидаем значение
+ атрибута.
+ 15 - Нашли имя атрибута. Ожидаем пробел или "=" или "/" или "]".
+ 16 - Находимся внутри значения атрибута, ограниченного кавычками.
+ Ожидаем что угодно.
+ 17 - Завершение значения атрибута. Ожидаем пробел или имя следующего
+ атрибута или "/" или "]".
+ 18 - Находимся внутри значения атрибута, ограниченного апострофами.
+ Ожидаем что угодно.
+ 19 - Находимся внутри незакавыченного значения атрибута. Ожидаем что
+ угодно.
+ 20 - Нашли пробел после значения атрибута. Ожидаем имя следующего
+ атрибута или "/" или "]".
+
+ Описание конечного автомата:
+ */
+ var finite_automaton = {
+ // Предыдущие | Состояния для текущих событий (лексем) |
+ // состояния | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
+ 0 : [ 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
+ , 1 : [ 2 , 3 , 3 , 3 , 3 , 4 , 3 , 3 , 5 ]
+ , 2 : [ 2 , 3 , 3 , 3 , 3 , 4 , 3 , 3 , 5 ]
+ , 3 : [ 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
+ , 4 : [ 2 , 6 , 3 , 3 , 3 , 3 , 3 , 3 , 7 ]
+ , 5 : [ 2 , 6 , 3 , 3 , 8 , 9 , 10 , 3 , 3 ]
+ , 6 : [ 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
+ , 7 : [ 2 , 6 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ]
+ , 8 : [ 13 , 13 , 11 , 12 , 13 , 13 , 14 , 13 , 13 ]
+ , 9 : [ 2 , 6 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ]
+ , 10 : [ 2 , 6 , 3 , 3 , 8 , 9 , 3 , 15 , 15 ]
+ , 11 : [ 16 , 16 , 17 , 16 , 16 , 16 , 16 , 16 , 16 ]
+ , 12 : [ 18 , 18 , 18 , 17 , 18 , 18 , 18 , 18 , 18 ]
+ , 13 : [ 19 , 6 , 19 , 19 , 19 , 19 , 17 , 19 , 19 ]
+ , 14 : [ 2 , 3 , 11 , 12 , 13 , 13 , 3 , 13 , 13 ]
+ , 15 : [ 2 , 6 , 3 , 3 , 8 , 9 , 10 , 3 , 3 ]
+ , 16 : [ 16 , 16 , 17 , 16 , 16 , 16 , 16 , 16 , 16 ]
+ , 17 : [ 2 , 6 , 3 , 3 , 3 , 9 , 20 , 15 , 15 ]
+ , 18 : [ 18 , 18 , 18 , 17 , 18 , 18 , 18 , 18 , 18 ]
+ , 19 : [ 19 , 6 , 19 , 19 , 19 , 19 , 20 , 19 , 19 ]
+ , 20 : [ 2 , 6 , 3 , 3 , 3 , 9 , 3 , 15 , 15 ]
+ };
+ // Закончили описание конечного автомата
+ var mode = 0;
+ this.syntax = [];
+ var decomposition = {};
+ var token_key = -1;
+ var value = '';
+ var previous_mode;
+ var type;
+ var name;
+ _cursor = 0;
+ var token = this.get_token();
+ // Сканируем массив лексем с помощью построенного автомата:
+ while (token) {
+ previous_mode = mode;
+ mode = finite_automaton[previous_mode][token[0]];
+ if (-1 < token_key) {
+ type = this.syntax[token_key].type;
+ } else {
+ type = false;
+ }
+ switch (mode) {
+ case 0:
+ if ('text' == type) {
+ this.syntax[token_key].str += token[1];
+ } else {
+ this.syntax[++token_key] = {
+ type : 'text',
+ str : token[1]
+ };
+ }
+ break;
+ case 1:
+ decomposition = {
+ name : '',
+ type : '',
+ str : '[',
+ layout : [[0, '[']]
+ };
+ break;
+ case 2:
+ if ('text' == type) {
+ this.syntax[token_key].str += decomposition.str;
+ } else {
+ this.syntax[++token_key] = {
+ type : 'text',
+ str : decomposition.str
+ };
+ }
+ decomposition = {
+ name : '',
+ type : '',
+ str : '[',
+ layout : [[0, '[']]
+ };
+ break;
+ case 3:
+ if ('text' == type) {
+ this.syntax[token_key].str += decomposition.str;
+ this.syntax[token_key].str += token[1];
+ } else {
+ this.syntax[++token_key] = {
+ type : 'text',
+ str : decomposition.str + token[1]
+ };
+ }
+ decomposition = {};
+ break;
+ case 4:
+ decomposition.type = 'close';
+ decomposition.str += '/';
+ decomposition.layout[decomposition.layout.length] = [1, '/'];
+ break;
+ case 5:
+ decomposition.type = 'open';
+ name = token[1].toLowerCase();
+ decomposition.name = name;
+ decomposition.str += token[1];
+ decomposition.layout[decomposition.layout.length] = [2, token[1]];
+ if (! decomposition.attrib) {
+ decomposition.attrib = {};
+ }
+ decomposition.attrib[name] = '';
+ break;
+ case 6:
+ if (! decomposition.name) {
+ decomposition.name = '';
+ }
+ if (13 == previous_mode || 19 == previous_mode) {
+ decomposition.layout[decomposition.layout.length] = [7, value];
+ }
+ decomposition.str += ']';
+ decomposition.layout[decomposition.layout.length] = [0, ']'];
+ this.syntax[++token_key] = decomposition;
+ decomposition = {};
+ break;
+ case 7:
+ decomposition.name = token[1].toLowerCase();
+ decomposition.str += token[1];
+ decomposition.layout[decomposition.layout.length] = [2, token[1]];
+ break;
+ case 8:
+ decomposition.str += '=';
+ decomposition.layout[decomposition.layout.length] = [3, '='];
+ break;
+ case 9:
+ decomposition.type = 'open/close';
+ decomposition.str += '/';
+ decomposition.layout[decomposition.layout.length] = [1, '/'];
+ break;
+ case 10:
+ decomposition.str += token[1];
+ decomposition.layout[decomposition.layout.length] = [4, token[1]];
+ break;
+ case 11:
+ decomposition.str += '"';
+ decomposition.layout[decomposition.layout.length] = [5, '"'];
+ value = '';
+ break;
+ case 12:
+ decomposition.str += "'";
+ decomposition.layout[decomposition.layout.length] = [5, "'"];
+ value = '';
+ break;
+ case 13:
+ if (! decomposition.attrib) {
+ decomposition.attrib = {};
+ }
+ decomposition.attrib[name] = token[1];
+ value = token[1];
+ decomposition.str += token[1];
+ break;
+ case 14:
+ decomposition.str += token[1];