function brilliant_gallery_get_picasa_hidden_imagenames in Brilliant Gallery 7
Same name and namespace in other branches
- 7.2 OLD_brilliant_gallery_functions.inc \brilliant_gallery_get_picasa_hidden_imagenames()
Get a list of files that should be hidden (based on .picasa.ini, if present)
1 call to brilliant_gallery_get_picasa_hidden_imagenames()
File
- ./
brilliant_gallery_functions.inc, line 478
Code
function brilliant_gallery_get_picasa_hidden_imagenames($absolute_album_path) {
$filenames = array();
// Skip processing if there is no .picasa.ini inside
if (file_exists($absolute_album_path . "/.picasa.ini")) {
// Skip if the .picasa.ini file lists no hidden images
$picasaini = file_get_contents($absolute_album_path . "/.picasa.ini");
if (strpos($picasaini, "hidden=yes") !== FALSE) {
$picasaini_lines = file($absolute_album_path . "/.picasa.ini");
$picasaini_lines = array_map('trim', $picasaini_lines);
$dir_files = scandir($absolute_album_path);
// Skip ., .., and .picasa.ini
$dir_files = array_diff($dir_files, array(
'..',
'.',
'.picasa.ini',
));
foreach ($dir_files as $key => $filename) {
/* Check if the filename is hidden in .picasa.ini
* Hidden entry example:
* [02_011_08a.jpg]
* rotate=rotate(2)
* backuphash=53332
* hidden=yes
*/
$searched_filename = '[' . $filename . ']';
$is_in_picasaini = array_search($searched_filename, $picasaini_lines);
// If the file name is not in .picasa.ini, skip
if ($is_in_picasaini === FALSE) {
continue;
}
// Ok so it's in .picasa.ini, but is it currently hidden?
$ishidden = FALSE;
foreach ($picasaini_lines as $key => $val) {
// Iterate to the line AFTER the matching file name
if ($key <= $is_in_picasaini) {
continue;
}
// If the line is "hidden=yes" then the file name is hidden
if ($val == 'hidden=yes') {
$ishidden = TRUE;
break;
}
// If we reach a line starting with "[" then we assume that the searched file name is NOT hidden
if (substr($val, 0, 1) == '[') {
break;
}
}
if (!$ishidden) {
continue;
}
$filenames[] = $filename;
}
}
}
return $filenames;
}