Initial commit of language_flags module.
63
modules/language_flags/controllers/admin_language_flags.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
class Admin_Language_Flags_Controller extends Admin_Controller {
|
||||
public function index() {
|
||||
// Generate a new admin page.
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_language_flags.html");
|
||||
$view->content->preferences_form = $this->_get_admin_form();
|
||||
print $view;
|
||||
}
|
||||
|
||||
public function saveprefs() {
|
||||
// Prevent Cross Site Request Forgery
|
||||
access::verify_csrf();
|
||||
|
||||
// Save Settings
|
||||
module::set_var("language_flags", "flag_shape", Input::instance()->post("flag_shape"));
|
||||
|
||||
// Load Admin page.
|
||||
message::success(t("Your Selection Has Been Saved."));
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_language_flags.html");
|
||||
$view->content->preferences_form = $this->_get_admin_form();
|
||||
print $view;
|
||||
}
|
||||
|
||||
private function _get_admin_form() {
|
||||
// Make a new Form.
|
||||
$form = new Forge("admin/language_flags/saveprefs", "", "post",
|
||||
array("id" => "g-language-flags-adminForm"));
|
||||
|
||||
// Figure out what type of flags to display.
|
||||
$group_flag_types = $form->group("flag_types");
|
||||
$group_flag_types->dropdown('flag_shape')
|
||||
->label(t("Flag Shape:"))
|
||||
->options(array('rectangular'=>'Rectangular', 'round'=>'Round', 'square'=>'Square', 'custom'=>'Custom'))
|
||||
->selected(module::get_var("language_flags", "flag_shape"));
|
||||
|
||||
// Add a save button to the form.
|
||||
$form->submit("SavePrefs")->value(t("Save"));
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
}
|
||||
}
|
12
modules/language_flags/css/language_flags_sidebar.css
Normal file
@ -0,0 +1,12 @@
|
||||
#g-selected-language-flag, #g-language-flag, #g-default-language-flag {
|
||||
position: relative;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#g-selected-language-flag {
|
||||
border:1px solid #000000;
|
||||
}
|
||||
|
||||
#g-default-language-flag {
|
||||
border:1px solid #000fff;
|
||||
}
|
30
modules/language_flags/helpers/language_flags_event.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
class language_flags_event_Core {
|
||||
static function admin_menu($menu, $theme) {
|
||||
// Add a menu option to the admin screen for configuring the slideshow.
|
||||
$menu->get("settings_menu")
|
||||
->append(Menu::factory("link")
|
||||
->id("language-flags")
|
||||
->label(t("Language flag settings"))
|
||||
->url(url::site("admin/language_flags")));
|
||||
}
|
||||
}
|
24
modules/language_flags/helpers/language_flags_theme.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class language_flags_theme_Core {
|
||||
static function head($theme) {
|
||||
$theme->css("language_flags_sidebar.css");
|
||||
}
|
||||
}
|
BIN
modules/language_flags/images/rectangular/af_ZA.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
modules/language_flags/images/rectangular/da_DK.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
modules/language_flags/images/rectangular/default.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
modules/language_flags/images/rectangular/el_GR.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
modules/language_flags/images/rectangular/en_GB.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
modules/language_flags/images/rectangular/en_US.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
modules/language_flags/images/rectangular/es_AR.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
modules/language_flags/images/rectangular/es_ES.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
modules/language_flags/images/rectangular/es_MX.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
modules/language_flags/images/rectangular/fi_FI.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/language_flags/images/rectangular/fr_FR.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/language_flags/images/rectangular/is_IS.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
modules/language_flags/images/rectangular/it_IT.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
modules/language_flags/images/rectangular/lt_LT.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/language_flags/images/rectangular/lv_LV.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/language_flags/images/rectangular/nl_NL.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
modules/language_flags/images/rectangular/no_NO.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
modules/language_flags/images/rectangular/pl_PL.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/language_flags/images/rectangular/pt_BR.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
modules/language_flags/images/rectangular/pt_PT.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
modules/language_flags/images/rectangular/ro_RO.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
modules/language_flags/images/rectangular/sk_SK.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
modules/language_flags/images/rectangular/sl_SI.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
modules/language_flags/images/rectangular/sr_CS.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
modules/language_flags/images/rectangular/sv_SE.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/language_flags/images/rectangular/tr_TR.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
modules/language_flags/images/round/af_ZA.png
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
modules/language_flags/images/round/da_DK.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
modules/language_flags/images/round/de_DE.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
modules/language_flags/images/round/default.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
modules/language_flags/images/round/el_GR.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
modules/language_flags/images/round/en_GB.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
modules/language_flags/images/round/en_US.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
modules/language_flags/images/round/es_AR.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
modules/language_flags/images/round/es_ES.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
modules/language_flags/images/round/es_MX.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
modules/language_flags/images/round/et_EE.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
modules/language_flags/images/round/faroe.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
modules/language_flags/images/round/fi_FI.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
modules/language_flags/images/round/fr_FR.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
modules/language_flags/images/round/is_IS.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
modules/language_flags/images/round/it_IT.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
modules/language_flags/images/round/lt_LT.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
modules/language_flags/images/round/lv_LV.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
modules/language_flags/images/round/nl_NL.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
modules/language_flags/images/round/no_NO.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
modules/language_flags/images/round/pl_PL.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
modules/language_flags/images/round/pt_BR.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
modules/language_flags/images/round/pt_PT.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
modules/language_flags/images/round/ro_RO.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
modules/language_flags/images/round/sk_SK.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
modules/language_flags/images/round/sl_SI.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
modules/language_flags/images/round/sr_CS.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
modules/language_flags/images/round/sv_SE.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
modules/language_flags/images/round/tr_TR.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
modules/language_flags/images/square/af_ZA.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
modules/language_flags/images/square/da_DK.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
modules/language_flags/images/square/de_DE.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
modules/language_flags/images/square/default.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
modules/language_flags/images/square/el_GR.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
modules/language_flags/images/square/en_GB.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
modules/language_flags/images/square/es_AR.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
modules/language_flags/images/square/es_ES.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
modules/language_flags/images/square/et_EE.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
modules/language_flags/images/square/fi_FI.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
modules/language_flags/images/square/fr_FR.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
modules/language_flags/images/square/is_IS.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
modules/language_flags/images/square/it_IT.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
modules/language_flags/images/square/lt_LT.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
modules/language_flags/images/square/lv_LV.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
modules/language_flags/images/square/nl_NL.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
modules/language_flags/images/square/no_NO.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
modules/language_flags/images/square/pl_PL.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
modules/language_flags/images/square/pt_BR.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
modules/language_flags/images/square/pt_PT.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
modules/language_flags/images/square/ro_RO.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
modules/language_flags/images/square/sk_SK.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
modules/language_flags/images/square/sl_SI.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
modules/language_flags/images/square/sr_CS.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
modules/language_flags/images/square/sv_SE.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
modules/language_flags/images/square/tr_TR.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
3
modules/language_flags/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "Language Flags"
|
||||
description = "Replaces the language selection drop-down box with clickable flags."
|
||||
version = 1
|
@ -0,0 +1,5 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<div id="g-language-flags-admin">
|
||||
<h2> <?= t("Language Flags") ?> </h2>
|
||||
<?= $preferences_form ?>
|
||||
</div>
|
46
modules/language_flags/views/user_languages_block.html.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<?
|
||||
// Base URL for flag pictures.
|
||||
$base_url = url::base(false, "http") . "modules/language_flags/images/" . module::get_var("language_flags", "flag_shape") . "/";
|
||||
|
||||
// Loop through each installed locale and display a flag.
|
||||
while ($one_locale = current($installed_locales)) {
|
||||
// Skip "default" so we don't end up with the same flag twice.
|
||||
if (key($installed_locales) != "") {
|
||||
|
||||
// Use seperate div id's for the current language, the default language, and everything else.
|
||||
$div_id = "g-language_flag";
|
||||
if (key($installed_locales) == $selected) {
|
||||
$div_id = "g-selected-language-flag";
|
||||
} elseif (key($installed_locales) == module::get_var("gallery", "default_locale")) {
|
||||
$div_id = "g-default-language-flag";
|
||||
}
|
||||
|
||||
// Print out the HTML for the flag.
|
||||
print "<div id=\"" . $div_id . "\">" .
|
||||
"<a href=\"javascript:image_click('" .
|
||||
key($installed_locales) . "')\"><img src=\"" .
|
||||
$base_url . key($installed_locales) . ".png" .
|
||||
"\" width=\"50\" title=\"" . $one_locale .
|
||||
"\" alt=\"" . $one_locale . "\" border=\"0\"></a></div>";
|
||||
}
|
||||
next($installed_locales);
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function image_click(flag_code)
|
||||
{
|
||||
var old_locale_preference = "<?= $selected ?>";
|
||||
var locale = flag_code;
|
||||
if (old_locale_preference == locale) {
|
||||
return;
|
||||
}
|
||||
|
||||
var expires = -1;
|
||||
if (locale) {
|
||||
expires = 365;
|
||||
}
|
||||
$.cookie("g_locale", locale, {"expires": expires, "path": "/"});
|
||||
window.location.reload(true);
|
||||
}
|
||||
</script>
|