public function run($request) { $files = DownloadTempFile::get(); $num = 0; foreach ($files as $file) { $file->delete(); $num++; } echo "{$num} files were deleted."; }
/** * @param DownloadTempFile $dl * @return HTMLText */ protected function displayCrunchingPage(DownloadTempFile $dl) { $crunchingPage = Config::inst()->get('Downloadable', 'crunching_page'); if ($crunchingPage) { $crunchingPage = SiteTree::get_by_link($crunchingPage); } if (!$crunchingPage || !$crunchingPage->exists()) { $crunchingPage = new Page(); $crunchingPage->Title = _t('Downloadable.CRUNCHINGTITLE', 'Processing Your Download'); $crunchingPage->Content = _t('Downloadable.CRUNCHINGBODY', '<p>Please wait while your download is prepared.</p>'); } // Just in case $this->dataRecord = $crunchingPage; // Add a meta tag that will refresh with the request that actually does the processing // In the future this could be wrapped in a <noscript> and we could do some better ajax // work to make this more userfriendly (such as a progress bar for multiple files, etc) Requirements::insertHeadTags('<meta http-equiv="refresh" content="1; url=' . $dl->getProcessingLink() . '">'); // And....render return $this->customise($crunchingPage)->renderWith(array('CrunchingPage', 'Page', 'Page')); }
public function exists() { $this->createLocalIfNeeded(); return parent::exists(); }