Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Symphony 4.x #10

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 37 additions & 9 deletions assets/language_switcher.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,41 @@
* @author John J. Camilleri
* @version 0.1
*/
#nav li.backend_language_switcher {
/*padding: 10px 7px;
height: 10px;
background: url("/symphony/assets/images/navigation.png") repeat-x scroll 0 -65px;*/
cursor:pointer;

.backend-language-switcher-ctn {
display: flex;
flex-direction: row;
align-items: baseline;
justify-content: space-between;
padding: 1rem 1.5rem;
cursor: auto;
}

.backend-language-switcher-ctn > span {
padding-right: 1rem;
}

.backend-language-switcher {
display: flex;
flex-direction: row;
align-items: baseline;
margin: 0;
padding: 0;
}

.backend-language-switcher li {
transition: color 0.2s;
color: currentColor;
font-size: 1.0rem;
text-transform: uppercase;
cursor: pointer;
}

.backend-language-switcher li.selected,
.backend-language-switcher li:hover {
color: #2f77eb;
}

.backend-language-switcher li + li {
margin-left: 0.5rem;
}
#nav li.backend_language_switcher.first { margin-left: 30px; }
#nav li.backend_language_switcher.selected { background-position: 0 -30px; }
#nav li.backend_language_switcher:hover { background-position: 0 0; }
#nav li.backend_language_switcher img { }
17 changes: 7 additions & 10 deletions assets/language_switcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
*/
(function($) {
$(function() {
$('#session > ul > li:first-child').after(
$('<li class="backend-language-switcher-ctn"><span>Language</span><ul class="backend-language-switcher" /></li>')
);
for (var i in Symphony.Languages) {
var lang = Symphony.Languages[i];
$('nav#nav ul.structure').append(
$('#session ul.backend-language-switcher').append(
// Nav menu item
$('<li />')
.addClass('backend_language_switcher')
Expand All @@ -21,13 +24,7 @@
'lang':lang
})
// Flag image
.append(
$('<img />')
.attr({
'src':Symphony.Context.get('root')+'/extensions/backend_language_switcher/assets/flags/'+lang+'.png',
'alt':lang.toUpperCase()
})
)
.text(lang)
// Click handler - Construct request to change user language
.click(function(){
var li = $(this);
Expand All @@ -50,6 +47,6 @@
})
);
}

});
})(jQuery);
})(jQuery);
23 changes: 12 additions & 11 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @version 1.2.1
*/
Class extension_backend_language_switcher extends Extension{

public function getSubscribedDelegates(){
return array(
array(
Expand All @@ -16,7 +16,7 @@ public function getSubscribedDelegates(){
),
);
}

private $LOAD_NUMBER = 955935299;

public function initializeAdmin($context) {
Expand All @@ -28,14 +28,15 @@ public function initializeAdmin($context) {
} else {
$author = Administration::instance()->Author;
}

//frontend localization
$codes = Symphony::Configuration()->get('langs', 'frontend_localisation');
//language redirect cases
if ($codes == '' || $codes == null) $codes = Symphony::Configuration()->get('language_codes', 'language_redirect');
if ($codes == '' || $codes == null) $codes = Symphony::Configuration()->get('languages', 'language_redirect');
$languages = array_filter(array_map('trim',explode(',', $codes )));


//Get Available Languages
$codes = Lang::getAvailableLanguages();
$languages = array();

foreach ($codes as $code => $lang) {
$languages[] = $code;
}

// CSS & JS for all admin
$page->addStylesheetToHead($assets_path . '/language_switcher.css', 'all', $LOAD_NUMBER++);
$script = new XMLElement('script');
Expand Down Expand Up @@ -66,7 +67,7 @@ public function initializeAdmin($context) {
$page->addElementToHead($script, $this->LOAD_NUMBER++);
$page->addScriptToHead($assets_path . '/language_switcher.js', $this->LOAD_NUMBER++);
}

public function enable() {
return $this->install();
}
Expand Down
5 changes: 4 additions & 1 deletion extension.meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
</author>
</authors>
<releases>
<release version="2.0.0" date="TBA" min="4.0.0" max="4.x.x" php-min="5.6.x" php-max="7.x.x">
* Update for Symphony 4.x
</release>
<release version="1.2.5" date="2016-03-06" min="2.3.0" max="2.x.x">
* Added Esperanto flag
* Updated compatibility info
Expand All @@ -50,4 +53,4 @@
</release>
<release version="1.1" date="2012-04-03" min="2.2" max="2.2.5" />
</releases>
</extension>
</extension>