]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Added graphapplet plugin.
authoreldy <>
Sat, 13 Dec 2003 01:26:38 +0000 (01:26 +0000)
committereldy <>
Sat, 13 Dec 2003 01:26:38 +0000 (01:26 +0000)
wwwroot/cgi-bin/awstats.pl
wwwroot/cgi-bin/plugins/graphapplet.pm
wwwroot/classes/awgraphapplet.jar
wwwroot/classes/src/AWGraphApplet.java

index a3c061c6d5e87efb80a24f62cafddeef5952651d..ce28c92818c4d85948a3f3ddf14d478fab421b06 100644 (file)
@@ -1757,12 +1757,13 @@ sub Read_Plugins {
        foreach my $key (keys %NoLoadPlugin) { if ($NoLoadPlugin{$key} < 0) { push @PluginsToLoad, $key; } }
        if ($Debug) { debug("Call to Read_Plugins with list: ".join(',',@PluginsToLoad)); }
        foreach my $plugininfo (@PluginsToLoad) {
-               if ($NoLoadPlugin{$plugininfo} && $NoLoadPlugin{$plugininfo} > 0) {
-                       if ($Debug) { debug(" Plugin load for '$plugininfo' has been disabled from command line"); }
-                       next;   
-               }
                my @loadplugin=split(/\s+/,$plugininfo,2);
                my $pluginfile=$loadplugin[0]; $pluginfile =~ s/\.pm$//i;
+               # Check if we plugin is not disabled
+               if ($NoLoadPlugin{$pluginfile} && $NoLoadPlugin{$pluginfile} > 0) {
+                       if ($Debug) { debug(" Plugin load for '$pluginfile' has been disabled from parameters"); }
+                       next;   
+               }
                my $pluginparam=$loadplugin[1]||'';
                $pluginfile =~ /([^\/\\]*)$/;
                my $pluginname=$1;
@@ -5027,7 +5028,7 @@ $tomorrowtime=int($tomorrowyear.$tomorrowmonth.$tomorrowday.$tomorrowhour.$tomor
 # Allowed option
 my @AllowedCLIArgs=('migrate','config',
 'logfile','output','runascli','update',
-'staticlinks','staticlinksext','noloadplugin','forceloadplugin',
+'staticlinks','staticlinksext','noloadplugin','loadplugin',
 'hostfilter','urlfilter','refererpagesfilter',
 'lang','month','year','framename','debug',
 'showsteps','showdropped','showcorrupted','showunknownorigin',
@@ -5129,8 +5130,8 @@ if ($QueryString =~ /(^|&)staticlinksext=([^&]+)/i) { $StaticExt="$2"; }
 if ($QueryString =~ /(^|&)framename=([^&]+)/i)         { $FrameName="$2"; }
 if ($QueryString =~ /(^|&)debug=(\d+)/i)                       { $Debug=$2; }
 if ($QueryString =~ /(^|&)updatefor=(\d+)/i)           { $UpdateFor=$2; }
-if ($QueryString =~ /(^|&)noloadplugin=([^&]+)/i)              { foreach (split(/,/,$2)) { $NoLoadPlugin{"$_"}=1; } }
-if ($QueryString =~ /(^|&)forceloadplugin=([^&]+)/i)   { foreach (split(/,/,$2)) { $NoLoadPlugin{"$_"}=-1; } }
+if ($QueryString =~ /(^|&)noloadplugin=([^&]+)/i)      { foreach (split(/,/,$2)) { $NoLoadPlugin{"$_"}=1; } }
+if ($QueryString =~ /(^|&)loadplugin=([^&]+)/i)                { foreach (split(/,/,$2)) { $NoLoadPlugin{"$_"}=-1; } }
 if ($QueryString =~ /(^|&)limitflush=(\d+)/i)          { $LIMITFLUSH=$2; }
 # Get/Define output
 if ($QueryString =~ /(^|&)output(=[^&]*|)(.*)&output(=[^&]*|)(&|$)/i) { error("Only 1 output option is allowed","","",1); }
@@ -5169,6 +5170,7 @@ else { $DayRequired=''; }
 
 # Print AWStats and Perl version 
 if ($Debug) {
+       if ($ENV{'GATEWAY_INTERFACE'}) { print "\n"; }  # To end the HTTP header and see all debug
        debug(ucfirst($PROG)." - $VERSION - Perl $^X $]",1);
        debug("QUERY_STRING=$QueryString",2);
        debug("HTMLOutput=".join(',',keys %HTMLOutput),1);
index cbf1eb1d949d5dbc1fffb1225ceba8f21be89d14..b40ad3fbdd397d2cd1a430eed8d7a04238544575 100644 (file)
@@ -26,6 +26,12 @@ my $PluginNeedAWStatsVersion="6.0";
 my $PluginHooksFunctions="ShowGraph";
 # ----->
 
+# <-----
+# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
+use vars qw/
+$DirClasses
+/;
+# ----->
 
 
 #-----------------------------------------------------------------------------
@@ -37,6 +43,7 @@ sub Init_graphapplet {
 
        # <-----
        # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
+       $DirClasses=$InitParams;
        # ----->
 
        return ($checkversion?$checkversion:"$PluginHooksFunctions");
@@ -78,7 +85,7 @@ sub ShowGraph_graphapplet() {
        else { error("Unknown type parameter in ShowGraph_graphapplet function"); }
 
 #      print "<applet code=\"AWGraphApplet.class\" codebase=\"/classes\" width=\"$graphwidth\" height=\"$graphheight\">\n";
-       print "<applet name=\"$type\" archive=\"awgraphapplet.jar\" code=\"AWGraphApplet.class\" codebase=\"/classes\" width=\"$graphwidth\" height=\"$graphheight\" alt= \"Your browser does not support Java correctly. Change browser or disable AWStats graphapplet plugin.\">\n";
+       print "<applet name=\"$type\" archive=\"awgraphapplet.jar\" code=\"AWGraphApplet.class\" codebase=\"$DirClasses\" width=\"$graphwidth\" height=\"$graphheight\" alt= \"Your browser does not support Java correctly. Change browser or disable AWStats graphapplet plugin.\">\n";
 print <<EOF;
 <param name="title" value="$title" />
 <param name="special" value="$type" />
@@ -86,6 +93,7 @@ print <<EOF;
 <param name="barsize" value="$barsize" />
 <param name="background_color" value="$color_Background" />
 <param name="border_color" value="$color_Background" />
+<param name="special_color" value="$color_weekend" />
 EOF
        print "<param name=\"nbblocks\" value=\"".(scalar @$blocklabel)."\" />\n";
        print "<param name=\"b_fontsize\" value=\"$blockfontsize\" />\n";
index f0219363fbcf9920d09ad9dc7e1c5cf69e25af2a..38fb8cea07ff95255edd4be4dd2bb8623130894f 100644 (file)
Binary files a/wwwroot/classes/awgraphapplet.jar and b/wwwroot/classes/awgraphapplet.jar differ
index 58a0e5e9768b35a5fd2c55bd535d9d29afa3f563..42781c24c3427fd9ae650a956ceb68d9f159b283 100644 (file)
@@ -14,6 +14,7 @@ public class AWGraphApplet extends Applet
     public AWGraphApplet()\r
     {\r
         special = "Not yet defined";
+        textVertSpacing = 0;\r
         b_fontsize = 11;\r
         blockSpacing = 5;\r
         valSpacing = 0;\r
@@ -21,6 +22,7 @@ public class AWGraphApplet extends Applet
         maxLabelWidth = 0;\r
         background_color = Color.white;\r
         border_color = Color.white;\r
+        special_color = Color.gray;\r
         backgraph_colorl = Color.decode("#F6F6F6");\r
         backgraph_colorm = Color.decode("#EDEDED");\r
         backgraph_colorh = Color.decode("#E0E0E0");\r
@@ -64,12 +66,15 @@ public class AWGraphApplet extends Applet
         if (s != null) { background_color = Color.decode("#"+s); }
                s = getParameter("border_color");
         if (s != null) { border_color = Color.decode("#"+s); }
+               s = getParameter("special_color");
+        if (s != null) { special_color = Color.decode("#"+s); }
 
         Log("bblocks "+nbblocks);
         Log("nbvalues "+nbvalues);
         Log("barsize "+barsize);
         
-               font = new Font("Verdana", 0, b_fontsize);\r
+               font  = new Font("Verdana,Arial,Helvetica", 0, b_fontsize);\r
+               fontb = new Font("Verdana,Arial,Helvetica", Font.BOLD, b_fontsize);
         fontmetrics = getFontMetrics(font);
         
         blabels = new String[nbblocks];
@@ -235,9 +240,9 @@ public class AWGraphApplet extends Applet
     {
                // background and border
         bfr.setColor(background_color);\r
-        bfr.fillRect(0, 0, getSize().width - 1, getSize().height - 1);\r
+        bfr.fillRect(0, 0, getSize().width, getSize().height);\r
         bfr.setColor(border_color);\r
-        bfr.drawRect(0, 0, getSize().width - 1, getSize().height - 1);\r
+        bfr.drawRect(0, 0, getSize().width, getSize().height);\r
 
                // draw the bars and their titles
                if(orientation == HORIZONTAL) { paintHorizontal(bfr); }
@@ -288,16 +293,14 @@ public class AWGraphApplet extends Applet
 
     private synchronized void paintVertical(Graphics g)
     {
-               Font font1 = new java.awt.Font("Verdana", 0, b_fontsize);
-               FontMetrics fontmetrics = getFontMetrics(font1);
                g.setColor(Color.black);
-               g.setFont(font1);
+               g.setFont(font);
 
                int shift=10;
                int allbarwidth=(((nbvalues*(valWidth+valSpacing))+blockSpacing)*nbblocks);
                int allbarheight=barsize;
                int axepointx=(getSize().width-allbarwidth)/2 - 2*shift;
-        int axepointy = getSize().height - (2*fontmetrics.getHeight()) - fontmetrics.getDescent();
+        int axepointy = getSize().height - (2*fontmetrics.getHeight()) - textVertSpacing;
 
                int cx=axepointx;
                int cy=axepointy;
@@ -338,25 +341,32 @@ public class AWGraphApplet extends Applet
 
             // Draw the block label
 //                     Log("Write block j="+j+" with cx="+cx);
-            cy = getSize().height - fontmetrics.getHeight() - fontmetrics.getDescent();
+            cy = getSize().height - fontmetrics.getHeight() - textVertSpacing;
             g.setColor(Color.black);
                        // Check if bold or highlight
-                       int bold=0; int highlight=0;
-                       if (blabels[j].indexOf(":")>0) { bold=1; blabels[j]=remove(blabels[j],":"); }
-                       if (blabels[j].indexOf("!")>0) { highlight=1; blabels[j]=remove(blabels[j],"!"); }
-
-                       String as[] = split(blabels[j], "\247", 0);\r
+                       int bold=0; int highlight=0; String label=blabels[j];
+                       if (blabels[j].indexOf(":")>0) { bold=1; label=remove(blabels[j],":"); }
+                       if (blabels[j].indexOf("!")>0) { highlight=1; label=remove(blabels[j],"!"); }
+
+                       if (bold==1) { g.setFont(fontb); }
+                       String as[] = split(label, "\247", 0);\r
+                       if (highlight==1) {
+                               g.setColor(special_color);
+                               g.fillRect(cx-Math.max(-1+blockSpacing>>1,0),cy-fontmetrics.getHeight(),(nbvalues*(valWidth+valSpacing))+Math.max(blockSpacing-2,0)+1,((fontmetrics.getHeight()+textVertSpacing)*as.length)+2);
+                               g.setColor(Color.black);
+                       }
             for (int i=0; i<as.length; i++) {
-                   int cxoffset=((nbvalues*(valWidth+valSpacing))-fontmetrics.stringWidth(as[i]))>>1;
+                               int cxoffset=((nbvalues*(valWidth+valSpacing))-fontmetrics.stringWidth(as[i]))>>1;
                    if (cxoffset<0) { cxoffset=0; }
-                   g.drawString(as[i], cx+cxoffset, cy);
-                               cy+=fontmetrics.getHeight()-2;
+                               g.drawString(as[i], cx+cxoffset, cy);
+                               cy+=fontmetrics.getHeight()+textVertSpacing;
                        }
+                       if (bold==1) { g.setFont(font); }
 
                        // Loop on each value
                for (int i = 0; i < nbvalues; i++) {
        
-                   cy = getSize().height - fontmetrics.getHeight() - fontmetrics.getDescent() - 4;
+                   cy = getSize().height - fontmetrics.getHeight() - textVertSpacing - 4;
                    cy -= fontmetrics.getHeight() - 4;
        
                    // draw the shadow and bar
@@ -378,7 +388,7 @@ public class AWGraphApplet extends Applet
     public synchronized String[][] getParameterInfo()
     {
         String[][] as = {
-            {"version", "string", "AWGraphApplet 1.0"},
+            {"version", "string", "AWGraphApplet "+VERSION},
             {"copyright", "string", "GPL"},
             {"title", "string", title}
         };
@@ -391,11 +401,12 @@ public class AWGraphApplet extends Applet
     private static final int STRIPED = 1;
        private static final int DEBUG = 3;
        private static final int SHIFTBAR = 3;
-       private static final String VERSION = "1.0";
+       private static final String VERSION = "1.1";
 
     private String title;
     private String special;
     private Font font;
+    private Font fontb;
     private FontMetrics fontmetrics;
     private int orientation;
     private int barsize;
@@ -404,6 +415,7 @@ public class AWGraphApplet extends Applet
     private String blabels[];
        private int b_fontsize;
     private int blockSpacing;
+    private int textVertSpacing;
        
     private int nbvalues;
     private Color colors[];
@@ -418,6 +430,7 @@ public class AWGraphApplet extends Applet
     private int maxLabelWidth;
        private Color background_color;
        private Color border_color;
+       private Color special_color;
        private Color backgraph_colorl;
        private Color backgraph_colorm;
        private Color backgraph_colorh;