From: Demian K. <dem...@vi...> - 2011-03-08 18:23:12
|
Thanks for sharing this. I have adapted your code into a patch file and posted it in JIRA here: http://vufind.org/jira/browse/VUFIND-389 I won't include this in the 1.1 release since it would require more updates to the language files, and I won't be able to get all of the new translations in time. However, I see no reason why we can't include this in 1.1.1, the first maintenance release after 1.1's release. I have made a few changes in my version of the patch: 1.) Rather than requiring subclassing to turn on the links, I have created a new config.ini setting in the [Record] section that lets you specify a comma-separated list of MARC fields to use for linking. 2.) I've made the link generation more complex -- in my system, the $w does not contain a bib ID but rather an OCLC number prefixed by "(OCoLC)". I have updated the code to detect OCLC numbers and generate different types of links as needed. We may want to do a little more work to account for the case where there is no valid $w present -- right now it will generate a blank link if this ever happens. 3.) I've made minor style changes to comply with PEAR standards and to reduce line lengths. Please let me know if you have any problems with my version of the patch -- I'll be happy to make further revisions if necessary! - Demian > -----Original Message----- > From: Zeno Tajoli [mailto:ta...@ci...] > Sent: Tuesday, March 08, 2011 12:11 PM > To: vuf...@li... > Subject: [VuFind-Tech] Insert the MARC linking fields in VuFind > > Hi all, > here some changes that we think you should include in 1.1 if it is > possible. Or later > > With these kind of changes, you can choose to show, or not, the > information related to the MARC fields > 760, 765, 770, 772, 774, 773, 775, 777, 780, 785 (the MARC linking > information) simply overriding the > new 'getAllRecordLinks' method. > For our installation of Vufind we wrote the 'SBN.php' driver that > calls the 'MarcRecord.php' RecordDriver. > 'SBN' class implements 'DriverInterface' and 'MarcRecord' extends > the > 'IndexRecord' class. 'MarcRecord' uses > the PEAR class 'File_MARC' and its constructor need the MARC record > as input parameter. > > First of all we have changed the > '/web/RecordDrivers/IndexRecord.php' > file. We added the line: > > > ----------------------------------------------------------------------- > ------------------------------------------------------- > $interface->assign('coreRecordLinks', $this- > >getAllRecordLinks()); > > ----------------------------------------------------------------------- > ------------------------------------------------------- > > within the 'getCoreMetadata' method, after the template assignment > of > 'coreSubjects'. This line calls the new empty method > 'getAllRecordLinks' (you can put it where you want within the > 'IndexRecord' class): > > > ----------------------------------------------------------------------- > ------------------------------------------------------- > /** > * Get all record links related to the current record. Each link is > returned as array. > * NB: to use this method you must override it. > * Format: > * <code> > * Array( > * Array( > * 'title' => label_for_title > * 'value' => link_name > * 'link' => link_URI > * ), > * ... > * ) > * </code> > * > * @access protected > * @return null|Array > */ > protected function getAllRecordLinks() > { > return null; > } > > ----------------------------------------------------------------------- > ------------------------------------------------------- > > With this code came the related template chunk into > '/RecordDrivers/Index/core.tpl' ('interface/themes' directory). > We think that this kind of data is important enough to have a place > into the main display area. We put it above the 'Tags' > code. Here the code: > > > ----------------------------------------------------------------------- > ------------------------------------------------------- > {if !empty($coreRecordLinks)} > {foreach from=$coreRecordLinks item=coreRecordLink} > <tr valign="top"> > <th>{translate text=$coreRecordLink.title} </th> > <td><a > href="{$coreRecordLink.link}">{$coreRecordLink.value}</a></td> > </tr> > {/foreach} > {/if} > > ----------------------------------------------------------------------- > ------------------------------------------------------- > > At this point you have a 'naife' 'core.tpl' and 'IndexRecord.php' > that don't show any data, but ready to do so if you > override the 'getAllRecordLinks' method. > > Here our implementation. > Our 'MarcRecord' class overrides the 'getAllRecordLinks' method. > This > method builds links to the linking information of the > MARC record using PEAR and a string that contains the full MARC > record. Here the code (NB: '$this->marcRecord' property > is the PEAR 'File_MARC' class): > > > ----------------------------------------------------------------------- > ------------------------------------------------------- > /** > * Get all record links related to the current record. Each link is > returned as array. > * Format: > * Array( > * Array( > * 'title' => label_for_title > * 'value' => link_name > * 'link' => link_URI > * ), > * ... > * ) > * > * @access protected > * @return null|array > */ > protected function getAllRecordLinks() > { > $fieldsNames = Array('760', '765', '770', '772', '774', '773', > '775', '777', '780', '785'); > $returnValue = Array(); > foreach($fieldsNames as $value){ > $fields = $this->marcRecord->getFields($value); > if(!empty($fields)){ > foreach($fields as $field){ > $indicator = $field->getIndicator('2'); > switch($value){ > case '773': if($indicator == '9'){ > $returnValue[] = > $this->getFieldData($field, $value.'_9'); > }elseif($indicator == ' '){ > $returnValue[] = > $this->getFieldData($field, $value); > } > break; > case '780': if($indicator == '0'){ > $returnValue[] = > $this->getFieldData($field, $value.'_0'); > }elseif($indicator == '1'){ > $returnValue[] = > $this->getFieldData($field, $value.'_1'); > }elseif($indicator == '5'){ > $returnValue[] = > $this->getFieldData($field, $value.'_5'); > } > break; > case '785': if($indicator == '0'){ > $returnValue[] = > $this->getFieldData($field, $value.'_0'); > }elseif($indicator == '7'){ > $returnValue[] = > $this->getFieldData($field, $value.'_7'); > } > break; > default : $returnValue[] = > $this->getFieldData($field, $value); > } > } > } > } > if(empty($returnValue)){ > $returnValue = null; > } > return $returnValue; > } > > /** > * Returns the array element for the 'getAllRecordLinks' method > * > * @access private > * return Array > */ > private function getFieldData($field, $value){ > global $configArray; > > $labelPrfx = 'note_'; > $baseURI = $configArray['Site']['url'].'/Record/'; > return Array('title' => $labelPrfx.$value, > 'value' => $field->getSubfield('t')->getData(), > 'link' => $baseURI.$field->getSubfield('w')- > >getData() > ); > } > > ----------------------------------------------------------------------- > ------------------------------------------------------- > > As you can see, there is a second private method that builds the > single array of data. This method builds the language label > formed by a fixed prefix 'note_' and the MARC field id (ex.: > 'note_760'). > > Here the labels (for '/lang/en.ini' and '/lang/it.ini'): > > > ----------------------------------------------------------------------- > ------------------------------------------------------- > (English) > note_760 = Main series: > note_765 = Translation of: > note_770 = Has supplement: > note_772 = Supplement to: > note_774 = Constituent unit: > note_773 = Contains: > note_773_9 = Related with: > note_775 = Other edition available: > note_777 = Issued with: > note_780_0 = Continues: > note_780_1 = Continues in part: > note_780_5 = Absorbed: > note_785_0 = Continued by: > note_785_7 = Merged with: > (Italian) > note_760 = Serie principale: > note_765 = Traduzione di: > note_770 = Supplemento: > note_772 = Supplemento di: > note_774 = Fa parte di: > note_773 = Contiene: > note_773_9 = Collegato con: > note_775 = Altra edizione disponibile: > note_777 = Pubblicato con: > note_780_0 = Continua: > note_780_1 = Continua in parte: > note_780_5 = Assorbe: > note_785_0 = Continuato da: > note_785_7 = Si fonde con: > > ----------------------------------------------------------------------- > ------------------------------------------------------- > > We made this kind of implementation to leave untouched the final > output of the original Vufind but giving the possibility to > add the MARK linking information if someone want them. You can > choose > to put this code where you think is better. > > You can delete the case of indicator 9 in tag 773. > We use it to support a conversion from Unimarc. > > I'm not sure that the cose is well formatted, I can send it with .txt > file if you prefer. > > Bye > Zeno Tajoli (code written by Matteo Perelli) > -- > Dott. Zeno Tajoli > tajoliAT_SPAM_no_prendiATcilea.it > fax +39 02 2135520 > CILEA - Consorzio Interuniversitario > http://www.cilea.it/disclaimer > > ----------------------------------------------------------------------- > ------- > What You Don't Know About Data Connectivity CAN Hurt You > This paper provides an overview of data connectivity, details > its effect on application quality, and explores various alternative > solutions. http://p.sf.net/sfu/progress-d2d > _______________________________________________ > Vufind-tech mailing list > Vuf...@li... > https://lists.sourceforge.net/lists/listinfo/vufind-tech |