*
* @param $dbw DatabaseBase: object
* @param $revision Revision: For ID number, and text used to set
- length and redirect status fields
+ length and redirect status fields
* @param $lastRevision Integer: if given, will not overwrite the page field
* when different from the currently set value.
* Giving 0 indicates the new page flag should be set
$parserOptions = new ParserOptions( $user );
$parserOptions->setTidy( true );
$parserOptions->enableLimitReport();
-
+
if ( $canonical ) {
$parserOptions->setUserLang( $wgLanguageCode ); # Must be set explicitely
return $parserOptions;
<?php
-/**
+/**
* This is a state machine style parser with two internal stacks:
* * A next state stack, which determines the state the machine will progress to next
* * A path stack, which keeps track of the logical location in the file.
/** The previous ConfEditorToken object */
var $prevToken;
- /**
- * The state machine stack. This is an array of strings where the topmost
+ /**
+ * The state machine stack. This is an array of strings where the topmost
* element will be popped off and become the next parser state.
*/
var $stateStack;
var $pathStack;
/**
- * The elements of the top of the pathStack for every path encountered, indexed
+ * The elements of the top of the pathStack for every path encountered, indexed
* by slash-separated path.
*/
var $pathInfo;
var $serial;
/**
- * Editor state. This consists of the internal copy/insert operations which
+ * Editor state. This consists of the internal copy/insert operations which
* are applied to the source string to obtain the destination string.
*/
var $edits;
}
/**
- * Edit the text. Returns the edited text.
+ * Edit the text. Returns the edited text.
* @param $ops Array of operations.
*
* Operations are given as an associative array, with members:
*
* delete
* Deletes an array element or statement with the specified path.
- * e.g.
+ * e.g.
* array('type' => 'delete', 'path' => '$foo/bar/baz' )
* is equivalent to the runtime PHP code:
* unset( $foo['bar']['baz'] );
*
* set
- * Sets the value of an array element. If the element doesn't exist, it
- * is appended to the array. If it does exist, the value is set, with
+ * Sets the value of an array element. If the element doesn't exist, it
+ * is appended to the array. If it does exist, the value is set, with
* comments and indenting preserved.
*
* append
* Appends a new element to the end of the array. Adds a trailing comma.
* e.g.
- * array( 'type' => 'append', 'path', '$foo/bar',
+ * array( 'type' => 'append', 'path', '$foo/bar',
* 'key' => 'baz', 'value' => "'x'" )
* is like the PHP code:
* $foo['bar']['baz'] = 'x';
list( $indent, ) = $this->getIndent( $start );
$textToInsert = "$indent$value,";
} else {
- list( $indent, $arrowIndent ) =
+ list( $indent, $arrowIndent ) =
$this->getIndent( $start, $key, $lastEltInfo['arrowByte'] );
$textToInsert = "$indent$key$arrowIndent=> $value,";
}
list( $indent, ) = $this->getIndent( $start );
$textToInsert = "$indent$value,";
} else {
- list( $indent, $arrowIndent ) =
+ list( $indent, $arrowIndent ) =
$this->getIndent( $start, $key, $info['arrowByte'] );
$textToInsert = "$indent$key$arrowIndent=> $value,";
}
try {
$this->parse();
} catch ( ConfEditorParseError $e ) {
- throw new MWException(
+ throw new MWException(
"Sorry, ConfEditor broke the file during editing and it won't parse anymore: " .
$e->getMessage() );
}
return $out;
}
-
+
/**
* Get the variables defined in the text
* @return array( varname => value )
strlen( $trimmedPath ) - strlen( $name ) );
if( substr( $parentPath, -1 ) == '/' )
$parentPath = substr( $parentPath, 0, -1 );
-
+
$value = substr( $this->text, $data['valueStartByte'],
$data['valueEndByte'] - $data['valueStartByte']
);
}
return $vars;
}
-
+
/**
* Set a value in an array, unless it's set already. For instance,
* setVar( $arr, 'foo/bar', 'baz', 3 ); will set
if ( !isset( $target[$key] ) )
$target[$key] = $value;
}
-
+
/**
* Parse a scalar value in PHP
* @return mixed Parsed value
}
/**
- * Finds the source byte region which you would want to delete, if $pathName
- * was to be deleted. Includes the leading spaces and tabs, the trailing line
+ * Finds the source byte region which you would want to delete, if $pathName
+ * was to be deleted. Includes the leading spaces and tabs, the trailing line
* break, and any comments in between.
*/
function findDeletionRegion( $pathName ) {
}
/**
- * Find the byte region in the source corresponding to the value part.
- * This includes the quotes, but does not include the trailing comma
- * or semicolon.
+ * Find the byte region in the source corresponding to the value part.
+ * This includes the quotes, but does not include the trailing comma
+ * or semicolon.
*
* The end position is the past-the-end (end + 1) value as per convention.
*/
}
/**
- * Run the parser on the text. Throws an exception if the string does not
+ * Run the parser on the text. Throws an exception if the string does not
* match our defined subset of PHP syntax.
*/
public function parse() {
}
/**
- * Set the parse position. Do not call this except from firstToken() and
+ * Set the parse position. Do not call this except from firstToken() and
* nextToken(), there is more to update than just the position.
*/
protected function setPos( $pos ) {
if ( $this->currentToken && $this->currentToken->type == $type ) {
return $this->nextToken();
} else {
- $this->error( "expected " . $this->getTypeName( $type ) .
+ $this->error( "expected " . $this->getTypeName( $type ) .
", got " . $this->getTypeName( $this->currentToken->type ) );
}
}
}
/**
- * Go to the next path on the same level. This ends the current path and
+ * Go to the next path on the same level. This ends the current path and
* starts a new one. If $path is \@next, the new path is set to the next
* numeric array element.
*/
} else {
$this->pathStack[$i]['name'] = $path;
}
- $this->pathStack[$i] =
+ $this->pathStack[$i] =
array(
'startByte' => $this->byteNum,
'startToken' => $this->pos,
}
/**
- * Looks ahead to see if the given type is the next token type, starting
- * from the current position plus the given offset. Skips any intervening
+ * Looks ahead to see if the given type is the next token type, starting
+ * from the current position plus the given offset. Skips any intervening
* whitespace.
*/
function isAhead( $type, $offset = 0 ) {
$out = '';
foreach ( $this->tokens as $token ) {
$obj = $this->newTokenObj( $token );
- $out .= sprintf( "%-28s %s\n",
- $this->getTypeName( $obj->type ),
+ $out .= sprintf( "%-28s %s\n",
+ $this->getTypeName( $obj->type ),
addcslashes( $obj->text, "\0..\37" ) );
}
echo "<pre>" . htmlspecialchars( $out ) . "</pre>";
function __construct( $editor, $msg ) {
$this->lineNum = $editor->lineNum;
$this->colNum = $editor->colNum;
- parent::__construct( "Parse error on line {$editor->lineNum} " .
+ parent::__construct( "Parse error on line {$editor->lineNum} " .
"col {$editor->colNum}: $msg" );
}
*/
class ConfEditorToken {
var $type, $text;
-
+
static $scalarTypes = array( T_LNUMBER, T_DNUMBER, T_STRING, T_CONSTANT_ENCAPSED_STRING );
static $skipTypes = array( T_WHITESPACE, T_COMMENT, T_DOC_COMMENT );
$wgAllowAsyncCopyUploads = false;
/**
- * Max size for uploads, in bytes. If not set to an array, applies to all
+ * Max size for uploads, in bytes. If not set to an array, applies to all
* uploads. If set to an array, per upload type maximums can be set, using the
* file and url keys. If the * key is set this value will be used as maximum
* for non-specified types.
- *
+ *
* For example:
* $wgUploadSize = array(
* '*' => 250 * 1024,
* );
* Sets the maximum for all uploads to 250 kB except for upload-by-url, which
* will have a maximum of 500 kB.
- *
+ *
*/
$wgMaxUploadSize = 1024*1024*100; # 100MB
# MS Office OpenXML and other Open Package Conventions files are zip files
# and thus blacklisted just as other zip files. If you remove these entries
# from the blacklist in your local configuration, a malicious file upload
- # will be able to compromise the wiki's user accounts, and the user
+ # will be able to compromise the wiki's user accounts, and the user
# accounts of any other website in the same cookie domain.
'application/x-opc+zip',
'application/msword',
* to setting $wgCacheEpoch to the modification time of LocalSettings.php, as
* was previously done in the default LocalSettings.php file.
*
- * On high-traffic wikis, this should be set to false, to avoid the need to
+ * On high-traffic wikis, this should be set to false, to avoid the need to
* check the file modification time, and to avoid the performance impact of
- * unnecessary cache invalidations.
+ * unnecessary cache invalidations.
*/
$wgInvalidateCacheOnLocalSettingsChange = true;
$wgBreakFrames = false;
/**
- * The X-Frame-Options header to send on pages sensitive to clickjacking
+ * The X-Frame-Options header to send on pages sensitive to clickjacking
* attacks, such as edit pages. This prevents those pages from being displayed
* in a frame or iframe. The options are:
*
* to allow framing within a trusted domain. This is insecure if there
* is a page on the same domain which allows framing of arbitrary URLs.
*
- * - false: Allow all framing. This opens up the wiki to XSS attacks and thus
- * full compromise of local user accounts. Private wikis behind a
- * corporate firewall are especially vulnerable. This is not
+ * - false: Allow all framing. This opens up the wiki to XSS attacks and thus
+ * full compromise of local user accounts. Private wikis behind a
+ * corporate firewall are especially vulnerable. This is not
* recommended.
*
* For extra safety, set $wgBreakFrames = true, to prevent framing on all pages,
* You can add new icons to the built in copyright or poweredby, or you can create
* a new block. Though note that you may need to add some custom css to get good styling
* of new blocks in monobook. vector and modern should work without any special css.
- *
+ *
* $wgFooterIcons itself is a key/value array.
- * The key is the name of a block that the icons will be wrapped in. The final id varies
- * by skin; Monobook and Vector will turn poweredby into f-poweredbyico while Modern
+ * The key is the name of a block that the icons will be wrapped in. The final id varies
+ * by skin; Monobook and Vector will turn poweredby into f-poweredbyico while Modern
* turns it into mw_poweredby.
* The value is either key/value array of icons or a string.
* In the key/value array the key may or may not be used by the skin but it can
* be used to find the icon and unset it or change the icon if needed.
* This is useful for disabling icons that are set by extensions.
- * The value should be either a string or an array. If it is a string it will be output
- * directly as html, however some skins may choose to ignore it. An array is the preferred format
+ * The value should be either a string or an array. If it is a string it will be output
+ * directly as html, however some skins may choose to ignore it. An array is the preferred format
* for the icon, the following keys are used:
* src: An absolute url to the image to use for the icon, this is recommended
* but not required, however some skins will ignore icons without an image
* Set of available actions that can be restricted via action=protect
* You probably shouldn't change this.
* Translated through restriction-* messages.
- * Title::getRestrictionTypes() will remove restrictions that are not
+ * Title::getRestrictionTypes() will remove restrictions that are not
* applicable to a specific title (upload currently)
*/
$wgRestrictionTypes = array( 'edit', 'move', 'upload' );
$wgReadOnlyFile = false;
/**
- * When you run the web-based upgrade utility, it will tell you what to set
+ * When you run the web-based upgrade utility, it will tell you what to set
* this to in order to authorize the upgrade process. It will subsequently be
* used as a password, to authorize further upgrades.
*
- * For security, do not set this to a guessable string. Use the value supplied
- * by the install/upgrade process. To cause the upgrader to generate a new key,
+ * For security, do not set this to a guessable string. Use the value supplied
+ * by the install/upgrade process. To cause the upgrader to generate a new key,
* delete the old key from LocalSettings.php.
*/
$wgUpgradeKey = false;
$wgCategoryPagingLimit = 200;
/**
- * Specify how category names should be sorted, when listed on a category page.
+ * Specify how category names should be sorted, when listed on a category page.
* A sorting scheme is also known as a collation.
*
* Available values are:
*
* - uppercase: Converts the category name to upper case, and sorts by that.
*
- * - uca-default: Provides access to the Unicode Collation Algorithm with
+ * - uca-default: Provides access to the Unicode Collation Algorithm with
* the default element table. This is a compromise collation which sorts
* all languages in a mediocre way. However, it is better than "uppercase".
*
- * To use the uca-default collation, you must have PHP's intl extension
- * installed. See http://php.net/manual/en/intl.setup.php . The details of the
- * resulting collation will depend on the version of ICU installed on the
+ * To use the uca-default collation, you must have PHP's intl extension
+ * installed. See http://php.net/manual/en/intl.setup.php . The details of the
+ * resulting collation will depend on the version of ICU installed on the
* server.
*
* After you change this, you must run maintenance/updateCollation.php to fix
- * the sort keys in the database.
+ * the sort keys in the database.
*/
$wgCategoryCollation = 'uppercase';
if ( $this->wasDeletedSinceLastEdit() && 'save' == $this->formtype ) {
$username = $this->lastDelete->user_name;
$comment = $this->lastDelete->log_comment;
-
+
// It is better to not parse the comment at all than to have templates expanded in the middle
// TODO: can the checkLabel be moved outside of the div so that wrapWikiMsg could be used?
$wgOut->addHTML(
$data = $dbr->selectRow(
array( 'logging', 'user' ),
array( 'log_type',
- 'log_action',
- 'log_timestamp',
- 'log_user',
- 'log_namespace',
- 'log_title',
- 'log_comment',
- 'log_params',
- 'log_deleted',
- 'user_name' ),
+ 'log_action',
+ 'log_timestamp',
+ 'log_user',
+ 'log_namespace',
+ 'log_title',
+ 'log_comment',
+ 'log_params',
+ 'log_deleted',
+ 'user_name' ),
array( 'log_namespace' => $this->mTitle->getNamespace(),
- 'log_title' => $this->mTitle->getDBkey(),
- 'log_type' => 'delete',
- 'log_action' => 'delete',
- 'user_id=log_user' ),
+ 'log_title' => $this->mTitle->getDBkey(),
+ 'log_type' => 'delete',
+ 'log_action' => 'delete',
+ 'user_id=log_user' ),
__METHOD__,
array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' )
);
array_map( array( 'Xml', 'encodeJsVar' ), $params ) );
$script .= "addButton($paramList);\n";
}
-
+
$wgOut->addScript( Html::inlineScript(
"if ( window.mediaWiki ) { jQuery(function(){{$script}}); }"
) );
-
+
$toolbar .= "\n</div>";
wfRunHooks( 'EditPageBeforeEditToolbar', array( &$toolbar ) );
switch ( $value ) {
case self::AS_HOOK_ERROR_EXPECTED:
case self::AS_CONTENT_TOO_BIG:
- case self::AS_ARTICLE_WAS_DELETED:
+ case self::AS_ARTICLE_WAS_DELETED:
case self::AS_CONFLICT_DETECTED:
case self::AS_SUMMARY_NEEDED:
case self::AS_TEXTBOX_EMPTY:
$this->userNotLoggedInPage();
return false;
- case self::AS_READ_ONLY_PAGE_LOGGED:
- case self::AS_READ_ONLY_PAGE:
- $wgOut->readOnlyPage();
- return false;
+ case self::AS_READ_ONLY_PAGE_LOGGED:
+ case self::AS_READ_ONLY_PAGE:
+ $wgOut->readOnlyPage();
+ return false;
- case self::AS_RATE_LIMITED:
- $wgOut->rateLimited();
- return false;
+ case self::AS_RATE_LIMITED:
+ $wgOut->rateLimited();
+ return false;
- case self::AS_NO_CREATE_PERMISSION:
- $this->noCreatePermission();
- return;
+ case self::AS_NO_CREATE_PERMISSION:
+ $this->noCreatePermission();
+ return;
case self::AS_BLANK_ARTICLE:
- $wgOut->redirect( $this->getContextTitle()->getFullURL() );
- return false;
+ $wgOut->redirect( $this->getContextTitle()->getFullURL() );
+ return false;
case self::AS_IMAGE_REDIRECT_LOGGED:
$wgOut->permissionRequired( 'upload' );
wfProfileOut( __METHOD__ );
return 0;
}
-
+
# Some fields heavily used for linking...
if ( $this->mForUpdate ) {
$db = wfGetDB( DB_MASTER );
$options = array();
}
- $s = $db->selectRow( 'page',
+ $s = $db->selectRow( 'page',
array( 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ),
array( 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey() ),
__METHOD__, $options );
function getQueryInfo() {
return null;
}
-
+
/**
* For back-compat, subclasses may return a raw SQL query here, as a string.
* This is stronly deprecated; getQueryInfo() should be overridden instead.
if ( !$this->isCacheable() ) {
return 0;
}
-
+
$fname = get_class( $this ) . '::recache';
$dbw = wfGetDB( DB_MASTER );
$dbr = wfGetDB( DB_SLAVE, array( $this->getName(), __METHOD__, 'vslow' ) );
}
}
if ( !$found ) {
- wfWarn( "Did not find alias for special page '$name'. " .
+ wfWarn( "Did not find alias for special page '$name'. " .
"Perhaps no aliases are defined for it?" );
}
}
# Don't change the following default, NS_MAIN is hardcoded in several
# places. See bug 696.
var $mDefaultNamespace = NS_MAIN; // /< Namespace index when there is no namespace
- # Zero except in {{transclusion}} tags
+ # Zero except in {{transclusion}} tags
var $mWatched = null; // /< Is $wgUser watching this page? null if unfilled, accessed through userIsWatching()
var $mLength = -1; // /< The page length, 0 for special pages
var $mRedirect = null; // /< Is the article at this title a redirect?
return array();
}
$dbr = wfGetDB( DB_SLAVE );
-
+
$res = $dbr->select(
'page',
array(
/**
* Check restrictions on cascading pages.
- *
+ *
* @param $action String the action to check
* @param $user User to check
* @param $errors Array list of current errors
* cache that we don't need to over-optimize by doing direct comparisons and
* acidentally creating new bugs where $title->equals( Title::newFromText() )
* ends up reporting something differently than $title->isMainPage();
- *
+ *
* @return Bool
*/
public function isMainPage() {
public function userCanEditJsSubpage() {
global $wgUser;
return ( ( $wgUser->isAllowed( 'editusercssjs' ) && $wgUser->isAllowed( 'edituserjs' ) )
- || preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform ) );
+ || preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform ) );
}
/**
if ( $this->mInterwiki != '' ) {
$p = $this->mInterwiki . ':';
}
+
if ( 0 != $this->mNamespace ) {
$p .= $this->getNsText() . ':';
}
# Redundant interwiki prefix to the local wiki
if ( $wgLocalInterwiki !== false
- && 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) )
+ && 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) )
{
if ( $dbkey == '' ) {
# Can't have an empty self-link
# reachable due to the way web browsers deal with 'relative' URLs.
# Also, they conflict with subpage syntax. Forbid them explicitly.
if ( strpos( $dbkey, '.' ) !== false &&
- ( $dbkey === '.' || $dbkey === '..' ||
- strpos( $dbkey, './' ) === 0 ||
- strpos( $dbkey, '../' ) === 0 ||
- strpos( $dbkey, '/./' ) !== false ||
- strpos( $dbkey, '/../' ) !== false ||
- substr( $dbkey, -2 ) == '/.' ||
- substr( $dbkey, -3 ) == '/..' ) )
+ ( $dbkey === '.' || $dbkey === '..' ||
+ strpos( $dbkey, './' ) === 0 ||
+ strpos( $dbkey, '../' ) === 0 ||
+ strpos( $dbkey, '/./' ) !== false ||
+ strpos( $dbkey, '/../' ) !== false ||
+ substr( $dbkey, -2 ) == '/.' ||
+ substr( $dbkey, -3 ) == '/..' ) )
{
return false;
}
}
if ( ( $this->getDBkey() == '' ) ||
( !$oldid ) ||
- ( $nt->getDBkey() == '' ) ) {
+ ( $nt->getDBkey() == '' ) ) {
$errors[] = array( 'badarticleerror' );
}
);
$dbw->update( 'categorylinks',
array(
- 'cl_sortkey' => Collation::singleton()->getSortKey(
+ 'cl_sortkey' => Collation::singleton()->getSortKey(
$nt->getCategorySortkey( $prefix ) ),
'cl_timestamp=cl_timestamp' ),
array( 'cl_from' => $pageid ),
/**
* Callback for usort() to do title sorts by (namespace, title)
- *
+ *
* @return Integer: result of string comparison, or namespace comparison
*/
public static function compare( $a, $b ) {
// Spec: http://www.sixapart.com/pronet/docs/trackback_spec
return "<!--
<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"
- xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
- xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\">
+ xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
+ xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\">
<rdf:Description
rdf:about=\"$url\"
dc:identifier=\"$url\"
*/
public function getRestrictionTypes() {
global $wgRestrictionTypes;
-
+
$types = $this->exists() ? $wgRestrictionTypes : array( 'create' );
if ( $this->getNamespace() != NS_FILE ) {
$types = array_diff( $types, array( 'upload' ) );
}
-
+
wfRunHooks( 'TitleGetRestrictionTypes', array( $this, &$types ) );
-
+
return $types;
}
if( $res && $dbr->numRows( $res ) > 0 ) {
$cache = LinkCache::singleton();
- foreach ( $res as $row ) {
+ foreach ( $res as $row ) {
$title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );
if( $title instanceof Title ) {
// Update the link cache while we're at it
$this->loadNewText();
$wgOut->setRevisionId( $this->mNewRev->getId() );
-
+
if ( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) {
// Stolen from Article::view --AG 2007-10-11
// Give hooks a chance to customise the output
$wgOut->addParserOutput( $pOutput );
} else {
$article->doViewParse();
- }
+ }
} else {
$wgOut->addWikiTextTidy( $this->mNewtext );
}
/**
* Open a connection to the database using the administrative user/password
- * currently defined in the session, without any caching. Returns a status
+ * currently defined in the session, without any caching. Returns a status
* object. On success, the status object will contain a Database object in
* its value member.
*
/**
* Connect to the database using the administrative user/password currently
- * defined in the session. Returns a status object. On success, the status
+ * defined in the session. Returns a status object. On success, the status
* object will contain a Database object in its value member.
- *
+ *
* This will return a cached connection if one is available.
*
* @return Status
public abstract function getLocalSettings();
/**
- * Override this to provide DBMS-specific schema variables, to be
+ * Override this to provide DBMS-specific schema variables, to be
* substituted into tables.sql and other schema files.
*/
public function getSchemaVars() {
/**
* Set up LBFactory so that wfGetDB() etc. works.
- * We set up a special LBFactory instance which returns the current
+ * We set up a special LBFactory instance which returns the current
* installer connection.
*/
public function enableLB() {
$r = $this->parent->request;
if ( $r->wasPosted() ) {
$status = $this->submit();
+
if ( $status->isGood() ) {
$this->setVar( '_UpgradeDone', false );
return 'continue';
/**
* Job for asynchronous upload-by-url.
- *
+ *
* This job is in fact an interface to UploadFromUrl, which is designed such
* that it does not require any globals. If it does, fix it elsewhere, do not
* add globals in here.
*/
class UploadFromUrlJob extends Job {
const SESSION_KEYNAME = 'wsUploadFromUrlJobData';
-
+
public $upload;
protected $user;
public function run() {
# Initialize this object and the upload object
$this->upload = new UploadFromUrl();
- $this->upload->initialize(
- $this->title->getText(),
+ $this->upload->initialize(
+ $this->title->getText(),
$this->params['url'],
false
);
$this->user = User::newFromName( $this->params['userName'] );
-
+
# Fetch the file
$status = $this->upload->fetchFile();
if ( !$status->isOk() ) {
$this->leaveMessage( $status );
return true;
}
-
+
# Verify upload
$result = $this->upload->verifyUpload();
if ( $result['status'] != UploadBase::OK ) {
$this->leaveMessage( $status );
return true;
}
-
+
# Check warnings
if ( !$this->params['ignoreWarnings'] ) {
$warnings = $this->upload->checkWarnings();
- if ( $warnings ) {
+ if ( $warnings ) {
wfSetupSession( $this->params['sessionId'] );
-
+
if ( $this->params['leaveMessage'] ) {
- $this->user->leaveUserMessage(
+ $this->user->leaveUserMessage(
wfMsg( 'upload-warning-subj' ),
- wfMsg( 'upload-warning-msg',
+ wfMsg( 'upload-warning-msg',
$this->params['sessionKey'],
$this->params['url'] )
);
$this->storeResultInSession( 'Warning',
'warnings', $warnings );
}
-
+
# Stash the upload in the session
$this->upload->stashSession( $this->params['sessionKey'] );
session_write_close();
-
+
return true;
}
}
-
+
# Perform the upload
- $status = $this->upload->performUpload(
+ $status = $this->upload->performUpload(
$this->params['comment'],
$this->params['pageText'],
$this->params['watch'],
);
$this->leaveMessage( $status );
return true;
-
+
}
-
+
/**
* Leave a message on the user talk page or in the session according to
* $params['leaveMessage'].
- *
+ *
* @param $status Status
*/
protected function leaveMessage( $status ) {
if ( $this->params['leaveMessage'] ) {
if ( $status->isGood() ) {
$this->user->leaveUserMessage( wfMsg( 'upload-success-subj' ),
- wfMsg( 'upload-success-msg',
+ wfMsg( 'upload-success-msg',
$this->upload->getTitle()->getText(),
- $this->params['url']
+ $this->params['url']
) );
} else {
$this->user->leaveUserMessage( wfMsg( 'upload-failure-subj' ),
- wfMsg( 'upload-failure-msg',
+ wfMsg( 'upload-failure-msg',
$status->getWikiText(),
$this->params['url']
) );
}
} else {
- wfSetupSession( $this->params['sessionId'] );
+ wfSetupSession( $this->params['sessionId'] );
if ( $status->isOk() ) {
- $this->storeResultInSession( 'Success',
+ $this->storeResultInSession( 'Success',
'filename', $this->upload->getLocalFile()->getName() );
} else {
$this->storeResultInSession( 'Failure',
'errors', $status->getErrorsArray() );
}
- session_write_close();
+ session_write_close();
}
}
/**
* Store a result in the session data. Note that the caller is responsible
* for appropriate session_start and session_write_close calls.
- *
+ *
* @param $result String: the result (Success|Warning|Failure)
* @param $dataKey String: the key of the extra data
* @param $dataValue Mixed: the extra data itself
$session['result'] = $result;
$session[$dataKey] = $dataValue;
}
-
+
/**
* Initialize the session data. Sets the intial result to queued.
*/
$session =& self::getSessionData( $this->params['sessionKey'] );
$$session['result'] = 'Queued';
}
-
+
public static function &getSessionData( $key ) {
if ( !isset( $_SESSION[self::SESSION_KEYNAME][$key] ) ) {
$_SESSION[self::SESSION_KEYNAME][$key] = array();
<?php
/**
* JavaScript Distiller
- *
+ *
* Author: Dean Edwards, Nicholas Martin, Trevor Parscal
* License: LGPL
*/
/**
* Removes most of the white-space from JavaScript code.
- *
+ *
* This code came from the first pass of Dean Edwards' JavaScript Packer. Compared to using
* JSMin::minify, this produces < 1% larger output (after gzip) in approx. 25% of the time.
- *
+ *
* @param $script String: JavaScript code to minify
* @param $stripVerticalSpace Boolean: Try to remove as much vertical whitespace as possible
*/
/*
* Creates an instance of ParseMaster and protects sensitive JavaScript regions.
- *
+ *
* This parser is based on regular expressions, which all get or'd together, so rules take
* precedence in the order they are added. We can use it to minify by armoring certain regions
* by matching them and replacing them with the full match, leaving the remaining regions around
* ParseMaster, version 1.0.2 (2005-08-19) Copyright 2005, Dean Edwards
* A multi-pattern parser.
* License: http://creativecommons.org/licenses/LGPL/2.1/
- *
+ *
* This is the PHP version of the ParseMaster component of Dean Edwards' (http://dean.edwards.name/)
* Packer, which was originally written in JavaScript. It was ported to PHP by Nicolas Martin.
- *
+ *
* Original Source: http://joliclic.free.fr/php/javascript-packer/en/
- *
+ *
* Changes should be pushed back upstream.
*/
class ParseMaster {
public $ignoreCase = false;
public $escapeChar = '';
-
+
// constants
const EXPRESSION = 0;
const REPLACEMENT = 1;
const LENGTH = 2;
-
+
// used to determine nesting levels
private $GROUPS = '/\\(/';//g
private $SUB_REPLACE = '/\\$\\d/';
private $ESCAPE = '/\\\./';//g
private $QUOTE = '/\'/';
private $DELETED = '/\\x01[^\\x01]*\\x01/';//g
-
+
public function add($expression, $replacement = '') {
// count the number of sub-expressions
// - add one because each pattern is itself a sub-expression
$length = 1 + preg_match_all($this->GROUPS, $this->_internalEscape((string)$expression), $out);
-
+
// treat only strings $replacement
if (is_string($replacement)) {
// does the pattern deal with sub-expressions?
} else { // a complicated lookup (e.g. "Hello $2 $1")
// build a function to do the lookup
$quote = preg_match($this->QUOTE, $this->_internalEscape($replacement))
- ? '"' : "'";
+ ? '"' : "'";
$replacement = array(
'fn' => '_backReferences',
'data' => array(
if (!empty($expression)) $this->_add($expression, $replacement, $length);
else $this->_add('/^$/', $replacement, $length);
}
-
+
public function exec($string) {
// execute the global replacement
$this->_escaped = array();
-
+
// simulate the _patterns.toSTring of Dean
$regexp = '/';
foreach ($this->_patterns as $reg) {
}
$regexp = substr($regexp, 0, -1) . '/S';
$regexp .= ($this->ignoreCase) ? 'i' : '';
-
+
$string = $this->_escape($string, $this->escapeChar);
$string = preg_replace_callback(
$regexp,
$string
);
$string = $this->_unescape($string, $this->escapeChar);
-
+
return preg_replace($this->DELETED, '', $string);
}
-
+
public function reset() {
// clear the patterns collection so that this object may be re-used
$this->_patterns = array();
// private
private $_escaped = array(); // escaped characters
private $_patterns = array(); // patterns stored by index
-
+
// create and add a new pattern to the patterns collection
private function _add() {
$arguments = func_get_args();
$this->_patterns[] = $arguments;
}
-
+
// this is the global replace function (it's quite complicated)
private function _replacement($arguments) {
if (empty($arguments)) return '';
-
+
$i = 1; $j = 0;
// loop through the patterns
while (isset($this->_patterns[$j])) {
// do we have a result?
if (isset($arguments[$i]) && ($arguments[$i] != '')) {
$replacement = $pattern[self::REPLACEMENT];
-
+
if (is_array($replacement) && isset($replacement['fn'])) {
-
+
if (isset($replacement['data'])) $this->buffer = $replacement['data'];
return call_user_func(array(&$this, $replacement['fn']), $arguments, $i);
-
+
} elseif (is_int($replacement)) {
return $arguments[$replacement + $i];
-
+
}
$delete = ($this->escapeChar == '' ||
- strpos($arguments[$i], $this->escapeChar) === false)
- ? '' : "\x01" . $arguments[$i] . "\x01";
+ strpos($arguments[$i], $this->escapeChar) === false)
+ ? '' : "\x01" . $arguments[$i] . "\x01";
return $delete . $replacement;
-
+
// skip over references to sub-expressions
} else {
$i += $pattern[self::LENGTH];
}
}
}
-
+
private function _backReferences($match, $offset) {
$replacement = $this->buffer['replacement'];
$quote = $this->buffer['quote'];
}
return $replacement;
}
-
+
private function _replace_name($match, $offset){
$length = strlen($match[$offset + 2]);
$start = $length - max($length - strlen($match[$offset + 3]), 0);
return substr($match[$offset + 1], $start, $length) . $match[$offset + 4];
}
-
+
private function _replace_encoded($match, $offset) {
return $this->buffer[$match[$offset]];
}
-
-
+
+
// php : we cannot pass additional data to preg_replace_callback,
// and we cannot use &$this in create_function, so let's go to lower level
private $buffer;
-
+
// encode escaped characters
private function _escape($string, $escapeChar) {
if ($escapeChar) {
array(&$this, '_escapeBis'),
$string
);
-
+
} else {
return $string;
}
$this->_escaped[] = $match[1];
return $this->buffer;
}
-
+
// decode escaped characters
private function _unescape($string, $escapeChar) {
if ($escapeChar) {
array(&$this, '_unescapeBis'),
$string
);
-
+
} else {
return $string;
}
$this->buffer['i']++;
return $this->buffer['escapeChar'] . $temp;
}
-
+
private function _internalEscape($string) {
return preg_replace($this->ESCAPE, '', $string);
}
}
return $holders->makeHolder( $title, isset($displayText) ? $displayText : $titleText, '', '', '' );
}
-
+
static function categoryLinkHook( $parser, $holders, $markers,
Title $title, $titleText, &$sortText = null, &$leadingColon = false ) {
global $wgContLang;
$parser->mOutput->addCategory( $title->getDBkey(), $sortText );
return '';
}
-
+
}
$threshold = $this->getStubThreshold();
$titlesToBeConverted = '';
$titlesAttrs = array();
-
+
// Concatenate titles to a single string, thus we only need auto convert the
// single string to all variants. This would improve parser's performance
// significantly.
'ns' => $ns,
'key' => "$ns:$index",
'titleText' => $titleText,
- );
+ );
// separate titles with \0 because it would never appears
// in a valid title
$titlesToBeConverted .= $titleText . "\0";
}
}
}
-
+
// Now do the conversion and explode string to text of titles
$titlesAllVariants = $wgContLang->autoConvertToAllVariants( $titlesToBeConverted );
$allVariantsName = array_keys( $titlesAllVariants );
* @file
* @ingroup Parser
*/
-
+
/**
* @ingroup Parser
*/
$xml = "<list>";
foreach ( $values as $k => $val ) {
-
+
if ( is_int( $k ) ) {
$xml .= "<part><name index=\"$k\"/><value>" . htmlspecialchars( $val ) ."</value></part>";
} else {
function preprocessToObj( $text, $flags = 0 ) {
wfProfileIn( __METHOD__ );
global $wgMemc, $wgPreprocessorCacheThreshold;
-
+
$xml = false;
$cacheable = $wgPreprocessorCacheThreshold !== false && strlen( $text ) > $wgPreprocessorCacheThreshold;
if ( $cacheable ) {
wfProfileOut( __METHOD__ );
return $obj;
}
-
+
function preprocessToXml( $text, $flags = 0 ) {
wfProfileIn( __METHOD__ );
$rules = array(
} else {
$attrEnd = $tagEndPos;
// Find closing tag
- if ( preg_match( "/<\/" . preg_quote( $name, '/' ) . "\s*>/i",
- $text, $matches, PREG_OFFSET_CAPTURE, $tagEndPos + 1 ) )
+ if ( preg_match( "/<\/" . preg_quote( $name, '/' ) . "\s*>/i",
+ $text, $matches, PREG_OFFSET_CAPTURE, $tagEndPos + 1 ) )
{
$inner = substr( $text, $tagEndPos + 1, $matches[0][1] - $tagEndPos - 1 );
$i = $matches[0][1] + strlen( $matches[0][0] );
$xml = $stack->rootAccum;
wfProfileOut( __METHOD__ );
-
+
return $xml;
}
}
# Heading
$s = $this->expand( $contextNode->childNodes, $flags );
- # Insert a heading marker only for <h> children of <root>
- # This is to stop extractSections from going over multiple tree levels
- if ( $contextNode->parentNode->nodeName == 'root'
- && $this->parser->ot['html'] )
- {
+ # Insert a heading marker only for <h> children of <root>
+ # This is to stop extractSections from going over multiple tree levels
+ if ( $contextNode->parentNode->nodeName == 'root'
+ && $this->parser->ot['html'] )
+ {
# Insert heading index marker
$headingIndex = $contextNode->getAttribute( 'i' );
$titleText = $this->title->getPrefixedDBkey();
}
return $arguments;
}
-
+
function getNumberedArguments() {
$arguments = array();
foreach ( array_keys($this->numberedArgs) as $key ) {
}
return $arguments;
}
-
+
function getNamedArguments() {
$arguments = array();
foreach ( array_keys($this->namedArgs) as $key ) {
$this->typeInfo = self::$allowedTypes[$this->typeName];
# If we have revisions, get the title from the first one
- # since they should all be from the same page. This allows
+ # since they should all be from the same page. This allows
# for more flexibility with page moves...
if( $this->typeName == 'revision' ) {
$rev = Revision::newFromId( $this->ids[0] );
$this->targetObj = $rev ? $rev->getTitle() : $this->targetObj;
}
-
+
$this->otherReason = $wgRequest->getVal( 'wpReason' );
# We need a target page!
if( is_null($this->targetObj) ) {
} else {
$this->showForm();
}
-
+
$qc = $this->getLogQueryCond();
# Show relevant lines from the deletion log
$wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
}
/**
- * Show a list of items that we will operate on, and show a form with checkboxes
+ * Show a list of items that we will operate on, and show a form with checkboxes
* which will allow the user to choose new visibility settings.
*/
protected function showForm() {
$wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
return;
}
-
+
$wgOut->addHTML( "</ul>" );
// Explanation text
$this->addUsageText();
// Show form if the user can submit
if( $this->mIsAllowed ) {
$out = Xml::openElement( 'form', array( 'method' => 'post',
- 'action' => $this->getTitle()->getLocalUrl( array( 'action' => 'submit' ) ),
+ 'action' => $this->getTitle()->getLocalUrl( array( 'action' => 'submit' ) ),
'id' => 'mw-revdel-form-revisions' ) ) .
Xml::fieldset( wfMsg( 'revdelete-legend' ) ) .
$this->buildCheckBoxes() .
$wgOut->addWikiMsg( 'revdelete-confirm' );
}
}
-
+
/**
* @return String: HTML
*/
$html .= "<tr>$line</tr>\n";
}
}
-
+
$html .= '</table>';
return $html;
}
}
return $bitfield;
}
-
+
/**
* Put together a rev_deleted bitfield
* @param $bitPars array extractBitParams() params
function getPreferredVariant() {
return $this->mConverter->getPreferredVariant();
}
-
+
function getDefaultVariant() {
return $this->mConverter->getDefaultVariant();
}
-
+
function getURLVariant() {
return $this->mConverter->getURLVariant();
}
parent::setUp();
$this->doLogin();
}
-
+
function testTitlesGetNormalized() {
-
+
global $wgSitename;
-
+
$data = $this->doApiRequest( array(
'action' => 'query',
'titles' => 'Project:articleA|article_B' ) );
-
-
+
+
$this->assertArrayHasKey( 'query', $data[0] );
$this->assertArrayHasKey( 'normalized', $data[0]['query'] );
-
- $this->assertEquals(
- array(
+
+ $this->assertEquals(
+ array(
'from' => 'Project:articleA',
'to' => $wgSitename . ':ArticleA'
),
$data[0]['query']['normalized'][0]
);
-
- $this->assertEquals(
- array(
+
+ $this->assertEquals(
+ array(
'from' => 'article_B',
'to' => 'Article B'
),
$data[0]['query']['normalized'][1]
);
-
+
}
-
+
function testTitlesAreRejectedIfInvalid() {
$title = false;
while( !$title || Title::newFromText( $title )->exists() ) {
$title = md5( mt_rand( 0, 10000 ) + rand( 0, 999000 ) );
}
-
+
$data = $this->doApiRequest( array(
'action' => 'query',
'titles' => $title . '|Talk:' ) );
-
-
+
+
$this->assertArrayHasKey( 'query', $data[0] );
$this->assertArrayHasKey( 'pages', $data[0]['query'] );
$this->assertEquals( 2, count( $data[0]['query']['pages'] ) );
-
+
$this->assertArrayHasKey( -2, $data[0]['query']['pages'] );
$this->assertArrayHasKey( -1, $data[0]['query']['pages'] );
-
+
$this->assertArrayHasKey( 'missing', $data[0]['query']['pages'][-2] );
$this->assertArrayHasKey( 'invalid', $data[0]['query']['pages'][-1] );
-
-
+
+
}
}