API CHANGE Deprecated Translatable::current_lang(), use Translatable::get_current_locale()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@76853 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-05-14 06:05:48 +00:00
parent b1018f5864
commit 67180937ff
6 changed files with 19 additions and 19 deletions

View File

@ -318,7 +318,7 @@ HTML;
* Returns the xml:lang and lang attributes
*/
function LangAttributes() {
$lang = Translatable::current_locale();
$lang = Translatable::get_current_locale();
return "xml:lang=\"$lang\" lang=\"$lang\"";
}

View File

@ -67,7 +67,7 @@ class RootURLController extends Controller {
}
if(singleton('SiteTree')->hasExtension('Translatable') && !$homePageOBJ) {
$urlSegment = Translatable::get_homepage_urlsegment_by_locale(Translatable::current_locale());
$urlSegment = Translatable::get_homepage_urlsegment_by_locale(Translatable::get_current_locale());
} elseif($homePageOBJ) {
$urlSegment = $homePageOBJ->URLSegment;
}

View File

@ -883,7 +883,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
}
// get the "long" lang name suitable for the HTTP content-language flag (with hyphens instead of underscores)
$currentLang = ($this->hasExtension('Translatable')) ? Translatable::current_locale() : i18n::get_locale();
$currentLang = ($this->hasExtension('Translatable')) ? Translatable::get_current_locale() : i18n::get_locale();
$tags .= "<meta http-equiv=\"Content-Language\" content=\"". i18n::convert_rfc1766($currentLang) ."\"/>\n";
// DEPRECATED 2.3: Use MetaTags

View File

@ -187,7 +187,7 @@ class Translatable extends DataObjectDecorator {
protected $original_values = null;
/**
* @var boolean Temporarily override the "auto-filter" for {@link current_locale()}
* @var boolean Temporarily override the "auto-filter" for {@link get_current_locale()}
* in {@link augmentSQL()}. IMPORTANT: You must set this value back to TRUE
* after the temporary usage.
*/
@ -260,7 +260,7 @@ class Translatable extends DataObjectDecorator {
* Get the current reading language.
* @return string
*/
static function current_locale() {
static function get_current_locale() {
if (!self::$language_decided) self::choose_site_locale();
return self::$reading_locale;
}
@ -288,7 +288,7 @@ class Translatable extends DataObjectDecorator {
* @return DataObject
*/
static function get_one_by_locale($class, $locale, $filter = '', $cache = false, $orderby = "") {
$orig = Translatable::current_locale();
$orig = Translatable::get_current_locale();
Translatable::set_reading_locale($locale);
$do = DataObject::get_one($class, $filter, $cache, $orderby);
Translatable::set_reading_locale($orig);
@ -309,7 +309,7 @@ class Translatable extends DataObjectDecorator {
* @return mixed The objects matching the conditions.
*/
static function get_by_locale($class, $locale, $filter = '', $sort = '', $join = "", $limit = "", $containerClass = "DataObjectSet", $having = "") {
$oldLang = self::current_locale();
$oldLang = self::get_current_locale();
self::set_reading_locale($locale);
$result = DataObject::get($class, $filter, $sort, $join, $limit, $containerClass, $having);
self::set_reading_locale($oldLang);
@ -453,7 +453,7 @@ class Translatable extends DataObjectDecorator {
/**
* Changes any SELECT query thats not filtering on an ID
* to limit by the current language defined in {@link current_locale()}.
* to limit by the current language defined in {@link get_current_locale()}.
* It falls back to "Locale='' OR Lang IS NULL" and assumes that
* this implies querying for the default language.
*
@ -463,7 +463,7 @@ class Translatable extends DataObjectDecorator {
// 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();
$locale = ($this->owner->ID && $this->owner->Locale) ? $this->owner->Locale : Translatable::get_current_locale();
$baseTable = ClassInfo::baseDataClass($this->owner->class);
$where = $query->where;
if(
@ -626,7 +626,7 @@ class Translatable extends DataObjectDecorator {
function contentcontrollerInit($controller) {
Translatable::choose_site_locale();
$controller->Locale = Translatable::current_locale();
$controller->Locale = Translatable::get_current_locale();
}
function modelascontrollerInit($controller) {
@ -654,7 +654,7 @@ class Translatable extends DataObjectDecorator {
// of the content, as a "single language" website might be expanded
// later on.
if(!$this->owner->ID && !$this->owner->Locale) {
$this->owner->Locale = Translatable::current_locale();
$this->owner->Locale = Translatable::get_current_locale();
}
// Specific logic for SiteTree subclasses.
@ -1154,10 +1154,10 @@ class Translatable extends DataObjectDecorator {
}
/**
* @deprecated 2.4 Use custom check: self::$default_locale == self::current_locale()
* @deprecated 2.4 Use custom check: self::$default_locale == self::get_current_locale()
*/
static function is_default_lang() {
return (self::$default_locale == self::current_locale());
return (self::$default_locale == self::get_current_locale());
}
/**
@ -1175,10 +1175,10 @@ class Translatable extends DataObjectDecorator {
}
/**
* @deprecated 2.4 Use current_locale()
* @deprecated 2.4 Use get_current_locale()
*/
static function current_lang() {
return i18n::get_lang_from_locale(self::current_locale());
return i18n::get_lang_from_locale(self::get_current_locale());
}
/**

View File

@ -6,7 +6,7 @@
* If multilingual content is enabled through the {@link Translatable} extension,
* only pages the currently set language on the holder for this searchform are found.
* The language is set through a hidden field in the form, which is prepoluated
* with {@link Translatable::current_locale()} when then form is constructed.
* with {@link Translatable::get_current_locale()} when then form is constructed.
*
* @see Use ModelController and SearchContext for a more generic search implementation based around DataObject
* @package sapphire
@ -55,7 +55,7 @@ class SearchForm extends Form {
}
if(singleton('SiteTree')->hasExtension('Translatable')) {
$fields->push(new HiddenField('locale', 'locale', Translatable::current_locale()));
$fields->push(new HiddenField('locale', 'locale', Translatable::get_current_locale()));
}
if(!$actions) {
@ -105,7 +105,7 @@ class SearchForm extends Form {
// set language (if present)
if(singleton('SiteTree')->hasExtension('Translatable') && isset($data['locale'])) {
$origLocale = Translatable::current_locale();
$origLocale = Translatable::get_current_locale();
Translatable::set_reading_locale($data['locale']);
}

View File

@ -152,7 +152,7 @@ class MigrateTranslatableTask extends BuildTask {
}
// Write the new translation to the database
$sitelang = Translatable::current_locale();
$sitelang = Translatable::get_current_locale();
Translatable::set_reading_locale($newtrans->Locale);
$newtrans->writeToStage($stage);
Translatable::set_reading_locale($sitelang);