silverstripe-subsites/code/extensions/ErrorPageSubsite.php

37 lines
1.3 KiB
PHP
Raw Normal View History

2009-10-05 23:01:01 +02:00
<?php
BUG: Modifying the module to work with SS 3.0 Replaced deprecated DataObjectDecorator with DataExtension Fixed hard crashes in the cms Updated to support new LeftAndMain template structure Made the subsites model admin functional Moved the LeftAndMain_Menu template up a directory so it overrides the core Fixed some errors caused by changes to the framework Re-organized the code folder Fixed permission issue causing to default to first subsite regardless if it is the default or not Fixed crashes on the subsite virtual page when creating/editing Removed toDropdownMap() calls replacing with map() Fixed the URLSegment field on subsites Fixed error when detecting subsite for a domain Improved styles on the subsite dropdown Updated LeftAndMain_Subsites.js to work with jQuery entwine Started porting the SubsitesTreeDropdownField.js to use jQuery entwine and work with the new TreeDropdownField.js Fixed issue causing crash when viewing a page who is linked to by a subsite virtual page Removed unused methods on SubsitesTreeDropdownField.js Re-added classes that were moved Fixed hard crash after saving caused by the many_many definition on SiteTreeSubsites Replaced deprecated DataObjectSet creation with ArrayList Compatibility fixes with SS 3.0 beta 2 Fixed crash in cms caused by no parameter being passed to the SubsiteReportWrapper constructor Proper fix for report wrapper Removed table list field in favor of a basic grid field Fixed updateCMSFields() for file subsites Migrated translations to yml Fixed issue causing the current page to not get cleared when changing subsites in the cms Fixed virtual page icon Fixed language files issue
2012-03-25 18:35:01 +02:00
class ErrorPageSubsite extends DataExtension {
2009-10-05 23:01:01 +02:00
/**
* Alter file path to generated a static (static) error page file to handle error page template on different sub-sites
*
* {@see Error::get_error_filename()}
2009-10-05 23:01:01 +02:00
*
* FIXME since {@link Subsite::currentSubsite()} partly relies on Session, viewing other sub-site (including main site) between
* opening ErrorPage in the CMS and publish ErrorPage causes static error page to get generated incorrectly.
*
* @param string $name Filename to write to
* @param int $statusCode Integer error code
2009-10-05 23:01:01 +02:00
*/
public function updateErrorFilename(&$name, $statusCode) {
// Try to get current subsite from session
$subsite = Subsite::currentSubsite(false);
// since this function is called from Page class before the controller is created, we have to get subsite from domain instead
if(!$subsite) {
$subsiteID = Subsite::getSubsiteIDForDomain();
if($subsiteID != 0) {
$subsite = DataObject::get_by_id("Subsite", $subsiteID);
}
}
// Without subsite, don't rewrite
if($subsite) {
// Add subdomain to end of filename, just before .html
// This should preserve translatable locale in the filename as well
2010-03-31 00:50:37 +02:00
$subdomain = $subsite->domain();
$name = substr($name, 0, -5) . "-{$subdomain}.html";
2009-10-05 23:01:01 +02:00
}
}
}