Commit e2a12ace authored by damjan's avatar damjan

[FEATURE] File Edit - Adding reference language selector

For reference languages are chosen only translated languages.
parent f8b38898
......@@ -81,11 +81,13 @@ abstract class AbstractController extends ActionController {
* @param string $constantSelection
* @param string $languageSelection
* @param string $constantTypeSelection
* @param string $bottomReferenceLanguageSelection
* @return void
*/
protected function saveSelectionsInSession(
$extensionSelection = NULL, $languageFileSelection = NULL, $referenceLanguageSelection = NULL,
$constantSelection = NULL, $languageSelection = NULL, $constantTypeSelection = NULL
$constantSelection = NULL, $languageSelection = NULL, $constantTypeSelection = NULL,
$bottomReferenceLanguageSelection = NULL
) {
/* Extension/language file select box can't be unselected.
Only situation when $extensionSelection === NULL is when the form is submitted by
......@@ -108,6 +110,9 @@ abstract class AbstractController extends ActionController {
if ($constantTypeSelection) {
$this->session->setDataByKey('constantTypeSelection', $constantTypeSelection);
}
if ($bottomReferenceLanguageSelection) {
$this->session->setDataByKey('bottomReferenceLanguageSelection', $bottomReferenceLanguageSelection);
}
}
/**
......
......@@ -69,6 +69,11 @@ class EditFileController extends AbstractBackendController {
);
$this->assignViewWidthMenuVariables('referenceLanguage', $referenceLanguageOptions);
$bottomReferenceLanguageOptions = $this->configurationService->menuLangList(
$langData, '', $this->backendUser, TRUE
);
$this->assignViewWidthMenuVariables('bottomReferenceLanguage', $bottomReferenceLanguageOptions);
$constantTypeOptions = $this->getConstantTypeOptions();
$this->assignViewWidthMenuVariables('constantType', $constantTypeOptions);
......@@ -88,16 +93,17 @@ class EditFileController extends AbstractBackendController {
* @param string $languageSelection
* @param string $referenceLanguageSelection
* @param string $constantTypeSelection
* @param string $bottomReferenceLanguageSelection
* @throws UnsupportedRequestTypeException
* @return void
*/
public function changeSelectionAction(
$extensionSelection = NULL, $languageFileSelection = NULL, $languageSelection = NULL,
$referenceLanguageSelection = NULL, $constantTypeSelection = NULL
$referenceLanguageSelection = NULL, $constantTypeSelection = NULL, $bottomReferenceLanguageSelection = NULL
) {
$this->saveSelectionsInSession(
$extensionSelection, $languageFileSelection, $referenceLanguageSelection, NULL, $languageSelection,
$constantTypeSelection
$constantTypeSelection, $bottomReferenceLanguageSelection
);
$this->redirect('editFile', NULL, NULL, array('buttonType' => 0));
}
......@@ -130,8 +136,9 @@ class EditFileController extends AbstractBackendController {
$langEdit = is_array($langData[$langList]) ? $langData[$langList] : array();
$langPattern = is_array($langData[$patternList]) ? $langData[$patternList] : array();
$langDefault = is_array($langData[$extConfig['defaultLanguage']])
? $langData[$extConfig['defaultLanguage']] : array();
$bottomReferenceLanguageSelection = $this->session->getDataByKey('bottomReferenceLanguageSelection');
$langDefault = is_array($langData[$bottomReferenceLanguageSelection])
? $langData[$bottomReferenceLanguageSelection] : array();
if (empty($langDefault)) {
$langDefault = is_array($langData['en']) ? $langData['en'] : array();
}
......
......@@ -276,9 +276,12 @@ class ConfigurationService extends AbstractService {
* @param array $langData language data
* @param string $default optional default value (if you dont want a default let it empty)
* @param BackendUserAuthentication $backendUser
* @param bool $translatedLanguagesOnly looks only for translated languages
* @return array
* @throws LFException
*/
public function menuLangList($langData, $default = '', BackendUserAuthentication $backendUser = NULL) {
public function menuLangList(
$langData, $default = '', BackendUserAuthentication $backendUser = NULL, $translatedLanguagesOnly = FALSE) {
// build languages
$languageArray = $this->getLangArray($backendUser);
$langList = array();
......@@ -287,6 +290,9 @@ class ConfigurationService extends AbstractService {
if (is_array($langData[$lang])) {
$constCount = count($langData[$lang]);
}
if ($translatedLanguagesOnly && $constCount <= 0) {
continue;
}
$langList[$lang] = $lang . ' (' . $constCount . ' ' .
LocalizationUtility::translate('const.consts', 'lfeditor') . ')';
}
......
{namespace lfe=SGalinski\Lfeditor\ViewHelpers}
<lfe:extendedIf condition="{languageFileSelection}" and="{referenceLanguageOptions}">
<lfe:extendedIf condition="{languageFileSelection}" and="{bottomReferenceLanguageOptions}">
<h2 class="uppercase">
<f:translate key="select.referenceLanguage" />
</h2>
<f:form.select name="referenceLanguageSelection"
value="{referenceLanguageSelection}"
options="{referenceLanguageOptions}"
<f:form.select name="bottomReferenceLanguageSelection"
value="{bottomReferenceLanguageSelection}"
options="{bottomReferenceLanguageOptions}"
additionalAttributes="{onchange: 'submitForm(\'mainMenuForm\')'}"
/>
</lfe:extendedIf>
\ No newline at end of file
......@@ -6,6 +6,7 @@
<f:render partial="SelectExtensionAndLanguageFile" arguments="{_all}" />
<f:form id="mainMenuForm" action="changeSelection">
<f:render partial="SelectLanguageAndReference" arguments="{_all}" />
<f:render partial="SelectReferenceLanguage" arguments="{_all}" />
<f:if condition="{constantTypeOptions}">
<h2 class="uppercase">
<f:translate key="select.constantType" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment