VuFind API Documentation

ResultScroller extends AbstractPlugin
in package

Class for managing "next" and "previous" navigation within result sets.

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

author

Ere Maijala ere.maijala@helsinki.fi

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Table of Contents

LAST_SEARCH_LIMIT  = 10
Maximum number of last searches to track
$data  : stdClass
Currently active scroll data
$enabled  : bool
Is scroller enabled?
$resultsManager  : PluginManager
Results manager
$searchMemory  : Memory
Search memory
$session  : Container
Session data used by scroller
__construct()  : mixed
Constructor. Create a new search result scroller.
getScrollData()  : array<string|int, mixed>
Get the previous/next record in the last search result set relative to the current one, also return the position of the current record in the result set.
init()  : bool
Initialize this result set scroller. This should only be called prior to displaying the results of a new search.
addData()  : void
Add data to session for a search
buildScrollDataArray()  : array<string|int, mixed>
Build and return the scroll data array
ensureRoomInSessionStorage()  : void
Make room for a new entry in the session storage as necessary
fetchNextPage()  : array<string|int, mixed>
Return a modified results array for the case where the user is on the cusp of the next page of results
fetchPage()  : array<string|int, mixed>
Fetch the given page of results from the given search object and return the IDs of the records in an array.
fetchPreviousPage()  : array<string|int, mixed>
Return a modified results array for the case where the user is on the cusp of the previous page of results
getFirstRecordId()  : string
Get the ID of the first record in the result set.
getLastPageNumber()  : int
Calculate the last page number in the result set.
getLastRecordId()  : string
Get the ID of the last record in the result set.
rememberSearch()  : void
Update the remembered "last search" in the session.
restoreSearch()  : Results|null
Restore a saved search.
scrollOnCurrentPage()  : array<string|int, mixed>
Return a modified results array to help scroll the user through the current page of results
scrollToFirstRecord()  : array<string|int, mixed>
Return a modified results array for the case where we need to retrieve data from the the first page of results
scrollToLastRecord()  : array<string|int, mixed>
Return a modified results array for the case where we need to retrieve data from the the last page of results
scrollToNextPage()  : array<string|int, mixed>
Return a modified results array for the case where we need to retrieve data from the next page of results
scrollToPreviousPage()  : array<string|int, mixed>
Return a modified results array for the case where we need to retrieve data from the previous page of results

Constants

LAST_SEARCH_LIMIT

Maximum number of last searches to track

public int LAST_SEARCH_LIMIT = 10

Properties

$data

Currently active scroll data

protected stdClass $data = null

$session

Session data used by scroller

protected Container $session

Methods

__construct()

Constructor. Create a new search result scroller.

public __construct(Container $session, PluginManager $rm, Memory $sm[, bool $enabled = true ]) : mixed
Parameters
$session : Container

Session container

$rm : PluginManager

Results manager

$sm : Memory

Search memory

$enabled : bool = true

Is the scroller enabled?

Return values
mixed

getScrollData()

Get the previous/next record in the last search result set relative to the current one, also return the position of the current record in the result set.

public getScrollData(AbstractBase $driver) : array<string|int, mixed>

Return array('previousRecord'=>previd, 'nextRecord'=>nextid, 'currentPosition'=>number, 'resultTotal'=>number).

Parameters
$driver : AbstractBase

Driver for the record currently being displayed

Return values
array<string|int, mixed>

init()

Initialize this result set scroller. This should only be called prior to displaying the results of a new search.

public init(Results $searchObject) : bool
Parameters
$searchObject : Results

The search object that was used to execute the last search.

Return values
bool

True if enabled and initialized with results, false otherwise.

addData()

Add data to session for a search

protected addData(Results $searchObject) : void
Parameters
$searchObject : Results

Search object

Return values
void

buildScrollDataArray()

Build and return the scroll data array

protected buildScrollDataArray(array<string|int, mixed> $retVal, AbstractBase $driver, Results $lastSearch) : array<string|int, mixed>
Parameters
$retVal : array<string|int, mixed>

Return values (in progress)

$driver : AbstractBase

Driver for the record currently being displayed

$lastSearch : Results

Representation of last search

