File: Menu.pm

package info (click to toggle)
lemonldap-ng 2.21.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 28,024 kB
  • sloc: perl: 77,414; javascript: 25,284; xml: 6,473; makefile: 1,303; sh: 453; sql: 159; python: 53; php: 26
file content (79 lines) | stat: -rw-r--r-- 1,630 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
##@file
# Menu

##@class
# Menu
#
# Display a menu on protected applications
package Lemonldap::NG::Handler::ApacheMP2::Menu;

use strict;
use base qw(Lemonldap::NG::Handler::ApacheMP2::Main);
use Apache2::Filter ();
use constant BUFF_LEN => 8192;

our $VERSION = '2.0.0';

sub handler {
    my $r = pop;
    __PACKAGE__->run($r);
}

## @rmethod Apache2::Const run(Apache2::Filter f)
# Overload main run method
# @param f Apache2 Filter
# @return Apache2::Const::OK
sub run {
    my $class = shift;
    my $f     = $_[0];

    unless ( $f->ctx ) {
        $f->r->headers_out->unset('Content-Length');
        $f->ctx(1);
    }

    # CSS parameters
    my $background  = "#ccc";
    my $border      = "#aaa";
    my $width       = "30%";
    my $marginleft  = "35%";
    my $marginright = "35%";

    my $menudiv = qq(
<style>
#lemonldap-ng-menu {
    background-color: $background;
    border-color: $border;
    border-width: 2px 2px 0 2px;
    border-style: solid;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    width: $width;
    margin-right: $marginright;
    margin-left: $marginleft;
    position: absolute;
    bottom: 0px;
    text-align: center;
    padding: 3px;
    z-index: 2;
}
html>body #lemonldap-ng-menu {
    position: fixed;
}
</style>
<div id="lemonldap-ng-menu">
<a href=") . $class->tsv->{portal}->() . qq(">☖ Home</a>
<span>  </span>
<a href=") . $class->tsv->{portal}->() . qq(?logout=1">☒ Logout</a>
</div>);

    while ( $f->read( my $buffer, BUFF_LEN ) ) {
        $buffer =~ s/<\/body>/$menudiv<\/body>/g;
        $f->print($buffer);
    }

    return $class->OK;

}

1;