Skip to content

Commit

Permalink
MINOR Merged from trunk
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@76855 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu authored and Sam Minnee committed Feb 2, 2011
1 parent 89e46dc commit 6af50b8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion core/control/ContentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ function PageComments() {
* Returns the xml:lang and lang attributes
*/
function LangAttributes() {
$lang = Translatable::current_locale();
$lang = Translatable::get_current_locale();
return "xml:lang=\"$lang\" lang=\"$lang\"";
}

Expand Down
2 changes: 1 addition & 1 deletion core/control/RootURLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static function get_homepage_urlsegment() {
}

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;
}
Expand Down
2 changes: 1 addition & 1 deletion core/model/SiteTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ public function MetaTags($includeTitle = true) {
}

// 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
Expand Down
24 changes: 12 additions & 12 deletions core/model/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -260,7 +260,7 @@ static function set_default_locale($locale) {
* 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;
}
Expand Down Expand Up @@ -288,7 +288,7 @@ static function set_reading_locale($locale) {
* @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);
Expand All @@ -309,7 +309,7 @@ static function get_one_by_locale($class, $locale, $filter = '', $cache = false,
* @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);
Expand Down Expand Up @@ -453,7 +453,7 @@ function extraStatics() {

/**
* 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.
*
Expand All @@ -463,7 +463,7 @@ function augmentSQL(SQLQuery &$query) {
// 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(
Expand Down Expand Up @@ -626,7 +626,7 @@ function isVersionedTable($table) {

function contentcontrollerInit($controller) {
Translatable::choose_site_locale();
$controller->Locale = Translatable::current_locale();
$controller->Locale = Translatable::get_current_locale();
}

function modelascontrollerInit($controller) {
Expand Down Expand Up @@ -654,7 +654,7 @@ function onBeforeWrite() {
// 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.
Expand Down Expand Up @@ -1153,10 +1153,10 @@ static function get_homepage_urlsegment_by_language($locale) {
}

/**
* @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());
}

/**
Expand All @@ -1174,10 +1174,10 @@ static function get_default_lang() {
}

/**
* @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());
}

/**
Expand Down
6 changes: 3 additions & 3 deletions search/SearchForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,7 +55,7 @@ function __construct($controller, $name, $fields = null, $actions = null, $showI
}

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) {
Expand Down Expand Up @@ -105,7 +105,7 @@ public function getResults($pageLength = null, $data = null){

// 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']);
}

Expand Down
2 changes: 1 addition & 1 deletion tasks/MigrateTranslatableTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function run($request) {
}

// 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);
Expand Down

0 comments on commit 6af50b8

Please sign in to comment.