[Koha-cvs] koha admin/itemtypes.pl C4/Search.pm koha-tmpl/... [rel_3_0]

paul poulain paul at koha-fr.org
Tue Dec 5 16:07:17 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	paul poulain <tipaul>	06/12/05 15:07:17

Modified files:
	admin          : itemtypes.pl 
	C4             : Search.pm 
	koha-tmpl/intranet-tmpl/prog/en/admin: itemtypes.tmpl 
	koha-tmpl/intranet-tmpl/prog/en/catalogue: results.tmpl 
	updater        : updatedatabase 

Log message:
	NEW FEATURE :
	a column (itemtypes.summary) has been added.
	
	If it is empty, no changes at all.
	In admin/itemtypes.pl, the librarian can go and define what (and how) the record appeard below the title.
	The summary must be entered exactly as the authority summary.
	An example is provided in admin/itemtypes.pl add/modify itemtype.
	
	This feature had been requested for a while by my librarians. The 2 uses we can imagine are :
	- for websites => show the link directly in the result list, to avoid 1 clic (& there is no need for a size/editor/publicationyear for web sites)
	- for serial publications => show some serial specific informations.
	
	This commit should do everything that is needed for this feature.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/admin/itemtypes.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.24.2.2&r2=1.24.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Search.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.120.2.34&r2=1.120.2.35
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/admin/itemtypes.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.2.2.1&r2=1.2.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/catalogue/results.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.17&r2=1.1.2.18
http://cvs.savannah.gnu.org/viewcvs/koha/updater/updatedatabase?cvsroot=koha&only_with_tag=rel_3_0&r1=1.157.2.30&r2=1.157.2.31

Patches:
Index: admin/itemtypes.pl
===================================================================
RCS file: /sources/koha/koha/admin/itemtypes.pl,v
retrieving revision 1.24.2.2
retrieving revision 1.24.2.3
diff -u -b -r1.24.2.2 -r1.24.2.3
--- admin/itemtypes.pl	30 Nov 2006 18:23:51 -0000	1.24.2.2
+++ admin/itemtypes.pl	5 Dec 2006 15:07:16 -0000	1.24.2.3
@@ -143,6 +143,7 @@
         notforloan => $data->{'notforloan'},
         imageurl => $data->{'imageurl'},
         template => C4::Context->preference('template'),
+        summary => $data->{summary},
         IMAGESLOOP => \@imagelist,
         remote_image => $remote_image,
     );
@@ -172,6 +173,7 @@
                  , rentalcharge = ?
                  , notforloan = ?
                  , imageurl = ?
+                 , summary = ?
             WHERE itemtype = ?
         ';
         my $sth=$dbh->prepare($query);
@@ -179,21 +181,23 @@
                 $input->param('description'),
 		        $input->param('renewalsallowed'),
                 $input->param('rentalcharge'),
-		        $input->param('notforloan') ? 1 : 0,
-                $input->param('image') eq 'removeImage'
-                ? undef
-                : $input->param('image') eq 'remoteImage'
+		        ($input->param('notforloan') ? 1 : 0),
+                ($input->param('image') eq 'removeImage'
+                        ?''
+                        :($input->param('image') eq 'remoteImage' 
                 ? $input->param('remoteImage')
-                : $input->param('image'),
-		        $input->param('itemtype'),
+                            :$input->param('image')."")
+                ),
+                $input->param('summary'),
+		        $input->param('itemtype')
             );
     }
     else { # add a new itemtype & not modif an old
         my $query = "
             INSERT INTO itemtypes
-                (itemtype,description,renewalsallowed,rentalcharge, notforloan, imageurl)
+                (itemtype,description,renewalsallowed,rentalcharge, notforloan, imageurl,summary)
             VALUES
-                (?,?,?,?,?,?);
+                (?,?,?,?,?,?,?);
             ";
         my $sth=$dbh->prepare($query);
 	    $sth->execute(
@@ -207,6 +211,7 @@
             : $input->param('image') eq 'remoteImage'
                 ? $input->param('remoteImage')
                 : $input->param('image'),
+        $input->param('summary'),
         );
     }
     

