protected function getTextAreaAttributes() { $textarea_attrs = parent::getTextAreaAttributes(); // If 'no autocomplete' was specified, print a regular // textarea instead. if (!array_key_exists('no autocomplete', $this->mOtherArgs) || $this->mOtherArgs['no autocomplete'] == false) { list($autocompleteSettings, $remoteDataType, $delimiter) = SFTextWithAutocompleteInput::setAutocompleteValues($this->mOtherArgs); if (!is_null($remoteDataType)) { $textarea_attrs['autocompletedatatype'] = $remoteDataType; } $textarea_attrs['autocompletesettings'] = $autocompleteSettings; $textarea_attrs['class'] .= ' autocompleteInput'; } return $textarea_attrs; }
public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { // TODO: Lots of duplication of code in the parent class. Needs refactoring! global $wgOut; // If 'no autocomplete' was specified, print a regular // textarea instead. if ( array_key_exists( 'no autocomplete', $other_args ) && $other_args['no autocomplete'] == true ) { unset( $other_args['autocompletion source'] ); return SFTextAreaInput::getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ); } global $sfgTabIndex, $sfgFieldNum; list( $autocompleteSettings, $remoteDataType, $delimiter ) = SFTextWithAutocompleteInput::setAutocompleteValues( $other_args ); $input_id = 'input_' . $sfgFieldNum; if ( array_key_exists( 'editor', $other_args ) && $other_args['editor'] == 'wikieditor' && method_exists( $wgOut, 'getResourceLoader' ) && in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) && class_exists( 'WikiEditorHooks' ) ) { // load modules for all enabled features WikiEditorHooks::editPageShowEditFormInitial( $this ); $wgOut->addModules( 'ext.semanticforms.wikieditor' ); $jstext = <<<JAVASCRIPT jQuery( jQuery('#$input_id').SemanticForms_registerInputInit( ext.wikieditor.init, null ) ); JAVASCRIPT; // write JS code directly to the page's code $wgOut->addScript( Html::inlineScript( $jstext ) ); $className = "wikieditor "; } else { $className = ""; } $className .= ( $is_mandatory ) ? 'autocompleteInput mandatoryField' : 'autocompleteInput createboxInput'; if ( array_key_exists( 'class', $other_args ) ) { $className .= ' ' . $other_args['class']; } if ( array_key_exists( 'rows', $other_args ) ) { $rows = $other_args['rows']; } else { $rows = 5; } $text = ''; if ( array_key_exists( 'autogrow', $other_args ) ) { $className .= ' autoGrow'; } $textarea_attrs = array( 'tabindex' => $sfgTabIndex, 'id' => $input_id, 'name' => $input_name, 'rows' => $rows, 'class' => $className, 'autocompletesettings' => $autocompleteSettings, ); if ( array_key_exists( 'cols', $other_args ) ) { $textarea_attrs['cols'] = $other_args['cols']; // Needed to prevent CSS from overriding the manually- // set width. $textarea_attrs['style'] = 'width: auto'; } elseif ( array_key_exists( 'autogrow', $other_args ) ) { // If 'autogrow' has been set, automatically set // the number of columns - otherwise, the Javascript // won't be able to know how many characters there // are per line, and thus won't work. $textarea_attrs['cols'] = 90; $textarea_attrs['style'] = 'width: auto'; } else { $textarea_attrs['style'] = 'width: 100%'; } if ( array_key_exists( 'origName', $other_args ) ) { $inputAttrs['origName'] = $other_args['origName']; } if ( !is_null( $remoteDataType ) ) { $textarea_attrs['autocompletedatatype'] = $remoteDataType; } if ( $is_disabled ) { $textarea_attrs['disabled'] = 'disabled'; } if ( array_key_exists( 'maxlength', $other_args ) ) { $maxlength = $other_args['maxlength']; // For every actual character pressed (i.e., excluding // things like the Shift key), reduce the string to // its allowed length if it's exceeded that. // This JS code is complicated so that it'll work // correctly in IE - IE moves the cursor to the end // whenever this.value is reset, so we'll make sure // to do that only when we need to. $maxLengthJSCheck = "if (window.event && window.event.keyCode < 48 && window.event.keyCode != 13) return; if (this.value.length > $maxlength) { this.value = this.value.substring(0, $maxlength); }"; $textarea_attrs['onKeyDown'] = $maxLengthJSCheck; $textarea_attrs['onKeyUp'] = $maxLengthJSCheck; } if ( array_key_exists( 'placeholder', $other_args ) ) { $textarea_attrs = $other_args['placeholder']; } $textarea_input = Html::element( 'textarea', $textarea_attrs, $cur_value ); $text .= $textarea_input; if ( array_key_exists( 'uploadable', $other_args ) && $other_args['uploadable'] == true ) { if ( array_key_exists( 'default filename', $other_args ) ) { $default_filename = $other_args['default filename']; } else { $default_filename = ''; } $text .= self::uploadableHTML( $input_id, $delimiter, $default_filename, $cur_value, $other_args ); } $spanClass = 'inputSpan'; if ( $is_mandatory ) { $spanClass .= ' mandatoryFieldSpan'; } $text = "\n" . Html::rawElement( 'span', array( 'class' => $spanClass ), $text ); return $text; }
public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) { global $sfgTabIndex, $sfgFieldNum, $sfgEDSettings; $other_args['is_list'] = true; if (array_key_exists('values from external data', $other_args)) { $autocompleteSettings = 'external data'; $remoteDataType = null; if (array_key_exists('origName', $other_args)) { $name = $other_args['origName']; } else { $name = $input_name; } $sfgEDSettings[$name] = array(); if ($other_args['values from external data'] != null) { $sfgEDSettings[$name]['title'] = $other_args['values from external data']; } if (array_key_exists('image', $other_args)) { $image_param = $other_args['image']; $sfgEDSettings[$name]['image'] = $image_param; global $edgValues; for ($i = 0; $i < count($edgValues[$image_param]); $i++) { $image = $edgValues[$image_param][$i]; if (strpos($image, "http") !== 0) { $file = wfFindFile($image); if ($file) { $url = $file->getFullUrl(); $edgValues[$image_param][$i] = $url; } else { $edgValues[$image_param][$i] = ""; } } } } if (array_key_exists('description', $other_args)) { $sfgEDSettings[$name]['description'] = $other_args['description']; } } else { list($autocompleteSettings, $remoteDataType, $delimiter) = SFTextWithAutocompleteInput::setAutocompleteValues($other_args); } if (is_array($cur_value)) { $cur_value = implode($delimiter, $cur_value); } $className = 'sfTokens '; $className .= $is_mandatory ? 'mandatoryField' : 'createboxInput'; if (array_key_exists('class', $other_args)) { $className .= ' ' . $other_args['class']; } $input_id = 'input_' . $sfgFieldNum; if (array_key_exists('size', $other_args)) { $size = $other_args['size']; } else { $size = '100'; } $inputAttrs = array('id' => $input_id, 'size' => $size, 'class' => $className, 'tabindex' => $sfgTabIndex, 'autocompletesettings' => $autocompleteSettings); if (array_key_exists('origName', $other_args)) { $inputAttrs['origName'] = $other_args['origName']; } if (array_key_exists('existing values only', $other_args)) { $inputAttrs['existingvaluesonly'] = 'true'; } if (!is_null($remoteDataType)) { $inputAttrs['autocompletedatatype'] = $remoteDataType; } if ($is_disabled) { $inputAttrs['disabled'] = true; } if (array_key_exists('maxlength', $other_args)) { $inputAttrs['maxlength'] = $other_args['maxlength']; } if (array_key_exists('placeholder', $other_args)) { $inputAttrs['placeholder'] = $other_args['placeholder']; } if (array_key_exists('max values', $other_args)) { $inputAttrs['maxvalues'] = $other_args['max values']; } $text = "\n\t" . Html::input($input_name, $cur_value, 'text', $inputAttrs) . "\n"; $spanClass = 'inputSpan'; if ($is_mandatory) { $spanClass .= ' mandatoryFieldSpan'; } $text = "\n" . Html::rawElement('span', array('class' => $spanClass), $text); return $text; }