Extension talk:InputBox

Jump to: navigation, search

About this board

Edit description

For the page history, see also here. / previous talk on this page


By clicking "Add topic", you agree to our Terms of Use and agree to irrevocably release your text under the CC BY-SA 3.0 License and GFDL
Ibutakov.smartec (talkcontribs)

is there any way to add button or smth to add namespace for new page from list? Ibutakov.smartec (talk) 16:09, 22 April 2016 (UTC)

217.108.170.8 (talkcontribs)

okay, if someone needs solution i will provide it here:

InputBox.classes.php:
	/**
	 * Generate create page form
	 */
	public function getCreateForm() {
		global $wgScript;

		if ( $this->mType == "comment" ) {
			if ( !$this->mButtonLabel ) {
				$this->mButtonLabel = wfMessage( 'inputbox-postcomment' )->text();
			}
		} else {
			if ( !$this->mButtonLabel ) {
				$this->mButtonLabel = wfMessage( 'inputbox-createarticle' )->text();
			}
		}

		$htmlOut = Xml::openElement( 'div',
			array(
				'class' => 'mw-inputbox-centered',
				'style' => $this->bgColorStyle(),
			)
		);
		$createBoxParams = array(
			'name' => 'createbox',
			'class' => 'createbox',
			'action' => $wgScript,
			'method' => 'get'
		);
		if ( $this->mID !== '' ) {
			$createBoxParams['id'] = Sanitizer::escapeId( $this->mID );
		}
		$htmlOut .= Xml::openElement( 'form', $createBoxParams );
		$editArgs = $this->getEditActionArgs();
		$htmlOut .= Html::hidden( $editArgs['name'], $editArgs['value'] );
		$htmlOut .= Html::hidden( 'preload', $this->mPreload );
		foreach ( $this->mPreloadparams as $preloadparams ) {
			$htmlOut .= Html::hidden( 'preloadparams[]', $preloadparams );
		}
		$htmlOut .= Html::hidden( 'editintro', $this->mEditIntro );
		$htmlOut .= Html::hidden( 'summary', $this->mSummary );
		$htmlOut .= Html::hidden( 'nosummary', $this->mNosummary );
		$htmlOut .= Html::hidden( 'prefix', $this->mPrefix );
		$htmlOut .= Html::hidden( 'minor', $this->mMinor );
		if ( $this->mType == 'comment' ) {
			$htmlOut .= Html::hidden( 'section', 'new' );
		}

		global $InputBoxNSList;

		$htmlOut .= Xml::openElement( 'select',
			array(
				'name' => 'ns',
				'class' => 'mw-ui-input mw-ui-input-inline createboxInput',
			)
		);
		foreach ($InputBoxNSList as $NS) {
			$htmlOut .= Xml::openElement( 'option',
				array('value' => $NS,
				)
			);
			$htmlOut .= $NS;
			$htmlOut .= Xml::closeElement( 'option' );
		}	
		$htmlOut .= Xml::closeElement( 'select' );

		$htmlOut .= Xml::openElement( 'input',
			array(
				'type' => $this->mHidden ? 'hidden' : 'text',
				'name' => 'title',
				'class' => $this->getLinebreakClasses() .
					'mw-ui-input mw-ui-input-inline createboxInput',
				'value' => $this->mDefaultText,
				'placeholder' => $this->mPlaceholderText,
				'size' => $this->mWidth,
				'dir' => $this->mDir,
			)
		);
		$htmlOut .= $this->mBR;
		$htmlOut .= Xml::openElement( 'input',
			array(
				'type' => 'submit',
				'name' => 'create',
				'class' => 'mw-ui-button mw-ui-progressive createboxButton',
				'value' => $this->mButtonLabel
			)
		);
		$htmlOut .= Xml::closeElement( 'form' );
		$htmlOut .= Xml::closeElement( 'div' );

		// Return HTML
		return $htmlOut;
	}
