diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/comment/helpers/comment.php | 7 | ||||
-rw-r--r-- | modules/recaptcha/helpers/recaptcha_event.php | 25 | ||||
-rw-r--r-- | modules/recaptcha/libraries/Form_Recaptcha.php | 18 |
3 files changed, 36 insertions, 14 deletions
diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php index 82b4f4b0..d2d5aee0 100644 --- a/modules/comment/helpers/comment.php +++ b/modules/comment/helpers/comment.php @@ -77,9 +77,7 @@ class comment_Core { $group->input("url") ->label(t("Website (hidden)"))->id("gUrl"); $group->textarea("text")->label(t("Comment")) ->id("gText"); $group->hidden("item_id")->value($item->id); - if (module::is_installed("recaptcha")) { - $group->recaptcha("recaptcha")->label("")->id("gRecaptcha"); - } + module::event("comment_add_form", $form); $group->submit("")->value(t("Add")); $active = user::active(); @@ -103,9 +101,6 @@ class comment_Core { $group->input("email") ->label(t("Email (hidden)")) ->id("gEmail"); $group->input("url") ->label(t("Website (hidden)"))->id("gUrl"); $group->textarea("text")->label(t("Comment")) ->id("gText"); - if (module::is_installed("recaptcha")) { - $group->recaptcha("recaptcha")->label("")->id("gRecaptcha"); - } $group->submit("")->value(t("Edit")); $group->text = $comment->text; diff --git a/modules/recaptcha/helpers/recaptcha_event.php b/modules/recaptcha/helpers/recaptcha_event.php new file mode 100644 index 00000000..d5dac756 --- /dev/null +++ b/modules/recaptcha/helpers/recaptcha_event.php @@ -0,0 +1,25 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 Bharat Mediratta + * + * 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 Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +class recaptcha_event_Core { + static function comment_add_form($form) { + $form->add_comment->recaptcha("recaptcha")->label("")->id("gRecaptcha"); + } +} diff --git a/modules/recaptcha/libraries/Form_Recaptcha.php b/modules/recaptcha/libraries/Form_Recaptcha.php index f834f068..271045c2 100644 --- a/modules/recaptcha/libraries/Form_Recaptcha.php +++ b/modules/recaptcha/libraries/Form_Recaptcha.php @@ -27,26 +27,28 @@ class Form_Recaptcha_Core extends Form_Input { public function __construct($name) { parent::__construct($name); - $this->error_messages("incorrect-captcha-sol", t("The values supplied to recaptcha are incorrect.")); + $this->error_messages("incorrect-captcha-sol", + t("The values supplied to recaptcha are incorrect.")); $this->error_messages("invalid-site-private-key", t("The site private key is incorrect.")); } public function render() { $public_key = module::get_var("recaptcha", "public_key"); - if (empty($public_key)) { + if (empty($public_key)) { throw new Exception("@todo NEED KEY <a href=\"http://recaptcha.net/api/getkey\">" . - "http://recaptcha.net/api/getkey</a>"); - } + "http://recaptcha.net/api/getkey</a>"); + } - $server = "http://api.recaptcha.net"; + $server = "http://api.recaptcha.net"; $options[] = "callback: Recaptcha.focus_response_field"; $options[] = "lang: \"" . Kohana::config("locale.root_locale") . "\""; $options[] = "theme: \"white\""; $options = implode(", ", $options); - + $html = "<div id=\"gRecaptcha\" />"; - $html .= "<script type=\"text/javascript\" src=\"http://api.recaptcha.net/js/recaptcha_ajax.js\"></script>"; + $html .= "<script type=\"text/javascript\" "; + $html .= "src=\"http://api.recaptcha.net/js/recaptcha_ajax.js\"></script>"; $html .= "<script type=\"text/javascript\">"; $html .= "Recaptcha.create(\"$public_key\", \"gRecaptcha\", {" . $options . "});"; $html .= "</script>"; @@ -72,4 +74,4 @@ class Form_Recaptcha_Core extends Form_Input { return empty($this->_error); } -}
\ No newline at end of file +}
\ No newline at end of file |