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 2 instance.
  */
 static function stats()
 {
     global $gallery;
     $root_album_id = g2(GalleryCoreApi::getDefaultAlbumId());
     $stats["users"] = g2(GalleryCoreApi::fetchUserCount());
     $stats["groups"] = g2(GalleryCoreApi::fetchGroupCount());
     $stats["albums"] = g2(GalleryCoreApi::fetchItemIdCount("GalleryAlbumItem"));
     $stats["photos"] = g2(GalleryCoreApi::fetchItemIdCount("GalleryPhotoItem"));
     $stats["movies"] = g2(GalleryCoreApi::fetchItemIdCount("GalleryMovieItem"));
     if (g2_import::g2_module_active("comment") && module::is_active("comment")) {
         GalleryCoreApi::requireOnce("modules/comment/classes/GalleryCommentHelper.class");
         list(, $stats["comments"]) = g2(GalleryCommentHelper::fetchAllComments($root_album_id, 1));
     } else {
         $stats["comments"] = 0;
     }
     if (g2_import::g2_module_active("tags") && module::is_active("tag")) {
         $result = g2($gallery->search("SELECT COUNT(DISTINCT([TagItemMap::itemId])) FROM [TagItemMap]"))->nextResult();
         $stats["tags"] = $result[0];
     } else {
         $stats["tags"] = 0;
     }
     return $stats;
 }