EPrints Technical Mailing List Archive

Message: #06989


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] validation on upload field


Hi Alfredo,

we solved an similar feature request by a either repository specific (i.e. Eprints/archives/repoID/cfg/cfg.d/) or server specific (i.e. Eprints/site_lib/cfg.d/) document_validate.pl:

$c->{validate_document} = sub
{
        my( $document, $repository, $for_archive ) = @_;

        my @problems = ();

        my $xml = $repository->xml();

        # default checks
# :
        # site-specific checks

        # check for proper filename, i.e. accepted by tivoli backup ingesting only ASCI-filenames without blanks
        # print STDERR "main: ", $document->value( "main" )," escaped: ",URI::Escape::uri_escape_utf8($document->value( "main" ), "^A-Za-z0-9\-\._~\/");
        my $doc_name_uri = URI::Escape::uri_escape_utf8($document->value( "main" ), "^A-Za-z0-9\-\._~\/");
        if( $document->value( "main" ) ne $doc_name_uri )
        {
                my $fieldname = $repository->make_element( "span", class=>"ep_problem_field:documents" );
                $fieldname->appendChild( $document->dataset->render_name( $repository ) );

                my $prob = $repository->make_doc_fragment;
                $prob->appendChild( $repository->html_phrase( "validate:bad_filename", fieldname=>$fieldname ) );
                $prob->appendChild( $repository->make_text( $doc_name_uri ) );

                $prob->appendChild( $repository->html_phrase( "validate:original_filename") );
                $prob->appendChild( $repository->make_text( $document->value( "main" ) ) );

                push @problems, $prob;
        }


        return( @problems );
};

After setting the introduced phrases by
<epp:phrase id="validate:bad_filename">Please replace non-ASCII characters (e.g. 'äöü') or blanks in the name of uploaded <epc:pin name="fieldname" /> appropriately to simplify future handling!<br/>Following filename prepared for repository<br/></epp:phrase>
<epp:phrase id="validate:original_filename"><br/>is different to original one :(<br/></epp:phrase>
in an appropriate .../lang/en/phrases/... file it should work :-)

Hth
Thomas