MINOR Merged from 2.3

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@75838 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-05-01 03:36:04 +00:00 committed by Sam Minnee
parent e825a3b118
commit 51523935fc
3 changed files with 12 additions and 12 deletions

View File

@ -149,12 +149,12 @@ class ErrorPage extends Page {
* which is generated through {@link publish()}.
*
* @param int $statusCode A HTTP Statuscode, mostly 404 or 500
* @param String $lang A language code in short locale format, e.g. 'de' (Optional)
* @param String $locale A locale, e.g. 'de_DE' (Optional)
* @return String
*/
static function get_filepath_for_errorcode($statusCode, $lang = null) {
if(Translatable::is_enabled() && $lang && $lang != Translatable::default_lang()) {
return self::$static_filepath . "/error-{$statusCode}-{$lang}.html";
static function get_filepath_for_errorcode($statusCode, $locale = null) {
if(singleton('SiteTree')->hasExtension('Translatable') && $locale && $locale != Translatable::default_locale()) {
return self::$static_filepath . "/error-{$statusCode}-{$locale}.html";
} else {
return self::$static_filepath . "/error-{$statusCode}.html";
}

View File

@ -451,11 +451,14 @@ class Translatable extends DataObjectDecorator {
* Use {@link $enable_lang_filter} to temporarily disable this "auto-filtering".
*/
function augmentSQL(SQLQuery &$query) {
$lang = Translatable::current_locale();
// If the record is saved (and not a singleton), and has a locale,
// limit the current call to its locale. This fixes a lot of problems
// with other extensions like Versioned
$locale = ($this->owner->ID && $this->owner->Locale) ? $this->owner->Locale : Translatable::current_locale();
$baseTable = ClassInfo::baseDataClass($this->owner->class);
$where = $query->where;
if(
$lang
$locale
// unless the filter has been temporarily disabled
&& self::$enable_lang_filter
// DataObject::get_by_id() should work independently of language
@ -467,11 +470,7 @@ class Translatable extends DataObjectDecorator {
&& !preg_match('/("|\')Lang("|\')/', $query->getFilter())
//&& !$query->filtersOnFK()
) {
$qry = "`Locale` = '$lang'";
if(self::$default_locale == self::current_locale()) {
$qry .= " OR `Locale` = '' ";
$qry .= " OR `Locale` IS NULL ";
}
$qry = sprintf('`%s`.`Locale` = \'%s\'', $baseTable, $locale);
$query->where[] = $qry;
}
}

View File

@ -142,6 +142,7 @@ class TestRunner extends Controller {
// run tests before outputting anything to the client
$suite = new PHPUnit_Framework_TestSuite();
natcasesort($classList);
foreach($classList as $className) {
// Ensure that the autoloader pulls in the test class, as PHPUnit won't know how to do this.
class_exists($className);
@ -157,7 +158,7 @@ class TestRunner extends Controller {
self::$default_reporter->writeHeader("Sapphire Test Runner");
if (count($classList) > 1) {
self::$default_reporter->writeInfo("All Tests", "Running test cases: " . implode(", ", $classList));
self::$default_reporter->writeInfo("All Tests", "Running test cases: " . implode(",", $classList));
} else {
self::$default_reporter->writeInfo($classList[0], "");
}