+sub create_action_bar_actions {
+ my ($self, $variables) = @_;
+
+ my @actions;
+ foreach my $type (qw(pdf csv)) {
+ next unless $variables->{"ALLOW_" . uc($type) . "_EXPORT"};
+
+ my $key = $variables->{CONTROLLER_DISPATCH} ? 'action' : 'report_generator_dispatch_to';
+ my $value = "report_generator_export_as_${type}";
+ $value = $variables->{CONTROLLER_DISPATCH} . "/${value}" if $variables->{CONTROLLER_DISPATCH};
+
+ push @actions, action => [
+ $type eq 'pdf' ? $::locale->text('PDF export') : $::locale->text('CSV export'),
+ submit => [ '#report_generator_form', { $key => $value } ],
+ ];
+ }
+
+ if (scalar(@actions) > 1) {
+ @actions = (
+ combobox => [
+ action => [ $::locale->text('Export') ],
+ @actions,
+ ],
+ );
+ }
+
+ return @actions;
+}
+
+sub setup_action_bar {
+ my ($self, $variables, %params) = @_;
+
+ my @actions = $self->create_action_bar_actions($variables);
+
+ if ($params{action_bar_setup_hook}) {
+ $params{action_bar_setup_hook}->(@actions);
+
+ } elsif (@actions) {
+ my $action_bar = blessed($params{action_bar}) ? $params{action_bar} : ($::request->layout->get('actionbar'))[0];
+ $action_bar->add(@actions);
+ }
+}
+