diff --git a/code/controllers/StaticExporter.php b/code/controllers/StaticExporter.php
deleted file mode 100644
index 613f2e76..00000000
--- a/code/controllers/StaticExporter.php
+++ /dev/null
@@ -1,114 +0,0 @@
-Usage
- *
- * The exporter can only be invoked through a URL. Usage on commandline (through [sake](sake)) is not possible at the moment, as we're sending a file to the browser for download.
- *
- *
http://localhost/StaticExporter/export
- *
- * Specify a custom baseurl in case you want to deploy the static HTML pages on a different host:
- * http://localhost/StaticExporter/export?baseurl=http://example.com
- *
- * @see StaticPublisher
- *
- * @package cms
- * @subpackage export
- */
-class StaticExporter extends Controller {
-
- private static $allowed_actions = array(
- 'index',
- 'export',
- );
-
- public function init() {
- parent::init();
-
- $canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN"));
- if(!$canAccess) return Security::permissionFailure($this);
- }
-
-
- public function Link($action = null) {
- return "StaticExporter/$action";
- }
-
- public function index() {
- echo ""._t('StaticExporter.NAME','Static exporter')."
";
- echo $this->StaticExportForm()->forTemplate();
- }
-
- public function StaticExportForm() {
- return new Form($this, 'StaticExportForm', new FieldList(
- // new TextField('folder', _t('StaticExporter.FOLDEREXPORT','Folder to export to')),
- new TextField('baseurl', _t('StaticExporter.BASEURL','Base URL'))
- ), new FieldList(
- new FormAction('export', _t('StaticExporter.EXPORTTO','Export to that folder'))
- ));
- }
-
- public function export() {
- // specify custom baseurl for publishing to other webroot
- if(isset($_REQUEST['baseurl'])) {
- $base = $_REQUEST['baseurl'];
- if(substr($base,-1) != '/') $base .= '/';
- Config::inst()->update('Director', 'alternate_base_url', $base);
- }
-
- // setup temporary folders
- $tmpBaseFolder = TEMP_FOLDER . '/static-export';
- $tmpFolder = (project()) ? "$tmpBaseFolder/" . project() : "$tmpBaseFolder/site";
- if(!file_exists($tmpFolder)) Filesystem::makeFolder($tmpFolder);
- $baseFolderName = basename($tmpFolder);
-
- // symlink /assets
- $f1 = ASSETS_PATH;
- $f2 = Director::baseFolder() . '/' . project();
- `cd $tmpFolder; ln -s $f1; ln -s $f2`;
-
- // iterate through all instances of SiteTree
- $pages = DataObject::get("SiteTree");
- foreach($pages as $page) {
- $subfolder = "$tmpFolder/" . trim($page->RelativeLink(null, true), '/');
- $contentfile = "$tmpFolder/" . trim($page->RelativeLink(null, true), '/') . '/index.html';
-
- // Make the folder
- if(!file_exists($subfolder)) {
- Filesystem::makeFolder($subfolder);
- }
-
- // Run the page
- Requirements::clear();
- $link = Director::makeRelative($page->Link());
- $response = Director::test($link);
-
- // Write to file
- if($fh = fopen($contentfile, 'w')) {
- fwrite($fh, $response->getBody());
- fclose($fh);
- }
- }
-
- // copy homepage (URLSegment: "home") to webroot
- copy("$tmpFolder/home/index.html", "$tmpFolder/index.html");
-
- // archive all generated files
- `cd $tmpBaseFolder; tar -czhf $baseFolderName.tar.gz $baseFolderName`;
- $archiveContent = file_get_contents("$tmpBaseFolder/$baseFolderName.tar.gz");
-
- // remove temporary files and folder
- Filesystem::removeFolder($tmpBaseFolder);
-
- // return as download to the client
- $response = SS_HTTPRequest::send_file($archiveContent, "$baseFolderName.tar.gz", 'application/x-tar-gz');
- echo $response->output();
- }
-
-}
-
diff --git a/code/staticpublisher/FilesystemPublisher.php b/code/staticpublisher/FilesystemPublisher.php
deleted file mode 100644
index 9ae0952b..00000000
--- a/code/staticpublisher/FilesystemPublisher.php
+++ /dev/null
@@ -1,371 +0,0 @@
-pagesAffectedByUnpublishing() to return other URLS
- * that should be de-cached if $page is unpublished.
- *
- * @see http://doc.silverstripe.com/doku.php?id=staticpublisher
- *
- * @package cms
- * @subpackage publishers
- */
-class FilesystemPublisher extends StaticPublisher {
-
- /**
- * @var String
- */
- protected $destFolder = 'cache';
-
- /**
- * @var String
- */
- protected $fileExtension = 'html';
-
- /**
- * @config
- * @var String
- */
- private static $static_base_url = null;
-
- /**
- * @config
- * @var Boolean Use domain based cacheing (put cache files into a domain subfolder)
- * This must be true if you are using this with the "subsites" module.
- * Please note that this form of caching requires all URLs to be provided absolute
- * (not relative to the webroot) via {@link SiteTree->AbsoluteLink()}.
- */
- private static $domain_based_caching = false;
-
- /**
- * Set a different base URL for the static copy of the site.
- * This can be useful if you are running the CMS on a different domain from the website.
- *
- * @deprecated 3.2 Use the "FilesystemPublisher.static_base_url" config setting instead
- */
- static public function set_static_base_url($url) {
- Deprecation::notice('3.2', 'Use the "FilesystemPublisher.static_base_url" config setting instead');
- Config::inst()->update('FilesystemPublisher', 'static_base_url', $url);
- }
-
- /**
- * @param $destFolder The folder to save the cached site into.
- * This needs to be set in framework/static-main.php as well through the {@link $cacheBaseDir} variable.
- * @param $fileExtension The file extension to use, e.g 'html'.
- * If omitted, then each page will be placed in its own directory,
- * with the filename 'index.html'. If you set the extension to PHP, then a simple PHP script will
- * be generated that can do appropriate cache & redirect header negotation.
- */
- public function __construct($destFolder = 'cache', $fileExtension = null) {
- // Remove trailing slash from folder
- if(substr($destFolder, -1) == '/') $destFolder = substr($destFolder, 0, -1);
-
- $this->destFolder = $destFolder;
- $this->fileExtension = $fileExtension;
-
- parent::__construct();
- }
-
- /**
- * Transforms relative or absolute URLs to their static path equivalent.
- * This needs to be the same logic that's used to look up these paths through
- * framework/static-main.php. Does not include the {@link $destFolder} prefix.
- *
- * URL filtering will have already taken place for direct SiteTree links via SiteTree->generateURLSegment()).
- * For all other links (e.g. custom controller actions), we assume that they're pre-sanitized
- * to suit the filesystem needs, as its impossible to sanitize them without risking to break
- * the underlying naming assumptions in URL routing (e.g. controller method names).
- *
- * Examples (without $domain_based_caching):
- * - http://mysite.com/mywebroot/ => /index.html (assuming your webroot is in a subfolder)
- * - http://mysite.com/about-us => /about-us.html
- * - http://mysite.com/parent/child => /parent/child.html
- *
- * Examples (with $domain_based_caching):
- * - http://mysite.com/mywebroot/ => /mysite.com/index.html (assuming your webroot is in a subfolder)
- * - http://mysite.com/about-us => /mysite.com/about-us.html
- * - http://myothersite.com/about-us => /myothersite.com/about-us.html
- * - http://subdomain.mysite.com/parent/child => /subdomain.mysite.com/parent/child.html
- *
- * @param Array $urls Absolute or relative URLs
- * @return Array Map of original URLs to filesystem paths (relative to {@link $destFolder}).
- */
- public function urlsToPaths($urls) {
- $mappedUrls = array();
- foreach($urls as $url) {
-
- // parse_url() is not multibyte safe, see https://bugs.php.net/bug.php?id=52923.
- // We assume that the URL hsa been correctly encoded either on storage (for SiteTree->URLSegment),
- // or through URL collection (for controller method names etc.).
- $urlParts = @parse_url($url);
-
- // Remove base folders from the URL if webroot is hosted in a subfolder (same as static-main.php)
- $path = isset($urlParts['path']) ? $urlParts['path'] : '';
- if(mb_substr(mb_strtolower($path), 0, mb_strlen(BASE_URL)) == mb_strtolower(BASE_URL)) {
- $urlSegment = mb_substr($path, mb_strlen(BASE_URL));
- } else {
- $urlSegment = $path;
- }
-
- // Normalize URLs
- $urlSegment = trim($urlSegment, '/');
-
- $filename = $urlSegment ? "$urlSegment.$this->fileExtension" : "index.$this->fileExtension";
-
- if (Config::inst()->get('FilesystemPublisher', 'domain_based_caching')) {
- if (!$urlParts) continue; // seriously malformed url here...
- $filename = $urlParts['host'] . '/' . $filename;
- }
-
- $mappedUrls[$url] = ((dirname($filename) == '/') ? '' : (dirname($filename).'/')).basename($filename);
- }
-
- return $mappedUrls;
- }
-
- public function unpublishPages($urls) {
- // Do we need to map these?
- // Detect a numerically indexed arrays
- if (is_numeric(join('', array_keys($urls)))) $urls = $this->urlsToPaths($urls);
-
- // This can be quite memory hungry and time-consuming
- // @todo - Make a more memory efficient publisher
- increase_time_limit_to();
- increase_memory_limit_to();
-
- $cacheBaseDir = $this->getDestDir();
-
- foreach($urls as $url => $path) {
- if (file_exists($cacheBaseDir.'/'.$path)) {
- @unlink($cacheBaseDir.'/'.$path);
- }
- }
- }
-
- /**
- * Uses {@link Director::test()} to perform in-memory HTTP requests
- * on the passed-in URLs.
- *
- * @param array $urls Relative URLs
- * @return array Result, keyed by URL. Keys:
- * - "statuscode": The HTTP status code
- * - "redirect": A redirect location (if applicable)
- * - "path": The filesystem path where the cache has been written
- */
- public function publishPages($urls) {
- $result = array();
-
- // Do we need to map these?
- // Detect a numerically indexed arrays
- if (is_numeric(join('', array_keys($urls)))) $urls = $this->urlsToPaths($urls);
-
- // This can be quite memory hungry and time-consuming
- // @todo - Make a more memory efficient publisher
- increase_time_limit_to();
- increase_memory_limit_to();
-
- // Set the appropriate theme for this publication batch.
- // This may have been set explicitly via StaticPublisher::static_publisher_theme,
- // or we can use the last non-null theme.
- $customTheme = Config::inst()->get('StaticPublisher', 'static_publisher_theme');
- if(!$customTheme)
- Config::inst()->update('SSViewer', 'theme', Config::inst()->get('SSViewer', 'custom_theme'));
- else
- Config::inst()->update('SSViewer', 'theme', $customTheme);
-
- $currentBaseURL = Director::baseURL();
- $staticBaseUrl = Config::inst()->get('FilesystemPublisher', 'static_base_url');
- if($staticBaseUrl) Config::inst()->update('Director', 'alternate_base_url', $staticBaseUrl);
- if($this->fileExtension == 'php') {
- Config::inst()->update('SSViewer', 'rewrite_hash_links', 'php');
- }
- if(Config::inst()->get('StaticPublisher', 'echo_progress')) {
- echo $this->class.": Publishing to " . $staticBaseUrl . "\n";
- }
- $files = array();
- $i = 0;
- $totalURLs = sizeof($urls);
- foreach($urls as $url => $path) {
- $origUrl = $url;
- $result[$origUrl] = array('statuscode' => null, 'redirect' => null, 'path' => null);
-
- if($staticBaseUrl) Config::inst()->update('Director', 'alternate_base_url', $staticBaseUrl);
- $i++;
-
- if($url && !is_string($url)) {
- user_error("Bad url:" . var_export($url,true), E_USER_WARNING);
- continue;
- }
-
- if(Config::inst()->get('StaticPublisher', 'echo_progress')) {
- echo " * Publishing page $i/$totalURLs: $url\n";
- flush();
- }
-
- Requirements::clear();
-
- if($url == "") $url = "/";
- if(Director::is_relative_url($url)) $url = Director::absoluteURL($url);
- $response = Director::test(str_replace('+', ' ', $url));
-
- if($response) {
- $result[$origUrl]['statuscode'] = $response->getStatusCode();
- }
-
- Requirements::clear();
-
- singleton('DataObject')->flushCache();
-
- //skip any responses with a 404 status code. We don't want to turn those into statically cached pages
- if (!$response || $response->getStatusCode() == '404') continue;
-
- // Generate file content
- // PHP file caching will generate a simple script from a template
- if($this->fileExtension == 'php') {
- if(is_object($response)) {
- if($response->getStatusCode() == '301' || $response->getStatusCode() == '302') {
- $content = $this->generatePHPCacheRedirection($response->getHeader('Location'));
- } else {
- $content = $this->generatePHPCacheFile($response->getBody(), HTTP::get_cache_age(), date('Y-m-d H:i:s'));
- }
- } else {
- $content = $this->generatePHPCacheFile($response . '', HTTP::get_cache_age(), date('Y-m-d H:i:s'));
- }
-
- // HTML file caching generally just creates a simple file
- } else {
- if(is_object($response)) {
- if($response->getStatusCode() == '301' || $response->getStatusCode() == '302') {
- $absoluteURL = Director::absoluteURL($response->getHeader('Location'));
- $result[$origUrl]['redirect'] = $response->getHeader('Location');
- $content = "";
- } else {
- $content = $response->getBody();
- }
- } else {
- $content = $response . '';
- }
- }
-
- if(Config::inst()->get('StaticPublisher', 'include_caching_metadata')) {
- $content = str_replace(
- '