View | Details | Raw Unified | Return to bug 11175
Collapse All | Expand All

(-)a/C4/XSLT.pm (-1 / +67 lines)
Lines 158-163 sub _get_best_default_xslt_filename { Link Here
158
158
159
sub XSLTParse4Display {
159
sub XSLTParse4Display {
160
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_;
160
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_;
161
    
162
    my $shouldIPullChildRecords; #We don't want to pull child records if they are not needed! Show child records only for detailed views.
163
    
161
    my $xslfilename = C4::Context->preference($xslsyspref);
164
    my $xslfilename = C4::Context->preference($xslsyspref);
162
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
165
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
163
        my $htdocs;
166
        my $htdocs;
Lines 169-174 sub XSLTParse4Display { Link Here
169
            $theme   = C4::Context->preference("template");
172
            $theme   = C4::Context->preference("template");
170
            $xslfile = C4::Context->preference('marcflavour') .
173
            $xslfile = C4::Context->preference('marcflavour') .
171
                       "slim2intranetDetail.xsl";
174
                       "slim2intranetDetail.xsl";
175
            $shouldIPullChildRecords = 1;
172
        } elsif ($xslsyspref eq "XSLTResultsDisplay") {
176
        } elsif ($xslsyspref eq "XSLTResultsDisplay") {
173
            $htdocs  = C4::Context->config('intrahtdocs');
177
            $htdocs  = C4::Context->config('intrahtdocs');
174
            $theme   = C4::Context->preference("template");
178
            $theme   = C4::Context->preference("template");
Lines 179-184 sub XSLTParse4Display { Link Here
179
            $theme   = C4::Context->preference("opacthemes");
183
            $theme   = C4::Context->preference("opacthemes");
180
            $xslfile = C4::Context->preference('marcflavour') .
184
            $xslfile = C4::Context->preference('marcflavour') .
181
                       "slim2OPACDetail.xsl";
185
                       "slim2OPACDetail.xsl";
186
            $shouldIPullChildRecords = 1;
182
        } elsif ($xslsyspref eq "OPACXSLTResultsDisplay") {
187
        } elsif ($xslsyspref eq "OPACXSLTResultsDisplay") {
183
            $htdocs  = C4::Context->config('opachtdocs');
188
            $htdocs  = C4::Context->config('opachtdocs');
184
            $theme   = C4::Context->preference("opacthemes");
189
            $theme   = C4::Context->preference("opacthemes");
Lines 192-200 sub XSLTParse4Display { Link Here
192
        my $lang = C4::Templates::_current_language();
197
        my $lang = C4::Templates::_current_language();
193
        $xslfilename =~ s/\{langcode\}/$lang/;
198
        $xslfilename =~ s/\{langcode\}/$lang/;
194
    }
199
    }
200
   
195
201
196
    # grab the XML, run it through our stylesheet, push it out to the browser
202
    # grab the XML, run it through our stylesheet, push it out to the browser
197
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
203
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
204
    my $f001Data = $record->field('001');
205
    $f001Data = $f001Data->data() if defined $f001Data; #Not all records have the field 001??
206
    
207
    my $childRecordsXML = _prepareChildRecords($f001Data) if $shouldIPullChildRecords &&
208
                                                            C4::Context->preference('AddChildRecordsToDetailedViews');;
209
    
198
    #return $record->as_formatted();
210
    #return $record->as_formatted();
199
    my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
211
    my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
200
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
212
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
Lines 214-220 sub XSLTParse4Display { Link Here
214
        $sysxml .= "<syspref name=\"$syspref\">$sp</syspref>\n";
226
        $sysxml .= "<syspref name=\"$syspref\">$sp</syspref>\n";
215
    }
227
    }
216
    $sysxml .= "</sysprefs>\n";
228
    $sysxml .= "</sysprefs>\n";
217
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
229
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml$childRecordsXML\<\/record\>/;
218
    if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs
230
    if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs
219
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
231
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
220
    }
232
    }
Lines 313-318 sub buildKohaItemsNamespace { Link Here
313
    return $xml;
325
    return $xml;
314
}
326
}
315
327
328
=head
329
330
  Makes a C4::Search::SimpleSearch() to find all records from the index rcn=Record-control-number matching the given
331
  field 001 value.
332
  Strips some key identifiers from those records.
333
  Builds a XML presentation out of those, ready for the XSLT processing.
334
335
  $childRecordsXML = &_prepareChildRecords($field001Data);
336
  
337
  In Koha the field 001 is not the same as the biblionumber!
338
  
339
  Returns: a string containing an XML representation of child records
340
           In XSL: childRecords/child/title
341
           in addition to title, elements can also be subtitle, biblionumber, author, publishercode, publicationyear
342
           eg. childRecords/child/biblionumber
