[vhffs-dev] [434] allwebsites.pl shows only letters for wich there are websites

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 434
Author:   beuss
Date:     2007-02-03 18:48:45 +0000 (Sat, 03 Feb 2007)

Log Message:
-----------
allwebsites.pl shows only letters for wich there are websites

Modified Paths:
--------------
    branches/vhffs_4.1/Makefile
    branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm
    branches/vhffs_4.1/vhffs-panel/public/allwebsites.pl
    branches/vhffs_4.1/vhffs-panel/templates/public/allwebsites.tmpl


Modified: branches/vhffs_4.1/Makefile
===================================================================
--- branches/vhffs_4.1/Makefile	2007-02-03 15:02:17 UTC (rev 433)
+++ branches/vhffs_4.1/Makefile	2007-02-03 18:48:45 UTC (rev 434)
@@ -101,7 +101,7 @@
 
 install-conf:
 	install -d -m 755 $(CONFDIR)
-	if [ ! -f $(CONFDIR)/vhffs.conf ]; then echo "INSTALL ORIGINAL CONFIG FILE" ; install -m 600 vhffs-backend/conf/vhffs.conf $(CONFDIR)/ ; else echo "CONFIG FILE ALREADY EXISTS" ; fi
+	@if [ ! -f $(CONFDIR)/vhffs.conf ]; then echo "INSTALL ORIGINAL CONFIG FILE" ; install -m 600 vhffs-backend/conf/vhffs.conf $(CONFDIR)/ ; else echo "CONFIG FILE ALREADY EXISTS" ; fi
 
 install-backend:
 	install -d -m 755 $(BACKENDDIR)

Modified: branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm
===================================================================
--- branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm	2007-02-03 15:02:17 UTC (rev 433)
+++ branches/vhffs_4.1/vhffs-api/src/Vhffs/Services/Httpd.pm	2007-02-03 18:48:45 UTC (rev 434)
@@ -426,6 +426,17 @@
     return _new Vhffs::Services::Httpd($main, @params);
 }
 
+# Return a reference on an array, each fiel is a hash with two fields
+# letter and count (count is the number of websites starting with letter).
+# 0 site letters aren't stored.
+sub get_used_letters {
+    my $main = shift;
+    my $sql = 'SELECT substr(servername, 1, 1) as letter, COUNT(*) as count FROM vhffs_httpd GROUP BY substr(servername, 1, 1)';
+    my $dbh = $main->get_db_object;
+    return $dbh->selectall_arrayref($sql, { Slice => {} });
+
+}
+
 sub _new {
     my ($class, $main, $httpd_id, $servername, $crawl, $owner_http, $owner_rev, $owner_uid, $owner_gid, $trafic, $alert_state, $alert_limit, $oid, $date_creation, $description, $state) = @_;
 

Modified: branches/vhffs_4.1/vhffs-panel/public/allwebsites.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/public/allwebsites.pl	2007-02-03 15:02:17 UTC (rev 433)
+++ branches/vhffs_4.1/vhffs-panel/public/allwebsites.pl	2007-02-03 18:48:45 UTC (rev 434)
@@ -50,7 +50,8 @@
 my $cgi = new CGI;
 my $template;
 my $templatedir = $vhffs->get_config->get_templatedir;
-my $letter = ( defined $cgi->param('letter') ? $cgi->param('letter') : 'a' );
+my $letters = Vhffs::Services::Httpd::get_used_letters($vhffs);
+my $letter = ( defined $cgi->param('letter') ? $cgi->param('letter') : (defined $letters->[0] ? $letters->[0]->{letter} : undef) );
 undef $letter if ( $letter eq 'all' );
 my $webs = Vhffs::Services::Httpd::getall_by_letter( $vhffs, $letter, Vhffs::Constants::ACTIVATED);
 my $output_final = "";	
@@ -64,7 +65,7 @@
 
 $maintemplate->param( THEME => Vhffs::Panel::Main::get_theme( $vhffs ) );
 $maintemplate->param( TEXT_TITLE => sprintf( gettext("All websites on %s") , $hostname ) );
-$maintemplate->param( LETTERS => [ { letter => '0' }, { letter => '1' }, { letter => '2' }, { letter => '3' }, { letter => '4' }, { letter => '5' }, { letter => '6' }, { letter => '7' }, { letter => '8' }, { letter => '9' }, { letter => 'a' },  { letter => 'b' }, { letter => 'c' }, { letter => 'd' }, { letter => 'e' }, { letter => 'f' }, { letter => 'g' }, { letter => 'h' }, { letter => 'i' }, { letter => 'j' }, { letter => 'k' }, { letter => 'l' }, { letter => 'm' }, { letter => 'n' }, { letter => 'o' }, { letter => 'p' }, { letter => 'q' }, { letter => 'r' }, { letter => 's' }, { letter => 't' }, { letter => 'u' }, { letter => 'v' },  { letter => 'w' }, { letter => 'x' }, { letter => 'y' }, { letter => 'z' } ]);
+$maintemplate->param( LETTERS => $letters );
 $maintemplate->param( ALL => gettext('All') );
 if( @{$webs} == 0 )
 {   

Modified: branches/vhffs_4.1/vhffs-panel/templates/public/allwebsites.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/public/allwebsites.tmpl	2007-02-03 15:02:17 UTC (rev 433)
+++ branches/vhffs_4.1/vhffs-panel/templates/public/allwebsites.tmpl	2007-02-03 18:48:45 UTC (rev 434)
@@ -17,7 +17,7 @@
 <tmpl_if name="LETTERS">
 <p style="text-align:center">
 <tmpl_loop name="LETTERS">
-[<a href="/public/allwebsites.pl?letter=<tmpl_var name="letter">"><tmpl_var name="letter"></a>]&nbsp;
+[<a href="/public/allwebsites.pl?letter=<tmpl_var name="letter">" title="<tmpl_var name="count">"><tmpl_var name="letter"></a>]&nbsp;
 </tmpl_loop>
 [<a href="/public/allwebsites.pl?letter=all"><tmpl_var name="ALL"></a>]
 </p>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/