provider.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @author Georg Ehrke <georg@owncloud.com>
  4. * @author Georg Ehrke <georg@ownCloud.com>
  5. * @author Joas Schilling <nickvergessen@owncloud.com>
  6. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  7. * @author Robin Appelman <icewind@owncloud.com>
  8. *
  9. * @copyright Copyright (c) 2015, ownCloud, Inc.
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OC\Preview;
  26. use OCP\Preview\IProvider;
  27. abstract class Provider implements IProvider {
  28. private $options;
  29. /**
  30. * Constructor
  31. *
  32. * @param array $options
  33. */
  34. public function __construct(array $options = []) {
  35. $this->options = $options;
  36. }
  37. /**
  38. * @return string Regex with the mimetypes that are supported by this provider
  39. */
  40. abstract public function getMimeType();
  41. /**
  42. * Check if a preview can be generated for $path
  43. *
  44. * @param \OCP\Files\FileInfo $file
  45. * @return bool
  46. */
  47. public function isAvailable(\OCP\Files\FileInfo $file) {
  48. return true;
  49. }
  50. /**
  51. * get thumbnail for file at path $path
  52. * @param string $path Path of file
  53. * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
  54. * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
  55. * @param bool $scalingup Disable/Enable upscaling of previews
  56. * @param \OC\Files\View $fileview fileview object of user folder
  57. * @return bool|\OCP\IImage false if no preview was generated
  58. */
  59. abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview);
  60. }