/** * render the view * * @since 3.0.0 * * @return string */ public function render() { $output = Hook::trigger('loginFormStart'); $outputLegend = null; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('login')); if (Db::getSetting('recovery')) { $linkElement = new Html\Element(); $linkElement->init('a', ['href' => $this->_registry->get('parameterRoute') . 'login/recover']); $outputLegend = $linkElement->text($this->_language->get('recovery_question') . $this->_language->get('question_mark')); } $formElement = new Html\Form($this->_registry, $this->_language); $formElement->init(['form' => ['class' => 'rs-js-validate-form rs-form-default rs-form-login'], 'button' => ['submit' => ['name' => get_class()]]], ['captcha' => Db::getSetting('captcha') > 0]); /* create the form */ $formElement->append('<fieldset>')->legend($outputLegend)->append('<ul><li>')->label('* ' . $this->_language->get('user'), ['for' => 'user'])->text(['autofocus' => 'autofocus', 'id' => 'user', 'name' => 'user', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required'])->append('</li><li>')->label('* ' . $this->_language->get('password'), ['for' => 'password'])->password(['id' => 'password', 'name' => 'password', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required'])->append('</li>'); if (Db::getSetting('captcha') > 0) { $formElement->append('<li>')->captcha('task')->append('</li>'); } $formElement->append('</ul></fieldset>'); if (Db::getSetting('captcha') > 0) { $formElement->captcha('solution'); } $formElement->token()->submit(); /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('loginFormEnd'); return $output; }
/** * render * * @since 2.6.0 */ public static function render() { $formElement = new Html\Form(Registry::getInstance(), Language::getInstance()); $formElement->init(array('form' => array('class' => 'js_validate_form form_default'), 'label' => array('class' => 'label'), 'textarea' => array('class' => 'js_auto_resize js_editor_textarea field_textarea'), 'input' => array('email' => array('class' => 'field_text'), 'number' => array('class' => 'field_text'), 'text' => array('class' => 'field_text'), 'url' => array('class' => 'field_text')), 'button' => array('submit' => array('class' => 'js_submit button_default', 'name' => get_class()), 'reset' => array('class' => 'js_reset button_default', 'name' => get_class()))), array('captcha' => Db::getSettings('captcha') > 0)); /* create the form */ $formElement->append('<fieldset>')->legend()->append('<ul><li>')->label('* ' . Language::get('author'), array('for' => 'author'))->text(array('id' => 'author', 'name' => 'author', 'readonly' => Registry::get('myName') ? 'readonly' : null, 'required' => 'required', 'value' => Registry::get('myName') ? Registry::get('myName') : Request::getPost('author')))->append('</li><li>')->label('* ' . Language::get('email'), array('for' => 'email'))->email(array('id' => 'email', 'name' => 'email', 'readonly' => Registry::get('myEmail') ? 'readonly' : null, 'required' => 'required', 'value' => Registry::get('myEmail') ? Registry::get('myEmail') : Request::getPost('email')))->append('</li><li>')->label(Language::get('url'), array('for' => 'url'))->url(array('id' => 'url', 'name' => 'url', 'value' => Request::getPost('url')))->append('</li><li>')->label('* ' . Language::get('message'), array('for' => 'text'))->textarea(array('id' => 'text', 'name' => 'text', 'required' => 'required', 'value' => Request::getPost('text')))->append('</li>'); if (Db::getSettings('captcha') > 0) { $formElement->append('<li>')->captcha('task')->append('</li>'); } $formElement->append('</ul></fieldset>'); if (Db::getSettings('captcha') > 0) { $formElement->captcha('solution'); } $formElement->token()->submit()->reset(); return $formElement; }
/** * render * * @since 2.6.0 * * return Form */ public static function render() { $formElement = new Html\Form(Registry::getInstance(), Language::getInstance()); $formElement->init(['textarea' => ['class' => 'rs-js-auto-resize rs-js-editor-textarea rs-field-textarea'], 'button' => ['submit' => ['name' => get_class()]]], ['captcha' => Db::getSetting('captcha') > 0]); /* create the form */ $formElement->append('<fieldset>')->legend()->append('<ul><li>')->label('* ' . Language::get('author'), ['for' => 'author'])->text(['id' => 'author', 'name' => 'author', 'readonly' => Registry::get('myName') ? 'readonly' : null, 'required' => 'required', 'value' => Registry::get('myName')])->append('</li><li>')->label('* ' . Language::get('email'), ['for' => 'email'])->email(['id' => 'email', 'name' => 'email', 'readonly' => Registry::get('myEmail') ? 'readonly' : null, 'required' => 'required', 'value' => Registry::get('myEmail')])->append('</li><li>')->label(Language::get('url'), ['for' => 'url'])->url(['id' => 'url', 'name' => 'url'])->append('</li><li>')->label('* ' . Language::get('message'), ['for' => 'text'])->textarea(['id' => 'text', 'name' => 'text', 'required' => 'required'])->append('</li>'); if (Db::getSetting('captcha') > 0) { $formElement->append('<li>')->captcha('task')->append('</li>'); } $formElement->append('</ul></fieldset>'); if (Db::getSetting('captcha') > 0) { $formElement->captcha('solution'); } $formElement->token()->submit()->reset(); return $formElement; }
/** * render the view * * @since 3.0.0 * * @param integer $articleId identifier of the article * * @return string */ public function render($articleId = null) { $output = Hook::trigger('commentFormStart'); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('comment_new')); $formElement = new Html\Form($this->_registry, $this->_language); $formElement->init(['button' => ['submit' => ['name' => get_class()]]], ['captcha' => Db::getSetting('captcha') > 0]); /* create the form */ $formElement->append('<fieldset>')->legend()->append('<ul><li>')->label('* ' . $this->_language->get('author'), ['for' => 'author'])->text(['id' => 'author', 'name' => 'author', 'readonly' => $this->_registry->get('myName') ? 'readonly' : null, 'required' => 'required', 'value' => $this->_registry->get('myName')])->append('</li><li>')->label('* ' . $this->_language->get('email'), ['for' => 'email'])->email(['id' => 'email', 'name' => 'email', 'readonly' => $this->_registry->get('myEmail') ? 'readonly' : null, 'required' => 'required', 'value' => $this->_registry->get('myEmail')])->append('</li><li>')->label($this->_language->get('url'), ['for' => 'url'])->url(['id' => 'url', 'name' => 'url'])->append('</li><li>')->label('* ' . $this->_language->get('text'), ['for' => 'text'])->textarea(['class' => 'rs-js-auto-resize rs-js-editor-textarea rs-field-textarea', 'id' => 'text', 'name' => 'text', 'required' => 'required'])->append('</li>'); if (Db::getSetting('captcha') > 0) { $formElement->append('<li>')->captcha('task')->append('</li>'); } $formElement->append('</ul></fieldset>'); if (Db::getSetting('captcha') > 0) { $formElement->captcha('solution'); } $formElement->hidden(['name' => 'article', 'value' => $articleId])->token()->submit()->reset(); /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('commentFormEnd'); return $output; }
/** * render the view * * @since 3.0.0 * * @return string */ public function render() { $output = Hook::trigger('recoverFormStart'); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('recovery')); $formElement = new Html\Form($this->_registry, $this->_language); $formElement->init(['form' => ['class' => 'rs-js-validate-form rs-form-default rs-form-recover'], 'button' => ['submit' => ['name' => get_class()]]], ['captcha' => Db::getSetting('captcha') > 0]); /* create the form */ $formElement->append('<fieldset>')->legend($this->_language->get('recovery_request') . $this->_language->get('point'))->append('<ul><li>')->label('* ' . $this->_language->get('email'), ['for' => 'email'])->email(['autofocus' => 'autofocus', 'id' => 'email', 'name' => 'email', 'required' => 'required'])->append('</li>'); if (Db::getSetting('captcha') > 0) { $formElement->append('<li>')->captcha('task')->append('</li>'); } $formElement->append('</ul></fieldset>'); if (Db::getSetting('captcha') > 0) { $formElement->captcha('solution'); } $formElement->token()->submit(); /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('recoverFormEnd'); return $output; }
/** * testCaptcha * * @param array $expect * * @dataProvider providerCaptcha * * @since 2.6.0 */ public function testCaptcha($expect = array()) { /* setup */ $form = new Html\Form($this->_registry, $this->_language); $form->init(); $form->captcha($expect['type']); /* actual */ $actual = $form->render(); /* compare */ $this->assertStringStartsWith($expect['prefix'], $actual); $this->assertStringEndsWith($expect['suffix'], $actual); }
/** * testCaptcha * * @since 3.0.0 * * @param array $expectArray * * @dataProvider providerCaptcha */ public function testCaptcha($expectArray = []) { /* setup */ $form = new Html\Form($this->_registry, $this->_language); $form->init(null, ['captcha' => true]); $form->captcha($expectArray['type']); /* actual */ $actual = $form->render(); /* compare */ $this->assertStringStartsWith($expectArray['start'], $actual); $this->assertStringEndsWith($expectArray['end'], $actual); }