343
344
=cut
345
sub _prepareChildRecords {
346
    
347
    my $field001Data = shift;
348
    my $childRecordsXML;
349
    my ($error, $childRecordISOs, $resultSetSize) = C4::Search::SimpleSearch("rcn=$field001Data");
350
    #TODO my ($error, $childRecordISOs, $resultSetSize) = C4::Search::SimpleSearch("rcn=$biblionumber title-sort-az");
351
    # how the hell do I sort the result set? BTW I cant sort it by title. le fuuu!
352
    
353
    if ($resultSetSize && !$error) {
354
        
355
        #Collect the XML elements to a array instead of continuously concatenating a string.
356
        #  There might be dozens of child records and in such a case string concatenation is extremely slow.
357
        my @childRecordsXML = ('<childRecords>'); #@childRecordsXML vs $childRecordsXML is a nice Perl curiosity!
358
        for my $cr ( @{$childRecordISOs} ) {
359
            push @childRecordsXML, '  <child>';
360
            my $marcrecord = MARC::File::USMARC::decode($cr);
361
            my $childBiblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,q{});
362
        
363
            push @childRecordsXML, "    <title>$childBiblio->{'title'}</title>"                               if $childBiblio->{'title'};
364
            push @childRecordsXML, "    <subtitle>$childBiblio->{'subtitle'}</subtitle>"                      if $childBiblio->{'subtitle'};
365
            push @childRecordsXML, "    <biblionumber>$childBiblio->{'biblionumber'}</biblionumber>"          if $childBiblio->{'biblionumber'};
366
            push @childRecordsXML, "    <author>$childBiblio->{'author'}</author>"                            if $childBiblio->{'author'};
367
            push @childRecordsXML, "    <publishercode>$childBiblio->{'publishercode'}</publishercode>"       if $childBiblio->{'publishercode'};
368
            push @childRecordsXML, "    <publicationyear>$childBiblio->{'publicationyear'}</publicationyear>" if $childBiblio->{'publicationyear'};
369
            
370
            push @childRecordsXML, '  </child>';
371
        }
372
        push @childRecordsXML, '</childRecords>';
373
        push @childRecordsXML, ''; #Just to make the join operation end with a newline
374
        
375
        #Build the real XML string.
376
        $childRecordsXML = join "\n", @childRecordsXML;
377
        
378
        return $childRecordsXML;
379
    }
380
    return ''; #Instantiate this string so we don't get undefined errors when concatenating with this.
