* @file
*/
-/**
- * This file is the entry point for all API queries. It begins by checking
+/**
+ * This file is the entry point for all API queries. It begins by checking
* whether the API is enabled on this wiki; if not, it informs the user that
* s/he should set $wgEnableAPI to true and exits. Otherwise, it constructs
* a new ApiMain using the parameter passed to it as an argument in the URL
*/
public function getPossibleErrors() {
$ret = array();
-
+
if ( $this->mustBePosted() ) {
$ret[] = array ( 'mustbeposted', $this->getModuleName() );
}
-
+
if ( $this->isReadMode() ) {
$ret[] = array ( 'readrequired' );
}
-
+
if ( $this->isWriteMode() ) {
$ret[] = array ( 'writerequired' );
$ret[] = array ( 'writedisabled' );
}
-
+
return $ret;
}
-
+
/**
* Parses a list of errors into a standardised format
* @param $errors array List of errors. Items can be in the for array( key, param1, param2, ... ) or array( 'code' => ..., 'info' => ... )
*/
public function parseErrors( $errors ) {
$ret = array();
-
+
foreach ( $errors as $row )
- {
+ {
if ( isset( $row['code'] ) && isset( $row['info'] ) ) {
$ret[] = $row;
}
public function getIsHtml() {
return $this->mIsHtml;
}
-
+
/**
* Whether this formatter can format the help message in a nice way.
* By default, this returns the same as getIsHtml().
- * When action=help is set explicitly, the help will always be shown
+ * When action=help is set explicitly, the help will always be shown
* @return bool
*/
public function getWantsHelp() {
* @param $text string
*/
public function printText( $text ) {
+ error_log($text);
if ( $this->mBufferResult ) {
$this->mBuffer = $text;
} elseif ( $this->getIsHtml() ) {
echo $text;
}
}
-
+
/**
* Get the contents of the buffer.
*/
*/
protected function formatHTML( $text ) {
global $wgUrlProtocols;
-
+
// Escape everything first for full coverage
$text = htmlspecialchars( $text );
public function getMimeType() {
$params = $this->extractRequestParams();
- // callback:
+ // callback:
if ( $params['callback'] ) {
return 'text/javascript';
}
public function getNeedsRawData() {
return $this->mIsRaw;
}
-
+
public function getWantsHelp() {
// Help is always ugly in JSON
return false;
function getModules() {
return array_merge( $this->mQueryPropModules, $this->mQueryListModules, $this->mQueryMetaModules );
}
-
+
public function getCustomPrinter() {
// If &exportnowrap is set, use the raw formatter
if ( $this->getParameter( 'export' ) &&
public function getData() {
return $this->mData;
}
-
+
/**
* Get the 'real' size of a result item. This means the strlen() of the item,
* or the sum of the strlen()s of the elements if the item is an array.
public function getSize() {
return $this->mSize;
}
-
+
/**
* Disable size checking in addValue(). Don't use this unless you
* REALLY know what you're doing. Values added while size checking
public function disableSizeCheck() {
$this->mCheckingSize = false;
}
-
+
/**
* Re-enable size checking in addValue()
*/
$this->deleted = 0;
$this->dataLoaded = false;
$this->exists = false;
-
+
if( is_object($title) ) {
$this->title = $title;
$this->name = $title->getDBkey();
}
-
+
if ($id)
$this->id = $id;
-
+
if ($key)
$this->key = $key;
-
+
if (!$id && !$key && !is_object($title))
throw new MWException( "No specifications provided to ArchivedFile constructor." );
}
return true;
}
$conds = array();
-
+
if( $this->id > 0 )
$conds['fa_id'] = $this->id;
if( $this->key ) {
- $conds['fa_storage_group'] = $this->group;
+ $conds['fa_storage_group'] = $this->group;
$conds['fa_storage_key'] = $this->key;
}
if( $this->title )
$conds['fa_name'] = $this->title->getDBkey();
-
+
if( !count($conds))
throw new MWException( "No specific information for retrieving archived file" );
-
+
if( !$this->title || $this->title->getNamespace() == NS_FILE ) {
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'filearchive',
$this->load();
return $this->id;
}
-
+
public function exists() {
$this->load();
return $this->exists;