$SETTINGS["unsplash"]["appid"],
'secret' => $SETTINGS["unsplash"]["secretkey"],
'utmSource' => $SETTINGS["unsplash"]["utmsource"]
]);
$page = 1;
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
$page = $_GET['page'];
}
$per_page = 15;
$results = null;
if (isset($_GET['query']) && $_GET['query'] != "") {
$results = Crew\Unsplash\Search::photos($_GET['query'], $page, $per_page, null, null);
$images = $results->getArrayObject();
} else {
$images = Crew\Unsplash\Photo::all($page, $per_page, 'popular');
}
$images->
$htmlout = "";
if (count($images) == 0) {
$htmlout = "
" . $Strings->get("no results", false) . "
";
}
$htmlout .= '';
foreach ($images as $img) {
$imageid = $img->id;
$description = $img->description;
$thumb = $img->urls['thumb'];
$image = $img->urls['regular'];
$attribution = '
' . $img->user['name'] . '';
$card = <<
END;
$htmlout .= $card;
}
$htmlout .= '';
$jsonout = [
'total' => null,
'pages' => null,
'page' => $page,
'html' => $htmlout
];
if (!is_null($results)) {
$jsonout['total'] = $Strings->build("x results", ["results" => $results->getTotal()], false);
$jsonout['pages'] = $results->getTotalPages();
}
echo json_encode($jsonout);