From 9b03b62439ef5cace30a0e9a5e9007b49d009787 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Mon, 14 Mar 2016 08:46:05 -0400 Subject: [PATCH] Refactored to reduce complexity of subclass. --- .../View/Helper/Bootstrap3/Recaptcha.php | 23 ++++++++----------- .../src/VuFind/View/Helper/Root/Recaptcha.php | 16 ++++++++++++- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Bootstrap3/Recaptcha.php b/module/VuFind/src/VuFind/View/Helper/Bootstrap3/Recaptcha.php index 2d56c4e7fcf..1256ccf3249 100644 --- a/module/VuFind/src/VuFind/View/Helper/Bootstrap3/Recaptcha.php +++ b/module/VuFind/src/VuFind/View/Helper/Bootstrap3/Recaptcha.php @@ -4,7 +4,7 @@ * * PHP version 5 * - * Copyright (C) Villanova University 2010. + * Copyright (C) Villanova University 2016. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, @@ -39,21 +39,16 @@ namespace VuFind\View\Helper\Bootstrap3; class Recaptcha extends \VuFind\View\Helper\Root\Recaptcha { /** - * Wrap in bootstrap 3-9 columns. Generate <div> with ReCaptcha from render. + * Constructor * - * @param boolean $useRecaptcha Boolean of active state, for compact templating - * - * @return string $html + * @param \ZendService\Recaptcha\Recaptcha $rc Custom formatted Recaptcha + * @param \VuFind\Config $config Config object */ - public function html($useRecaptcha = true) + public function __construct($rc, $config) { - if (!isset($useRecaptcha) || !$useRecaptcha) { - return false; - } - return '<div class="form-group">' . - '<div class="col-sm-9 col-sm-offset-3">' . - $this->recaptcha->getHtml() . - '</div>' . - '</div>'; + $this->prefixHtml = '<div class="form-group">' . + '<div class="col-sm-9 col-sm-offset-3">'; + $this->suffixHtml = '</div></div>'; + parent::__construct($rc, $config); } } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php b/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php index a75638eaa0f..b26ab3dd75a 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php @@ -53,6 +53,20 @@ class Recaptcha extends AbstractHelper */ protected $active; + /** + * HTML prefix for ReCaptcha output. + * + * @var string + */ + protected $prefixHtml = ''; + + /** + * HTML suffix for ReCaptcha output. + * + * @var string + */ + protected $suffixHtml = ''; + /** * Constructor * @@ -87,7 +101,7 @@ class Recaptcha extends AbstractHelper if (!isset($useRecaptcha) || !$useRecaptcha) { return false; } - return $this->recaptcha->getHtml(); + return $this->prefixHtml . $this->recaptcha->getHtml() . $this->suffixHtml; } /** -- GitLab