Exemplo n.º 1
0
 /**
  * Return a set of statistics about the number of users, groups, albums, photos, movies and
  * comments available for import from the Gallery 1 instance.
  */
 static function g1_stats()
 {
     $stats['users'] = 0;
     $stats['groups'] = 0;
     $stats['albums'] = 0;
     $stats['photos'] = 0;
     $stats['movies'] = 0;
     $stats['comments'] = 0;
     $stats['tags'] = 0;
     $albumDir = self::$album_dir;
     if (substr($albumDir, -1) != DIRECTORY_SEPARATOR) {
         $albumDir .= DIRECTORY_SEPARATOR;
     }
     require_once 'Gallery1DataParser.php';
     if (Gallery1DataParser::isValidAlbumsPath($albumDir)) {
         if (count(self::$tree) == 0) {
             list($result, $tree) = Gallery1DataParser::getAlbumHierarchy($albumDir);
             if ($result == null) {
                 self::$tree = $tree;
             }
         }
         list($result, $uids) = Gallery1DataParser::getUserUids($albumDir);
         if ($result == null) {
             $stats['users'] = count($uids);
         }
         self::$queued_items = array();
         self::$queued_comments = array();
         self::$queued_highlights = array();
         self::$albums_flat = array();
         self::$albums_hidden = array();
         self::$warn_utf8 = array();
         if (count(self::$tree)) {
             $stats['albums'] = 1 + g1_import::recursiveCountGallery($albumDir, self::$tree, 0);
         }
         $stats['photos'] = count(self::$queued_items);
         foreach (self::$queued_comments as $element) {
             foreach ($element as $item => $comments) {
                 $stats['comments'] += count($comments);
             }
         }
         arsort(self::$queued_highlights);
         $stats['highlights'] = count(self::$queued_highlights);
         arsort(self::$albums_flat);
         foreach (self::$albums_flat as $key => $value) {
             $pos = strpos($value, ':');
             if ($pos !== false) {
                 self::$albums_flat[$key] = substr($value, $pos + 1);
             }
         }
     }
     return $stats;
 }