DjVuSupport.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. * http://www.gnu.org/copyleft/gpl.html
  17. *
  18. * @file
  19. * @ingroup Testing
  20. */
  21. /**
  22. * Initialize and detect the DjVu files support
  23. */
  24. class DjVuSupport {
  25. /**
  26. * Initialises DjVu tools global with default values
  27. */
  28. public function __construct() {
  29. global $wgDjvuRenderer, $wgDjvuDump, $wgDjvuToXML, $wgFileExtensions, $wgDjvuTxt;
  30. $wgDjvuRenderer = $wgDjvuRenderer ?: '/usr/bin/ddjvu';
  31. $wgDjvuDump = $wgDjvuDump ?: '/usr/bin/djvudump';
  32. $wgDjvuToXML = $wgDjvuToXML ?: '/usr/bin/djvutoxml';
  33. $wgDjvuTxt = $wgDjvuTxt ?: '/usr/bin/djvutxt';
  34. if ( !in_array( 'djvu', $wgFileExtensions ) ) {
  35. $wgFileExtensions[] = 'djvu';
  36. }
  37. }
  38. /**
  39. * Returns true if the DjVu tools are usable
  40. *
  41. * @return bool
  42. */
  43. public function isEnabled() {
  44. global $wgDjvuRenderer, $wgDjvuDump, $wgDjvuToXML, $wgDjvuTxt;
  45. return is_executable( $wgDjvuRenderer )
  46. && is_executable( $wgDjvuDump )
  47. && is_executable( $wgDjvuToXML )
  48. && is_executable( $wgDjvuTxt );
  49. }
  50. }