Index: C4/Search.pm
===================================================================
RCS file: /sources/koha/koha/C4/Search.pm,v
retrieving revision 1.120.2.34
retrieving revision 1.120.2.35
diff -u -b -r1.120.2.34 -r1.120.2.35
--- C4/Search.pm	5 Dec 2006 11:35:30 -0000	1.120.2.34
+++ C4/Search.pm	5 Dec 2006 15:07:16 -0000	1.120.2.35
@@ -25,7 +25,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.120.2.34 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.120.2.35 $' =~ /\d+/g;
     shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
 };
 
@@ -803,12 +803,13 @@
     #find itemtype & itemtype image
     my %itemtypes;
     $bsth =
-      $dbh->prepare("SELECT itemtype,description,imageurl FROM itemtypes");
+      $dbh->prepare("SELECT itemtype,description,imageurl,summary FROM itemtypes");
     $bsth->execute();
     while ( my $bdata = $bsth->fetchrow_hashref ) {
         $itemtypes{ $bdata->{'itemtype'} }->{description} =
           $bdata->{'description'};
         $itemtypes{ $bdata->{'itemtype'} }->{imageurl} = $bdata->{'imageurl'};
+        $itemtypes{ $bdata->{'itemtype'} }->{summary} = $bdata->{'summary'};
     }
 
     #search item field code
@@ -858,7 +859,30 @@
             $oldbiblio->{description} =
               $itemtypes{ $oldbiblio->{itemtype} }->{description};
         }
