[vhffs-dev] [1091] Websearch is back!

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


Revision: 1091
Author:   beuss
Date:     2007-11-21 20:25:09 +0000 (Wed, 21 Nov 2007)

Log Message:
-----------
Websearch is back!

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/Group.pm
    trunk/vhffs-api/src/Vhffs/Panel/Web.pm
    trunk/vhffs-public/Makefile.am
    trunk/vhffs-public/templates/index.tmpl
    trunk/vhffs-public/templates/websiteslist.tmpl

Added Paths:
-----------
    trunk/vhffs-public/websitesearch.pl

Removed Paths:
-------------
    trunk/vhffs-public/websearch.pl


Modified: trunk/vhffs-api/src/Vhffs/Panel/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Group.pm	2007-11-21 05:56:42 UTC (rev 1090)
+++ trunk/vhffs-api/src/Vhffs/Panel/Group.pm	2007-11-21 20:25:09 UTC (rev 1091)
@@ -114,7 +114,6 @@
 
 sub public_search {
     my ($main, $groupname, $description, $start, $count) = @_;
-    my $result = {};
 
     my $select_clause = 'SELECT g.gid, g.groupname, g.realname, o.description';
     my $restriction = ' FROM vhffs_groups g LEFT OUTER JOIN vhffs_users u ON u.username=g.groupname INNER JOIN vhffs_object o ON o.object_id=g.object_id WHERE o.state = ? AND u.username IS NULL';

Modified: trunk/vhffs-api/src/Vhffs/Panel/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Web.pm	2007-11-21 05:56:42 UTC (rev 1090)
+++ trunk/vhffs-api/src/Vhffs/Panel/Web.pm	2007-11-21 20:25:09 UTC (rev 1091)
@@ -124,7 +124,27 @@
     return $webs;
 }
 
