summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/album.php3
-rw-r--r--modules/gallery/helpers/gallery.php25
-rw-r--r--modules/gallery/helpers/gallery_installer.php6
-rw-r--r--modules/gallery/helpers/locales.php56
4 files changed, 57 insertions, 33 deletions
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php
index dfb1e66d..9cd746d7 100644
--- a/modules/gallery/helpers/album.php
+++ b/modules/gallery/helpers/album.php
@@ -135,6 +135,9 @@ class album_Core {
->error_messages(
"not_url_safe",
t("The internet address should contain only letters, numbers, hyphens and underscores"));
+ } else {
+ $group->hidden("dirname")->value($parent->name);
+ $group->hidden("slug")->value($parent->slug);
}
$sort_order = $group->group("sort_order", array("id" => "gAlbumSortOrder"))
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 813134eb..80ae65bd 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class gallery_Core {
- const VERSION = "3.0 git (pre-beta3)";
+ const VERSION = "3.0 git (pre-RC1)";
/**
* If Gallery is in maintenance mode, then force all non-admins to get routed to a "This site is
@@ -95,15 +95,22 @@ class gallery_Core {
$menu->append($add_menu = Menu::factory("submenu")
->id("add_menu")
->label(t("Add")));
- $add_menu->append(Menu::factory("dialog")
- ->id("add_photos_item")
- ->label(t("Add photos"))
- ->url(url::site("simple_uploader/app/$item->id")));
- if ($item->is_album()) {
+ $is_album_writable =
+ is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path());
+ if ($is_album_writable) {
$add_menu->append(Menu::factory("dialog")
- ->id("add_album_item")
- ->label(t("Add an album"))
- ->url(url::site("form/add/albums/$item->id?type=album")));
+ ->id("add_photos_item")
+ ->label(t("Add photos"))
+ ->url(url::site("simple_uploader/app/$item->id")));
+ if ($item->is_album()) {
+ $add_menu->append(Menu::factory("dialog")
+ ->id("add_album_item")
+ ->label(t("Add an album"))
+ ->url(url::site("form/add/albums/$item->id?type=album")));
+ }
+ } else {
+ message::warning(t("The album '%album_name' is not writable.",
+ array("album_name" => $item->title)));
}
}
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index a1856424..6500482b 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -203,6 +203,12 @@ class gallery_installer {
access::register_permission("edit", "Edit");
access::register_permission("add", "Add");
+ // Mark for translation (must be the same strings as used above)
+ t("View Full Size");
+ t("View");
+ t("Edit");
+ t("Add");
+
$root = ORM::factory("item");
$root->type = "album";
$root->title = "Gallery";
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index 16dda2d7..ab7f7526 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -165,50 +165,58 @@ class locales_Core {
list ($ignored, $qvalue) = explode("=", $qvalue . "==");
$qvalue = floatval($qvalue);
}
- $locale_preferences[] = array($requested_locale, $qvalue);
+ // Group by language to boost inexact same-language matches
+ list ($language) = explode("_", $requested_locale . "_");
+ if (!isset($locale_preferences[$language])) {
+ $locale_preferences[$language] = array();
+ }
+ $locale_preferences[$language][$requested_locale] = $qvalue;
}
}
// Compare and score requested locales with installed ones
$scored_locales = array();
- foreach ($locale_preferences as $requested_value) {
- $scored_locale_match = self::_locale_match_score($requested_value);
- if ($scored_locale_match) {
- $scored_locales[] = $scored_locale_match;
+ foreach ($locale_preferences as $language => $requested_locales) {
+ // Inexact match adjustment (same language, different region)
+ $fallback_adjustment_factor = 0.95;
+ if (count($requested_locales) > 1) {
+ // Sort by qvalue, descending
+ $qvalues = array_values($requested_locales);
+ rsort($qvalues);
+ // Ensure inexact match scores worse than 2nd preference in same language.
+ $fallback_adjustment_factor *= $qvalues[1];
+ }
+ foreach ($requested_locales as $requested_locale => $qvalue) {
+ list ($matched_locale, $match_score) =
+ self::_locale_match_score($requested_locale, $qvalue, $fallback_adjustment_factor);
+ if ($matched_locale &&
+ (!isset($scored_locales[$matched_locale]) ||
+ $match_score > $scored_locales[$matched_locale])) {
+ $scored_locales[$matched_locale] = $match_score;
+ }
}
}
- usort($scored_locales, array("locales", "_compare_locale_by_qvalue"));
+ arsort($scored_locales);
- $best_match = array_shift($scored_locales);
- if ($best_match) {
- return $best_match[0];
- }
+ list ($locale) = each($scored_locales);
+ return $locale;
}
return null;
}
- static function _compare_locale_by_qvalue($a, $b) {
- $a = $a[1];
- $b = $b[1];
- if ($a == $b) {
- return 0;
- }
- return $a < $b ? 1 : -1;
- }
-
- private static function _locale_match_score($requested_locale_and_qvalue) {
- list ($requested_locale, $qvalue) = $requested_locale_and_qvalue;
+ private static function _locale_match_score($requested_locale, $qvalue, $adjustment_factor) {
$installed = self::installed();
if (isset($installed[$requested_locale])) {
- return $requested_locale_and_qvalue;
+ return array($requested_locale, $qvalue);
}
list ($language) = explode("_", $requested_locale . "_");
if (isset(self::$language_subtag_to_locale[$language]) &&
isset($installed[self::$language_subtag_to_locale[$language]])) {
- return array(self::$language_subtag_to_locale[$language], $qvalue * 0.66);
+ $score = $adjustment_factor * $qvalue;
+ return array(self::$language_subtag_to_locale[$language], $score);
}
- return null;
+ return array(null, 0);
}
} \ No newline at end of file