From 91d36ad4c5ae7c1b1a4fbcdc26a0d56d1ae00ad8 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 2 Jun 2015 15:51:09 -0400 Subject: [PATCH] Added helper method to eliminate redundant logic. --- .../src/VuFind/View/Helper/Root/Record.php | 25 +++++++++++++++++++ .../templates/Recommend/CatalogResults.phtml | 14 +++-------- .../templates/Recommend/RandomRecommend.phtml | 11 +++----- .../templates/Recommend/SummonResults.phtml | 14 +++-------- .../templates/Recommend/WebResults.phtml | 14 +++-------- .../RecordDriver/LibGuides/result-list.phtml | 11 +++----- .../RecordDriver/Pazpar2/result-list.phtml | 14 +++-------- .../RecordDriver/SolrDefault/list-entry.phtml | 11 +++----- .../SolrDefault/result-grid.phtml | 14 +++-------- .../SolrDefault/result-list.phtml | 14 +++-------- .../RecordDriver/SolrWeb/result-list.phtml | 14 +++-------- .../templates/Recommend/CatalogResults.phtml | 12 +-------- .../templates/Recommend/RandomRecommend.phtml | 12 +-------- .../templates/Recommend/SummonResults.phtml | 12 +-------- .../templates/Recommend/WebResults.phtml | 14 +++-------- .../RecordDriver/LibGuides/result-list.phtml | 11 +++----- .../RecordDriver/Pazpar2/result-list.phtml | 14 +++-------- .../RecordDriver/SolrDefault/list-entry.phtml | 13 ++-------- .../SolrDefault/result-grid.phtml | 14 +++-------- .../SolrDefault/result-list.phtml | 12 +-------- .../RecordDriver/SolrWeb/result-list.phtml | 14 +++-------- .../RecordDriver/LibGuides/result-list.phtml | 9 +------ .../RecordDriver/Pazpar2/result-list.phtml | 12 +-------- .../RecordDriver/SolrDefault/list-entry.phtml | 11 +------- .../SolrDefault/result-list.phtml | 12 +-------- .../RecordDriver/SolrWeb/result-list.phtml | 12 +-------- 26 files changed, 81 insertions(+), 259 deletions(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Record.php b/module/VuFind/src/VuFind/View/Helper/Root/Record.php index 9a590b187bb..46688744533 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Record.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Record.php @@ -303,6 +303,31 @@ class Record extends AbstractHelper return $idClasses; } + /** + * Get HTML to render a title. + * + * @param int $maxLength Maximum length of non-highlighted title. + * + * @return string + */ + public function getTitleHtml($maxLength = 180) + { + $highlightedTitle = $this->driver->tryMethod('getHighlightedTitle'); + $title = $this->driver->tryMethod('getTitle'); + if (!empty($highlightedTitle)) { + $highlight = $this->getView()->plugin('highlight'); + $addEllipsis = $this->getView()->plugin('addEllipsis'); + return $highlight($addEllipsis($highlightedTitle, $title)); + } + if (!empty($title)) { + $escapeHtml = $this->getView()->plugin('escapeHtml'); + $truncate = $this->getView()->plugin('truncate'); + return $escapeHtml($truncate($title, $maxLength)); + } + $transEsc = $this->getView()->plugin('transEsc'); + return $transEsc('Title not available'); + } + /** * Get the name of the controller used by the record route. * diff --git a/themes/blueprint/templates/Recommend/CatalogResults.phtml b/themes/blueprint/templates/Recommend/CatalogResults.phtml index fbd0863666b..38f433d42fa 100644 --- a/themes/blueprint/templates/Recommend/CatalogResults.phtml +++ b/themes/blueprint/templates/Recommend/CatalogResults.phtml @@ -7,17 +7,9 @@ <li> <? $formats = $driver->getFormats(); $format = isset($formats[0]) ? $formats[0] : ''; ?> <span class="<?=$this->record($driver)->getFormatClass($format)?>"> - <a href="<?=$this->recordLink()->getUrl($driver)?>" class="title"><? - $summHighlightedTitle = $driver->getHighlightedTitle(); - $summTitle = $driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a href="<?=$this->recordLink()->getUrl($driver)?>" class="title"> + <?=$this->record($driver)->getTitleHtml()?> + </a> </span> <? $summAuthor = $driver->getPrimaryAuthor(); if (!empty($summAuthor)): ?> <br /> diff --git a/themes/blueprint/templates/Recommend/RandomRecommend.phtml b/themes/blueprint/templates/Recommend/RandomRecommend.phtml index 2cfc3e9854a..0cb2e44ccd8 100644 --- a/themes/blueprint/templates/Recommend/RandomRecommend.phtml +++ b/themes/blueprint/templates/Recommend/RandomRecommend.phtml @@ -27,14 +27,9 @@ <?if($this->recommend->getDisplayMode() === "standard" || $this->recommend->getDisplayMode() === "mixed"):?> <? $formats = $driver->getFormats(); $format = isset($formats[0]) ? $formats[0] : ''; ?> <span class="<?=$this->record($driver)->getFormatClass($format)?>"> - <a href="<?=$this->recordLink()->getUrl($driver)?>" class="title"><? - $summTitle = $driver->getTitle(); - if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a href="<?=$this->recordLink()->getUrl($driver)?>" class="title"> + <?=$this->record($driver)->getTitleHtml()?> + </a> </span> <? $summAuthor = $driver->getPrimaryAuthor(); if (!empty($summAuthor)): ?> <br /> diff --git a/themes/blueprint/templates/Recommend/SummonResults.phtml b/themes/blueprint/templates/Recommend/SummonResults.phtml index 585bb232726..1e5f7ef5fa8 100644 --- a/themes/blueprint/templates/Recommend/SummonResults.phtml +++ b/themes/blueprint/templates/Recommend/SummonResults.phtml @@ -7,17 +7,9 @@ <li> <? $formats = $driver->getFormats(); $format = isset($formats[0]) ? $formats[0] : ''; ?> <span class="<?=$this->record($driver)->getFormatClass($format)?>"> - <a href="<?=$this->recordLink()->getUrl($driver)?>" class="title"><? - $summHighlightedTitle = $driver->getHighlightedTitle(); - $summTitle = $driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a href="<?=$this->recordLink()->getUrl($driver)?>" class="title"> + <?=$this->record($driver)->getTitleHtml()?> + </a> </span> <span style="font-size: .8em"> <? $summAuthor = $driver->getPrimaryAuthor(); if (!empty($summAuthor)): ?> diff --git a/themes/blueprint/templates/Recommend/WebResults.phtml b/themes/blueprint/templates/Recommend/WebResults.phtml index 701bd836951..055b21a3617 100644 --- a/themes/blueprint/templates/Recommend/WebResults.phtml +++ b/themes/blueprint/templates/Recommend/WebResults.phtml @@ -5,17 +5,9 @@ <ul class="similar"> <? foreach ($results as $driver): ?> <li> - <a href="<?=$this->escapeHtmlAttr($driver->getUrl())?>" class="title"><? - $summHighlightedTitle = $driver->getHighlightedTitle(); - $summTitle = $driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a href="<?=$this->escapeHtmlAttr($driver->getUrl())?>" class="title"> + <?=$this->record($driver)->getTitleHtml()?> + </a> <? $snippet = $driver->getHighlightedSnippet(); ?> <? $summary = $driver->getSummary(); ?> <? if (!empty($snippet)): ?> diff --git a/themes/blueprint/templates/RecordDriver/LibGuides/result-list.phtml b/themes/blueprint/templates/RecordDriver/LibGuides/result-list.phtml index f956d8d46df..531097ffc94 100644 --- a/themes/blueprint/templates/RecordDriver/LibGuides/result-list.phtml +++ b/themes/blueprint/templates/RecordDriver/LibGuides/result-list.phtml @@ -3,14 +3,9 @@ ?> <div class="listentry span-15"> <div class="resultItemLine1"> - <a href="<?=$this->escapeHtmlAttr($url)?>" class="title"><? - $summTitle = $this->driver->getTitle(); - if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a href="<?=$this->escapeHtmlAttr($url)?>" class="title"> + <?=$this->record($this->driver)->getTitleHtml()?> + </a> </div> </div> <div class="clearer"></div> \ No newline at end of file diff --git a/themes/blueprint/templates/RecordDriver/Pazpar2/result-list.phtml b/themes/blueprint/templates/RecordDriver/Pazpar2/result-list.phtml index 20c98d30a59..dc4e1f3170b 100644 --- a/themes/blueprint/templates/RecordDriver/Pazpar2/result-list.phtml +++ b/themes/blueprint/templates/RecordDriver/Pazpar2/result-list.phtml @@ -9,17 +9,9 @@ </div> <div class="span-9"> <div class="resultItemLine1"> - <b class="title"><? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></b> + <b class="title"> + <?=$this->record($this->driver)->getTitleHtml()?> + </b> </div> <div class="resultItemLine2"> diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/list-entry.phtml b/themes/blueprint/templates/RecordDriver/SolrDefault/list-entry.phtml index 2d72d6eed56..3faf6ac5961 100644 --- a/themes/blueprint/templates/RecordDriver/SolrDefault/list-entry.phtml +++ b/themes/blueprint/templates/RecordDriver/SolrDefault/list-entry.phtml @@ -20,14 +20,9 @@ <? endif; ?> </div> <div class="span-10"> - <a href="<?=$this->recordLink()->getUrl($this->driver)?>" class="title"><? - $listTitle = $this->driver->getTitle(); - if (!empty($listTitle)) { - echo $this->escapeHtml($this->truncate($listTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a><br/> + <a href="<?=$this->recordLink()->getUrl($this->driver)?>" class="title"> + <?=$this->record($this->driver)->getTitleHtml()?> + </a><br/> <? $listAuthor = $this->driver->getPrimaryAuthor(); if (!empty($listAuthor)): ?> <?=$this->transEsc('by')?>: <a href="<?=$this->record($this->driver)->getLink('author', $listAuthor)?>"><?=$this->escapeHtml($listAuthor)?></a><br/> diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/result-grid.phtml b/themes/blueprint/templates/RecordDriver/SolrDefault/result-grid.phtml index 5031504dbf7..40fcfd8082d 100644 --- a/themes/blueprint/templates/RecordDriver/SolrDefault/result-grid.phtml +++ b/themes/blueprint/templates/RecordDriver/SolrDefault/result-grid.phtml @@ -12,17 +12,9 @@ </a> </span> <div class="gridTitleBox" > - <a class="gridTitle" href="<?=$this->recordLink()->getUrl($this->driver)?>"><? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 80)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a class="gridTitle" href="<?=$this->recordLink()->getUrl($this->driver)?>"> + <?=$this->record($this->driver)->getTitleHtml(80)?> + </a> <? /* We need to find out if we're supposed to display an OpenURL link ($openUrlActive), but even if we don't plan to display the link, we still want to get the $openUrl value for use in generating a COinS (Z3988) tag -- see bottom of file. diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml b/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml index b76affe451d..816b068ea4f 100644 --- a/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml +++ b/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml @@ -11,17 +11,9 @@ </div> <div class="span-9"> <div class="resultItemLine1"> - <a href="<?=$this->recordLink()->getUrl($this->driver)?>" class="title"><? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a href="<?=$this->recordLink()->getUrl($this->driver)?>" class="title"> + <?=$this->record($this->driver)->getTitleHtml()?> + </a> </div> <div class="resultItemLine2"> diff --git a/themes/blueprint/templates/RecordDriver/SolrWeb/result-list.phtml b/themes/blueprint/templates/RecordDriver/SolrWeb/result-list.phtml index f9e9fc43193..b0a979dd74d 100644 --- a/themes/blueprint/templates/RecordDriver/SolrWeb/result-list.phtml +++ b/themes/blueprint/templates/RecordDriver/SolrWeb/result-list.phtml @@ -3,17 +3,9 @@ ?> <div class="listentry span-15"> <div class="resultItemLine1"> - <a href="<?=$this->escapeHtmlAttr($url)?>" class="title"><? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a href="<?=$this->escapeHtmlAttr($url)?>" class="title"> + <?=$this->record($this->driver)->getTitleHtml()?> + </a> </div> <div class="resultItemLine2"> diff --git a/themes/bootstrap3/templates/Recommend/CatalogResults.phtml b/themes/bootstrap3/templates/Recommend/CatalogResults.phtml index ef27b679408..6b168699983 100644 --- a/themes/bootstrap3/templates/Recommend/CatalogResults.phtml +++ b/themes/bootstrap3/templates/Recommend/CatalogResults.phtml @@ -5,17 +5,7 @@ <li class="list-group-item catalog-result"> <? $formats = $driver->getFormats(); $format = isset($formats[0]) ? $formats[0] : ''; ?> <a href="<?=$this->recordLink()->getUrl($driver)?>" class="title <?=$this->record($driver)->getFormatClass($format)?>"> - <? - $summHighlightedTitle = $driver->getHighlightedTitle(); - $summTitle = $driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?> + <?=$this->record($driver)->getTitleHtml()?> </a> <? $summDate = $driver->getPublicationDates(); ?> <? $summAuthor = $driver->getPrimaryAuthor(); ?> diff --git a/themes/bootstrap3/templates/Recommend/RandomRecommend.phtml b/themes/bootstrap3/templates/Recommend/RandomRecommend.phtml index 9c83e95d804..550b040d61a 100644 --- a/themes/bootstrap3/templates/Recommend/RandomRecommend.phtml +++ b/themes/bootstrap3/templates/Recommend/RandomRecommend.phtml @@ -27,17 +27,7 @@ <? $formats = $driver->getFormats(); $format = isset($formats[0]) ? $formats[0] : ''; ?> <a href="<?=$this->recordLink()->getUrl($driver)?>" class="title <?=$this->record($driver)->getFormatClass($format)?> clearfix"> - <? - $summHighlightedTitle = $driver->getHighlightedTitle(); - $summTitle = $driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?> + <?=$this->record($driver)->getTitleHtml()?> <? $summAuthor = $driver->getPrimaryAuthor(); ?> <span class="small<? if (!empty($summAuthor)): ?> pull-right<? endif; ?>"> <? $summDate = $driver->getPublicationDates(); ?> diff --git a/themes/bootstrap3/templates/Recommend/SummonResults.phtml b/themes/bootstrap3/templates/Recommend/SummonResults.phtml index 1995f77ab7a..93918cd32d6 100644 --- a/themes/bootstrap3/templates/Recommend/SummonResults.phtml +++ b/themes/bootstrap3/templates/Recommend/SummonResults.phtml @@ -6,17 +6,7 @@ <span> <? $formats = $driver->getFormats(); $format = isset($formats[0]) ? $formats[0] : ''; ?> <a href="<?=$this->recordLink()->getUrl($driver)?>" class="title <?=$this->record($driver)->getFormatClass($format)?>"> - <? - $summHighlightedTitle = $driver->getHighlightedTitle(); - $summTitle = $driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?> + <?=$this->record($driver)->getTitleHtml()?> </a> <? $summAuthor = $driver->getPrimaryAuthor(); if (!empty($summAuthor)): ?> <span class="small"> diff --git a/themes/bootstrap3/templates/Recommend/WebResults.phtml b/themes/bootstrap3/templates/Recommend/WebResults.phtml index 701bd836951..055b21a3617 100644 --- a/themes/bootstrap3/templates/Recommend/WebResults.phtml +++ b/themes/bootstrap3/templates/Recommend/WebResults.phtml @@ -5,17 +5,9 @@ <ul class="similar"> <? foreach ($results as $driver): ?> <li> - <a href="<?=$this->escapeHtmlAttr($driver->getUrl())?>" class="title"><? - $summHighlightedTitle = $driver->getHighlightedTitle(); - $summTitle = $driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a href="<?=$this->escapeHtmlAttr($driver->getUrl())?>" class="title"> + <?=$this->record($driver)->getTitleHtml()?> + </a> <? $snippet = $driver->getHighlightedSnippet(); ?> <? $summary = $driver->getSummary(); ?> <? if (!empty($snippet)): ?> diff --git a/themes/bootstrap3/templates/RecordDriver/LibGuides/result-list.phtml b/themes/bootstrap3/templates/RecordDriver/LibGuides/result-list.phtml index 7e2fbc62fb0..eda74148212 100644 --- a/themes/bootstrap3/templates/RecordDriver/LibGuides/result-list.phtml +++ b/themes/bootstrap3/templates/RecordDriver/LibGuides/result-list.phtml @@ -3,13 +3,8 @@ ?> <div class="listentry col-xs-11"> <div class="resultItemLine1"> - <a href="<?=$this->escapeHtmlAttr($url)?>" class="title"><? - $summTitle = $this->driver->getTitle(); - if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a href="<?=$this->escapeHtmlAttr($url)?>" class="title"> + <?=$this->record($this->driver)->getTitleHtml()?> + </a> </div> </div> \ No newline at end of file diff --git a/themes/bootstrap3/templates/RecordDriver/Pazpar2/result-list.phtml b/themes/bootstrap3/templates/RecordDriver/Pazpar2/result-list.phtml index 986197b7971..101a4a69a2f 100644 --- a/themes/bootstrap3/templates/RecordDriver/Pazpar2/result-list.phtml +++ b/themes/bootstrap3/templates/RecordDriver/Pazpar2/result-list.phtml @@ -10,17 +10,9 @@ </div> <div class="col-sm-10 col-xs-9 middle"> <div> - <b><? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></b> + <b> + <?=$this->record($this->driver)->getTitleHtml()?> + </b> </div> <div> diff --git a/themes/bootstrap3/templates/RecordDriver/SolrDefault/list-entry.phtml b/themes/bootstrap3/templates/RecordDriver/SolrDefault/list-entry.phtml index 3f378ca3cd1..6db22f3fde9 100644 --- a/themes/bootstrap3/templates/RecordDriver/SolrDefault/list-entry.phtml +++ b/themes/bootstrap3/templates/RecordDriver/SolrDefault/list-entry.phtml @@ -25,17 +25,8 @@ <div class="col-xs-6 middle"> <div class="resultItemLine1"> <a href="<?=$this->recordLink()->getUrl($this->driver)?>"> - <? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <?=$this->record($this->driver)->getTitleHtml()?> + </a> </div> <div class="resultItemLine2"> diff --git a/themes/bootstrap3/templates/RecordDriver/SolrDefault/result-grid.phtml b/themes/bootstrap3/templates/RecordDriver/SolrDefault/result-grid.phtml index 67c96dee649..f0271bedabc 100644 --- a/themes/bootstrap3/templates/RecordDriver/SolrDefault/result-grid.phtml +++ b/themes/bootstrap3/templates/RecordDriver/SolrDefault/result-grid.phtml @@ -31,17 +31,9 @@ $urls = $this->record($this->driver)->getLinkDetails(); <? endif; ?> <? endif; ?> <div> - <a class="title" href="<?=$this->recordLink()->getUrl($this->driver)?>"><? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 80)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a class="title" href="<?=$this->recordLink()->getUrl($this->driver)?>"> + <?=$this->record($this->driver)->getTitleHtml(80)?> + </a> <? if ($openUrlActive || !empty($urls)): ?> <br/><br/> <? if ($openUrlActive): ?> diff --git a/themes/bootstrap3/templates/RecordDriver/SolrDefault/result-list.phtml b/themes/bootstrap3/templates/RecordDriver/SolrDefault/result-list.phtml index c9e2be7d15e..4327aaeeab5 100644 --- a/themes/bootstrap3/templates/RecordDriver/SolrDefault/result-list.phtml +++ b/themes/bootstrap3/templates/RecordDriver/SolrDefault/result-list.phtml @@ -14,17 +14,7 @@ <div class="col-sm-7 col-xs-6 middle"> <div> <a href="<?=$this->recordLink()->getUrl($this->driver)?>" class="title"> - <? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?> + <?=$this->record($this->driver)->getTitleHtml()?> </a> </div> diff --git a/themes/bootstrap3/templates/RecordDriver/SolrWeb/result-list.phtml b/themes/bootstrap3/templates/RecordDriver/SolrWeb/result-list.phtml index b5a0ecd1342..0e7e5c518cf 100644 --- a/themes/bootstrap3/templates/RecordDriver/SolrWeb/result-list.phtml +++ b/themes/bootstrap3/templates/RecordDriver/SolrWeb/result-list.phtml @@ -3,17 +3,9 @@ ?> <div class="listentry col-xs-11"> <div class="resultItemLine1"> - <a href="<?=$this->escapeHtmlAttr($url)?>" class="title"><? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></a> + <a href="<?=$this->escapeHtmlAttr($url)?>" class="title"> + <?=$this->record($this->driver)->getTitleHtml()?> + </a> </div> <div class="resultItemLine2"> diff --git a/themes/jquerymobile/templates/RecordDriver/LibGuides/result-list.phtml b/themes/jquerymobile/templates/RecordDriver/LibGuides/result-list.phtml index 66ce9ddb275..df1627a06f5 100644 --- a/themes/jquerymobile/templates/RecordDriver/LibGuides/result-list.phtml +++ b/themes/jquerymobile/templates/RecordDriver/LibGuides/result-list.phtml @@ -3,13 +3,6 @@ ?> <a rel="external" href="<?=$this->escapeHtmlAttr($url)?>"> <div class="result"> - <h3><? - $summTitle = $this->driver->getTitle(); - if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></h3> + <h3><?=$this->record($this->driver)->getTitleHtml()?></h3> </div> </a> diff --git a/themes/jquerymobile/templates/RecordDriver/Pazpar2/result-list.phtml b/themes/jquerymobile/templates/RecordDriver/Pazpar2/result-list.phtml index 10a10b6b568..ca0a884fca3 100644 --- a/themes/jquerymobile/templates/RecordDriver/Pazpar2/result-list.phtml +++ b/themes/jquerymobile/templates/RecordDriver/Pazpar2/result-list.phtml @@ -1,17 +1,7 @@ <b> <div class="result source<?=$this->escapeHtmlAttr($this->driver->getResourceSource())?> recordId<?=$this->driver->supportsAjaxStatus()?' ajaxItemId':''?>"> <input type="hidden" value="<?=$this->escapeHtmlAttr($this->driver->getUniqueID())?>" class="hiddenId" /> - <h3><? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></h3> + <h3><?=$this->record($this->driver)->getTitleHtml()?></h3> <? $summAuthor = $this->driver->getPrimaryAuthor(); if (!empty($summAuthor)): ?> <p><?=$this->transEsc('by')?> <? $summHighlightedAuthor = $this->driver->getHighlightedAuthor(); diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/list-entry.phtml b/themes/jquerymobile/templates/RecordDriver/SolrDefault/list-entry.phtml index 056f5a0e3d0..bd2c8e7b4bd 100644 --- a/themes/jquerymobile/templates/RecordDriver/SolrDefault/list-entry.phtml +++ b/themes/jquerymobile/templates/RecordDriver/SolrDefault/list-entry.phtml @@ -13,16 +13,7 @@ <a rel="external" href="<?=$this->recordLink()->getUrl($this->driver)?>"> <div class="result source<?=$this->escapeHtmlAttr($this->driver->getResourceSource())?> recordId<?=$this->driver->supportsAjaxStatus()?' ajaxItemId':''?>"> <input type="hidden" value="<?=$this->escapeHtmlAttr($this->driver->getUniqueID())?>" class="hiddenId" /> - <h3> - <? - $listTitle = $this->driver->getTitle(); - if (!empty($listTitle)) { - echo $this->escapeHtml($this->truncate($listTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?> - </h3> + <h3><?=$this->record($this->driver)->getTitleHtml()?></h3> <? $listAuthor = $this->driver->getPrimaryAuthor(); if (!empty($listAuthor)): ?> <p><?=$this->transEsc('by')?> <?=$this->escapeHtml($listAuthor)?></p> <? endif; ?> diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/result-list.phtml b/themes/jquerymobile/templates/RecordDriver/SolrDefault/result-list.phtml index ce04278048f..31c5f2e60a9 100644 --- a/themes/jquerymobile/templates/RecordDriver/SolrDefault/result-list.phtml +++ b/themes/jquerymobile/templates/RecordDriver/SolrDefault/result-list.phtml @@ -1,17 +1,7 @@ <a rel="external" href="<?=$this->recordLink()->getUrl($this->driver)?>"> <div class="result source<?=$this->escapeHtmlAttr($this->driver->getResourceSource())?> recordId<?=$this->driver->supportsAjaxStatus()?' ajaxItemId':''?>"> <input type="hidden" value="<?=$this->escapeHtmlAttr($this->driver->getUniqueID())?>" class="hiddenId" /> - <h3><? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></h3> + <h3><?=$this->record($this->driver)->getTitleHtml()?></h3> <? $summAuthor = $this->driver->getPrimaryAuthor(); if (!empty($summAuthor)): ?> <p><?=$this->transEsc('by')?> <? $summHighlightedAuthor = $this->driver->getHighlightedAuthor(); diff --git a/themes/jquerymobile/templates/RecordDriver/SolrWeb/result-list.phtml b/themes/jquerymobile/templates/RecordDriver/SolrWeb/result-list.phtml index c1bcfddbdd9..b205c9e8719 100644 --- a/themes/jquerymobile/templates/RecordDriver/SolrWeb/result-list.phtml +++ b/themes/jquerymobile/templates/RecordDriver/SolrWeb/result-list.phtml @@ -3,17 +3,7 @@ ?> <a rel="external" href="<?=$this->escapeHtmlAttr($url)?>"> <div class="result"> - <h3><? - $summHighlightedTitle = $this->driver->getHighlightedTitle(); - $summTitle = $this->driver->getTitle(); - if (!empty($summHighlightedTitle)) { - echo $this->highlight($this->addEllipsis($summHighlightedTitle, $summTitle)); - } else if (!empty($summTitle)) { - echo $this->escapeHtml($this->truncate($summTitle, 180)); - } else { - echo $this->transEsc('Title not available'); - } - ?></h3> + <h3><?=$this->record($this->driver)->getTitleHtml()?></h3> </div> <? $snippet = $this->driver->getHighlightedSnippet(); ?> <? $summary = $this->driver->getSummary(); ?> -- GitLab