InputBox.hooks.php:
	public static function onMediaWikiPerformAction(
		$output,
		$article,
		$title,
		$user,
		$request,
		$wiki
	) {
		if( $wiki->getAction( $request ) !== 'edit' ){
			# not our problem
			return true;
		}
		if( $request->getText( 'prefix', '' ) === '' && $request->getText( 'ns', '' ) === ''){
			# Fine
			return true;
		}

		$params = $request->getValues();

		$title = $params['prefix'];
		if ($request->getText( 'ns', '' ) != ''){
			if ( $params['ns'] !='(main)') { $title .= $params['ns'] . ':'; }
		}
		if ( isset( $params['title'] ) ) {
			$title .= $params['title'];
		}
		unset( $params['ns'] );
		unset( $params['prefix'] );
		$params['title'] = $title;

		global $wgScript;
		$output->redirect( wfAppendQuery( $wgScript, $params ), '301' );
		return false;
	}
Reply to "Namespaces for create form"
Loman87 (talkcontribs)

Hi everybody, I want to use the parameter 'prefix=' in my InputBox 'type=fulltext' to limit search within a specific category. I use CirrusSearch as search engine, so it supports queries like 'incategory:[CategoryName]'. So in my Inputbox I would use something like 'prefix=incategory:[CategoryName]'. I tried but in the query results I see it has been searched something like '[wordQueried] prefix:incategory:[CategoryName]'.

I have read in InputBox documentation that this feature was supported just by Lucene; is there any chance to see it working also with other search engines? I think it could be an intersting upgrade for InputBox users. Thanks for your help! Lorenzo

Quiddity (WMF) (talkcontribs)

Hi. The "prefix" parameter is just for finding "pages that start with a specific string their name", so won't work for your purpose here.

I think the "default" parameter might be the closest to what you want. Your users will need to (1) Leave the 'default' as it appears, and (2) add a space after the default. But it will work, as long as you use underscores for multi-word category names. E.g. see this revision. Hope that helps.

Loman87 (talkcontribs)

Hi, thanks for your answer. Yes, the other option is to use the parameter 'default' but I don't like it very much. Is it possible to add this feature for future updates? Thanks, Lorenzo

Quiddity (WMF) (talkcontribs)

I've added a comment at the existing feature-request, Phab:T147951. I'm not sure if any developers are actively working on this extension currently, so patches welcome if you know how to code! Otherwise, it may take a long time.

Loman87 (talkcontribs)

Thanks very much! Unfortunately I am not an actual developer, however I am going to study the source to understand what could be done. Bye!

Reply to "Paramater prefix doesn't work"

How can I allow a user to search by pageid?

1
Stevenpcox (talkcontribs)

I would like users to be able to look up an article based on pageid.

Using ?curid=PAGEID I can add the pageid to a url and go directly to the page. I would like to have a search function where the user input the pageid into a field, mediawiki appends the URL and the desired page opens up.

This should be easy. The only thing I cannot figure out is how to have the user type the pageid into a field and hit enter. From there I can turn it into a variable and inject it into the URL.

Reply to "How can I allow a user to search by pageid?"
Cpiral (talkcontribs)

The namespaces parameter doesn't take the space character. So there's no searching talk namespaces. Quoting or underscoring fails to help. This is an 8 yr old problem?

Please accept the namespace numbers directly that are output the URL. Please accept namespace aliases. Please ignore capitalization. Please ignore whitespace between the field separator. Thanks a lot.

Reply to "Namespaces parameter still broken"

Open created page in new tab. Not in current.

3
Aka sektor (talkcontribs)

How do I get by clicking on the button creation page, go to the new tab and does not remain in the current? What is correct in extension code, if in no other way?

Russian:

Как сделать, чтобы по нажатию на кнопку создания страницы, переходило в новую вкладку, а не оставалась в текущей? Что поправить в коде расширения, если по-другому нельзя?

Ciencia Al Poder (talkcontribs)

Add this JavaScript code to your wiki:

// Create page form: open on new window
$(function(){
  $('form.createbox').attr('target', '_blank');
});
Aka sektor (talkcontribs)

Thank you very much. Work fine.

Dturtill (talkcontribs)

Is there any way that this can be used to create a subpage of the page the button is on, please.

Eg if the button was on a page called January the create button would create a subpage called January/whatever the title was entered

