Diff for /loncom/interface/lonsearchcat.pm between versions 1.296 and 1.305

version 1.296, 2008/07/15 16:18:41 version 1.305, 2009/02/26 16:17:30
Line 281  sub handler { Line 281  sub handler {
             $closebutton .="onClick='self.close()'";              $closebutton .="onClick='self.close()'";
         }          }
         $closebutton .= ">";          $closebutton .= ">";
           my $txt_import = &mt('IMPORT');
         $importbutton=<<END;          $importbutton=<<END;
 <input type='button' name='import' value='IMPORT'  <input type='button' name='import' value='$txt_import'
 onClick='javascript:select_group()'>  onClick='javascript:select_group()'>
 END  END
     } else {      } else {
Line 518  sub course_search { Line 519  sub course_search {
         my $totaldiscussions = 0;          my $totaldiscussions = 0;
         $r->print('<br /><br /><b>'.&mt('Discussion postings').':</b><br />');           $r->print('<br /><br /><b>'.&mt('Discussion postings').':</b><br />'); 
         my $navmap = Apache::lonnavmaps::navmap->new();          my $navmap = Apache::lonnavmaps::navmap->new();
         my @allres=$navmap->retrieveResources();          if (defined($navmap)) {
         my %discussiontime = &Apache::lonnet::dump('discussiontimes',              my @allres=$navmap->retrieveResources();
                                $env{'course.'.$env{'request.course.id'}.'.domain'},              my %discussiontime = &Apache::lonnet::dump('discussiontimes',
                                $env{'course.'.$env{'request.course.id'}.'.num'});                                     $env{'course.'.$env{'request.course.id'}.'.domain'},
         foreach my $resource (@allres) {                                     $env{'course.'.$env{'request.course.id'}.'.num'});
             my $result = '';              foreach my $resource (@allres) {
             my $applies = 0;                  my $result = '';
             my $symb = $resource->symb();                  my $applies = 0;
             my $ressymb = $symb;                  my $symb = $resource->symb();
             if ($symb =~ m#(___adm/$LONCAPA::domain_re/$LONCAPA::username_re)/(\d+)/bulletinboard$#) {                  my $ressymb = $symb;
                 $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard';                  if ($symb =~ m#(___adm/$LONCAPA::domain_re/$LONCAPA::username_re)/(\d+)/bulletinboard$#) {
                 unless ($ressymb =~ m#bulletin___\d+___adm/wrapper#) {                      $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard';
                     $ressymb=~s#(bulletin___\d+___)#$1adm/wrapper/#;                      unless ($ressymb =~ m#bulletin___\d+___adm/wrapper#) {
                           $ressymb=~s#(bulletin___\d+___)#$1adm/wrapper/#;
                       }
                 }                  }
             }                  if (defined($discussiontime{$ressymb})) { 
             if (defined($discussiontime{$ressymb})) {                       my %contrib = &Apache::lonnet::restore($ressymb,$env{'request.course.id'},
                 my %contrib = &Apache::lonnet::restore($ressymb,$env{'request.course.id'},                           $env{'course.'.$env{'request.course.id'}.'.domain'},
                      $env{'course.'.$env{'request.course.id'}.'.domain'},                           $env{'course.'.$env{'request.course.id'}.'.num'});
                      $env{'course.'.$env{'request.course.id'}.'.num'});                      if ($contrib{'version'}) {
                 if ($contrib{'version'}) {                          for (my $id=1;$id<=$contrib{'version'};$id++) {
                     for (my $id=1;$id<=$contrib{'version'};$id++) {                              unless (($contrib{'hidden'}=~/\.$id\./) || ($contrib{'deleted'}=~/\.$id\./)) { 
                         unless (($contrib{'hidden'}=~/\.$id\./) || ($contrib{'deleted'}=~/\.$id\./)) {                                   if ($contrib{$id.':subject'}) {
                             if ($contrib{$id.':subject'}) {                                      $result .= $contrib{$id.':subject'};
                                 $result .= $contrib{$id.':subject'};                                  }
                             }                                  if ($contrib{$id.':message'}) {
                             if ($contrib{$id.':message'}) {                                      $result .= $contrib{$id.':message'};
                                 $result .= $contrib{$id.':message'};  
                             }  
                             if ($contrib{$id,':attachmenturl'}) {  
                                 if ($contrib{$id,':attachmenturl'} =~ m-/([^/]+)$-) {  
                                     $result .= $1;  
                                 }                                  }
                                   if ($contrib{$id,':attachmenturl'}) {
                                       if ($contrib{$id,':attachmenturl'} =~ m-/([^/]+)$-) {
                                           $result .= $1;
                                       }
                                   }
                                   $applies = &checkwords($result,$applies,@allwords);
                             }                              }
                             $applies = &checkwords($result,$applies,@allwords);  
                         }                          }
                     }                      }
                 }                  }
             }  
 # Does this discussion apply?  # Does this discussion apply?
             if ($applies) {                  if ($applies) {
                 my ($map,$ind,$url)=&Apache::lonnet::decode_symb($ressymb);                      my ($map,$ind,$url)=&Apache::lonnet::decode_symb($ressymb);
                 my $disctype = &mt('resource');                      my $disctype = &mt('resource');
                 if ($url =~ m#/bulletinboard$#) {                      if ($url =~ m#/bulletinboard$#) {
                     if ($url =~m#^adm/wrapper/adm/.*/bulletinboard$#) {                          if ($url =~m#^adm/wrapper/adm/.*/bulletinboard$#) {
                         $url =~s#^adm/wrapper##;                              $url =~s#^adm/wrapper##;
                           }
                           $disctype = &mt('discussion board');
                       } else {
                           $url = '/res/'.$url;
                     }                      }
                     $disctype = &mt('bulletin board');                      if ($url =~ /\?/) {
                 } else {                          $url .= '&symb=';
                     $url = '/res/'.$url;                      } else {
                 }                          $url .= '?symb=';
                 if ($url =~ /\?/) {                      }
                     $url .= '&symb=';                      $url .= &escape($resource->symb());
                       my $title = $resource->compTitle();
                       $r->print('<br /><a href="'.$url.'" target="cat">'.
                            ($title?$title:$url).'</a>&nbsp;&nbsp;-&nbsp;'.
                            $disctype.'<br />');
                       $totaldiscussions++;
                 } else {                  } else {
                     $url .= '?symb=';                      $r->print(' .');
                 }                  }
                 $url .= &escape($resource->symb());  
                 my $title = $resource->compTitle();  
                 $r->print('<br /><a href="'.$url.'" target="cat">'.  
                      ($title?$title:$url).'</a>&nbsp;&nbsp;-&nbsp;'.$disctype.'<br />');  
                 $totaldiscussions++;  
             } else {  
                 $r->print(' .');  
             }              }
         }              unless ($totaldiscussions) {
         unless ($totaldiscussions) {                  $r->print('<p>'.&mt('No matches found in postings').'.</p>');
             $r->print('<p>'.&mt('No matches found in postings').'.</p>');              }
           } else {
               $r->print('<div class="LC_error">'.&mt('An error occurred retrieving information about resources in the course.').'<br />'.&mt('It is recommended that you [_1]re-initialize the course[_2] and then try your search again.','<a href="/adm/roles">','</a>').'</div>');
         }          }
     }      }
     