Return values
array<string|int, mixed>

ensureRoomInSessionStorage()

Make room for a new entry in the session storage as necessary

protected ensureRoomInSessionStorage() : void
Return values
void

fetchNextPage()

Return a modified results array for the case where the user is on the cusp of the next page of results

protected fetchNextPage(array<string|int, mixed> $retVal, Results $lastSearch, int $pos) : array<string|int, mixed>
Parameters
$retVal : array<string|int, mixed>

Return values (in progress)

$lastSearch : Results

Representation of last search

$pos : int

Current position within current page

Return values
array<string|int, mixed>

fetchPage()

Fetch the given page of results from the given search object and return the IDs of the records in an array.

protected fetchPage(object $searchObject[, int $page = null ]) : array<string|int, mixed>
Parameters
$searchObject : object

The search object to use to execute the search

$page : int = null

The page number to fetch (null for current)

Return values
array<string|int, mixed>

fetchPreviousPage()

Return a modified results array for the case where the user is on the cusp of the previous page of results

protected fetchPreviousPage(array<string|int, mixed> $retVal, Results $lastSearch, int $pos, int $count) : array<string|int, mixed>
Parameters
$retVal : array<string|int, mixed>

Return values (in progress)

$lastSearch : Results

Representation of last search

$pos : int

Current position within current page

$count : int

Size of current page of results

Return values
array<string|int, mixed>

getFirstRecordId()

Get the ID of the first record in the result set.

protected getFirstRecordId(Results $lastSearch) : string
Parameters
$lastSearch : Results

Representation of last search

Return values
string

getLastPageNumber()

Calculate the last page number in the result set.

protected getLastPageNumber() : int
Return values
int

getLastRecordId()

Get the ID of the last record in the result set.

protected getLastRecordId(Results $lastSearch) : string
Parameters
$lastSearch : Results

Representation of last search

Return values
string

rememberSearch()

Update the remembered "last search" in the session.

protected rememberSearch(Results $search) : void
Parameters
$search : Results

Search object to remember.

Return values
void

restoreSearch()

Restore a saved search.

protected restoreSearch(int $searchId) : Results|null
Parameters
$searchId : int

Search ID

Return values
Results|null

scrollOnCurrentPage()

Return a modified results array to help scroll the user through the current page of results

protected scrollOnCurrentPage(array<string|int, mixed> $retVal, int $pos) : array<string|int, mixed>
Parameters
$retVal : array<string|int, mixed>

Return values (in progress)

$pos : int

Current position within current page

Return values
array<string|int, mixed>

scrollToFirstRecord()

Return a modified results array for the case where we need to retrieve data from the the first page of results

protected scrollToFirstRecord(array<string|int, mixed> $retVal, Results $lastSearch) : array<string|int, mixed>
Parameters
$retVal : array<string|int, mixed>

Return values (in progress)

$lastSearch : Results

Representation of last search

Return values
array<string|int, mixed>

scrollToLastRecord()

Return a modified results array for the case where we need to retrieve data from the the last page of results

protected scrollToLastRecord(array<string|int, mixed> $retVal, Results $lastSearch) : array<string|int, mixed>
Parameters
$retVal : array<string|int, mixed>

Return values (in progress)

$lastSearch : Results

Representation of last search

Return values
array<string|int, mixed>

scrollToNextPage()

Return a modified results array for the case where we need to retrieve data from the next page of results

protected scrollToNextPage(array<string|int, mixed> $retVal, Results $lastSearch, int $pos) : array<string|int, mixed>
Parameters
$retVal : array<string|int, mixed>

Return values (in progress)

$lastSearch : Results

Representation of last search

$pos : int

Current position within next page

Return values
array<string|int, mixed>

scrollToPreviousPage()

Return a modified results array for the case where we need to retrieve data from the previous page of results

protected scrollToPreviousPage(array<string|int, mixed> $retVal, Results $lastSearch, int $pos) : array<string|int, mixed>
Parameters
$retVal : array<string|int, mixed>

Return values (in progress)

$lastSearch : Results

Representation of last search

$pos : int

Current position within previous page

Return values
array<string|int, mixed>

Search results