Ciencia Al Poder (talkcontribs)

Yes. Add:

prefix={{FULLPAGENAME}}/
Mattho69 (talkcontribs)

Hi !

Is it possible to use InputBox with VisualEditor ?

Bozomal (talkcontribs)

I guess you are asking about the create article "problem"?

I'm a newbie, so probably what I'm suggesing might be very bad, but worked for me

here is suppoed to be a solution, but not working for me

so I search in the source files and found that if you change the file /extensions/Inputbox/Inputbox.classes.php and change action to veaction (see below) the magic happens. This doesn't work When you are using the parameter prefix, it won't create an article with prefix in the name.

$htmlOut .= Xml::openElement( 'input',
  array(
        'type' => 'hidden',
	'name' => 'veaction',
	'value' => 'edit',
	)
Mpconnick (talkcontribs)

An easier way (now) to do this is add the parameter 'useve' for InputBox. I'm not sure when this was added, but I'm running MediaWiki 1.26.2.

<inputbox>

type=create

break=no

useve=yes

</inputbox>

Mattho69 (talkcontribs)

Thanks for that ;-)

Do you know if using a preload is possible with VisualEditor?

Swennet (talkcontribs)

@Mattho69 Did you manage to get preload working with VisualEditor?

Mpconnick (talkcontribs)

I'm not sure what you mean by preload. I'm pretty new to administering an instance of MediaWiki. Still figuring a lot out. Sorry I can't be of more help.

Mattho69 (talkcontribs)

@Swennet Not yet but I hope this will be available soon

@Mpconnick look at Manual:Creating pages with preloaded text

Thanks :-)

OgreMHDW (talkcontribs)

This is currently a bug in VisualEditor. See bug tracking at https://phabricator.wikimedia.org/T51622

Reply to "VisualEditor"
67.78.106.74 (talkcontribs)

Is there a way to add the ajax search suggestion to an inputbox? Thanks

Stefahn (talkcontribs)

I would like to know this too.
In my eyes the search is no fun if there's no autocompletion / suggestions...

Emijrp (talkcontribs)

I have found a hack to add ajax suggestions to any inputbox. You must add the following code to your MediaWiki:Common.js, and refresh browser cache.

document.getElementById('searchform').action = '/w/index.php';
document.getElementsByName('search')[0].id = 'searchInput';
Reply to "Add SearchSuggest to inputbox?"

useve currently not workgin for type=create

3
Summary by Ciencia Al Poder

Reported as task T147048

Evolution and evolvability (talkcontribs)

When using useve=true and type=create, the url doesn't contain the correct parameter "&vecreate=inputboxcontents"

Example:

<inputbox>

type        = create

buttonlabel = Create pre-print

placeholder = Pre-print title

useve=true

break       = no

</inputbox>

Ciencia Al Poder (talkcontribs)

Reported as task T147048

Evolution and evolvability (talkcontribs)

As part of the solution, the current syntax calls the url:

https://www.mediawiki.org/w/index.php?veaction=edit&preload=&editintro=&summary=&nosummary=&prefix=&minor=&title=somepage&create=Create+pre-print

Whereas it should call:

https://www.mediawiki.org/w/index.php?veaction=edit&title=somepage&create=Create+pre-print

If you can remove the empty parameters (preload=&editintro=&summary=&nosummary=&prefix=&minor=) the function should call properly.

Reply to "useve currently not workgin for type=create"
Great Brightstar (talkcontribs)

This would be useful if you insert a InputBox into an element with top-to-bottom direction. --Great Brightstar (talk) 10:04, 18 September 2016 (UTC)

Great Brightstar (talkcontribs)

As my works in Manchu test of Wikipedia, I found the width parameter is not enough in an element uses top-to-bottom direction, if you use it, the box would be very long, and it would out of page even if you add the height in this element (see this page, tested on the latest version of Firefox). So I think this parameter should be added in this extension, but defaulting to nothing (i.e. this parameter should be activated only when you input it).

Ciencia Al Poder (talkcontribs)

What's the use case of having a "vertical" inputbox?

Reply to "Add height parameter"