1
0

Initial commit of language_flags module.

This commit is contained in:
rWatcher 2010-03-04 22:55:41 -05:00
parent 8d446c45ca
commit 12760d48d2
88 changed files with 183 additions and 0 deletions

View 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;
}
}

View 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;
}

View 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")));
}
}

View 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");
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,3 @@
name = "Language Flags"
description = "Replaces the language selection drop-down box with clickable flags."
version = 1

View File

@ -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>

View 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>