Get received input (user text or clicked button payload)

@return mixed|null|void
491221
public function getReceivedInput()
    {
        if (!$this->isUserMessage()) {
            return;
        }

        if (isset($this->message['text'])) {
            return $this->message['text'];
        }

        if (isset($this->postback['payload'])) {
            return $this->postback['payload'];
        }

        return null;
    }
879774
private function parseInput()
    {
        $result = null;
        try {
            $rawBody = file_get_contents('php://input');
            if (strpos($rawBody, '&form_key=')) {
                $parts = explode('&form_key=', $rawBody);
                $rawBody = reset($parts);
            }
            $obj = json_decode($rawBody, true);
            if ($obj) {
                $type = $this->getInDataType();
                $asArray = (array)$obj;
                $result = $this->inputProcessor->convertValue($asArray, $type);
            }
        } catch (\Throwable $t) {
            $this->logger->error("Cannot parse input data: " . $t->getMessage());
        }
        return $result;
    }
1212270
public function getInput()
    {
        $this->codeBufferOpen = false;

        do {
            // reset output verbosity (in case it was altered by a subcommand)
            $this->output->setVerbosity(ShellOutput::VERBOSITY_VERBOSE);

            $input = $this->readline();

            /*
             * Handle Ctrl+D. It behaves differently in different cases:
             *
             *   1) In an expression, like a function or "if" block, clear the input buffer
             *   2) At top-level session, behave like the exit command
             */
            if ($input === false) {
                $this->output->writeln('');

                if ($this->hasCode()) {
                    $this->resetCodeBuffer();
                } else {
                    throw new BreakException('Ctrl+D');
                }
            }

            // handle empty input
            if (\trim($input) === '' && !$this->codeBufferOpen) {
                continue;
            }

            $input = $this->onInput($input);

            // If the input isn't in an open string or comment, check for commands to run.
            if ($this->hasCommand($input) && !$this->inputInOpenStringOrComment($input)) {
                $this->addHistory($input);
                $this->runCommand($input);

                continue;
            }

            $this->addCode($input);
        } while (!$this->hasValidCode());
    }
984598
public function getInputData() {
		$a = array(
			'extension' => $this->extensionId,
			'dttm' => null,
			'data' => $this->data->asArray(),
			'verificationMode' => $this->verificationMode ? 'true' : 'false'
		);

		return $a;
	}
745161
protected function getInput()
	{
		// Initialize some field attributes.
		$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
		$maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
		$class = $this->element['class'] ? ' ' . (string) $this->element['class'] : '';
		$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
		$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';

		// " and \ are always forbidden in email unless escaped.
		$this->value = str_replace(array('"','\\'), '', $this->value);

		// Initialize JavaScript field attributes.
		$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';

		return '<input type="text" name="' . $this->name . '" class="validate-email' . $class . '" id="' . $this->id . '"' . ' value="'
			. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly . $onchange . $maxLength . '/>';
	}
697042
protected function getInputSource()
	{
		if ($this->isJson()) return $this->json();

		return $this->getMethod() == 'GET' ? $this->query : $this->request;
	}
526536
protected function getInput()
	{
		$html = array();

		// Initialize some field attributes.
		$class = $this->element['class'] ? ' class="radio ' . (string) $this->element['class'] . '"' : ' class="radio"';

		// Start the radio field output.
		$html[] = '<fieldset id="' . $this->id . '"' . $class . '>';

		// Get the field options.
		$options = $this->getOptions();

		// Build the radio field output.
		foreach ($options as $i => $option)
		{
			// Initialize some option attributes.
			$checked = ((string) $option->value == (string) $this->value) ? ' checked="checked"' : '';
			$class = !empty($option->class) ? ' class="' . $option->class . '"' : '';
			$disabled = !empty($option->disable) ? ' disabled="disabled"' : '';

			// Initialize some JavaScript option attributes.
			$onclick = !empty($option->onclick) ? ' onclick="' . $option->onclick . '"' : '';

			$html[] = '<input type="radio" id="' . $this->id . $i . '" name="' . $this->name . '"' . ' value="'
				. htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $class . $onclick . $disabled . '/>';

			$html[] = '<label for="' . $this->id . $i . '"' . $class . '>'
				. Text::alt($option->text, preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)) . '</label>';
		}

		// End the radio field output.
		$html[] = '</fieldset>';

		return implode($html);
	}
490476
public function input() {

		$output       = '<input type="hidden" value="' . esc_attr( $this->get_value() ) . '" ' . $this->build_attributes() . '>';
		$button_text  = isset( $this->struct['add_label'] ) ? $this->struct['add_label'] : __( 'Select Image', 'uix' );
		$preview_size = isset( $this->struct['preview_size'] ) ? $this->struct['preview_size'] : 'medium';
		$type         = isset( $this->struct['type'] ) ? $this->struct['type'] : 'id';
		$size         = isset( $this->struct['size'] ) ? $this->struct['size'] : 'full';
		$output      .= $this->preview( $preview_size );
		$output      .= '<button type="button" data-size="' . esc_attr( $size ) . '" data-type="' . esc_attr( $type ) . '" data-preview-size="' . esc_attr( $preview_size ) . '" data-target="' . esc_attr( $this->id() ) . '" class="button button-small uix-image-control-button">' . esc_html( $button_text ) . '</button>';

		return $output;
	}
165179
protected function parseInput()
    {
        foreach ($this->input as $key=>$value) {
            $this->applyParameter($key, $value);
        }
    }
827693
protected function getInput()
	{
		if ($this->element['extension'])
		{
			$extension = (string) $this->element['extension'];
		}
		else
		{
			$extension = (string) JFactory::getApplication()->input->get('extension', 'com_content');
		}

		$allowEdit  = ((string) $this->element['edit'] == 'true') ? true : false;
		$allowClear = ((string) $this->element['clear'] != 'false') ? true : false;

		// Load language
		JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR);

		// The active category id field.
		$value = (int) $this->value > 0 ? (int) $this->value : '';

		// Build the script.
		$script = array();

		// Select button script
		$script[] = '	function jSelectCategory_' . $this->id . '(id, title, object) {';
		$script[] = '		document.getElementById("' . $this->id . '_id").value = id;';
		$script[] = '		document.getElementById("' . $this->id . '_name").value = title;';

		if ($allowEdit)
		{
			$script[] = '		if (id == "' . (int) $this->value . '") {';
			$script[] = '			jQuery("#' . $this->id . '_edit").removeClass("hidden");';
			$script[] = '		} else {';
			$script[] = '			jQuery("#' . $this->id . '_edit").addClass("hidden");';
			$script[] = '		}';
		}

		if ($allowClear)
		{
			$script[] = '		jQuery("#' . $this->id . '_clear").removeClass("hidden");';
		}

		$script[] = '		jQuery("#categorySelect' . $this->id . 'Modal").modal("hide");';
		$script[] = '	}';

		// Edit button script
		$script[] = '	function jEditCategory_' . $value . '(title) {';
		$script[] = '		document.getElementById("' . $this->id . '_name").value = title;';
		$script[] = '	}';

		// Clear button script
		static $scriptClear;

		if ($allowClear && !$scriptClear)
		{
			$scriptClear = true;

			$script[] = '	function jClearCategory(id) {';
			$script[] = '		document.getElementById(id + "_id").value = "";';
			$script[] = '		document.getElementById(id + "_name").value = "'
				. htmlspecialchars(JText::_('COM_CATEGORIES_SELECT_A_CATEGORY', true), ENT_COMPAT, 'UTF-8') . '";';
			$script[] = '		jQuery("#"+id + "_clear").addClass("hidden");';
			$script[] = '		if (document.getElementById(id + "_edit")) {';
			$script[] = '			jQuery("#"+id + "_edit").addClass("hidden");';
			$script[] = '		}';
			$script[] = '		return false;';
			$script[] = '	}';
		}

		// Add the script to the document head.
		JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));

		// Setup variables for display.
		$html = array();

		$linkCategories = 'index.php?option=com_categories&amp;view=categories&amp;layout=modal&amp;tmpl=component'
			. '&amp;extension=' . $extension
			. '&amp;function=jSelectCategory_' . $this->id;

		$linkCategory   = 'index.php?option=com_categories&amp;view=category&amp;layout=modal&amp;tmpl=component'
			. '&amp;task=category.edit'
			. '&amp;function=jEditCategory_' . $value;

		if (isset($this->element['language']))
		{
			$linkCategories .= '&amp;forcedLanguage=' . $this->element['language'];
			$linkCategory   .= '&amp;forcedLanguage=' . $this->element['language'];
			$modalTitle = JText::_('COM_CATEGORIES_CHANGE_CATEGORY') . ' &#8212; ' . $this->element['label'];
		}
		else
		{
			$modalTitle = JText::_('COM_CATEGORIES_CHANGE_CATEGORY');
		}

		$urlSelect = $linkCategories . '&amp;' . JSession::getFormToken() . '=1';
		$urlEdit   = $linkCategory . '&amp;id=' . $value . '&amp;' . JSession::getFormToken() . '=1';

		if ($value)
		{
			$db    = JFactory::getDbo();
			$query = $db->getQuery(true)
				->select($db->quoteName('title'))
				->from($db->quoteName('#__categories'))
				->where($db->quoteName('id') . ' = ' . (int) $value);
			$db->setQuery($query);

			try
			{
				$title = $db->loadResult();
			}
			catch (RuntimeException $e)
			{
				JError::raiseWarning(500, $e->getMessage());
			}
		}

		if (empty($title))
		{
			$title = JText::_('COM_CATEGORIES_SELECT_A_CATEGORY', true);
		}

		$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');

		// The current category display field.
		$html[] = '<span class="input-append">';
		$html[] = '<input class="input-medium" id="' . $this->id . '_name" type="text" value="' . $title . '" disabled="disabled" size="35" />';

		// Select category button
		$html[] = '<a'
			. ' class="btn hasTooltip"'
			. ' data-toggle="modal"'
			. ' role="button"'
			. ' href="#categorySelect' . $this->id . 'Modal"'
			. ' title="' . JHtml::tooltipText('COM_CATEGORIES_CHANGE_CATEGORY') . '">'
			. '<span class="icon-file"></span> ' . JText::_('JSELECT')
			. '</a>';

		// Edit category button
		if ($allowEdit)
		{
			$html[] = '<a'
				. ' class="btn hasTooltip' . ($value ? '' : ' hidden') . '"'
				. ' id="' . $this->id . '_edit"'
				. ' data-toggle="modal"'
				. ' role="button"'
				. ' href="#categoryEdit' . $value . 'Modal"'
				. ' title="' . JHtml::tooltipText('COM_CATEGORIES_EDIT_CATEGORY') . '">'
				. '<span class="icon-edit"></span> ' . JText::_('JACTION_EDIT')
				. '</a>';
		}

		// Clear category button
		if ($allowClear)
		{
			$html[] = '<button'
				. ' class="btn' . ($value ? '' : ' hidden') . '"'
				. ' id="' . $this->id . '_clear"'
				. ' onclick="return jClearCategory(\'' . $this->id . '\')">'
				. '<span class="icon-remove"></span>' . JText::_('JCLEAR')
				. '</button>';
		}

		$html[] = '</span>';

		// Select category modal
		$html[] = JHtml::_(
			'bootstrap.renderModal',
			'categorySelect' . $this->id . 'Modal',
			array(
				'title'       => $modalTitle,
				'url'         => $urlSelect,
				'height'      => '400px',
				'width'       => '800px',
				'bodyHeight'  => '70',
				'modalWidth'  => '80',
				'footer'      => '<a type="button" class="btn" data-dismiss="modal" aria-hidden="true">'
						. JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '</a>',
			)
		);

		// Edit category modal
		$html[] = JHtml::_(
			'bootstrap.renderModal',
			'categoryEdit' . $value . 'Modal',
			array(
				'title'       => JText::_('COM_CATEGORIES_EDIT_CATEGORY'),
				'backdrop'    => 'static',
				'keyboard'    => false,
				'closeButton' => false,
				'url'         => $urlEdit,
				'height'      => '400px',
				'width'       => '800px',
				'bodyHeight'  => '70',
				'modalWidth'  => '80',
				'footer'      => '<a type="button" class="btn" data-dismiss="modal" aria-hidden="true"'
						. ' onclick="jQuery(\'#categoryEdit' . $value . 'Modal iframe\').contents().find(\'#closeBtn\').click();">'
						. JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '</a>'
						. '<button type="button" class="btn btn-primary" aria-hidden="true"'
						. ' onclick="jQuery(\'#categoryEdit' . $value . 'Modal iframe\').contents().find(\'#saveBtn\').click();">'
						. JText::_("JSAVE") . '</button>'
						. '<button type="button" class="btn btn-success" aria-hidden="true"'
						. ' onclick="jQuery(\'#categoryEdit' . $value . 'Modal iframe\').contents().find(\'#applyBtn\').click();">'
						. JText::_("JAPPLY") . '</button>',
			)
		);

		// Note: class='required' for client side validation
		$class = $this->required ? ' class="required modal-value"' : '';

		$html[] = '<input type="hidden" id="' . $this->id . '_id"' . $class . ' name="' . $this->name . '" value="' . $value . '" />';

		return implode("\n", $html);
	}
