public function handleRecentItems(SS_HTTPRequest $r)
{
$result = array();
$fileIDs = File::get()->sort('LastEdited', 'DESC')->limit($this->config()->recent_items_limit)->column('ID');
if (!empty($fileIDs)) {
$files = File::get()->sort($this->getSortClause($r->getVar('sort')))->byIDs($fileIDs);
foreach ($files as $file) {
if (!$file->canView()) {
continue;
}
$result[] = $file instanceof Folder ? $this->createFolderJSON($file) : $this->createFileJSON($file);
}
}
return (new SS_HTTPResponse(Convert::array2json($result), 200))->addHeader('Content-Type', 'application/json');
}