Diff for /loncom/interface/lonsearchcat.pm between versions 1.327 and 1.332

version 1.327, 2011/01/17 20:18:02 version 1.332, 2012/12/07 18:16:33
Line 78  use HTML::Entities(); Line 78  use HTML::Entities();
 use Parse::RecDescent;  use Parse::RecDescent;
 use Apache::lonnavmaps;  use Apache::lonnavmaps;
 use Apache::lonindexer();  use Apache::lonindexer();
   use Apache::lonwishlist();
 use LONCAPA;  use LONCAPA;
   
 ######################################################################  ######################################################################
Line 151  sub handler { Line 152  sub handler {
     ## Initialize global variables      ## Initialize global variables
     ##      ##
     my $domain  = $r->dir_config('lonDefDomain');      my $domain  = $r->dir_config('lonDefDomain');
     $diropendb= "/home/httpd/perl/tmp/".      my $temp_file_dir = LONCAPA::tempdir();
       $diropendb= $temp_file_dir .
         "$env{'user.domain'}_$env{'user.name'}_sel_res.db";          "$env{'user.domain'}_$env{'user.name'}_sel_res.db";
     #      #
     # set the name of the persistent database      # set the name of the persistent database
Line 162  sub handler { Line 164  sub handler {
         $env{'form.persistent_db_id'} = time;          $env{'form.persistent_db_id'} = time;
     }      }
   
     my $persistent_db_file = "/home/httpd/perl/tmp/".      my $persistent_db_file = $temp_file_dir .
         &escape($domain).          &escape($domain).
             '_'.&escape($env{'user.name'}).              '_'.&escape($env{'user.name'}).
                 '_'.$env{'form.persistent_db_id'}.'_persistent_search.db';                  '_'.$env{'form.persistent_db_id'}.'_persistent_search.db';
Line 1913  sub ensure_db_and_table { Line 1915  sub ensure_db_and_table {
     ##      ##
     my $connection_result = &Apache::lonmysql::connect_to_db();      my $connection_result = &Apache::lonmysql::connect_to_db();
     if (!defined($connection_result)) {      if (!defined($connection_result)) {
         $r->print("Unable to connect to the MySQL database where your results".          $r->print(
                   " are saved.".              '<p class="LC_error">'
   &Apache::loncommon::end_page());             .&mt('Unable to connect to the MySQL database where your results are saved.')
              .'</p>'
              .&Apache::loncommon::end_page()
           );
         &Apache::lonnet::logthis("lonsearchcat: unable to get lonmysql to".          &Apache::lonnet::logthis("lonsearchcat: unable to get lonmysql to".
                                  " connect to database.");                                   " connect to database.");
         &Apache::lonnet::logthis(&Apache::lonmysql::get_error());          &Apache::lonnet::logthis(&Apache::lonmysql::get_error());
Line 1923  sub ensure_db_and_table { Line 1928  sub ensure_db_and_table {
     }      }
     my $table_check = &Apache::lonmysql::check_table($table);      my $table_check = &Apache::lonmysql::check_table($table);
     if (! defined($table_check)) {      if (! defined($table_check)) {
         $r->print("A MySQL error has occurred.</form>".          $r->print(
   &Apache::loncommon::end_page());              '<p class="LC_error">'
              .&mt('A MySQL error has occurred.')
              .'</p></form>'
              .&Apache::loncommon::end_page());
         &Apache::lonnet::logthis("lonmysql was unable to determine the status".          &Apache::lonnet::logthis("lonmysql was unable to determine the status".
                                  " of table ".$table);                                   " of table ".$table);
         return undef;          return undef;
     } elsif (! $table_check) {      } elsif (! $table_check) {
         $r->print("The table of results could not be found.");          $r->print(
               '<p class="LC_error">'
              .&mt('The table of results could not be found.')
              .'</p>'
           );
         &Apache::lonnet::logthis("The user requested a table, ".$table.          &Apache::lonnet::logthis("The user requested a table, ".$table.
                                  ", that could not be found.");                                   ", that could not be found.");
         return undef;          return undef;
Line 2382  END Line 2394  END
                 next;                  next;
             }              }
             $status=~s|/||g;              $status=~s|/||g;
            my $datafile=$r->dir_config('lonDaemons').'/tmp/'.$status;  
   
   
              my $datafile=LONCAPA::tempdir().$status;
             if (-e $datafile && ! -e "$datafile.end") {              if (-e $datafile && ! -e "$datafile.end") {
                 &update_status($r,&mt('Receiving results from [_1]',$server));                  &update_status($r,&mt('Receiving results from [_1]',$server));
                 next;                  next;
Line 3058  SCRIPT Line 3073  SCRIPT
 </script>  </script>
 SCRIPT  SCRIPT
   
     # HTML-Markup for 'Set a link for this resource to wishlist'  
     # this is written via JavaScript document.write (function set_wishlistlink)   
     # it is split into 3 parts and the inputfields for title and path are left out  
     # these fields are inserted later to set the values for title and path  
     # automatically via JavaScript (document.title and location.pathname)   
     my %folders = &Apache::lonnet::get('wishlist',['folders']);  
     if ($folders{'folders'} eq '') {  
         $folders{'folders'} = '<option value="" selected="selected">('.&mt('Top level').')</option>';  
     }  
     my $start_page_wishlistlink =   
         &Apache::loncommon::start_page('Set link to wishlist',undef,  
        {'only_body' => 1,  
  'js_ready'  => 1,  
  'bgcolor'   => '#FFFFFF',});  
   
     my $warningLink = &mt('You must insert a title!');  
   
     my $in_page_wishlistlink1 = '<h1>'.&mt('Set a link to wishlist').'</h1>'.  
                                 '<form method="post" name="newlink" action="/adm/wishlist?mode=set" '.  
                                 'onsubmit="return newlinksubmit();" >'.  
                                 &Apache::lonhtmlcommon::start_pick_box().  
                                 &Apache::lonhtmlcommon::row_title(&mt('Link Title'));  
   
     my $in_page_wishlistlink2 = &Apache::lonhtmlcommon::row_closure().  
                                 &Apache::lonhtmlcommon::row_title(&mt('Path'));  
   
     my $in_page_wishlistlink3 = &Apache::lonhtmlcommon::row_closure().  
                                 &Apache::lonhtmlcommon::row_title(&mt('Note')).  
                                 '<textarea name="note" rows="3" cols="35" style="width:100%"></textarea>'.  
                                 &Apache::lonhtmlcommon::row_closure(1).  
                                 &Apache::lonhtmlcommon::end_pick_box().  
                                 '<br/><br/>'.  
                                 '<input type="submit" value="'.&mt('Save in').'" />'.  
                                 '<select name="folders">'.  
                                 $folders{'folders'}.  
                                 '</select>'.  
                                 '<input type="button" value="'.&mt('cancel').'" onclick="javascript:window.close();" />'.  
                                 '</form>';  
   
     # remove all \n for inserting on javascript document.write  
     $in_page_wishlistlink1 =~ s/\n//g;  
     $in_page_wishlistlink2 =~ s/\n//g;  
     $in_page_wishlistlink3 =~ s/\n//g;  
   
     my $end_page_wishlistlink =   
        &Apache::loncommon::end_page({'js_ready' => 1});  
   
     # Add JavaScript-function to set link for a ressource to wishlist  
     $js.=<<SCRIPT;  
 <script type="text/javascript">  
 // <![CDATA[  
 function set_wishlistlink(title, path){  
    if(!title){  
        title=document.title;  
    }  
    if(!path){  
        path=location.pathname;  
    }  
    wishlistlink=window.open('','wishlistNewLink','width=560,height=350,scrollbars=0');  
    wishlistlink.document.write(  
    '$start_page_wishlistlink'  
    +'<script type="text\/javascript">'  
    +'function newlinksubmit(){'  
    +'var title = document.getElementsByName("title")[0].value;'  
    +'if (!title) {'  
    +'alert("$warningLink");'  
    +'return false;}'  
    +'return true;}'  
    +'<\/scr'+'ipt>'  
    +'$in_page_wishlistlink1'  
    +'<input type="text" name="title" size="45" value="'+title+'"/>'  
    +'$in_page_wishlistlink2'  
    +'<input type="text" name="path" size="45" value="'+path+'" '  
    +'readonly="readonly" style="background-color: #DDDDDD"/>'  
    +'$in_page_wishlistlink3'  
    +'$end_page_wishlistlink' );  
    wishlistlink.document.close();  
 }  
   
 // ]]>  
 </script>  
 SCRIPT  
   
     my $start_page  = &Apache::loncommon::start_page(undef,$js,      my $start_page  = &Apache::loncommon::start_page(undef,$js,
      {'only_body' =>1});       {'only_body' =>1,
                                                         'add_wishlist' =>1});
     my $result=<<END;      my $result=<<END;
 $start_page  $start_page
 <form name="results" method="post" action="/adm/searchcat">  <form name="results" method="post" action="/adm/searchcat">
Line 3234  sub evalfields { Line 3167  sub evalfields {
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
   sub display_tools {
       my ($title, $jumpurl) = @_;
       my $result;
       # Metadata
       $result.=
           &Apache::loncommon::modal_link(
               $jumpurl.'.meta?inhibitmenu=yes',
               '<img class="LC_icon" src="/res/adm/pages/catalog.png" alt="Info" />',
               500,500,'_blank',undef,&mt('Metadata'));
       # Stored Links
       $result.=
           ' <a href="javascript:;"'.
           ' onclick="set_wishlistlink('."'$title','$jumpurl'".')" '.
           'title="'.&mt('Save a link for this resource in your personal Stored Links repository').'">'.
           '<img class="LC_icon" src="/res/adm/pages/wishlist.png" '.
           'alt="Stored Links" style="width:22px;"/></a>';
       return $result;
   }
   
   ######################################################################
   ######################################################################
   
 =pod   =pod 
   
 =item Metadata Viewing Functions  =item Metadata Viewing Functions
Line 3258  sub detailed_citation_view { Line 3213  sub detailed_citation_view {
     my $result;      my $result;
     my $jumpurl=$values{'url'};      my $jumpurl=$values{'url'};
     $jumpurl=~s|^/ext/|http://|;      $jumpurl=~s|^/ext/|http://|;
     $result .= '<b>'.$prefix.      $result .=
           '<b>'.$prefix.
         '<img src="'.&Apache::loncommon::icon($values{'url'}).'" alt="" />'.'&nbsp;'.          '<img src="'.&Apache::loncommon::icon($values{'url'}).'" alt="" />'.'&nbsp;'.
         '<a href="'.$jumpurl.'?inhibitmenu=yes" '.          '<a href="'.$jumpurl.'?inhibitmenu=yes" '.
         'target="preview">'.$values{'title'}."</a></b>\n".          'target="preview">'.$values{'title'}."</a></b>\n".
         '<a href="javascript:;" onclick="set_wishlistlink('."'$values{'title'}','$jumpurl'".')" '.          &display_tools($values{'title'}, $jumpurl).
         'title="'.&mt('Set link to wishlist').'">'.          "<p>\n".
         '<img class="LC_icon" src="/res/adm/pages/wishlist.png" '.          '<b>'.$values{'author'}.'</b>,'.
         'alt="set wishlistlink" style="width:22px;"/></a>';  
     $result .= "<p>\n";  
     $result .= '<b>'.$values{'author'}.'</b>,'.  
         ' <i>'.$values{'owner'}.'</i><br />';          ' <i>'.$values{'owner'}.'</i><br />';
     foreach my $field       foreach my $field 
         (          (
Line 3395  sub summary_view { Line 3348  sub summary_view {
     my $jumpurl=$values{'url'};      my $jumpurl=$values{'url'};
     $jumpurl=~s|^/ext/|http://|;      $jumpurl=~s|^/ext/|http://|;
     my $link = '<br />'.&display_url($jumpurl,1).'<br />';      my $link = '<br />'.&display_url($jumpurl,1).'<br />';
       $result .=
     my $titleWL = &mt('Set link to wishlist');          '<a href="'.$jumpurl.'?inhibitmenu=yes"'.
     $result.=<<END;          ' target="preview">'.$values{'title'}.'</a>'.
 <a href="$jumpurl?inhibitmenu=yes"           &display_tools($values{'title'}, $jumpurl).<<END;
    target="preview">$values{'title'}</a>  
 <a href="javascript:;" onclick="set_wishlistlink('$values{'title'}','$jumpurl')"   
    title="$titleWL">  
    <img class="LC_icon" src="/res/adm/pages/wishlist.png"  
         alt="set wishlistlink" style="width:22px;"/>  
 </a>  
 <br />  <br />
 $link<br />  $link<br />
 $values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}<br />  $values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}<br />
Line 3451  sub compact_view { Line 3398  sub compact_view {
     $result.=' <span class="LC_nobreak">'.      $result.=' <span class="LC_nobreak">'.
  '<a href="'.$jumpurl.'?inhibitmenu=yes" target="preview">'.   '<a href="'.$jumpurl.'?inhibitmenu=yes" target="preview">'.
         &HTML::Entities::encode($values{'title'},'<>&"').'</a></span> '.          &HTML::Entities::encode($values{'title'},'<>&"').'</a></span> '.
         '<a href="javascript:;" onclick="set_wishlistlink('."'$values{'title'}','$jumpurl'".')" '.          &display_tools($values{'title'}, $jumpurl).
         'title="'.&mt('Set link to wishlist').'">'.  
         '<img class="LC_icon" src="/res/adm/pages/wishlist.png" '.  
         'alt="set wishlistlink" style="width:22px;"/>'.  
         '</a>'.  
  $link.' <b>'.$values{'author'}.'</b> ('.$values{'domain'}.')';   $link.' <b>'.$values{'author'}.'</b> ('.$values{'domain'}.')';
     return $result;      return $result;
 }  }
Line 3497  sub fielded_format_view { Line 3440  sub fielded_format_view {
     my $jumpurl=$values{'url'};      my $jumpurl=$values{'url'};
     $jumpurl=~s|^/ext/|http://|;      $jumpurl=~s|^/ext/|http://|;
   
     my $titleWL = ('Set link to wishlist');  
     my $result=<<END;      my $result=<<END;
 $prefix <img src="$icon" alt="" />  $prefix <img src="$icon" alt="" />
 <dl>  <dl>
 <dt>URL:</dt>  <dt>URL:</dt>
     <dd><a href="$jumpurl?inhibitmenu=yes"       <dd><a href="$jumpurl?inhibitmenu=yes" 
          target='preview'>$values{'url'}</a>           target='preview'>$values{'url'}</a>
          <a href="javascript:;" onclick="set_wishlistlink('$values{'title'}','$jumpurl')"  
             title="$titleWL">  
             <img class="LC_icon" src="/res/adm/pages/wishlist.png"  
             alt="set wishlistlink" style="width:22px;"/>  
          </a>  
     </dd>  
 END  END
       $result .=
           &display_tools($values{'title'}, $jumpurl).'
       </dd>';
     foreach my $field ('title','author','domain','subject','keywords','notes',      foreach my $field ('title','author','domain','subject','keywords','notes',
                        'mimetag','language','creationdate','lastrevisiondate',                         'mimetag','language','creationdate','lastrevisiondate',
                        'owner','copyrighttag','hostname','abstract') {                         'owner','copyrighttag','hostname','abstract') {

Removed from v.1.327  
changed lines
  Added in v.1.332


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>