资源说明:git mirror
>**Note**
>If your escaping strategy is set to `on`: (this is the default case for symfony 1.3 and 1.4)
>
> # settings.yml
> # Output escaping settings
> escaping_strategy: on # Determines how variables are made ...
>
>You will have to call the `getRawValue()` function on your parser object in order
>not to have the output escaped:
>
> [php]
> getRawValue()->qparse('[b]Bold[/b]'); ?>
Extend the plugin
=================
If you want to create your own filters, let's say the filter called `myFilter`:
* Create the class `sfBBCodeParser_Filter_myFilter``in your lib/ directory
* Add this filter in the `config/bb_code_parser_config.yml` file
* Add the related tags in the `config/bb_code_parser_tags.yml`
>**Note**
>To know how to implement your filter class, look at the standard filter classes
>like `sfBBCodeParser_Filter_Email` provided by the plugin and check
>[the library API on the PEAR website](http://pear.php.net/package/HTML_BBCodeParser/docs/latest/).
Demo
====
If you want to see the demo, enable the `sfBBCodeParser` module in your `settings.yml`
file, then call the `/sfBBCodeParser` URL. (If you have desactivated the default symfony routes,
a `routing.yml` file is included in the `config` folder of the plugin. (copy/paste it
in the `routing.yml` of your application.
You can also check the live demo on my [symfony blog](http://snippets.strangebuzz.com/sfBBCodeParser).
>**Note**
>If the demo doesn't work, check the note above about the escaping strategy of your
>application.
TODO
====
* Check and correct the bugs in the [PEAR bug tracker](http://pear.php.net/bugs/search.php?cmd=display&package_name[]=HTML_BBCodeParser).
Support
=======
Please report bugs on the symfony TRAC, I can also answer if you ask on the symfony
mailing list.
See you. [COil](http://www.strangebuzz.com) :)
Changelog
=========
>**Note**
>Check the changelog TAB
Bugs
====
* The `img` tag doesn't allow to have spaces in alt or title attributes.
----
This plugin is sponsored by [SQL Technologies](http://www.sqltechnologies.com)
![SQL Technologies](http://www.php-debug.com/images/sql.gif)
sfBBCodeParserPlugin -------------------- The **sfBBCodeParserPlugin** allows you to parse *BBCode* and get the corresponding html output. There are 6 available filters which provide the following tags: * Basic (b, i, u, s, sub, sup) * Extended (color, size, font, align, quote, code, h1 to h6) * Images (img) * Links (url) * Lists (list, ulist, li) * Email (email) You can activate the filters you want. For each filter you can also decide which tags can be used. And finally you can make your own filters with your own tags. Almost everything can be configured in the plugin, filters, tags, attributes, opening and closing character... The plugin is based on the [PEAR library HTML_BBCodeParser](http://pear.php.net/package/HTML_BBCodeParser) but the PEAR dependencies were removed so you don't have to install it in order to use the plugin. Installation ============ * Install the plugin $ symfony plugin:install sfBBCodeParserPlugin (or download and unzip in your /plugins directory or checkout with [SVN](http://svn.symfony-project.com/plugins/sfBBCodeParserPlugin/trunk/)) * Clear your cache $ symfony cc Configuration ============= The plugins comes with 2 configurations files: * `config/bb_code_parser_config.yml`: contains the main configuration config: quotestyle: "double" quotewhat: "all" open: "[" close: "]" xmlclose: true filters: "Basic,Extended,Images,Links,Lists,Email" * `config/bb_code_parser_tags.yml`: contains the configuration for the filters and their tags. filters: Basic: b: htmlopen: "strong" htmlclose: "strong" allowed: "all" attributes: { } i: htmlopen: "em" htmlclose: "em" allowed: "all" attributes: { } # ... To customize the configuration, just copy these 2 files into the `config` folder of your project or your application. They will automatically override the one provided by the plugin. Then, feel free to add/delete filters, add/delete tags... Usage ===== * Instantiate a `sfBBCodeParser` object: [php] // actions.class.php $this->bb_parser = new sfBBCodeParser(); * Then use the `qparse` function of the object: [php] // indexSuccess.phpsfBBCodeParser demo
Basic filter |
||
[b]Bold[/b] | : | qparse('[b]Bold[/b]'); ?> |
[i]Italic[/i] | : | qparse('[i]Italic[/i]'); ?> |
[i]Underline[/i] | : | qparse('[i]Underline[/i]'); ?> |
[s]Strike[/s] | : | qparse('[s]Strike[/s]'); ?> |
Normal [sub]Sub[/sub] | : | qparse('Normal [sub]Sub[/sub]'); ?> |
Normal [sup]Sup[/sup] | : | qparse('Normal [sup]Sup[/sup]'); ?> |
Extended filter |
||
[color="#FF7F50"]Color #FF7F50[/color] | : | qparse('[color="#FF7F50"]Color #FF7F50[/color]'); ?> |
[size="18"]Size 18[/size] | : | qparse('[size="18"]Size 18[/size]'); ?> |
[font="Tahoma"]font Tahoma[/font] | : | qparse('[font="Tahoma"]font Tahoma[/font]'); ?> |
[align="center"]Align center[/align] | : | qparse('[align="center"]Align center[/align]'); ?> |
[code]$php = "good"[/code] | : | qparse('[code]$php = "good"[/code]'); ?> |
[quote="COil"]This is a good plugin ! :)[/quote] | : | qparse('[quote="COil"]This is a good plugin ! :)[/quote]'); ?> |
[h1]Title 1[/h1] | : | qparse('[h1]Title 1[/h1]'); ?> |
[h2]Title 2[/h2] | : | qparse('[h2]Title 2[/h2]'); ?> |
[h3]Title 3[/h3] | : | qparse('[h3]Title 3[/h3]'); ?> |
[h4]Title 4[/h4] | : | qparse('[h4]Title 4[/h4]'); ?> |
[h5]Title 5[/h5] | : | qparse('[h5]Title 5[/h5]'); ?> |
[h6]Title 6[/h6] | : | qparse('[h6]Title 6[/h6]'); ?> |
Images |
||
[img src="http://www.symfony-project.org/downloads/logos/symfony.gif" alt="Symfony_logo" title="Symfony_rocks!"][/img] | : | qparse('[img src="http://www.symfony-project.org/downloads/logos/symfony.gif" alt="Symfony_logo" title="Symfony_rocks!"][/img]'); ?> |
Links |
||
[url href="http://www.symfony-project.org/plugins/sfBBCodeParserPlugin"] Back to plugin homepage [/url] | : | qparse('[url href="http://www.symfony-project.org/plugins/sfBBCodeParserPlugin"]Back to plugin homepage[/url]'); ?> |
Lists |
||
[list][*]Element 1 [*]Element 2[/list] | : | qparse('[list][*]Element 1 [*]Element 2[/list]'); ?> |
[ulist][*]Element 1 [*]Element 2[/list] | : | qparse('[ulist][*]Element 1 [*]Element 2[/ulist]'); ?> |
[li]Element 1[/li][li]Element 2[/li] | : | qparse('[li]Element 3[/li][li]Element 4[/li]'); ?> |
[email="toto@domain.com"]toto@domain.com[/email] | qparse('[email="toto@domain.com"]toto@domain.com[/email]'); ?> |
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。