381
}
316
382
317
383
318
1;
384
1;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 3-8 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
3
('AcqItemSetSubfieldsWhenReceived','0','','This syspref set a status for item when items are created when receiving (e.g. 995\$o=5)','Free'),
3
('AcqItemSetSubfieldsWhenReceived','0','','This syspref set a status for item when items are created when receiving (e.g. 995\$o=5)','Free'),
4
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
4
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
5
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
5
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
6
('AddChildRecordsToDetailedViews','1',NULL,'Show child records in the detailed views.','YesNo'),
6
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
7
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
7
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
8
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
8
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
9
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (+3 lines)
Lines 1871-1876 span.permissiondesc { Link Here
1871
.results_summary a {
1871
.results_summary a {
1872
  font-weight: normal;
1872
  font-weight: normal;
1873
}
1873
}
1874
.childRecordsContainer {
1875
	float: right;
1876
}
1874
1877
1875
ul.budget_hierarchy {
1878
ul.budget_hierarchy {
1876
    margin-left: 0px;
1879
    margin-left: 0px;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (+7 lines)
Lines 161-166 Cataloging: Link Here
161
              class: short
161
              class: short
162
            - (Leave blank if not used. Define a range like <code>192.168.</code>.)
162
            - (Leave blank if not used. Define a range like <code>192.168.</code>.)
163
        -
163
        -
164
            - "Requires XSLTDetailsDisplay and/or OPACXSLTDetailsDisplay system preferences to be active. "
165
            - pref: AddChildRecordsToDetailedViews
166
              choices:
167
                  yes: Show
168
                  no: "Don't show"
169
            - child records in the detailed views. This might cause a performance penalty for records with lots of child records. Technical explanation: This enables appending child records to the bibliographic record data for the XSLT parsing.
170
        -
164
            - pref: SeparateHoldings
171
            - pref: SeparateHoldings
165
              choices:
172
              choices:
166
                  yes: Separate
173
                  yes: Separate
(-)a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl (+29 lines)
Lines 99-105 Link Here
99
                </xsl:call-template>
99
                </xsl:call-template>
100
            </h1>
100
            </h1>
101
        </xsl:if>
101
        </xsl:if>
102
        
103
        
102
104
105
        <!--Child records: Displaying title and author of child records if available. These are floated to right by css. -->	  
106
        <xsl:if test="marc:childRecords/marc:child">
107
		  <span class="childRecordsContainer results_summary">
108
			<h5>Child records:</h5>
109
			<xsl:for-each select="marc:childRecords/marc:child">
110
			  <span class="childRecord">
111
				<xsl:if test="marc:title">
112
				  <span class="childRecordTitle">
113
					<a><xsl:attribute name="href">/cgi-bin/koha/catalogue/detail.pl?biblionumber=<xsl:value-of select="marc:biblionumber" /></xsl:attribute>
114
					  <xsl:value-of select="marc:title" />
115
					</a>
116
				  </span>
117
				</xsl:if>
118
				<xsl:if test="marc:author">
119
				  - 
120
				  <span class="childRecordAuthor">
121
					<xsl:value-of select="marc:author" />
122
				  </span>
123
				</xsl:if>
124
			  </span>
125
			  <br />
126
			</xsl:for-each>
127
		  </span>
128
		</xsl:if>
129
        
130
        
131
        
103
        <xsl:if test="marc:datafield[@tag=245]">
132
        <xsl:if test="marc:datafield[@tag=245]">
104
        <h1>
133
        <h1>
105
            <xsl:for-each select="marc:datafield[@tag=245]">
134
            <xsl:for-each select="marc:datafield[@tag=245]">
(-)a/koha-tmpl/opac-tmpl/prog/en/css/opac.css (+3 lines)
Lines 1144-1149 table#marc div.results_summary ul { Link Here
1144
table#marc div.results_summary ul li {
1144
table#marc div.results_summary ul li {
1145
	display : inline;
1145
	display : inline;
1146
}
1146
}
1147
.childRecordsContainer {
1148
	float: right;
1149
}
1147
1150
1148
#basketcount {
1151
#basketcount {
1149
	display : inline;
1152
	display : inline;
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt (-1 / +2 lines)
Lines 528-533 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
528
    <div class="yui-b"><div id="opac-detail-yui-ge" class="yui-ge">
528
    <div class="yui-b"><div id="opac-detail-yui-ge" class="yui-ge">
529
    <div class="yui-u first">
529
    <div class="yui-u first">
530
    <div id="userdetail" class="container">
530
    <div id="userdetail" class="container">
531
    <div class="yui-g" style="float: none">[%# This prevents overflow from component childrens list from breaking the detail view. %]
531
    <div id="catalogue_detail_biblio">
532
    <div id="catalogue_detail_biblio">
532
533
533
    <div id="bookcover">
534
    <div id="bookcover">
Lines 933-939 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
933
    [% END %]
934
    [% END %]
934
935
935
</div>
936
</div>
936
937
</div>[%# End of div class="yui-g" %]
937
<div id="bibliodescriptions" class="toptabs">
938
<div id="bibliodescriptions" class="toptabs">
938
939
939
<ul>   
940
<ul>   
(-)a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl (-4 / +30 lines)
Lines 145-150 Link Here
145
            </xsl:for-each>
145
            </xsl:for-each>
146
        </h1>
146
        </h1>
147
        </xsl:if>
147
        </xsl:if>
148
		
149
	  
150
      <!--Child records: Displaying title and author of child records if available. These are floated to right by css. -->	  
151
	  <xsl:if test="marc:childRecords/marc:child">
152
		  <span class="childRecordsContainer results_summary">
153
			<h5>Child records:</h5>
154
			<xsl:for-each select="marc:childRecords/marc:child">
155
			  <span class="childRecord">
156
				<xsl:if test="marc:title">
157
				  <span class="childRecordTitle">
158
					<a><xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="marc:biblionumber" /></xsl:attribute>
159
					  <xsl:value-of select="marc:title" />
160
					</a>
161
				  </span>
162
				</xsl:if>
163
				<xsl:if test="marc:author">
164
				  - 
165
				  <span class="childRecordAuthor">
166
					<xsl:value-of select="marc:author" />
167
				  </span>
168
				</xsl:if>
169
			  </span>
170
			  <br />
171
			</xsl:for-each>
172
		  </span>
173
		</xsl:if>
174
	  
148
175
149
        <!-- Author Statement: Alternate Graphic Representation (MARC 880) -->
176
        <!-- Author Statement: Alternate Graphic Representation (MARC 880) -->
150
        <xsl:if test="$display880">
177
        <xsl:if test="$display880">
Lines 175-182 Link Here
175
        <xsl:value-of select="$materialTypeLabel"/>
202
        <xsl:value-of select="$materialTypeLabel"/>
176
        </span>
203
        </span>
177
        </xsl:if>
204
        </xsl:if>
178
   </xsl:if>
205
   </xsl:if>  
179
206
	  
180
        <!--Series: Alternate Graphic Representation (MARC 880) -->
207
        <!--Series: Alternate Graphic Representation (MARC 880) -->
181
        <xsl:if test="$display880">
208
        <xsl:if test="$display880">
182
            <xsl:call-template name="m880Select">
209
            <xsl:call-template name="m880Select">
Lines 982-988 Link Here
982
        </xsl:if>
1009
        </xsl:if>
983
1010
984
    </xsl:element>
1011
    </xsl:element>
985
    </xsl:template>
1012
    </xsl:template><!-- End of  marc:record -->
986
1013
987
    <xsl:template name="showAuthor">
1014
    <xsl:template name="showAuthor">
988
        <xsl:param name="authorfield" />
1015
        <xsl:param name="authorfield" />
989
- 

Return to bug 11175