<?php
-
/**
- * Created on May 10, 2010
- *
* API for MediaWiki 1.12+
*
+ * Created on May 10, 2010
+ *
* Copyright © 2010 Sam Reed
* Copyright © 2008 Vasiliev Victor vasilvv@gmail.com,
* based on ApiQueryAllpages.php
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
*/
if ( !defined( 'MEDIAWIKI' ) ) {
if ( !$wgUser->isAllowed( 'deletedhistory' ) ) {
$this->dieUsage( 'You don\'t have permission to view deleted file information', 'permissiondenied' );
}
-
+
$db = $this->getDB();
$params = $this->extractRequestParams();
-
+
$prop = array_flip( $params['prop'] );
- $fld_id = isset( $prop['id'] );
$fld_sha1 = isset( $prop['sha1'] );
$fld_timestamp = isset( $prop['timestamp'] );
$fld_user = isset( $prop['user'] );
$fld_mime = isset( $prop['mime'] );
$fld_metadata = isset( $prop['metadata'] );
$fld_bitdepth = isset( $prop['bitdepth'] );
-
+
$this->addTables( 'filearchive' );
-
+
$this->addFields( 'fa_name' );
$this->addFieldsIf( 'fa_storage_key', $fld_sha1 );
$this->addFieldsIf( 'fa_timestamp', $fld_timestamp );
$res = $this->select( __METHOD__ );
- $titles = array();
$count = 0;
$result = $this->getResult();
- while ( $row = $db->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
if ( ++$count > $limit ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
// TODO: Security issue - if the user has no right to view next title, it will still be shown
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->fa_name ) );
break;
}
-
+
$file = array();
$file['name'] = $row->fa_name;
$file['height'] = $row->fa_height;
$file['width'] = $row->fa_width;
}
- if ( $fld_description ){
+ if ( $fld_description ) {
$file['description'] = $row->fa_description;
}
- if ( $fld_metadata ){
+ if ( $fld_metadata ) {
$file['metadata'] = $row->fa_metadata ? ApiQueryImageInfo::processMetaData( unserialize( $row->fa_metadata ), $result ) : null;
}
- if ( $fld_bitdepth ){
+ if ( $fld_bitdepth ) {
$file['bitdepth'] = $row->fa_bits;
}
if ( $fld_mime ) {
$file['mime'] = "$row->fa_major_mime/$row->fa_minor_mime";
}
-
+
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $file );
if ( !$fit ) {
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->fa_name ) );
break;
}
}
- $db->freeResult( $res );
$result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'fa' );
}
'limit' => 'How many total images to return',
'sha1' => "SHA1 hash of image. Overrides {$this->getModulePrefix()}sha1base36",
'sha1base36' => 'SHA1 hash of image in base 36 (used in MediaWiki)',
- 'prop' => 'Which properties to get',
+ 'prop' => array(
+ 'What image information to get:',
+ ' sha1 - Adds SHA-1 hash for the image',
+ ' timestamp - Adds timestamp for the uploaded version',
+ ' user - Adds user for uploaded the image version',
+ ' size - Adds the size of the image in bytes',
+ ' dimensions - Adds the height and width of the image',
+ ' description - Adds description the image version',
+ ' mime - Adds MIME of the image',
+ ' metadata - Lists EXIF metadata for the version of the image',
+ ' bitdepth - Adds the bit depth of the version',
+ ),
);
}