Ejemplo n.º 1
0
 public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args)
 {
     // For backward compatibility with pre-SF-2.1 forms
     if (array_key_exists('no autocomplete', $other_args) && $other_args['no autocomplete'] == true) {
         unset($other_args['autocompletion source']);
         return SFTextInput::getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args);
     }
     global $sfgTabIndex, $sfgFieldNum;
     $className = 'sfComboBox';
     if ($is_mandatory) {
         $className .= ' mandatoryField';
     }
     if (array_key_exists('class', $other_args)) {
         $className .= ' ' . $other_args['class'];
     }
     if (array_key_exists('size', $other_args)) {
         $size = $other_args['size'];
     } else {
         $size = '35';
     }
     // There's no direct correspondence between the 'size='
     // attribute for text inputs and the number of pixels, but
     // multiplying by 6 seems to be about right for the major
     // browsers.
     $pixel_width = $size * 6 . 'px';
     list($autocompleteFieldType, $autocompletionSource) = SFTextWithAutocompleteInput::getAutocompletionTypeAndSource($other_args);
     // @TODO - that count() check shouldn't be necessary
     if (array_key_exists('possible_values', $other_args) && count($other_args['possible_values']) > 0) {
         $values = $other_args['possible_values'];
     } elseif ($autocompleteFieldType == 'values') {
         $values = explode(',', $other_args['values']);
     } else {
         $values = SFUtils::getAutocompleteValues($autocompletionSource, $autocompleteFieldType);
     }
     $autocompletionSource = str_replace("'", "\\'", $autocompletionSource);
     $optionsText = Html::element('option', array('value' => $cur_value), null, false) . "\n";
     foreach ($values as $value) {
         $optionsText .= Html::element('option', array('value' => $value), $value) . "\n";
     }
     $selectAttrs = array('id' => "input_{$sfgFieldNum}", 'name' => $input_name, 'class' => $className, 'tabindex' => $sfgTabIndex, 'autocompletesettings' => $autocompletionSource, 'comboboxwidth' => $pixel_width);
     if (array_key_exists('origName', $other_args)) {
         $selectAttrs['origname'] = $other_args['origName'];
     }
     if (array_key_exists('existing values only', $other_args)) {
         $selectAttrs['existingvaluesonly'] = 'true';
     }
     $selectText = Html::rawElement('select', $selectAttrs, $optionsText);
     $divClass = 'ui-widget';
     if ($is_mandatory) {
         $divClass .= ' mandatory';
     }
     $text = Html::rawElement('div', array('class' => $divClass), $selectText);
     return $text;
 }
