⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchform.pm

📁 一个论文管理系统
💻 PM
字号:
# $Id: SearchForm.pm,v 1.11 2005/11/16 22:39:48 martin Exp $## Copyright 2005 Nature Publishing Group# This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2# of the License, or (at your option) any later version.## The Bibliotech::Component::Search class provides a search form.package Bibliotech::Component::SearchForm;use strict;# base was Bibliotech::Component, but /rss/search?q=xxx didn't# work because this is the main component for# Bibliotech::Page::Search yet it has no rss_content().# We use ListOfRecent explicitly in a search.tpl and then# this base to underlay the other *_content() routines.# We also had to remove last_updated_basis() because its not# fine-grained enough to return a different value for HTML# content vs other content.use base 'Bibliotech::Component::ListOfRecent';use URI;use URI::QueryParam;use Bibliotech::Command;sub html_content {  my ($self, $class, $verbose, $main) = @_;  my $bibliotech = $self->bibliotech;  my $location = $bibliotech->location;  my $command = $bibliotech->command;  my $query = $bibliotech->query;  my $page = $command->page;  my $cgi = $bibliotech->cgi;  my $validationmsg;  if ($cgi->param('form')) {    my $uri;    eval {      my $phrase = $cgi->param('q');      my $type = $cgi->param('type') || 'all';      my $submit_uri = $cgi->param('uri');      if ($type eq 'current') {	$uri = URI->new($submit_uri);	$uri->query_param(q => $phrase);	$uri->query_param_delete('start');      }      elsif ($type eq 'all') {	$uri = URI->new($location.'search');	$uri->query_param(q => $phrase);      }      elsif ($type eq 'library') {	$uri = URI->new($location.'library');	$uri->query_param(q => $phrase);      }      elsif ($type eq 'tag' or $type eq 'user') {	$phrase =~ s|\s*\+\s*|+|g;	# this next bit is designed for tags, bet we let it be for users as well	my @tags = $bibliotech->parser->tag_search($phrase) or	    die "Missing ${type}s, malformed ${type}s, or use of a reserved keyword as a ${type}.\n";	my $tags = join('/', map { ref $_ ? join('+', @{$_}) : $_; } @tags);	$uri = $command->canonical_uri($location, {page => [set => 'recent'],						   output => [set => 'html'],						   $type => [set => $tags]});      }      elsif ($type eq 'google') {	$uri = URI->new('http://www.google.com/search');	(my $domain = $location->host) =~ s/^www\.//;	$uri->query_param(q => "site:$domain $phrase");      }      else {	die "Invalid search type: $type\n";      }    };    if ($@) {      $validationmsg = $@;    }    else {      die "Location: $uri\n";    }  }  if ($main) {    # error ... just show it    return Bibliotech::Page::HTML_Content->simple($cgi->div({class => 'errormsg'}, $validationmsg))	if $validationmsg;    # have been called with a phrase in the main area - drop to ListOfRecent to show results    return $self->SUPER::html_content($class, $verbose, $main)	if $cgi->param('q');    # no error, no search, just a hit on /search probably ... just display a short message    return Bibliotech::Page::HTML_Content->simple($cgi->p('Please search above.'));  }  my @possible_values = ('library', 'all', 'tag', 'user', 'google');  my $default_value = 'all';  unshift @possible_values, $default_value = 'current' if defined $query && $query->any_filters;  $default_value = 'library' if $bibliotech->in_my_library;  my $o = $cgi->div( {id => 'search-and-account-bar'},    $cgi->div( {id => 'search-new'},      $cgi->span( {id => 'account'},        $cgi->span( {id => 'reglinks'},          $cgi->a( {href => $location.'library', class => 'search-link'}, 'My Library'),          ' | ',          $cgi->a( {href => $location.'register', class => 'search-link'}, 'Registration')        )      ),      $cgi->start_form(-method => 'POST', -action => $location.'search', -id => 'search-form'),      'Search '.$cgi->popup_menu(-accesskey => 't',				 -id => 'searchtype',				 -class => 'searchpulldownctl',				 -name => 'type',				 -labels => {'current' => 'This collection',					     'library' => 'My library',					     'all'     => 'All',					     'tag'     => 'Find exact tag',					     'user'    => 'Find exact user',					     'google'  => 'Via Google'					       },				 -values => \@possible_values,				 -default => $default_value,				 -onchange => "document.getElementById(\'searchbox\').focus();"				 ),      $cgi->textfield(-accesskey => 's', -id => 'searchbox', -class => 'searchtextctl', -name => 'q').' ',      $cgi->hidden(uri => $command->canonical_uri($location)),      $cgi->hidden(form => 1),      $cgi->submit(-id => 'searchbutton', -class => 'buttonctl', -name => 'button', -value => 'Search'),      $cgi->end_form    )  );      return Bibliotech::Page::HTML_Content->simple($o);}1;__END__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -