1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 
<?php
namespace Omeka\Form\View\Helper;

use Zend\Form\View\Helper\AbstractHelper;
use Zend\Form\ElementInterface;

class FormRecaptcha extends AbstractHelper
{
    public function __invoke(ElementInterface $element)
    {
        return $this->render($element);
    }

    public function render(ElementInterface $element)
    {
        $view = $this->getView();
        $view->headScript()->appendFile(
            $view->assetUrl('js/recaptcha.js', 'Omeka')
        );
        $view->headScript()->appendFile(
            'https://www.google.com/recaptcha/api.js?onload=recaptchaCallback&render=explicit',
            'text/javascript',
            ['async' => true, 'defer' => true]
        );
        return sprintf(
            '<div %s></div>',
            $this->createAttributesString($element->getAttributes())
        );
    }
}