[index] [prev] [next] [options] [help]
See the Contact page for how to subscribe and unsubscribe.

eprints_tech messages

Please note: this page shows emails that have been sent to the eprints_tech mailing list. Some of these may be spam emails we have failed to filter.

[EP-tech] Re: Phrases based on eprint type

From: Duncan Dickinson <d.dickinson AT qut.edu.au>
Date: Mon, 10 Nov 2008 09:41:46 +1000


Threading: [EP-tech] Phrases based on eprint type from d.dickinson AT qut.edu.au
      • This Message

http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** EPrints community wiki - http://wiki.eprints.org/
Thanks Alfons! I couldn't quite get that to work but checked the data structure 
with Dumper and came up with the following code:

sub render_name {
	my ( $self, $session ) =  AT _;

	if ( defined $self->{title_xhtml} ) {
		return $self->{title_xhtml};
	}
	my $phrasename = $self->{confid} . "_fieldname_" . 
$self->{name};

	# START: Changes made to provide context sensitive names
	my $eprintid = $session->{query}->{eprintid}->[0];
	
	if ($eprintid eq "") {
		$eprintid = $session->{query}->{param}->{eprintid}->[0];
	}

	my $ep = EPrints::DataObj::EPrint->new( $session,
          $eprintid );
	
	if ($ep) {
		my $eptype = $ep->get_type;
		$phrasename .= "#$eptype" if 
$session->get_lang->has_phrase("$phrasename#$eptype");
	} 
	# END: Changes made to provide context sensitive names
	
	return $session->html_phrase($phrasename);
}

sub render_help
{
	my ( $self, $session ) =  AT _;

	if ( defined $self->{help_xhtml} ) {
		return $self->{help_xhtml};
	}
	my $phrasename = $self->{confid} . "_fieldhelp_" . 
$self->{name};

	# START: Changes made to provide context sensitive help
	my $eprintid = $session->{query}->{eprintid}->[0];
	
	if ($eprintid eq "") {
		$eprintid = $session->{query}->{param}->{eprintid}->[0];
	}

	my $ep = EPrints::DataObj::EPrint->new( $session,
          $eprintid );
	
	if ($ep) {
		my $eptype = $ep->get_type;
		$phrasename .= "#$eptype" if 
$session->get_lang->has_phrase("$phrasename#$eptype");
	} 
	# END: Changes made to provide context sensitive help

	return $session->html_phrase($phrasename);
}

So now we can have the following for titles:
	<epp:phrase 
id="eprint_fieldname_title">Title</epp:phrase>
	<epp:phrase id="eprint_fieldname_title#book_section">Chapter 
Title</epp:phrase>
 And for help:

<epp:phrase id="eprint_fieldhelp_title">
		The title of the item.
</epp:phrase>
<epp:phrase id="eprint_fieldhelp_title#book">
		The title of the book.
</epp:phrase>


Naturally, the phrase-setting code could be put into a sub. I just hope eprints 
doesn't hit the DB with each call.....

I'd vote for this change to be put into the next release (it really helps keep 
our forms easy to follow) :)

Cheers,

Duncan

 Duncan Dickinson / QUT Digital Repository Technical Project Manager / Library 
Systems
 Queensland University of Technology / CRICOS: 00213J
 ph 3138 3782

-----Original Message-----
From: eprints-tech-bounces AT ecs.soton.ac.uk [mailto:eprints-tech-bounces AT 
ecs.soton.ac.uk] On Behalf Of Alfons Wittmann
Sent: Friday, 7 November 2008 6:56 PM
To: eprints-tech AT ecs.soton.ac.uk
Subject: [EP-tech] Re: Phrases based on eprint type

http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** EPrints community wiki - http://wiki.eprints.org/
Duncan Dickinson schrieb am 07.11.2008 02:35:
> I'm editing EPrints::MetaField, altering the render_help function to be:
> sub render_help
...
> 	my $phrasename = 
$self->{confid}."_fieldhelp_".$self->{name}; 
> 	my $eptype = EPrints::DataObj::EPrint->new( $session,
>    		$session->{query}->{eprintid}->[0])->get_type; 
>    	$phrasename .= "#$eptype" if 
$session->get_lang->has_phrase("$phrasename#$eptype");
> 	return $session->html_phrase( $phrasename );
>
> This gives me an error of: "Can't call method get_type on an 
undefined value"

Ok, I had this too, when running "generate_abstracts" or 
"send_alerts".
Small change to avoid this error:

sub render_help {
        ...
        my $phrasename = 
$self->{confid}."_fieldhelp_".$self->{name};

        my $ep = EPrints::DataObj::EPrint->new( $session,
          $session->{query}->{eprintid}->[0] );
        if ($ep) {
          my $eptype = $ep->get_type;
          $phrasename .= "#$eptype" if
            
$session->get_lang->has_phrase("$phrasename#$eptype");
        }

        return $session->html_phrase( $phrasename );
}

> We're running EPrints 3.1.1 (Port and Brandy)

Same here.

Regards,
Alfons

--
Universitätsbibliothek Eichstätt-Ingolstadt
EDV-Referat                    Tel: 08421/93-1486 - Fax: 08421/93-1791
Universitätsallee 1            EMail: alfons.wittmann AT ku-eichstaett.de
85071 Eichstätt                http://www.ku-eichstaett.de/Bibliothek/




[index] [prev] [next] [options] [help]