/** * converts to HTML * * @param FieldTable $field * @param UserTable $user * @param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'search' for searches * @param string $tag <tag * @param string $type type="$type" * @param string $value value="$value" * @param string $additional 'xxxx="xxx" yy="y"' WARNING: No classes in here, use $classes * @param string $allValues * @param boolean $displayFieldIcons * @param array $classes CSS classes * @return string HTML: <tag type="$type" value="$value" xxxx="xxx" yy="y" /> */ protected function _fieldEditToHtml(&$field, &$user, $reason, $tag, $type, $value, $additional, $allValues = null, $displayFieldIcons = true, $classes = null) { global $_CB_framework, $_PLUGINS; $readOnly = $this->_isReadOnly($field, $user, $reason); $oReq = $this->_isRequired($field, $user, $reason); if ($readOnly) { $additional .= ' disabled="disabled"'; $oReq = 0; } if ($oReq) { $classes[] = 'required'; } $inputName = $field->name; $translatedTitle = $this->getFieldTitle($field, $user, 'html', $reason); $translatedPlaceholder = $this->getFieldPlaceholder($field, $user, 'text', $reason); $htmlDescription = $this->getFieldDescription($field, $user, 'htmledit', $reason); $trimmedDescription = trim(strip_tags($htmlDescription)); $htmlInput = null; switch ($type) { case 'radio': if ($classes) { $additional .= ' class="' . implode(' ', $classes) . '"'; } $tooltip = $trimmedDescription ? cbTooltip($_CB_framework->getUi(), $htmlDescription, $translatedTitle, null, null, null, null, 'data-hascbtooltip="true"') : null; $htmlInput = moscomprofilerHTML::radioListTable($allValues, $inputName, $additional, 'value', 'text', $value, $field->cols, $field->rows, $field->size, $oReq, null, $tooltip); break; /** @noinspection PhpMissingBreakStatementInspection */ /** @noinspection PhpMissingBreakStatementInspection */ case 'multiselect': $additional .= ' multiple="multiple"'; $inputName .= '[]'; // no break on purpose for fall-through: // no break on purpose for fall-through: case 'select': $classes[] = 'form-control'; $additional .= ' class="' . implode(' ', $classes) . '"'; if ($field->size > 0) { $additional .= ' size="' . $field->size . '"'; } $tooltip = $trimmedDescription ? cbTooltip($_CB_framework->getUi(), $htmlDescription, $translatedTitle, null, null, null, null, $additional) : $additional; $htmlInput = moscomprofilerHTML::selectList($allValues, $inputName, $tooltip, 'value', 'text', $this->_explodeCBvaluesToObj($value), $oReq); break; case 'multicheckbox': if ($classes) { $additional .= ' class="' . implode(' ', $classes) . '"'; } $tooltip = $trimmedDescription ? cbTooltip($_CB_framework->getUi(), $htmlDescription, $translatedTitle, null, null, null, null, 'data-hascbtooltip="true"') : null; $htmlInput = moscomprofilerHTML::checkboxListTable($allValues, $inputName . '[]', $additional, 'value', 'text', $this->_explodeCBvaluesToObj($value), $field->cols, $field->rows, $field->size, $oReq, null, $tooltip); break; case 'checkbox': if ($classes) { $additional .= ' class="' . implode(' ', $classes) . '"'; } $tooltip = $trimmedDescription ? cbTooltip($_CB_framework->getUi(), $htmlDescription, $translatedTitle, null, null, null, null, $additional) : $additional; $htmlInput = '<span class="cbSingleCntrl">' . '<label for="' . htmlspecialchars($inputName) . '" class="checkbox-inline">' . '<input type="checkbox" id="' . htmlspecialchars($inputName) . '" name="' . htmlspecialchars($inputName) . '" value="' . htmlspecialchars($value) . '"' . $tooltip . ' />' . '</label>' . '</span>'; break; /** @noinspection PhpMissingBreakStatementInspection */ /** @noinspection PhpMissingBreakStatementInspection */ case 'password': $additional .= ' autocomplete="off"'; // on purpose no break here ! // on purpose no break here ! case 'text': case 'primaryemailaddress': case 'emailaddress': case 'webaddress': case 'predefined': if ($type != 'password') { $type = 'text'; // Prevent predefined, emailaddress, etc.. from using invalid html type } if ($field->size > 0) { $additional .= ' size="' . $field->size . '"'; } else { $additional .= ' size="25"'; } $fieldMaxLength = $this->getMaxLength($field); if ($fieldMaxLength > 0) { $additional .= ' maxlength="' . $fieldMaxLength . '"'; } if ($translatedPlaceholder) { $additional .= ' placeholder="' . htmlspecialchars($translatedPlaceholder) . '"'; } $classes[] = 'form-control'; break; case 'textarea': $tag = 'textarea'; $type = null; if ($field->cols > 0) { $additional .= ' cols="' . $field->cols . '"'; } if ($field->rows > 0) { $additional .= ' rows="' . $field->rows . '"'; } $fieldMaxLength = $this->getMaxLength($field); if ($fieldMaxLength > 0) { $additional .= ' maxlength="' . $fieldMaxLength . '"'; } if ($translatedPlaceholder) { $additional .= ' placeholder="' . htmlspecialchars($translatedPlaceholder) . '"'; } $classes[] = 'form-control'; break; case 'file': $classes[] = 'form-control'; if ($field->size > 0) { $additional .= ' size="' . $field->size . '"'; } break; case 'html': return $value; break; default: break; } if ($classes) { $additional .= ' class="' . implode(' ', $classes) . '"'; } // if ( $_PLUGINS->triggerListenersExist( 'onInputFieldHtmlRender' ) ) { // return implode( '', $_PLUGINS->trigger( 'onInputFieldHtmlRender', array( &$this, &$field, &$user, $reason, $tag, $type, $inputName, $value, $additional, $htmlDescription, $allValues, $displayFieldIcons, $oReq ) ) ); // } if ($htmlInput === null) { $tooltip = $trimmedDescription ? cbTooltip($_CB_framework->getUi(), $htmlDescription, $translatedTitle, null, null, null, null, $additional) : $additional; $htmlInput = '<' . $tag . ($type ? ' type="' . $type . '"' : '') . ' name="' . $inputName . '" id="' . $inputName . '"' . ($tag == 'textarea' ? '' : ' value="' . htmlspecialchars($value) . '"') . $tooltip . ($tag == 'textarea' ? '>' . htmlspecialchars($value) . '</textarea>' : ' />'); } $htmlIcons = $this->_fieldIconsHtml($field, $user, 'htmledit', $reason, $tag, $type, $value, $additional, $allValues, $displayFieldIcons, $oReq); if ($reason != 'search') { $htmlInput = $this->formatFieldValueLayout($htmlInput, $reason, $field, $user); } if ($_PLUGINS->triggerListenersExist('onInputFieldHtmlRender')) { return implode('', $_PLUGINS->trigger('onInputFieldHtmlRender', array($htmlInput, $htmlIcons, $this, $field, $user, $reason, $tag, $type, $inputName, $value, $additional, $htmlDescription, $allValues, $displayFieldIcons, $oReq))); } return $htmlInput . $htmlIcons; }
/** * converts to HTML * * @param moscomprofilerFields $field * @param moscomprofilerUser $user * @param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'search' for searches * @param string $tag <tag * @param string $type type="$type" * @param string $value value="$value" * @param string $additional 'xxxx="xxx" yy="y"' WARNING: No classes in here, use $classes * @param string $allValues * @param boolean $displayFieldIcons * @param array $classes CSS classes * @return string HTML: <tag type="$type" value="$value" xxxx="xxx" yy="y" /> */ function _fieldEditToHtml(&$field, &$user, $reason, $tag, $type, $value, $additional, $allValues = null, $displayFieldIcons = true, $classes = null) { global $_PLUGINS; $readOnly = $this->_isReadOnly($field, $user, $reason); $oReq = $this->_isRequired($field, $user, $reason); if ($readOnly) { $additional .= ' disabled="disabled"'; $oReq = 0; } if ($oReq) { $classes[] = 'required'; if (!defined('_CB_VALIDATE_NEW')) { $additional .= ' mosReq="1"' . ' mosLabel="' . htmlspecialchars($this->getFieldTitle($field, $user, 'text', $reason)) . '"'; } } if ($field->size > 0) { $additional .= ' size="' . $field->size . '" '; } $inputName = $field->name; $translatedTitle = $this->getFieldTitle($field, $user, 'html', $reason); $htmlDescription = $this->getFieldDescription($field, $user, 'htmledit', $reason); $titleAttr = $this->_renderFieldInputTitleAttribute($field, $user, 'htmledit', $reason, $translatedTitle, $htmlDescription); $htmlInput = null; switch ($type) { case 'radio': if ($classes) { $additional .= ' class="' . implode(' ', $classes) . '"'; } $htmlInput = moscomprofilerHTML::radioListTable($allValues, $inputName, $additional . $titleAttr, 'value', 'text', $value, $field->cols, $field->rows, $field->size, $oReq); break; case 'multiselect': $additional .= ' multiple="multiple"'; if ($classes) { $additional .= ' class="' . implode(' ', $classes) . '"'; } $inputName .= '[]'; // no break on purpose for fall-through: // no break on purpose for fall-through: case 'select': $classes[] = 'inputbox'; $additional .= ' class="' . implode(' ', $classes) . '"'; $htmlInput = moscomprofilerHTML::selectList($allValues, $inputName, $additional . $titleAttr, 'value', 'text', $this->_explodeCBvaluesToObj($value), $oReq); break; case 'multicheckbox': $additional .= ' size="' . $field->size . '"'; if ($classes) { $additional .= ' class="' . implode(' ', $classes) . '"'; } $htmlInput = moscomprofilerHTML::checkboxListTable($allValues, $inputName . '[]', $additional . $titleAttr, 'value', 'text', $this->_explodeCBvaluesToObj($value), $field->cols, $field->rows, $field->size, $oReq); break; case 'password': $additional .= ' autocomplete="off"'; // on purpose no break here ! // on purpose no break here ! case 'text': case 'primaryemailaddress': case 'emailaddress': case 'webaddress': case 'predefined': if ($field->size == 0) { $additional .= ' size="25"'; } $fieldMaxLength = $this->getMaxLength($field); if ($fieldMaxLength > 0) { $additional .= ' maxlength="' . $fieldMaxLength . '"'; } $classes[] = 'inputbox'; break; case 'textarea': $tag = 'textarea'; $type = null; if ($field->cols > 0) { $additional .= ' cols="' . $field->cols . '"'; } if ($field->rows > 0) { $additional .= ' rows="' . $field->rows . '"'; } $fieldMaxLength = $this->getMaxLength($field); if ($fieldMaxLength > 0) { $additional .= ' maxlength="' . $fieldMaxLength . '"'; } $classes[] = 'inputbox'; break; case 'file': $classes[] = 'inputbox'; break; case 'html': return $value; break; default: break; } if ($classes) { $additional .= ' class="' . implode(' ', $classes) . '"'; } // if ( $_PLUGINS->triggerListenersExist( 'onInputFieldHtmlRender' ) ) { // return implode( '', $_PLUGINS->trigger( 'onInputFieldHtmlRender', array( &$this, &$field, &$user, $reason, $tag, $type, $inputName, $value, $additional, $htmlDescription, $allValues, $displayFieldIcons, $oReq ) ) ); // } if ($htmlInput === null) { $htmlInput = '<' . $tag . ($type ? ' type="' . $type . '"' : '') . ' name="' . $inputName . '" id="' . $inputName . '"' . ($tag == 'textarea' ? '' : ' value="' . htmlspecialchars($value) . '"') . ($additional ? ' ' . $additional : '') . $titleAttr . ($tag == 'textarea' ? '>' . htmlspecialchars($value) . '</textarea>' : ' />'); } $htmlIcons = $this->_fieldIconsHtml($field, $user, 'htmledit', $reason, $tag, $type, $value, $additional, $allValues, $displayFieldIcons, $oReq); if ($_PLUGINS->triggerListenersExist('onInputFieldHtmlRender')) { return implode('', $_PLUGINS->trigger('onInputFieldHtmlRender', array($htmlInput, $htmlIcons, $this, $field, $user, $reason, $tag, $type, $inputName, $value, $additional, $htmlDescription, $allValues, $displayFieldIcons, $oReq))); } else { return $htmlInput . $htmlIcons; } }