BBCODE

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • ok, hast recht..

    hab dir noch 2 extra dateien aus der Doku erstellt, danach sollte es funkionieren
    kopiere erstmal die beiden klassen dateien in den ordner bbcode
    dann kopiere die datei easy-coding-parser.php in den ordner bbcode

    daraufhin kannst du den inhalt der datei test.php überall verändern (gegebenfalls den pfad ändern)

    test.php

    Quellcode

    1. <?
    2. define('DIR','bbcode');
    3. require_once (DIR.'/easy-coding-parser.php');
    4. echo $bbcode->parse ('[b]Dies ist ein Test![/b]');
    5. ?>


    bbcode/easy-coding-parser.php

    Quellcode

    1. <?
    2. // Zeilenumbrüche verschiedener Betriebsysteme vereinheitlichen
    3. function convertlinebreaks ($text) {
    4. return preg_replace ("/\015\01 2|\015|\012/", "\n", $text);
    5. }
    6. // Alles bis auf Neuezeile-Zeichen entfernen
    7. function bbcode_stripcontents ($text) {
    8. return preg_replace ("/[^\n]/", '', $text);
    9. }
    10. function do_bbcode_url ($action, $attributes, $content, $params, $node_object) {
    11. if ($action == 'validate') {
    12. return true;
    13. }
    14. if (!isset ($attributes['default'])) {
    15. return '<a href="'.htmlspecialchars ($content).'">'.htmlspecialchars ($content).'</a>';
    16. }
    17. return '<a href="'.htmlspecialchars ($attributes['default']).'">'.$content.'</a>';
    18. }
    19. // Funktion zum Einbinden von Bildern
    20. function do_bbcode_img ($action, $attributes, $content, $params, $node_object) {
    21. if ($action == 'validate') {
    22. return true;
    23. }
    24. return '<img src="'.htmlspecialchars($content).'" alt="">';
    25. }
    26. require_once(DIR.'/stringparser_bbcode.class.php');
    27. $bbcode = new StringParser_BBCode ();
    28. $bbcode->addFilter (STRINGPARSER_FILTER_PRE, 'convertlinebreaks');
    29. $bbcode->addParser (array ('block', 'inline', 'link', 'listitem'), 'htmlspecialchars');
    30. $bbcode->addParser (array ('block', 'inline', 'link', 'listitem'), 'nl2br');
    31. $bbcode->addParser ('list', 'bbcode_stripcontents');
    32. $bbcode->addCode ('b', 'simple_replace', null, array ('start_tag' => '<b>', 'end_tag' => '</b>'),
    33. 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
    34. $bbcode->addCode ('i', 'simple_replace', null, array ('start_tag' => '<i>', 'end_tag' => '</i>'),
    35. 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
    36. $bbcode->addCode ('url', 'usecontent?', 'do_bbcode_url', array ('usecontent_param' => 'default'),
    37. 'link', array ('listitem', 'block', 'inline'), array ('link'));
    38. $bbcode->addCode ('link', 'callback_replace_single', 'do_bbcode_url', array (),
    39. 'link', array ('listitem', 'block', 'inline'), array ('link'));
    40. $bbcode->addCode ('img', 'usecontent', 'do_bbcode_img', array (),
    41. 'image', array ('listitem', 'block', 'inline', 'link'), array ());
    42. $bbcode->addCode ('bild', 'usecontent', 'do_bbcode_img', array (),
    43. 'image', array ('listitem', 'block', 'inline', 'link'), array ());
    44. $bbcode->setOccurrenceType ('img', 'image');
    45. $bbcode->setOccurrenceType ('bild', 'image');
    46. $bbcode->setMaxOccurrences ('image', 2);
    47. $bbcode->addCode ('list', 'simple_replace', null, array ('start_tag' => '<ul>', 'end_tag' => '</ul>'),
    48. 'list', array ('block', 'listitem'), array ());
    49. $bbcode->addCode ('*', 'simple_replace', null, array ('start_tag' => '<li>', 'end_tag' => '</li>'),
    50. 'listitem', array ('list'), array ());
    51. $bbcode->setCodeFlag ('*', 'closetag', BBCODE_CLOSETAG_OPTIONAL);
    52. $bbcode->setCodeFlag ('*', 'paragraphs', true);
    53. $bbcode->setCodeFlag ('list', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
    54. $bbcode->setCodeFlag ('list', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
    55. $bbcode->setCodeFlag ('list', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
    56. $bbcode->setRootParagraphHandling (true);
    57. ?>
    Alles anzeigen
    Dateien
  • was verstehst du unter einem editor für websiten?
    Suchst du ein content management system, dass bbcode kann?

    oder willst du einen fertigen code aus textarea und buttons haben?
    ich nehme an du willst 2teres.. dazu gibt es auch eine lösung von der bbCode homepage bzw. selfhtml

    http://aktuell.de.selfhtml.org/tippstricks/javascript/bbcode/
    einfach den javascript part in eine externe auslagern:
    z.B. bbform.js (wie angehängt)

    danach per

    Quellcode

    1. <script type="text/javascript" src="bbcode.js"></script>
    einbinden

    und die buttons nacheinander einbauen..

    Quellcode

    1. <form name="formular" action="">
    2. <p /><textarea name="eingabe" cols="30" rows="10">Ihre Nachricht</textarea></p>
    3. <p />
    4. <input type="button" value="Link Einfügen" onClick="insert('[url]', '[/url]')">
    5. <input type="button" value="Bild Einfügen" onClick="insert('[img]', '[/img]')">
    6. <input type="button" value="F" onClick="insert('[b]', '[/b]')">
    7. <input type="button" value="K" onClick="insert('[i]', '[/i]')">
    8. <input type="button" value="U" onClick="insert('[u]', '[/u]')">
    9. </form>
    Dateien
    • bbform.js

      (1,83 kB, 482 mal heruntergeladen, zuletzt: )
  • Hey,

    ich war ja damals der der auch danach gefragt hatte.

    Im end effekt ist doch der Java [coderwiki]bbCode[/coderwiki] um einiges Leichter zu verstehen oder?
    Also anhand deinen Beispielen Donut.
    Und das ganze ist nicht so sehr aufwendig finde ich ;).

    //EDIT: Hey, ich habe das ma eingebut alles wie es sein soll aber die Buttons fügen das nicht ein!!!: schau

    http://www.tut-base.net/?activ=contact


    greetZ Shorty
    --Kommt noch--