Provider.php 2.1 KB

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