public function SubsiteList() { if ($this->owner->class == 'AssetAdmin') { // See if the right decorator is there.... $file = new File(); if (!$file->hasExtension('FileSubsites')) { return false; } } $list = $this->Subsites(); $currentSubsiteID = Subsite::currentSubsiteID(); if ($list->Count() > 1) { $output = '<select id="SubsitesSelect">'; foreach ($list as $subsite) { $selected = $subsite->ID == $currentSubsiteID ? ' selected="selected"' : ''; $output .= "\n<option value=\"{$subsite->ID}\"{$selected}>" . htmlspecialchars($subsite->Title, ENT_QUOTES) . "</option>"; } $output .= '</select>'; Requirements::javascript('subsites/javascript/LeftAndMain_Subsites.js'); return $output; } else { if ($list->Count() == 1) { return $list->First()->Title; } } }
/** * Sends the given file by whatever method is appropriate. Uses php's * header() instead of silverstripe's HTTPResponse class to prevent other * headers from being added and so we can just use readfile() instead of * pulling the whole file into a string for setBody(). * * @param File $file */ protected function sendFile(File $file) { // this is for optional compatibility with markguinn/silverstripe-cloudassets if ($file->hasExtension('CloudFileExtension') && $file->CloudStatus === 'Live') { header('Location: ' . $file->getAbsoluteURL()); exit; } // this is the normal way to send the files header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $file->Name . '"'); if (Config::inst()->get('Downloadable', 'use_xsendfile')) { header('X-Sendfile: ' . $file->getURL()); } else { header('Content-Length: ' . $file->getAbsoluteSize()); readfile($file->getFullPath()); } exit; }