summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/gallery.php2
-rw-r--r--modules/gallery/helpers/gallery_menu.php13
-rw-r--r--modules/gallery/helpers/item.php17
-rw-r--r--modules/gallery/helpers/l10n_client.php76
-rw-r--r--modules/gallery/helpers/p.php2
5 files changed, 103 insertions, 7 deletions
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 34671f1f..1686571c 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -23,7 +23,7 @@ class gallery_Core {
* down for maintenance" page.
*/
static function maintenance_mode() {
- $maintenance_mode = Kohana::config("gallery.maintenance_mode", false, false);
+ $maintenance_mode = Kohana::config("core.maintenance_mode", false, false);
if (Router::$controller != "login" && !empty($maintenance_mode) && !user::active()->admin) {
Router::$controller = "maintenance";
diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php
index 09c2d91a..d28e71c9 100644
--- a/modules/gallery/helpers/gallery_menu.php
+++ b/modules/gallery/helpers/gallery_menu.php
@@ -30,7 +30,14 @@ class gallery_menu_Core {
$can_edit = $item && access::can("edit", $item) || $is_admin;
$can_add = $item && (access::can("add", $item) || $is_admin);
-
+
+ if ($can_add) {
+ $menu->append(Menu::factory("dialog")
+ ->id("add_photos_item")
+ ->label(t("Add photos"))
+ ->url(url::site("simple_uploader/app/$item->id")));
+ }
+
if ($item && $can_edit || $can_add) {
$menu->append($options_menu = Menu::factory("submenu")
->id("options_menu")
@@ -49,10 +56,6 @@ class gallery_menu_Core {
if ($can_add) {
$options_menu
->append(Menu::factory("dialog")
- ->id("add_item")
- ->label(t("Add a photo"))
- ->url(url::site("simple_uploader/app/$item->id")))
- ->append(Menu::factory("dialog")
->id("add_album")
->label(t("Add an album"))
->url(url::site("form/add/albums/$item->id?type=album")));
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 7daaf1e1..09870b45 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -19,6 +19,8 @@
*/
class item_Core {
static function move($source, $target) {
+ access::required("view", $source);
+ access::required("view", $target);
access::required("edit", $source);
access::required("edit", $target);
@@ -47,6 +49,8 @@ class item_Core {
static function make_album_cover($item) {
$parent = $item->parent();
+ access::required("view", $item);
+ access::required("view", $parent);
access::required("edit", $parent);
model_cache::clear("item", $parent->album_cover_item_id);
@@ -61,6 +65,7 @@ class item_Core {
}
static function remove_album_cover($album) {
+ access::required("view", $album);
access::required("edit", $album);
@unlink($album->thumb_path());
@@ -102,4 +107,16 @@ class item_Core {
$input->add_error("conflict", 1);
}
}
+
+ /**
+ * Sanitize a filename into something presentable as an item title
+ * @param string $filename
+ * @return string title
+ */
+ static function convert_filename_to_title($filename) {
+ $title = strtr($filename, "_", " ");
+ $title = preg_replace("/\..*?$/", "", $title);
+ $title = preg_replace("/ +/", " ", $title);
+ return $title;
+ }
} \ No newline at end of file
diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php
index d26739f5..4e905c6c 100644
--- a/modules/gallery/helpers/l10n_client.php
+++ b/modules/gallery/helpers/l10n_client.php
@@ -200,4 +200,80 @@ class l10n_client_Core {
// @todo Move messages out of outgoing into incoming, using new rev?
// @todo show which messages have been rejected / are pending?
}
+
+ /**
+ * Plural forms.
+ */
+ static function plural_forms($locale) {
+ $parts = explode('_', $locale);
+ $language = $parts[0];
+
+ // Data from CLDR 1.6 (http://unicode.org/cldr/data/common/supplemental/plurals.xml).
+ // Docs: http://www.unicode.org/cldr/data/charts/supplemental/language_plural_rules.html
+ switch ($language) {
+ case 'az':
+ case 'fa':
+ case 'hu':
+ case 'ja':
+ case 'ko':
+ case 'my':
+ case 'to':
+ case 'tr':
+ case 'vi':
+ case 'yo':
+ case 'zh':
+ case 'bo':
+ case 'dz':
+ case 'id':
+ case 'jv':
+ case 'ka':
+ case 'km':
+ case 'kn':
+ case 'ms':
+ case 'th':
+ return array('other');
+
+ case 'ar':
+ return array('zero', 'one', 'two', 'few', 'many', 'other');
+
+ case 'lv':
+ return array('zero', 'one', 'other');
+
+ case 'ga':
+ case 'se':
+ case 'sma':
+ case 'smi':
+ case 'smj':
+ case 'smn':
+ case 'sms':
+ return array('one', 'two', 'other');
+
+ case 'ro':
+ case 'mo':
+ case 'lt':
+ case 'cs':
+ case 'sk':
+ case 'pl':
+ return array('one', 'few', 'other');
+
+ case 'hr':
+ case 'ru':
+ case 'sr':
+ case 'uk':
+ case 'be':
+ case 'bs':
+ case 'sh':
+ case 'mt':
+ return array('one', 'few', 'many', 'other');
+
+ case 'sl':
+ return array('one', 'two', 'few', 'other');
+
+ case 'cy':
+ return array('one', 'two', 'many', 'other');
+
+ default: // en, de, etc.
+ return array('one', 'other');
+ }
+ }
} \ No newline at end of file
diff --git a/modules/gallery/helpers/p.php b/modules/gallery/helpers/p.php
index c3074c23..0a6210dc 100644
--- a/modules/gallery/helpers/p.php
+++ b/modules/gallery/helpers/p.php
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class p_Core {
- function clean($dirty_html) {
+ static function clean($dirty_html) {
return html::specialchars($dirty_html);
}
}