29
Feb
Using JCCreCaptcha with yvComment
Written by Júlio Oliveira Last Updated (Thursday, 20 August 2009 14:38)
Editting the yvComment
When I wrote the JCCReCaptcha, I thought to use it with the yvComment. because this, I wrote a plugin based on OSTWigits-Captcha interface plugin, wich I already used with yvComment.
Despite we strictly followed the OSTWigits-Captcha interface, the fact of ReCaptcha to work with itself html GUI imposed the need of some changes on yvComment source code.
Naturally, this is one of the things more beautiful on Open Software: The possibility of to suit it to yours needs. This differ to make indiscriminate changes only because you can do, so, we looked about alternatives to changes that had less impact on yvComment code.
Before start, I would like to point that the showed changes were made over the version 1.23 of yvComment component. Naturally there aren't any warranty that this edittings will be functional in future versions of yvComment!
“Lazy” Editting
I call this "Lazy" edittings, because this is the less intrusive changes on source code of yvComment component. The pay off is that yvComment will be incompatible with the OSTWigits-Captcha like plugins.
- Source: "default.php", on folder "components\com_yvcomment\views\comment\tmpl", original code, lines 352-361:
In this lines a html <img> tag is used, to show the on-fly image generated by OSTWigits-Captcha plugin. The plugin is a triggered by the URL on "SRC" argument, "JRoute::_('index.php?option=com_yvcomment&task=displaycaptcha'".
All that we need is to replace this lines by the following code:
Note that the "input secretword" is needed just because the yvComment rely on it to follow to the plugin. The ReCaptcha don't need it, but remove it will to cause more edittings on yvComment. So, we take it hidden and with a default value, also neede to avoid the yvComment validation that blocks submissions to the Captcha plugin if the secretword don't have entered.
- Source: "default.php", folder "components\com_yvcomment\views\comment\tmpl", original code, lines 364-378:
This is the lines that originally provides the input for the sercretword. Since the ReCaptcha already have its own input, this lines can be wholly removed from the source!
A Better Suited Edittings
In contrast with the above edittings, the following will keep yvComment compatible with OSTWigits-Captcha like plugin.
It will be accomplished by adding a parameter on yvComnent, that will to permit a user to select when he/she wants to use a OSTWigits-Captcha interface like captcha plugin or a JCCreCaptcha one. It just will be well suited because the yvComment make use of captcha plugins through Triggers mechanism. So it don't have strictly rely with a particular plugin, what easy its replacement by another since it have the same interface. Then I want to keep it and take use of this, what resulted on the follow edittings:
- Source: "en-GB.com_yvcomment.ini", Folder "administrator/language/en-GB", line 190:
This is the language file for the yvComment plugin. We will make the insert of messages that we will create to support our edittings. They are indicated on highlighted lines:
- Source: "yvcomment.xml", plugin yvcomment, folder "plugins\content":
This define the parameters for the yvComment plugin and for the yvComment component. At line 139, we add the follow code, that define our new parameter, “captcha_render_mode”:
Note that we use the macros that we defined before, on language file. Thats will to permit that our change can be easily translated.
- Source: "view.html.php", component yvcomment, folder "components\com_yvcomment\views\comment":
The interesting lines in this source make the load of some parameters to variables for later use. We will to add, on 373 line, the load of our new parameter, following the style and naming conventions used on original code:
- Source: "default.php", component yvComment, folder "components\com_yvcomment\views\comment\tmpl", lines 352 to 361:
We will make use of the new parameter to keep the original source code thar to render the captcha image, "switching" between it and the new code, that render the reCaptcha html GUI. Over the original source code, we will to add the following (highlighted) lines:
- Source: "default.php", component yvComment, folder "components\com_yvcomment\views\comment\tmpl", lines 364-378, (on unmodifyied source code, after the last edittings, the new lines will be 374-388) :
We will make use of the new parameter to hide html TABLE line that contain the secretword textbox, even our captcha control don't need it. On the original code, we will to add the highlighted lines:
Using the modifyied version
Made that above edittings, Go to the yvComment plugin's setup interface. You will to find our new parameter, like showed on follow picture:
Change it to "HTML User Interface" option and save.
Install the JCCReCaptcha and enable it. If you have another Captcha plugin, disable it.
Now test your increased yvComment with JCCreCaptcha. It will to result on anything like showed down:

Finalizing
Unfortunately, because our host restrictions, we can't to use JCCreCaptcha on our blog, just because the reCaptcha use sockets on its API implementation and outgoing connections its blocked on free account (our case). So, we can't to show a live version on JCCreCaptcha with yvComment. Therefore, we invite anyone who to test the component to post a comment here to let us know about the experience. We will to answer any question as soon as possible, here, on comments.





















Parabéns e muito obrigado de dividir com a comunidade.
Abraços de João Pessoa / Paraiba
I hope to see you work together with yurivolkov.com to implement a permanent integration with future yvcomment releases. The Joomla! community would greatly benefit from this collaboration!
Thank you!
Surely, yes, on GNU-GPL v2 terms, only.
There are a link to the GNU-GPL v2 license on download section of the article, if it be needed.
Thanks,
By the way, I've tried the good one and failed, so the Lazy one is much better.