diff --git a/module/VuFind/src/VuFind/Recommend/AuthorFacets.php b/module/VuFind/src/VuFind/Recommend/AuthorFacets.php index 8a96c93ef08c9ad2da9cdce321d8ec4364555c5b..7acf6eb355f38653a30f49ff2edc332b7976ea7f 100644 --- a/module/VuFind/src/VuFind/Recommend/AuthorFacets.php +++ b/module/VuFind/src/VuFind/Recommend/AuthorFacets.php @@ -100,6 +100,16 @@ class AuthorFacets implements RecommendInterface $this->results = $results; } + /** + * Get results stored in the object. + * + * @return \VuFind\Search\Base\Results + */ + public function getResults() + { + return $this->results; + } + /** * Returns search term. * diff --git a/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php b/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php index e68c1558b350668846b335a9d9bd4f5679b4e0fa..2307403077d46981a64d07cd8b15ab2e0020f5ed 100644 --- a/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php +++ b/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php @@ -55,7 +55,8 @@ class AuthorityRecommend implements RecommendInterface protected $searchObject; protected $lookfor; protected $filters = array(); - protected $results = array(); + protected $results; + protected $recommendations = array(); /** * setConfig @@ -109,6 +110,8 @@ class AuthorityRecommend implements RecommendInterface */ public function process($results) { + $this->results = $results; + // function will return blank on Advanced Search if ($results->getParams()->getSearchType()== 'advanced') { return; @@ -155,8 +158,8 @@ class AuthorityRecommend implements RecommendInterface ); // check for duplicates before adding record to recordSet - if (!$this->inArrayR($recordArray['heading'], $this->results)) { - array_push($this->results, $recordArray); + if (!$this->inArrayR($recordArray['heading'], $this->recommendations)) { + array_push($this->recommendations, $recordArray); } else { continue; } @@ -164,10 +167,20 @@ class AuthorityRecommend implements RecommendInterface } /** - * Get results (for use in the view). + * Get recommendations (for use in the view). * * @return array */ + public function getRecommendations() + { + return $this->recommendations; + } + + /** + * Get results stored in the object. + * + * @return \VuFind\Search\Base\Results + */ public function getResults() { return $this->results; @@ -183,7 +196,7 @@ class AuthorityRecommend implements RecommendInterface * * @return bool */ - public function inArrayR($needle, $haystack) + protected function inArrayR($needle, $haystack) { foreach ($haystack as $v) { if ($needle == $v) { diff --git a/module/VuFind/src/VuFind/Recommend/SideFacets.php b/module/VuFind/src/VuFind/Recommend/SideFacets.php index 9460e96c322bb1840108062bfcdc03378bc476a3..20e3c29d9171da58da98d1987cbcc8216f48d6c8 100644 --- a/module/VuFind/src/VuFind/Recommend/SideFacets.php +++ b/module/VuFind/src/VuFind/Recommend/SideFacets.php @@ -161,4 +161,14 @@ class SideFacets implements RecommendInterface } return $result; } + + /** + * Get results stored in the object. + * + * @return \VuFind\Search\Base\Results + */ + public function getResults() + { + return $this->results; + } } diff --git a/module/VuFind/src/VuFind/Recommend/SwitchType.php b/module/VuFind/src/VuFind/Recommend/SwitchType.php index 85c080511a57e6391ed8d87f3a182d7386f4954b..1ff9cc97b45370b67a135802b723f3b120f951f8 100644 --- a/module/VuFind/src/VuFind/Recommend/SwitchType.php +++ b/module/VuFind/src/VuFind/Recommend/SwitchType.php @@ -45,6 +45,7 @@ class SwitchType implements RecommendInterface protected $newHandler; // search handler to try protected $newHandlerName; // on-screen description of handler protected $active; // is this module active? + protected $results; // results object /** * setConfig @@ -94,6 +95,7 @@ class SwitchType implements RecommendInterface public function process($results) { $handler = $results->getParams()->getSearchHandler(); + $this->results = $results; // If the handler is null, we can't figure out a single handler, so this // is probably an advanced search. In that case, we shouldn't try to change @@ -103,6 +105,16 @@ class SwitchType implements RecommendInterface $this->active = (!is_null($handler) && $handler != $this->newHandler); } + /** + * Get results stored in the object. + * + * @return \VuFind\Search\Base\Results + */ + public function getResults() + { + return $this->results; + } + /** * Get the new search handler, or false if it does not apply. * diff --git a/module/VuFind/src/VuFind/Recommend/TopFacets.php b/module/VuFind/src/VuFind/Recommend/TopFacets.php index 304848eb8e318492735f419d14af3f5589e10873..1570e76d2ad586785d343ff69b72cdd6d8ec7ef3 100644 --- a/module/VuFind/src/VuFind/Recommend/TopFacets.php +++ b/module/VuFind/src/VuFind/Recommend/TopFacets.php @@ -116,6 +116,16 @@ class TopFacets implements RecommendInterface $this->results = $results; } + /** + * Get results stored in the object. + * + * @return \VuFind\Search\Base\Results + */ + public function getResults() + { + return $this->results; + } + /** * Get facet information taken from the search. * diff --git a/themes/blueprint/templates/Recommend/AuthorFacets.phtml b/themes/blueprint/templates/Recommend/AuthorFacets.phtml index 0838ef5a237a3f62727c95309cc04f4717b0681c..a7b3d2cd13c2cacd1e8c2ebe67d3e77abb9f67f5 100644 --- a/themes/blueprint/templates/Recommend/AuthorFacets.phtml +++ b/themes/blueprint/templates/Recommend/AuthorFacets.phtml @@ -1,4 +1,4 @@ -<? if ($this->results->getResultTotal() > 0): ?> +<? if ($this->recommend->getResults()->getResultTotal() > 0): ?> <? $similarAuthors = $this->recommend->getSimilarAuthors(); ?> <? if (!empty($similarAuthors['list'])): ?> <div class="authorbox"> diff --git a/themes/blueprint/templates/Recommend/AuthorityRecommend.phtml b/themes/blueprint/templates/Recommend/AuthorityRecommend.phtml index d8dabd54d18f56543baa13dfb412d74c3bdd6442..5a7cbdbfb8b3d7804150cb462e2d4a0daaa15619 100644 --- a/themes/blueprint/templates/Recommend/AuthorityRecommend.phtml +++ b/themes/blueprint/templates/Recommend/AuthorityRecommend.phtml @@ -1,12 +1,16 @@ -<? $data = $this->recommend->getResults(); if (is_array($data) && !empty($data)): ?> +<? + $data = $this->recommend->getRecommendations(); + $results = $this->recommend->getResults(); +?> +<? if (is_array($data) && !empty($data)): ?> <div class="authoritybox"> <div><strong><?=$this->transEsc('See also')?>:</strong></div> <div> <? for ($i = 0; $i < count($data); $i++): ?> <? // Generate a new search URL that replaces the user's current term with the authority term: - $url = $this->url($this->results->getOptions()->getSearchAction()) - . $this->results->getUrlQuery()->replaceTerm($this->results->getParams()->getDisplayQuery(), $data[$i]['heading']); + $url = $this->url($results->getOptions()->getSearchAction()) + . $results->getUrlQuery()->replaceTerm($results->getParams()->getDisplayQuery(), $data[$i]['heading']); ?> <a href="<?=$url?>"><?=$this->escapeHtml($data[$i]['heading'])?></a><? if ($i != count($data) - 1): ?>, <? endif; ?> <? endfor; ?> diff --git a/themes/blueprint/templates/Recommend/FavoriteFacets.phtml b/themes/blueprint/templates/Recommend/FavoriteFacets.phtml index 3ca5f5e814ba35d7945e496d2810b0f84384b37b..802c9a48293564737555aeac8a8504948b3f1270 100644 --- a/themes/blueprint/templates/Recommend/FavoriteFacets.phtml +++ b/themes/blueprint/templates/Recommend/FavoriteFacets.phtml @@ -1,3 +1,4 @@ +<? $results = $this->recommend->getResults(); ?> <div class="sidegroup"> <? $sideFacetSet = $this->recommend->getFacetSet(); ?> @@ -22,14 +23,14 @@ <? if (isset($sideFacetSet['tags']) && !empty($sideFacetSet['tags']['list'])): ?> <div class="sidegroup"> <h4 class="tag"><?=$this->transEsc($sideFacetSet['tags']['label'])?></h4> - <? $filterList = $this->results->getParams()->getFilterList(true); + <? $filterList = $results->getParams()->getFilterList(true); $tagFilterList = isset($filterList[$sideFacetSet['tags']['label']]) ? $filterList[$sideFacetSet['tags']['label']] : null; if (!empty($tagFilterList)): ?> <strong><?=$this->transEsc('Remove Filters')?></strong> <ul class="filters"> <? $field = $sideFacetSet['tags']['label']; foreach ($tagFilterList as $filter): ?> - <? $removeLink = $this->currentPath().$this->results->getUrlQuery()->removeFacet($filter['field'], $filter['value']); ?> + <? $removeLink = $this->currentPath().$results->getUrlQuery()->removeFacet($filter['field'], $filter['value']); ?> <li> <a href="<?=$removeLink?>"><img src="<?=$this->imageLink('silk/delete.png')?>" alt="<?=$this->transEsc('Delete') ?>"/></a> <a href="<?=$removeLink?>"><?=$this->transEsc($field)?>: <?=$this->escapeHtml($filter['displayText'])?></a> @@ -43,7 +44,7 @@ <? if ($thisFacet['isApplied']): ?> <?=$this->escapeHtml($thisFacet['displayText'])?> <img src="<?=$this->imageLink('silk/tick.png')?>" alt="<?=$this->transEsc('Selected') ?>"/> <? else: ?> - <a href="<?=$this->currentPath().$this->results->getUrlQuery()->addFacet('tags', $thisFacet['value'])?>"><?=$this->escapeHtml($thisFacet['displayText'])?></a> (<?=$this->escapeHtml($thisFacet['count'])?>) + <a href="<?=$this->currentPath().$results->getUrlQuery()->addFacet('tags', $thisFacet['value'])?>"><?=$this->escapeHtml($thisFacet['displayText'])?></a> (<?=$this->escapeHtml($thisFacet['count'])?>) <? endif; ?> </li> <? endforeach; ?> diff --git a/themes/blueprint/templates/Recommend/SideFacets.phtml b/themes/blueprint/templates/Recommend/SideFacets.phtml index 05c969d175c7394155df961e66961c53efd00893..42646d34a009e15a0bdc7325e9989644fd4683d6 100644 --- a/themes/blueprint/templates/Recommend/SideFacets.phtml +++ b/themes/blueprint/templates/Recommend/SideFacets.phtml @@ -1,22 +1,23 @@ +<? $results = $this->recommend->getResults(); ?> <div class="sidegroup"> - <? if ($this->results->getResultTotal() > 0): ?><h4><?=$this->transEsc('Narrow Search')?></h4><? endif; ?> - <? $checkboxFilters = $this->results->getParams()->getCheckboxFacets(); if (count($checkboxFilters) > 0): ?> + <? if ($results->getResultTotal() > 0): ?><h4><?=$this->transEsc('Narrow Search')?></h4><? endif; ?> + <? $checkboxFilters = $results->getParams()->getCheckboxFacets(); if (count($checkboxFilters) > 0): ?> <? foreach ($checkboxFilters as $current): ?> - <div class="checkboxFilter<?=($this->results->getResultTotal() < 1 && !$current['selected'] && !$current['alwaysVisible']) ? ' hide' : ''?>"> + <div class="checkboxFilter<?=($results->getResultTotal() < 1 && !$current['selected'] && !$current['alwaysVisible']) ? ' hide' : ''?>"> <input type="checkbox" name="filter[]" value="<?=$this->escapeHtml($current['filter'])?>" <?=$current['selected'] ? 'checked="checked"' : ''?> id="<?=$this->escapeHtml(str_replace(' ', '', $current['desc']))?>" - onclick="document.location.href='<?=$current['selected'] ? $this->results->getUrlQuery()->removeFilter($current['filter']) : $this->results->getUrlQuery()->addFilter($current['filter'])?>';" /> + onclick="document.location.href='<?=$current['selected'] ? $results->getUrlQuery()->removeFilter($current['filter']) : $results->getUrlQuery()->addFilter($current['filter'])?>';" /> <label for="<?=$this->escapeHtml(str_replace(' ', '', $current['desc']))?>"><?=$this->transEsc($current['desc'])?></label> </div> <? endforeach; ?> <? endif; ?> - <? $filterList = $this->results->getParams()->getFilterList(true); if (!empty($filterList)): ?> + <? $filterList = $results->getParams()->getFilterList(true); if (!empty($filterList)): ?> <strong><?=$this->transEsc('Remove Filters')?></strong> <ul class="filters"> <? foreach ($filterList as $field => $filters): ?> <? foreach ($filters as $filter): ?> <? - $removeLink = $this->currentPath().$this->results->getUrlQuery()->removeFacet($filter['field'], $filter['value']); + $removeLink = $this->currentPath().$results->getUrlQuery()->removeFacet($filter['field'], $filter['value']); if ($filter['displayText'] == '[* TO *]') $filter['displayText'] = $this->translate('filter_wildcard'); ?> <li> @@ -28,12 +29,12 @@ </ul> <? endif; ?> <? $sideFacetSet = $this->recommend->getFacetSet(); $dateFacets = $this->recommend->getDateFacets(); ?> - <? if (!empty($sideFacetSet) && $this->results->getResultTotal() > 0): ?> + <? if (!empty($sideFacetSet) && $results->getResultTotal() > 0): ?> <? foreach ($sideFacetSet as $title => $cluster): ?> <? if (isset($dateFacets[$title])): ?> <? /* Load the publication date slider UI widget */ $this->headScript()->appendFile('pubdate_slider.js'); ?> <form action="" name="<?=$this->escapeHtml($title)?>Filter" id="<?=$this->escapeHtml($title)?>Filter"> - <?=$this->results->getUrlQuery()->asHiddenFields(array('filter' => "/^{$title}:.*/"))?> + <?=$results->getUrlQuery()->asHiddenFields(array('filter' => "/^{$title}:.*/"))?> <input type="hidden" name="daterange[]" value="<?=$this->escapeHtml($title)?>"/> <fieldset class="publishDateLimit" id="<?=$this->escapeHtml($title)?>"> <legend><?=$this->transEsc($cluster['label'])?></legend> @@ -57,7 +58,7 @@ <? if ($thisFacet['isApplied']): ?> <dd><?=$this->escapeHtml($thisFacet['displayText'])?> <img src="<?=$this->imageLink('silk/tick.png')?>" alt="Selected"/></dd> <? else: ?> - <dd><a href="<?=$this->currentPath().$this->results->getUrlQuery()->addFacet($title, $thisFacet['value'])?>"><?=$this->escapeHtml($thisFacet['displayText'])?></a> (<?=$this->escapeHtml($thisFacet['count'])?>)</dd> + <dd><a href="<?=$this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'])?>"><?=$this->escapeHtml($thisFacet['displayText'])?></a> (<?=$this->escapeHtml($thisFacet['count'])?>)</dd> <? endif; ?> <? endforeach; ?> <? if ($i > 5): ?><dd><a href="#" onclick="lessFacets('<?=$this->escapeHtml($title)?>'); return false;"><?=$this->transEsc('less')?> ...</a></dd><? endif; ?> diff --git a/themes/blueprint/templates/Recommend/SwitchType.phtml b/themes/blueprint/templates/Recommend/SwitchType.phtml index 7129a776b2ca55505ccf9d9e9c3f691059c63df6..48bf99dce3722173bf2a92fc20b228ca8e44946d 100644 --- a/themes/blueprint/templates/Recommend/SwitchType.phtml +++ b/themes/blueprint/templates/Recommend/SwitchType.phtml @@ -1,6 +1,6 @@ <? if ($handler = $this->recommend->getNewHandler()): ?> <div class="info"> <?=$this->transEsc('widen_prefix')?> - <a href="<?=$this->results->getUrlQuery()->setHandler($handler)?>"><?=$this->transEsc($this->recommend->getNewHandlerName())?></a>. + <a href="<?=$this->recommend->getResults()->getUrlQuery()->setHandler($handler)?>"><?=$this->transEsc($this->recommend->getNewHandlerName())?></a>. </div> <? endif; ?> \ No newline at end of file diff --git a/themes/blueprint/templates/Recommend/TopFacets.phtml b/themes/blueprint/templates/Recommend/TopFacets.phtml index be69c21f460518bb4dc1e335126b1a1b6961cb94..ac4154c9b0b89f1ec99ae07c4731cd28857bc93d 100644 --- a/themes/blueprint/templates/Recommend/TopFacets.phtml +++ b/themes/blueprint/templates/Recommend/TopFacets.phtml @@ -20,7 +20,7 @@ <? if ($thisFacet['isApplied']): ?> <?=$this->escapeHtml($thisFacet['displayText'])?> <img src="<?=$this->imageLink('silk/tick.png')?>" alt="<?=$this->transEsc('Selected') ?>"/> <? else: ?> - <a href="<?=$this->currentPath().$this->results->getUrlQuery()->addFacet($title, $thisFacet['value'])?>"><?=$this->escapeHtml($thisFacet['displayText'])?></a> (<?=$thisFacet['count'] ?>) + <a href="<?=$this->currentPath().$this->recommend->getResults()->getUrlQuery()->addFacet($title, $thisFacet['value'])?>"><?=$this->escapeHtml($thisFacet['displayText'])?></a> (<?=$thisFacet['count'] ?>) <? endif; ?> </span> <? if (count($cluster['list']) > $corner && $iter == count($cluster['list'])): ?> diff --git a/themes/jquerymobile/templates/Recommend/SideFacets-dialog.phtml b/themes/jquerymobile/templates/Recommend/SideFacets-dialog.phtml index 117650dae8d4319a651b8d65d784d3bcbb4e52e3..9247bc0ee419816a6c8fe89bc60056817919f261 100644 --- a/themes/jquerymobile/templates/Recommend/SideFacets-dialog.phtml +++ b/themes/jquerymobile/templates/Recommend/SideFacets-dialog.phtml @@ -1,5 +1,8 @@ -<? $sideFacetSet = $this->recommend->getFacetSet(); ?> -<? if (!empty($sideFacetSet) && $this->results->getResultTotal() > 0): ?> +<? + $results = $this->recommend->getResults(); + $sideFacetSet = $this->recommend->getFacetSet(); +?> +<? if (!empty($sideFacetSet) && $results->getResultTotal() > 0): ?> <div data-role="dialog" id="Search-narrow"> <div data-role="header" data-theme="d" data-position="inline"> <h1><?=$this->transEsc('Narrow Search')?></h1> @@ -15,7 +18,7 @@ <? if ($thisFacet['isApplied']): ?> <li data-icon="check" class="checked"><a href="" data-rel="back"><?=$this->escapeHtml($thisFacet['displayText'])?></a> <span class="ui-li-count"><?=$this->escapeHtml($thisFacet['count'])?></span></li> <? else: ?> - <li><a rel="external" href="<?=$this->currentPath().$this->results->getUrlQuery()->addFacet($title, $thisFacet['value'])?>"><?=$this->escapeHtml($thisFacet['displayText'])?></a> <span class="ui-li-count"><?=$this->escapeHtml($thisFacet['count'])?></span></li> + <li><a rel="external" href="<?=$this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'])?>"><?=$this->escapeHtml($thisFacet['displayText'])?></a> <span class="ui-li-count"><?=$this->escapeHtml($thisFacet['count'])?></span></li> <? endif; ?> <? endforeach; ?> </ul> diff --git a/themes/jquerymobile/templates/Recommend/SideFacets.phtml b/themes/jquerymobile/templates/Recommend/SideFacets.phtml index c0aa056738532408af1c60b266208a0271f05aee..361f90c5d235e81387fe8fb0d7da0d48e08c225f 100644 --- a/themes/jquerymobile/templates/Recommend/SideFacets.phtml +++ b/themes/jquerymobile/templates/Recommend/SideFacets.phtml @@ -1,10 +1,11 @@ -<? $filterList = $this->results->getParams()->getFilterList(true); if (!empty($filterList)): ?> +<? $results = $this->recommend->getResults(); ?> +<? $filterList = $results->getParams()->getFilterList(true); if (!empty($filterList)): ?> <ul class="filters" data-role="listview" data-inset="true" data-dividertheme="e"> <li data-role="list-divider"><?=$this->transEsc('adv_search_filters')?></li> <? $i = 0; foreach ($filterList as $field => $filters): ?> <? foreach ($filters as $filter): ?> <? - $removeLink = $this->currentPath().$this->results->getUrlQuery()->removeFacet($filter['field'], $filter['value']); + $removeLink = $this->currentPath().$results->getUrlQuery()->removeFacet($filter['field'], $filter['value']); if ($filter['displayText'] == '[* TO *]') $filter['displayText'] = $this->translate('filter_wildcard'); ?> <li data-icon="minus"> diff --git a/themes/jquerymobile/templates/Recommend/SwitchType.phtml b/themes/jquerymobile/templates/Recommend/SwitchType.phtml index 7129a776b2ca55505ccf9d9e9c3f691059c63df6..48bf99dce3722173bf2a92fc20b228ca8e44946d 100644 --- a/themes/jquerymobile/templates/Recommend/SwitchType.phtml +++ b/themes/jquerymobile/templates/Recommend/SwitchType.phtml @@ -1,6 +1,6 @@ <? if ($handler = $this->recommend->getNewHandler()): ?> <div class="info"> <?=$this->transEsc('widen_prefix')?> - <a href="<?=$this->results->getUrlQuery()->setHandler($handler)?>"><?=$this->transEsc($this->recommend->getNewHandlerName())?></a>. + <a href="<?=$this->recommend->getResults()->getUrlQuery()->setHandler($handler)?>"><?=$this->transEsc($this->recommend->getNewHandlerName())?></a>. </div> <? endif; ?> \ No newline at end of file