[LON-CAPA-cvs] cvs: loncom /interface lonsearchcat.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 29 Nov 2005 20:25:45 -0000


www		Tue Nov 29 15:25:45 2005 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
  Log:
  Bug #4480: by default, do not include external (i.e., NSDL) resources
  Bug #4479: better default sorting option
  
  
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.247 loncom/interface/lonsearchcat.pm:1.248
--- loncom/interface/lonsearchcat.pm:1.247	Fri Nov 25 21:42:45 2005
+++ loncom/interface/lonsearchcat.pm	Tue Nov 29 15:25:44 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.247 2005/11/26 02:42:45 www Exp $
+# $Id: lonsearchcat.pm,v 1.248 2005/11/29 20:25:44 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -283,12 +283,7 @@
     ## Sanity checks on form elements
     ##
     if (!defined($env{'form.viewselect'})) {
-        if (($env{'form.catalogmode'} eq 'groupsearch') ||
-            ($env{'form.catalogmode'} eq 'interactive')) {
-            $env{'form.viewselect'} ="Compact View";
-        } else {
-            $env{'form.viewselect'} ="Detailed Citation View";
-        }
+	$env{'form.viewselect'} ="summary";
     }
     $env{'form.phase'} = 'disp_basic' if (! exists($env{'form.phase'}));
     $env{'form.show'} = 20 if (! exists($env{'form.show'}));
@@ -708,6 +703,10 @@
                                                  ),
                 $r->dir_config('lonDefDomain')
                 ).'</label>';
+        my $inclext= '<label>'.
+            &mt('[_1] include external resources',
+                &Apache::lonhtmlcommon::checkbox
+                ('inclext',$env{'form.inclext'})).'</label>';
         my $adv_search_link = 
             '<a href="/adm/searchcat?'.
             'phase=disp_adv&'.
@@ -740,7 +739,8 @@
             '<nobr>'.('&nbsp;'x3).$adv_search_link.'</nobr>'.'<br />'.
             '<nobr>'.('&nbsp;'x1).$userelatedwords.'</nobr>'.'<br />'.
             '<nobr>'.('&nbsp;'x1).$onlysearchdomain.'</nobr>'.'<br />'.
-            '</font></td>'.
+            '<nobr>'.('&nbsp;'x1).$inclext.'</nobr>'.'<br />'.
+             '</font></td>'.
             '</tr>'.$/;
         #
         $scrout .= '<tr><td align="center" colspan="2">'.
@@ -902,7 +902,10 @@
 	&titlefield(&mt('Domains')).'</td><td colspan="2">'. 
 	    &Apache::loncommon::domain_select('domains',
 						   $env{'form.domains'},1).
-	    '</td></tr>'.$/;
+						   '<br /><label>'.
+            &mt('[_1] include external resources',
+                &Apache::lonhtmlcommon::checkbox
+                ('inclext',$env{'form.inclext'})).'</label></td></tr>'.$/;
     #
     # Misc metadata
     $scrout.='<tr><td align="right" valign="top">'.
@@ -2522,8 +2525,11 @@
                     my %Fields = &parse_raw_result($result,$server);
                     $Fields{'hostname'} = $server;
                     #
+                    # Skip if external and we did not want that
+                    next if ((! $env{'form.inclext'}) && ($Fields{'url'}=~/^\/ext\//));
                     # Skip based on copyright
                     next if (! &copyright_check(\%Fields));
+
                     #
                     # Store the result in the mysql database
                     my $result = &Apache::lonmysql::store_row($table,\%Fields);
@@ -2725,7 +2731,15 @@
     }
     my %sort_fields = map {$_->{'key'},$_->{'desc'}} @fields;
     $sort_fields{'select_form_order'} = \@field_order;
-    $env{'form.sortorder'} = 'asc' if (! exists($env{'form.sortorder'}));
+    $env{'form.sortorder'} = 'desc' if (! exists($env{'form.sortorder'}));
+    $env{'form.sortfield'} = 'count' if (! exists($env{'form.sortfield'}));
+    if (! exists($env{'form.sortorder'})) {
+	if ($env{'form.sortfield'}=~/^(count|stdno|disc|clear|technical|correct|helpful)$/) {
+	    $env{'form.sortorder'}='desc';
+	} else {
+	    $env{'form.sortorder'}='asc';
+	}
+    }
     my $sortform = &mt('Sort by [_1] [_2]',
                        &Apache::loncommon::select_form($env{'form.sortfield'},
                                                       'sortfield',