diff --git a/languages/en.ini b/languages/en.ini index 581440b13922a197fb83c4499e3318f763fe5920..c9758db4aaa877497dd12510efb80bf39bd4c366 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -844,6 +844,7 @@ Requests = "Requests" Reserves = "Reserves" Reserves Search = "Reserves Search" Reserves Search Results = "Reserves Search Results" +result_checkbox_label = "Select result number %%number%%" result_count = "%%count%% results" Results = "Results" results = "results" diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Record.php b/module/VuFind/src/VuFind/View/Helper/Root/Record.php index fa7448e53a6d771109cdd939d725f5f846bb9fcf..cea7cb35a3a0bce118a00c7e3b76cc2f95b1843b 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Record.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Record.php @@ -413,16 +413,16 @@ class Record extends AbstractHelper * * @param string $idPrefix Prefix for checkbox HTML ids * @param string $formAttr ID of form for [form] attribute + * @param int $number Result number (for label of checkbox) * * @return string */ - public function getCheckbox($idPrefix = '', $formAttr = false) + public function getCheckbox($idPrefix = '', $formAttr = false, $number = null) { - static $checkboxCount = 0; $id = $this->driver->getSourceIdentifier() . '|' . $this->driver->getUniqueId(); $context - = ['id' => $id, 'count' => $checkboxCount++, 'prefix' => $idPrefix]; + = ['id' => $id, 'number' => $number, 'prefix' => $idPrefix]; if ($formAttr) { $context['formAttr'] = $formAttr; } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php index 6151a184dc0c1be70a0467eb03a2029addcb8bf1..b3f0715824ad165d937bc2f1276073ca1580f73d 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordTest.php @@ -273,17 +273,17 @@ class RecordTest extends \PHPUnit\Framework\TestCase { $context = $this->getMockContext(); $context->expects($this->at(1))->method('renderInContext') - ->with($this->equalTo('record/checkbox.phtml'), $this->equalTo(['id' => 'Solr|000105196', 'count' => 0, 'prefix' => 'bar', 'formAttr' => 'foo'])) + ->with($this->equalTo('record/checkbox.phtml'), $this->equalTo(['id' => 'Solr|000105196', 'number' => 1, 'prefix' => 'bar', 'formAttr' => 'foo'])) ->will($this->returnValue('success')); $context->expects($this->at(2))->method('renderInContext') - ->with($this->equalTo('record/checkbox.phtml'), $this->equalTo(['id' => 'Solr|000105196', 'count' => 1, 'prefix' => 'bar', 'formAttr' => 'foo'])) + ->with($this->equalTo('record/checkbox.phtml'), $this->equalTo(['id' => 'Solr|000105196', 'number' => 2, 'prefix' => 'bar', 'formAttr' => 'foo'])) ->will($this->returnValue('success')); $record = $this->getRecord( $this->loadRecordFixture('testbug1.json'), [], $context ); // We run the test twice to ensure that checkbox incrementing works properly: - $this->assertEquals('success', $record->getCheckbox('bar', 'foo')); - $this->assertEquals('success', $record->getCheckbox('bar', 'foo')); + $this->assertEquals('success', $record->getCheckbox('bar', 'foo', 1)); + $this->assertEquals('success', $record->getCheckbox('bar', 'foo', 2)); } /** diff --git a/themes/bootstrap3/templates/record/checkbox.phtml b/themes/bootstrap3/templates/record/checkbox.phtml index 53d3b326dcb7c237817efed440a36122aea34197..7c37bb0ab2482b8e6e321128dd30ed6fc4f77ac6 100644 --- a/themes/bootstrap3/templates/record/checkbox.phtml +++ b/themes/bootstrap3/templates/record/checkbox.phtml @@ -1,5 +1,6 @@ <label class="record-checkbox hidden-print"> <input class="checkbox-select-item" type="checkbox" name="ids[]" value="<?=$this->escapeHtmlAttr($this->id) ?>"<?php if(isset($this->formAttr)): ?> form="<?=$this->formAttr ?>"<?php endif; ?>/> <span class="checkbox-icon"></span> + <?php if (strlen($this->number ?? '') > 0): ?><span class="sr-only"><?=$this->transEsc('result_checkbox_label', ['%%number%%' => $this->number]) ?></span><?php endif; ?> </label> <input type="hidden" name="idsAll[]" value="<?=$this->escapeHtmlAttr($this->id) ?>"<?php if(isset($this->formAttr)): ?> form="<?=$this->formAttr ?>"<?php endif; ?>/> diff --git a/themes/bootstrap3/templates/search/list-list.phtml b/themes/bootstrap3/templates/search/list-list.phtml index d8783c90565a793ddadfab825b8f550957063f21..af656e815b8e9236284def57a20d7229efe5ec8d 100644 --- a/themes/bootstrap3/templates/search/list-list.phtml +++ b/themes/bootstrap3/templates/search/list-list.phtml @@ -4,7 +4,7 @@ <?php $recordNumber = $this->results->getStartRecord() + $i - $this->indexStart; ?> <div id="result<?=$i++ ?>" class="result<?=$current->supportsAjaxStatus()?' ajaxItem':''?>"> <?php if (isset($this->showCheckboxes) && $this->showCheckboxes): ?> - <?=$this->record($current)->getCheckbox('', 'search-cart-form')?> + <?=$this->record($current)->getCheckbox('', 'search-cart-form', $recordNumber)?> <?php endif; ?> <div class="record-number"> <?=$recordNumber ?>