(file) Return to tooltips.pm CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / awstats-6.3 / wwwroot / cgi-bin / plugins

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

Rizwan Kassim
Powered by
ViewCVS 0.9.2