Image.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * Backwards compatibility class
  4. * @deprecated
  5. * @ingroup FileRepo
  6. */
  7. class Image extends LocalFile {
  8. function __construct( $title ) {
  9. wfDeprecated( __METHOD__ );
  10. $repo = RepoGroup::singleton()->getLocalRepo();
  11. parent::__construct( $title, $repo );
  12. }
  13. /**
  14. * Wrapper for wfFindFile(), for backwards-compatibility only
  15. * Do not use in core code.
  16. * @deprecated
  17. */
  18. static function newFromTitle( $title, $time = false ) {
  19. wfDeprecated( __METHOD__ );
  20. $img = wfFindFile( $title, $time );
  21. if ( !$img ) {
  22. $img = wfLocalFile( $title );
  23. }
  24. return $img;
  25. }
  26. /**
  27. * Wrapper for wfFindFile(), for backwards-compatibility only.
  28. * Do not use in core code.
  29. *
  30. * @param string $name name of the image, used to create a title object using Title::makeTitleSafe
  31. * @return image object or null if invalid title
  32. * @deprecated
  33. */
  34. static function newFromName( $name ) {
  35. wfDeprecated( __METHOD__ );
  36. $title = Title::makeTitleSafe( NS_FILE, $name );
  37. if ( is_object( $title ) ) {
  38. $img = wfFindFile( $title );
  39. if ( !$img ) {
  40. $img = wfLocalFile( $title );
  41. }
  42. return $img;
  43. } else {
  44. return NULL;
  45. }
  46. }
  47. /**
  48. * Return the URL of an image, provided its name.
  49. *
  50. * Backwards-compatibility for extensions.
  51. * Note that fromSharedDirectory will only use the shared path for files
  52. * that actually exist there now, and will return local paths otherwise.
  53. *
  54. * @param string $name Name of the image, without the leading "Image:"
  55. * @param boolean $fromSharedDirectory Should this be in $wgSharedUploadPath?
  56. * @return string URL of $name image
  57. * @deprecated
  58. */
  59. static function imageUrl( $name, $fromSharedDirectory = false ) {
  60. wfDeprecated( __METHOD__ );
  61. $image = null;
  62. if( $fromSharedDirectory ) {
  63. $image = wfFindFile( $name );
  64. }
  65. if( !$image ) {
  66. $image = wfLocalFile( $name );
  67. }
  68. return $image->getUrl();
  69. }
  70. }