2008-10-27 20:33:18 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Classes for InputBox extension
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
|
|
|
*/
|
|
|
|
|
|
|
|
// InputBox class
|
|
|
|
class InputBox {
|
|
|
|
|
|
|
|
/* Fields */
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 21:35:00 +00:00
|
|
|
private $mParser;
|
2008-11-13 08:50:13 +00:00
|
|
|
private $mType = '';
|
|
|
|
private $mWidth = 50;
|
|
|
|
private $mPreload = '';
|
|
|
|
private $mEditIntro = '';
|
2009-01-13 02:18:30 +00:00
|
|
|
private $mSummary = '';
|
2010-03-31 12:33:11 +00:00
|
|
|
private $mNosummary = '';
|
2009-01-13 02:18:30 +00:00
|
|
|
private $mMinor = '';
|
2008-11-13 08:50:13 +00:00
|
|
|
private $mPage = '';
|
|
|
|
private $mBR = 'yes';
|
|
|
|
private $mDefaultText = '';
|
|
|
|
private $mBGColor = 'transparent';
|
|
|
|
private $mButtonLabel = '';
|
|
|
|
private $mSearchButtonLabel = '';
|
|
|
|
private $mFullTextButton = '';
|
|
|
|
private $mLabelText = '';
|
|
|
|
private $mHidden = '';
|
|
|
|
private $mNamespaces = '';
|
|
|
|
private $mID = '';
|
|
|
|
private $mInline = false;
|
2008-12-31 03:31:41 +00:00
|
|
|
private $mPrefix = '';
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
/* Functions */
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
public function __construct( $parser ) {
|
2008-10-28 01:56:15 +00:00
|
|
|
$this->mParser = $parser;
|
2008-10-27 20:33:18 +00:00
|
|
|
}
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
public function render() {
|
|
|
|
// Handle various types
|
2008-10-27 21:35:00 +00:00
|
|
|
switch( $this->mType ) {
|
2008-10-27 20:33:18 +00:00
|
|
|
case 'create':
|
|
|
|
case 'comment':
|
|
|
|
return $this->getCreateForm();
|
2008-10-28 00:08:08 +00:00
|
|
|
case 'commenttitle':
|
|
|
|
return $this->getCommentForm();
|
2008-10-27 20:33:18 +00:00
|
|
|
case 'search':
|
2009-01-01 00:55:18 +00:00
|
|
|
return $this->getSearchForm('search');
|
|
|
|
case 'fulltext':
|
|
|
|
return $this->getSearchForm('fulltext');
|
2008-10-27 20:33:18 +00:00
|
|
|
case 'search2':
|
|
|
|
return $this->getSearchForm2();
|
|
|
|
default:
|
|
|
|
return Xml::tags( 'div', null,
|
|
|
|
Xml::element( 'strong',
|
|
|
|
array(
|
|
|
|
'class' => 'error'
|
|
|
|
),
|
2008-10-28 01:56:15 +00:00
|
|
|
strlen( $this->mType ) > 0
|
|
|
|
? wfMsgForContent( 'inputbox-error-bad-type', $this->mType )
|
|
|
|
: wfMsgForContent( 'inputbox-error-no-type' )
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate search form
|
2009-01-01 00:55:18 +00:00
|
|
|
* @param $type
|
2008-10-27 20:33:18 +00:00
|
|
|
*/
|
2009-01-01 00:55:18 +00:00
|
|
|
public function getSearchForm( $type ) {
|
2008-10-27 20:33:18 +00:00
|
|
|
global $wgContLang;
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
// Use button label fallbacks
|
2008-10-27 21:35:00 +00:00
|
|
|
if ( !$this->mButtonLabel ) {
|
|
|
|
$this->mButtonLabel = wfMsgHtml( 'tryexact' );
|
2008-10-27 20:33:18 +00:00
|
|
|
}
|
2008-10-27 21:35:00 +00:00
|
|
|
if ( !$this->mSearchButtonLabel ) {
|
|
|
|
$this->mSearchButtonLabel = wfMsgHtml( 'searchfulltext' );
|
2008-10-27 20:33:18 +00:00
|
|
|
}
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
// Build HTML
|
|
|
|
$htmlOut = Xml::openElement( 'div',
|
|
|
|
array(
|
|
|
|
'align' => 'center',
|
2008-10-27 21:35:00 +00:00
|
|
|
'style' => 'background-color:' . $this->mBGColor
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::openElement( 'form',
|
|
|
|
array(
|
|
|
|
'name' => 'searchbox',
|
|
|
|
'id' => 'searchbox',
|
|
|
|
'class' => 'searchbox',
|
|
|
|
'action' => SpecialPage::getTitleFor( 'Search' )->escapeLocalUrl(),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::element( 'input',
|
|
|
|
array(
|
|
|
|
'class' => 'searchboxInput',
|
|
|
|
'name' => 'search',
|
2008-10-27 21:35:00 +00:00
|
|
|
'type' => $this->mHidden ? 'hidden' : 'text',
|
|
|
|
'value' => $this->mDefaultText,
|
|
|
|
'size' => $this->mWidth,
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
2008-12-31 03:31:41 +00:00
|
|
|
|
|
|
|
if( $this->mPrefix != '' ){
|
|
|
|
$htmlOut .= Xml::element( 'input',
|
|
|
|
array(
|
|
|
|
'name' => 'prefix',
|
|
|
|
'type' => 'hidden',
|
|
|
|
'value' => $this->mPrefix,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-10-27 21:35:00 +00:00
|
|
|
$htmlOut .= $this->mBR;
|
2008-10-27 20:33:18 +00:00
|
|
|
|
|
|
|
// Determine namespace checkboxes
|
|
|
|
$namespaces = $wgContLang->getNamespaces();
|
2008-10-27 21:35:00 +00:00
|
|
|
$namespacesArray = explode( ',', $this->mNamespaces );
|
|
|
|
if ( $this->mNamespaces ) {
|
2008-10-27 20:33:18 +00:00
|
|
|
foreach ( $namespacesArray as $userNamespace ) {
|
|
|
|
$checked = array();
|
|
|
|
// Namespace needs to be checked if flagged with "**" or if it's the only one
|
|
|
|
if ( strstr( $userNamespace, '**' ) || count( $namespacesArray ) == 1 ) {
|
|
|
|
$userNamespace = str_replace( '**', '', $userNamespace );
|
|
|
|
$checked = array( 'checked' => 'checked' );
|
|
|
|
}
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
// Namespace checkboxes
|
|
|
|
foreach ( $namespaces as $i => $name ) {
|
|
|
|
if ( $i < 0 ) {
|
|
|
|
continue;
|
|
|
|
} elseif ( $i == 0 ) {
|
|
|
|
$name = 'Main';
|
|
|
|
}
|
2008-10-27 20:56:23 +00:00
|
|
|
if ( $userNamespace == $name ) {
|
2008-10-27 20:33:18 +00:00
|
|
|
// Checkbox
|
|
|
|
$htmlOut .= Xml::element( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'name' => 'ns' . $i,
|
2008-10-28 01:56:15 +00:00
|
|
|
'value' => 1,
|
|
|
|
'id' => 'mw-inputbox-ns' . $i
|
2008-10-27 20:33:18 +00:00
|
|
|
) + $checked
|
|
|
|
);
|
|
|
|
// Label
|
2010-05-30 17:33:59 +00:00
|
|
|
$htmlOut .= ' ' . Xml::label( $userNamespace, 'mw-inputbox-ns' . $i );
|
2008-10-27 20:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-10-27 20:56:23 +00:00
|
|
|
|
|
|
|
// Line break
|
2008-10-27 21:35:00 +00:00
|
|
|
$htmlOut .= $this->mBR;
|
2009-02-26 20:15:49 +00:00
|
|
|
} else if( $type == 'search' ) {
|
2008-10-27 20:33:18 +00:00
|
|
|
// Go button
|
|
|
|
$htmlOut .= Xml::element( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'submit',
|
|
|
|
'name' => 'go',
|
|
|
|
'class' => 'searchboxGoButton',
|
2008-10-27 21:35:00 +00:00
|
|
|
'value' => $this->mButtonLabel
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
2010-05-30 17:33:59 +00:00
|
|
|
$htmlOut .= ' ';
|
2008-10-27 20:33:18 +00:00
|
|
|
}
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
// Search button
|
|
|
|
$htmlOut .= Xml::element( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'submit',
|
|
|
|
'name' => 'fulltext',
|
|
|
|
'class' => 'searchboxSearchButton',
|
2008-10-27 21:35:00 +00:00
|
|
|
'value' => $this->mSearchButtonLabel
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
2009-02-26 20:15:49 +00:00
|
|
|
|
|
|
|
// Hidden fulltext param for IE (bug 17161)
|
|
|
|
if( $type == 'fulltext' ) {
|
2010-10-29 15:32:44 +00:00
|
|
|
$htmlOut .= Html::hidden( 'fulltext', 'Search' );
|
2009-02-26 20:15:49 +00:00
|
|
|
}
|
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
$htmlOut .= Xml::closeElement( 'form' );
|
|
|
|
$htmlOut .= Xml::closeElement( 'div' );
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
// Return HTML
|
|
|
|
return $htmlOut;
|
|
|
|
}
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
/*
|
|
|
|
* Generate search form version 2
|
|
|
|
*/
|
|
|
|
public function getSearchForm2() {
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
// Use button label fallbacks
|
2008-10-27 21:35:00 +00:00
|
|
|
if ( !$this->mButtonLabel ) {
|
|
|
|
$this->mButtonLabel = wfMsgHtml( 'tryexact' );
|
2008-10-27 20:33:18 +00:00
|
|
|
}
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-12-30 00:22:14 +00:00
|
|
|
$id = Sanitizer::escapeId( $this->mID, 'noninitial' );
|
2008-10-27 20:33:18 +00:00
|
|
|
$htmlLabel = '';
|
2008-10-27 21:35:00 +00:00
|
|
|
if ( isset( $this->mLabelText ) && strlen( trim( $this->mLabelText ) ) ) {
|
2008-11-29 04:07:46 +00:00
|
|
|
$this->mLabelText = $this->mParser->recursiveTagParse( $this->mLabelText );
|
|
|
|
$htmlLabel = Xml::openElement( 'label', array( 'for' => 'bodySearchInput' . $id ) );
|
|
|
|
$htmlLabel .= $this->mLabelText;
|
|
|
|
$htmlLabel .= Xml::closeElement( 'label' );
|
2008-10-27 20:33:18 +00:00
|
|
|
}
|
|
|
|
$htmlOut = Xml::openElement( 'form',
|
|
|
|
array(
|
|
|
|
'name' => 'bodySearch' . $id,
|
|
|
|
'id' => 'bodySearch' . $id,
|
|
|
|
'class' => 'bodySearch',
|
|
|
|
'action' => SpecialPage::getTitleFor( 'Search' )->escapeLocalUrl(),
|
2008-10-27 21:35:00 +00:00
|
|
|
'style' => $this->mInline ? 'display: inline;' : ''
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::openElement( 'div',
|
|
|
|
array(
|
|
|
|
'class' => 'bodySearchWrap',
|
2008-10-27 21:35:00 +00:00
|
|
|
'style' => 'background-color:' . $this->mBGColor . ';' .
|
|
|
|
$this->mInline ? 'display: inline;' : ''
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= $htmlLabel;
|
|
|
|
$htmlOut .= Xml::element( 'input',
|
|
|
|
array(
|
2008-10-27 21:35:00 +00:00
|
|
|
'type' => $this->mHidden ? 'hidden' : 'text',
|
2008-10-27 20:33:18 +00:00
|
|
|
'name' => 'search',
|
2008-10-27 21:35:00 +00:00
|
|
|
'size' => $this->mWidth,
|
2008-11-29 04:07:46 +00:00
|
|
|
'id' => 'bodySearchInput' . $id
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::element( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'submit',
|
|
|
|
'name' => 'go',
|
2008-10-27 21:35:00 +00:00
|
|
|
'value' => $this->mButtonLabel,
|
2008-10-27 20:33:18 +00:00
|
|
|
'class' => 'bodySearchBtnGo' . $id
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Better testing needed here!
|
2008-10-27 21:35:00 +00:00
|
|
|
if ( !empty( $this->mFullTextButton ) ) {
|
2008-10-27 20:33:18 +00:00
|
|
|
$htmlOut .= Xml::element( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'submit',
|
|
|
|
'name' => 'fulltext',
|
|
|
|
'class' => 'bodySearchBtnSearch',
|
2008-10-27 21:35:00 +00:00
|
|
|
'value' => $this->mSearchButtonLabel
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
$htmlOut .= Xml::closeElement( 'div' );
|
|
|
|
$htmlOut .= Xml::closeElement( 'form' );
|
|
|
|
|
|
|
|
// Return HTML
|
|
|
|
return $htmlOut;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate create page form
|
|
|
|
*/
|
|
|
|
public function getCreateForm() {
|
2008-10-27 20:56:23 +00:00
|
|
|
global $wgScript;
|
2008-10-27 20:33:18 +00:00
|
|
|
|
2008-10-27 21:35:00 +00:00
|
|
|
if ( $this->mType == "comment" ) {
|
|
|
|
if ( !$this->mButtonLabel ) {
|
|
|
|
$this->mButtonLabel = wfMsgHtml( "postcomment" );
|
2008-10-27 20:33:18 +00:00
|
|
|
}
|
|
|
|
} else {
|
2008-10-27 21:35:00 +00:00
|
|
|
if ( !$this->mButtonLabel ) {
|
|
|
|
$this->mButtonLabel = wfMsgHtml( 'createarticle' );
|
2008-10-27 20:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
$htmlOut = Xml::openElement( 'div',
|
|
|
|
array(
|
|
|
|
'align' => 'center',
|
2008-10-27 21:35:00 +00:00
|
|
|
'style' => 'background-color:' . $this->mBGColor
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
2009-12-15 11:23:43 +00:00
|
|
|
$createBoxParams = array(
|
|
|
|
'name' => 'createbox',
|
|
|
|
'class' => 'createbox',
|
|
|
|
'action' => $wgScript,
|
|
|
|
'method' => 'get'
|
2008-10-27 20:33:18 +00:00
|
|
|
);
|
2009-12-15 11:23:43 +00:00
|
|
|
if( isset( $this->mId ) ) {
|
|
|
|
$createBoxParams['id'] = Sanitizer::escapeId( $this->mId );
|
|
|
|
}
|
|
|
|
$htmlOut .= Xml::openElement( 'form', $createBoxParams );
|
2008-10-27 20:33:18 +00:00
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'action',
|
|
|
|
'value' => 'edit',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'preload',
|
2008-10-27 21:35:00 +00:00
|
|
|
'value' => $this->mPreload,
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'editintro',
|
2008-10-27 21:35:00 +00:00
|
|
|
'value' => $this->mEditIntro,
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
2009-01-13 02:18:30 +00:00
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'summary',
|
|
|
|
'value' => $this->mSummary,
|
|
|
|
)
|
|
|
|
);
|
2010-03-31 12:33:11 +00:00
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'nosummary',
|
|
|
|
'value' => $this->mNosummary,
|
|
|
|
)
|
|
|
|
);
|
2010-03-18 19:11:12 +00:00
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'prefix',
|
|
|
|
'value' => $this->mPrefix,
|
|
|
|
)
|
|
|
|
);
|
2009-01-13 02:18:30 +00:00
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'minor',
|
|
|
|
'value' => $this->mMinor,
|
|
|
|
)
|
|
|
|
);
|
2008-10-27 21:35:00 +00:00
|
|
|
if ( $this->mType == 'comment' ) {
|
2008-10-27 20:33:18 +00:00
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'section',
|
|
|
|
'value' => 'new',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
2008-10-27 21:35:00 +00:00
|
|
|
'type' => $this->mHidden ? 'hidden' : 'text',
|
2008-10-27 20:33:18 +00:00
|
|
|
'name' => 'title',
|
|
|
|
'class' => 'createboxInput',
|
2008-10-27 21:35:00 +00:00
|
|
|
'value' => $this->mDefaultText,
|
|
|
|
'size' => $this->mWidth
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
2008-10-27 21:35:00 +00:00
|
|
|
$htmlOut .= $this->mBR;
|
2008-10-27 20:33:18 +00:00
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'submit',
|
|
|
|
'name' => 'create',
|
|
|
|
'class' => 'createboxButton',
|
2008-10-27 21:35:00 +00:00
|
|
|
'value' => $this->mButtonLabel
|
2008-10-27 20:33:18 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::closeElement( 'form' );
|
|
|
|
$htmlOut .= Xml::closeElement( 'div' );
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
// Return HTML
|
|
|
|
return $htmlOut;
|
|
|
|
}
|
2008-10-28 00:08:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate new section form
|
|
|
|
*/
|
|
|
|
public function getCommentForm() {
|
|
|
|
global $wgScript;
|
|
|
|
|
|
|
|
if ( !$this->mButtonLabel ) {
|
|
|
|
$this->mButtonLabel = wfMsgHtml( "postcomment" );
|
|
|
|
}
|
|
|
|
|
|
|
|
$htmlOut = Xml::openElement( 'div',
|
|
|
|
array(
|
|
|
|
'align' => 'center',
|
|
|
|
'style' => 'background-color:' . $this->mBGColor
|
|
|
|
)
|
|
|
|
);
|
2009-12-15 11:23:43 +00:00
|
|
|
$commentFormParams = array(
|
|
|
|
'name' => 'commentbox',
|
|
|
|
'class' => 'commentbox',
|
|
|
|
'action' => $wgScript,
|
|
|
|
'method' => 'get'
|
2008-10-28 00:08:08 +00:00
|
|
|
);
|
2009-12-15 11:23:43 +00:00
|
|
|
if( isset( $this->mId ) ) {
|
|
|
|
$commentFormParams['id'] = Sanitizer::escapeId( $this->mId );
|
|
|
|
}
|
|
|
|
$htmlOut .= Xml::openElement( 'form', $commentFormParams );
|
2008-10-28 00:08:08 +00:00
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'action',
|
|
|
|
'value' => 'edit',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'preload',
|
|
|
|
'value' => $this->mPreload,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'editintro',
|
|
|
|
'value' => $this->mEditIntro,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
2008-11-17 21:54:38 +00:00
|
|
|
'type' => $this->mHidden ? 'hidden' : 'text',
|
2008-10-28 00:08:08 +00:00
|
|
|
'name' => 'preloadtitle',
|
|
|
|
'class' => 'commentboxInput',
|
|
|
|
'value' => $this->mDefaultText,
|
|
|
|
'size' => $this->mWidth
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'section',
|
|
|
|
'value' => 'new',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'title',
|
|
|
|
'value' => $this->mPage
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= $this->mBR;
|
|
|
|
$htmlOut .= Xml::openElement( 'input',
|
|
|
|
array(
|
|
|
|
'type' => 'submit',
|
|
|
|
'name' => 'create',
|
|
|
|
'class' => 'commentboxButton',
|
|
|
|
'value' => $this->mButtonLabel
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$htmlOut .= Xml::closeElement( 'form' );
|
|
|
|
$htmlOut .= Xml::closeElement( 'div' );
|
|
|
|
|
|
|
|
// Return HTML
|
|
|
|
return $htmlOut;
|
|
|
|
}
|
2008-10-27 20:33:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Extract options from a blob of text
|
|
|
|
*
|
|
|
|
* @param string $text Tag contents
|
|
|
|
*/
|
|
|
|
public function extractOptions( $text ) {
|
|
|
|
wfProfileIn( __METHOD__ );
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
// Parse all possible options
|
|
|
|
$values = array();
|
2008-10-27 20:56:23 +00:00
|
|
|
foreach ( explode( "\n", $text ) as $line ) {
|
|
|
|
if ( strpos( $line, '=' ) === false )
|
2008-10-27 20:33:18 +00:00
|
|
|
continue;
|
|
|
|
list( $name, $value ) = explode( '=', $line, 2 );
|
|
|
|
$values[ strtolower( trim( $name ) ) ] = trim( $value );
|
|
|
|
}
|
2008-10-27 20:56:23 +00:00
|
|
|
|
2008-11-13 08:50:13 +00:00
|
|
|
// Build list of options, with local member names
|
2008-10-27 20:33:18 +00:00
|
|
|
$options = array(
|
2008-11-13 08:50:13 +00:00
|
|
|
'type' => 'mType',
|
|
|
|
'width' => 'mWidth',
|
|
|
|
'preload' => 'mPreload',
|
|
|
|
'page' => 'mPage',
|
|
|
|
'editintro' => 'mEditIntro',
|
2009-01-13 02:18:30 +00:00
|
|
|
'summary' => 'mSummary',
|
2010-03-31 12:33:11 +00:00
|
|
|
'nosummary' => 'mNosummary',
|
2009-01-13 02:18:30 +00:00
|
|
|
'minor' => 'mMinor',
|
2008-11-13 08:50:13 +00:00
|
|
|
'break' => 'mBR',
|
|
|
|
'default' => 'mDefaultText',
|
|
|
|
'bgcolor' => 'mBGColor',
|
|
|
|
'buttonlabel' => 'mButtonLabel',
|
|
|
|
'searchbuttonlabel' => 'mSearchButtonLabel',
|
|
|
|
'fulltextbutton' => 'mFullTextButton',
|
|
|
|
'namespaces' => 'mNamespaces',
|
|
|
|
'labeltext' => 'mLabelText',
|
|
|
|
'hidden' => 'mHidden',
|
|
|
|
'id' => 'mID',
|
|
|
|
'inline' => 'mInline',
|
2008-12-31 03:31:41 +00:00
|
|
|
'prefix' => 'mPrefix',
|
2008-10-27 20:33:18 +00:00
|
|
|
);
|
2008-10-27 20:56:23 +00:00
|
|
|
foreach ( $options as $name => $var ) {
|
|
|
|
if ( isset( $values[$name] ) ) {
|
2008-11-13 08:50:13 +00:00
|
|
|
$this->$var = $values[$name];
|
2008-10-27 20:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
2009-01-01 13:29:46 +00:00
|
|
|
|
2008-10-27 20:33:18 +00:00
|
|
|
// Insert a line break if configured to do so
|
2009-01-01 13:29:46 +00:00
|
|
|
$this->mBR = ( strtolower( $this->mBR ) == "no" ) ? ' ' : '<br />';
|
2008-10-27 20:33:18 +00:00
|
|
|
|
|
|
|
// Validate the width; make sure it's a valid, positive integer
|
2008-10-27 21:35:00 +00:00
|
|
|
$this->mWidth = intval( $this->mWidth <= 0 ? 50 : $this->mWidth );
|
2009-01-01 13:29:46 +00:00
|
|
|
|
2010-03-30 03:59:15 +00:00
|
|
|
// Validate background color
|
|
|
|
if ( !$this->isValidColor( $this->mBGColor ) ) {
|
|
|
|
$this->mBGColor = 'transparent';
|
|
|
|
}
|
2008-10-27 20:33:18 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
}
|
|
|
|
|
2010-03-30 03:59:15 +00:00
|
|
|
/**
|
|
|
|
* Do a security check on the bgcolor parameter
|
|
|
|
*/
|
|
|
|
public function isValidColor( $color ) {
|
|
|
|
$regex = <<<REGEX
|
|
|
|
/^ (
|
|
|
|
[a-zA-Z]* | # color names
|
|
|
|
\# [0-9a-f]{3} | # short hexadecimal
|
|
|
|
\# [0-9a-f]{6} | # long hexadecimal
|
|
|
|
rgb \s* \( \s* (
|
|
|
|
\d+ \s* , \s* \d+ \s* , \s* \d+ | # rgb integer
|
|
|
|
[0-9.]+% \s* , \s* [0-9.]+% \s* , \s* [0-9.]+% # rgb percent
|
|
|
|
) \s* \)
|
|
|
|
) $ /xi
|
|
|
|
REGEX;
|
|
|
|
return (bool) preg_match( $regex, $color );
|
|
|
|
}
|
2008-10-27 20:33:18 +00:00
|
|
|
}
|