Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

add_to_collection_link()

Description

Generates a HTML link for adding a resource to a collection

IMPORTANT: never use untrusted data here!

Parameters

ColumnTypeDefaultDescription
$resource integer ID of resource
$extracode string "" Additional code to be run when link is selected
$size string "" Resource size if appropriate
$class string "" Class to be applied to link
$view_title string "": string { # Generates a HTML link for removing a resource from a collection global $lang The title of the field, taken from $view_title_field
jQuery'div#ResourceShell{$resource}'} {draggable:
'{$resource}'
{$extracode} '{$size}'; \"{$resource}\"" . generate_csrf_data_for_api_native_authmode'add_resource_to_collection' . ">"; } /** * Render a "remove from collection" link wherever such a function is shown in the UI * * @param integer $resource * @param string $class * @param string $onclick Additional onclick code to call before returning false. * @param bool $notused No longer used * @param string $view_title The title of the field
from taken
$onclick string ''
$notused false
$pagename;
{$onclick} '{$pagename}'; \"{$resource}\"" . generate_csrf_data_for_api_native_authmode'remove_resource_from_collection' . ">"; } /** * Generates a HTML link for adding a changing the current collection * * @param integer $collection * @return string */ function change_collection_link$collection

Return

string

Location

include/collections_functions.php lines 3491 to 3503

Definition

 
function add_to_collection_link($resource$extracode=""$size=""$class=""$view_title=""): string
    
{
    
$resource = (int) $resource;
    
$size escape($size);
    
$class escape($class);
    
$title escape($GLOBALS['lang']["addtocurrentcollection"] . (($view_title != "") ? " - " $view_title ""));

    return 
"<a class=\"addToCollection {$class}\" href=\"#\" title=\"{$title}\""
        
" onClick=\"AddResourceToCollection(event, {draggable: jQuery('div#ResourceShell{$resource}')},'{$resource}','{$size}'); {$extracode} return false;\""
        
" data-resource-ref=\"{$resource}\""
        
generate_csrf_data_for_api_native_authmode('add_resource_to_collection')
        . 
">";
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.