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

collection_download_process_data_only_types()

Description

Add PDFs for "data only" types to a zip file during creation.

Parameters

ColumnTypeDefaultDescription
$result array
$id integer
$collection_download_tar boolean
$usertempdir string
&$zip
&$path
&$deletion_array
$zip object
$path string
$deletion_array array

Return

void

Location

include/collections_functions.php lines 4899 to 4968

Definition

 
function collection_download_process_data_only_types(array $result$id$collection_download_tar$usertempdir, &$zip, &$path, &$deletion_array)
    {
    global 
$data_only_resource_types$k$usage$usagecomment$resource_hit_count_on_downloads$use_zip_extension;

    for(
$n 0$n count($result); $n++)
        {
        
// Data-only type of resources should be generated and added in the archive
        
if(in_array($result[$n]['resource_type'], $data_only_resource_types))
            {
            
$template_path get_pdf_template_path($result[$n]['resource_type']);
            if (
$template_path === false)
                {
                continue;
                }
            
$pdf_filename 'RS_' $result[$n]['ref'] . '_data_only.pdf';
            
$pdf_file_path get_temp_dir(false$id) . '/' $pdf_filename;

            
// Go through fields and decide which ones we add to the template
            
$placeholders = array(
                
'resource_type_name' => get_resource_type_name($result[$n]['resource_type'])
            );

            
$metadata get_resource_field_data($result[$n]['ref'], falsetruenull'' != $k);

            foreach(
$metadata as $metadata_field)
                {
                
$metadata_field_value trim(tidylist(i18n_get_translated($metadata_field['value'])));

                
// Skip if empty
                
if('' == $metadata_field_value)
                    {
                    continue;
                    }

                
$placeholders['metadatafield-' $metadata_field['ref'] . ':title'] = $metadata_field['title'];
                
$placeholders['metadatafield-' $metadata_field['ref'] . ':value'] = $metadata_field_value;
                }
            
generate_pdf($template_path$pdf_file_path$placeholderstrue);

            
// Go and add file to archive
           
if($collection_download_tar)
                {
                
// Add a link to pdf 
                
symlink($pdf_file_path$usertempdir DIRECTORY_SEPARATOR  $pdf_filename); 
                }
            elseif(
$use_zip_extension)
                {
                
$zip->addFile($pdf_file_path$pdf_filename);
                }
            else
                {
                
$path .= $pdf_file_path "\r\n";
                }
            
$deletion_array[] = $pdf_file_path;

            continue;
            }

        
daily_stat('Resource download'$result[$n]['ref']);
        
resource_log($result[$n]['ref'], 'd'0$usagecomment'''', (int) $usage);

        if(
$resource_hit_count_on_downloads)
            { 
            
/*greatest() is used so the value is taken from the hit_count column in the event that new_hit_count is zero
            to support installations that did not previously have a new_hit_count column (i.e. upgrade compatability).*/
            
$resource_ref_escaped $result[$n]['ref'];
            
ps_query("UPDATE resource SET new_hit_count = greatest(hit_count, new_hit_count) + 1 WHERE ref = ?",array("i",$resource_ref_escaped));
            }
        }
    }

This article was last updated 13th September 2024 10:05 Europe/London time based on the source file dated 19th August 2024 09:55 Europe/London time.