Line 684  sub print_basic_search_form { Line 690  sub print_basic_search_form {
     my $bread_crumb =      my $bread_crumb =
         &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic',          &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic',
     $env{'form.catalogmode'} ne 'import');      $env{'form.catalogmode'} ne 'import');
     my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb;      my $scrout = &Apache::loncommon::start_page('Content Library').$bread_crumb;
 # Search form for resource space   # Search form for resource space 
     if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {      if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {
         $scrout .= &setup_basic_search($r,'res',$hidden_fields,$closebutton);          $scrout .= &setup_basic_search($r,'res',$hidden_fields,$closebutton);
Line 698  sub print_basic_search_form { Line 704  sub print_basic_search_form {
  'note' => 'Enter terms or phrases, then press "Search" below',   'note' => 'Enter terms or phrases, then press "Search" below',
  'use' => 'use related words',   'use' => 'use related words',
  'full' =>'fulltext search (time consuming)',   'full' =>'fulltext search (time consuming)',
          'disc' => 'search discussion postings (resources and bulletin boards)',           'disc' => 'search discussion postings (resources and discussion boards)',
    );     );
         $scrout.=(<<ENDCOURSESEARCH);          $scrout.=(<<ENDCOURSESEARCH);
 <form name="loncapa_search" method="post" action="/adm/searchcat">  <form name="loncapa_search" method="post" action="/adm/searchcat">
Line 793  sub setup_basic_search { Line 799  sub setup_basic_search {
              '<br />'.               '<br />'.
             '<font size="-1">'.&searchhelp().'</font>'.'</td>'.              '<font size="-1">'.&searchhelp().'</font>'.'</td>'.
             '<td><font size="-1">'.              '<td><font size="-1">'.
             '<nobr>'.('&nbsp;'x3).$adv_search_link.'</nobr>'.'<br />'.              '<span class="LC_nobreak">'.('&nbsp;'x3).$adv_search_link.'</span>'.'<br />'.
             '<nobr>'.('&nbsp;'x1).$userelatedwords.'</nobr>'.'<br />'.              '<span class="LC_nobreak">'.('&nbsp;'x1).$userelatedwords.'</span>'.'<br />'.
             '<nobr>'.('&nbsp;'x1).$onlysearchdomain.'</nobr>'.'<br />'.              '<span class="LC_nobreak">'.('&nbsp;'x1).$onlysearchdomain.'</span>'.'<br />'.
             '<nobr>'.('&nbsp;'x1).$inclext.'</nobr>'.'<br />'.              '<span class="LC_nobreak">'.('&nbsp;'x1).$inclext.'</span>'.'<br />'.
              '</font></td>'.               '</font></td>'.
             '</tr>'.$/;              '</tr>'.$/;
     #      #
Line 1153  Outputs: text for box with view options Line 1159  Outputs: text for box with view options
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
 sub viewoptions {  sub viewoptions {
     my $scrout;      my $scrout = '<span class="LC_nobreak">';
     if (! defined($env{'form.viewselect'})) {       if (! defined($env{'form.viewselect'})) { 
         $env{'form.viewselect'}='detailed';           $env{'form.viewselect'}='detailed'; 
     }      }
Line 1166  sub viewoptions { Line 1172  sub viewoptions {
                                                   $env{'form.show'},                                                    $env{'form.show'},
                                                   undef,                                                    undef,
                                                   (10,20,50,100,1000,10000));                                                    (10,20,50,100,1000,10000));
     $scrout .= ('&nbsp;'x2).&mt('[_1] Records per Page',$countselect).      $scrout .= ('&nbsp;'x2)
         '</nobr>'.$/;                .&mt('[_1] Records per Page',$countselect)
                 .'</span>'.$/;
     return $scrout;      return $scrout;
 }  }
   
Line 1393  sub parse_advanced_search { Line 1400  sub parse_advanced_search {
    'lastrevisiondatestart_month','lastrevisiondatestart_day',     'lastrevisiondatestart_month','lastrevisiondatestart_day',
    'lastrevisiondatestart_year','lastrevisiondateend_month',     'lastrevisiondatestart_year','lastrevisiondateend_month',
    'lastrevisiondateend_day','lastrevisiondateend_year') {     'lastrevisiondateend_day','lastrevisiondateend_year') {
  $env{'form.'.$field}=~s/[^\w\/\s\(\)\=\-\"\'.]//g;   $env{'form.'.$field}=~s/[^\w\/\s\(\)\=\-\"\'.\*]//g;
     }      }
     foreach ('mode','form','element') {      foreach ('mode','form','element') {
  # is this required?  Hmmm.   # is this required?  Hmmm.
Line 1638  sub parse_advanced_search { Line 1645  sub parse_advanced_search {
     #      #
     if (@queries) {      if (@queries) {
         if ($env{'form.area'} eq 'portfolio') {          if ($env{'form.area'} eq 'portfolio') {
             $query ="SELECT pm.*,pa.keynum,pa.scope FROM portfolio_metadata pm, portfolio_access pa, portfolio_addedfields pf WHERE (pm.url = pa.url AND pf.url = pm.url AND (pa.start < NOW() AND (pa.end IS NULL OR pa.end > NOW())) AND (".join(') AND (',@queries).'))';              $query ="SELECT pm.*,pa.keynum,pa.scope FROM portfolio_metadata pm, portfolio_access pa, portfolio_addedfields pf WHERE (pm.url = pa.url AND pf.url = pm.url AND (pa.start < UTC_TIMESTAMP() AND (pa.end IS NULL OR pa.end > UTC_TIMESTAMP())) AND (".join(') AND (',@queries).'))';
         } else {          } else {
     $query="SELECT * FROM metadata WHERE (".join(") AND (",@queries).')';      $query="SELECT * FROM metadata WHERE (".join(") AND (",@queries).')';
         }          }
Line 1701  sub parse_basic_search { Line 1708  sub parse_basic_search {
     #      #
     # Clean up fields for safety      # Clean up fields for safety
     for my $field ('basicexp') {      for my $field ('basicexp') {
  $env{"form.$field"}=~s/[^\w\s\'\"\!\(\)\-]//g;   $env{"form.$field"}=~s/[^\w\s\'\"\!\(\)\-\*]//g;
     }      }
     foreach ('mode','form','element') {      foreach ('mode','form','element') {
  # is this required?  Hmmm.   # is this required?  Hmmm.
Line 1740  sub parse_basic_search { Line 1747  sub parse_basic_search {
     #}      #}
     my $final_query;      my $final_query;
     if ($env{'form.area'} eq 'portfolio') {      if ($env{'form.area'} eq 'portfolio') {
         $final_query = 'SELECT pm.*,pa.keynum,pa.scope FROM portfolio_metadata pm, portfolio_access pa  WHERE (pm.url = pa.url AND (pa.start < NOW() AND (pa.end IS NULL OR pa.end > NOW())) AND '.join(" AND ",@Queries).')';          $final_query = 'SELECT pm.*,pa.keynum,pa.scope FROM portfolio_metadata pm, portfolio_access pa  WHERE (pm.url = pa.url AND (pa.start < UTC_TIMESTAMP() AND (pa.end IS NULL OR pa.end > UTC_TIMESTAMP())) AND '.join(" AND ",@Queries).')';
     } else {      } else {
         $final_query = 'SELECT * FROM metadata WHERE '.join(" AND ",@Queries);          $final_query = 'SELECT * FROM metadata WHERE '.join(" AND ",@Queries);
     }      }
Line 2488  sub run_search { Line 2495  sub run_search {
     $r->print(<<END);      $r->print(<<END);
 $start_page  $start_page
 $breadcrumbs  $breadcrumbs
 <form name="statusform" action="" method="post">  
 <input type="hidden" name="acts" value="" />  
 END  END
     # Remove leading and trailing <br />      # Remove leading and trailing <br />
     $pretty_string =~ s:^\s*<br />::i;      $pretty_string =~ s:^\s*<br />::i;
Line 2500  END Line 2505  END
         pop(@Lines);          pop(@Lines);
     }      }
     if (@Lines > 2) {      if (@Lines > 2) {
         $pretty_string = join '<br />',(@Lines[0..2],'....<br />');          $pretty_string = join '<br />',(@Lines[0..2],'...<br />');
     }      }
     $r->print(&mt("Search: [_1]",$pretty_string));      $r->print(&mt("Search: [_1]",$pretty_string));
     $r->rflush();      $r->rflush();
Line 2555  END Line 2560  END
     my $server;       my $server; 
     my $status;      my $status;
     my $revise = &revise_button();      my $revise = &revise_button();
     $r->print(<<END);      $r->print('<form name="statusform" action="" method="post">'."\n".
 <table>                '<input type="hidden" name="acts" value="" />'."\n".
 <tr><th>Status</th><th>Total Matches</th><th>Time Remaining</th><th></th></tr>                '<table border="0"><tr><td>'."\n".
 <tr>                &Apache::loncommon::start_data_table());
 <td><input type="text" name="status"  value="" size="50" /></td>      $r->print(&Apache::loncommon::start_data_table_header_row()
 <td><input type="text" name="count"   value="" size="10" /></td>               .'<th>'.&mt('Status').'</th>'
 <td><input type="text" name="seconds" value="" size="8" /></td>               .'<th>'.&mt('Total Matches').'</th>'
 <td>$revise</td>               .'<th>'.&mt('Time Remaining').'</th>'
 </tr>               .&Apache::loncommon::end_data_table_header_row()
 </table>               .&Apache::loncommon::start_data_table_row()
 </form>               .'<td><input type="text" name="status"  value="" size="50" readonly="readonly" /></td>'
 END               .'<td><input type="text" name="count"   value="" size="10" readonly="readonly" /></td>'
                .'<td><input type="text" name="seconds" value="" size="8" readonly="readonly" /></td>'
                .&Apache::loncommon::end_data_table_row()
                .&Apache::loncommon::end_data_table()
                .'</td><td>&nbsp;</td><td>'.$revise.'</td></tr></table></form>');
     $r->rflush();      $r->rflush();
     &reset_timing();      &reset_timing();
     &update_seconds($r);      &update_seconds($r);
Line 2891  sub display_results { Line 2900  sub display_results {
     ## Output links (if necessary) for 'prev' and 'next' pages.      ## Output links (if necessary) for 'prev' and 'next' pages.
     $r->print      $r->print
         ('<table width="100%"><tr><td width="25%" align="right">'.          ('<table width="100%"><tr><td width="25%" align="right">'.
          '<nobr>'.$sortform.'</nobr>'.           '<span class="LC_nobreak">'.$sortform.'</span>'.
          '</td><td width="25%" align="right">'.           '</td><td width="25%" align="right">'.
          &prev_next_buttons($min,$env{'form.show'},$total_results).           &prev_next_buttons($min,$env{'form.show'},$total_results).
          '</td><td align="right">'.           '</td><td align="right">'.

Removed from v.1.296  
changed lines
  Added in v.1.305


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.