Collections functions
Encryption functions
General functions
Theme permission functions
Resource 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 3632 to 3697

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']);
            
$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 escape_check($result[$n]['ref']);
            
sql_query("UPDATE resource SET new_hit_count = greatest(hit_count, new_hit_count) + 1 WHERE ref = '{$resource_ref_escaped}'");
            }
        }
    }

This article was last updated 13th July 2020 16:35 Europe/London time based on the source file dated 9th July 2020 17:22 Europe/London time.