+sub public_search {
+    my ($main, $servername, $description, $start, $count) = @_;
 
+    my $select = 'SELECT w.servername, g.groupname, o.description';
+    my $from = ' FROM vhffs_httpd w INNER JOIN vhffs_object o ON o.object_id = w.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE o.state = ?';
+    my @params;
+    push @params, Vhffs::Constants::ACTIVATED;
+    if(defined $servername) {
+        $from .= ' AND w.servername LIKE ?';
+        push @params, '%'.$servername.'%';
+    }
+
+    if(defined $description) {
+        $from .= ' AND o.description LIKE ?';
+        push @params, '%'.$description.'%';
+    }
+
+   return Vhffs::Panel::Commons::fetch_slice_and_count($main, $select, $from, ' ORDER BY w.servername', $start, $count, \@params);
+}
+
+
 sub create_web {
         my( $main, $servername, $description, $user, $group ) = @_;
 

Modified: trunk/vhffs-public/Makefile.am
===================================================================
--- trunk/vhffs-public/Makefile.am	2007-11-21 05:56:42 UTC (rev 1090)
+++ trunk/vhffs-public/Makefile.am	2007-11-21 20:25:09 UTC (rev 1091)
@@ -13,7 +13,7 @@
 	lastusers.pl \
 	user.pl \
 	usersearch.pl \
-	websearch.pl \
+	websitesearch.pl \
 	rss/lastgroups.pl \
 	rss/lastusers.pl
 

Modified: trunk/vhffs-public/templates/index.tmpl
===================================================================
--- trunk/vhffs-public/templates/index.tmpl	2007-11-21 05:56:42 UTC (rev 1090)
+++ trunk/vhffs-public/templates/index.tmpl	2007-11-21 20:25:09 UTC (rev 1091)
@@ -44,6 +44,8 @@
         <form method="post" action="/websitesearch.pl">
             <p><label for="search_servername"><TMPL_I18N KEY="Website name">:</label>
                 <input type="text" name="servername" id="search_servername"/></p>
+            <p><label for="search_wdesc"><TMPL_I18N KEY="Website description">:</label>
+                <input type="text" name="description" id="search_wdesc"/></p>
             <p><input type="submit" name="search_website_submit" value="<TMPL_I18N KEY="Search">"/></p>
         </form>
    </fieldset>

Modified: trunk/vhffs-public/templates/websiteslist.tmpl
===================================================================
--- trunk/vhffs-public/templates/websiteslist.tmpl	2007-11-21 05:56:42 UTC (rev 1090)
+++ trunk/vhffs-public/templates/websiteslist.tmpl	2007-11-21 20:25:09 UTC (rev 1091)
@@ -2,12 +2,14 @@
 
 <div id="public">
 <h1><TMPL_VAR ESCAPE=1 NAME="TEXT_TITLE"></h1>
+<TMPL_IF NAME="LETTERS">
 <p style="text-align:center">
 <TMPL_LOOP name="LETTERS">
 [<a href="/allwebsites.pl?letter=<TMPL_VAR ESCAPE=1 name="letter">" title="<TMPL_VAR ESCAPE=1 name="count"> <TMPL_I18N KEY="website(s)">"><TMPL_VAR ESCAPE=1 name="letter"></a>]&nbsp;
 </TMPL_LOOP>
 [<a href="/allwebsites.pl?letter=all"><TMPL_VAR ESCAPE=1 name="ALL"></a>]
 </p>
+</TMPL_IF>
 <TMPL_INCLUDE NAME="misc/pagination.tmpl">
 <TMPL_IF NAME="WEBSITES">
 <TMPL_INCLUDE NAME="misc/web-part.tmpl">

Deleted: trunk/vhffs-public/websearch.pl
===================================================================
--- trunk/vhffs-public/websearch.pl	2007-11-21 05:56:42 UTC (rev 1090)
+++ trunk/vhffs-public/websearch.pl	2007-11-21 20:25:09 UTC (rev 1091)
@@ -1,99 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-use strict;
-use utf8;
-
-use POSIX qw(locale_h);
-use HTML::Template;
-use locale;
-use Locale::gettext;
-use CGI;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Group;
-use Vhffs::Main;
-use Vhffs::Acl;
-use Vhffs::Constants;
-use Vhffs::Panel::Main;
-use Vhffs::Services::Web;
-use Vhffs::Functions;
-
-my $panel = new Vhffs::Panel::Main();
-exit 0 unless $panel;
-
-my $vhffs = $panel->{'vhffs'};
-my $templatedir = $panel->{'templatedir'};
-my $cgi = $panel->{'cgi'};
-
-$panel->check_public();
-
-my $template;
-my $output_final = "";	
-my $web;
-my $maintemplate;
-my $name = $cgi->param("name");
-
-$name = Vhffs::Functions::check_arg( $name );
-my $hostname = $vhffs->get_config->get_host_name;
-
-
-my $webs = Vhffs::Services::Web::search( $vhffs  , Vhffs::Constants::ACTIVATED , $name );
-$maintemplate = new HTML::Template( filename => $templatedir."/public/websiteslist.tmpl" );
-
-
-setlocale(LC_ALL, CGI->cookie("language") );
-bindtextdomain("vhffs", $vhffs->get_config->get_intldir);
-textdomain("vhffs");
-
-$maintemplate->param( TEXT_TITLE => sprintf( gettext("All websites on %s") , $hostname ) );
-
-my $output = "";
-    
-foreach $web (@{$webs})
-{
-
-    $template = new HTML::Template( filename => $templatedir."/public/misc/web-part.tmpl" );
-    
-    $template->param( SERVERNAME => $web->get_servername );
-    $template->param( GROUPNAME => Vhffs::Group::get_name_by_gid( $vhffs , $web->get_owner_gid ) );
-    $template->param( DESCRIPTION => CGI::escapeHTML( $web->get_description ) );
-    
-   
-    $output .= $template->output;
-}
-
-
-$maintemplate->param( VALUES => $output );
-
-$panel->light( $maintemplate );
-$panel->display;

Added: trunk/vhffs-public/websitesearch.pl
===================================================================
--- trunk/vhffs-public/websitesearch.pl	                        (rev 0)
+++ trunk/vhffs-public/websitesearch.pl	2007-11-21 20:25:09 UTC (rev 1091)
@@ -0,0 +1,84 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+
+use POSIX qw(locale_h);
+use locale;
+use Locale::gettext;
+use CGI;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Panel::Main;
+use Vhffs::Panel::Template;
+use Vhffs::Panel::Web;
+
+my $panel = new Vhffs::Panel::Main();
+exit 0 unless $panel;
+
+my $vhffs = $panel->{'vhffs'};
+my $templatedir = $panel->{'templatedir'};
+my $cgi = $panel->{'cgi'};
+
+$panel->check_public();
+
+my $hostname = $vhffs->get_config->get_host_name;
+my $template = new Vhffs::Panel::Template( filename => $templatedir."/public/websiteslist.tmpl" );
+
+my $servername = $cgi->param('servername') || '';
+my $description = $cgi->param('description') || '';
+my $page = $cgi->param('page');
+my $per_page_count = 10;
+$page = 1 unless(defined $page && int($page) > 0);
+
+my $result = Vhffs::Panel::Web::public_search(
+    $vhffs,
+    $servername =~ /^\s*$/ ? undef : $servername,
+    $description =~ /^\s*$/ ? undef : $description, 
+    ($page - 1) * $per_page_count,
+    $per_page_count
+);
+
+
+if($result->{total_count} == 0) {
+    $template->param( TEXT_TITLE => gettext('No website found') );
+} else {
+    Vhffs::Panel::Commons::paginate($template, $page, $result->{total_count}, $per_page_count,
+        { servername => $servername, description => $description });
+    $template->param( TEXT_TITLE => sprintf( gettext('%d websites(s) found'), $result->{total_count} ) );
+    $template->param( WEBSITES => $result->{data} );
+}
+
+
+
+$panel->light( $template );
+$panel->display;


Property changes on: trunk/vhffs-public/websitesearch.pl
___________________________________________________________________
Name: svn:executable
   + *


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