Ejemplo n.º 2
0
    static function renderFormInput(&$parser)
    {
        global $wgHtml5;
        $params = func_get_args();
        array_shift($params);
        // don't need the parser
        // set defaults
        $inFormName = $inValue = $inButtonStr = $inQueryStr = '';
        $inQueryArr = array();
        $positionalParameters = false;
        $inAutocompletionSource = '';
        $inRemoteAutocompletion = false;
        $inSize = 25;
        $classStr = "sfFormInput";
        $inPlaceholder = "";
        // assign params - support unlabelled params, for backwards compatibility
        foreach ($params as $i => $param) {
            $elements = explode('=', $param, 2);
            // set param_name and value
            if (count($elements) > 1 && !$positionalParameters) {
                $param_name = trim($elements[0]);
                // parse (and sanitize) parameter values
                $value = trim($parser->recursiveTagParse($elements[1]));
            } else {
                $param_name = null;
                // parse (and sanitize) parameter values
                $value = trim($parser->recursiveTagParse($param));
            }
            if ($param_name == 'form') {
                $inFormName = $value;
            } elseif ($param_name == 'size') {
                $inSize = $value;
            } elseif ($param_name == 'default value') {
                $inValue = $value;
            } elseif ($param_name == 'button text') {
                $inButtonStr = $value;
            } elseif ($param_name == 'query string') {
                // Change HTML-encoded ampersands directly to
                // URL-encoded ampersands, so that the string
                // doesn't get split up on the '&'.
                $inQueryStr = str_replace('&', '%26', $value);
                // "Decode" any other HTML tags.
                $inQueryStr = html_entity_decode($inQueryStr, ENT_QUOTES);
                parse_str($inQueryStr, $arr);
                $inQueryArr = SFUtils::array_merge_recursive_distinct($inQueryArr, $arr);
            } elseif ($param_name == 'autocomplete on category') {
                $inAutocompletionSource = $value;
                $autocompletion_type = 'category';
            } elseif ($param_name == 'autocomplete on namespace') {
                $inAutocompletionSource = $value;
                $autocompletion_type = 'namespace';
            } elseif ($param_name == 'remote autocompletion') {
                $inRemoteAutocompletion = true;
            } elseif ($param_name == 'placeholder') {
                $inPlaceholder = $value;
            } elseif ($param_name == null && $value == 'popup') {
                SFUtils::loadScriptsForPopupForm($parser);
                $classStr .= ' popupforminput';
            } elseif ($param_name !== null && !$positionalParameters) {
                $value = urlencode($value);
                parse_str("{$param_name}={$value}", $arr);
                $inQueryArr = SFUtils::array_merge_recursive_distinct($inQueryArr, $arr);
            } elseif ($i == 0) {
                $inFormName = $value;
                $positionalParameters = true;
            } elseif ($i == 1) {
                $inSize = $value;
            } elseif ($i == 2) {
                $inValue = $value;
            } elseif ($i == 3) {
                $inButtonStr = $value;
            } elseif ($i == 4) {
                // Change HTML-encoded ampersands directly to
                // URL-encoded ampersands, so that the string
                // doesn't get split up on the '&'.
                $inQueryStr = str_replace('&', '%26', $value);
                parse_str($inQueryStr, $arr);
                $inQueryArr = SFUtils::array_merge_recursive_distinct($inQueryArr, $arr);
            }
        }
        $fs = SpecialPageFactory::getPage('FormStart');
        $fs_url = $fs->getTitle()->getLocalURL();
        $str = <<<END
\t\t\t<form name="createbox" action="{$fs_url}" method="get" class="{$classStr}">
\t\t\t<p>

END;
        $formInputAttrs = array('size' => $inSize);
        if ($wgHtml5) {
            $formInputAttrs['placeholder'] = $inPlaceholder;
            $formInputAttrs['autofocus'] = 'autofocus';
        }
        // Now apply the necessary settings and Javascript, depending
        // on whether or not there's autocompletion (and whether the
        // autocompletion is local or remote).
        $input_num = 1;
        if (empty($inAutocompletionSource)) {
            $formInputAttrs['class'] = 'formInput';
        } else {
            self::$num_autocompletion_inputs++;
            $input_num = self::$num_autocompletion_inputs;
            // place the necessary Javascript on the page, and
            // disable the cache (so the Javascript will show up) -
            // if there's more than one autocompleted #forminput
            // on the page, we only need to do this the first time
            if ($input_num == 1) {
                $parser->disableCache();
                SFUtils::addJavascriptAndCSS($parser);
            }
            $inputID = 'input_' . $input_num;
            $formInputAttrs['id'] = $inputID;
            $formInputAttrs['class'] = 'autocompleteInput createboxInput formInput';
            global $sfgMaxLocalAutocompleteValues;
            $autocompletion_values = SFUtils::getAutocompleteValues($inAutocompletionSource, $autocompletion_type);
            if (count($autocompletion_values) > $sfgMaxLocalAutocompleteValues || $inRemoteAutocompletion) {
                $formInputAttrs['autocompletesettings'] = $inAutocompletionSource;
                $formInputAttrs['autocompletedatatype'] = $autocompletion_type;
            } else {
                global $sfgAutocompleteValues;
                $sfgAutocompleteValues[$inputID] = $autocompletion_values;
                $formInputAttrs['autocompletesettings'] = $inputID;
            }
        }
        $str .= "\t" . Html::input('page_name', $inValue, 'text', $formInputAttrs) . "\n";
        // if the form start URL looks like "index.php?title=Special:FormStart"
        // (i.e., it's in the default URL style), add in the title as a
        // hidden value
        if (($pos = strpos($fs_url, "title=")) > -1) {
            $str .= Html::hidden("title", urldecode(substr($fs_url, $pos + 6)));
        }
        if ($inFormName == '') {
            $str .= SFUtils::formDropdownHTML();
        } else {
            $str .= Html::hidden("form", $inFormName);
        }
        // Recreate the passed-in query string as a set of hidden variables.
        if (!empty($inQueryArr)) {
            // query string has to be turned into hidden inputs.
            $query_components = explode('&', http_build_query($inQueryArr, '', '&'));
            foreach ($query_components as $query_component) {
                $var_and_val = explode('=', $query_component, 2);
                if (count($var_and_val) == 2) {
                    $str .= Html::hidden(urldecode($var_and_val[0]), urldecode($var_and_val[1]));
                }
            }
        }
        $button_str = $inButtonStr != '' ? $inButtonStr : wfMessage('sf_formstart_createoredit')->escaped();
        $str .= <<<END
\t\t\t<input type="submit" value="{$button_str}" id="input_button_{$input_num}" class="forminput_button"/></p>
\t\t\t</form>

END;
        if (!empty($inAutocompletionSource)) {
            $str .= "\t\t\t" . Html::element('div', array('class' => 'page_name_auto_complete', 'id' => "div_{$input_num}"), ' ') . "\n";
        }
        // hack to remove newline from beginning of output, thanks to
        // http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function
        return $parser->insertStripItem($str, $parser->mStripState);
    }
 public static function setAutocompleteValues($field_args)
 {
     global $sfgAutocompleteValues, $sfgMaxLocalAutocompleteValues;
     // Get all autocomplete-related values, plus delimiter value
     // (it's needed also for the 'uploadable' link, if there is one).
     list($autocompleteFieldType, $autocompletionSource) = self::getAutocompletionTypeAndSource($field_args);
     $autocompleteSettings = $autocompletionSource;
     $is_list = array_key_exists('is_list', $field_args) && $field_args['is_list'] == true;
     if ($is_list) {
         $autocompleteSettings .= ',list';
         if (array_key_exists('delimiter', $field_args)) {
             $delimiter = $field_args['delimiter'];
             $autocompleteSettings .= ',' . $delimiter;
         } else {
             $delimiter = ',';
         }
     } else {
         $delimiter = null;
     }
     $remoteDataType = null;
     if (array_key_exists('remote autocompletion', $field_args) && $field_args['remote autocompletion'] == true) {
         $remoteDataType = $autocompleteFieldType;
     } elseif ($autocompletionSource !== '') {
         // @TODO - that count() check shouldn't be necessary
         if (array_key_exists('possible_values', $field_args) && count($field_args['possible_values']) > 0) {
             $autocompleteValues = $field_args['possible_values'];
         } elseif ($autocompleteFieldType == 'values') {
             $autocompleteValues = explode(',', $field_args['values']);
         } else {
             $autocompleteValues = SFUtils::getAutocompleteValues($autocompletionSource, $autocompleteFieldType);
         }
         if (count($autocompleteValues) > $sfgMaxLocalAutocompleteValues && $autocompleteFieldType != 'values' && !array_key_exists('values dependent on', $field_args) && !array_key_exists('mapping template', $field_args)) {
             $remoteDataType = $autocompleteFieldType;
         }
         $sfgAutocompleteValues[$autocompleteSettings] = $autocompleteValues;
     }
     return array($autocompleteSettings, $remoteDataType, $delimiter);
 }
 public static function setAutocompleteValues($field_args)
 {
     global $sfgAutocompleteValues, $sfgMaxLocalAutocompleteValues;
     list($autocompleteFieldType, $autocompletionSource) = SFTextWithAutocompleteInput::getAutocompletionTypeAndSource($field_args);
     $remoteDataType = null;
     if (array_key_exists('remote autocompletion', $field_args) && $field_args['remote autocompletion'] == true) {
         $remoteDataType = $autocompleteFieldType;
     } elseif ($autocompletionSource !== '') {
         // @TODO - that count() check shouldn't be necessary
         if (array_key_exists('possible_values', $field_args) && count($field_args['possible_values']) > 0) {
             $autocompleteValues = $field_args['possible_values'];
         } elseif ($autocompleteFieldType == 'values') {
             $autocompleteValues = explode(',', $field_args['values']);
         } else {
             $autocompleteValues = SFUtils::getAutocompleteValues($autocompletionSource, $autocompleteFieldType);
         }
         if (count($autocompleteValues) > $sfgMaxLocalAutocompleteValues && $autocompleteFieldType != 'values' && !array_key_exists('values dependent on', $field_args) && !array_key_exists('mapping template', $field_args)) {
             $remoteDataType = $autocompleteFieldType;
         }
         $sfgAutocompleteValues[$autocompletionSource] = $autocompleteValues;
     }
     $autocompletionSource = str_replace("'", "\\'", $autocompletionSource);
     return array($autocompletionSource, $remoteDataType);
 }
	static function renderFormInput ( &$parser ) {
		global $wgVersion;

		$params = func_get_args();
		array_shift( $params ); // don't need the parser
		// set defaults
		$inFormName = $inValue = $inButtonStr = $inQueryStr = '';
		$inAutocompletionSource = '';
		$inRemoteAutocompletion = false;
		$inSize = 25;
		$classStr = "";
		// assign params - support unlabelled params, for backwards compatibility
		foreach ( $params as $i => $param ) {
			$elements = explode( '=', $param, 2 );
			$param_name = null;
			$value = trim( $param );
			if ( count( $elements ) > 1 ) {
				$param_name = trim( $elements[0] );
				$value = trim( $parser->recursiveTagParse( $elements[1] ) );
			}
			if ( $param_name == 'form' )
				$inFormName = $value;
			elseif ( $param_name == 'size' )
				$inSize = $value;
			elseif ( $param_name == 'default value' )
				$inValue = $value;
			elseif ( $param_name == 'button text' )
				$inButtonStr = $value;
			elseif ( $param_name == 'query string' )
				$inQueryStr = $value;
			elseif ( $param_name == 'autocomplete on category' ) {
				$inAutocompletionSource = $value;
				$autocompletion_type = 'category';
			} elseif ( $param_name == 'autocomplete on namespace' ) {
				$inAutocompletionSource = $value;
				$autocompletion_type = 'namespace';
			} elseif ( $param_name == 'remote autocompletion' ) {
				$inRemoteAutocompletion = true;
			} elseif ( $param_name == null && $value == 'popup' ) {
				self::loadScriptsForPopupForm( $parser );
				$classStr = 'popupforminput';
			}
			elseif ( $i == 0 )
				$inFormName = $param;
			elseif ( $i == 1 )
				$inSize = $param;
			elseif ( $i == 2 )
				$inValue = $param;
			elseif ( $i == 3 )
				$inButtonStr = $param;
			elseif ( $i == 4 )
				$inQueryStr = $param;
		}

		$fs = SFUtils::getSpecialPage( 'FormStart' );

		$fs_url = $fs->getTitle()->getLocalURL();
		$str = <<<END
			<form name="createbox" action="$fs_url" method="get" class="$classStr">
			<p>

END;
		$formInputAttrs = array( 'size' => $inSize );

		// Now apply the necessary settings and Javascript, depending
		// on whether or not there's autocompletion (and whether the
		// autocompletion is local or remote).
		$input_num = 1;
		if ( empty( $inAutocompletionSource ) ) {
			$formInputAttrs['class'] = 'formInput';
		} else {
			self::$num_autocompletion_inputs++;
			$input_num = self::$num_autocompletion_inputs;
			// place the necessary Javascript on the page, and
			// disable the cache (so the Javascript will show up) -
			// if there's more than one autocompleted #forminput
			// on the page, we only need to do this the first time
			if ( $input_num == 1 ) {
				$parser->disableCache();
				SFUtils::addJavascriptAndCSS();
			}

			$inputID = 'input_' . $input_num;
			$formInputAttrs['id'] = $inputID;
			$formInputAttrs['class'] = 'autocompleteInput createboxInput formInput';
			if ( $inRemoteAutocompletion ) {
				$formInputAttrs['autocompletesettings'] = $inAutocompletionSource;
				$formInputAttrs['autocompletedatatype'] = $autocompletion_type;
			} else {
				$autocompletion_values = SFUtils::getAutocompleteValues( $inAutocompletionSource, $autocompletion_type );
				global $sfgAutocompleteValues;
				$sfgAutocompleteValues[$inputID] = $autocompletion_values;
				$formInputAttrs['autocompletesettings'] = $inputID;
			}
		}

		$str .= "\t" . Html::input( 'page_name', $inValue, 'text', $formInputAttrs ) . "\n";

		// if the form start URL looks like "index.php?title=Special:FormStart"
		// (i.e., it's in the default URL style), add in the title as a
		// hidden value
		if ( ( $pos = strpos( $fs_url, "title=" ) ) > - 1 ) {
			$str .= SFFormUtils::hiddenFieldHTML( "title", urldecode( substr( $fs_url, $pos + 6 ) ) );
		}
		if ( $inFormName == '' ) {
			$str .= SFUtils::formDropdownHTML();
		} else {
			$str .= SFFormUtils::hiddenFieldHTML( "form", $inFormName );
		}
		// Recreate the passed-in query string as a set of hidden
		// variables.
		// Change HTML-encoded ampersands to URL-encoded ampersands, so
		// that the string doesn't get split up on the '&'.
		$inQueryStr = str_replace( '&amp;', '%26', $inQueryStr );
		$query_components = explode( '&', $inQueryStr );
		foreach ( $query_components as $component ) {
			// change URL-encoded ampersands back
			$component = str_replace( '%26', '&', $component );
			$subcomponents = explode( '=', $component, 2 );
			$key = ( isset( $subcomponents[0] ) ) ? $subcomponents[0] : '';
			$val = ( isset( $subcomponents[1] ) ) ? $subcomponents[1] : '';
			if ( ! empty( $key ) ) {
				$str .= '\t\t\t' .  Html::hidden( $key, $val ) . "\n";
			}
		}
		$button_str = ( $inButtonStr != '' ) ? $inButtonStr : wfMsg( 'sf_formstart_createoredit' );
		$str .= <<<END
			<input type="submit" value="$button_str" /></p>
			</form>

END;
		if ( ! empty( $inAutocompletionSource ) ) {
			$str .= "\t\t\t" .
				Html::element( 'div',
					array(
						'class' => 'page_name_auto_complete',
						'id' => "div_$input_num",
					),
					// it has to be <div></div>, not
					// <div />, to work properly - stick
					// in a space as the content
					' '
				) . "\n";
		}

		// hack to remove newline from beginning of output, thanks to
		// http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function
		return $parser->insertStripItem( $str, $parser->mStripState );
	}
 static function renderFormInput(&$parser)
 {
     $params = func_get_args();
     array_shift($params);
     // don't need the parser
     // Set defaults.
     $inFormName = $inValue = $inButtonStr = $inQueryStr = '';
     $inQueryArr = array();
     $inAutocompletionSource = '';
     $inRemoteAutocompletion = false;
     $inSize = 25;
     $classStr = "sfFormInput";
     $inPlaceholder = null;
     $inAutofocus = true;
     // Assign params.
     foreach ($params as $i => $param) {
         $elements = explode('=', $param, 2);
         // Set param name and value.
         if (count($elements) > 1) {
             $paramName = trim($elements[0]);
             // Parse (and sanitize) parameter values.
             // We call recursivePreprocess() and not
             // recursiveTagParse() so that URL values will
             // not be turned into links.
             $value = trim($parser->recursivePreprocess($elements[1]));
         } else {
             $paramName = trim($param);
             $value = null;
         }
         if ($paramName == 'form') {
             $inFormName = $value;
         } elseif ($paramName == 'size') {
             $inSize = $value;
         } elseif ($paramName == 'default value') {
             $inValue = $value;
         } elseif ($paramName == 'button text') {
             $inButtonStr = $value;
         } elseif ($paramName == 'query string') {
             // Change HTML-encoded ampersands directly to
             // URL-encoded ampersands, so that the string
             // doesn't get split up on the '&'.
             $inQueryStr = str_replace('&amp;', '%26', $value);
             // "Decode" any other HTML tags.
             $inQueryStr = html_entity_decode($inQueryStr, ENT_QUOTES);
             parse_str($inQueryStr, $arr);
             $inQueryArr = SFUtils::array_merge_recursive_distinct($inQueryArr, $arr);
         } elseif ($paramName == 'autocomplete on category') {
             $inAutocompletionSource = $value;
             $autocompletionType = 'category';
         } elseif ($paramName == 'autocomplete on namespace') {
             $inAutocompletionSource = $value;
             $autocompletionType = 'namespace';
         } elseif ($paramName == 'remote autocompletion') {
             $inRemoteAutocompletion = true;
         } elseif ($paramName == 'placeholder') {
             $inPlaceholder = $value;
         } elseif ($paramName == 'popup') {
             SFUtils::loadScriptsForPopupForm($parser);
             $classStr .= ' popupforminput';
         } elseif ($paramName == 'no autofocus') {
             $inAutofocus = false;
         } else {
             $value = urlencode($value);
             parse_str("{$paramName}={$value}", $arr);
             $inQueryArr = SFUtils::array_merge_recursive_distinct($inQueryArr, $arr);
         }
     }
     $formInputAttrs = array('size' => $inSize);
     if ($inPlaceholder != null) {
         $formInputAttrs['placeholder'] = $inPlaceholder;
     }
     if ($inAutofocus) {
         $formInputAttrs['autofocus'] = 'autofocus';
     }
     // Now apply the necessary settings and Javascript, depending
     // on whether or not there's autocompletion (and whether the
     // autocompletion is local or remote).
     $input_num = 1;
     if (empty($inAutocompletionSource)) {
         $formInputAttrs['class'] = 'formInput';
     } else {
         self::$num_autocompletion_inputs++;
         $input_num = self::$num_autocompletion_inputs;
         // Place the necessary Javascript on the page, and
         // disable the cache (so the Javascript will show up) -
         // if there's more than one autocompleted #forminput
         // on the page, we only need to do this the first time.
         if ($input_num == 1) {
             $parser->disableCache();
             $output = $parser->getOutput();
             $output->addModules('ext.semanticforms.main');
         }
         $inputID = 'input_' . $input_num;
         $formInputAttrs['id'] = $inputID;
         $formInputAttrs['class'] = 'autocompleteInput createboxInput formInput';
         global $sfgMaxLocalAutocompleteValues;
         $autocompletion_values = SFUtils::getAutocompleteValues($inAutocompletionSource, $autocompletionType);
         if (count($autocompletion_values) > $sfgMaxLocalAutocompleteValues || $inRemoteAutocompletion) {
             $formInputAttrs['autocompletesettings'] = $inAutocompletionSource;
             $formInputAttrs['autocompletedatatype'] = $autocompletionType;
         } else {
             global $sfgAutocompleteValues;
             $sfgAutocompleteValues[$inputID] = $autocompletion_values;
             $formInputAttrs['autocompletesettings'] = $inputID;
         }
     }
     $formContents = Html::input('page_name', $inValue, 'text', $formInputAttrs);
     // If the form start URL looks like "index.php?title=Special:FormStart"
     // (i.e., it's in the default URL style), add in the title as a
     // hidden value
     $fs = SpecialPageFactory::getPage('FormStart');
     $fsURL = $fs->getTitle()->getLocalURL();
     if (($pos = strpos($fsURL, "title=")) > -1) {
         $formContents .= Html::hidden("title", urldecode(substr($fsURL, $pos + 6)));
     }
     if ($inFormName == '') {
         $formContents .= SFUtils::formDropdownHTML();
     } else {
         $formContents .= Html::hidden("form", $inFormName);
     }
     // Recreate the passed-in query string as a set of hidden
     // variables.
     if (!empty($inQueryArr)) {
         // Query string has to be turned into hidden inputs.
         $query_components = explode('&', http_build_query($inQueryArr, '', '&'));
         foreach ($query_components as $query_component) {
             $var_and_val = explode('=', $query_component, 2);
             if (count($var_and_val) == 2) {
                 $formContents .= Html::hidden(urldecode($var_and_val[0]), urldecode($var_and_val[1]));
             }
         }
     }
     $buttonStr = $inButtonStr != '' ? $inButtonStr : wfMessage('sf_formstart_createoredit')->escaped();
     $formContents .= "&nbsp;" . Html::input(null, $buttonStr, 'submit', array('id' => "input_button_{$input_num}", 'class' => 'forminput_button'));
     $str = "\t" . Html::rawElement('form', array('name' => 'createbox', 'action' => $fsURL, 'method' => 'get', 'class' => $classStr), '<p>' . $formContents . '</p>') . "\n";
     if (!empty($inAutocompletionSource)) {
         $str .= "\t\t\t" . Html::element('div', array('class' => 'page_name_auto_complete', 'id' => "div_{$input_num}"), ' ') . "\n";
     }
     // Hack to remove newline from beginning of output, thanks to
     // http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function
     return $parser->insertStripItem($str, $parser->mStripState);
 }