Main Koha release repository https://koha-community.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

82 lines
2.1 KiB

  1. package Koha::Template::Plugin::Koha;
  2. # Copyright ByWater Solutions 2013
  3. # This file is part of Koha.
  4. #
  5. # Koha is free software; you can redistribute it and/or modify it
  6. # under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # Koha is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with Koha; if not, see <http://www.gnu.org/licenses>.
  17. use Modern::Perl;
  18. use base qw( Template::Plugin );
  19. use C4::Context;
  20. use Koha;
  21. =head1 NAME
  22. Koha::Template::Plugin::Koha - General Koha Template Toolkit plugin
  23. =head1 SYNOPSIS
  24. This plugin contains various Koha replated Template Toolkit functions
  25. to help streamline Koha and to move logic from the Perl code into the
  26. Templates when it makes sense to do so.
  27. To use, first, include the line '[% USE Koha %]' at the top
  28. of the template to enable the plugin.
  29. For example: [% IF Koha.Preference( 'MyPreference ) == 'SettingA' %]
  30. removes the necessity of setting a template variable in Perl code for
  31. each and every system preference, even if no evaluation of the setting
  32. is necessary.
  33. =cut
  34. =head1 API
  35. =head2 Class Methods
  36. =cut
  37. sub Preference {
  38. my ( $self, $pref ) = @_;
  39. return C4::Context->preference( $pref );
  40. }
  41. sub Version {
  42. my $version_string = Koha::version();
  43. my ( $major, $minor, $maintenance, $development ) = split( '\.', $version_string );
  44. return {
  45. major => $major,
  46. minor => $minor,
  47. release => $major . "." . $minor,
  48. maintenance => $major . "." . $minor . "." . $maintenance,
  49. development => ( $development ne '000' ) ? $development : undef,
  50. };
  51. }
  52. =head3 ArePluginsEnabled
  53. Returns true if plugins are enabled, false otherwise.
  54. =cut
  55. sub ArePluginsEnabled {
  56. return C4::Context->config('enable_plugins');
  57. }
  58. 1;