<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class Install_Form_License extends Engine_Form
{
  public function init()
  {

		// Key
    $this->addElement('Text', 'key', array(
      'label' => 'License Key',
      'required' => true,
      'allowEmpty' => false,
      'validators' => array(
        array('NotEmpty', true),
      )
    ));
    $this->getElement('key')->getValidator('NotEmpty')
      ->setMessage('Please fill in the license key.', 'notEmptyInvalid')
      ->setMessage('Please fill in the license key.', 'isEmpty');

		if (in_array($_SERVER['SERVER_NAME'], ['localhost', '127.0.0.1'])) {
			$this->addElement('Text', 'domain_name', array(
				'label' => 'Domain Name',
				'required' => true,
				'allowEmpty' => false,
				'validators' => array(
					array('NotEmpty', true),
				)
			));
			$this->getElement('domain_name')->getValidator('NotEmpty')
				->setMessage('Please fill in the domain name.', 'notEmptyInvalid')
				->setMessage('Please fill in the domain name.', 'isEmpty');
		}

    // Submit
    $this->addElement('Button', 'submit', array(
      'label' => 'Continue',
      'type' => 'submit',
      'order' => 10000,
      'ignore' => true,
      'decorators' => array(
        'ViewHelper',
        array('HtmlTag', array('tag' => 'div', 'class' => 'form-wrapper submit-wrapper')),
      )
    ));

    $this->addElement('Hidden', 'valid', array(
      'label' => 'Continue...',
      'type' => 'submit',
      'order' => 10001,
    ));

    // Modify decorators
    $this->loadDefaultDecorators();
    $this->getDecorator('FormErrors')->setSkipLabels(true);
  }
}
