Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

reorder_slideshow_images()

Description

Function used to re-order slideshow images

Parameters

ColumnTypeDefaultDescription
$from array Slideshow image data we move FROM
$to array Slideshow image data we move TO

Return

boolean

Location

include/slideshow_functions.php lines 99 to 145

Definition

 
function reorder_slideshow_images(array $from, array $to)
    {
    if(!
file_exists($from['file_path']))
        {
        
trigger_error('File "' $from['file_path'] . '" does not exist or could not be found/accessed!');
        }

    if(!
file_exists($to['file_path']))
        {
        
trigger_error('File "' $to['file_path'] . '" does not exist or could not be found/accessed!');
        }

    
// Calculate files to be moved around
    
$from_file $from['file_path'];
    
$temp_file "{$from['file_path']}.tmp";
    
$to_file   $to['file_path'];

    
// Swap the slideshow images
    
if(!copy($from_file$temp_file))
        {
        
trigger_error("Failed to copy '{$from_file}' to temp file '{$temp_file}'");
        }

    if(
rename($to_file$from_file) && rename($temp_file$to_file))
        {
        
set_slideshow(
            
$from['ref'],
            
$to['resource_ref'],
            
$to['homepage_show'],
            
$to['featured_collections_show'],
            
$to['login_show']);

        
set_slideshow(
            
$to['ref'],
            
$from['resource_ref'],
            
$from['homepage_show'],
            
$from['featured_collections_show'],
            
$from['login_show']);
    
            
// Clear cache
            
clear_query_cache("slideshow");

        return 
true;
        }

    return 
false;
    }

This article was last updated 16th July 2020 01:35 Europe/London time based on the source file dated 8th June 2020 12:35 Europe/London time.