544926
private function getInputFromHTTP() {
		if($this->logger) $this->logger->debug('Getting and decoding HTTP request body');
		$input = file_get_contents('php://input');
		$this->setInput($input);
		return $this->input;
	}
1184642
protected function getData() {
        $data = Input::all();
        if (is_array($data)) {
            return $this->excludeKeys($data);
        } else {
            return null;
        }
    }
1273748
protected function getInputData()
    {
        (new MenuValidator())->validateForm();

        $_data = request()->all();

        array_set($data, 'record.language_code', array_get($_data, 'language'));
        array_set($data, 'record.parent_id', array_get($_data, 'parent', null));
        array_set($data, 'record.menu_type_id', array_get($_data, 'menu_type'));
        array_set($data, 'record.type', array_get($_data, 'type'));
        array_set($data, 'record.url', array_get($_data, 'url'));
        array_set($data, 'record.link_text', array_get($_data, 'link_text'));
        array_set($data, 'record.page_id', array_get($_data, 'page_translations'));

        array_set($data, 'record.link_type', array_get($_data, 'link_type'));
        array_set($data, 'record.icon', array_get($_data, 'icon'));
        array_set($data, 'record.dropdown', array_get($_data, 'dropdown', "0"));
        array_set($data, 'record.sequence', array_get($_data, 'sequence', null));

        array_set($data, 'menu_groups', array_get($_data, 'menu_groups', []));

        return makeEmptyNullable($data);
    }
