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_summary_notes()

Description

(passed by reference so can be added to)

Parameters

ColumnTypeDefaultDescription
&$dl_data array
$filename string Resource filename
&$zip mixed
$dl_data array Array of collection download data from process_collection_download()
$zip mixed Collection zip file, false if using TAR

Location

include/collections_functions.php lines 4569 to 4651

Definition

 
function collection_download_process_summary_notes(array &$dl_datastring $filenamemixed &$zip)
{
    global 
$p;
    
$size $dl_data['size'];
    
$text $dl_data['text'];
    
$subbed_original_resources $dl_data['subbed_original_resources'];
    
$used_resources $dl_data['used_resources'];
    
$available_sizes $dl_data['available_sizes'];

    if (
        !
hook('zippedcollectiontextfile''', array($text))
        && 
$dl_data['includetext']
    ) {
        
$qty_sizes = isset($available_sizes[$size]) ? count($available_sizes[$size]) : 0;
        
$qty_total count($dl_data['collection_resources']);
        
$text .= $GLOBALS["lang"]["status-note"] . ": " $qty_sizes " " $GLOBALS["lang"]["of"] . " " $qty_total " ";
        switch (
$qty_total) {
            case 
0:
                
$text .= $GLOBALS["lang"]["resource-0"] . " ";
                break;
            case 
1:
                
$text .= $GLOBALS["lang"]["resource-1"] . " ";
                break;
            default:
                
$text .= $GLOBALS["lang"]["resource-2"] . " ";
                break;
        }

        switch (
$qty_sizes) {
            case 
0:
                
$text .= $GLOBALS["lang"]["were_available-0"] . " ";
                break;
            case 
1:
                
$text .= $GLOBALS["lang"]["were_available-1"] . " ";
                break;
            default:
                
$text .= $GLOBALS["lang"]["were_available-2"] . " ";
                break;
        }
        
$text .= $GLOBALS["lang"]["forthispackage"] . ".\r\n\r\n";

        foreach (
$dl_data['collection_resources'] as $resource) {
            if (
in_array($resource['ref'], $subbed_original_resources)) {
                
$text .= $GLOBALS["lang"]["didnotinclude"] . ": " $resource['ref'];
                
$text .= " (" $GLOBALS["lang"]["substituted_original"] . ")";
                
$text .= "\r\n";
            } elseif (!
in_array($resource['ref'], $used_resources)) {
                
$text .= $GLOBALS["lang"]["didnotinclude"] . ": " $resource['ref'];
                
$text .= "\r\n";
            }
        }

        
$textfile get_temp_dir(false$dl_data['id']) . "/" . (int) $dl_data['collection'] . "-" safe_file_name(i18n_get_collection_name($dl_data['collectiondata'])) . $dl_data['sizetext'] . ".txt";
        
$fh fopen($textfile'w') or die("can't open file");
        
fwrite($fh$text);
        
fclose($fh);
        if (
$dl_data['collection_download_tar']) {
            
$usertempdir get_temp_dir(false"rs_" $GLOBALS["userref"] . "_" $dl_data['id']);
            
debug("collection_download adding symlink: " $p " - " $usertempdir DIRECTORY_SEPARATOR $filename);
            
            
$GLOBALS["use_error_exception"] = true;
            try {
                
symlink(
                    
$textfile,
                    
$usertempdir 
                        
DIRECTORY_SEPARATOR $dl_data['collection']
                        . 
"-" safe_file_name(i18n_get_collection_name($dl_data['collectiondata']))
                        . 
$dl_data['sizetext'] . '.txt'
                
);
            } catch (
Throwable $e) {
                
debug("collection_download_process_archive_command: Unable to create symlink {$e->getMessage()}");
                return 
false;
            }
            unset(
$GLOBALS["use_error_exception"]);
        } elseif (
$GLOBALS['use_zip_extension']) {
            
debug("Adding $textfile to " $zip->filename);
            
$zip->addFile($textfile$dl_data['collection'] . "-" safe_file_name(i18n_get_collection_name($dl_data['collectiondata'])) . $dl_data['sizetext'] . ".txt");
        } else {
            
$dl_data['includefiles'][] = $textfile;
        }
         
$dl_data['deletion_array'][] = $textfile;
    }
}

This article was last updated 14th April 2025 21:35 Europe/London time based on the source file dated 10th April 2025 10:40 Europe/London time.