Skip to content

Commit

Permalink
Extract template for selector
Browse files Browse the repository at this point in the history
  • Loading branch information
VicDeo committed Jul 3, 2018
1 parent dcd7ffd commit 91c0a21
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
10 changes: 7 additions & 3 deletions settings/Panels/Personal/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ public function getPanel() {
$activeLangCode
);

$selector = new Template('settings', 'language');
$selector->assign('selectId', 'languageinput');
$selector->assign('activelanguage', $userLang);
$selector->assign('commonlanguages', $commonLanguages);
$selector->assign('languages', $languages);

$tmpl = new Template('settings', 'panels/personal/profile');
$tmpl->assign('email', $this->userSession->getUser()->getEMailAddress());
$tmpl->assign('languages', $languages);
$tmpl->assign('commonlanguages', $commonLanguages);
$tmpl->assign('activelanguage', $userLang);
$tmpl->assign('displayName', $this->userSession->getUser()->getDisplayName());
$tmpl->assign('enableAvatars', $this->config->getSystemValue('enable_avatars', true) === true);
$tmpl->assign('avatarChangeSupported', $this->userSession->getUser()->canChangeAvatar());
Expand All @@ -100,6 +103,7 @@ public function getPanel() {
$groups = $this->groupManager->getUserGroupIds($this->userSession->getUser());
\sort($groups);
$tmpl->assign('groups', $groups);
$tmpl->assign('languageSelector', $selector->fetchPage());
return $tmpl;
}

Expand Down
16 changes: 16 additions & 0 deletions settings/templates/language.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<select id="<?php p($_['selectId'])?>" name="lang" data-placeholder="<?php p($l->t('Language'));?>">
<option value="<?php p($_['activelanguage']['code']);?>">
<?php p($_['activelanguage']['name']);?>
</option>
<?php foreach ($_['commonlanguages'] as $language):?>
<option value="<?php p($language['code']);?>">
<?php p($language['name']);?>
</option>
<?php endforeach;?>
<optgroup label="––––––––––"></optgroup>
<?php foreach ($_['languages'] as $language):?>
<option value="<?php p($language['code']);?>">
<?php p($language['name']);?>
</option>
<?php endforeach;?>
</select>
30 changes: 7 additions & 23 deletions settings/templates/panels/personal/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,31 +131,15 @@
<?php
}
?>

<form id="language" class="section">
<form class="section">
<h2>
<label for="languageinput"><?php p($l->t('Language'));?></label>
<label><?php p($l->t('Language'));?></label>
</h2>
<select id="languageinput" name="lang" data-placeholder="<?php p($l->t('Language'));?>">
<option value="<?php p($_['activelanguage']['code']);?>">
<?php p($_['activelanguage']['name']);?>
</option>
<?php foreach ($_['commonlanguages'] as $language):?>
<option value="<?php p($language['code']);?>">
<?php p($language['name']);?>
</option>
<?php endforeach;?>
<optgroup label="––––––––––"></optgroup>
<?php foreach ($_['languages'] as $language):?>
<option value="<?php p($language['code']);?>">
<?php p($language['name']);?>
</option>
<?php endforeach;?>
</select>
<?php print_unescaped($_['languageSelector']); ?>
<?php if (OC_Util::getEditionString() === OC_Util::EDITION_COMMUNITY): ?>
<a href="https://www.transifex.com/projects/p/owncloud/"
target="_blank" rel="noreferrer">
<em><?php p($l->t('Help translate'));?></em>
</a>
<a href="https://www.transifex.com/projects/p/owncloud/"
target="_blank" rel="noreferrer">
<em><?php p($l->t('Help translate'));?></em>
</a>
<?php endif; ?>
</form>

0 comments on commit 91c0a21

Please sign in to comment.