summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gallery.common.js15
-rw-r--r--modules/gallery/controllers/admin_languages.php52
-rw-r--r--modules/gallery/views/admin_languages.html.php71
-rw-r--r--modules/notification/helpers/notification.php2
-rw-r--r--themes/admin_default/css/admin_screen.css18
-rw-r--r--themes/default/css/screen.css23
-rw-r--r--themes/default/js/ui.init.js60
7 files changed, 142 insertions, 99 deletions
diff --git a/lib/gallery.common.js b/lib/gallery.common.js
index a959d90d..c6a619c1 100644
--- a/lib/gallery.common.js
+++ b/lib/gallery.common.js
@@ -140,19 +140,18 @@
/* after scaling the width, check that the height fits */
if (imageHeight > height) {
- ratio = height / imageHeight;
- imageWidth *= ratio;
- imageHeight *= ratio;
+ ratio = height / imageHeight;
+ imageWidth *= ratio;
+ imageHeight *= ratio;
}
// handle the case where the calculation is almost zero (2.14e-14)
return {
- top: Number((height - imageHeight) / 2),
- left: Number((width - imageWidth) / 2),
- width: Number(imageWidth),
- height: Number(imageHeight)
+ top: Number((height - imageHeight) / 2),
+ left: Number((width - imageWidth) / 2),
+ width: Number(imageWidth),
+ height: Number(imageHeight)
};
};
})(jQuery);
-
diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php
index ae90ad07..6dc242c6 100644
--- a/modules/gallery/controllers/admin_languages.php
+++ b/modules/gallery/controllers/admin_languages.php
@@ -21,7 +21,10 @@ class Admin_Languages_Controller extends Admin_Controller {
public function index($share_translations_form=null) {
$v = new Admin_View("admin.html");
$v->content = new View("admin_languages.html");
- $v->content->settings_form = $this->_languages_form();
+ $v->content->available_locales = locales::available();
+ $v->content->installed_locales = locales::installed();
+ $v->content->default_locale = module::get_var("gallery", "default_locale");
+
if (empty($share_translations_form)) {
$share_translations_form = $this->_share_translations_form();
}
@@ -32,14 +35,21 @@ class Admin_Languages_Controller extends Admin_Controller {
public function save() {
access::verify_csrf();
-
- $form = $this->_languages_form();
- if ($form->validate()) {
- module::set_var("gallery", "default_locale", $form->choose_language->locale->value);
- locales::update_installed($form->choose_language->installed_locales->value);
- message::success(t("Settings saved"));
- }
- url::redirect("admin/languages");
+
+ locales::update_installed($this->input->post("installed_locales"));
+
+ $installed_locales = array_keys(locales::installed());
+ $new_default_locale = $this->input->post("default_locale");
+ if (!in_array($new_default_locale, $installed_locales)) {
+ if (!empty($installed_locales)) {
+ $new_default_locale = $installed_locales[0];
+ } else {
+ $new_default_locale = "en_US";
+ }
+ }
+ module::set_var("gallery", "default_locale", $new_default_locale);
+
+ print json_encode(array("result" => "success"));
}
public function share() {
@@ -88,30 +98,6 @@ class Admin_Languages_Controller extends Admin_Controller {
}
}
- private function _languages_form() {
- $all_locales = locales::available();
- $installed_locales = locales::installed();
- $form = new Forge("admin/languages/save", "", "post", array("id" => "gLanguageSettingsForm"));
- $group = $form->group("choose_language")
- ->label(t("Language settings"));
- $group->dropdown("locale")
- ->options($installed_locales)
- ->selected(module::get_var("gallery", "default_locale"))
- ->label(t("Default language"))
- ->rules('required');
-
- $installation_options = array();
- foreach ($all_locales as $code => $display_name) {
- $installation_options[$code] = array($display_name, isset($installed_locales->$code));
- }
- $group->checklist("installed_locales")
- ->label(t("Installed Languages"))
- ->options($installation_options)
- ->rules("required");
- $group->submit("save")->value(t("Save settings"));
- return $form;
- }
-
private function _outgoing_translations_count() {
return ORM::factory("outgoing_translation")->count_all();
}
diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php
index f41694b4..fc3a87dc 100644
--- a/modules/gallery/views/admin_languages.html.php
+++ b/modules/gallery/views/admin_languages.html.php
@@ -1,14 +1,69 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="gLanguages">
- <h2> <?= t("Languages") ?> </h2>
+ <h1> <?= t("Languages") ?> </h1>
+ <p>
+ <?= t("Here you can install new languages, update installed ones and set the default language for your Gallery.") ?>
+ </p>
- <?= $settings_form ?>
-
- <h2> <?= t("Download translations") ?> </h2>
- <a href="<?= url::site("admin/maintenance/start/gallery_task::update_l10n?csrf=$csrf") ?>"
- class="gDialogLink">
- <?= t("Get updates") ?>
- </a>
+ <form id="gLanguagesForm" method="post" action="<?= url::site("admin/languages/save") ?>">
+ <?= access::csrf_form_field() ?>
+ <table>
+ <tr>
+ <th> <?= t("Installed") ?> </th>
+ <th> <?= t("Language") ?> </th>
+ <th> <?= t("Default language") ?> </th>
+ </tr>
+ <? $i = 0 ?>
+ <? foreach ($available_locales as $code => $display_name): ?>
+
+ <? if ($i == (count($available_locales)/2)): ?>
+ <table>
+ <tr>
+ <th> <?= t("Installed") ?> </th>
+ <th> <?= t("Language") ?> </th>
+ <th> <?= t("Default language") ?> </th>
+ </tr>
+ <? endif ?>
+
+ <tr class="<?= (isset($installed_locales[$code])) ? "installed" : "" ?><?= ($default_locale == $code) ? " default" : "" ?>">
+ <td> <?= form::checkbox("installed_locales[]", $code, isset($installed_locales[$code])) ?> </td>
+ <td> <?= $display_name ?> </td>
+ <td>
+ <?= form::radio("default_locale", $code, ($default_locale == $code), ((isset($installed_locales[$code]))?'':'disabled="disabled"') ) ?>
+ </td>
+ </tr>
+ <? $i++ ?>
+
+ <? endforeach ?>
+ </table>
+ <input type="submit" value="<?= t("Update languages") ?>" />
+ </form>
+
+ <script type="text/javascript">
+ var old_default_locale = "<?= $default_locale ?>";
+
+ $("input[name='installed_locales[]']").change(function (event) {
+ if (this.checked) {
+ $("input[type='radio'][value='" + this.value + "']").enable();
+ } else {
+ if ($("input[type='radio'][value='" + this.value + "']").selected()) { // if you deselect your default language, switch to some other installed language
+ $("input[type='radio'][value='" + old_default_locale + "']").attr("checked", "checked");
+ }
+ $("input[type='radio'][value='" + this.value + "']").attr("disabled", "disabled");
+ }
+ });
+
+ $("#gLanguagesForm").ajaxForm({
+ dataType: "json",
+ success: function(data) {
+ if (data.result == "success") {
+ el = $('<a href="<?= url::site("admin/maintenance/start/gallery_task::update_l10n?csrf=$csrf") ?>"></a>'); // this is a little hack to trigger the update_l10n task in a dialog
+ el.gallery_dialog();
+ el.trigger('click');
+ }
+ }
+ });
+ </script>
<h2> <?= t("Your Own Translations") ?> </h2>
<?= $share_translations_form ?>
diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php
index 92c40d4f..d95b3060 100644
--- a/modules/notification/helpers/notification.php
+++ b/modules/notification/helpers/notification.php
@@ -153,7 +153,7 @@ class notification {
->where("email", $email)
->find_all();
if ($result->count() == 1) {
- $pending = $result->get();
+ $pending = $result->current();
Sendmail::factory()
->to($email)
->subject($pending->subject)
diff --git a/themes/admin_default/css/admin_screen.css b/themes/admin_default/css/admin_screen.css
index d408acf0..913631dc 100644
--- a/themes/admin_default/css/admin_screen.css
+++ b/themes/admin_default/css/admin_screen.css
@@ -451,8 +451,20 @@ li.gDefaultGroup h4, li.gDefaultGroup .gUser {
cursor: pointer;
}
-#gLanguageSettingsForm .checklist li {
- width: 150px;
- overflow: hidden;
+#gLanguagesForm table {
+ width: 400px;
+ float: left;
+ margin: 0 3em 1em 0;
+}
+#gLanguagesForm .installed {
+ background-color: #EEEEEE;
}
+#gLanguagesForm .default {
+ background-color: #C5DBEC;
+ font-weight: bold;
+}
+#gLanguagesForm input, #gShareTranslationsForm, #gLanguages h2 {
+ clear: both;
+}
+
diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css
index 481581a2..94a67ccf 100644
--- a/themes/default/css/screen.css
+++ b/themes/default/css/screen.css
@@ -406,7 +406,6 @@ form .gError,
}
#gSidebar {
- background-color: #fff;
font-size: .9em;
padding: 0 20px;
width: 220px;
@@ -492,23 +491,13 @@ form .gError,
width: 16px;
}
-#gContent #gAlbumGrid #gHoverItem {
+#gContent #gAlbumGrid .gHoverItem {
background-color: #fff;
border: 1px solid #000;
- display: none;
- height: auto;
- padding: 0;
- position: absolute;
- width: auto;
- z-index: 100;
-}
-
-#gContent #gAlbumGrid #gHoverItem .gItem {
- border: none;
}
-#gContent #gHoverItem .gItem h2,
-#gContent #gHoverItem .gItem .gMetadata {
+#gContent .gHoverItem h2,
+#gContent .gHoverItem .gMetadata {
display: block;
}
@@ -654,15 +643,15 @@ form .gError,
line-height: 1.6em;
}
-#gHoverItem .gContextMenu {
+.gHoverItem .gContextMenu {
display: block;
}
-#gHoverItem .gContextMenu li {
+.gHoverItem .gContextMenu li {
text-align: left;
}
-#gHoverItem .gContextMenu a:hover {
+.gHoverItem .gContextMenu a:hover {
text-decoration: none;
}
diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js
index 67cdb968..949933e9 100644
--- a/themes/default/js/ui.init.js
+++ b/themes/default/js/ui.init.js
@@ -62,39 +62,41 @@ $(document).ready(function() {
// Initialize context menus
$(".gItem").hover(
function(){
+ // Insert invisible placeholder to hold the item's position in the grid
+ var placeHolder = $(this).clone();
+ $(placeHolder).attr("id", "gPlaceHolder");
+ $(placeHolder).css("visibility", "hidden");
+ $(this).after($(placeHolder));
+ // Style and position the item
+ $(this).addClass("gHoverItem");
var position = $(this).position();
- var item_classes = $(this).attr("class");
- var bg_color = $(this).css("background-color");
- var container = $(this).parent();
- $("#gHoverItem").remove();
- container.append("<div id=\"gHoverItem\"><div class=\"" + item_classes + "\">"
- + $(this).html() + "</div></div>");
- $("#gHoverItem").css("top", position.top);
- $("#gHoverItem").css("left", position.left);
- $("#gHoverItem").css("background-color", bg_color);
- $.fn.gallery_hover_init();
- var v_align = $(this).find(".gValign");
+ $(this).css("position", "absolute");
+ $(this).css("top", position.top);
+ $(this).css("left", position.left);
+ $(this).css("z-index", "1000");
+ // Initialize the contextual menu
+ $(this).gallery_context_menu();
+ // Set height based on height of descendents
var title = $(this).find("h2");
var meta = $(this).find(".gMetadata");
- var context = $(this).find(".gContextMenu");
var context_label = $(this).find(".gContextMenu li:first");
- $("#gHoverItem .gItem").height(
- $(v_align).gallery_height()
- + $(title).gallery_height()
- + $(meta).gallery_height()
- + parseInt($(context).css("margin-top").replace("px",""))
- + $(context_label).gallery_height()
- );
-
- $("#gHoverItem").fadeIn("fast");
- $("#gHoverItem").hover(
- function(){
- $(this).gallery_context_menu();
- },
- function() {
- $(this).hide();
- }
- );
+ var item_ht = $(this).height();
+ var title_ht = $(title).gallery_height();
+ var meta_ht = $(meta).gallery_height();
+ var context_label_ht = $(context_label).gallery_height();
+ $(this).height(item_ht + title_ht + meta_ht + context_label_ht);
+ },
+ function() {
+ // Reset item height, position, and z-index
+ var sib_height = $(this).next().height();
+ $(this).css("height", sib_height);
+ $(this).css("position", "relative");
+ $(this).css("top", null);
+ $(this).css("left", null);
+ $(this).css("z-index", null);
+ // Remove the placeholder and hover class from the item
+ $("#gPlaceHolder").remove();
+ $(this).removeClass("gHoverItem");
}
);
}