From fc01e7a820129a0b5c6510fcdf2f71eca49f11d0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 21 Sep 2023 14:40:26 +0200 Subject: [PATCH] Bug 34862: [DO NOT PUSH] add script --- add_blocking_errors.pl | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 add_blocking_errors.pl diff --git a/add_blocking_errors.pl b/add_blocking_errors.pl new file mode 100644 index 00000000000..23ab8731146 --- /dev/null +++ b/add_blocking_errors.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl + +use Modern::Perl; +use File::Find; +use File::Slurp; +use Data::Dumper; + +my @themes; + +# OPAC themes +my $opac_dir = 'koha-tmpl/opac-tmpl'; +opendir ( my $dh, $opac_dir ) or die "can't opendir $opac_dir: $!"; +for my $theme ( grep { not /^\.|lib|js|xslt/ } readdir($dh) ) { + push @themes, "$opac_dir/$theme/en"; +} +close $dh; + +# STAFF themes +my $staff_dir = 'koha-tmpl/intranet-tmpl'; +opendir ( $dh, $staff_dir ) or die "can't opendir $staff_dir: $!"; +for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) { + push @themes, "$staff_dir/$theme/en"; +} +close $dh; + +my @files; +sub wanted { + my $name = $File::Find::name; + push @files, $name + if $name =~ m[\.(tt)$] and -f $name; +} + +find({ wanted => \&wanted, no_chdir => 1 }, @themes ); + +my @errors; +for my $file ( @files ) { + add_messages($file); +} + +sub add_messages { + my ( $file ) = @_; + + my $messages_include = "[% INCLUDE 'messages.inc' %]\n"; + my @lines = read_file($file); + my @new_lines = @lines; + my $has_main_tag = grep { $_ =~ m|