Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource 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;

Return

string

Location

include/collections_functions.php lines 3460 to 3472

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 19th March 2024 06:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.