Diff -- /var/www/vhosts/3dshawn.com/affiliate.3dshawn.com/MODS/AffSoft/EmailAdminTabs.pm
Diff

/var/www/vhosts/3dshawn.com/affiliate.3dshawn.com/MODS/AffSoft/EmailAdminTabs.pm

added on local at 2026-07-01 13:47:28

Added
+60
lines
Removed
-0
lines
Context
0
unchanged
Blobs
from
to 0ebb007e7358
Restore this content →
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.
1package MODS::AffSoft::EmailAdminTabs;
2#======================================================================
3# AffSoft -- shared tab strip for the Email Setup admin section.
4#
5# Refactored out of admin_emails.cgi / admin_email_schedules.cgi /
6# admin_email_controls.cgi (which each had an identical _email_setup_tabs
7# helper inlined) so adding a tab now touches one file instead of four.
8# admin_email_announcements.cgi joins the same strip.
9#
10# Usage:
11# use MODS::AffSoft::EmailAdminTabs;
12# my $tabs_html = MODS::AffSoft::EmailAdminTabs->render('templates');
13#======================================================================
14use strict;
15use warnings;
16
17sub new { return bless({}, $_[0]); }
18
19# Order is significant -- this is what users read left-to-right.
20my @ORDER = qw(templates schedules controls announcements);
21my %LABEL = (
22 templates => 'Templates',
23 schedules => 'Schedules',
24 controls => 'Controls',
25 announcements => 'Announcements',
26);
27my %HREF = (
28 templates => '/admin_emails.cgi',
29 schedules => '/admin_email_schedules.cgi',
30 controls => '/admin_email_controls.cgi',
31 announcements => '/admin_email_announcements.cgi',
32);
33
34# render($active_key) -> HTML string. Class-method OR plain function call
35# both work (so the existing CGIs can drop their helpers in place).
36sub render {
37 my ($maybe_class, $active) = @_;
38 # Allow MODS::AffSoft::EmailAdminTabs->render($active) AND
39 # MODS::AffSoft::EmailAdminTabs::render($active).
40 if (!defined $active && defined $maybe_class
41 && $maybe_class !~ /^(?:templates|schedules|controls|announcements)$/) {
42 $active = ''; # called as class method with no arg
43 } elsif (!defined $active) {
44 $active = $maybe_class;
45 }
46 $active = '' unless defined $active;
47
48 my $html = '<div style="display:flex;gap:0;border-bottom:1px solid rgba(255,255,255,.08);margin:0 0 22px">';
49 foreach my $k (@ORDER) {
50 my $is_active = ($k eq $active) ? 1 : 0;
51 my $color = $is_active ? '#5aa9ff' : '#94a3b8';
52 my $border = $is_active ? '#5aa9ff' : 'transparent';
53 my $weight = $is_active ? '600' : '500';
54 $html .= qq~<a href="$HREF{$k}" style="padding:10px 20px;color:$color;text-decoration:none;font-size:13px;border-bottom:2px solid $border;font-weight:$weight;letter-spacing:.02em">$LABEL{$k}</a>~;
55 }
56 $html .= '</div>';
57 return $html;
58}
59
601;
Keyboard: j next diff k previous diff g top G bottom r restore c compile-check ? help