mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #2820 from creative-commoners/pulls/5/remove-translatable
ENH Remove unused Translatable code
This commit is contained in:
commit
9bb6f700b4
@ -73,7 +73,6 @@ use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\VersionedAdmin\Controllers\CMSPageHistoryViewerController;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\View\Requirements;
|
||||
use Translatable;
|
||||
|
||||
/**
|
||||
* The main "content" area of the CMS.
|
||||
@ -183,11 +182,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
protected function init()
|
||||
{
|
||||
// set reading lang
|
||||
if (SiteTree::has_extension('Translatable') && !$this->getRequest()->isAjax()) {
|
||||
Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages(SiteTree::class) ?? []));
|
||||
}
|
||||
|
||||
parent::init();
|
||||
|
||||
Requirements::javascript('silverstripe/cms: client/dist/js/bundle.js');
|
||||
|
@ -30,7 +30,6 @@ use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\View\Parsers\URLSegmentFilter;
|
||||
use SilverStripe\View\Requirements;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use Translatable;
|
||||
|
||||
/**
|
||||
* The most common kind of controller; effectively a controller linked to a {@link DataObject}.
|
||||
@ -199,11 +198,6 @@ class ContentController extends Controller
|
||||
// control to a child controller. This allows for the creation of chains of controllers which correspond to a
|
||||
// nested URL.
|
||||
if ($action && SiteTree::config()->nested_urls && !$this->hasAction($action)) {
|
||||
// See ModelAdController->getNestedController() for similar logic
|
||||
if (class_exists('Translatable')) {
|
||||
Translatable::disable_locale_filter();
|
||||
}
|
||||
|
||||
$filter = URLSegmentFilter::create();
|
||||
|
||||
// look for a page with this URLSegment
|
||||
@ -212,10 +206,6 @@ class ContentController extends Controller
|
||||
// url encode unless it's multibyte (already pre-encoded in the database)
|
||||
'URLSegment' => $filter->getAllowMultibyte() ? $action : rawurlencode($action),
|
||||
])->first();
|
||||
|
||||
if (class_exists('Translatable')) {
|
||||
Translatable::enable_locale_filter();
|
||||
}
|
||||
}
|
||||
|
||||
// we found a page with this URLSegment.
|
||||
@ -225,25 +215,6 @@ class ContentController extends Controller
|
||||
|
||||
$response = ModelAsController::controller_for($child)->handleRequest($request);
|
||||
} else {
|
||||
// If a specific locale is requested, and it doesn't match the page found by URLSegment,
|
||||
// look for a translation and redirect (see #5001). Only happens on the last child in
|
||||
// a potentially nested URL chain.
|
||||
if (class_exists('Translatable')) {
|
||||
$locale = $request->getVar('locale');
|
||||
if ($locale
|
||||
&& i18n::getData()->validate($locale)
|
||||
&& $this->dataRecord
|
||||
&& $this->dataRecord->Locale != $locale
|
||||
) {
|
||||
$translation = $this->dataRecord->getTranslation($locale);
|
||||
if ($translation) {
|
||||
$response = new HTTPResponse();
|
||||
$response->redirect($translation->Link(), 301);
|
||||
throw new HTTPResponse_Exception($response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Director::set_current_page($this->data());
|
||||
|
||||
try {
|
||||
@ -415,9 +386,6 @@ HTML;
|
||||
|
||||
/**
|
||||
* Returns an RFC1766 compliant locale string, e.g. 'fr-CA'.
|
||||
* Inspects the associated {@link dataRecord} for a {@link SiteTree->Locale} value if present,
|
||||
* and falls back to {@link Translatable::get_current_locale()} or {@link i18n::default_locale()},
|
||||
* depending if Translatable is enabled.
|
||||
*
|
||||
* Suitable for insertion into lang= and xml:lang=
|
||||
* attributes in HTML or XHTML output.
|
||||
@ -426,14 +394,7 @@ HTML;
|
||||
*/
|
||||
public function ContentLocale()
|
||||
{
|
||||
if ($this->dataRecord && $this->dataRecord->hasExtension('Translatable')) {
|
||||
$locale = $this->dataRecord->Locale;
|
||||
} elseif (class_exists('Translatable') && SiteTree::has_extension('Translatable')) {
|
||||
$locale = Translatable::get_current_locale();
|
||||
} else {
|
||||
$locale = i18n::get_locale();
|
||||
}
|
||||
|
||||
$locale = i18n::get_locale();
|
||||
return i18n::convert_rfc1766($locale);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ use SilverStripe\Dev\Debug;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\View\Parsers\URLSegmentFilter;
|
||||
use Translatable;
|
||||
|
||||
/**
|
||||
* ModelAsController deals with mapping the initial request to the first {@link SiteTree}/{@link ContentController}
|
||||
@ -112,11 +111,6 @@ class ModelAsController extends Controller implements NestedController
|
||||
throw new Exception('ModelAsController->getNestedController(): was not passed a URLSegment value.');
|
||||
}
|
||||
|
||||
// Find page by link, regardless of current locale settings
|
||||
if (class_exists('Translatable')) {
|
||||
Translatable::disable_locale_filter();
|
||||
}
|
||||
|
||||
// url encode unless it's multibyte (already pre-encoded in the database)
|
||||
$filter = URLSegmentFilter::create();
|
||||
if (!$filter->getAllowMultibyte()) {
|
||||
@ -132,21 +126,10 @@ class ModelAsController extends Controller implements NestedController
|
||||
/** @var SiteTree $sitetree */
|
||||
$sitetree = DataObject::get_one(SiteTree::class, $conditions);
|
||||
|
||||
// Check translation module
|
||||
// @todo Refactor out module specific code
|
||||
if (class_exists('Translatable')) {
|
||||
Translatable::enable_locale_filter();
|
||||
}
|
||||
|
||||
if (!$sitetree) {
|
||||
$this->httpError(404, 'The requested page could not be found.');
|
||||
}
|
||||
|
||||
// Enforce current locale setting to the loaded SiteTree object
|
||||
if (class_exists('Translatable') && $sitetree->Locale) {
|
||||
Translatable::set_current_locale($sitetree->Locale);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['debug'])) {
|
||||
Debug::message("Using record #$sitetree->ID of type " . get_class($sitetree) . " with link {$sitetree->Link()}");
|
||||
}
|
||||
|
@ -13,17 +13,11 @@ use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use Translatable;
|
||||
|
||||
/**
|
||||
* Standard basic search form which conducts a fulltext search on all {@link SiteTree}
|
||||
* objects.
|
||||
*
|
||||
* 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::get_current_locale()} when then form is constructed.
|
||||
*
|
||||
* @see Use ModelController and SearchContext for a more generic search implementation based around DataObject
|
||||
*/
|
||||
class SearchForm extends Form
|
||||
@ -70,12 +64,6 @@ class SearchForm extends Form
|
||||
);
|
||||
}
|
||||
|
||||
if (class_exists('Translatable')
|
||||
&& SiteTree::singleton()->hasExtension('Translatable')
|
||||
) {
|
||||
$fields->push(new HiddenField('searchlocale', 'searchlocale', Translatable::get_current_locale()));
|
||||
}
|
||||
|
||||
if (!$actions) {
|
||||
$actions = new FieldList(
|
||||
new FormAction("results", _t(__CLASS__.'.GO', 'Go'))
|
||||
@ -130,22 +118,6 @@ class SearchForm extends Form
|
||||
// Get request data from request handler
|
||||
$request = $this->getRequestHandler()->getRequest();
|
||||
|
||||
// set language (if present)
|
||||
$locale = null;
|
||||
$origLocale = null;
|
||||
if (class_exists('Translatable')) {
|
||||
$locale = $request->requestVar('searchlocale');
|
||||
if (SiteTree::singleton()->hasExtension('Translatable') && $locale) {
|
||||
if ($locale === "ALL") {
|
||||
Translatable::disable_locale_filter();
|
||||
} else {
|
||||
$origLocale = Translatable::get_current_locale();
|
||||
|
||||
Translatable::set_current_locale($locale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$keywords = $request->requestVar('Search');
|
||||
|
||||
$andProcessor = function ($matches) {
|
||||
@ -181,17 +153,6 @@ class SearchForm extends Form
|
||||
}
|
||||
}
|
||||
|
||||
// reset locale
|
||||
if (class_exists('Translatable')) {
|
||||
if (SiteTree::singleton()->hasExtension('Translatable') && $locale) {
|
||||
if ($locale == "ALL") {
|
||||
Translatable::enable_locale_filter();
|
||||
} else {
|
||||
Translatable::set_current_locale($origLocale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user