I can appreciate that I'm not using it as designed and I think that just speaks to the power and flexibility of CB, honestly. With a little creativity, you can build anything.
I did write some PHP that ended up working pretty well. I wouldn't recommend using this on a site open to the public, but it's a good temp fix for me right now. Since I can't publish a module to just the Galley tab of a profile, I published a module in Debug and have the code written to run when the current URL meets a requirement found only when the CBgalley folders are displayed. It pulls the folder id from the URL, finds all of the matching items in the database for that folder, builds download URLs out of the info in the database, and downloads all of those when you click the displayed button. Quick and dirty using just a joomla module and Sourcerer by Regular Labs, without touching any CB files.
Code:
[source]
<?php
// Database connection parameters
$host = 'localhost';
$user = 'XXXXXXX';
$password = 'XXXXXXX';
$db = 'XXXXXXX';
$dbprefix = 'XXXXXXX_';
$tableName = $dbprefix . 'comprofiler_plugin_gallery_items'; // Table name with prefix
// Create a new MySQLi connection
$database = new mysqli($host, $user, $password, $db);
// Check if connection is successful
if ($database->connect_errno) {
die('Failed to connect to MySQL: ' . $database->connect_error);
}
// Get the current URL
$currentUrl = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
// Check if the current URL contains the specified substring
$expectedSubstring = "XXXXXXX/index.php/cb-profile/pluginclass/cbgallery?action=folder&func=show&id=";
if (strpos($currentUrl, $expectedSubstring) !== false) {
// Extract Folder ID from the URL
preg_match('/show&id=([0-9]+)&gallery=/', $currentUrl, $matches);
$folderId = $matches[1] ?? null;
if ($folderId) {
// Query to find all matching rows in the database
$query = "SELECT id FROM $tableName WHERE folder = ?";
$stmt = $database->prepare($query);
if (!$stmt) {
die('Failed to prepare SQL statement.');
}
$stmt->bind_param('i', $folderId);
$stmt->execute();
$result = $stmt->get_result();
// Array to store file URLs
$fileUrls = ;
$baseUrl = "XXXXXXX/index.php?option=com_comprofiler&view=pluginclass&plugin=cbgallery&action=item&func=download&Itemid=111&format=raw&id=";
while ($row = $result->fetch_assoc()) {
$fileUrls = $baseUrl . $row['id'];
}
// Output the HTML with a "Download" button at the bottom left
echo '<!DOCTYPE html>';
echo '<html lang="en">';
echo '<head>';
echo '<meta charset="UTF-8">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
echo '<title>Download Files</title>';
echo '<style>';
echo 'body { margin: 0; padding: 0; height: 100vh; }';
echo '.download-button { position: fixed; bottom: 10px; left: 10px; padding: 10px 20px; background-color: #81A1C1; color: white; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.3s; }';
echo '.download-button:hover { background-color: #81A1C1; }';
echo '</style>';
echo '<script>';
echo 'function downloadFiles(urls) {';
echo ' urls.forEach(function(url, index) {';
echo ' setTimeout(function() {';
echo ' var a = document.createElement("a");';
echo ' a.href = url;';
echo ' a.download = "";';
echo ' document.body.appendChild(a);';
echo ' a.click();';
echo ' document.body.removeChild(a);';
echo ' }, index * 200);'; // Delay each download by 200ms
echo ' });';
echo '}';
echo 'function initiateDownload() {';
echo ' var urls = ' . json_encode($fileUrls) . ';';
echo ' downloadFiles(urls);';
echo '}';
echo '</script>';
echo '</head>';
echo '<body>';
echo '<button class="download-button" onclick="initiateDownload()">Download all files in this folder</button>';
echo '</body>';
echo '</html>;
} else {
die('Invalid Folder ID.');
}
}
// Close the database connection
$database->close();
?>
[/source]