Record
extends AbstractHelper
in package
implements
DbServiceAwareInterface
Uses
ClassBasedTemplateRendererTrait, DbServiceAwareTrait
Record driver view helper
Tags
Interfaces, Classes, Traits and Enums
- DbServiceAwareInterface
- Marker interface for classes that depend on the \VuFind\Db\Service\PluginManager
Table of Contents
- $config : Config|null
- $contextHelper : Context
- Context view helper
- $coverRouter : Router
- Cover router
- $dbServiceManager : PluginManager
- Database service plugin manager
- $driver : AbstractBase
- Record driver
- $tagsService : TagsService
- $templateCache : array<string|int, mixed>
- Cache for found templates
- __construct() : mixed
- Constructor
- __invoke() : Record
- Store a record driver object and return this object so that the appropriate template can be rendered.
- getCheckbox() : string
- Render an HTML checkbox control for the current record.
- getCollectionBriefRecord() : string
- Render the a brief record for use in collection mode.
- getCollectionMetadata() : string
- Render the core metadata area of the collection view.
- getComments() : array<string|int, CommentsEntityInterface>
- Get comments associated with the current record.
- getCoreMetadata() : string
- Render the core metadata area of the record view.
- getCover() : string
- Render a cover for the current record.
- getCoverDetails() : array<string|int, mixed>
- Get the rendered cover plus some useful parameters.
- getDbService() : T
- Get a database service object.
- getDbServiceManager() : PluginManager
- Get the service plugin manager. Throw an exception if it is missing.
- getExport() : string
- Export the record in the requested format. For legal values, see the export helper's getFormatsForRecord() method.
- getFormatClass() : string
- Get the CSS class used to properly render a format. (Note that this may not be used by every theme).
- getFormatList() : string
- Render a list of record formats.
- getLabelList() : string
- Render a list of record labels.
- getLink() : string
- Render the link of the specified type.
- getLinkDetails() : array<string|int, mixed>
- Get all the links associated with this record. Returns an array of associative arrays each containing 'desc' and 'url' keys.
- getListEntry() : string
- Render an entry in a favorite list.
- getListNotes() : array<string|int, string>
- Get notes associated with this record in user lists.
- getPreviewData() : string
- Render data needed to get previews.
- getPreviewIds() : array<string|int, mixed>
- Collects ISBN, LCCN, and OCLC numbers to use in calling preview APIs
- getPreviewLink() : string
- Render links to previews of the item if configured.
- getPreviews() : string
- Render previews (data and link) of the item if configured.
- getQrCode() : string|bool
- Generate a qrcode URL (return false if unsupported).
- getSearchResult() : string
- Render a search result for the specified view mode.
- getTab() : string
- Render the contents of the specified record tab.
- getTags() : array<string|int, mixed>
- Get tags associated with the currently-loaded record.
- getTagsFromFavorites() : array<string|int, mixed>
- Get tags associated with the currently-loaded record AND with a favorites list.
- getThumbnail() : string|bool
- Generate a thumbnail URL (return false if unsupported).
- getThumbnailAlignment() : string
- Get the configured thumbnail alignment
- getTitleHtml() : string
- Get HTML to render a title.
- getToolbar() : string
- Render a toolbar for use on the record view.
- getUrlList() : array<string|int, mixed>
- Get all URLs associated with the record. Returns an array of strings.
- renderTemplate() : string
- Render a template within a record driver folder.
- setCoverRouter() : void
- Inject the cover router
- setDbServiceManager() : void
- Set the service plugin manager.
- deduplicateLinks() : array<string|int, mixed>
- Remove duplicates from the array. All keys and values are being used recursively to compare, so if there are 2 links with the same url but different desc, they will both be preserved.
- getBriefClass() : string
- Helper to grab the end of the class name
- getCachedClassTemplate() : string
- Resolve the class template file unless already cached and return the file name.
- getCoverSize() : string
- Get the configured thumbnail size for record lists
- getPreviewCoverLinkSetting() : bool
- Should cover images be linked to previews (when applicable) in the provided template context?
- getTemplateWithClass() : string
- Helper to put the template path and class name together
- hasOpenUrlReplaceSetting() : bool
- Get all the links associated with this record depending on the OpenURL setting replace_other_urls. Returns an array of associative arrays each containing 'desc' and 'url' keys.
- renderClassTemplate() : string
- Render a template associated with the provided class name, applying to specified context variables.
- resolveClassTemplate() : string
- Recursively locate a template that matches the provided class name (or one of its parent classes); throw an exception if no match is found.
Properties
$config
protected
Config|null
$config
= null
$contextHelper
Context view helper
protected
Context
$contextHelper
$coverRouter
Cover router
protected
Router
$coverRouter
= null
$dbServiceManager
Database service plugin manager
protected
PluginManager
$dbServiceManager
$driver
Record driver
protected
AbstractBase
$driver
$tagsService
protected
TagsService
$tagsService
$templateCache
Cache for found templates
protected
array<string|int, mixed>
$templateCache
= []
Methods
__construct()
Constructor
public
__construct(TagsService $tagsService[, Config $config = null ]) : mixed
Parameters
- $tagsService : TagsService
-
Tags service
- $config : Config = null
-
Configuration from config.ini
Return values
mixed —__invoke()
Store a record driver object and return this object so that the appropriate template can be rendered.
public
__invoke(AbstractBase $driver) : Record
Parameters
- $driver : AbstractBase
-
Record driver object.
Return values
Record —getCheckbox()
Render an HTML checkbox control for the current record.
public
getCheckbox([string $idPrefix = '' ][, string $formAttr = false ][, int $number = null ]) : string
Parameters
- $idPrefix : string = ''
-
Prefix for checkbox HTML ids
- $formAttr : string = false
-
ID of form for [form] attribute
- $number : int = null
-
Result number (for label of checkbox)
Return values
string —getCollectionBriefRecord()
Render the a brief record for use in collection mode.
public
getCollectionBriefRecord() : string
Return values
string —getCollectionMetadata()
Render the core metadata area of the collection view.
public
getCollectionMetadata() : string
Return values
string —getComments()
Get comments associated with the current record.
public
getComments() : array<string|int, CommentsEntityInterface>
Return values
array<string|int, CommentsEntityInterface> —getCoreMetadata()
Render the core metadata area of the record view.
public
getCoreMetadata() : string
Return values
string —getCover()
Render a cover for the current record.
public
getCover(string $context, string $default[, string $link = false ]) : string
Parameters
- $context : string
-
Context of code being generated
- $default : string
-
The default size of the cover
- $link : string = false
-
The link for the anchor
Return values
string —getCoverDetails()
Get the rendered cover plus some useful parameters.
public
getCoverDetails(string $context, string $default[, string|array<string|int, mixed>|false $link = false ]) : array<string|int, mixed>
Parameters
- $context : string
-
Context of code being generated
- $default : string
-
The default size of the cover
- $link : string|array<string|int, mixed>|false = false
-
The href link for the anchor (false for no link, or a string to use as an href, or an array of attributes to include in the anchor tag)
Return values
array<string|int, mixed> —getDbService()
Get a database service object.
public
getDbService(class-string<\VuFind\Db\Service\T> $name) : T
Parameters
- $name : class-string<\VuFind\Db\Service\T>
-
Name of service to retrieve
Tags
Return values
T —getDbServiceManager()
Get the service plugin manager. Throw an exception if it is missing.
public
getDbServiceManager() : PluginManager
Tags
Return values
PluginManager —getExport()
Export the record in the requested format. For legal values, see the export helper's getFormatsForRecord() method.
public
getExport(string $format) : string
Parameters
- $format : string
-
Export format to display
Return values
string —Exported data
getFormatClass()
Get the CSS class used to properly render a format. (Note that this may not be used by every theme).
public
getFormatClass(string $format) : string
Parameters
- $format : string
-
Format text to convert into CSS class
Return values
string —getFormatList()
Render a list of record formats.
public
getFormatList() : string
Return values
string —getLabelList()
Render a list of record labels.
public
getLabelList() : string
Return values
string —getLink()
Render the link of the specified type.
public
getLink(string $type, string $lookfor) : string
Parameters
- $type : string
-
Link type
- $lookfor : string
-
String to search for at link
Return values
string —getLinkDetails()
Get all the links associated with this record. Returns an array of associative arrays each containing 'desc' and 'url' keys.
public
getLinkDetails([bool $openUrlActive = false ]) : array<string|int, mixed>
Parameters
- $openUrlActive : bool = false
-
Is there an active OpenURL on the page?
Return values
array<string|int, mixed> —getListEntry()
Render an entry in a favorite list.
public
getListEntry([UserListEntityInterface|null $list = null ][, UserEntityInterface|null $user = null ]) : string
Parameters
- $list : UserListEntityInterface|null = null
-
Currently selected list (null for combined favorites)
- $user : UserEntityInterface|null = null
-
Current logged in user (null if none)
Return values
string —getListNotes()
Get notes associated with this record in user lists.
public
getListNotes([int $list_id = null ][, int $user_id = null ]) : array<string|int, string>
Parameters
- $list_id : int = null
-
ID of list to load tags from (null for all lists)
- $user_id : int = null
-
ID of user to load tags from (null for all users)
Return values
array<string|int, string> —getPreviewData()
Render data needed to get previews.
public
getPreviewData() : string
Return values
string —getPreviewIds()
Collects ISBN, LCCN, and OCLC numbers to use in calling preview APIs
public
getPreviewIds() : array<string|int, mixed>
Return values
array<string|int, mixed> —getPreviewLink()
Render links to previews of the item if configured.
public
getPreviewLink() : string
Return values
string —getPreviews()
Render previews (data and link) of the item if configured.
public
getPreviews() : string
Return values
string —getQrCode()
Generate a qrcode URL (return false if unsupported).
public
getQrCode(string $context[, array<string|int, mixed> $extra = [] ][, string $level = 'L' ][, int $size = 3 ][, int $margin = 4 ]) : string|bool
Parameters
- $context : string
-
Context of code being generated (core or results)
- $extra : array<string|int, mixed> = []
-
Extra details to pass to the QR code template
- $level : string = 'L'
-
QR code level
- $size : int = 3
-
QR code size
- $margin : int = 4
-
QR code margin
Return values
string|bool —getSearchResult()
Render a search result for the specified view mode.
public
getSearchResult(string $view) : string
Parameters
- $view : string
-
View mode to use.
Return values
string —getTab()
Render the contents of the specified record tab.
public
getTab(TabInterface $tab) : string
Parameters
- $tab : TabInterface
-
Tab to display
Return values
string —getTags()
Get tags associated with the currently-loaded record.
public
getTags([UserListEntityInterface|int|null $listOrId = null ][, UserEntityInterface|int|null $userOrId = null ][, string $sort = 'count' ][, UserEntityInterface|int|null $ownerOrId = null ]) : array<string|int, mixed>
Parameters
- $listOrId : UserListEntityInterface|int|null = null
-
ID of list to load tags from (null for no restriction)
- $userOrId : UserEntityInterface|int|null = null
-
ID of user to load tags from (null for all users)
- $sort : string = 'count'
-
Sort type ('count' or 'tag')
- $ownerOrId : UserEntityInterface|int|null = null
-
ID of user to check for ownership
Return values
array<string|int, mixed> —getTagsFromFavorites()
Get tags associated with the currently-loaded record AND with a favorites list.
public
getTagsFromFavorites([UserListEntityInterface|int|null $listOrId = null ][, UserEntityInterface|int|null $userOrId = null ][, string $sort = 'count' ][, UserEntityInterface|int|null $ownerOrId = null ]) : array<string|int, mixed>
Parameters
- $listOrId : UserListEntityInterface|int|null = null
-
ID of list to load tags from (null for tags that are associated with ANY list, but excluding non-list tags)
- $userOrId : UserEntityInterface|int|null = null
-
ID of user to load tags from (null for all users)
- $sort : string = 'count'
-
Sort type ('count' or 'tag')
- $ownerOrId : UserEntityInterface|int|null = null
-
ID of user to check for ownership
Return values
array<string|int, mixed> —getThumbnail()
Generate a thumbnail URL (return false if unsupported).
public
getThumbnail([string $size = 'small' ]) : string|bool
Parameters
- $size : string = 'small'
-
Size of thumbnail (small, medium or large -- small is default).
Return values
string|bool —getThumbnailAlignment()
Get the configured thumbnail alignment
public
getThumbnailAlignment([string $context = 'result' ]) : string
Parameters
- $context : string = 'result'
-
telling the context asking, prepends the config key
Return values
string —getTitleHtml()
Get HTML to render a title.
public
getTitleHtml([int $maxLength = 180 ]) : string
Parameters
- $maxLength : int = 180
-
Maximum length of non-highlighted title.
Return values
string —getToolbar()
Render a toolbar for use on the record view.
public
getToolbar() : string
Return values
string —getUrlList()
Get all URLs associated with the record. Returns an array of strings.
public
getUrlList() : array<string|int, mixed>
Return values
array<string|int, mixed> —renderTemplate()
Render a template within a record driver folder.
public
renderTemplate(string $name[, array<string|int, mixed> $context = null ][, bool $throw = true ]) : string
Parameters
- $name : string
-
Template name to render
- $context : array<string|int, mixed> = null
-
Variables needed for rendering template; these will be temporarily added to the global view context, then reverted after the template is rendered (default = record driver only).
- $throw : bool = true
-
If true (default), an exception is thrown if the template is not found. Otherwise an empty string is returned.
Return values
string —setCoverRouter()
Inject the cover router
public
setCoverRouter(Router $router) : void
Parameters
- $router : Router
-
Cover router
Return values
void —setDbServiceManager()
Set the service plugin manager.
public
setDbServiceManager(PluginManager $manager) : void
Parameters
- $manager : PluginManager
-
Plugin manager
Return values
void —deduplicateLinks()
Remove duplicates from the array. All keys and values are being used recursively to compare, so if there are 2 links with the same url but different desc, they will both be preserved.
protected
deduplicateLinks(array<string|int, mixed> $links) : array<string|int, mixed>
Parameters
- $links : array<string|int, mixed>
-
array of associative arrays, each containing 'desc' and 'url' keys
Return values
array<string|int, mixed> —getBriefClass()
Helper to grab the end of the class name
protected
getBriefClass(string $className) : string
Parameters
- $className : string
-
Class name to abbreviate
Return values
string —getCachedClassTemplate()
Resolve the class template file unless already cached and return the file name.
protected
getCachedClassTemplate(string $template, string $className) : string
Parameters
- $template : string
-
Template path (with %s as class name placeholder)
- $className : string
-
Name of class to apply to template.
Return values
string —getCoverSize()
Get the configured thumbnail size for record lists
protected
getCoverSize(string $context[, string $default = 'medium' ]) : string
Parameters
- $context : string
-
Context of code being generated
- $default : string = 'medium'
-
The default size of the cover
Return values
string —getPreviewCoverLinkSetting()
Should cover images be linked to previews (when applicable) in the provided template context?
protected
getPreviewCoverLinkSetting(string $context) : bool
Parameters
- $context : string
-
Context of code being generated
Return values
bool —getTemplateWithClass()
Helper to put the template path and class name together
protected
getTemplateWithClass(string $template, string $className) : string
Parameters
- $template : string
-
Template path (with %s as class name placeholder)
- $className : string
-
Class name to abbreviate
Return values
string —hasOpenUrlReplaceSetting()
Get all the links associated with this record depending on the OpenURL setting replace_other_urls. Returns an array of associative arrays each containing 'desc' and 'url' keys.
protected
hasOpenUrlReplaceSetting() : bool
Return values
bool —renderClassTemplate()
Render a template associated with the provided class name, applying to specified context variables.
protected
renderClassTemplate(string $template, string $className[, array<string|int, mixed> $context = [] ][, bool $throw = true ]) : string
Parameters
- $template : string
-
Template path (with %s as class name placeholder)
- $className : string
-
Name of class to apply to template.
- $context : array<string|int, mixed> = []
-
Context for rendering template
- $throw : bool = true
-
If true (default), an exception is thrown if the template is not found. Otherwise an empty string is returned.
Tags
Return values
string —resolveClassTemplate()
Recursively locate a template that matches the provided class name (or one of its parent classes); throw an exception if no match is found.
protected
resolveClassTemplate(string $template, string $className, ResolverInterface $resolver[, string $topClassName = null ]) : string
Parameters
- $template : string
-
Template path (with %s as class name placeholder)
- $className : string
-
Name of class to apply to template.
- $resolver : ResolverInterface
-
Resolver to use
- $topClassName : string = null
-
Top-level parent class of $className (or null if $className is already the top level; used for recursion only).