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)
Topic on Extension talk:InputBox
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;
}