Example #1
0
 /**
  * Create Menu
  *
  * @param string $dir 
  * @param int $level
  * @author Thibaud Rohmer
  */
 public function __construct($dir = null, $level = 0)
 {
     /// Init Menu
     if ($dir == null) {
         $dir = Settings::$photos_dir;
     }
     /// Check rights
     if (!Judge::view($dir) || Judge::searchDir($dir) == NULL) {
         return;
     }
     if (!CurrentUser::$admin && !CurrentUser::$uploader && sizeof($this->list_files($dir, true, false, true)) == 0) {
         return;
     }
     /// Set variables
     $this->title = end(explode('/', $dir));
     $this->webdir = urlencode(File::a2r($dir));
     $this->path = File::a2r($dir);
     try {
         /// Check if selected dir is in $dir
         File::a2r(CurrentUser::$path, $dir);
         $this->selected = true;
         $this->class = "level-{$level} selected";
     } catch (Exception $e) {
         /// Selected dir not in $dir, or nothing is selected
         $this->selected = false;
         $this->class = "level-{$level}";
     }
     /// Create Menu for each directory
     $subdirs = $this->list_dirs($dir);
     if (Settings::$reverse_menu) {
         $subdirs = array_reverse($subdirs);
     }
     foreach ($subdirs as $d) {
         $this->items[] = new Menu($d, $level + 1);
     }
 }
Example #2
0
 /**
  * Generate a foldergrid
  *
  * @return void
  * @author Thibaud Rohmer
  */
 private function foldergrid()
 {
     foreach ($this->dirs as $d) {
         $firstImg = Judge::searchDir($d);
         if (!(Judge::view($d) || $firstImg)) {
             continue;
         }
         $f = Menu::list_files($d, true);
         if (CurrentUser::$admin || CurrentUser::$uploader || sizeof($f) > 0) {
             if ($firstImg) {
                 $f[0] = $firstImg;
             }
             $item = new BoardDir($d, $f);
             $this->boardfolders[] = $item;
         }
     }
 }
Example #3
0
 /**
  * Check recursively if a file is viewable in a folder, and returns path to that file.
  */
 public static function searchDir($dir, $public_search = false)
 {
     foreach (Menu::list_files($dir) as $f) {
         if (Judge::view($f)) {
             return $f;
         }
     }
     foreach (Menu::list_dirs($dir) as $d) {
         if (($f = Judge::searchDir($d, $public_search)) != NULL) {
             return $f;
         }
     }
     return NULL;
 }
Example #4
0
 /**
  * Check if a file is viewable in a folder, and returns path to that file.
  */
 public static function searchDir($dir, $public_search = false)
 {
     $rightsdir = File::r2a(File::a2r($dir), Settings::$thumbs_dir);
     $rightsfiles = glob($rightsdir . "/.*ights.xml");
     // Check files
     foreach ($rightsfiles as $rf) {
         $f = Judge::associated_file($rf);
         if ($public_search and Judge::is_public($f) or !$public_search and Judge::view($f)) {
             if (is_file($f)) {
                 return $f;
             } else {
                 foreach (Menu::list_files($f, true) as $p) {
                     if ($public_search and Judge::is_public($p) or !$public_search and Judge::view($p)) {
                         return $p;
                     }
                 }
             }
         }
     }
     // Check subdirs
     foreach (Menu::list_dirs($dir) as $d) {
         if ($f = Judge::searchDir($d, $public_search)) {
             return $f;
         }
     }
     return false;
 }
Example #5
0
 /**
  * Generate a foldergrid
  *
  * @return void
  * @author Thibaud Rohmer
  */
 private function foldergrid()
 {
     foreach ($this->dirs as $d) {
         if (!Judge::view($d)) {
             //Dir is not accessible (rights) - ignore it for better performance
             continue;
         }
         $firstImg = Judge::searchDir($d);
         if (!$firstImg) {
             if (CurrentUser::$admin) {
                 $firstImg = NULL;
             } else {
                 continue;
             }
         }
         $item = new BoardDir($d, $firstImg);
         $this->boardfolders[] = $item;
     }
     if (Settings::$reverse_menu) {
         $this->boardfolders = array_reverse($this->boardfolders);
     }
 }