From 67dce773e634c7d00a72e62bedd63c35520e2571 Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Fri, 27 Feb 2015 20:37:24 +0100 Subject: [PATCH] Updated Album::getAll --- dist/main.css | Bin 34408 -> 33566 bytes dist/main.js | Bin 173915 -> 174199 bytes php/modules/Album.php | 55 +++++++++++++++++++++++-------------- src/scripts/album.js | 10 +++---- src/scripts/albums.js | 42 ++++++++++++++-------------- src/scripts/contextMenu.js | 4 +-- src/scripts/password.js | 2 +- src/scripts/view.js | 21 ++++++++------ 8 files changed, 77 insertions(+), 57 deletions(-) diff --git a/dist/main.css b/dist/main.css index 932de008b6283b727b67c0616ac301ac92c69699..980c5d30cfaaf386057b24528cb4095c949be54c 100644 GIT binary patch delta 1440 zcmah}TTmNi6rSDGGzm!w0Ry>_4UtQdC4@^9f-saaU@I*KXUgRPyJR=8W5|YNfiPJ=Ng>Tb)CDO&rcI1`*|AolqZDi!tMN{a9@mXE z&YU-<1`A1<^@_>3G%jVC;9QzZrG&JCzgs+OTNEj!JGE%nJ76(*$Tzx|Y4nelSlD2k zt`+@)Boy@89> zAL09G5%jfgd|h*qMC(c@ZEl+awMz$9{5s_PR_1>?%ySgR#z+U{Q}3lJDF(VJgXKUE zmV9M-^BUWiH!GVmIj=ayO$f81Fvske>>dFM?!Dm91e-JD=lW5thHVU?v&C7S>v~q0 zkEgjQA;Y9*5*a}WRqy&-`-4_e9G@pK5)P%ZOo(Z2PG#{^iwl)u7a0!!L7U_>m&_zM zSs1Ac`Oq=uw5BClJ*ua}u4CGY|8lLjUUwb{Zd7X(ULLNi$8^MDt#9Imi2^)Qw;hHr z+kEDKzl*=xh7N-Dt!hHVBZ2$D)ky7qAh{VaYVEu@EApx;3ah@0D431=9l0F|oyZF! zt1e?fQ0mxDx#-7yWV366!fL#Vyw?3H1$R#a26_TS=~)i?$5>E=MIMU2yBfD#P zC#8%m@N=R(xev*roDdY;?)4xvuSZeeG=8NlR6BXD@6Hi3sszNtrGj_FaweSj@)5g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*9L?6Wtf@ujWcb3`(I+hGDzxVRmb@b_ejPH=!|YEF2oK~y8XF_%k;cw(4} zXa+lBXCs1rII!3RO4B~4y-_&R39nYRO5ADG-NAbHoa8u~%xJj|X+ULn_7bV^7z?Ad ztpU}4dY**Qx_utEoAi1-eYohKCxUso7e@C4R4$<6gJ8LNj_k*0j1%c_2&&8F%wa7< z8F>PmlZq?4Go^M2D#pa8<8yvNwZqI~9_Rz1V0hpxK2)={AEFR8=lbCp2ozes0Jj(j zn$=zygJ9vf7oJ78P&)v(*I@(x7KB$D>m*K&(AXf-xqXs(X$-!JThSw+Gc_WXN(V*r zy(lbTqfW#igpGPV22KpQ83VPdTC&R%3x^Z%zPn~w$wJQpoPt&F#i!vEv*MXOUxz=h zI$amw;T5Nlz5uYXF01NVhRPEGWjs4$o>>HE?Ftk!FD*i6XvLM1*_m-Sq4uZOr}6)W z_m*(aTHG^FG+w9i4ED8jMf5r7swn{>bKyDY5K7Kk`sG7KxQx9VE|RCS<4P(~;^v%o#a>qflbLZwZ-8K*-#)1dhIvvzECGEn{9r3$HCf z1(=_mgC_IMF{ZNc&I|CP&zm=I!j{6b@4=7P6_@7YAHad?xUI*Kx#8E)Wp23!%_TrG z-PfSK(ETCoI=Cuil4n9kL&XC+pN?mAnO%0Kb^JxF=u|9(BmXn5RQ__5dHG3ZYj2ru z|L0(-y5d3egRM+s1-@PLE9V&Rn&G;7j%i(AMrk6jb$!{jMZi%;$F1I4tYmrK&6)E| Zx9J^aT!l;L84b*P3ye^pUu7zq{|S7gPO<<1 diff --git a/php/modules/Album.php b/php/modules/Album.php index a45d398..5c74a84 100644 --- a/php/modules/Album.php +++ b/php/modules/Album.php @@ -154,8 +154,15 @@ class Album extends Module { # Call plugins $this->plugins(__METHOD__, 0, func_get_args()); + # Initialize return var + $return = array( + 'smartalbums' => null, + 'albums' => null, + 'num' => 0 + ); + # Get SmartAlbums - if ($public===false) $return = $this->getSmartInfo(); + if ($public===false) $return['smartalbums'] = $this->getSmartInfo(); # Albums query $query = Database::prepare($this->database, 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0', array(LYCHEE_TABLE_ALBUMS)); @@ -192,7 +199,7 @@ class Album extends Module { } # Add to return - $return['content'][$album['id']] = $album; + $return['albums'][$album['id']] = $album; } @@ -211,29 +218,25 @@ class Album extends Module { # Check dependencies self::dependencies(isset($this->database, $this->settings)); + # Initialize return var + $return = array( + 'unsorted' => null, + 'public' => null, + 'starred' => null, + 'recent' => null + ); + # Unsorted $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE album = 0 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); $unsorted = $this->database->query($query); $i = 0; while($row = $unsorted->fetch_object()) { if ($i<3) { - $return["unsortedThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row->thumbUrl; + $return['unsorted']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row->thumbUrl; $i++; } else break; } - $return['unsortedNum'] = $unsorted->num_rows; - - # Public - $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); - $public = $this->database->query($query); - $i = 0; - while($row2 = $public->fetch_object()) { - if ($i<3) { - $return["publicThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row2->thumbUrl; - $i++; - } else break; - } - $return['publicNum'] = $public->num_rows; + $return['unsorted']['num'] = $unsorted->num_rows; # Starred $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE star = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); @@ -241,11 +244,23 @@ class Album extends Module { $i = 0; while($row3 = $starred->fetch_object()) { if ($i<3) { - $return["starredThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl; + $return['starred']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl; $i++; } else break; } - $return['starredNum'] = $starred->num_rows; + $return['starred']['num'] = $starred->num_rows; + + # Public + $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); + $public = $this->database->query($query); + $i = 0; + while($row2 = $public->fetch_object()) { + if ($i<3) { + $return['public']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row2->thumbUrl; + $i++; + } else break; + } + $return['public']['num'] = $public->num_rows; # Recent $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); @@ -253,11 +268,11 @@ class Album extends Module { $i = 0; while($row3 = $recent->fetch_object()) { if ($i<3) { - $return["recentThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl; + $return['recent']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl; $i++; } else break; } - $return['recentNum'] = $recent->num_rows; + $return['recent']['num'] = $recent->num_rows; return $return; diff --git a/src/scripts/album.js b/src/scripts/album.js index 61c52b9..b75460f 100644 --- a/src/scripts/album.js +++ b/src/scripts/album.js @@ -179,7 +179,7 @@ album.delete = function(albumIDs) { albumIDs.forEach(function(id) { albums.json.num--; view.albums.content.delete(id); - delete albums.json.content[id]; + delete albums.json.albums[id]; }); } else { @@ -209,7 +209,7 @@ album.delete = function(albumIDs) { // Get title if (album.json) albumTitle = album.json.title; - else if (albums.json) albumTitle = albums.json.content[albumIDs].title; + else if (albums.json) albumTitle = albums.json.albums[albumIDs].title; msg = "

Are you sure you want to delete the album '" + albumTitle + "' and all of the photos it contains? This action can't be undone!

"; @@ -253,7 +253,7 @@ album.setTitle = function(albumIDs) { // Get old title if only one album is selected if (album.json) oldTitle = album.json.title; - else if (albums.json) oldTitle = albums.json.content[albumIDs].title; + else if (albums.json) oldTitle = albums.json.albums[albumIDs].title; if (!oldTitle) oldTitle = ''; oldTitle = oldTitle.replace("'", '''); @@ -280,13 +280,13 @@ album.setTitle = function(albumIDs) { if (albums.json) { var id = albumIDs[0]; - albums.json.content[id].title = newTitle; + albums.json.albums[id].title = newTitle; } } else if (visible.albums()) { albumIDs.forEach(function(id) { - albums.json.content[id].title = newTitle; + albums.json.albums[id].title = newTitle; view.albums.content.title(id); }); diff --git a/src/scripts/albums.js b/src/scripts/albums.js index 8a447ea..a93f176 100644 --- a/src/scripts/albums.js +++ b/src/scripts/albums.js @@ -25,44 +25,44 @@ albums.load = function() { api.post('Album::getAll', {}, function(data) { /* Smart Albums */ - data.unsortedAlbum = { + data.smartalbums.unsorted = { id: 0, title: 'Unsorted', - sysdate: data.unsortedNum + ' photos', + sysdate: data.smartalbums.unsorted.num + ' photos', unsorted: '1', - thumb0: data.unsortedThumb0, - thumb1: data.unsortedThumb1, - thumb2: data.unsortedThumb2 + thumb0: data.smartalbums.unsorted.thumb0, + thumb1: data.smartalbums.unsorted.thumb1, + thumb2: data.smartalbums.unsorted.thumb2 }; - data.starredAlbum = { + data.smartalbums.starred = { id: 'f', title: 'Starred', - sysdate: data.starredNum + ' photos', + sysdate: data.smartalbums.starred.num + ' photos', star: '1', - thumb0: data.starredThumb0, - thumb1: data.starredThumb1, - thumb2: data.starredThumb2 + thumb0: data.smartalbums.starred.thumb0, + thumb1: data.smartalbums.starred.thumb1, + thumb2: data.smartalbums.starred.thumb2 }; - data.publicAlbum = { + data.smartalbums.public = { id: 's', title: 'Public', - sysdate: data.publicNum + ' photos', + sysdate: data.smartalbums.public.num + ' photos', public: '1', - thumb0: data.publicThumb0, - thumb1: data.publicThumb1, - thumb2: data.publicThumb2 + thumb0: data.smartalbums.public.thumb0, + thumb1: data.smartalbums.public.thumb1, + thumb2: data.smartalbums.public.thumb2 }; - data.recentAlbum = { + data.smartalbums.recent = { id: 'r', title: 'Recent', - sysdate: data.recentNum + ' photos', + sysdate: data.smartalbums.recent.num + ' photos', recent: '1', - thumb0: data.recentThumb0, - thumb1: data.recentThumb1, - thumb2: data.recentThumb2 + thumb0: data.smartalbums.recent.thumb0, + thumb1: data.smartalbums.recent.thumb1, + thumb2: data.smartalbums.recent.thumb2 }; albums.json = data; @@ -79,7 +79,7 @@ albums.load = function() { setTimeout(function() { header.setMode('albums'); view.albums.init(); - lychee.animate('.album, .photo', 'contentZoomIn'); + lychee.animate('.album', 'contentZoomIn'); }, waitTime); }); diff --git a/src/scripts/contextMenu.js b/src/scripts/contextMenu.js index 9659fb9..2a3e70f 100644 --- a/src/scripts/contextMenu.js +++ b/src/scripts/contextMenu.js @@ -82,7 +82,7 @@ contextMenu.albumTitle = function(albumID, e) { items.push({ type: 'separator' }); // Generate list of albums - $.each(data.content, function(index) { + $.each(data.albums, function(index) { var that = this, title = ''; @@ -220,7 +220,7 @@ contextMenu.move = function(photoIDs, e) { } else { // Generate list of albums - $.each(data.content, function(index) { + $.each(data.albums, function(index) { var that = this; diff --git a/src/scripts/password.js b/src/scripts/password.js index 10440c6..6267559 100644 --- a/src/scripts/password.js +++ b/src/scripts/password.js @@ -16,7 +16,7 @@ password.get = function(albumID, callback) { if (!lychee.publicMode) callback(); else if (album.json&&album.json.password==false) callback(); - else if (albums.json&&albums.json.content[albumID].password==false) callback(); + else if (albums.json&&albums.json.albums[albumID].password==false) callback(); else if (!albums.json&&!album.json) { // Continue without password diff --git a/src/scripts/view.js b/src/scripts/view.js index 2668b71..8385358 100644 --- a/src/scripts/view.js +++ b/src/scripts/view.js @@ -49,16 +49,21 @@ view.albums = { albumsData = ''; /* Smart Albums */ - albums.parse(albums.json.unsortedAlbum); - albums.parse(albums.json.publicAlbum); - albums.parse(albums.json.starredAlbum); - albums.parse(albums.json.recentAlbum); - if (!lychee.publicMode) smartData = build.divider('Smart Albums') + build.album(albums.json.unsortedAlbum) + build.album(albums.json.starredAlbum) + build.album(albums.json.publicAlbum) + build.album(albums.json.recentAlbum); + if (!lychee.publicMode) { + + albums.parse(albums.json.smartalbums.unsorted); + albums.parse(albums.json.smartalbums.public); + albums.parse(albums.json.smartalbums.starred); + albums.parse(albums.json.smartalbums.recent); + + smartData = build.divider('Smart Albums') + build.album(albums.json.smartalbums.unsorted) + build.album(albums.json.smartalbums.public) + build.album(albums.json.smartalbums.starred) + build.album(albums.json.smartalbums.recent); + + } /* Albums */ - if (albums.json.content&&albums.json.num!==0) { + if (albums.json.albums&&albums.json.num!==0) { - $.each(albums.json.content, function() { + $.each(albums.json.albums, function() { albums.parse(this); // Display albums in reverse order @@ -88,7 +93,7 @@ view.albums = { title: function(albumID) { var longTitle = '', - title = albums.json.content[albumID].title; + title = albums.json.albums[albumID].title; if (title!==null&&title.length>18) { longTitle = title;