103172
protected function getInput()
	{
		// Initialize variables.
		$html = array();

		// Initialize some field attributes.
		$class = $this->element['class'] ? ' class="radio ' . (string) $this->element['class'] . '"' : ' class="radio"';

		// Start the radio field output.
		$html[] = '<fieldset id="' . $this->id . '"' . $class . '>';

		// Get the field options.
		$options = $this->getOptions();
		$found = false;

		$html[] = '<ul>';

		// Build the radio field output.
		foreach ($options as $i => $option)
		{
			// Initialize some option attributes.
			$checked  = ((string) $option->value == (string) $this->value) ? ' checked="checked"' : '';
			$class    = !empty($option->class) ? ' class="' . $option->class . '"' : '';
			$disabled = !empty($option->disable) ? ' disabled="disabled"' : '';

			if ($checked)
			{
				$found = true;
			}

			// Add data attributes
			$dataAttributes = '';
			foreach ($option as $field => $value)
			{
				$dataField = strtolower(substr($field, 0, 4));
				if ($dataField == 'data')
				{
					$dataAttributes .= ' ' . $field . '="' . $value . '"';
				}
			}
			// Initialize some JavaScript option attributes.
			$onclick = !empty($option->onclick) ? ' onclick="' . $option->onclick . '"' : '';

			$html[] = '<li>';
			$html[] = '<input type="radio" id="' . $this->id . $i . '" name="' . $this->name . '" value="' . htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $class . $onclick . $disabled . $dataAttributes . '/>';
			$html[] = '<label for="' . $this->id . $i . '"' . $class . '>' . App::get('language')->alt($option->text, preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)) . '</label>';
			$html[] = '</li>';
		}

		if ($this->element['option_other'])
		{
			$checked = '';
			if (!$found && $this->value)
			{
				$checked = ' checked="checked"';
			}
			$html[] = '<li>';
			$html[] = '<input type="radio" id="' . $this->id . ($i + 1) . '" name="' . $this->name . '" value=""' . $checked . $class . $onclick . $disabled . '/>';
			$html[] = '<label for="' . $this->id . ($i + 1) . '"' . $class . '>' . App::get('language')->txt('JOTHER') . '</label>';
			$html[] = '<input type="text" id="' . $this->id . '_other" name="' . $this->getName($this->fieldname . '_other') . '" value="' . ($checked ? htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') : '') . '"' . $class . $onclick . $disabled . '/>';
			$html[] = '</li>';
		}

		$html[] = '</ul>';

		// End the radio field output.
		$html[] = '</fieldset>';

		return implode($html);
	}
371748
protected function getInput()
    {
        $type = $this->request->headers->get('CONTENT_TYPE');

        // If it's json, decode it
        if (stripos($type, '/json') !== false || stripos($type, '+json') !== false) {
            if (is_array($parsed = json_decode($this->request->getContent(), true))) {
                return $parsed;
            }
        }

        // Yes, we really do want request->request
        return $this->request->request->all();
    }
345837
protected function getInput() {

        $js = "";

        $locale   = $this->element['locale'] ? (string) $this->element['locale'] : (new LanguageFactory())->getLanguage()->get('iso');
        $format   = $this->element['format'] ? (string) $this->element['format'] : 'L';
        $valueFormat = $this->element['valueFormat'] ? (string) $this->element['valueFormat'] : 'YYYY-MM-DD HH:mm:ss';
        $minDate  = $this->element['minDate'] ? (string) $this->element['minDate'] : null;
        $maxDate  = $this->element['maxDate'] ? (string) $this->element['maxDate'] : null;
        $placeholder  = $this->element['placeholder'] ? ' placeholder="' . htmlspecialchars((string) $this->element['placeholder']) . '"' : null;
        $class    = $this->element['class'] ? ' ' . (string) $this->element['class'] : '';
        $dayOnly  = $this->element['dayOnly'] ? ((string) $this->element['dayOnly'] == "true") : false;
        $readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
        $disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';

        $options = array(
            'locale'  => $locale,
            'format'  => $format,
            'icons' => array(
                'time' => 'fa fa-clock-o',
                'date' => 'fa fa-calendar',
                'up' => 'fa fa-chevron-up',
                'down' => 'fa fa-chevron-down',
                'previous' => 'fa fa-chevron-left',
                'next' => 'fa fa-chevron-right',
                'today' => 'fa fa-dot-circle-o',
                'clear' => 'fa fa-trash',
                'close' => 'fa fa-times'
            )
        );

	    if ($this->element['showClose']) {
		    $options['showClose'] = ($this->element['showClose'] == "true");
	    }

	    if ($this->element['showClear']) {
		    $options['showClear'] = ($this->element['showClear'] == "true");
	    }

	    if ($this->element['showTodayButton']) {
		    $options['showTodayButton'] = ($this->element['showTodayButton'] == "true");
	    }

	    if ($this->element['calendarWeeks']) {
		    $options['calendarWeeks'] = ($this->element['calendarWeeks'] == "true");
	    }

	    if ($this->element['useCurrent']) {
		    $options['useCurrent'] = ($this->element['useCurrent'] == "true");
	    }

	    if ($this->element['collapse']) {
		    $options['collapse'] = ($this->element['collapse'] == "true");
	    }

	    if ($this->element['collapse']) {
		    $options['collapse'] = ($this->element['collapse'] == "true");
	    }

	    if (isset($this->element['stepping'])) {
		    $options["stepping"] = (string) $this->element['stepping'];
	    }

	    if (isset($this->element['viewMode'])) {
		    $options["viewMode"] = (string) $this->element['viewMode'];
	    }

	    if (isset($this->element['toolbarPlacement'])) {
		    $options["toolbarPlacement"] = (string) $this->element['toolbarPlacement'];
	    }

        if (isset($this->element['default'])) {
            $options["defaultDate"] = (string) $this->element['default'];
        }

        if (isset($this->element['widgetParent'])) {
            $options["widgetParent"] = (string) $this->element['widgetParent'];
        }

        if (isset($this->element['disabledDates'])) {
	    	if (is_array($this->element['disabledDates'])) {
			    $options["disabledDates"] = (array) $this->element['disabledDates'];
		    } else {
			    $options["disabledDates"] = explode(",", (string) $this->element['disabledDates']);
		    }
        }

	    if (isset($this->element['enabledDates'])) {
		    if (is_array($this->element['enabledDates'])) {
			    $options["enabledDates"] = (array) $this->element['enabledDates'];
		    } else {
			    $options["enabledDates"] = explode(",", (string) $this->element['enabledDates']);
		    }
	    }

	    if (isset($this->element['daysOfWeekDisabled'])) {
		    if (is_array($this->element['daysOfWeekDisabled'])) {
			    $options["daysOfWeekDisabled"] = (array) $this->element['daysOfWeekDisabled'];
		    } else {
			    $options["daysOfWeekDisabled"] = explode(",", (string) $this->element['daysOfWeekDisabled']);
		    }
	    }

        if (isset($this->element['sideBySide'])) {
            $options["sideBySide"] = ((string) $this->element['sideBySide'] == "true");
        }

        if (isset($this->element['useStrict'])) {
            $options["useStrict"] = ((string) $this->element['useStrict'] == "true");
        }

        if (isset($this->element['keepOpen'])) {
            $options["keepOpen"] = ((string) $this->element['keepOpen'] == "true");
        }

        if (isset($this->element['inline'])) {
            $options["inline"] = ((string) $this->element['inline'] == "true");
        }

        if (isset($this->element['keepInvalid'])) {
            $options["keepInvalid"] = ((string) $this->element['keepInvalid'] == "true");
        }

        if (isset($this->element['debug'])) {
            $options["debug"] = ((string) $this->element['debug'] == "true");
        }

        if (isset($this->element['ignoreReadonly'])) {
            $options["ignoreReadonly"] = ((string) $this->element['ignoreReadonly'] == "true");
        }

        if (isset($this->element['allowInputToggle'])) {
            $options["allowInputToggle"] = ((string) $this->element['allowInputToggle'] == "true");
        }

        if (isset($this->element['focusOnShow'])) {
            $options["focusOnShow"] = ((string) $this->element['focusOnShow'] == "true");
        }

        if (isset($minDate)) {
            if (strpos($minDate, 'field:') !== false) {

                $fieldName = substr($minDate, 6);
                $field     = $this->form->getField($fieldName);

                if ($field !== false) {

                    $js .= "$('#" . $field->id . "_picker').on('dp.change', function(e) {
    if (e.oldDate) {
        $('#" . $this->id . "_picker').data('DateTimePicker').minDate(e.date);
    }
});\n";

                }

            } else {
                $options['minDate'] = $minDate;
            }
        }

        if (isset($maxDate)) {
            if (strpos($maxDate, 'field:') !== false) {

                $fieldName = substr($maxDate, 6);
                $field     = $this->form->getField($fieldName);

                if ($field !== false) {

                    $js .= "$('#" . $field->id . "_picker').on('dp.change', function(e) {
    if (e.oldDate) {
        $('#" . $this->id . "_picker').data('DateTimePicker').maxDate(e.date);
    }
});\n";

                }

            } else {
                $options['maxDate'] = $maxDate;
            }
        }

        // Si on a une valeur.
        if (!empty($this->value) && $this->value != $this->form->getDb()->getNullDate() && $this->value != '0000-00-00') {

            // La date venant du système est en UTC.
            // On la formate avec le fuseau horaire de l'utilisateur.
            $value = (new DateUtility($this->form->getApplication()->get('timezone')))->format($this->value, 'APP_GLOBAL_DATE_ISO');
            $options['defaultDate'] = $value;

        }

        $js .= "$('#" . $this->id . "_picker').datetimepicker(" . json_encode($options) .").on('dp.change', function(e) {
    if (e.date) $('#" . $this->id . "').val(e.date";

        if ($dayOnly) {
            $js .= ".startOf('day')";
        } else {
            $js .= ".utc()";
        }

    $js .= ".format('" . $valueFormat . "'))
    else $('#" . $this->id . "').val('');
    $('#" . $this->id . "').trigger('change');
});
$('#" . $this->id . "_btn').on('click', function() {
    $('#" . $this->id . "_picker').data('DateTimePicker').show();
});";

        (new RequireJSUtility())
            ->addRequireJSModule("moment", "js/vendor/moment.min", true, array("jquery"))
            ->addRequireJSModule("bsdatetimepicker", "js/vendor/bootstrap-datetimepicker.min", true, array("jquery", "bootstrap", "moment"))
            ->addDomReadyJS($js, false, "bsdatetimepicker, css!/css/vendor/bootstrap-datetimepicker.min.css");

        $html = array();

        $html[] = '<div class="input-group date' . $class . '">';
        $html[] = '<input type="text" id="' . $this->id . '_picker" class="form-control"' . $readonly . $placeholder . $disabled . '>';
        $html[] = '<span class="input-group-addon" id="' . $this->id . '_btn">';
        $html[] = '<span class="fa fa-calendar"></span>';
        $html[] = '</span>';
        $html[] = '</div>';
        $html[] = '<input type="hidden" id="' . $this->id . '" name="' . $this->name . '" value="' . htmlspecialchars($this->value) . '">';

        return implode($html);

    }
378631
protected function getInput() {

        $js = [];

        $defaultAltFormat = 'd/m/Y';
        $defaultFormat    = 'Y-m-d';

        if ($this->element['enableTime'] == "true") {
            $defaultAltFormat .= ' H:i';
            $defaultFormat    .= ' H:i';
        }

        if ($this->element['enableSeconds'] == "true") {
            $defaultAltFormat .= ':S';
            $defaultAltFormat .= ':S';
        }

        $class         = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
        $placeholder   = $this->element['placeholder'] ? ' placeholder="' . htmlspecialchars((string) $this->element['placeholder']) . '"' : null;
        $altFormat     = $this->element['displayFormat'] ? (string) $this->element['displayFormat'] : $defaultAltFormat;
        $defaultFormat = $this->element['dateFormat'] ? (string) $this->element['dateFormat'] : $defaultFormat;
        $minDate       = $this->element['minDate'] ? (string) $this->element['minDate'] : null;
        $maxDate       = $this->element['maxDate'] ? (string) $this->element['maxDate'] : null;

        $options = [
            "altInput"   => true,
            "altFormat"  => $this->getText()->translate($altFormat),
            "utc"        => false,
            "time_24hr"  => true,
            "dateFormat" => $defaultFormat
        ];

        if ($this->element['class']) {
            $options["altInputClass"] = (string) $this->element['class'];
        }

        if ($this->element['allowInput']) {
            $options['allowInput'] = ($this->element['allowInput'] == "true");
        }

        if ($this->element['dateFormat']) {
            $options['dateFormat'] = (string) $this->element['dateFormat'];
        }

        if ($this->element['enableTime']) {
            $options['enableTime'] = ($this->element['enableTime'] == "true");
        }

        if ($this->element['hourIncrement']) {
            $options['hourIncrement'] = (int) $this->element['hourIncrement'];
        }

        if ($this->element['minuteIncrement']) {
            $options['minuteIncrement'] = (int) $this->element['minuteIncrement'];
        }

        if ($this->element['nextArrow']) {
            $options['nextArrow'] = (string) $this->element['nextArrow'];
        }

        if ($this->element['noCalendar']) {
            $options['noCalendar'] = ($this->element['noCalendar'] == "true");
        }

        if ($this->element['prevArrow']) {
            $options['prevArrow'] = (string) $this->element['prevArrow'];
        }

        if ($this->element['shorthandCurrentMonth']) {
            $options['shorthandCurrentMonth'] = ($this->element['shorthandCurrentMonth'] == "true");
        }

        if ($this->element['static']) {
            $options['static'] = ($this->element['static'] == "true");
        }

        if ($this->element['time_24hr']) {
            $options['time_24hr'] = ($this->element['time_24hr'] == "true");
        }

        if ($this->element['utc']) {
            $options['utc'] = ($this->element['utc'] == "true");
        }

        if (isset($minDate)) {
            if (strpos($minDate, 'field:') !== false) {

                $parts     = explode(".", substr($minDate, 6), 2);
                $fieldName = isset($parts[1]) ? $parts[1] : $parts[0];
                $groupName = isset($parts[1]) ? $parts[0] : null;
                $field     = $this->form->getField($fieldName, $groupName);

                if ($field !== false) {

                    $js[] = "var old_min_" . $field->id . "; 
document.getElementById('" . $field->id . "').addEventListener('change', function() {
    var v = document.getElementById('" . $field->id . "')._flatpickr.selectedDates[0];
    if (v && (!old_min_" . $field->id . " || old_min_" . $field->id . ".getTime() !== v.getTime())) {
        old_min_" . $field->id . " = v;
        document.getElementById('" . $this->id . "')._flatpickr.set('minDate', v);                 
    }
});\n";

                }

            } else {
                $options['minDate'] = $minDate;
            }
        }

        if (isset($maxDate)) {
            if (strpos($maxDate, 'field:') !== false) {

                $parts     = explode(".", substr($maxDate, 6), 2);
                $fieldName = isset($parts[1]) ? $parts[1] : $parts[0];
                $groupName = isset($parts[1]) ? $parts[0] : null;
                $field     = $this->form->getField($fieldName, $groupName);

                if ($field !== false) {

                    $js[] = "var old_max_" . $field->id . "; 
document.getElementById('" . $field->id . "').addEventListener('change', function() {
    var v = document.getElementById('" . $field->id . "')._flatpickr.selectedDates[0];
    if (v && (!old_max_" . $field->id . " || old_max_" . $field->id . ".getTime() !== v.getTime())) {
        old_max_" . $field->id . " = v;
        document.getElementById('" . $this->id . "')._flatpickr.set('maxDate', v);                 
    }
});\n";
                }

            } else {
                $options['maxDate'] = $maxDate;
            }
        }

        if ($this->element['wrap']) {
            $options['wrap'] = ($this->element['wrap'] == "true");
        }

        if ($this->element['clickOpens']) {
            $options['clickOpens'] = ($this->element['clickOpens'] == "true");
        }

        if ($this->element['inline']) {
            $options['inline'] = ($this->element['inline'] == "true");
        }

        if ($this->element['weekNumbers']) {
            $options['weekNumbers'] = ($this->element['weekNumbers'] == "true");
        }

        if ($this->element['weekNumbers']) {
            $options['weekNumbers'] = ($this->element['weekNumbers'] == "true");
        }

        if (!$options['utc'] && !$this->element['localAsValue']) {
            $options['onChange'] = "##STARTFUNC##function(d,s,i) { if (d.length) document.getElementById('" . $this->id . "').value = i.formatDate(d[0].fp_toUTC(), i.config.dateFormat) }##ENDFUNC##";
        }

        $options = str_replace(['"##STARTFUNC##', '##ENDFUNC##"'], "", json_encode($options));
        $options = str_replace('##Q##', '"', $options);
        $options = str_replace('##SLASH##', '/', $options);
        $options = str_replace("\\\\", "\\", $options);

        $js[] = "document.getElementById('" . $this->id . "').flatpickr(" . $options . ");";

        (new RequireJSUtility())
            ->addRequireJSModule("flatpickr", "js/vendor/flatpickr.min")
            ->addDomReadyJS(implode("\n", $js), false, "flatpickr, css!/css/vendor/flatpickr.min.css", false);

        return '<input id="' . $this->id . '" name="' . $this->name . '" type="text"  value="' . htmlspecialchars($this->value, ENT_QUOTES, "UTF-8") . '" ' . $placeholder . $class . '>';

    }