From e72e22b0addb3250868e689ff28260df752c844e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 21 Sep 2023 10:49:45 +0200 Subject: [PATCH] Bug 34478: op-cud - Add a script to rename op with op-cud in templates --- rename_op_with_op-cud.pl | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 rename_op_with_op-cud.pl diff --git a/rename_op_with_op-cud.pl b/rename_op_with_op-cud.pl new file mode 100644 index 00000000000..a80b9131ea2 --- /dev/null +++ b/rename_op_with_op-cud.pl @@ -0,0 +1,59 @@ +#!/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|inc)$] and -f $name; +} + +find({ wanted => \&wanted, no_chdir => 1 }, @themes ); + +rename_op($_) for @files; + +sub rename_op { + my ( $file ) = @_; + + my @lines = read_file($file); + my @errors; + return unless grep { $_ =~ m|