Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 269
- Log:
Overdue upgrade to AWStats v6.9, the most recent version
available at the time of writing.
- Author:
- rool
- Date:
- Wed May 27 23:57:15 +0100 2009
- Size:
- 8192 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/perl |
2 | #----------------------------------------------------------------------------- |
3 | # Tooltips AWStats plugin |
4 | # This plugin allow you to add some toolpus in AWStats HTML report pages. |
5 | # The tooltip are in same language than the report (they are stored in the |
6 | # awstats-tt-codelanguage.txt files in lang directory). |
7 | #----------------------------------------------------------------------------- |
8 | # Perl Required Modules: None |
9 | #----------------------------------------------------------------------------- |
10 | # $Revision: 1.17 $ - $Author: eldy $ - $Date: 2008/11/15 16:03:42 $ |
11 | |
12 | |
13 | # <----- |
14 | # ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES. |
15 | # -----> |
16 | #use strict; |
17 | no strict "refs"; |
18 | |
19 | |
20 | |
21 | #----------------------------------------------------------------------------- |
22 | # PLUGIN VARIABLES |
23 | #----------------------------------------------------------------------------- |
24 | # <----- |
25 | # ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN |
26 | # AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE. |
27 | my $PluginNeedAWStatsVersion="6.1"; |
28 | my $PluginHooksFunctions="AddHTMLStyles AddHTMLBodyHeader"; |
29 | # -----> |
30 | |
31 | # <----- |
32 | # IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE. |
33 | use vars qw/ |
34 | $TOOLTIPWIDTH |
35 | /; |
36 | # -----> |
37 | |
38 | |
39 | |
40 | #----------------------------------------------------------------------------- |
41 | # PLUGIN FUNCTION: Init_pluginname |
42 | #----------------------------------------------------------------------------- |
43 | sub Init_tooltips { |
44 | my $InitParams=shift; |
45 | my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion); |
46 | |
47 | # <----- |
48 | # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS |
49 | debug(" Plugin tooltips: InitParams=$InitParams",1); |
50 | $TOOLTIPON=1; |
51 | $TOOLTIPWIDTH=380; # Width of tooltips |
52 | # -----> |
53 | |
54 | return ($checkversion?$checkversion:"$PluginHooksFunctions"); |
55 | } |
56 | |
57 | |
58 | |
59 | #----------------------------------------------------------------------------- |
60 | # PLUGIN FUNCTION: AddHTMLStyles_pluginname |
61 | # UNIQUE: NO (Several plugins using this function can be loaded) |
62 | # Function called to Add HTML styles at beginning of BODY section. |
63 | #----------------------------------------------------------------------------- |
64 | sub AddHTMLStyles_tooltips { |
65 | # <----- |
66 | print "div { font: 12px 'Arial','Verdana','Helvetica', sans-serif; text-align: justify; }\n"; |
67 | print ".CTooltip { position:absolute; top: 0px; left: 0px; z-index: 2; width: ${TOOLTIPWIDTH}px; visibility:hidden; font: 8pt 'MS Comic Sans','Arial',sans-serif; background-color: #FFFFE6; padding: 8px; border: 1px solid black; }\n"; |
68 | return 1; |
69 | # -----> |
70 | } |
71 | |
72 | |
73 | #----------------------------------------------------------------------------- |
74 | # PLUGIN FUNTION: AddHTMLBodyHeader_pluginname |
75 | # UNIQUE: NO (Several plugins using this function can be loaded) |
76 | # Function called to Add HTML code at beginning of BODY section. |
77 | #----------------------------------------------------------------------------- |
78 | sub AddHTMLBodyHeader_tooltips { |
79 | # <----- |
80 | if ($FrameName ne 'mainleft') { |
81 | |
82 | # GET AND WRITE THE TOOLTIP STRINGS |
83 | #--------------------------------------------------------------------- |
84 | &_ReadAndOutputTooltipFile($Lang); |
85 | |
86 | # WRITE TOOLTIPS JAVASCRIPT CODE |
87 | #--------------------------------------------------------------------- |
88 | # Position .style.pixelLeft/.pixelHeight/.pixelWidth/.pixelTop IE OK Opera OK |
89 | # .style.left/.height/.width/.top IE456 OK Netscape67 OK XHTML OK |
90 | # document.getElementById IE456 OK Opera OK Netscape67 OK XHTML OK |
91 | # document.body.offsetWidth|document.body.style.pixelWidth IE OK Opera OK Netscape OK XHTML KO Visible width of container |
92 | # document.documentElement.offsetWidth XHTML OK Visible width of container |
93 | # tooltipOBJ.offsetWidth|tooltipOBJ.style.pixelWidth IE OK Opera OK Netscape OK Width of an object |
94 | # event.clientXY IE OK Opera OK Netscape KO XHTML KO Position of mouse |
95 | # window.innerHeight IE OK Netscape OK Height of container |
96 | |
97 | # window.pageYOffset ? |
98 | # document.body.scrollTop IE OK Opera OK Netscape OK XHTML KO Vertical position of scrollbar |
99 | |
100 | my $docwidth="document.body.offsetWidth"; |
101 | my $doctop="document.body.scrollTop"; |
102 | if ($BuildReportFormat eq 'xhtml' || $BuildReportFormat eq 'xml') { |
103 | $docwidth="document.documentElement.offsetWidth"; |
104 | $doctop="document.documentElement.scrollTop"; |
105 | } |
106 | |
107 | print <<EOF; |
108 | |
109 | <script type="text/javascript"> |
110 | function ShowTip(fArg) |
111 | { |
112 | var tooltipOBJ = (document.getElementById) ? document.getElementById('tt' + fArg) : eval("document.all['tt" + fArg + "']"); |
113 | if (tooltipOBJ != null) { |
114 | var tooltipLft = ($docwidth?$docwidth:document.body.style.pixelWidth) - (tooltipOBJ.offsetWidth?tooltipOBJ.offsetWidth:(tooltipOBJ.style.pixelWidth?tooltipOBJ.style.pixelWidth:$TOOLTIPWIDTH)) - 30; |
115 | var tooltipTop = 10; |
116 | if (navigator.appName == 'Netscape') { |
117 | tooltipTop = ($doctop>=0?$doctop+10:event.clientY+10); |
118 | tooltipOBJ.style.top = tooltipTop+"px"; |
119 | tooltipOBJ.style.left = tooltipLft+"px"; |
120 | } |
121 | else { |
122 | tooltipTop = ($doctop>=0?$doctop+10:event.clientY+10); |
123 | tooltipTop = (document.body.scrollTop>=0?document.body.scrollTop+10:event.clientY+10); |
124 | EOF |
125 | # Seul IE en HTML a besoin de code supplémentaire. IE en xhtml est OK |
126 | if ($BuildReportFormat ne 'xhtml' && $BuildReportFormat ne 'xml') { |
127 | print <<EOF; |
128 | if ((event.clientX > tooltipLft) && (event.clientY < (tooltipOBJ.scrollHeight?tooltipOBJ.scrollHeight:tooltipOBJ.style.pixelHeight) + 10)) { |
129 | tooltipTop = ($doctop?$doctop:document.body.offsetTop) + event.clientY + 20; |
130 | } |
131 | EOF |
132 | } |
133 | print <<EOF; |
134 | tooltipOBJ.style.left = tooltipLft; |
135 | tooltipOBJ.style.top = tooltipTop; |
136 | } |
137 | tooltipOBJ.style.visibility = "visible"; |
138 | } |
139 | } |
140 | function HideTip(fArg) |
141 | { |
142 | var tooltipOBJ = (document.getElementById) ? document.getElementById('tt' + fArg) : eval("document.all['tt" + fArg + "']"); |
143 | if (tooltipOBJ != null) { |
144 | tooltipOBJ.style.visibility = "hidden"; |
145 | } |
146 | } |
147 | </script> |
148 | |
149 | EOF |
150 | |
151 | } |
152 | return 1; |
153 | # -----> |
154 | } |
155 | |
156 | |
157 | #------------------------------------------------------------------------------ |
158 | # Function: Get the tooltip texts for a specified language and write it |
159 | # Parameters: LanguageId |
160 | # Input: $DirLang $DIR |
161 | # Output: Full tooltips text |
162 | # Return: None |
163 | #------------------------------------------------------------------------------ |
164 | sub _ReadAndOutputTooltipFile { |
165 | # Check lang files in common possible directories : |
166 | # Windows and standard package: "$DIR/lang" (lang in same dir than awstats.pl) |
167 | # Debian package : "/usr/share/awstats/lang" |
168 | # Other possible directories : "./lang" |
169 | my @PossibleLangDir=("$DirLang","${DIR}/lang","/usr/share/awstats/lang","./lang"); |
170 | |
171 | my $FileLang=''; |
172 | my $logtype=lc($LogType ne 'S'?$LogType:'W'); |
173 | foreach my $dir (@PossibleLangDir) { |
174 | my $searchdir=$dir; |
175 | if ($searchdir && (!($searchdir =~ /\/$/)) && (!($searchdir =~ /\\$/)) ) { $searchdir .= "/"; } |
176 | if (open(LANG,"${searchdir}tooltips_${logtype}/awstats-tt-$_[0].txt")) { $FileLang="${searchdir}tooltips_${logtype}/awstats-tt-$_[0].txt"; last; } |
177 | } |
178 | # If file not found, we try english |
179 | if (! $FileLang) { |
180 | foreach my $dir (@PossibleLangDir) { |
181 | my $searchdir=$dir; |
182 | if ($searchdir && (!($searchdir =~ /\/$/)) && (!($searchdir =~ /\\$/)) ) { $searchdir .= "/"; } |
183 | if (open(LANG,"${searchdir}tooltips_${logtype}/awstats-tt-en.txt")) { $FileLang="${searchdir}tooltips_${logtype}/awstats-tt-en.txt"; last; } |
184 | } |
185 | } |
186 | if ($Debug) { debug(" Plugin tooltips: Call to Read_Language_Tooltip [FileLang=\"$FileLang\"]"); } |
187 | if ($FileLang) { |
188 | my $aws_PROG=ucfirst($PROG); |
189 | my $aws_VisitTimeout = $VISITTIMEOUT/10000*60; |
190 | my $aws_NbOfRobots = scalar keys %RobotsHashIDLib; |
191 | my $aws_NbOfWorms = scalar @WormsSearchIDOrder; |
192 | my $aws_NbOfSearchEngines = scalar keys %SearchEnginesHashLib; |
193 | while (<LANG>) { |
194 | if ($_ =~ /\<!--/) { next; } # Remove comment |
195 | # Search for replaceable parameters |
196 | s/#PROG#/$aws_PROG/; |
197 | s/#MaxNbOfRefererShown#/$MaxNbOf{'RefererShown'}/; |
198 | s/#VisitTimeOut#/$aws_VisitTimeout/; |
199 | s/#RobotArray#/$aws_NbOfRobots/; |
200 | s/#WormsArray#/$aws_NbOfWorms/; |
201 | s/#SearchEnginesArray#/$aws_NbOfSearchEngines/; |
202 | print "$_"; |
203 | } |
204 | } |
205 | close(LANG); |
206 | } |
207 | |
208 | |
209 | 1; # Do not remove this line |