| 1 | ##@file | ||
| 2 | # Menu | ||
| 3 | |||
| 4 | ##@class | ||
| 5 | # Menu | ||
| 6 | # | ||
| 7 | # Display a menu on protected applications | ||
| 8 | package Lemonldap::NG::Handler::ApacheMP2::Menu; | ||
| 9 | |||
| 10 | use strict; | ||
| 11 | use base qw(Lemonldap::NG::Handler::ApacheMP2::Main); | ||
| 12 | use Apache2::Filter (); | ||
| 13 | use constant BUFF_LEN => 8192; | ||
| 14 | |||
| 15 | our $VERSION = '2.23.0'; | ||
| 16 | |||
| 17 | sub handler { | ||
| 18 | my $r = pop; | ||
| 19 | __PACKAGE__->run($r); | ||
| 20 | } | ||
| 21 | |||
| 22 | ## @rmethod Apache2::Const run(Apache2::Filter f) | ||
| 23 | # Overload main run method | ||
| 24 | # @param f Apache2 Filter | ||
| 25 | # @return Apache2::Const::OK | ||
| 26 | sub run { | ||
| 27 | my $class = shift; | ||
| 28 | my $f = $_[0]; | ||
| 29 | |||
| 30 | unless ( $f->ctx ) { | ||
| 31 | $f->r->headers_out->unset('Content-Length'); | ||
| 32 | $f->ctx(1); | ||
| 33 | } | ||
| 34 | |||
| 35 | # CSS parameters | ||
| 36 | my $background = "#ccc"; | ||
| 37 | my $border = "#aaa"; | ||
| 38 | my $width = "30%"; | ||
| 39 | my $marginleft = "35%"; | ||
| 40 | my $marginright = "35%"; | ||
| 41 | |||
| 42 | my $menudiv = qq( | ||
| 43 | <style> | ||
| 44 | #lemonldap-ng-menu { | ||
| 45 | background-color: $background; | ||
| 46 | border-color: $border; | ||
| 47 | border-width: 2px 2px 0 2px; | ||
| 48 | border-style: solid; | ||
| 49 | border-top-left-radius: 10px; | ||
| 50 | border-top-right-radius: 10px; | ||
| 51 | width: $width; | ||
| 52 | margin-right: $marginright; | ||
| 53 | margin-left: $marginleft; | ||
| 54 | position: absolute; | ||
| 55 | bottom: 0px; | ||
| 56 | text-align: center; | ||
| 57 | padding: 3px; | ||
| 58 | z-index: 2; | ||
| 59 | } | ||
| 60 | html>body #lemonldap-ng-menu { | ||
| 61 | position: fixed; | ||
| 62 | } | ||
| 63 | </style> | ||
| 64 | <div id="lemonldap-ng-menu"> | ||
| 65 | <a href=") . $class->tsv->{portal}->() . qq(">☖ Home</a> | ||
| 66 | <span> </span> | ||
| 67 | <a href=") . $class->tsv->{portal}->() . qq(?logout=1">☒ Logout</a> | ||
| 68 | </div>); | ||
| 69 | |||
| 70 | while ( $f->read( my $buffer, BUFF_LEN ) ) { | ||
| 71 | $buffer =~ s/<\/body>/$menudiv<\/body>/g; | ||
| 72 | $f->print($buffer); | ||
| 73 | } | ||
| 74 | |||
| 75 | return $class->OK; | ||
| 76 | |||
| 77 | } | ||
| 78 | |||
| 79 | 1; |