Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of language_flags module.
- Loading branch information
rWatcher
committed
Mar 5, 2010
1 parent
8d446c4
commit 12760d4
Showing
88 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
modules/language_flags/controllers/admin_language_flags.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name = "Language Flags" | ||
description = "Replaces the language selection drop-down box with clickable flags." | ||
version = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
46
modules/language_flags/views/user_languages_block.html.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |