/** * Method to get the user field input markup. * * @return string The field input markup. */ protected function getInput() { $html = array(); $groups = $this->getGroups(); $excluded = $this->getExcluded(); $link = 'index.php?option=com_users&view=users&layout=modal&tmpl=component&field=' . $this->id . (isset($groups) ? '&groups=' . base64_encode(json_encode($groups)) : '') . (isset($excluded) ? '&excluded=' . base64_encode(json_encode($excluded)) : ''); // Initialize some field attributes. $attr = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; // Initialize JavaScript field attributes. $onchange = (string) $this->element['onchange']; // Load the modal behavior script. WindwalkerScript::modal('.hasUserModal'); JQueryScript::ui(array('effect')); // Build the script. $js = <<<JS function jSelectUser_{$this->id}(id, title) { \tvar input = jQuery('#{$this->id}_id'); \tvar oldId = input.val(); \tif (oldId != id) { \t\tinput.val(id); \t\tjQuery('#{$this->id}_name').val(title).removeClass('invalid').delay(300).effect('highlight'); \t} \t{$onchange}; \tWindwalker.Modal.hide(); }; JS; // Add the script to the document head. $asset = Container::getInstance()->get('helper.asset'); $asset->internalJS($js); // Load the current username if available. $table = JTable::getInstance('user'); if ($this->value) { $table->load($this->value); } elseif (strtoupper($this->value) == 'CURRENT') { // 'CURRENT' is not a reasonable value to be placed in the html $this->value = JFactory::getUser()->id; $table->load($this->value); } else { $table->name = JText::_('JLIB_FORM_SELECT_USER'); } // Create a dummy text field with the user name. $html[] = '<div class="input-append">'; $html[] = ' <input type="text" id="' . $this->id . '_name" value="' . htmlspecialchars($table->name, ENT_COMPAT, 'UTF-8') . '"' . ' readonly' . $attr . ' />'; // Create the user select button. if (!XmlHelper::getBool($this->element, 'readonly', false)) { $html[] = ' <a class="btn btn-primary hasUserModal modal_' . $this->id . '" title="' . JText::_('JLIB_FORM_CHANGE_USER') . '" href="' . $link . '"' . ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">'; $html[] = '<i class="icon-user"></i></a>'; } $html[] = '</div>'; // Create the real field, hidden, that stored the user id. $html[] = '<input type="hidden" id="' . $this->id . '_id" name="' . $this->name . '" value="' . $this->value . '" />'; return implode("\n", $html); }
/** * Method to get the field input markup. * * @return string The field input markup. */ public function getInput() { // Load the modal behavior script. WindwalkerScript::modal('.hasFinderModal'); if (!static::$initialised) { $this->setScript(); } // Setup variables for display. // ================================================================ $html = array(); $disabled = XmlHelper::getBool($this->element, 'disabled'); $readonly = XmlHelper::getBool($this->element, 'readonly'); $link = $this->getLink(); $title = $this->getTitle(); // Set Title // ================================================================ if (empty($title)) { $title = \JText::_(XmlHelper::get($this->element, 'select_label', 'LIB_WINDWALKER_FORMFIELD_FINDER_SELECT_FILE')); } $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); // The text field. // ================================================================ $preview = $this->getPreview(); // The current user display field. $html[] = '<span class="' . (!$disabled && !$readonly ? 'input-append' : '') . '">'; $html[] = '<input type="text" class="finder-item-name ' . (!$disabled && !$readonly ? 'input-medium ' . $this->element['class'] : $this->element['class']) . '" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />'; if (!$disabled && !$readonly) { $html[] = '<a class="hasFinderModal btn btn-primary" title="' . JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_BROWSE_FILES') . '" href="' . $link . '&' . JSession::getFormToken() . '=1"> <i class="icon-picture"></i> ' . JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_BROWSE_FILES') . '</a>'; } $html[] = '</span>'; // The class='required' for client side validation // ================================================================ $class = ''; if ($this->required) { $class = ' class="required modal-value"'; } // Velue store input $disabled_attr = $disabled ? ' disabled="true" ' : ''; $html[] = '<input type="hidden" id="' . $this->id . '"' . $class . ' name="' . $this->name . '" value="' . $this->value . '" ' . $disabled_attr . ' />'; $html = implode("\n", $html); $options = array('text' => array('clear_title' => JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_SELECT_FILE'))); $this->initScript('#' . $this->id, $options); if (!$disabled && !$readonly) { $html .= '<a class="btn btn-danger hasTooltip clear-button" title="' . JText::_('JLIB_FORM_BUTTON_CLEAR') . '"' . ' href="javascript: void(0)">'; $html .= '<i class="icon-remove"></i></a>'; } // Image Preview // ================================================================ $html = $html . $preview; return $html; }
/** * Method to get the field input markup. * * @return string The field input markup. */ public function getInput() { // Load the modal behavior script. $this->setElement(); $this->setScript(); // Setup variables for display. $readonly = $this->getElement('readonly', false); $disabled = $this->getElement('disabled', false); $html = array(); $link = $this->getLink(); $title = $this->getTitle(); if (empty($title)) { $title = $this->element['select_label'] ? (string) JText::_($this->element['select_label']) : JText::_('COM_' . strtoupper($this->component) . '_SELECT_ITEM'); } $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); // The current user display field. $html[] = '<span class="' . (!$disabled && !$readonly ? 'input-append' : '') . '">'; $html[] = '<input type="text" class="' . (!$disabled && !$readonly ? 'input-medium ' . $this->element['class'] : $this->element['class']) . '" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />'; if (!$disabled && !$readonly) { WindwalkerScript::modal('.hasFieldModal'); $html[] = '<a class="hasFieldModal btn" title="' . JText::_('COM_' . strtoupper($this->component) . '_CHANGE_ITEM_BUTTON') . '" href="' . $link . '&' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-file"></i> ' . JText::_('JSELECT') . '</a>'; } $html[] = '</span>'; // The active article id field. if (!$this->value) { $value = ''; } else { $value = $this->value; } // Class='required' for client side validation $class = ''; if ($this->required) { $class = ' class="required modal-value"'; } $html[] = '<input type="hidden" id="' . $this->id . '_id"' . $class . ' name="' . $this->name . '" value="' . $value . '" />'; return implode("\n", $html) . $this->quickadd(); }