📄 addusertagannotationform.pm
字号:
# $Id: AddUserTagAnnotationForm.pm,v 1.3 2005/08/03 18:10:27 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::AddUserTagAnnotationForm class# provides an annotation add form.package Bibliotech::Component::AddUserTagAnnotationForm;use strict;use base 'Bibliotech::Component';sub last_updated_basis { ('DBI', 'LOGIN')}sub html_content { my ($self, $class, $verbose, $main, $action) = @_; my $bibliotech = $self->bibliotech; my $cgi = $bibliotech->cgi; my ($add, $edit) = (0, 0); if (!$action or $action eq 'add') { $action = 'add'; $add = 1; } elsif ($action eq 'edit') { $edit = 1; } my $user = $self->getlogin; unless ($user) { my $msg; if ($action eq 'add') { $msg = 'to add a note'; } elsif ($action eq 'edit') { $msg = 'to edit a note'; } return $self->saylogin($msg); } my $username = $user->username; # parameter cleaning foreach (qw/tag entry/) { my $value = $self->cleanparam($cgi->param($_)); $cgi->param($_ => $value) if $value; } my $validationmsg; my $overwrite = 0; my ($tagname, $tag, $entry, $user_tag_annotation); my $button = $cgi->param('button'); my $performed = 0; eval { if ($tagname = $cgi->param('tag')) { $tag = $bibliotech->parser->want_single_tag_but_may_have_more($tagname); $tagname = $tag->name; #$bibliotech->parser->check_tag_format($tagname) or die "Invalid tag format. Please enter just one tag.\n"; #$tag = new Bibliotech::Tag ($tagname) or die "You are not currently using this tag; please check that you have entered it correctly.\n"; } if ($entry = $cgi->param('entry')) { die "Please enter a tag that you would like this note to be associated with.\n" unless $tagname; } if ($button =~ /^Add/ or $button =~ /^Save/) { my $func = $action.'uta'; $bibliotech->$func(user => $user, tag => $tag, entry => $entry); $performed = 1; } }; if ($@) { $validationmsg = $@; if ($validationmsg =~ /already have a note/) { $overwrite = $validationmsg =~ /confirm/ ? 1 : 2; $action = 'edit'; $add = 0; $edit = 1; } } else { die 'Location: '.$bibliotech->location.'user/'.$user->username.'/tag/'.$tagname."\n" if $performed; } eval { if ($edit) { if ($tag) { ($user_tag_annotation) = Bibliotech::User_Tag_Annotation->search(user => $user, tag => $tag); die "No note.\n" unless defined $user_tag_annotation; $entry ||= $user_tag_annotation->comment->entry; $entry =~ s| *<br ?/?>|\n|g; $cgi->param(entry => $entry); } else { die "No tag.\n"; } } }; return Bibliotech::Page::HTML_Content->simple($cgi->div({class => 'errormsg'}, $@)) if $@; my $formaction = $bibliotech->location.$action.'tagnote'; my $o = ''; unless($edit) { $o .= $cgi->p({-class => 'welcome'}, 'You can use this form to add notes to describeyour tags.'); $o .= $cgi->p({-class => 'welcome'}, 'A tag note allows you to explain your collection for a specific tag to yourself and other users. The note will appear at the top of the list of links you have saved under that tag. For more information and help, see the ' . $cgi->a({-href => $bibliotech->location.'guide#tagnotes'}, 'site guide.')); $o .= $cgi->br; } $o .= $cgi->start_form(-method => 'POST', -action => $formaction, -name => $action); if ($validationmsg) { $o .= $cgi->div({class => 'errormsg'}, $validationmsg); $o .= $user_tag_annotation->html_content($bibliotech, 'existing', 1, 0) if $overwrite == 1; } $o .= $cgi->start_table; $o .= $cgi->Tr($cgi->td({id => 'taglabelcell', class => 'addfgroupormlabelcell'}, 'Tag:'), $cgi->td({id => 'tagdatacell', class => 'addutadatacell'}, $add ? $cgi->textfield(-id => 'tagbox', -class => 'textctl', -name => 'tag', -size => 40) : $tagname . $cgi->hidden('tag'))); $o .= $cgi->Tr($cgi->td({id => 'entrylabelcell', class => 'addutaformlabelcell'}, 'Note:'), $cgi->td({id => 'entrydatacell', class => 'addutaformdatacell'}, $cgi->textarea(-id => 'entrybox', -class => 'textareactl', -name => 'entry', -rows => 4, -columns => 60). ($edit && !$overwrite ? $cgi->div({id => 'entryhelpbox', class => 'ctlhelp'}, 'Erase all the text to remove the note entirely.') : '')) ); $o .= $cgi->Tr($cgi->td(['', $cgi->submit(-id => 'addbutton', -class => 'buttonctl', -name => 'button', -value => $add ? 'Add' : 'Save')])); $o .= $cgi->end_table; $o .= $cgi->end_form; my $javascript_first_empty = $self->firstempty($cgi, $action, qw/tag entry/); return new Bibliotech::Page::HTML_Content ({html_parts => {main => $o}, javascript_onload => ($main ? $javascript_first_empty : undef)});}1;__END__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -