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

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 107 to 153

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 14th December 2024 20:35 Europe/London time based on the source file dated 6th December 2024 11:00 Europe/London time.