You are here

function brilliant_gallery_image_is_hidden in Brilliant Gallery 7.2

@todo Please document this function.

1 call to brilliant_gallery_image_is_hidden()
brilliant_gallery_getbgfiles in ./brilliant_gallery.inc
Recursively read all gallery images and repopulate table brilliant_gallery_sources.

File

./brilliant_gallery.inc, line 109

Code

function brilliant_gallery_image_is_hidden($uri) {

  // @TODO rething function name?
  // Check for hidden images.
  global $picasa_inis;
  $parent_path_abs = dirname($uri);
  if (!isset($picasa_inis[$parent_path_abs])) {

    //dpm($parent_path_abs);
    if (file_exists($parent_path_abs . "/.picasa.ini")) {

      //$picasa_inis[$parent_path_abs] = file_get_contents($parent_path_abs . "/.picasa.ini");
      $picasaini_lines = array_map('trim', file($parent_path_abs . "/.picasa.ini"));

      //dpm($picasaini_lines);
      $picasa_inis[$parent_path_abs] = $picasaini_lines;
    }
    else {
      $picasa_inis[$parent_path_abs] = array();
    }
  }

  // Skip processing if there is no .picasa.ini inside
  if (empty($picasa_inis[$parent_path_abs])) {
    return FALSE;
  }

  // Skip if the .picasa.ini file lists no hidden images
  if (array_search("hidden=yes", $picasa_inis[$parent_path_abs]) == FALSE) {
    return FALSE;
  }

  //dpm($picasa_inis[$parent_path_abs]);

  /* 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 = '[' . basename($uri) . ']';
  $is_in_picasaini = array_search($searched_filename, $picasa_inis[$parent_path_abs]);

  // If the file name is not in .picasa.ini, skip
  if ($is_in_picasaini === FALSE) {
    return FALSE;
  }

  // Ok so it's in .picasa.ini, but is it currently hidden?
  foreach ($picasa_inis[$parent_path_abs] 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') {

      //dpm($searched_filename . ' IS HIDDEN!');

      // We've found that this file is marked hidden, exit the function immediately.
      return TRUE;
    }

    // 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 we did not return by now, then there surely was no match, so return FALSE.
  return FALSE;
}