I'd prefer to have that logic outside of the template in the "controller" apps/files_sharing/public.php