MediaWiki  1.23.0
File.php
Go to the documentation of this file.
1 <?php
50 abstract class File {
51  // Bitfield values akin to the Revision deletion constants
52  const DELETED_FILE = 1;
53  const DELETED_COMMENT = 2;
54  const DELETED_USER = 4;
55  const DELETED_RESTRICTED = 8;
56 
58  const RENDER_NOW = 1;
63  const RENDER_FORCE = 2;
64 
65  const DELETE_SOURCE = 1;
66 
67  // Audience options for File::getDescription()
68  const FOR_PUBLIC = 1;
69  const FOR_THIS_USER = 2;
70  const RAW = 3;
71 
72  // Options for File::thumbName()
73  const THUMB_FULL_NAME = 1;
74 
95  public $repo;
96 
98  protected $title;
99 
101  protected $lastError;
102 
104  protected $redirected;
105 
107  protected $redirectedTitle;
108 
110  protected $fsFile;
111 
113  protected $handler;
114 
116  protected $url;
117 
119  protected $extension;
120 
122  protected $name;
123 
125  protected $path;
126 
128  protected $hashPath;
129 
133  protected $pageCount;
134 
136  protected $transformScript;
137 
139  protected $redirectTitle;
140 
142  protected $canRender;
143 
147  protected $isSafeFile;
148 
150  protected $repoClass = 'FileRepo';
151 
162  function __construct( $title, $repo ) {
163  if ( $title !== false ) { // subclasses may not use MW titles
164  $title = self::normalizeTitle( $title, 'exception' );
165  }
166  $this->title = $title;
167  $this->repo = $repo;
168  }
169 
179  static function normalizeTitle( $title, $exception = false ) {
180  $ret = $title;
181  if ( $ret instanceof Title ) {
182  # Normalize NS_MEDIA -> NS_FILE
183  if ( $ret->getNamespace() == NS_MEDIA ) {
184  $ret = Title::makeTitleSafe( NS_FILE, $ret->getDBkey() );
185  # Sanity check the title namespace
186  } elseif ( $ret->getNamespace() !== NS_FILE ) {
187  $ret = null;
188  }
189  } else {
190  # Convert strings to Title objects
191  $ret = Title::makeTitleSafe( NS_FILE, (string)$ret );
192  }
193  if ( !$ret && $exception !== false ) {
194  throw new MWException( "`$title` is not a valid file title." );
195  }
196 
197  return $ret;
198  }
199 
200  function __get( $name ) {
201  $function = array( $this, 'get' . ucfirst( $name ) );
202  if ( !is_callable( $function ) ) {
203  return null;
204  } else {
205  $this->$name = call_user_func( $function );
206 
207  return $this->$name;
208  }
209  }
210 
218  static function normalizeExtension( $ext ) {
219  $lower = strtolower( $ext );
220  $squish = array(
221  'htm' => 'html',
222  'jpeg' => 'jpg',
223  'mpeg' => 'mpg',
224  'tiff' => 'tif',
225  'ogv' => 'ogg' );
226  if ( isset( $squish[$lower] ) ) {
227  return $squish[$lower];
228  } elseif ( preg_match( '/^[0-9a-z]+$/', $lower ) ) {
229  return $lower;
230  } else {
231  return '';
232  }
233  }
234 
243  static function checkExtensionCompatibility( File $old, $new ) {
244  $oldMime = $old->getMimeType();
245  $n = strrpos( $new, '.' );
246  $newExt = self::normalizeExtension( $n ? substr( $new, $n + 1 ) : '' );
247  $mimeMagic = MimeMagic::singleton();
248 
249  return $mimeMagic->isMatchingExtension( $newExt, $oldMime );
250  }
251 
257  function upgradeRow() {
258  }
259 
267  public static function splitMime( $mime ) {
268  if ( strpos( $mime, '/' ) !== false ) {
269  return explode( '/', $mime, 2 );
270  } else {
271  return array( $mime, 'unknown' );
272  }
273  }
274 
282  public static function compare( File $a, File $b ) {
283  return strcmp( $a->getName(), $b->getName() );
284  }
285 
291  public function getName() {
292  if ( !isset( $this->name ) ) {
293  $this->assertRepoDefined();
294  $this->name = $this->repo->getNameFromTitle( $this->title );
295  }
296 
297  return $this->name;
298  }
299 
305  function getExtension() {
306  if ( !isset( $this->extension ) ) {
307  $n = strrpos( $this->getName(), '.' );
308  $this->extension = self::normalizeExtension(
309  $n ? substr( $this->getName(), $n + 1 ) : '' );
310  }
311 
312  return $this->extension;
313  }
314 
320  public function getTitle() {
321  return $this->title;
322  }
323 
329  public function getOriginalTitle() {
330  if ( $this->redirected ) {
331  return $this->getRedirectedTitle();
332  }
333 
334  return $this->title;
335  }
336 
342  public function getUrl() {
343  if ( !isset( $this->url ) ) {
344  $this->assertRepoDefined();
345  $ext = $this->getExtension();
346  $this->url = $this->repo->getZoneUrl( 'public', $ext ) . '/' . $this->getUrlRel();
347  }
348 
349  return $this->url;
350  }
351 
359  public function getFullUrl() {
360  return wfExpandUrl( $this->getUrl(), PROTO_RELATIVE );
361  }
362 
366  public function getCanonicalUrl() {
367  return wfExpandUrl( $this->getUrl(), PROTO_CANONICAL );
368  }
369 
373  function getViewURL() {
374  if ( $this->mustRender() ) {
375  if ( $this->canRender() ) {
376  return $this->createThumb( $this->getWidth() );
377  } else {
378  wfDebug( __METHOD__ . ': supposed to render ' . $this->getName() .
379  ' (' . $this->getMimeType() . "), but can't!\n" );
380 
381  return $this->getURL(); #hm... return NULL?
382  }
383  } else {
384  return $this->getURL();
385  }
386  }
387 
401  public function getPath() {
402  if ( !isset( $this->path ) ) {
403  $this->assertRepoDefined();
404  $this->path = $this->repo->getZonePath( 'public' ) . '/' . $this->getRel();
405  }
406 
407  return $this->path;
408  }
409 
417  public function getLocalRefPath() {
418  $this->assertRepoDefined();
419  if ( !isset( $this->fsFile ) ) {
420  $this->fsFile = $this->repo->getLocalReference( $this->getPath() );
421  if ( !$this->fsFile ) {
422  $this->fsFile = false; // null => false; cache negative hits
423  }
424  }
425 
426  return ( $this->fsFile )
427  ? $this->fsFile->getPath()
428  : false;
429  }
430 
441  public function getWidth( $page = 1 ) {
442  return false;
443  }
444 
455  public function getHeight( $page = 1 ) {
456  return false;
457  }
458 
466  public function getUser( $type = 'text' ) {
467  return null;
468  }
469 
475  public function getLength() {
476  $handler = $this->getHandler();
477  if ( $handler ) {
478  return $handler->getLength( $this );
479  } else {
480  return 0;
481  }
482  }
483 
489  public function isVectorized() {
490  $handler = $this->getHandler();
491  if ( $handler ) {
492  return $handler->isVectorized( $this );
493  } else {
494  return false;
495  }
496  }
497 
509  public function getAvailableLanguages() {
510  $handler = $this->getHandler();
511  if ( $handler ) {
512  return $handler->getAvailableLanguages( $this );
513  } else {
514  return array();
515  }
516  }
517 
525  public function getDefaultRenderLanguage() {
526  $handler = $this->getHandler();
527  if ( $handler ) {
528  return $handler->getDefaultRenderLanguage( $this );
529  } else {
530  return null;
531  }
532  }
533 
544  public function canAnimateThumbIfAppropriate() {
545  $handler = $this->getHandler();
546  if ( !$handler ) {
547  // We cannot handle image whatsoever, thus
548  // one would not expect it to be animated
549  // so true.
550  return true;
551  } else {
552  if ( $this->allowInlineDisplay()
553  && $handler->isAnimatedImage( $this )
554  && !$handler->canAnimateThumbnail( $this )
555  ) {
556  // Image is animated, but thumbnail isn't.
557  // This is unexpected to the user.
558  return false;
559  } else {
560  // Image is not animated, so one would
561  // not expect thumb to be
562  return true;
563  }
564  }
565  }
566 
573  public function getMetadata() {
574  return false;
575  }
576 
583  public function getCommonMetaArray() {
584  $handler = $this->getHandler();
585 
586  if ( !$handler ) {
587  return false;
588  }
589 
590  return $handler->getCommonMetaArray( $this );
591  }
592 
601  public function convertMetadataVersion( $metadata, $version ) {
602  $handler = $this->getHandler();
603  if ( !is_array( $metadata ) ) {
604  // Just to make the return type consistent
605  $metadata = unserialize( $metadata );
606  }
607  if ( $handler ) {
608  return $handler->convertMetadataVersion( $metadata, $version );
609  } else {
610  return $metadata;
611  }
612  }
613 
620  public function getBitDepth() {
621  return 0;
622  }
623 
630  public function getSize() {
631  return false;
632  }
633 
641  function getMimeType() {
642  return 'unknown/unknown';
643  }
644 
652  function getMediaType() {
653  return MEDIATYPE_UNKNOWN;
654  }
655 
668  function canRender() {
669  if ( !isset( $this->canRender ) ) {
670  $this->canRender = $this->getHandler() && $this->handler->canRender( $this );
671  }
672 
673  return $this->canRender;
674  }
675 
680  protected function getCanRender() {
681  return $this->canRender();
682  }
683 
694  function mustRender() {
695  return $this->getHandler() && $this->handler->mustRender( $this );
696  }
697 
703  function allowInlineDisplay() {
704  return $this->canRender();
705  }
706 
720  function isSafeFile() {
721  if ( !isset( $this->isSafeFile ) ) {
722  $this->isSafeFile = $this->getIsSafeFileUncached();
723  }
724 
725  return $this->isSafeFile;
726  }
727 
733  protected function getIsSafeFile() {
734  return $this->isSafeFile();
735  }
736 
742  protected function getIsSafeFileUncached() {
743  global $wgTrustedMediaFormats;
744 
745  if ( $this->allowInlineDisplay() ) {
746  return true;
747  }
748  if ( $this->isTrustedFile() ) {
749  return true;
750  }
751 
752  $type = $this->getMediaType();
753  $mime = $this->getMimeType();
754  #wfDebug( "LocalFile::isSafeFile: type= $type, mime= $mime\n" );
755 
756  if ( !$type || $type === MEDIATYPE_UNKNOWN ) {
757  return false; #unknown type, not trusted
758  }
759  if ( in_array( $type, $wgTrustedMediaFormats ) ) {
760  return true;
761  }
762 
763  if ( $mime === "unknown/unknown" ) {
764  return false; #unknown type, not trusted
765  }
766  if ( in_array( $mime, $wgTrustedMediaFormats ) ) {
767  return true;
768  }
769 
770  return false;
771  }
772 
786  function isTrustedFile() {
787  #this could be implemented to check a flag in the database,
788  #look for signatures, etc
789  return false;
790  }
791 
799  public function exists() {
800  return $this->getPath() && $this->repo->fileExists( $this->path );
801  }
802 
809  public function isVisible() {
810  return $this->exists();
811  }
812 
816  function getTransformScript() {
817  if ( !isset( $this->transformScript ) ) {
818  $this->transformScript = false;
819  if ( $this->repo ) {
820  $script = $this->repo->getThumbScriptUrl();
821  if ( $script ) {
822  $this->transformScript = wfAppendQuery( $script, array( 'f' => $this->getName() ) );
823  }
824  }
825  }
826 
827  return $this->transformScript;
828  }
829 
837  function getUnscaledThumb( $handlerParams = array() ) {
838  $hp =& $handlerParams;
839  $page = isset( $hp['page'] ) ? $hp['page'] : false;
840  $width = $this->getWidth( $page );
841  if ( !$width ) {
842  return $this->iconThumb();
843  }
844  $hp['width'] = $width;
845 
846  return $this->transform( $hp );
847  }
848 
858  public function thumbName( $params, $flags = 0 ) {
859  $name = ( $this->repo && !( $flags & self::THUMB_FULL_NAME ) )
860  ? $this->repo->nameForThumb( $this->getName() )
861  : $this->getName();
862 
863  return $this->generateThumbName( $name, $params );
864  }
865 
873  public function generateThumbName( $name, $params ) {
874  if ( !$this->getHandler() ) {
875  return null;
876  }
877  $extension = $this->getExtension();
878  list( $thumbExt, ) = $this->handler->getThumbType(
879  $extension, $this->getMimeType(), $params );
880  $thumbName = $this->handler->makeParamString( $params ) . '-' . $name;
881  if ( $thumbExt != $extension ) {
882  $thumbName .= ".$thumbExt";
883  }
884 
885  return $thumbName;
886  }
887 
905  public function createThumb( $width, $height = -1 ) {
906  $params = array( 'width' => $width );
907  if ( $height != -1 ) {
908  $params['height'] = $height;
909  }
910  $thumb = $this->transform( $params );
911  if ( !$thumb || $thumb->isError() ) {
912  return '';
913  }
914 
915  return $thumb->getUrl();
916  }
917 
927  protected function transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags ) {
928  global $wgIgnoreImageErrors;
929 
930  $handler = $this->getHandler();
931  if ( $handler && $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
932  return $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
933  } else {
934  return new MediaTransformError( 'thumbnail_error',
935  $params['width'], 0, wfMessage( 'thumbnail-dest-create' )->text() );
936  }
937  }
938 
947  function transform( $params, $flags = 0 ) {
948  global $wgUseSquid, $wgIgnoreImageErrors, $wgThumbnailEpoch;
949 
950  wfProfileIn( __METHOD__ );
951  do {
952  if ( !$this->canRender() ) {
953  $thumb = $this->iconThumb();
954  break; // not a bitmap or renderable image, don't try
955  }
956 
957  // Get the descriptionUrl to embed it as comment into the thumbnail. Bug 19791.
958  $descriptionUrl = $this->getDescriptionUrl();
959  if ( $descriptionUrl ) {
960  $params['descriptionUrl'] = wfExpandUrl( $descriptionUrl, PROTO_CANONICAL );
961  }
962 
963  $handler = $this->getHandler();
964  $script = $this->getTransformScript();
965  if ( $script && !( $flags & self::RENDER_NOW ) ) {
966  // Use a script to transform on client request, if possible
967  $thumb = $handler->getScriptedTransform( $this, $script, $params );
968  if ( $thumb ) {
969  break;
970  }
971  }
972 
973  $normalisedParams = $params;
974  $handler->normaliseParams( $this, $normalisedParams );
975 
976  $thumbName = $this->thumbName( $normalisedParams );
977  $thumbUrl = $this->getThumbUrl( $thumbName );
978  $thumbPath = $this->getThumbPath( $thumbName ); // final thumb path
979 
980  if ( $this->repo ) {
981  // Defer rendering if a 404 handler is set up...
982  if ( $this->repo->canTransformVia404() && !( $flags & self::RENDER_NOW ) ) {
983  wfDebug( __METHOD__ . " transformation deferred.\n" );
984  // XXX: Pass in the storage path even though we are not rendering anything
985  // and the path is supposed to be an FS path. This is due to getScalerType()
986  // getting called on the path and clobbering $thumb->getUrl() if it's false.
987  $thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
988  break;
989  }
990  // Clean up broken thumbnails as needed
991  $this->migrateThumbFile( $thumbName );
992  // Check if an up-to-date thumbnail already exists...
993  wfDebug( __METHOD__ . ": Doing stat for $thumbPath\n" );
994  if ( !( $flags & self::RENDER_FORCE ) && $this->repo->fileExists( $thumbPath ) ) {
995  $timestamp = $this->repo->getFileTimestamp( $thumbPath );
996  if ( $timestamp !== false && $timestamp >= $wgThumbnailEpoch ) {
997  // XXX: Pass in the storage path even though we are not rendering anything
998  // and the path is supposed to be an FS path. This is due to getScalerType()
999  // getting called on the path and clobbering $thumb->getUrl() if it's false.
1000  $thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
1001  $thumb->setStoragePath( $thumbPath );
1002  break;
1003  }
1004  } elseif ( $flags & self::RENDER_FORCE ) {
1005  wfDebug( __METHOD__ . " forcing rendering per flag File::RENDER_FORCE\n" );
1006  }
1007  }
1008 
1009  // If the backend is ready-only, don't keep generating thumbnails
1010  // only to return transformation errors, just return the error now.
1011  if ( $this->repo->getReadOnlyReason() !== false ) {
1012  $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
1013  break;
1014  }
1015 
1016  // Create a temp FS file with the same extension and the thumbnail
1017  $thumbExt = FileBackend::extensionFromPath( $thumbPath );
1018  $tmpFile = TempFSFile::factory( 'transform_', $thumbExt );
1019  if ( !$tmpFile ) {
1020  $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
1021  break;
1022  }
1023  $tmpThumbPath = $tmpFile->getPath(); // path of 0-byte temp file
1024 
1025  // Actually render the thumbnail...
1026  wfProfileIn( __METHOD__ . '-doTransform' );
1027  $thumb = $handler->doTransform( $this, $tmpThumbPath, $thumbUrl, $params );
1028  wfProfileOut( __METHOD__ . '-doTransform' );
1029  $tmpFile->bind( $thumb ); // keep alive with $thumb
1030 
1031  if ( !$thumb ) { // bad params?
1032  $thumb = null;
1033  } elseif ( $thumb->isError() ) { // transform error
1034  $this->lastError = $thumb->toText();
1035  // Ignore errors if requested
1036  if ( $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
1037  $thumb = $handler->getTransform( $this, $tmpThumbPath, $thumbUrl, $params );
1038  }
1039  } elseif ( $this->repo && $thumb->hasFile() && !$thumb->fileIsSource() ) {
1040  // Copy the thumbnail from the file system into storage...
1041  $disposition = $this->getThumbDisposition( $thumbName );
1042  $status = $this->repo->quickImport( $tmpThumbPath, $thumbPath, $disposition );
1043  if ( $status->isOK() ) {
1044  $thumb->setStoragePath( $thumbPath );
1045  } else {
1046  $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
1047  }
1048  // Give extensions a chance to do something with this thumbnail...
1049  wfRunHooks( 'FileTransformed', array( $this, $thumb, $tmpThumbPath, $thumbPath ) );
1050  }
1051 
1052  // Purge. Useful in the event of Core -> Squid connection failure or squid
1053  // purge collisions from elsewhere during failure. Don't keep triggering for
1054  // "thumbs" which have the main image URL though (bug 13776)
1055  if ( $wgUseSquid ) {
1056  if ( !$thumb || $thumb->isError() || $thumb->getUrl() != $this->getURL() ) {
1057  SquidUpdate::purge( array( $thumbUrl ) );
1058  }
1059  }
1060  } while ( false );
1061 
1062  wfProfileOut( __METHOD__ );
1063 
1064  return is_object( $thumb ) ? $thumb : false;
1065  }
1066 
1072  function getThumbDisposition( $thumbName, $dispositionType = 'inline' ) {
1073  $fileName = $this->name; // file name to suggest
1074  $thumbExt = FileBackend::extensionFromPath( $thumbName );
1075  if ( $thumbExt != '' && $thumbExt !== $this->getExtension() ) {
1076  $fileName .= ".$thumbExt";
1077  }
1079  return FileBackend::makeContentDisposition( $dispositionType, $fileName );
1080  }
1081 
1087  function migrateThumbFile( $thumbName ) {
1088  }
1089 
1096  function getHandler() {
1097  if ( !isset( $this->handler ) ) {
1098  $this->handler = MediaHandler::getHandler( $this->getMimeType() );
1099  }
1100 
1101  return $this->handler;
1102  }
1103 
1109  function iconThumb() {
1110  global $wgStylePath, $wgStyleDirectory;
1111 
1112  $try = array( 'fileicon-' . $this->getExtension() . '.png', 'fileicon.png' );
1113  foreach ( $try as $icon ) {
1114  $path = '/common/images/icons/' . $icon;
1115  $filepath = $wgStyleDirectory . $path;
1116  if ( file_exists( $filepath ) ) { // always FS
1117  $params = array( 'width' => 120, 'height' => 120 );
1118 
1119  return new ThumbnailImage( $this, $wgStylePath . $path, false, $params );
1120  }
1121  }
1123  return null;
1124  }
1125 
1130  function getLastError() {
1131  return $this->lastError;
1132  }
1140  function getThumbnails() {
1141  return array();
1142  }
1143 
1151  function purgeCache( $options = array() ) {
1152  }
1159  function purgeDescription() {
1160  $title = $this->getTitle();
1161  if ( $title ) {
1163  $title->purgeSquid();
1164  }
1165  }
1166 
1171  function purgeEverything() {
1172  // Delete thumbnails and refresh file metadata cache
1173  $this->purgeCache();
1174  $this->purgeDescription();
1175 
1176  // Purge cache of all pages using this file
1177  $title = $this->getTitle();
1178  if ( $title ) {
1179  $update = new HTMLCacheUpdate( $title, 'imagelinks' );
1180  $update->doUpdate();
1181  }
1182  }
1183 
1195  function getHistory( $limit = null, $start = null, $end = null, $inc = true ) {
1196  return array();
1197  }
1198 
1208  public function nextHistoryLine() {
1209  return false;
1210  }
1211 
1218  public function resetHistory() {
1219  }
1220 
1228  function getHashPath() {
1229  if ( !isset( $this->hashPath ) ) {
1230  $this->assertRepoDefined();
1231  $this->hashPath = $this->repo->getHashPath( $this->getName() );
1232  }
1233 
1234  return $this->hashPath;
1235  }
1243  function getRel() {
1244  return $this->getHashPath() . $this->getName();
1245  }
1246 
1254  function getArchiveRel( $suffix = false ) {
1255  $path = 'archive/' . $this->getHashPath();
1256  if ( $suffix === false ) {
1257  $path = substr( $path, 0, -1 );
1258  } else {
1259  $path .= $suffix;
1260  }
1261 
1262  return $path;
1263  }
1264 
1272  function getThumbRel( $suffix = false ) {
1273  $path = $this->getRel();
1274  if ( $suffix !== false ) {
1275  $path .= '/' . $suffix;
1276  }
1277 
1278  return $path;
1279  }
1280 
1287  function getUrlRel() {
1288  return $this->getHashPath() . rawurlencode( $this->getName() );
1289  }
1290 
1299  function getArchiveThumbRel( $archiveName, $suffix = false ) {
1300  $path = 'archive/' . $this->getHashPath() . $archiveName . "/";
1301  if ( $suffix === false ) {
1302  $path = substr( $path, 0, -1 );
1303  } else {
1304  $path .= $suffix;
1305  }
1306 
1307  return $path;
1308  }
1309 
1316  function getArchivePath( $suffix = false ) {
1317  $this->assertRepoDefined();
1318 
1319  return $this->repo->getZonePath( 'public' ) . '/' . $this->getArchiveRel( $suffix );
1320  }
1321 
1329  function getArchiveThumbPath( $archiveName, $suffix = false ) {
1330  $this->assertRepoDefined();
1331 
1332  return $this->repo->getZonePath( 'thumb' ) . '/' .
1333  $this->getArchiveThumbRel( $archiveName, $suffix );
1334  }
1335 
1342  function getThumbPath( $suffix = false ) {
1343  $this->assertRepoDefined();
1344 
1345  return $this->repo->getZonePath( 'thumb' ) . '/' . $this->getThumbRel( $suffix );
1346  }
1347 
1354  function getTranscodedPath( $suffix = false ) {
1355  $this->assertRepoDefined();
1356 
1357  return $this->repo->getZonePath( 'transcoded' ) . '/' . $this->getThumbRel( $suffix );
1358  }
1359 
1366  function getArchiveUrl( $suffix = false ) {
1367  $this->assertRepoDefined();
1368  $ext = $this->getExtension();
1369  $path = $this->repo->getZoneUrl( 'public', $ext ) . '/archive/' . $this->getHashPath();
1370  if ( $suffix === false ) {
1371  $path = substr( $path, 0, -1 );
1372  } else {
1373  $path .= rawurlencode( $suffix );
1374  }
1375 
1376  return $path;
1377  }
1378 
1386  function getArchiveThumbUrl( $archiveName, $suffix = false ) {
1387  $this->assertRepoDefined();
1388  $ext = $this->getExtension();
1389  $path = $this->repo->getZoneUrl( 'thumb', $ext ) . '/archive/' .
1390  $this->getHashPath() . rawurlencode( $archiveName ) . "/";
1391  if ( $suffix === false ) {
1392  $path = substr( $path, 0, -1 );
1393  } else {
1394  $path .= rawurlencode( $suffix );
1395  }
1396 
1397  return $path;
1398  }
1399 
1407  function getZoneUrl( $zone, $suffix = false ) {
1408  $this->assertRepoDefined();
1409  $ext = $this->getExtension();
1410  $path = $this->repo->getZoneUrl( $zone, $ext ) . '/' . $this->getUrlRel();
1411  if ( $suffix !== false ) {
1412  $path .= '/' . rawurlencode( $suffix );
1413  }
1414 
1415  return $path;
1416  }
1417 
1424  function getThumbUrl( $suffix = false ) {
1425  return $this->getZoneUrl( 'thumb', $suffix );
1426  }
1427 
1434  function getTranscodedUrl( $suffix = false ) {
1435  return $this->getZoneUrl( 'transcoded', $suffix );
1436  }
1437 
1444  function getVirtualUrl( $suffix = false ) {
1445  $this->assertRepoDefined();
1446  $path = $this->repo->getVirtualUrl() . '/public/' . $this->getUrlRel();
1447  if ( $suffix !== false ) {
1448  $path .= '/' . rawurlencode( $suffix );
1449  }
1450 
1451  return $path;
1452  }
1453 
1460  function getArchiveVirtualUrl( $suffix = false ) {
1461  $this->assertRepoDefined();
1462  $path = $this->repo->getVirtualUrl() . '/public/archive/' . $this->getHashPath();
1463  if ( $suffix === false ) {
1464  $path = substr( $path, 0, -1 );
1465  } else {
1466  $path .= rawurlencode( $suffix );
1467  }
1468 
1469  return $path;
1470  }
1471 
1478  function getThumbVirtualUrl( $suffix = false ) {
1479  $this->assertRepoDefined();
1480  $path = $this->repo->getVirtualUrl() . '/thumb/' . $this->getUrlRel();
1481  if ( $suffix !== false ) {
1482  $path .= '/' . rawurlencode( $suffix );
1483  }
1484 
1485  return $path;
1486  }
1487 
1491  function isHashed() {
1492  $this->assertRepoDefined();
1493 
1494  return (bool)$this->repo->getHashLevels();
1495  }
1496 
1500  function readOnlyError() {
1501  throw new MWException( get_class( $this ) . ': write operations are not supported' );
1502  }
1503 
1519  function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '',
1520  $watch = false, $timestamp = false, User $user = null
1521  ) {
1522  $this->readOnlyError();
1523  }
1524 
1546  function publish( $srcPath, $flags = 0, array $options = array() ) {
1547  $this->readOnlyError();
1548  }
1549 
1553  function formatMetadata() {
1554  if ( !$this->getHandler() ) {
1555  return false;
1556  }
1558  return $this->getHandler()->formatMetadata( $this, $this->getMetadata() );
1559  }
1560 
1566  function isLocal() {
1567  return $this->repo && $this->repo->isLocal();
1568  }
1569 
1575  function getRepoName() {
1576  return $this->repo ? $this->repo->getName() : 'unknown';
1577  }
1578 
1584  function getRepo() {
1585  return $this->repo;
1586  }
1594  function isOld() {
1595  return false;
1596  }
1597 
1605  function isDeleted( $field ) {
1606  return false;
1607  }
1608 
1614  function getVisibility() {
1615  return 0;
1616  }
1617 
1623  function wasDeleted() {
1624  $title = $this->getTitle();
1625 
1626  return $title && $title->isDeletedQuick();
1627  }
1628 
1641  function move( $target ) {
1642  $this->readOnlyError();
1643  }
1644 
1659  function delete( $reason, $suppress = false ) {
1660  $this->readOnlyError();
1661  }
1662 
1677  function restore( $versions = array(), $unsuppress = false ) {
1678  $this->readOnlyError();
1679  }
1688  function isMultipage() {
1689  return $this->getHandler() && $this->handler->isMultiPage( $this );
1690  }
1691 
1698  function pageCount() {
1699  if ( !isset( $this->pageCount ) ) {
1700  if ( $this->getHandler() && $this->handler->isMultiPage( $this ) ) {
1701  $this->pageCount = $this->handler->pageCount( $this );
1702  } else {
1703  $this->pageCount = false;
1704  }
1705  }
1706 
1707  return $this->pageCount;
1708  }
1709 
1719  static function scaleHeight( $srcWidth, $srcHeight, $dstWidth ) {
1720  // Exact integer multiply followed by division
1721  if ( $srcWidth == 0 ) {
1722  return 0;
1723  } else {
1724  return round( $srcHeight * $dstWidth / $srcWidth );
1725  }
1726  }
1727 
1735  function getImageSize( $fileName ) {
1736  if ( !$this->getHandler() ) {
1737  return false;
1738  }
1739 
1740  return $this->handler->getImageSize( $this, $fileName );
1741  }
1742 
1749  function getDescriptionUrl() {
1750  if ( $this->repo ) {
1751  return $this->repo->getDescriptionUrl( $this->getName() );
1752  } else {
1753  return false;
1754  }
1755  }
1756 
1763  function getDescriptionText( $lang = false ) {
1765  if ( !$this->repo || !$this->repo->fetchDescription ) {
1766  return false;
1767  }
1768  if ( !$lang ) {
1769  $lang = $wgLang;
1770  }
1771  $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() );
1772  if ( $renderUrl ) {
1773  if ( $this->repo->descriptionCacheExpiry > 0 ) {
1774  wfDebug( "Attempting to get the description from cache..." );
1775  $key = $this->repo->getLocalCacheKey(
1776  'RemoteFileDescription',
1777  'url',
1778  $lang->getCode(),
1779  $this->getName()
1780  );
1781  $obj = $wgMemc->get( $key );
1782  if ( $obj ) {
1783  wfDebug( "success!\n" );
1784 
1785  return $obj;
1786  }
1787  wfDebug( "miss\n" );
1788  }
1789  wfDebug( "Fetching shared description from $renderUrl\n" );
1790  $res = Http::get( $renderUrl );
1791  if ( $res && $this->repo->descriptionCacheExpiry > 0 ) {
1792  $wgMemc->set( $key, $res, $this->repo->descriptionCacheExpiry );
1793  }
1794 
1795  return $res;
1796  } else {
1797  return false;
1798  }
1799  }
1800 
1813  function getDescription( $audience = self::FOR_PUBLIC, User $user = null ) {
1814  return null;
1815  }
1816 
1822  function getTimestamp() {
1823  $this->assertRepoDefined();
1824 
1825  return $this->repo->getFileTimestamp( $this->getPath() );
1826  }
1827 
1833  function getSha1() {
1834  $this->assertRepoDefined();
1835 
1836  return $this->repo->getFileSha1( $this->getPath() );
1837  }
1838 
1844  function getStorageKey() {
1845  $hash = $this->getSha1();
1846  if ( !$hash ) {
1847  return false;
1848  }
1849  $ext = $this->getExtension();
1850  $dotExt = $ext === '' ? '' : ".$ext";
1851 
1852  return $hash . $dotExt;
1853  }
1854 
1863  function userCan( $field, User $user = null ) {
1864  return true;
1865  }
1866 
1877  static function getPropsFromPath( $path, $ext = true ) {
1878  wfDebug( __METHOD__ . ": Getting file info for $path\n" );
1879  wfDeprecated( __METHOD__, '1.19' );
1880 
1881  $fsFile = new FSFile( $path );
1882 
1883  return $fsFile->getProps();
1884  }
1885 
1897  static function sha1Base36( $path ) {
1898  wfDeprecated( __METHOD__, '1.19' );
1899 
1900  $fsFile = new FSFile( $path );
1901 
1903  }
1904 
1908  function getStreamHeaders() {
1909  $handler = $this->getHandler();
1910  if ( $handler ) {
1911  return $handler->getStreamHeaders( $this->getMetadata() );
1912  } else {
1913  return array();
1914  }
1915  }
1916 
1920  function getLongDesc() {
1921  $handler = $this->getHandler();
1922  if ( $handler ) {
1923  return $handler->getLongDesc( $this );
1924  } else {
1925  return MediaHandler::getGeneralLongDesc( $this );
1926  }
1927  }
1928 
1932  function getShortDesc() {
1933  $handler = $this->getHandler();
1934  if ( $handler ) {
1935  return $handler->getShortDesc( $this );
1936  } else {
1937  return MediaHandler::getGeneralShortDesc( $this );
1938  }
1939  }
1940 
1944  function getDimensionsString() {
1945  $handler = $this->getHandler();
1946  if ( $handler ) {
1947  return $handler->getDimensionsString( $this );
1948  } else {
1949  return '';
1950  }
1951  }
1952 
1956  function getRedirected() {
1957  return $this->redirected;
1958  }
1959 
1963  function getRedirectedTitle() {
1964  if ( $this->redirected ) {
1965  if ( !$this->redirectTitle ) {
1966  $this->redirectTitle = Title::makeTitle( NS_FILE, $this->redirected );
1967  }
1969  return $this->redirectTitle;
1970  }
1971 
1972  return null;
1973  }
1974 
1979  function redirectedFrom( $from ) {
1980  $this->redirected = $from;
1981  }
1982 
1986  function isMissing() {
1987  return false;
1988  }
1989 
1994  public function isCacheable() {
1995  return true;
1996  }
1997 
2002  protected function assertRepoDefined() {
2003  if ( !( $this->repo instanceof $this->repoClass ) ) {
2004  throw new MWException( "A {$this->repoClass} object is not set for this File.\n" );
2005  }
2006  }
2007 
2012  protected function assertTitleDefined() {
2013  if ( !( $this->title instanceof Title ) ) {
2014  throw new MWException( "A Title object is not set for this File.\n" );
2015  }
2016  }
2017 }
File\getExtension
getExtension()
Get the file extension, e.g.
Definition: File.php:287
File\THUMB_FULL_NAME
const THUMB_FULL_NAME
Definition: File.php:73
File\wasDeleted
wasDeleted()
Was this file ever deleted from the wiki?
Definition: File.php:1605
File\redirectedFrom
redirectedFrom( $from)
Definition: File.php:1961
File\getPath
getPath()
Return the storage path to the file.
Definition: File.php:383
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
MediaTransformError
Basic media transform error class.
Definition: MediaTransformOutput.php:409
ThumbnailImage
Media transform output for images.
Definition: MediaTransformOutput.php:250
File\checkExtensionCompatibility
static checkExtensionCompatibility(File $old, $new)
Checks if file extensions are compatible.
Definition: File.php:225
File\$repo
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
Definition: File.php:94
MediaHandler\getCommonMetaArray
getCommonMetaArray(File $file)
Get an array of standard (FormatMetadata type) metadata values.
Definition: MediaHandler.php:232
File\canAnimateThumbIfAppropriate
canAnimateThumbIfAppropriate()
Will the thumbnail be animated if one would expect it to be.
Definition: File.php:526
MediaHandler\normaliseParams
normaliseParams( $image, &$params)
Changes the parameter array as necessary, ready for transformation.
PROTO_CANONICAL
const PROTO_CANONICAL
Definition: Defines.php:271
File\getArchiveThumbPath
getArchiveThumbPath( $archiveName, $suffix=false)
Get the path of an archived file's thumbs, or a particular thumb if $suffix is specified.
Definition: File.php:1311
File\getHeight
getHeight( $page=1)
Return the height of the image.
Definition: File.php:437
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
File\DELETED_USER
const DELETED_USER
Definition: File.php:54
File\getBitDepth
getBitDepth()
Return the bit depth of the file Overridden by LocalFile STUB.
Definition: File.php:602
$mime
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string $mime
Definition: hooks.txt:2573
File\getUrlRel
getUrlRel()
Get urlencoded path of the file relative to the public zone root.
Definition: File.php:1269
File\migrateThumbFile
migrateThumbFile( $thumbName)
Hook into transform() to allow migration of thumbnail files STUB Overridden by LocalFile.
Definition: File.php:1069
File\isMultipage
isMultipage()
Returns 'true' if this file is a type which supports multiple pages, e.g.
Definition: File.php:1670
File\getFullUrl
getFullUrl()
Return a fully-qualified URL to the file.
Definition: File.php:341
File\purgeCache
purgeCache( $options=array())
Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile.
Definition: File.php:1133
File\getZoneUrl
getZoneUrl( $zone, $suffix=false)
Get the URL of the zone directory, or a particular file if $suffix is specified.
Definition: File.php:1389
File\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: File.php:55
File\getMetadata
getMetadata()
Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB.
Definition: File.php:555
File\RAW
const RAW
Definition: File.php:70
File\getStreamHeaders
getStreamHeaders()
Definition: File.php:1890
File\getIsSafeFileUncached
getIsSafeFileUncached()
Uncached accessor.
Definition: File.php:724
File\$transformScript
string $transformScript
URL of transformscript (for example thumb.php) *.
Definition: File.php:122
File\getRel
getRel()
Get the path of the file relative to the public zone root.
Definition: File.php:1225
$wgMemc
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
Definition: globals.txt:25
File\isMissing
isMissing()
Definition: File.php:1968
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
File\getOriginalTitle
getOriginalTitle()
Return the title used to find this file.
Definition: File.php:311
$timestamp
if( $limit) $timestamp
Definition: importImages.php:104
FSFile\getProps
getProps( $ext=true)
Get an associative array containing information about a file with the given storage path.
Definition: FSFile.php:104
File\$redirectTitle
Title $redirectTitle
Definition: File.php:124
MediaHandler\getShortDesc
getShortDesc( $file)
Used instead of getLongDesc if there is no handler registered for file.
Definition: MediaHandler.php:581
File\getLastError
getLastError()
Get last thumbnailing error.
Definition: File.php:1112
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
File\getTimestamp
getTimestamp()
Get the 14-character timestamp of the file upload.
Definition: File.php:1804
$n
$n
Definition: RandomTest.php:76
File\getSha1
getSha1()
Get the SHA-1 base 36 hash of the file.
Definition: File.php:1815
$ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1530
$from
$from
Definition: importImages.php:90
File\convertMetadataVersion
convertMetadataVersion( $metadata, $version)
get versioned metadata
Definition: File.php:583
File\getUser
getUser( $type='text')
Returns ID or name of user who uploaded the file STUB.
Definition: File.php:448
MEDIATYPE_UNKNOWN
const MEDIATYPE_UNKNOWN
Definition: Defines.php:123
File\$pageCount
string $pageCount
number of pages of a multipage document, or false for documents which aren't multipage documents
Definition: File.php:120
File\RENDER_FORCE
const RENDER_FORCE
Force rendering even if thumbnail already exist and using RENDER_NOW I.e.
Definition: File.php:63
File\getUrl
getUrl()
Return the URL of the file.
Definition: File.php:324
NS_FILE
const NS_FILE
Definition: Defines.php:85
File\compare
static compare(File $a, File $b)
Callback for usort() to do file sorts by name.
Definition: File.php:264
$params
$params
Definition: styleTest.css.php:40
File\getTranscodedUrl
getTranscodedUrl( $suffix=false)
Get the URL of the transcoded directory, or a particular file if $suffix is specified.
Definition: File.php:1416
$limit
if( $sleep) $limit
Definition: importImages.php:99
File\getWidth
getWidth( $page=1)
Return the width of the image.
Definition: File.php:423
File\recordUpload
recordUpload( $oldver, $desc, $license='', $copyStatus='', $source='', $watch=false, $timestamp=false, User $user=null)
Record a file upload in the upload log and the image table STUB Overridden by LocalFile.
Definition: File.php:1501
File\getMediaType
getMediaType()
Return the type of the media in the file.
Definition: File.php:634
File\getCanonicalUrl
getCanonicalUrl()
Definition: File.php:348
File\splitMime
static splitMime( $mime)
Split an internet media type into its two components; if not a two-part name, set the minor type to '...
Definition: File.php:249
File\isVisible
isVisible()
Returns true if file exists in the repository and can be included in a page.
Definition: File.php:791
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2113
MediaHandler\getLongDesc
getLongDesc( $file)
Short description.
Definition: MediaHandler.php:593
File\$repoClass
string $repoClass
Required Repository class type *.
Definition: File.php:132
File\getArchiveRel
getArchiveRel( $suffix=false)
Get the path of an archived file relative to the public zone root.
Definition: File.php:1236
File\isDeleted
isDeleted( $field)
Is this file a "deleted" file in a private archive? STUB.
Definition: File.php:1587
File\getVisibility
getVisibility()
Return the deletion bitfield STUB.
Definition: File.php:1596
File\getDescriptionText
getDescriptionText( $lang=false)
Get the HTML text of the description page, if available.
Definition: File.php:1745
File\FOR_PUBLIC
const FOR_PUBLIC
Definition: File.php:68
File\normalizeTitle
static normalizeTitle( $title, $exception=false)
Given a string or Title object return either a valid Title object with namespace NS_FILE or null.
Definition: File.php:161
MediaHandler\getAvailableLanguages
getAvailableLanguages(File $file)
Get list of languages file can be viewed in.
Definition: MediaHandler.php:782
File\exists
exists()
Returns true if file exists in the repository.
Definition: File.php:781
File\getThumbVirtualUrl
getThumbVirtualUrl( $suffix=false)
Get the virtual URL for a thumbnail file or directory.
Definition: File.php:1460
File\upgradeRow
upgradeRow()
Upgrade the database row if there is one Called by ImagePage STUB.
Definition: File.php:239
FileRepo
Base class for file repositories.
Definition: FileRepo.php:37
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:459
File\$path
string $path
The storage path corresponding to one of the zones *.
Definition: File.php:114
title
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
Definition: All_system_messages.txt:2703
File\isCacheable
isCacheable()
Check if this file object is small and can be cached.
Definition: File.php:1976
File\normalizeExtension
static normalizeExtension( $ext)
Normalize a file extension to the common form, and ensure it's clean.
Definition: File.php:200
File\$canRender
bool $canRender
Wether the output of transform() for this file is likely to be valid.
Definition: File.php:126
File
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition: File.php:50
File\getMimeType
getMimeType()
Returns the mime type of the file.
Definition: File.php:623
File\getDefaultRenderLanguage
getDefaultRenderLanguage()
In files that support multiple language, what is the default language to use if none specified.
Definition: File.php:507
File\$url
string $url
The URL corresponding to one of the four basic zones *.
Definition: File.php:108
MWException
MediaWiki exception.
Definition: MWException.php:26
File\getLocalRefPath
getLocalRefPath()
Get an FS copy or original of this file and return the path.
Definition: File.php:399
File\DELETED_COMMENT
const DELETED_COMMENT
Definition: File.php:53
File\transformErrorOutput
transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags)
Return either a MediaTransformError or placeholder thumbnail (if $wgIgnoreImageErrors)
Definition: File.php:909
File\getIsSafeFile
getIsSafeFile()
Accessor for __get()
Definition: File.php:715
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1127
File\$redirectedTitle
Title $redirectedTitle
Definition: File.php:102
File\getThumbPath
getThumbPath( $suffix=false)
Get the path of the thumbnail directory, or a particular file if $suffix is specified.
Definition: File.php:1324
File\pageCount
pageCount()
Returns the number of pages of a multipage document, or false for documents which aren't multipage do...
Definition: File.php:1680
File\nextHistoryLine
nextHistoryLine()
Return the history of this file, line by line.
Definition: File.php:1190
File\getArchiveVirtualUrl
getArchiveVirtualUrl( $suffix=false)
Get the public zone virtual URL for an archived version source file.
Definition: File.php:1442
SquidUpdate\purge
static purge( $urlArr)
Purges a list of Squids defined in $wgSquidServers.
Definition: SquidUpdate.php:134
MediaHandler\canAnimateThumbnail
canAnimateThumbnail( $file)
If the material is animated, we can animate the thumbnail.
Definition: MediaHandler.php:384
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
wfMessage
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
File\formatMetadata
formatMetadata()
Definition: File.php:1535
File\getTransformScript
getTransformScript()
Definition: File.php:798
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4001
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
File\FOR_THIS_USER
const FOR_THIS_USER
Definition: File.php:69
File\getArchiveThumbRel
getArchiveThumbRel( $archiveName, $suffix=false)
Get the path, relative to the thumbnail zone root, for an archived file's thumbs directory or a speci...
Definition: File.php:1281
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
FSFile\getSha1Base36
getSha1Base36( $recache=false)
Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding,...
Definition: FSFile.php:201
File\getStorageKey
getStorageKey()
Get the deletion archive key, "<sha1>.<ext>".
Definition: File.php:1826
File\__construct
__construct( $title, $repo)
Call this constructor from child classes.
Definition: File.php:144
File\isHashed
isHashed()
Definition: File.php:1473
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:188
File\getCommonMetaArray
getCommonMetaArray()
Like getMetadata but returns a handler independent array of common values.
Definition: File.php:565
File\getThumbRel
getThumbRel( $suffix=false)
Get the path, relative to the thumbnail zone root, of the thumbnail directory or a particular file if...
Definition: File.php:1254
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1530
Http\get
static get( $url, $timeout='default', $options=array())
Simple wrapper for Http::request( 'GET' )
Definition: HttpFunctions.php:93
File\getUnscaledThumb
getUnscaledThumb( $handlerParams=array())
Get a ThumbnailImage which is the same size as the source.
Definition: File.php:819
MediaHandler\getDimensionsString
getDimensionsString( $file)
Shown in file history box on image description page.
Definition: MediaHandler.php:649
File\canRender
canRender()
Checks if the output of transform() for this file is likely to be valid.
Definition: File.php:650
File\$fsFile
FSFile bool $fsFile
False if undefined *.
Definition: File.php:104
File\getRedirectedTitle
getRedirectedTitle()
Definition: File.php:1945
MediaHandler\convertMetadataVersion
convertMetadataVersion( $metadata, $version=1)
Convert metadata version.
Definition: MediaHandler.php:162
MediaHandler\getGeneralShortDesc
static getGeneralShortDesc( $file)
Long description.
Definition: MediaHandler.php:606
wfDebug
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:933
HTMLCacheUpdate
Class to invalidate the HTML cache of all the pages linking to a given title.
Definition: HTMLCacheUpdate.php:29
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:422
File\getAvailableLanguages
getAvailableLanguages()
Gives a (possibly empty) list of languages to render the file in.
Definition: File.php:491
File\iconThumb
iconThumb()
Get a ThumbnailImage representing a file type icon.
Definition: File.php:1091
File\purgeDescription
purgeDescription()
Purge the file description page, but don't go after pages using the file.
Definition: File.php:1141
TempFSFile\factory
static factory( $prefix, $extension='')
Make a new temporary file on the file system.
Definition: TempFSFile.php:44
File\isOld
isOld()
Returns true if the image is an old version STUB.
Definition: File.php:1576
File\$handler
MediaHandler $handler
Definition: File.php:106
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:67
File\assertTitleDefined
assertTitleDefined()
Assert that $this->title is set to a Title.
Definition: File.php:1994
MediaHandler\getTransform
getTransform( $image, $dstPath, $dstUrl, $params)
Get a MediaTransformOutput object representing the transformed output.
Definition: MediaHandler.php:262
File\getHistory
getHistory( $limit=null, $start=null, $end=null, $inc=true)
Return a fragment of the history of file.
Definition: File.php:1177
File\generateThumbName
generateThumbName( $name, $params)
Generate a thumbnail file name from a name and specified parameters.
Definition: File.php:855
File\createThumb
createThumb( $width, $height=-1)
Create a thumbnail of the image having the specified width/height.
Definition: File.php:887
File\$title
Title string bool $title
Definition: File.php:96
$handlerParams
see documentation in includes Linker php for Linker::makeImageLink & $handlerParams
Definition: hooks.txt:1356
File\getDescriptionUrl
getDescriptionUrl()
Get the URL of the image description page.
Definition: File.php:1731
$version
$version
Definition: parserTests.php:86
PROTO_RELATIVE
const PROTO_RELATIVE
Definition: Defines.php:269
File\getArchiveThumbUrl
getArchiveThumbUrl( $archiveName, $suffix=false)
Get the URL of the archived file's thumbs, or a particular thumb if $suffix is specified.
Definition: File.php:1368
File\getName
getName()
Return the name of this file.
Definition: File.php:273
File\getArchiveUrl
getArchiveUrl( $suffix=false)
Get the URL of the archive directory, or a particular file if $suffix is specified.
Definition: File.php:1348
File\getThumbDisposition
getThumbDisposition( $thumbName, $dispositionType='inline')
Definition: File.php:1054
File\publish
publish( $srcPath, $flags=0, array $options=array())
Move or copy a file to its public location.
Definition: File.php:1528
MediaHandler\getStreamHeaders
getStreamHeaders( $metadata)
Get useful response headers for GET/HEAD requests for a file with the given metadata.
Definition: MediaHandler.php:310
FSFile
Class representing a non-directory file on the file system.
Definition: FSFile.php:29
MediaHandler\doTransform
doTransform( $image, $dstPath, $dstUrl, $params, $flags=0)
Get a MediaTransformOutput object representing the transformed output.
File\isSafeFile
isSafeFile()
Determines if this media file is in a format that is unlikely to contain viruses or malicious content...
Definition: File.php:702
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
File\getRepoName
getRepoName()
Returns the name of the repository.
Definition: File.php:1557
File\DELETE_SOURCE
const DELETE_SOURCE
Definition: File.php:65
File\$extension
string $extension
File extension *.
Definition: File.php:110
$hash
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
Definition: hooks.txt:2697
File\$hashPath
string $hashPath
Relative path including trailing slash *.
Definition: File.php:116
File\scaleHeight
static scaleHeight( $srcWidth, $srcHeight, $dstWidth)
Calculate the height of a thumbnail using the source and destination width.
Definition: File.php:1701
File\RENDER_NOW
const RENDER_NOW
Force rendering in the current process.
Definition: File.php:58
File\transform
transform( $params, $flags=0)
Transform a media file.
Definition: File.php:929
File\getTitle
getTitle()
Return the associated title object.
Definition: File.php:302
File\readOnlyError
readOnlyError()
Definition: File.php:1482
Title
Represents a title within MediaWiki.
Definition: Title.php:35
$wgLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition: design.txt:56
File\restore
restore( $versions=array(), $unsuppress=false)
Restore all or specified deleted revisions to the given file.
Definition: File.php:1659
ForeignAPIRepo
A foreign repository with a remote MediaWiki with an API thingy.
Definition: ForeignAPIRepo.php:39
File\$isSafeFile
bool $isSafeFile
Wether this media file is in a format that is unlikely to contain viruses or malicious content.
Definition: File.php:130
type
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
Definition: postgres.txt:22
File\move
move( $target)
Move file to the new title.
Definition: File.php:1623
File\assertRepoDefined
assertRepoDefined()
Assert that $this->repo is set to a valid FileRepo instance.
Definition: File.php:1984
$ext
$ext
Definition: NoLocalSettings.php:34
FileBackend\extensionFromPath
static extensionFromPath( $path)
Get the final extension from a storage or FS path.
Definition: FileBackend.php:1400
File\getShortDesc
getShortDesc()
Definition: File.php:1914
File\getDescription
getDescription( $audience=self::FOR_PUBLIC, User $user=null)
Get description of file revision STUB.
Definition: File.php:1795
File\getLength
getLength()
Get the duration of a media file in seconds.
Definition: File.php:457
File\getLongDesc
getLongDesc()
Definition: File.php:1902
File\isLocal
isLocal()
Returns true if the file comes from the local file repository.
Definition: File.php:1548
Title\purgeSquid
purgeSquid()
Purge all applicable Squid URLs.
Definition: Title.php:3531
MediaHandler\getHandler
static getHandler( $type)
Get a MediaHandler for a given MIME type from the instance cache.
Definition: MediaHandler.php:48
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
File\sha1Base36
static sha1Base36( $path)
Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding,...
Definition: File.php:1879
File\getImageSize
getImageSize( $fileName)
Get an image size array like that returned by getImageSize(), or false if it can't be determined.
Definition: File.php:1717
File\getCanRender
getCanRender()
Accessor for __get()
Definition: File.php:662
MediaHandler\isAnimatedImage
isAnimatedImage( $file)
The material is an image, and is animated.
Definition: MediaHandler.php:373
$source
if(PHP_SAPI !='cli') $source
Definition: mwdoc-filter.php:18
MediaHandler\isVectorized
isVectorized( $file)
The material is vectorized and thus scaling is lossless.
Definition: MediaHandler.php:361
File\mustRender
mustRender()
Return true if the file is of a type that can't be directly rendered by typical browsers and needs to...
Definition: File.php:676
Title\isDeletedQuick
isDeletedQuick()
Is there a version of this page in the deletion archive?
Definition: Title.php:3095
File\resetHistory
resetHistory()
Reset the history pointer to the first element of the history.
Definition: File.php:1200
MediaHandler\getScriptedTransform
getScriptedTransform( $image, $script, $params)
Get a MediaTransformOutput object representing an alternate of the transformed output which will call...
Definition: MediaHandler.php:248
File\getRedirected
getRedirected()
Definition: File.php:1938
File\$name
string $name
The name of a file from its title object *.
Definition: File.php:112
File\DELETED_FILE
const DELETED_FILE
Definition: File.php:52
name
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
Definition: design.txt:12
MediaHandler\getGeneralLongDesc
static getGeneralLongDesc( $file)
Used instead of getShortDesc if there is no handler registered for file.
Definition: MediaHandler.php:618
File\getRepo
getRepo()
Returns the repository.
Definition: File.php:1566
File\allowInlineDisplay
allowInlineDisplay()
Alias for canRender()
Definition: File.php:685
File\getThumbUrl
getThumbUrl( $suffix=false)
Get the URL of the thumbnail directory, or a particular file if $suffix is specified.
Definition: File.php:1406
File\isVectorized
isVectorized()
Return true if the file is vectorized.
Definition: File.php:471
File\getDimensionsString
getDimensionsString()
Definition: File.php:1926
File\getHandler
getHandler()
Get a MediaHandler instance for this file.
Definition: File.php:1078
File\__get
__get( $name)
Definition: File.php:182
File\userCan
userCan( $field, User $user=null)
Determine if the current user is allowed to view a particular field of this file, if it's marked as d...
Definition: File.php:1845
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:59
File\thumbName
thumbName( $params, $flags=0)
Return the file name of a thumbnail with the specified parameters.
Definition: File.php:840
File\$lastError
string $lastError
Text of last error *.
Definition: File.php:98
File\$redirected
string $redirected
Main part of the title, with underscores (Title::getDBkey) *.
Definition: File.php:100
Title\invalidateCache
invalidateCache()
Updates page_touched for this page; called from LinksUpdate.php.
Definition: Title.php:4630
File\getPropsFromPath
static getPropsFromPath( $path, $ext=true)
Get an associative array containing information about a file in the local filesystem.
Definition: File.php:1859
$res
$res
Definition: database.txt:21
File\getArchivePath
getArchivePath( $suffix=false)
Get the path of the archived file.
Definition: File.php:1298
File\purgeEverything
purgeEverything()
Purge metadata and all affected pages when the file is created, deleted, or majorly updated.
Definition: File.php:1153
File\getHashPath
getHashPath()
Get the filename hash component of the directory including trailing slash, e.g.
Definition: File.php:1210
File\isTrustedFile
isTrustedFile()
Returns true if the file is flagged as trusted.
Definition: File.php:768
LocalRepo
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Definition: LocalRepo.php:31
File\getSize
getSize()
Return the size of the image file, in bytes Overridden by LocalFile, UnregisteredLocalFile STUB.
Definition: File.php:612
MediaHandler
Base media handler class.
Definition: MediaHandler.php:29
MediaHandler\getLength
getLength( $file)
If its an audio file, return the length of the file.
Definition: MediaHandler.php:812
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:497
File\getThumbnails
getThumbnails()
Get all thumbnail names previously generated for this file STUB Overridden by LocalFile.
Definition: File.php:1122
MediaHandler\getDefaultRenderLanguage
getDefaultRenderLanguage(File $file)
On file types that support renderings in multiple languages, which language is used by default if uns...
Definition: MediaHandler.php:798
$license
$license
Definition: importImages.php:123
File\getTranscodedPath
getTranscodedPath( $suffix=false)
Get the path of the transcoded directory, or a particular file if $suffix is specified.
Definition: File.php:1336
File\getViewURL
getViewURL()
Definition: File.php:355
File\getVirtualUrl
getVirtualUrl( $suffix=false)
Get the public zone virtual URL for a current version source file.
Definition: File.php:1426
$type
$type
Definition: testCompression.php:46
FileBackend\makeContentDisposition
static makeContentDisposition( $type, $filename='')
Build a Content-Disposition header value per RFC 6266.
Definition: FileBackend.php:1426