init() public method

init the class
Since: 2.6.0
public init ( array $attributeArray = [], array $optionArray = [] ) : Form
$attributeArray array attributes of the form
$optionArray array options of the form
return Form
Beispiel #1
0
 /**
  * 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;
 }
Beispiel #2
0
 /**
  * render the view
  *
  * @param string $table name of the table
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function render($table = null)
 {
     $output = Hook::trigger('searchFormStart');
     /* html elements */
     $formElement = new Html\Form($this->_registry, $this->_language);
     $formElement->init(['form' => ['class' => 'rs-js-validate-search rs-form-search'], 'button' => ['submit' => ['class' => 'rs-button-search', 'name' => get_class()]]]);
     /* create the form */
     $formElement->search(['name' => 'search', 'placeholder' => $this->_language->get('search'), 'tabindex' => '1'])->hidden(['name' => 'table', 'value' => $table])->token()->submit($this->_language->get('search'));
     /* collect output */
     $output .= $formElement;
     $output .= Hook::trigger('searchFormEnd');
     return $output;
 }
Beispiel #3
0
 /**
  * render the view
  *
  * @param array $optionArray options of the form
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function render($optionArray = [])
 {
     $output = Hook::trigger('installFormStart');
     /* html elements */
     $titleElement = new Html\Element();
     $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('installation'));
     $formElement = new Html\Form($this->_registry, $this->_language);
     $formElement->init(['form' => ['class' => 'rs-js-accordion rs-js-validate-form rs-install-js-form rs-component-accordion rs-form-default rs-install-form-default'], 'button' => ['submit' => ['class' => 'rs-js-submit rs-button-default rs-is-large rs-is-full', 'name' => get_class()]]]);
     /* create the form */
     $formElement->append('<fieldset class="rs-js-set-accordion rs-js-set-active rs-set-accordion rs-set-active">')->append('<legend class="rs-js-title-accordion rs-js-title-active rs-title-accordion rs-title-active">' . $this->_language->get('database_setup') . '</legend>')->append('<ul class="rs-js-box-accordion rs-js-box-active rs-box-accordion rs-box-active"><li>')->label($this->_language->get('type'), ['for' => 'db-type'])->select(Helper\Option::getDatabaseArray(), ['id' => 'db-type', 'name' => 'db-type', 'value' => $optionArray['dbType']])->append('</li><li>')->label($this->_language->get('host'), ['for' => 'db-host'])->text(['data-sqlite' => uniqid() . '.sqlite', 'data-mysql' => 'localhost', 'data-pgsql' => 'localhost', 'id' => 'db-host', 'name' => 'db-host', 'required' => 'required', 'value' => $optionArray['dbHost']])->append('</li><li>')->label($this->_language->get('name'), ['for' => 'db-name'])->text(['id' => 'db-name', 'name' => 'db-name', 'required' => 'required', 'value' => $optionArray['dbName']])->append('</li><li>')->label($this->_language->get('user'), ['for' => 'db-user'])->text(['id' => 'db-user', 'name' => 'db-user', 'required' => 'required', 'value' => $optionArray['dbUser']])->append('</li><li>')->label($this->_language->get('password'), ['for' => 'db-password'])->password(['id' => 'db-password', 'name' => 'db-password', 'value' => $optionArray['dbPassword']])->append('</li><li>')->label($this->_language->get('prefix'), ['for' => 'db-prefix'])->text(['id' => 'db-prefix', 'name' => 'db-prefix', 'value' => $optionArray['dbPrefix']])->append('</li></ul></fieldset>')->append('<fieldset class="rs-js-set-accordion rs-set-accordion">')->append('<legend class="rs-js-title-accordion rs-title-accordion">' . $this->_language->get('account_create') . '</legend>')->append('<ul class="rs-js-box-accordion rs-box-accordion"><li>')->label($this->_language->get('name'), ['for' => 'name'])->text(['id' => 'admin-name', 'name' => 'admin-name', 'required' => 'required', 'value' => $optionArray['adminName']])->append('</li><li>')->label($this->_language->get('user'), ['for' => 'admin-user'])->text(['id' => 'admin-user', 'name' => 'admin-user', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required', 'value' => $optionArray['adminUser']])->append('</li><li>')->label($this->_language->get('password'), ['for' => 'admin_password'])->password(['id' => 'admin-password', 'name' => 'admin-password', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required', 'value' => $optionArray['adminPassword']])->append('</li><li>')->label($this->_language->get('email'), ['for' => 'admin-email'])->email(['id' => 'admin-email', 'name' => 'admin-email', 'required' => 'required', 'value' => $optionArray['adminEmail']])->append('</li></ul></fieldset>')->hidden(['name' => 'db-salt', 'value' => sha1(uniqid())])->hidden(['name' => 'refresh-connection', 'value' => 1])->token()->submit($this->_language->get('install'));
     /* collect output */
     $output .= $titleElement . $formElement;
     $output .= Hook::trigger('installFormEnd');
     return $output;
 }
Beispiel #4
0
 /**
  * render the view
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function render()
 {
     $output = Hook::trigger('resetFormStart');
     /* html elements */
     $titleElement = new Html\Element();
     $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('password_reset'));
     $formElement = new Html\Form($this->_registry, $this->_language);
     $formElement->init(['form' => ['class' => 'rs-js-validate-form rs-form-default rs-form-reset'], 'button' => ['submit' => ['name' => get_class()]]], ['captcha' => true]);
     /* create the form */
     $formElement->append('<fieldset>')->legend()->append('<li><ul>')->captcha('task')->append('</li></ul></fieldset>')->hidden(['name' => 'password', 'value' => $this->_registry->get('thirdParameter')])->hidden(['name' => 'id', 'value' => $this->_registry->get('thirdSubParameter')])->captcha('solution')->token()->submit();
     /* collect output */
     $output .= $titleElement . $formElement;
     $output .= Hook::trigger('resetFormEnd');
     return $output;
 }
Beispiel #5
0
 /**
  * render the view
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function render()
 {
     $output = Hook::trigger('consoleFormStart');
     /* html elements */
     $formElement = new Html\Form($this->_registry, $this->_language);
     $formElement->init(['form' => ['class' => 'rs-console-js-form rs-console-form-default']]);
     $myUser = $this->_registry->get('myUser');
     $outputLabel = $myUser ? $myUser . '@' : null;
     $outputLabel .= $this->_registry->get('host') . ':~$';
     /* create the form */
     $formElement->label($outputLabel, ['class' => 'rs-console-js-label rs-console-label-default', 'for' => 'prompt'])->text(['autocapitalize' => 'off', 'autofocus' => 'autofocus', 'autocomplete' => 'off', 'class' => 'rs-console-js-field rs-console-field-text', 'id' => 'prompt', 'name' => 'argv', 'spellcheck' => 'false']);
     /* collect output */
     $output .= $formElement;
     $output .= Hook::trigger('consoleFormEnd');
     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;
 }
Beispiel #7
0
 /**
  * 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;
 }
Beispiel #8
0
 /**
  * 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;
 }
Beispiel #9
0
 /**
  * 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;
 }
 /**
  * testButton
  *
  * @param string $method
  * @param string $text
  * @param array $attributeArray
  * @param string $expect
  *
  * @dataProvider providerButton
  *
  * @since 2.6.0
  */
 public function testButton($method = null, $text = null, $attributeArray = array(), $expect = null)
 {
     /* setup */
     $form = new Html\Form($this->_registry, $this->_language);
     $form->init();
     $form->{$method}($text, $attributeArray);
     /* actual */
     $actual = $form;
     /* compare */
     $this->assertEquals($expect, $actual);
 }