zikula-modules / bbcode Goto Github PK
View Code? Open in Web Editor NEWBBCode hook for Zikula
BBCode hook for Zikula
I have data in a module (Intercom) with data in, it migrated from phpbb, that uses BBCode. Is there a way to display BBCode in modules without direct hook support? I am thinking maybe I can write a smarty modifier plugin or something... Any other suggestions?
Please consider adding a YouTube? code which allows users to grab the embed url from a video page
[YouTube?]embed_urlYouTube
I know that if ticket #4 were implemented this would happen, but seems it would be simpler to add one very popular item than to write a plugin interface.
Thanks for considering.
Change History
comment:1 Changed 13 months ago by phaidon
I have add this function to the new Zikula 1.3 module of BBCode. If you can't wait here a patch for the old version:
Open pnuserapi.php
Add
// [youtube] and [/youtube] for youtube videos.
$message = preg_replace("/youtube[/youtube]/si", '<iframe class="youtube-player" type="" width="560" height="340" src="http://www.youtube.com/embed/\\1" frameborder="0"></iframe>', $message);
After
// [b] and [/b] for bolding text.
$message = preg_replace("/b[/b]/si", "\1", $message);
Open pntemplates/BBCode_user_bbcodes.tpl
Add
<input title="{gt text='Insert youtube video' domain="module_bbcode"}" type="button" accesskey="c" name="youtube_{$counter}" value=" {gt text='Youtube' domain="module_bbcode"} " class="BBCode_button" onclick="AddBBCode('{$textfieldid}', 'youtube')" />
After
<input title="{gt text='Insert code' domain="module_bbcode"}" type="button" accesskey="c" name="code_{$counter}" value=" {gt text='Code' domain="module_bbcode"} " class="BBCode_button" onclick="AddBBCode('{$textfieldid}', 'code')" />
Open pnjavascript/bbcode.js
Add
case "youtube":
aTag = "[youtube]";
eTag = "[/youtube]";
break;
After
case "bold":
aTag = "[b]";
eTag = "[/b]";
break;
If you want to use BBCode in Dizkus you have to edit this module, too.
Open bootstrap.php
Add
$text = str_replace('<iframe class="youtube-player" type="" width="560" height="340" src="http://www.youtube.com/embed/', '[youtube]', $text); $text = str_replace('" frameborder="0"></iframe>', '[/youtube]', $text);
Before
case "bold":
// the real work
$text = nl2br(DataUtil::formatForDisplayHTML($text));
Add
$text = preg_replace("/youtube[/youtube]/si", '<iframe class="youtube-player" type="" width="560" height="340" src="http://www.youtube.com/embed/\\1" frameborder="0"></iframe>', $text);
After
case "bold":
// the real work
$text = nl2br(DataUtil::formatForDisplayHTML($text));
Seems like BBCode hooks code does not work with current Zikula master
During installation I've got:
Fatal error: Class 'Zikula_Version_HookProviderBundle' not found in \src\modules\BBCode\lib\BBCode\Version.php on line 29
There's more such errors.
ajax edit fails with (also affect BBSmile)
'Argument 1 passed to BBSmile_HookHandlers::uifilter() must be an instance of Zikula_FilterHook, instance of Zikula\Core\Hook\FilterHook given', '/home/ntq/public_html/core/src/modules/BBSmile/lib/BBSmile/HookHandlers.php'
<h1>Whoops, looks like something went wrong.</h1>
<div class="block_exception clear_fix">
<h2><span>1/1</span> <abbr title="Symfony\Component\Debug\Exception\ContextErrorException">ContextErrorException</abbr>: Catchable Fatal Error: Argument 1 passed to BBSmile_HookHandlers::uifilter() must be an instance of Zikula_FilterHook, instance of Zikula\Core\Hook\FilterHook given in /home/ntq/public_html/core/src/modules/BBSmile/lib/BBSmile/HookHandlers.php line 87</h2>
</div>
<div class="block">
<ol class="traces list_exception">
<li> in /home/ntq/public_html/core/src/modules/BBSmile/lib/BBSmile/HookHandlers.php line 87</li>
<li>at <abbr title="Symfony\Component\Debug\ErrorHandler">ErrorHandler</abbr>->handle('4096', 'Argument 1 passed to BBSmile_HookHandlers::uifilter() must be an instance of Zikula_FilterHook, instance of Zikula\Core\Hook\FilterHook given', '/home/ntq/public_html/core/src/modules/BBSmile/lib/BBSmile/HookHandlers.php', '87', <em>array</em>()) in /home/ntq/public_html/core/src/modules/BBSmile/lib/BBSmile/HookHandlers.php line 87</li>
<li>at <abbr title="BBSmile_HookHandlers">BBSmile_HookHandlers</abbr>->uifilter(<em>object</em>(<abbr title="Zikula\Core\Hook\FilterHook">FilterHook</abbr>), 'dizkus.filter_hooks.post.filter', <em>object</em>(<abbr title="Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher">TraceableEventDispatcher</abbr>))</li>
<li>at <abbr title=""></abbr>call_user_func(<em>array</em>(<em>object</em>(<abbr title="BBSmile_HookHandlers">BBSmile_HookHandlers</abbr>), 'uifilter'), <em>object</em>(<abbr title="Zikula\Core\Hook\FilterHook">FilterHook</abbr>), 'dizkus.filter_hooks.post.filter', <em>object</em>(<abbr title="Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher">TraceableEventDispatcher</abbr>)) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 388</li>
<li>at <abbr title="Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher">TraceableEventDispatcher</abbr>->Symfony\Component\HttpKernel\Debug\{closure}(<em>object</em>(<abbr title="Zikula\Core\Hook\FilterHook">FilterHook</abbr>), 'dizkus.filter_hooks.post.filter', <em>object</em>(<abbr title="Zikula_EventManager">Zikula_EventManager</abbr>))</li>
<li>at <abbr title=""></abbr>call_user_func(<em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Zikula\Core\Hook\FilterHook">FilterHook</abbr>), 'dizkus.filter_hooks.post.filter', <em>object</em>(<abbr title="Zikula_EventManager">Zikula_EventManager</abbr>)) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 164</li>
<li>at <abbr title="Symfony\Component\EventDispatcher\EventDispatcher">EventDispatcher</abbr>->doDispatch(<em>array</em>(<em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Closure">Closure</abbr>)), 'dizkus.filter_hooks.post.filter', <em>object</em>(<abbr title="Zikula\Core\Hook\FilterHook">FilterHook</abbr>)) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 53</li>
<li>at <abbr title="Symfony\Component\EventDispatcher\EventDispatcher">EventDispatcher</abbr>->dispatch('dizkus.filter_hooks.post.filter', <em>object</em>(<abbr title="Zikula\Core\Hook\FilterHook">FilterHook</abbr>)) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php line 167</li>
<li>at <abbr title="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">ContainerAwareEventDispatcher</abbr>->dispatch('dizkus.filter_hooks.post.filter', <em>object</em>(<abbr title="Zikula\Core\Hook\FilterHook">FilterHook</abbr>), <em>null</em>) in /home/ntq/public_html/core/src/lib/legacy/Zikula/EventManager.php line 99</li>
<li>at <abbr title="Zikula_EventManager">Zikula_EventManager</abbr>->dispatch('dizkus.filter_hooks.post.filter', <em>object</em>(<abbr title="Zikula\Core\Hook\FilterHook">FilterHook</abbr>)) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 138</li>
<li>at <abbr title="Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher">TraceableEventDispatcher</abbr>->dispatch('dizkus.filter_hooks.post.filter', <em>object</em>(<abbr title="Zikula\Core\Hook\FilterHook">FilterHook</abbr>)) in /home/ntq/public_html/core/src/lib/legacy/Zikula/HookDispatcher.php line 103</li>
<li>at <abbr title="Zikula_HookDispatcher">Zikula_HookDispatcher</abbr>->dispatch('dizkus.filter_hooks.post.filter', <em>object</em>(<abbr title="Zikula\Core\Hook\FilterHook">FilterHook</abbr>)) in /home/ntq/public_html/core/src/lib/legacy/Zikula/AbstractController.php line 124</li>
<li>at <abbr title="Zikula_AbstractController">Zikula_AbstractController</abbr>->dispatchHooks('dizkus.filter_hooks.post.filter', <em>object</em>(<abbr title="Zikula\Core\Hook\FilterHook">FilterHook</abbr>)) in /home/ntq/public_html/core/src/modules/dizkus-module/Zikula/Module/DizkusModule/Controller/AjaxController.php line 277</li>
<li>at <abbr title="Zikula\Module\DizkusModule\Controller\AjaxController">AjaxController</abbr>->updatepostAction()</li>
<li>at <abbr title=""></abbr>call_user_func_array(<em>array</em>(<em>object</em>(<abbr title="Zikula\Module\DizkusModule\Controller\AjaxController">AjaxController</abbr>), 'updatepostAction'), <em>array</em>()) in /home/ntq/public_html/core/src/lib/util/ModUtil.php line 1151</li>
<li>at <abbr title="ModUtil">ModUtil</abbr>::exec('ZikulaDizkusModule', 'ajax', 'updatepost', <em>array</em>(), <em>false</em>, <em>null</em>) in /home/ntq/public_html/core/src/lib/util/ModUtil.php line 1203</li>
<li>at <abbr title="ModUtil">ModUtil</abbr>::func('ZikulaDizkusModule', 'ajax', 'updatepost') in /home/ntq/public_html/core/src/lib/Zikula/Bundle/CoreBundle/EventListener/LegacyRouteListener.php line 182</li>
<li>at <abbr title="Zikula\Bundle\CoreBundle\EventListener\LegacyRouteListener">LegacyRouteListener</abbr>->ajax(<em>object</em>(<abbr title="Symfony\Component\HttpKernel\Event\GetResponseEvent">GetResponseEvent</abbr>)) in /home/ntq/public_html/core/src/lib/Zikula/Bundle/CoreBundle/EventListener/LegacyRouteListener.php line 78</li>
<li>at <abbr title="Zikula\Bundle\CoreBundle\EventListener\LegacyRouteListener">LegacyRouteListener</abbr>->onKernelRequest(<em>object</em>(<abbr title="Symfony\Component\HttpKernel\Event\GetResponseEvent">GetResponseEvent</abbr>), 'kernel.request', <em>object</em>(<abbr title="Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher">TraceableEventDispatcher</abbr>))</li>
<li>at <abbr title=""></abbr>call_user_func(<em>array</em>(<em>object</em>(<abbr title="Zikula\Bundle\CoreBundle\EventListener\LegacyRouteListener">LegacyRouteListener</abbr>), 'onKernelRequest'), <em>object</em>(<abbr title="Symfony\Component\HttpKernel\Event\GetResponseEvent">GetResponseEvent</abbr>), 'kernel.request', <em>object</em>(<abbr title="Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher">TraceableEventDispatcher</abbr>)) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 388</li>
<li>at <abbr title="Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher">TraceableEventDispatcher</abbr>->Symfony\Component\HttpKernel\Debug\{closure}(<em>object</em>(<abbr title="Symfony\Component\HttpKernel\Event\GetResponseEvent">GetResponseEvent</abbr>), 'kernel.request', <em>object</em>(<abbr title="Zikula_EventManager">Zikula_EventManager</abbr>))</li>
<li>at <abbr title=""></abbr>call_user_func(<em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Symfony\Component\HttpKernel\Event\GetResponseEvent">GetResponseEvent</abbr>), 'kernel.request', <em>object</em>(<abbr title="Zikula_EventManager">Zikula_EventManager</abbr>)) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 164</li>
<li>at <abbr title="Symfony\Component\EventDispatcher\EventDispatcher">EventDispatcher</abbr>->doDispatch(<em>array</em>(<em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Closure">Closure</abbr>), <em>object</em>(<abbr title="Closure">Closure</abbr>)), 'kernel.request', <em>object</em>(<abbr title="Symfony\Component\HttpKernel\Event\GetResponseEvent">GetResponseEvent</abbr>)) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php line 53</li>
<li>at <abbr title="Symfony\Component\EventDispatcher\EventDispatcher">EventDispatcher</abbr>->dispatch('kernel.request', <em>object</em>(<abbr title="Symfony\Component\HttpKernel\Event\GetResponseEvent">GetResponseEvent</abbr>)) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php line 167</li>
<li>at <abbr title="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">ContainerAwareEventDispatcher</abbr>->dispatch('kernel.request', <em>object</em>(<abbr title="Symfony\Component\HttpKernel\Event\GetResponseEvent">GetResponseEvent</abbr>), <em>null</em>) in /home/ntq/public_html/core/src/lib/legacy/Zikula/EventManager.php line 99</li>
<li>at <abbr title="Zikula_EventManager">Zikula_EventManager</abbr>->dispatch('kernel.request', <em>object</em>(<abbr title="Symfony\Component\HttpKernel\Event\GetResponseEvent">GetResponseEvent</abbr>)) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 138</li>
<li>at <abbr title="Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher">TraceableEventDispatcher</abbr>->dispatch('kernel.request', <em>object</em>(<abbr title="Symfony\Component\HttpKernel\Event\GetResponseEvent">GetResponseEvent</abbr>)) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php line 107</li>
<li>at <abbr title="Symfony\Component\HttpKernel\HttpKernel">HttpKernel</abbr>->handleRaw(<em>object</em>(<abbr title="Zikula_Request_Http">Zikula_Request_Http</abbr>), '1') in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php line 66</li>
<li>at <abbr title="Symfony\Component\HttpKernel\HttpKernel">HttpKernel</abbr>->handle(<em>object</em>(<abbr title="Zikula_Request_Http">Zikula_Request_Http</abbr>), '1', <em>true</em>) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php line 64</li>
<li>at <abbr title="Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel">ContainerAwareHttpKernel</abbr>->handle(<em>object</em>(<abbr title="Zikula_Request_Http">Zikula_Request_Http</abbr>), '1', <em>true</em>) in /home/ntq/public_html/core/src/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php line 185</li>
<li>at <abbr title="Symfony\Component\HttpKernel\Kernel">Kernel</abbr>->handle(<em>object</em>(<abbr title="Zikula_Request_Http">Zikula_Request_Http</abbr>)) in /home/ntq/public_html/core/src/index.php line 21</li>
</ol>
wenn alle Default Smilies deaktiviert werden, erscheint nur noch der link "weitere Smilies".
Wäre es nicht besser es so zu lösen das die ersten N Smilies angezeigt werden?
gruß Andreas
Migrated from http://code.zikula.org/parked/ticket/473
not every bbcode can be bundle with bbcode , a plugin system which will work like this
parsing a plugin folder
execute a common function
if it's php5 only, it could be writen like this
interface bbcodePlugin{
public function transform($var);
public function getStartTag();
public function getEndTag();
// public function untransform($var, $arg);
}
classe UpperPlugin implements bbcodePlugin{
public function transform(&$var) {
ucfirst($var);
}
public function getStartTag(){
return "[uppercase]";
}
public function getEndTag(){
return "[/uppercase]";
}
}
in that case, bbcode like [video type=youtube] could be implemented, you can think to something like [url pagerank=true] for a seo blog ... etc ..
note that a cache system to create only the needed instance of bbcode could be good, or may be using static tricks to avoid instanciation ...
Change History
comment:1 Changed 3 years ago by mumuri
public function transform($var,$param);
where paramtype?="youtube" for instance
comment:2 Changed 3 years ago by mumuri
where param['type']="youtube" for instance
Maybe this error also exists for other modules.
Message body with wrong used quotes by some users (attached)
Attachments
test.txt Download (286 bytes) - added by quan 21 months ago.
this message body of an intercom mail will make intercom broken
Change History
Changed 21 months ago by quan
attachment test.txt Download added
this message body of an intercom mail will make intercom broken
comment:1 Changed 21 months ago by Landseer
Priority changed from blocker to minor
Status changed from new to closed
Resolution set to wontfix
incorrect usage of quote tags.
comment:2 Changed 21 months ago by quan
Status changed from closed to reopened
Resolution wontfix deleted
great.. Everybody is able to make intercom unusavle for other users inserting this code...
every site using intercom and bbcode is affected.
it's right that the usage of bbcode syntax is incorrect but fixing this bug will make the usability of a zikula site more user friendly...
comment:3 Changed 21 months ago by Landseer
Priority changed from minor to trivial
If your users cannot handle quotetags correctly, turn bbcode off.
When I have installed BBCode and there are no areas assigned I get this error:
Could not load the 'forum' module at 'viewtopic'.
BBCode_Controller_User::bbcodes() does not exist.
the url tags doesn't support IDN
For instance you can look at this post
http://community.zikula.org/module-Forum-viewtopic-topic-55369-start-0.htm
and test with this link
http://www.ingénieurs.org/demo/images/menu_bg.png
Change History
comment:1 Changed 3 years ago by mumuri
sorry it's work for img
comment:2 Changed 3 years ago by Landseer
So does it work or not?
comment:3 Changed 3 years ago by Landseer
Type changed from defect to enhancement
Milestone set to 3.0
comment:4 Changed 2 years ago by mumuri
it's ok for me , you can close it
It would be cool to not only be able to input a URL but also to upload an image to imageshack: http://forum.codecall.net/classes-code-snippets/14319-php-imageshack-uploader.html
The advantage is, that you don't have to take care of the storage - open folder and so on.
This would be a great addition to forums, comments and the like.
allow a configuration for each module what code parts should be converted etc...
this could be a theme only issue, but as the picture shows the rendering of the BBCODE quote (and code) busts out the right side of the container and forces the container past the edges of the browser. This is what zikula.org would look like if the bbcode transform hook was connected.
ideas @espaan @rallek @damon18 @Guite @cmfcmf @phaidon HELP! critical for zikula.org
Would be nice.
plainbbcode allow you to add bbcode button in your template
but in some case, you don't want to display all the options to the user
For instance in the header of an article,if you don't want that the user put a picture,
plainbbcode image=no
Note that for the 3.0, you can add
plainbbcode extraplugins=no
for the customized version of a given plugin
Concerning the project of custom plugin for bbcode
i had an other idea
the tags overriding, which is quite simple
check for custom tags plugin (or for non classical tags if the performance are better)
apply custom tags plugin
apply classical tags
Notes that this allow you to have a clean way to handle lighttpd img tags etc ...
Change History
comment:1 Changed 3 years ago by Landseer
Owner set to Landseer
Status changed from new to accepted
Milestone set to 3.0
Interesting idea, can be achieved in the same way as the needle handling in MultiHook? so that bbcode does not need to scan all modules plugins folders for such files: Scan the plugins once or when requested to do so and store the information about them in an serialized array using a module variable.
when using smiley and bbcode, which is usually the case, you might have problem with some tags, for instance
{{{[code]
)
code
}}}
will create a smiley, but ... you don't wan't it
This feature would consist in
adding a module vars with "not to parse" serialized tags array
,
and an option in the configuration panel to handle them
use the same algorithme that in this smarty to protect the code
smarty_outputfilter_trimwhitespace
the included GeSHi library is quote old (2006!) so probably should use something newer.
options:
http://alexgorbatchev.com/SyntaxHighlighter/
http://softwaremaniacs.org/soft/highlight/en/
http://code.google.com/p/google-code-prettify/ (prettify is also included already)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.