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

📄 addform.pm

📁 一个论文管理系统
💻 PM
📖 第 1 页 / 共 2 页
字号:
  my $note = $cgi->param('note');  my $formaction = $location.$action.($popup ? 'popup' : '');  my $o = $cgi->start_form(-method  => 'POST',			   -action  => $formaction,			   -name    => $action,			   );  # hack to change enctype to old urlencoded system  # CGI.pm insists on using multipart for XHTML output but this causes cgi_error() to return an error  # '400 Bad request (malformed multipart POST)' when checked during init for some people  # an alternative approach would be to avoid doing that check (we do it voluntarily)  # (this has to be a substitution because start_form() won't accept an enctype in XHTML mode)  $o =~ s|multipart/form-data|application/x-www-form-urlencoded|g;  $o .= $cgi->hidden(uri => $uri) if !$add;  $o .= $cgi->div({class => 'note'},		  'You have already bookmarked this page, but if you would like to edit this entry in your',		  'library then you can do so using the form below.')      if $note and $note eq 'alreadyknown';  $o .= $cgi->div({class => 'errormsg'}, $validationmsg) if $validationmsg;  $o .= $cgi->start_table;  my $uribox;  if ($bookmark and $main) {    $o .= $cgi->Tr($cgi->td({class => 'preadd', valign => 'top'},			    ['Identified:',			     $cgi->div({class => 'identifed'},				       scalar $bookmark->html_content($bibliotech, 'preadd', 1, 1))]));    # note -size param may be overridden in global.css via #urlboxupdated    $uribox = $cgi->textfield(-id => 'urlboxupdated', -class => 'textctl', -name => 'uri', -size => 70);  }  else {    # note -size param may be overridden in global.css via #urlbox    $uribox = $cgi->textfield(-id => 'urlbox', -class => 'textctl', -name => 'uri', -size => 55).	' '.$cgi->submit(-id => 'addbutton', -class => 'buttonctl', -name => 'button', -value => LOOK_UP_LABEL);  }  if ($add) {    $o .= $cgi->Tr($cgi->td({id => 'bookmarklabelcell', class => 'addformlabelcell'}, URI_TERM_PROMPT.':'),		   $cgi->td({id => 'bookmarkdatacell', class => 'addformdatacell'}, $uribox));  }  my @gangnames = map($_->name, $bibliotech->user->gangs);  if (my $loaded_gang_name = $cgi->param('group')) {    unless (grep($loaded_gang_name eq $_, @gangnames)) {      push @gangnames, $loaded_gang_name;    }  }  my $private_radio = $cgi->div({class => 'privacybasic'},				$cgi->radio_group(-name => 'private',						  -values => [0, (@gangnames ? (2) : ()), 1],						  -default => 0,						  -linebreak => 'true',						  -labels => {0 => 'Share with all.',							      2 => 'Share with members of group: __GROUP_CONTROL__',							      1 => 'Keep this '.URI_TERM.' private to me.'}						  ));  my $group_control = $cgi->popup_menu(-id => 'groupselect',				       -name => 'group',				       -class => 'pulldownctlminor',				       -values => ['', sort @gangnames],				       -default => '');  $private_radio =~ s|__GROUP_CONTROL__|$group_control|;  $o .= join('',	     $cgi->Tr($cgi->td({id => 'titlelabelcell', class => 'addformlabelcell'}, 'Title:'),		      $cgi->td({id => 'titledatacell', class => 'addformdatacell'},			       $cgi->textfield(-id => 'titlebox', -class => 'textctl', -name => 'usertitle', -size => 70))		      ),	     $cgi->Tr($cgi->td({id => 'descriptionlabelcell', class => 'addformlabelcell'},			       'Description:', $cgi->span({class => 'optional'}, '(optional)')),		      $cgi->td({id => 'descriptiondatacell', class => 'addformdatacell'},			       $cgi->textfield(-id => 'descriptionbox', -class => 'textctl', -name => 'description', -size => 70))		      ),	     $cgi->Tr($cgi->td({id => 'tagslabelcell', class => 'addformlabelcell'}, 'Tags:'),		      $cgi->td({id => 'tagsdatacell', class => 'addformdatacell'},			       $cgi->textfield(-id => 'tagsbox', -class => 'textctl', -name => 'tags', -size => 46).' '.			       $cgi->submit(-id => 'addbutton', -class => 'buttonctl', -name => 'button',					    -value => $add ? 'Add to my library' : 'Save').			       $cgi->div({id => 'taghelpbox', class => 'ctlhelp'},					 'Separate tags with spaces or commas.',					 "Enclose multi-word tags in \"quotes\".",					 'For example:'.$cgi->br,					 $cgi->span({class => 'tagexample'}, "genetics \"DNA structure\" history").$cgi->br,					 $cgi->span({class => 'tagexample'}, "\"C. elegans\", \"neuromuscular development\"").					 $cgi->br,					 'See the',					 $cgi->a({href => $location.'guide#tags'}, 'site guide'),					 'for more details.'))		      ),	     $cgi->Tr($cgi->td({id => 'myworklabelcell', class => 'addformlabelcell'}, 'My work:'),		      $cgi->td({id => 'myworkdatacell', class => 'addformdatacell'},			       $cgi->checkbox(-id => 'myworkbox', -class => 'checkboxctl', -name => 'mywork',					      -label => 'I am the author or one of the co-authors of this work.', -value => 1))		      ),	     $cgi->Tr($cgi->td({id => 'privatelabelcell', class => 'addformlabelcell'}, 'Private:'),		      $cgi->td({id => 'privatedatacell', class => 'addformdatacell'},			       $private_radio,			       $cgi->div({class => 'privacyrelease'},					 'Release to all on:',					 $cgi->textfield(-id => 'embargobox', -class => 'textctlminor', -name => 'embargo',							 -size => 20).' UTC (yyyy-mm-dd hh:mm)')			       ))	     ) if $add or $edit;  $o .= $cgi->Tr($cgi->td({id => 'lastcommentlabelcell', class => 'addformlabelcell'}, 'You Said:'),		 $cgi->td({id => 'lastcommentdatacell', class => 'addformdatacell'},			  $cgi->textarea(-id => 'lastcommentbox', -class => 'textareactl', -name => 'lastcomment',					 -rows => 4, -columns => 60).			  $cgi->div({id => 'commenthelpbox', class => 'ctlhelp'},				    'Here you may alter your last posted comment.',				    'Erase all the text to remove the comment entirely.'))		 ) if $edit and $cgi->param('lastcomment');  $o .= join('',	     $cgi->Tr($cgi->td({id => 'commentlabelcell', class => 'addformlabelcell'},			       'Comment:', $cgi->span({class => 'optional'}, '(optional)')),		      $cgi->td({id => 'commentdatacell', class => 'addformdatacell'},			       $cgi->textarea(-id => 'commentbox', -class => 'textareactl', -name => 'comment',					      -rows => 4, -columns => 60))		      ),	     $cgi->Tr($cgi->td(['', $cgi->submit(-id => 'addbutton2', -class => 'buttonctl', -name => 'button',						 -value => $add ? 'Add to my library' : 'Save')])));  $o .= $cgi->end_table;  if ($addcomment and !$cgi->param('continue')) {    my $continue = 'comments';    $continue .= 'popup' if $popup;    $cgi->param('continue' => $continue);  }  $o .= $cgi->hidden('continue');  $o .= $cgi->hidden('title') if $add or $edit;  $o .= $cgi->hidden('from') if $add;  $o .= $cgi->end_form;  if ($action eq 'addcomment' and $main) {    my $comments_component = new Bibliotech::Component::Comments ({bibliotech => $bibliotech});    $o .= $comments_component->html_content($class.'comment', 1, 0, 1)->content;  # that last 1 is 'just comments'  }  my $javascript_tag_list = 'var tags = ['.join(', ', map("\"".$_->name."\"", $user->tags)).']';  my $javascript_first_empty = $self->firstempty($cgi, $action, $add || $edit ? qw/uri usertitle description tags/ : 'comment');  return new Bibliotech::Page::HTML_Content ({html_parts => {main => $o},					      javascript_block => $javascript_tag_list,					      javascript_onload => ($main ? $javascript_first_empty : undef)});}sub call_action_with_cgi_params {  my ($self, $action, $user, $cgi) = @_;  my $bibliotech = $self->bibliotech;  my @params = qw/uri comment/;  push @params, qw/title usertitle description tags mywork private group embargo lastcomment from/      if $action eq 'add' or $action eq 'edit';  my %fields = map { $_ => $self->cleanparam($cgi->param($_)); } @params;  # private = 0  no privacy  # private = 1  private to me  # private = 2  private to group  if (!$fields{private}) {    die "You cannot choose to share with all and specify a private group.\n" if $fields{group};    die "You cannot choose to share with all and specify a release date.\n"  if $fields{embargo};  }  elsif ($fields{private} == 2) {    die "You must specify a private group.\n" unless $fields{group};    $fields{private} = 0;  }  if ($fields{embargo}) {    die "You cannot choose to share with all and specify a release date.\n"	unless $fields{private} || $fields{group};    $fields{embargo} =~ s|\b(\d+:\d+)\b|$1:00|;  # add seconds    $fields{embargo} =~ s/(?<! UTC)$/ UTC/;      # add UTC time zone  }  else {    $fields{embargo} = undef;  }  $fields{group} ||= undef;  if ($action eq 'add' or $action eq 'edit') {    my @tags = $bibliotech->parser->tag_list($fields{tags}) or	die "Missing tags, malformed tags, or use of a reserved keyword as a tag.\n";    $fields{tags} = \@tags;  }  $fields{user} = $user;  return $bibliotech->$action(%fields);}1;__END__

⌨️ 快捷键说明

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