-
+        #
+        # build summary if there is one (the summary is defined in itemtypes table
+        #
+        if ($itemtypes{ $oldbiblio->{itemtype} }->{summary}) {
+            my $summary = $itemtypes{ $oldbiblio->{itemtype} }->{summary};
+            my @fields = $marcrecord->fields();
+            foreach my $field (@fields) {
+                my $tag = $field->tag();
+                my $tagvalue = $field->as_string();
+                $summary =~ s/\[(.?.?.?.?)$tag\*(.*?)]/$1$tagvalue$2\[$1$tag$2]/g;
+                unless ($tag<10) {
+                    my @subf = $field->subfields;
+                    for my $i (0..$#subf) {
+                        my $subfieldcode = $subf[$i][0];
+                        my $subfieldvalue = $subf[$i][1];
+                        my $tagsubf = $tag.$subfieldcode;
+                        $summary =~ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
+                    }
+                }
+            }
+            $summary =~ s/\[(.*?)]//g;
+            $summary =~ s/\n/<br>/g;
+            $oldbiblio->{summary} = $summary;
+        }
         # add spans to search term in results
         foreach my $term ( keys %$span_terms_hashref ) {
 

Index: koha-tmpl/intranet-tmpl/prog/en/admin/itemtypes.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/admin/itemtypes.tmpl,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -b -r1.2.2.1 -r1.2.2.2
--- koha-tmpl/intranet-tmpl/prog/en/admin/itemtypes.tmpl	19 Oct 2006 09:02:54 -0000	1.2.2.1
+++ koha-tmpl/intranet-tmpl/prog/en/admin/itemtypes.tmpl	5 Dec 2006 15:07:16 -0000	1.2.2.2
@@ -157,6 +157,16 @@
           <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="<!-- TMPL_VAR name="rentalcharge" -->" />
         </td>
       </tr><!--  /Hide from NPL -->
+      <tr>
+        <th>
+          <label for="rentalcharge">Summary</label>
+        </th>
+        <td><p>Enter a summary that will overwrite the default one in search results lists</p>
+          <p><textarea id="summary" name="summary" cols="40" rows="10"><!-- TMPL_VAR NAME="summary" --></textarea></p>
+          <p>Example, for a website itemtype : </p>
+          <p><b>&lt;a href="[856u]"&gt;open site&lt;/a&gt;</b> will show the link just below the title</p>
+        </td>
+      </tr>
     </table>
 
     <p id="action">

Index: koha-tmpl/intranet-tmpl/prog/en/catalogue/results.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/catalogue/Attic/results.tmpl,v
retrieving revision 1.1.2.17
retrieving revision 1.1.2.18
diff -u -b -r1.1.2.17 -r1.1.2.18
--- koha-tmpl/intranet-tmpl/prog/en/catalogue/results.tmpl	23 Nov 2006 16:17:23 -0000	1.1.2.17
+++ koha-tmpl/intranet-tmpl/prog/en/catalogue/results.tmpl	5 Dec 2006 15:07:16 -0000	1.1.2.18
@@ -201,6 +201,9 @@
                                         <!-- /TMPL_IF -->
                                     <!-- /TMPL_IF -->
                                 </p> 
+                                <!-- TMPL_IF name="summary" -->
+                                    <p><!-- TMPL_VAR name="summary" --></p>
+                                <!-- TMPL_ELSE -->
                                 <p>
                                     <!-- TMPL_IF NAME="author" -->
                                         <a href="search.pl?q=au:<!-- TMPL_VAR NAME="author" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="author" --></a>
@@ -215,6 +218,7 @@
                                     <!-- TMPL_IF name="size" --> ; <!-- TMPL_VAR name="size" --><!-- /TMPL_IF -->
                                     <!-- TMPL_IF name="timestamp" --> <i>(modified on <!-- TMPL_VAR name="timestamp" -->)</i><!-- /TMPL_IF -->
                                 </p>
+                                <!-- /TMPL_IF -->
                                 </td>
                                 <td>
                                     <a href="/cgi-bin/koha/catalogue/search.pl?q=callnum:<!-- TMPL_VAR NAME="classification" ESCAPE="URL" -->">

Index: updater/updatedatabase
===================================================================
RCS file: /sources/koha/koha/updater/updatedatabase,v
retrieving revision 1.157.2.30
retrieving revision 1.157.2.31
diff -u -b -r1.157.2.30 -r1.157.2.31
--- updater/updatedatabase	29 Nov 2006 11:58:18 -0000	1.157.2.30
+++ updater/updatedatabase	5 Dec 2006 15:07:16 -0000	1.157.2.31
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: updatedatabase,v 1.157.2.30 2006/11/29 11:58:18 toins Exp $
+# $Id: updatedatabase,v 1.157.2.31 2006/12/05 15:07:16 tipaul Exp $
 
 # Database Updater
 # This script checks for required updates to the database.
@@ -784,7 +784,14 @@
             null   => 'NOT NULL',
             key    => 'PRI',
             extra  => 'UNIQUE',
-        }
+        },
+        {
+            field  => 'summary',
+            type   => 'TEXT',
+            null   => 'NULL',
+            key    => '',
+            extra  => '',
+        },
     ],
     reserves =>  [
         {
@@ -2023,6 +2030,21 @@
 exit;
 
 # $Log: updatedatabase,v $
+# Revision 1.157.2.31  2006/12/05 15:07:16  tipaul
+# NEW FEATURE :
+# a column (itemtypes.summary) has been added.
+#
+# If it is empty, no changes at all.
+# In admin/itemtypes.pl, the librarian can go and define what (and how) the record appeard below the title.
+# The summary must be entered exactly as the authority summary.
+# An example is provided in admin/itemtypes.pl add/modify itemtype.
+#
+# This feature had been requested for a while by my librarians. The 2 uses we can imagine are :
+# - for websites => show the link directly in the result list, to avoid 1 clic (& there is no need for a size/editor/publicationyear for web sites)
+# - for serial publications => show some serial specific informations.
+#
+# This commit should do everything that is needed for this feature.
+#
 # Revision 1.157.2.30  2006/11/29 11:58:18  toins
 # re indenting with space.
 #





More information about the Koha-cvs mailing list