Skip to content

Commit

Permalink
Initial commit of language_flags module.
Browse files Browse the repository at this point in the history
  • Loading branch information
rWatcher committed Mar 5, 2010
1 parent 8d446c4 commit 12760d4
Show file tree
Hide file tree
Showing 88 changed files with 183 additions and 0 deletions.
63 changes: 63 additions & 0 deletions modules/language_flags/controllers/admin_language_flags.php
@@ -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 changes: 12 additions & 0 deletions modules/language_flags/css/language_flags_sidebar.css
@@ -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 changes: 30 additions & 0 deletions modules/language_flags/helpers/language_flags_event.php
@@ -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 changes: 24 additions & 0 deletions modules/language_flags/helpers/language_flags_theme.php
@@ -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");
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/language_flags/images/round/af_ZA.png
Binary file added modules/language_flags/images/round/da_DK.png
Binary file added modules/language_flags/images/round/de_DE.png
Binary file added modules/language_flags/images/round/default.png
Binary file added modules/language_flags/images/round/el_GR.png
Binary file added modules/language_flags/images/round/en_GB.png
Binary file added modules/language_flags/images/round/en_US.png
Binary file added modules/language_flags/images/round/es_AR.png
Binary file added modules/language_flags/images/round/es_ES.png
Binary file added modules/language_flags/images/round/es_MX.png
Binary file added modules/language_flags/images/round/et_EE.png
Binary file added modules/language_flags/images/round/faroe.png
Binary file added modules/language_flags/images/round/fi_FI.png
Binary file added modules/language_flags/images/round/fr_FR.png
Binary file added modules/language_flags/images/round/is_IS.png
Binary file added modules/language_flags/images/round/it_IT.png
Binary file added modules/language_flags/images/round/lt_LT.png
Binary file added modules/language_flags/images/round/lv_LV.png
Binary file added modules/language_flags/images/round/nl_NL.png
Binary file added modules/language_flags/images/round/no_NO.png
Binary file added modules/language_flags/images/round/pl_PL.png
Binary file added modules/language_flags/images/round/pt_BR.png
Binary file added modules/language_flags/images/round/pt_PT.png
Binary file added modules/language_flags/images/round/ro_RO.png
Binary file added modules/language_flags/images/round/sk_SK.png
Binary file added modules/language_flags/images/round/sl_SI.png
Binary file added modules/language_flags/images/round/sr_CS.png
Binary file added modules/language_flags/images/round/sv_SE.png
Binary file added modules/language_flags/images/round/tr_TR.png
Binary file added modules/language_flags/images/square/af_ZA.png
Binary file added modules/language_flags/images/square/da_DK.png
Binary file added modules/language_flags/images/square/de_DE.png
Binary file added modules/language_flags/images/square/default.png
Binary file added modules/language_flags/images/square/el_GR.png
Binary file added modules/language_flags/images/square/en_GB.png
Binary file added modules/language_flags/images/square/es_AR.png
Binary file added modules/language_flags/images/square/es_ES.png
Binary file added modules/language_flags/images/square/et_EE.png
Binary file added modules/language_flags/images/square/fi_FI.png
Binary file added modules/language_flags/images/square/fr_FR.png
Binary file added modules/language_flags/images/square/is_IS.png
Binary file added modules/language_flags/images/square/it_IT.png
Binary file added modules/language_flags/images/square/lt_LT.png
Binary file added modules/language_flags/images/square/lv_LV.png
Binary file added modules/language_flags/images/square/nl_NL.png
Binary file added modules/language_flags/images/square/no_NO.png
Binary file added modules/language_flags/images/square/pl_PL.png
Binary file added modules/language_flags/images/square/pt_BR.png
Binary file added modules/language_flags/images/square/pt_PT.png
Binary file added modules/language_flags/images/square/ro_RO.png
Binary file added modules/language_flags/images/square/sk_SK.png
Binary file added modules/language_flags/images/square/sl_SI.png
Binary file added modules/language_flags/images/square/sr_CS.png
Binary file added modules/language_flags/images/square/sv_SE.png
Binary file added modules/language_flags/images/square/tr_TR.png
3 changes: 3 additions & 0 deletions modules/language_flags/module.info
@@ -0,0 +1,3 @@
name = "Language Flags"
description = "Replaces the language selection drop-down box with clickable flags."
version = 1
5 changes: 5 additions & 0 deletions modules/language_flags/views/admin_language_flags.html.php
@@ -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 changes: 46 additions & 0 deletions modules/language_flags/views/user_languages_block.html.php
@@ -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>

0 comments on commit 12760d4

Please sign in to comment.