Use Album::prepareData in search
This commit is contained in:
parent
ea149b68af
commit
c9f5d112d4
@ -20,9 +20,13 @@ function search($database, $settings, $term) {
|
|||||||
'hash' => ''
|
'hash' => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
|
###
|
||||||
# Photos
|
# Photos
|
||||||
|
###
|
||||||
|
|
||||||
$query = Database::prepare($database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%' OR tags LIKE '%?%'", array(LYCHEE_TABLE_PHOTOS, $term, $term, $term));
|
$query = Database::prepare($database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%' OR tags LIKE '%?%'", array(LYCHEE_TABLE_PHOTOS, $term, $term, $term));
|
||||||
$result = $database->query($query);
|
$result = $database->query($query);
|
||||||
|
|
||||||
while($photo = $result->fetch_assoc()) {
|
while($photo = $result->fetch_assoc()) {
|
||||||
|
|
||||||
$photo = Photo::prepareData($photo);
|
$photo = Photo::prepareData($photo);
|
||||||
@ -30,29 +34,31 @@ function search($database, $settings, $term) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###
|
||||||
# Albums
|
# Albums
|
||||||
|
###
|
||||||
|
|
||||||
$query = Database::prepare($database, "SELECT id, title, public, sysstamp, password FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%'", array(LYCHEE_TABLE_ALBUMS, $term, $term));
|
$query = Database::prepare($database, "SELECT id, title, public, sysstamp, password FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%'", array(LYCHEE_TABLE_ALBUMS, $term, $term));
|
||||||
$result = $database->query($query);
|
$result = $database->query($query);
|
||||||
$i = 0;
|
|
||||||
while($row = $result->fetch_object()) {
|
|
||||||
|
|
||||||
# Info
|
while($album = $result->fetch_assoc()) {
|
||||||
$return['albums'][$row->id]['id'] = $row->id;
|
|
||||||
$return['albums'][$row->id]['title'] = $row->title;
|
# Turn data from the database into a front-end friendly format
|
||||||
$return['albums'][$row->id]['public'] = $row->public;
|
$album = Album::prepareData($album);
|
||||||
$return['albums'][$row->id]['sysdate'] = date('F Y', $row->sysstamp);
|
|
||||||
$return['albums'][$row->id]['password'] = ($row->password=='' ? false : true);
|
|
||||||
|
|
||||||
# Thumbs
|
# Thumbs
|
||||||
$query = Database::prepare($database, "SELECT thumbUrl FROM ? WHERE album = '?' " . $settings['sorting'] . " LIMIT 0, 3", array(LYCHEE_TABLE_PHOTOS, $row->id));
|
$query = Database::prepare($database, "SELECT thumbUrl FROM ? WHERE album = '?' " . $settings['sorting'] . " LIMIT 0, 3", array(LYCHEE_TABLE_PHOTOS, $album['id']));
|
||||||
$result2 = $database->query($query);
|
$thumbs = $database->query($query);
|
||||||
$k = 0;
|
|
||||||
while($row2 = $result2->fetch_object()){
|
# For each thumb
|
||||||
$return['albums'][$row->id]["thumb$k"] = LYCHEE_URL_UPLOADS_THUMB . $row2->thumbUrl;
|
$k = 0;
|
||||||
|
while ($thumb = $thumbs->fetch_object()) {
|
||||||
|
$album['thumbs'][$k] = LYCHEE_URL_UPLOADS_THUMB . $thumb->thumbUrl;
|
||||||
$k++;
|
$k++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
# Add to return
|
||||||
|
$return['albums'][$album['id']] = $album;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user