summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/controllers/admin_graphics.php39
-rw-r--r--modules/gallery/controllers/admin_languages.php52
-rw-r--r--modules/gallery/controllers/combined.php9
-rw-r--r--modules/gallery/controllers/file_proxy.php2
-rw-r--r--modules/gallery/controllers/l10n_client.php13
-rw-r--r--modules/gallery/controllers/packager.php4
-rw-r--r--modules/gallery/controllers/quick.php14
-rw-r--r--modules/gallery/controllers/simple_uploader.php2
-rw-r--r--modules/gallery/css/l10n_client.css12
-rw-r--r--modules/gallery/css/quick.css52
-rw-r--r--modules/gallery/helpers/album.php23
-rw-r--r--modules/gallery/helpers/gallery.php179
-rw-r--r--modules/gallery/helpers/gallery_installer.php32
-rw-r--r--modules/gallery/helpers/gallery_quick.php152
-rw-r--r--modules/gallery/helpers/gallery_rss.php5
-rw-r--r--modules/gallery/helpers/gallery_theme.php32
-rw-r--r--modules/gallery/helpers/graphics.php92
-rw-r--r--modules/gallery/helpers/item.php53
-rw-r--r--modules/gallery/helpers/module.php8
-rw-r--r--modules/gallery/helpers/photo.php8
-rw-r--r--modules/gallery/helpers/task.php1
-rw-r--r--modules/gallery/js/l10n_client.js7
-rw-r--r--modules/gallery/js/quick.js78
-rw-r--r--modules/gallery/libraries/I18n.php9
-rw-r--r--modules/gallery/libraries/Menu.php38
-rw-r--r--modules/gallery/libraries/ORM_MPTT.php65
-rw-r--r--modules/gallery/libraries/Sendmail.php4
-rw-r--r--modules/gallery/libraries/Theme_View.php9
-rw-r--r--modules/gallery/models/item.php71
-rw-r--r--modules/gallery/tests/Item_Helper_Test.php49
-rw-r--r--modules/gallery/tests/Item_Model_Test.php14
-rw-r--r--modules/gallery/tests/ORM_MPTT_Test.php8
-rw-r--r--modules/gallery/views/admin_graphics.html.php14
-rw-r--r--modules/gallery/views/admin_graphics_gd.html.php23
-rw-r--r--modules/gallery/views/admin_graphics_graphicsmagick.html.php18
-rw-r--r--modules/gallery/views/admin_graphics_imagemagick.html.php20
-rw-r--r--modules/gallery/views/admin_graphics_none.html.php7
-rw-r--r--modules/gallery/views/admin_languages.html.php103
-rw-r--r--modules/gallery/views/admin_maintenance.html.php16
-rw-r--r--modules/gallery/views/admin_modules.html.php2
-rw-r--r--modules/gallery/views/after_install.html.php2
-rw-r--r--modules/gallery/views/after_install_loader.html.php2
-rw-r--r--modules/gallery/views/l10n_client.html.php5
-rw-r--r--modules/gallery/views/permissions_browse.html.php42
-rw-r--r--modules/gallery/views/quick_pane.html.php26
-rw-r--r--modules/gallery/views/simple_uploader.html.php2
46 files changed, 729 insertions, 689 deletions
diff --git a/modules/gallery/controllers/admin_graphics.php b/modules/gallery/controllers/admin_graphics.php
index 72f8d8e1..c59dd38e 100644
--- a/modules/gallery/controllers/admin_graphics.php
+++ b/modules/gallery/controllers/admin_graphics.php
@@ -21,41 +21,24 @@ class Admin_Graphics_Controller extends Admin_Controller {
public function index() {
$view = new Admin_View("admin.html");
$view->content = new View("admin_graphics.html");
- $view->content->available = "";
-
- $tk = new ArrayObject(graphics::detect_toolkits(), ArrayObject::ARRAY_AS_PROPS);
- $active = module::get_var("gallery", "graphics_toolkit", "none");
- foreach (array("gd", "imagemagick", "graphicsmagick", "none") as $id) {
- if ($id == $active) {
- $view->content->active = new View("admin_graphics_$id.html");
- $view->content->active->tk = $tk;
- $view->content->active->is_active = true;
- } else if ($id != "none") {
- $v = new View("admin_graphics_$id.html");
- $v->tk = $tk;
- $v->is_active = false;
- $view->content->available .= $v;
- }
- }
-
+ $view->content->tk = graphics::detect_toolkits();
+ $view->content->active = module::get_var("gallery", "graphics_toolkit", "none");
print $view;
}
- public function choose($toolkit) {
+ public function choose($toolkit_id) {
access::verify_csrf();
- if ($toolkit != module::get_var("gallery", "graphics_toolkit")) {
- module::set_var("gallery", "graphics_toolkit", $toolkit);
-
- $toolkit_info = graphics::detect_toolkits();
- if ($toolkit == "graphicsmagick" || $toolkit == "imagemagick") {
- module::set_var("gallery", "graphics_toolkit_path", $toolkit_info[$toolkit]);
- }
+ if ($toolkit_id != module::get_var("gallery", "graphics_toolkit")) {
+ $tk = graphics::detect_toolkits();
+ module::set_var("gallery", "graphics_toolkit", $toolkit_id);
+ module::set_var("gallery", "graphics_toolkit_path", $tk->$toolkit_id->dir);
site_status::clear("missing_graphics_toolkit");
- message::success(t("Updated Graphics Toolkit"));
- log::success("graphics", t("Changed graphics toolkit to: %toolkit",
- array("toolkit" => $toolkit)));
+
+ $msg = t("Changed graphics toolkit to: %toolkit", array("toolkit" => $tk->$toolkit_id->name));
+ message::success($msg);
+ log::success("graphics", $msg);
}
url::redirect("admin/graphics");
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/controllers/combined.php b/modules/gallery/controllers/combined.php
index 9a790fdf..c1f42bfe 100644
--- a/modules/gallery/controllers/combined.php
+++ b/modules/gallery/controllers/combined.php
@@ -42,22 +42,23 @@ class Combined_Controller extends Controller {
private function _emit($type, $key) {
$input = Input::instance();
+ // We don't need to save the session for this request
+ Session::abort_save();
+
// Our data is immutable, so if they already have a copy then it needs no updating.
if ($input->server("HTTP_IF_MODIFIED_SINCE")) {
header('HTTP/1.0 304 Not Modified');
header("Expires: Tue, 19 Jan 2038 00:00:00 GMT");
header("Cache-Control: max-age=2678400");
header('Pragma: public');
- return;
+ Kohana::close_buffers(false);
+ return "";
}
if (empty($key)) {
Kohana::show_404();
}
- // We don't need to save the session for this request
- Session::abort_save();
-
$cache = Cache::instance();
$use_gzip = function_exists("gzencode") &&
stripos($input->server("HTTP_ACCEPT_ENCODING"), "gzip") !== false &&
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index a85f0a85..8cb90c50 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -119,7 +119,7 @@ class File_Proxy_Controller extends Controller {
if (in_array($item->mime_type, array("video/x-flv", "video/mp4"))) {
header("Content-type: image/jpeg");
} else {
- print("Content-Type: $item->mime_type");
+ header("Content-Type: $item->mime_type");
}
Kohana::close_buffers(false);
diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php
index 831c79c1..0775791e 100644
--- a/modules/gallery/controllers/l10n_client.php
+++ b/modules/gallery/controllers/l10n_client.php
@@ -90,10 +90,15 @@ class L10n_Client_Controller extends Controller {
}
$session = Session::instance();
- $session->set("l10n_mode",
- !$session->get("l10n_mode", false));
-
- url::redirect("albums/1");
+ $l10n_mode = $session->get("l10n_mode", false);
+ $session->set("l10n_mode", !$l10n_mode);
+
+ $redirect_url = "admin/languages";
+ if (!$l10n_mode) {
+ $redirect_url .= "#l10n-client";
+ }
+
+ url::redirect($redirect_url);
}
private static function _l10n_client_search_form() {
diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php
index 7b4d68f6..fbb1d07d 100644
--- a/modules/gallery/controllers/packager.php
+++ b/modules/gallery/controllers/packager.php
@@ -123,6 +123,10 @@ class Packager_Controller extends Controller {
// Normalize dates
$line = preg_replace("/,$root_created_timestamp,/", ",UNIX_TIMESTAMP(),", $line);
$line = preg_replace("/,$root_updated_timestamp,/", ",UNIX_TIMESTAMP(),", $line);
+
+ // Remove ENGINE= specifications
+ $line = preg_replace("/ENGINE=\S+ /", "", $line);
+
$buf .= $line;
}
$fd = fopen($sql_file, "wb");
diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php
index 98a5bf9f..8fddb563 100644
--- a/modules/gallery/controllers/quick.php
+++ b/modules/gallery/controllers/quick.php
@@ -18,20 +18,6 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Quick_Controller extends Controller {
- public function pane($id) {
- $item = model_cache::get("item", $id);
- if (!access::can("view", $item) || !access::can("edit", $item)) {
- return "";
- }
-
- $view = new View("quick_pane.html");
- $page_type = Input::instance()->get("page_type");
- $view->button_list = gallery_quick::get_quick_buttons($item, $page_type);
- $view->item = $item;
- $view->page_type = $page_type;
- print $view;
- }
-
public function rotate($id, $dir) {
access::verify_csrf();
$item = model_cache::get("item", $id);
diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php
index e7c0bd6f..156d18ac 100644
--- a/modules/gallery/controllers/simple_uploader.php
+++ b/modules/gallery/controllers/simple_uploader.php
@@ -71,7 +71,7 @@ class Simple_Uploader_Controller extends Controller {
unlink($temp_filename);
}
header("HTTP/1.1 500 Internal Server Error");
- print "ERROR:" . $e->getMessage();
+ print "ERROR: " . $e->getMessage();
return;
}
unlink($temp_filename);
diff --git a/modules/gallery/css/l10n_client.css b/modules/gallery/css/l10n_client.css
index 51cbc753..9c1b12d0 100644
--- a/modules/gallery/css/l10n_client.css
+++ b/modules/gallery/css/l10n_client.css
@@ -42,9 +42,17 @@
cursor:pointer;
display:block;
position:absolute; right:0em;
- padding: 0em .75em; height:2em; line-height:2em;
+ height:2em; line-height:2em;
text-transform:uppercase;
- text-align:center; background:#000;}
+ text-align:center; background:#000;
+}
+#l10n-client-toggler a {
+ font-size: 1em;
+ padding: .5em;
+}
+#l10n-client-toggler #gMinimizeL10n {
+ border-right: 1px solid #ffffff;
+}
/* Panel labels */
#l10n-client h2 {
diff --git a/modules/gallery/css/quick.css b/modules/gallery/css/quick.css
deleted file mode 100644
index f153d475..00000000
--- a/modules/gallery/css/quick.css
+++ /dev/null
@@ -1,52 +0,0 @@
-.gQuickPane {
- position: absolute;
- top: 0;
- left: 0;
- text-align: center;
- width: 100%;
- height: auto;
-}
-
-.gItem:hover {
- background-color: #cfdeff;
-}
-
-.gQuick {
- border: none !important;
- margin: 0 !important;
- padding: 0 !important;
-}
-
-.gQuickPane {
- background: #000;
- border-bottom: 1px solid #ccc;
- opacity: 0.9;
- position: absolute;
- top: 0;
- left: 0;
-}
-
-.gQuickPane a {
- cursor: pointer;
- float: left;
- margin: 4px;
-}
-
-.gQuickPaneOptions {
- background: #000;
- float: left;
- width: 100%;
-}
-
-.gQuickPaneOptions li a {
- display: block;
- float: none;
- width: auto;
- margin: 0;
- padding: .5em .5em .5em .8em;
- text-align: left;
-}
-
-.gQuickPaneOptions li a:hover {
- background-color: #4d4d4d;
-}
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php
index 8a7c9951..d46f21ac 100644
--- a/modules/gallery/helpers/album.php
+++ b/modules/gallery/helpers/album.php
@@ -56,7 +56,7 @@ class album_Core {
$album->thumb_dirty = 1;
$album->resize_dirty = 1;
$album->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
- $album->sort_column = "weight";
+ $album->sort_column = "created";
$album->sort_order = "ASC";
while (ORM::factory("item")
@@ -116,13 +116,7 @@ class album_Core {
$sort_order->dropdown("column", array("id" => "gAlbumSortColumn"))
->label(t("Sort by"))
- ->options(array("weight" => t("Order Added"),
- "captured" => t("Capture Date"),
- "created" => t("Creation Date"),
- "title" => t("Title"),
- "updated" => t("Updated Date"),
- "view_count" => t("Number of views"),
- "rand_key" => t("Random")))
+ ->options(album::get_sort_order_options())
->selected($parent->sort_column);
$sort_order->dropdown("direction", array("id" => "gAlbumSortDirection"))
->label(t("Order"))
@@ -137,4 +131,17 @@ class album_Core {
$form->add_rules_from(ORM::factory("item"));
return $form;
}
+
+ /**
+ * Return a structured set of all the possible sort orders.
+ */
+ static function get_sort_order_options() {
+ return array("weight" => t("Manual"),
+ "captured" => t("Date captured"),
+ "created" => t("Date uploaded"),
+ "title" => t("Title"),
+ "updated" => t("Date modified"),
+ "view_count" => t("Number of views"),
+ "rand_key" => t("Random"));
+ }
}
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 476e9cbe..122227fc 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -82,9 +82,9 @@ class gallery_Core {
static function site_menu($menu, $theme) {
if ($theme->page_type != "login") {
$menu->append(Menu::factory("link")
- ->id("home")
- ->label(t("Home"))
- ->url(url::site("albums/1")));
+ ->id("home")
+ ->label(t("Home"))
+ ->url(url::site("albums/1")));
$item = $theme->item();
@@ -92,48 +92,47 @@ class gallery_Core {
$can_add = $item && access::can("add", $item);
if ($can_add) {
- $menu->append(Menu::factory("dialog")
- ->id("add_photos_item")
- ->label(t("Add photos"))
- ->url(url::site("simple_uploader/app/$item->id")));
+ $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()) {
+ $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")));
+ }
}
$menu->append($options_menu = Menu::factory("submenu")
- ->id("options_menu")
- ->label(t("Options")));
+ ->id("options_menu")
+ ->label(t("Photo options")));
if ($item && ($can_edit || $can_add)) {
if ($can_edit) {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("edit_item")
- ->label($item->is_album() ? t("Edit album") : t("Edit photo"))
- ->url(url::site("form/edit/{$item->type}s/$item->id")));
+ $options_menu->append(Menu::factory("dialog")
+ ->id("edit_item")
+ ->label($item->is_album() ? t("Edit album") : t("Edit photo"))
+ ->url(url::site("form/edit/{$item->type}s/$item->id")));
}
- // @todo Move album options menu to the album quick edit pane
if ($item->is_album()) {
- if ($can_add) {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("add_album")
- ->label(t("Add an album"))
- ->url(url::site("form/add/albums/$item->id?type=album")));
- }
-
+ $options_menu->label(t("Album options"));
if ($can_edit) {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("edit_permissions")
- ->label(t("Edit permissions"))
- ->url(url::site("permissions/browse/$item->id")));
+ $options_menu->append(Menu::factory("dialog")
+ ->id("edit_permissions")
+ ->label(t("Edit permissions"))
+ ->url(url::site("permissions/browse/$item->id")));
}
}
}
if (user::active()->admin) {
$menu->append($admin_menu = Menu::factory("submenu")
- ->id("admin_menu")
- ->label(t("Admin")));
+ ->id("admin_menu")
+ ->label(t("Admin")));
gallery::admin_menu($admin_menu, $theme);
module::event("admin_menu", $admin_menu, $theme);
}
@@ -160,12 +159,6 @@ class gallery_Core {
->label(t("Languages"))
->url(url::site("admin/languages")))
->append(Menu::factory("link")
- ->id("l10n_mode")
- ->label(Session::instance()->get("l10n_mode", false)
- ? t("Stop translating") : t("Start translating"))
- ->url(url::site("l10n_client/toggle_l10n_mode?csrf=" .
- access::csrf_token())))
- ->append(Menu::factory("link")
->id("advanced")
->label(t("Advanced"))
->url(url::site("admin/advanced_settings"))))
@@ -196,4 +189,118 @@ class gallery_Core {
->url(url::site("admin/maintenance")));
return $menu;
}
+
+ static function context_menu($menu, $theme, $item, $thumb_css_selector) {
+ $menu->append($options_menu = Menu::factory("submenu")
+ ->id("options_menu")
+ ->label(t("Options"))
+ ->css_class("ui-icon-carat-1-n"));
+
+ if (access::can("edit", $item)) {
+ $page_type = $theme->page_type();
+ switch ($item->type) {
+ case "movie":
+ $edit_title = t("Edit this movie");
+ $delete_title = t("Delete this movie");
+ break;
+
+ case "album":
+ $edit_title = t("Edit this album");
+ $delete_title = t("Delete this album");
+ break;
+
+ default:
+ $edit_title = t("Edit this photo");
+ $delete_title = t("Delete this photo");
+ break;
+ }
+ $cover_title = t("Choose as the album cover");
+ $move_title = t("Move to another album");
+
+ $csrf = access::csrf_token();
+
+ $options_menu->append(Menu::factory("dialog")
+ ->id("edit")
+ ->label($edit_title)
+ ->css_class("ui-icon-pencil")
+ ->url(url::site("quick/form_edit/$item->id?page_type=$page_type")));
+
+
+ if ($item->is_photo() && graphics::can("rotate")) {
+ $options_menu
+ ->append(
+ Menu::factory("ajax_link")
+ ->id("rotate_ccw")
+ ->label(t("Rotate 90° counter clockwise"))
+ ->css_class("ui-icon-rotate-ccw")
+ ->ajax_handler("function(data) { " .
+ "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }")
+ ->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type")))
+ ->append(
+ Menu::factory("ajax_link")
+ ->id("rotate_cw")
+ ->label(t("Rotate 90° clockwise"))
+ ->css_class("ui-icon-rotate-cw")
+ ->ajax_handler("function(data) { " .
+ "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }")
+ ->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type")));
+ }
+
+ // Don't move photos from the photo page; we don't yet have a good way of redirecting after
+ // move
+ if ($page_type == "album") {
+ $options_menu
+ ->append(Menu::factory("dialog")
+ ->id("move")
+ ->label($move_title)
+ ->css_class("ui-icon-folder-open")
+ ->url(url::site("move/browse/$item->id")));
+ }
+
+ $parent = $item->parent();
+ if (access::can("edit", $parent)) {
+ // We can't make this item the highlight if it's an album with no album cover, or if it's
+ // already the album cover.
+ if (($item->type == "album" && empty($item->album_cover_item_id)) ||
+ ($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) ||
+ $parent->album_cover_item_id == $item->id) {
+ $disabledState = " ui-state-disabled";
+ } else {
+ $disabledState = " ";
+ }
+ $options_menu
+ ->append(Menu::factory("ajax_link")
+ ->id("make_album_cover")
+ ->label($cover_title)
+ ->css_class("ui-icon-star")
+ ->ajax_handler("function(data) { window.location.reload() }")
+ ->url(url::site("quick/make_album_cover/$item->id?csrf=$csrf")))
+ ->append(Menu::factory("dialog")
+ ->id("delete")
+ ->label($delete_title)
+ ->css_class("ui-icon-trash")
+ ->css_id("gQuickDelete")
+ ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type")));
+ }
+
+ if ($item->is_album()) {
+ $options_menu
+ ->append(Menu::factory("dialog")
+ ->id("add_item")
+ ->label(t("Add a photo"))
+ ->css_class("add_item")
+ ->url(url::site("simple_uploader/app/$item->id")))
+ ->append(Menu::factory("dialog")
+ ->id("add_album")
+ ->label(t("Add an album"))
+ ->css_class("add_album")
+ ->url(url::site("form/add/albums/$item->id?type=album")))
+ ->append(Menu::factory("dialog")
+ ->id("edit_permissions")
+ ->label(t("Edit permissions"))
+ ->css_class("permissions")
+ ->url(url::site("permissions/browse/$item->id")));
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index d12dad70..a212ef85 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -24,13 +24,13 @@ class gallery_installer {
`id` int(9) NOT NULL auto_increment,
`item_id` int(9),
PRIMARY KEY (`id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {access_intents} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9),
PRIMARY KEY (`id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {caches} (
`id` int(9) NOT NULL auto_increment,
@@ -40,7 +40,7 @@ class gallery_installer {
`cache` longblob,
PRIMARY KEY (`id`),
KEY (`tags`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {graphics_rules} (
`id` int(9) NOT NULL auto_increment,
@@ -51,7 +51,7 @@ class gallery_installer {
`priority` int(9) NOT NULL,
`target` varchar(32) NOT NULL,
PRIMARY KEY (`id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {incoming_translations} (
`id` int(9) NOT NULL auto_increment,
@@ -63,7 +63,7 @@ class gallery_installer {
PRIMARY KEY (`id`),
UNIQUE KEY(`key`, `locale`),
KEY `locale_key` (`locale`, `key`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {items} (
`id` int(9) NOT NULL auto_increment,
@@ -100,7 +100,7 @@ class gallery_installer {
KEY `type` (`type`),
KEY `random` (`rand_key`),
KEY `weight` (`weight` DESC))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {logs} (
`id` int(9) NOT NULL auto_increment,
@@ -113,7 +113,7 @@ class gallery_installer {
`url` varchar(255) default NULL,
`user_id` int(9) default 0,
PRIMARY KEY (`id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {messages} (
`id` int(9) NOT NULL auto_increment,
@@ -122,7 +122,7 @@ class gallery_installer {
`value` varchar(255) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY(`key`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {modules} (
`id` int(9) NOT NULL auto_increment,
@@ -131,7 +131,7 @@ class gallery_installer {
`version` int(9) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {outgoing_translations} (
`id` int(9) NOT NULL auto_increment,
@@ -143,7 +143,7 @@ class gallery_installer {
PRIMARY KEY (`id`),
UNIQUE KEY(`key`, `locale`),
KEY `locale_key` (`locale`, `key`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {permissions} (
`id` int(9) NOT NULL auto_increment,
@@ -151,14 +151,14 @@ class gallery_installer {
`name` varchar(64) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {sessions} (
`session_id` varchar(127) NOT NULL,
`data` text NOT NULL,
`last_activity` int(10) UNSIGNED NOT NULL,
PRIMARY KEY (`session_id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {tasks} (
`id` int(9) NOT NULL auto_increment,
@@ -173,7 +173,7 @@ class gallery_installer {
`updated` int(9) default NULL,
PRIMARY KEY (`id`),
KEY (`owner_id`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {themes} (
`id` int(9) NOT NULL auto_increment,
@@ -181,7 +181,7 @@ class gallery_installer {
`version` int(9) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {vars} (
`id` int(9) NOT NULL auto_increment,
@@ -190,7 +190,7 @@ class gallery_installer {
`value` text,
PRIMARY KEY (`id`),
UNIQUE KEY(`module_name`, `name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) {
@mkdir(VARPATH . $dir);
@@ -284,7 +284,7 @@ class gallery_installer {
`cache` text,
PRIMARY KEY (`id`),
KEY (`tags`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ DEFAULT CHARSET=utf8;");
module::set_version("gallery", $version = 4);
}
diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php
deleted file mode 100644
index 8a92890b..00000000
--- a/modules/gallery/helpers/gallery_quick.php
+++ /dev/null
@@ -1,152 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 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 gallery_quick_Core {
- static function get_quick_buttons($item, $page_type) {
- $buttons = self::buttons($item, $page_type);
- foreach (module::active() as $module) {
- if ($module->name == "gallery") {
- continue;
- }
- $class_name = "{$module->name}_quick";
- if (method_exists($class_name, "buttons")) {
- $module_buttons = call_user_func(array($class_name, "buttons"), $item, $page_type);
- foreach (array("left", "center", "right", "additional") as $position) {
- if (!empty($module_buttons[$position])) {
- $buttons[$position] = array_merge($buttons[$position], $module_buttons[$position]);
- }
- }
- }
- }
-
- $sorted_buttons->main = array();
- foreach (array("left", "center", "right") as $position) {
- $sorted_buttons->main = array_merge($sorted_buttons->main, $buttons[$position]);
- }
-
- $sorted_buttons->additional = $buttons["additional"];
- $max_display = empty($sorted_buttons->additional) ? 6 : 5;
- if (count($sorted_buttons->main) >= $max_display) {
- $to_move = array_slice($sorted_buttons->main, 5);
- $sorted_buttons->additional = array_merge($to_move, $sorted_buttons->additional);
- for ($i = count($sorted_buttons->main); $i >= 5; $i--) {
- unset($sorted_buttons->main[$i]);
- }
- }
-
- return $sorted_buttons;
- }
-
- static function buttons($item, $page_type) {
- $elements = array("left" => array(), "center" => array(), "right" => array(),
- "additional" => array());
- switch ($item->type) {
- case "movie":
- $edit_title = t("Edit this movie");
- $move_title = t("Move this movie to another album");
- $cover_title = t("Choose this movie as the album cover");
- $delete_title = t("Delete this movie");
- break;
- case "album":
- $edit_title = t("Edit this album");
- $move_title = t("Move this album to another album");
- $cover_title = t("Choose this album as the album cover");
- $delete_title = t("Delete this album");
- break;
- default:
- $edit_title = t("Edit this photo");
- $move_title = t("Move this photo to another album");
- $cover_title = t("Choose this photo as the album cover");
- $delete_title = t("Delete this photo");
- break;
- }
-
- $csrf = access::csrf_token();
- $elements["left"][] = (object)array(
- "title" => $edit_title,
- "class" => "gDialogLink gButtonLink",
- "icon" => "ui-icon-pencil",
- "href" => url::site("quick/form_edit/$item->id?page_type=$page_type"));
-
- if ($item->is_photo() && graphics::can("rotate")) {
- $elements["left"][] =
- (object)array(
- "title" => t("Rotate 90 degrees counter clockwise"),
- "class" => "gButtonLink",
- "icon" => "ui-icon-rotate-ccw",
- "href" => url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type"));
- $elements["left"][] =
- (object)array(
- "title" => t("Rotate 90 degrees clockwise"),
- "class" => "gButtonLink",
- "icon" => "ui-icon-rotate-cw",
- "href" => url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type"));
- }
-
- // Don't move photos from the photo page; we don't yet have a good way of redirecting after move
- if ($page_type == "album") {
- $elements["left"][] = (object)array(
- "title" => $move_title,
- "class" => "gDialogLink gButtonLink",
- "icon" => "ui-icon-folder-open",
- "href" => url::site("move/browse/$item->id"));
- }
-
- $parent = $item->parent();
- if (access::can("edit", $parent)) {
- // We can't make this item the highlight if it's an album with no album cover, or if it's
- // already the album cover.
- if (($item->type == "album" && empty($item->album_cover_item_id)) ||
- ($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) ||
- $parent->album_cover_item_id == $item->id) {
- $disabledState = " ui-state-disabled";
- } else {
- $disabledState = " ";
- }
- $elements["right"][] = (object)array(
- "title" => $cover_title,
- "class" => "gButtonLink$disabledState",
- "icon" => "ui-icon-star",
- "href" => url::site("quick/make_album_cover/$item->id?csrf=$csrf&page_type=$page_type"));
-
- $elements["right"][] = (object)array(
- "title" => $delete_title,
- "class" => "gDialogLink gButtonLink",
- "icon" => "ui-icon-trash",
- "id" => "gQuickDelete",
- "href" => url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type"));
- }
-
- if ($item->is_album()) {
- $elements["additional"][] = (object)array(
- "title" => t("Add a photo"),
- "class" => "add_item gDialogLink",
- "href" => url::site("simple_uploader/app/$item->id"));
- $elements["additional"][] = (object)array(
- "title" => t("Add an album"),
- "class" => "add_album gDialogLink",
- "href" => url::site("form/add/albums/$item->id?type=album"));
- $elements["additional"][] = (object)array(
- "title" => t("Edit permissions"),
- "class" => "permissions gDialogLink",
- "href" => url::site("permissions/browse/$item->id"));
- }
- return $elements;
- }
-}
diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php
index be555296..affb3101 100644
--- a/modules/gallery/helpers/gallery_rss.php
+++ b/modules/gallery/helpers/gallery_rss.php
@@ -50,8 +50,9 @@ class gallery_rss_Core {
$feed->children = $item
->viewable()
- ->descendants($limit, $offset, "photo");
- $feed->max_pages = ceil($item->viewable()->descendants_count("photo") / $limit);
+ ->descendants($limit, $offset, array("type" => "photo"));
+ $feed->max_pages = ceil(
+ $item->viewable()->descendants_count(array("type" => "photo")) / $limit);
$feed->title = SafeString::purify($item->title);
$feed->link = url::abs_site("albums/{$item->id}");
$feed->description = nl2br(SafeString::purify($item->description));
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index d3751b80..69c5a091 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -24,11 +24,6 @@ class gallery_theme_Core {
if ($session->get("debug")) {
$theme->css("debug.css");
}
- if (($theme->page_type == "album" || $theme->page_type == "photo")
- && access::can("edit", $theme->item())) {
- $theme->css("quick.css");
- $theme->script("quick.js");
- }
if (module::is_active("rss")) {
if ($item = $theme->item()) {
@@ -51,33 +46,8 @@ class gallery_theme_Core {
return $buf;
}
- static function resize_top($theme, $item) {
- if (access::can("edit", $item)) {
- $edit_link = url::site("quick/pane/$item->id?page_type=photo");
- return "<div class=\"gQuick\" href=\"$edit_link\">";
- }
- }
-
- static function resize_bottom($theme, $item) {
- if (access::can("edit", $item)) {
- return "</div>";
- }
- }
-
- static function thumb_top($theme, $child) {
- if (access::can("edit", $child)) {
- $edit_link = url::site("quick/pane/$child->id?page_type=album");
- return "<div class=\"gQuick\" href=\"$edit_link\">";
- }
- }
-
- static function thumb_bottom($theme, $child) {
- if (access::can("edit", $child)) {
- return "</div>";
- }
- }
-
static function admin_head($theme) {
+ $theme->script("gallery.panel.js");
$session = Session::instance();
if ($session->get("debug")) {
$theme->css("debug.css");
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index d506a982..7dc46eeb 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -339,15 +339,90 @@ class graphics_Core {
* GraphicsMagick we return the path to the directory containing the appropriate binaries.
*/
static function detect_toolkits() {
+ $toolkits = new stdClass();
+
+ // GD is special, it doesn't use exec()
$gd = function_exists("gd_info") ? gd_info() : array();
- $exec = function_exists("exec");
+ $toolkits->gd->name = "GD";
if (!isset($gd["GD Version"])) {
- $gd["GD Version"] = false;
+ $toolkits->gd->installed = false;
+ $toolkits->gd->error = t("GD is not installed");
+ } else {
+ $toolkits->gd->installed = true;
+ $toolkits->gd->version = $gd["GD Version"];
+ $toolkits->gd->rotate = function_exists("imagerotate");
+ $toolkits->gd->binary = "";
+ $toolkits->gd->dir = "";
+
+ if (!$toolkits->gd->rotate) {
+ $toolkits->gd->error =
+ t("You have GD version %version, but it lacks image rotation.",
+ array("version" => $gd["GD Version"]));
+ }
+ }
+
+ if (!function_exists("exec")) {
+ $toolkits->imagemagick->installed = false;
+ $toolkits->imagemagick->error = t("ImageMagick requires the <b>exec</b> function");
+
+ $toolkits->graphicsmagick->installed = false;
+ $toolkits->graphicsmagick->error = t("GraphicsMagick requires the <b>exec</b> function");
+ } else {
+ putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin:/opt/bin");
+
+ // @todo: consider refactoring the two segments below into a loop since they are so
+ // similar.
+
+ // ImageMagick
+ $path = exec("which convert");
+ $toolkits->imagemagick->name = "ImageMagick";
+ if ($path) {
+ if (@is_file($path)) {
+ preg_match('/Version: \S+ (\S+)/', `convert -v`, $matches);
+ $version = $matches[1];
+
+ $toolkits->imagemagick->installed = true;
+ $toolkits->imagemagick->version = $version;
+ $toolkits->imagemagick->binary = $path;
+ $toolkits->imagemagick->dir = dirname($path);
+ $toolkits->imagemagick->rotate = true;
+ } else {
+ $toolkits->imagemagick->installed = false;
+ $toolkits->imagemagick->error =
+ t("ImageMagick is installed, but PHP's open_basedir restriction " .
+ "prevents Gallery from using it.");
+ }
+ } else {
+ $toolkits->imagemagick->installed = false;
+ $toolkits->imagemagick->error = t("We could not locate ImageMagick on your system.");
+ }
+
+ // GraphicsMagick
+ $path = exec("which gm");
+ $toolkits->graphicsmagick->name = "GraphicsMagick";
+ if ($path) {
+ if (@is_file($path)) {
+ preg_match('/\S+ (\S+)/', `gm version`, $matches);
+ $version = $matches[1];
+
+ $toolkits->graphicsmagick->installed = true;
+ $toolkits->graphicsmagick->version = $version;
+ $toolkits->graphicsmagick->binary = $path;
+ $toolkits->graphicsmagick->dir = dirname($path);
+ $toolkits->graphicsmagick->rotate = true;
+ } else {
+ $toolkits->graphicsmagick->installed = false;
+ $toolkits->graphicsmagick->error =
+ t("GraphicsMagick is installed, but PHP's open_basedir restriction " .
+ "prevents Gallery from using it.");
+ }
+ } else {
+ $toolkits->graphicsmagick->installed = false;
+ $toolkits->graphicsmagick->error = t("We could not locate GraphicsMagick on your system.");
+ }
}
- putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin:/opt/bin");
- return array("gd" => $gd,
- "imagemagick" => $exec ? dirname(exec("which convert")) : false,
- "graphicsmagick" => $exec ? dirname(exec("which gm")) : false);
+
+ return $toolkits;
}
/**
@@ -357,12 +432,13 @@ class graphics_Core {
// Detect a graphics toolkit
$toolkits = graphics::detect_toolkits();
foreach (array("imagemagick", "graphicsmagick", "gd") as $tk) {
- if ($toolkits[$tk]) {
+ if ($toolkits->$tk->installed) {
module::set_var("gallery", "graphics_toolkit", $tk);
- module::set_var("gallery", "graphics_toolkit_path", $tk == "gd" ? "" : $toolkits[$tk]);
+ module::set_var("gallery", "graphics_toolkit_path", $toolkits->$tk->dir);
break;
}
}
+
if (!module::get_var("gallery", "graphics_toolkit")) {
site_status::warning(
t("Graphics toolkit missing! Please <a href=\"%url\">choose a toolkit</a>",
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 80c25862..8839861f 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -129,7 +129,7 @@ class item_Core {
if (Input::instance()->get("page_type") == "album") {
$page_type = "album";
} else {
- $page_type = "item";
+ $page_type = "photo";
}
$form = new Forge("quick/delete/$item->id?page_type=$page_type", "", "post", array("id" => "gConfirmDelete"));
$form->hidden("_method")->value("put");
@@ -137,4 +137,55 @@ class item_Core {
$group->submit("")->value(t("Delete"));
return $form;
}
+
+ /**
+ * Get the next weight value
+ */
+ static function get_max_weight() {
+ // Guard against an empty result when we create the first item. It's unfortunate that we
+ // have to check this every time.
+ // @todo: figure out a better way to bootstrap the weight.
+ $result = Database::instance()
+ ->select("weight")->from("items")
+ ->orderby("weight", "desc")->limit(1)
+ ->get()->current();
+ return ($result ? $result->weight : 0) + 1;
+ }
+
+ /**
+ * Add a set of restrictions to any following queries to restrict access only to items
+ * viewable by the active user.
+ * @chainable
+ */
+ static function viewable($model) {
+ $view_restrictions = array();
+ if (!user::active()->admin) {
+ foreach (user::group_ids() as $id) {
+ // Separate the first restriction from the rest to make it easier for us to formulate
+ // our where clause below
+ if (empty($view_restrictions)) {
+ $view_restrictions[0] = "items.view_$id";
+ } else {
+ $view_restrictions[1]["items.view_$id"] = access::ALLOW;
+ }
+ }
+ }
+ switch (count($view_restrictions)) {
+ case 0:
+ break;
+
+ case 1:
+ $model->where($view_restrictions[0], access::ALLOW);
+ break;
+
+ default:
+ $model->open_paren();
+ $model->where($view_restrictions[0], access::ALLOW);
+ $model->orwhere($view_restrictions[1]);
+ $model->close_paren();
+ break;
+ }
+
+ return $model;
+ }
} \ No newline at end of file
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index 0d483206..03d538a9 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -274,11 +274,9 @@ class module_Core {
array_shift($args);
$function = str_replace(".", "_", $name);
- foreach (self::$modules as $module) {
- if (!$module->active) {
- continue;
- }
-
+ // @todo: consider calling gallery_event first, since for things menus we need it to do some
+ // setup
+ foreach (self::$active as $module) {
$class = "{$module->name}_event";
if (method_exists($class, $function)) {
call_user_func_array(array($class, $function), $args);
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index 5cf37de1..96a66d29 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -109,8 +109,12 @@ class photo_Core {
// there's only one save() happening here.
module::event("item_created", $photo);
- // Build our thumbnail/resizes
- graphics::generate($photo);
+ // Build our thumbnail/resizes. If we fail to build thumbnail/resize we assume that the image
+ // is bad in some way and discard it.
+ if (!graphics::generate($photo)) {
+ $photo->delete();
+ throw new Exception("@todo BAD_IMAGE_FILE");
+ }
// If the parent has no cover item, make this it.
if (access::can("edit", $parent) && $parent->album_cover_item_id == null) {
diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php
index 352fe522..9fa04305 100644
--- a/modules/gallery/helpers/task.php
+++ b/modules/gallery/helpers/task.php
@@ -84,6 +84,7 @@ class task_Core {
}
$task->save();
} catch (Exception $e) {
+ Kohana::log("error", $e->__toString());
$task->log($e->__toString());
$task->state = "error";
$task->done = true;
diff --git a/modules/gallery/js/l10n_client.js b/modules/gallery/js/l10n_client.js
index f5be5058..80fe166b 100644
--- a/modules/gallery/js/l10n_client.js
+++ b/modules/gallery/js/l10n_client.js
@@ -58,7 +58,8 @@ jQuery.extend(Gallery, {
case 1:
$('#l10n-client-string-select, #l10n-client-string-editor, #l10n-client .labels .label').show();
$('#l10n-client').height('22em').removeClass('hidden');
- $('#l10n-client-toggler').text(MSG_CLOSE_X);
+ //$('#l10n-client').slideUp();
+ $('#gMinimizeL10n').text("_");
/*
* This CSS clashes with Gallery's CSS, probably due to
* YUI's grid / floats.
@@ -72,7 +73,7 @@ jQuery.extend(Gallery, {
$('#l10n-client-string-select, #l10n-client-string-editor, #l10n-client .labels .label').hide();
$('#l10n-client').height('2em').addClass('hidden');
// TODO: Localize this message
- $('#l10n-client-toggler').text(MSG_TRANSLATE_TEXT);
+ $('#gMinimizeL10n').text(MSG_TRANSLATE_TEXT);
/*
if(!$.browser.msie) {
$('body').css('border-bottom', '0px');
@@ -197,7 +198,7 @@ Gallery.behaviors.l10nClient = function(context) {
});
// When l10n_client window is clicked, toggle based on current state.
- $('#l10n-client-toggler').click(function() {
+ $('#gMinimizeL10n').click(function() {
if($('#l10n-client').is('.hidden')) {
Gallery.l10nClient.toggle(1);
} else {
diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js
deleted file mode 100644
index fda6470f..00000000
--- a/modules/gallery/js/quick.js
+++ /dev/null
@@ -1,78 +0,0 @@
-$(document).ready(function() {
- if ($("#gAlbumGrid").length) {
- // @todo Add quick edit pane for album (meta, move, permissions, delete)
- $(".gItem").hover(show_quick, function() {});
- }
- if ($("#gPhoto").length) {
- $("#gPhoto").hover(show_quick, function() {});
- }
-});
-
-var show_quick = function() {
- var cont = $(this);
- var quick = $(this).find(".gQuick");
- var img = cont.find(".gThumbnail,.gResize");
- cont.find(".gQuickPane").remove();
- cont.append("<div class=\"gQuickPane\"></div>");
- cont.find(".gQuickPane").hide();
- cont.hover(function() {}, function() { cont.find(".gQuickPane").remove(); });
- $.get(
- quick.attr("href"),
- {},
- function(data, textStatus) {
- cont.find(".gQuickPane").html(data).slideDown("fast");
- $(".ui-state-default").hover(
- function() {
- $(this).addClass("ui-state-hover");
- },
- function() {
- $(this).removeClass("ui-state-hover");
- }
- );
- cont.find(".gQuickPane a:not(.options)").click(function(e) {
- e.preventDefault();
- quick_do(cont, $(this), img);
- });
- cont.find(".gQuickPane a.options").click(function(e) {
- e.preventDefault();
- cont.find(".gQuickPaneOptions").slideToggle("fast");
- });
- }
- );
-};
-
-var quick_do = function(cont, pane, img) {
- if (pane.hasClass("ui-state-disabled")) {
- return false;
- }
- if (pane.hasClass("gDialogLink")) {
- openDialog(pane);
- } else {
- img.css("opacity", "0.1");
- cont.addClass("gLoadingLarge");
- $.ajax({
- type: "GET",
- url: pane.attr("href"),
- dataType: "json",
- success: function(data) {
- img.css("opacity", "1");
- cont.removeClass("gLoadingLarge");
- if (data.src) {
- img.attr("width", data.width);
- img.attr("height", data.height);
- img.attr("src", data.src);
- if (data.height > data.width) {
- img.css("margin-top", -32);
- } else {
- img.css("margin-top", 0);
- }
- } else if (data.location) {
- window.location = data.location;
- } else if (data.reload) {
- window.location.reload();
- }
- }
- });
- }
- return false;
-};
diff --git a/modules/gallery/libraries/I18n.php b/modules/gallery/libraries/I18n.php
index a53d5ae9..c3336052 100644
--- a/modules/gallery/libraries/I18n.php
+++ b/modules/gallery/libraries/I18n.php
@@ -77,7 +77,12 @@ class I18n_Core {
// TODO: See G2 for better fallack code.
$locale_prefs = array($locale);
$locale_prefs[] = 'en_US';
- setlocale(LC_ALL, $locale_prefs);
+ $new_locale = setlocale(LC_ALL, $locale_prefs);
+ if (is_string($new_locale) && strpos($new_locale, 'tr') === 0) {
+ // Make PHP 5 work with Turkish (the localization results are mixed though).
+ // Hack for http://bugs.php.net/18556
+ setlocale(LC_CTYPE, 'C');
+ }
}
return $this->_config['default_locale'];
}
@@ -184,7 +189,7 @@ class I18n_Core {
static function is_plural_message($message) {
return is_array($message);
}
-
+
private function interpolate($locale, $string, $key_values) {
// TODO: Handle locale specific number formatting.
diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php
index a39b59a5..07b2b2b8 100644
--- a/modules/gallery/libraries/Menu.php
+++ b/modules/gallery/libraries/Menu.php
@@ -91,12 +91,43 @@ class Menu_Element_Link extends Menu_Element {
} else {
$css_class = "";
}
- return "<li><a$css_id class=\"gMenuElement$css_class\" href=\"$this->url\" " .
+ return "<li><a$css_id class=\"gMenuLink $css_class\" href=\"$this->url\" " .
"title=\"$this->label\">$this->label</a></li>";
}
}
/**
+ * Menu element that provides an AJAX link.
+ */
+class Menu_Element_Ajax_Link extends Menu_Element {
+ public $ajax_handler;
+
+ /**
+ * Set the AJAX handler
+ * @chainable
+ */
+ public function ajax_handler($ajax_handler) {
+ $this->ajax_handler = $ajax_handler;
+ return $this;
+ }
+
+ public function __toString() {
+ if (isset($this->css_id) && !empty($this->css_id)) {
+ $css_id = " id=\"$this->css_id\"";
+ } else {
+ $css_id = "";
+ }
+ if (isset($this->css_class) && !empty($this->css_class)) {
+ $css_class = " $this->css_class";
+ } else {
+ $css_class = "";
+ }
+ return "<li><a$css_id class=\"gAjaxLink $css_class\" href=\"$this->url\" " .
+ "title=\"$this->label\" ajax_handler=\"$this->ajax_handler\">$this->label</a></li>";
+ }
+}
+
+/**
* Menu element that provides a pop-up dialog
*/
class Menu_Element_Dialog extends Menu_Element {
@@ -111,7 +142,7 @@ class Menu_Element_Dialog extends Menu_Element {
} else {
$css_class = "";
}
- return "<li><a$css_id class=\"gMenuLink$css_class\" href=\"$this->url\" " .
+ return "<li><a$css_id class=\"gDialogLink $css_class\" href=\"$this->url\" " .
"title=\"$this->label\">$this->label</a></li>";
}
}
@@ -132,6 +163,9 @@ class Menu_Core extends Menu_Element {
case "link":
return new Menu_Element_Link($type);
+ case "ajax_link":
+ return new Menu_Element_Ajax_Link($type);
+
case "dialog":
return new Menu_Element_Dialog($type);
diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php
index 1917d738..a7defba9 100644
--- a/modules/gallery/libraries/ORM_MPTT.php
+++ b/modules/gallery/libraries/ORM_MPTT.php
@@ -146,69 +146,62 @@ class ORM_MPTT_Core extends ORM {
* @chainable
* @param integer SQL limit
* @param integer SQL offset
+ * @param array additional where clauses
* @param array orderby
* @return array ORM
*/
- function children($limit=null, $offset=0, $orderby=null) {
- $this->where("parent_id", $this->id);
- if (empty($orderby)) {
- $this->orderby("id", "ASC");
- } else {
- $this->orderby($orderby);
- }
- return $this->find_all($limit, $offset);
+ function children($limit=null, $offset=0, $where=array(), $orderby=array("id" => "ASC")) {
+ return $this
+ ->where("parent_id", $this->id)
+ ->where($where)
+ ->orderby($orderby)
+ ->find_all($limit, $offset);
}
/**
* Return all of the children of this node, ordered by id.
*
* @chainable
- * @param integer SQL limit
- * @param integer SQL offset
+ * @param array additional where clauses
* @return array ORM
*/
- function children_count() {
- return $this->where("parent_id", $this->id)->count_all();
+ function children_count($where=array()) {
+ return $this
+ ->where($where)
+ ->where("parent_id", $this->id)
+ ->count_all();
}
/**
- * Return all of the children of the specified type, ordered by id.
+ * Return all of the decendents of the specified type, ordered by id.
*
* @param integer SQL limit
* @param integer SQL offset
- * @param string type to return
+ * @param array additional where clauses
* @param array orderby
* @return object ORM_Iterator
*/
- function descendants($limit=null, $offset=0, $type=null, $orderby=null) {
- $this->where("left_ptr >", $this->left_ptr)
- ->where("right_ptr <=", $this->right_ptr);
- if ($type) {
- $this->where("type", $type);
- }
-
- if (empty($orderby)) {
- $this->orderby("id", "ASC");
- } else {
- $this->orderby($orderby);
- }
-
- return $this->find_all($limit, $offset);
+ function descendants($limit=null, $offset=0, $where=array(), $orderby=array("id" => "ASC")) {
+ return $this
+ ->where("left_ptr >", $this->left_ptr)
+ ->where("right_ptr <=", $this->right_ptr)
+ ->where($where)
+ ->orderby($orderby)
+ ->find_all($limit, $offset);
}
/**
* Return the count of all the children of the specified type.
*
- * @param string type to count
+ * @param array additional where clauses
* @return integer child count
*/
- function descendants_count($type=null) {
- $this->where("left_ptr >", $this->left_ptr)
- ->where("right_ptr <=", $this->right_ptr);
- if ($type) {
- $this->where("type", $type);
- }
- return $this->count_all();
+ function descendants_count($where=array()) {
+ return $this
+ ->where("left_ptr >", $this->left_ptr)
+ ->where("right_ptr <=", $this->right_ptr)
+ ->where($where)
+ ->count_all();
}
/**
diff --git a/modules/gallery/libraries/Sendmail.php b/modules/gallery/libraries/Sendmail.php
index 90998457..7bc21a67 100644
--- a/modules/gallery/libraries/Sendmail.php
+++ b/modules/gallery/libraries/Sendmail.php
@@ -52,6 +52,7 @@ class Sendmail_Core {
break;
case "header":
if (count($value) != 2) {
+ Kohana::log("error", wordwrap("Invalid header parameters\n" . Kohana::debug($value)));
throw new Exception("@todo INVALID_HEADER_PARAMETERS");
}
$this->headers[$value[0]] = $value[1];
@@ -70,6 +71,7 @@ class Sendmail_Core {
public function send() {
if (empty($this->to)) {
+ Kohana::log("error", wordwrap("Sending mail failed:\nNo to address specified"));
throw new Exception("@todo TO_IS_REQUIRED_FOR_MAIL");
}
$to = implode(", ", $this->to);
@@ -84,8 +86,6 @@ class Sendmail_Core {
$headers = implode($this->header_separator, $headers);
$message = wordwrap($this->message, $this->line_length, "\n");
if (!$this->mail($to, $this->subject, $message, $headers)) {
- Kohana::log("error", wordwrap("Sending mail failed:\nTo: $to\n $this->subject\n" .
- "Headers: $headers\n $this->message"));
throw new Exception("@todo SEND_MAIL_FAILED");
}
return $this;
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 360e5e46..541bce88 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -111,14 +111,15 @@ class Theme_View_Core extends Gallery_View {
return $menu->compact();
}
- public function thumb_menu($item) {
+ public function context_menu($item, $thumbnail_css_selector) {
$menu = Menu::factory("root")
->append(Menu::factory("submenu")
- ->id("options_menu")
+ ->id("context_menu")
->label(t("Options")))
- ->css_class("gThumbMenu");
+ ->css_class("gContextMenu");
- module::event("thumb_menu", $menu, $this, $item);
+ gallery::context_menu($menu, $this, $item, $thumbnail_css_selector);
+ module::event("context_menu", $menu, $this, $item, $thumbnail_css_selector);
return $menu->compact();
}
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index f3e6b8f3..68e89db6 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -19,7 +19,6 @@
*/
class Item_Model extends ORM_MPTT {
protected $children = 'items';
- private $view_restrictions = null;
protected $sorting = array();
var $rules = array(
@@ -34,38 +33,7 @@ class Item_Model extends ORM_MPTT {
* @chainable
*/
public function viewable() {
- if (is_null($this->view_restrictions)) {
- if (user::active()->admin) {
- $this->view_restrictions = array();
- } else {
- foreach (user::group_ids() as $id) {
- // Separate the first restriction from the rest to make it easier for us to formulate
- // our where clause below
- if (empty($this->view_restrictions)) {
- $this->view_restrictions[0] = "view_$id";
- } else {
- $this->view_restrictions[1]["view_$id"] = access::ALLOW;
- }
- }
- }
- }
- switch (count($this->view_restrictions)) {
- case 0:
- break;
-
- case 1:
- $this->where($this->view_restrictions[0], access::ALLOW);
- break;
-
- default:
- $this->open_paren();
- $this->where($this->view_restrictions[0], access::ALLOW);
- $this->orwhere($this->view_restrictions[1]);
- $this->close_paren();
- break;
- }
-
- return $this;
+ return item::viewable($this);
}
/**
@@ -351,14 +319,7 @@ class Item_Model extends ORM_MPTT {
$this->updated = time();
if (!$this->loaded) {
$this->created = $this->updated;
- // Guard against an empty result when we create the first item. It's unfortunate that we
- // have to check this every time.
- // @todo: figure out a better way to bootstrap the weight.
- $result = Database::instance()
- ->select("weight")->from("items")
- ->orderby("weight", "desc")->limit(1)
- ->get()->current();
- $this->weight = ($result ? $result->weight : 0) + 1;
+ $this->weight = item::get_max_weight();
} else {
$send_event = 1;
}
@@ -521,26 +482,38 @@ class Item_Model extends ORM_MPTT {
}
/**
- * Return all of the children of this node, ordered by the defined sort order.
+ * Return all of the children of this album. Unless you specify a specific sort order, the
+ * results will be ordered by this album's sort order.
*
* @chainable
* @param integer SQL limit
* @param integer SQL offset
+ * @param array additional where clauses
+ * @param array orderby
* @return array ORM
*/
- function children($limit=null, $offset=0) {
- return parent::children($limit, $offset, array($this->sort_column => $this->sort_order));
+ function children($limit=null, $offset=0, $where=array(), $orderby=null) {
+ if (empty($orderby)) {
+ $orderby = array($this->sort_column => $this->sort_order);
+ }
+ return parent::children($limit, $offset, $where, $orderby);
}
/**
- * Return all of the children of the specified type, ordered by the defined sort order.
+ * Return the children of this album, and all of it's sub-albums. Unless you specify a specific
+ * sort order, the results will be ordered by this album's sort order. Note that this
+ * album's sort order is imposed on all sub-albums, regardless of their sort order.
+ *
+ * @chainable
* @param integer SQL limit
* @param integer SQL offset
- * @param string type to return
+ * @param array additional where clauses
* @return object ORM_Iterator
*/
- function descendants($limit=null, $offset=0, $type=null) {
- return parent::descendants($limit, $offset, $type,
- array($this->sort_column => $this->sort_order));
+ function descendants($limit=null, $offset=0, $where=array(), $orderby=null) {
+ if (empty($orderby)) {
+ $orderby = array($this->sort_column => $this->sort_order);
+ }
+ return parent::descendants($limit, $offset, $where, $orderby);
}
}
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
new file mode 100644
index 00000000..3f80733f
--- /dev/null
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -0,0 +1,49 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 Item_Helper_Test extends Unit_Test_Case {
+
+ public function viewable_test() {
+ $root = ORM::factory("item", 1);
+ $album = album::create($root, rand(), rand(), rand());
+ $item = self::_create_random_item($album);
+ user::set_active(user::guest());
+
+ // We can see the item when permissions are granted
+ access::allow(group::everybody(), "view", $album);
+ $this->assert_equal(
+ 1,
+ ORM::factory("item")->viewable()->where("id", $item->id)->count_all());
+
+ // We can't see the item when permissions are denied
+ access::deny(group::everybody(), "view", $album);
+ $this->assert_equal(
+ 0,
+ ORM::factory("item")->viewable()->where("id", $item->id)->count_all());
+ }
+
+
+ private static function _create_random_item($album) {
+ // Set all required fields (values are irrelevant)
+ $item = ORM::factory("item");
+ $item->name = rand();
+ $item->type = "photo";
+ return $item->add_to_parent($album);
+ }
+}
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 0940d076..585e247c 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -19,12 +19,12 @@
*/
class Item_Model_Test extends Unit_Test_Case {
public function saving_sets_created_and_updated_dates_test() {
- $item = self::create_random_item();
+ $item = self::_create_random_item();
$this->assert_true(!empty($item->created));
$this->assert_true(!empty($item->updated));
}
- private function create_random_item() {
+ private static function _create_random_item() {
$item = ORM::factory("item");
/* Set all required fields (values are irrelevant) */
$item->name = rand();
@@ -33,7 +33,7 @@ class Item_Model_Test extends Unit_Test_Case {
}
public function updating_doesnt_change_created_date_test() {
- $item = self::create_random_item();
+ $item = self::_create_random_item();
// Force the creation date to something well known
$db = Database::instance();
@@ -47,7 +47,7 @@ class Item_Model_Test extends Unit_Test_Case {
}
public function updating_view_count_only_doesnt_change_updated_date_test() {
- $item = self::create_random_item();
+ $item = self::_create_random_item();
$item->reload();
$this->assert_same(0, $item->view_count);
@@ -64,7 +64,7 @@ class Item_Model_Test extends Unit_Test_Case {
public function move_photo_test() {
// Create a test photo
- $item = self::create_random_item();
+ $item = self::_create_random_item();
file_put_contents($item->thumb_path(), "thumb");
file_put_contents($item->resize_path(), "resize");
@@ -128,7 +128,7 @@ class Item_Model_Test extends Unit_Test_Case {
public function item_rename_wont_accept_slash_test() {
// Create a test photo
- $item = self::create_random_item();
+ $item = self::_create_random_item();
$new_name = rand() . "/";
@@ -142,7 +142,7 @@ class Item_Model_Test extends Unit_Test_Case {
}
public function save_original_values_test() {
- $item = $this->create_random_item();
+ $item = self::_create_random_item();
$item->title = "ORIGINAL_VALUE";
$item->save();
$item->title = "NEW_VALUE";
diff --git a/modules/gallery/tests/ORM_MPTT_Test.php b/modules/gallery/tests/ORM_MPTT_Test.php
index 943810c3..f77f1f34 100644
--- a/modules/gallery/tests/ORM_MPTT_Test.php
+++ b/modules/gallery/tests/ORM_MPTT_Test.php
@@ -177,8 +177,8 @@ class ORM_MPTT_Test extends Unit_Test_Case {
$parent->reload();
$this->assert_equal(3, $parent->descendants()->count());
- $this->assert_equal(2, $parent->descendants(null, 0, "photo")->count());
- $this->assert_equal(1, $parent->descendants(null, 0, "album")->count());
+ $this->assert_equal(2, $parent->descendants(null, 0, array("type" => "photo"))->count());
+ $this->assert_equal(1, $parent->descendants(null, 0, array("type" => "album"))->count());
}
public function descendant_limit_test() {
@@ -215,7 +215,7 @@ class ORM_MPTT_Test extends Unit_Test_Case {
$parent->reload();
$this->assert_equal(3, $parent->descendants_count());
- $this->assert_equal(2, $parent->descendants_count("photo"));
- $this->assert_equal(1, $parent->descendants_count("album"));
+ $this->assert_equal(2, $parent->descendants_count(array("type" => "photo")));
+ $this->assert_equal(1, $parent->descendants_count(array("type" => "album")));
}
}
diff --git a/modules/gallery/views/admin_graphics.html.php b/modules/gallery/views/admin_graphics.html.php
index 08374471..c4a2f5c6 100644
--- a/modules/gallery/views/admin_graphics.html.php
+++ b/modules/gallery/views/admin_graphics.html.php
@@ -9,8 +9,8 @@
};
$("#gAdminGraphics div.gAvailable .gBlock").click(select_toolkit);
});
-
</script>
+
<div id="gAdminGraphics">
<h1> <?= t("Graphics Settings") ?> </h1>
<p>
@@ -18,11 +18,19 @@
</p>
<h2> <?= t("Active Toolkit") ?> </h2>
- <?= $active ?>
+ <? if ($active == "none"): ?>
+ <?= new View("admin_graphics_none.html") ?>
+ <? else: ?>
+ <?= new View("admin_graphics_$active.html", array("tk" => $tk->$active, "is_active" => true)) ?>
+ <? endif ?>
<div class="gAvailable">
<h2> <?= t("Available Toolkits") ?> </h2>
- <?= $available ?>
+ <? foreach (array_keys((array)$tk) as $id): ?>
+ <? if ($id != $active): ?>
+ <?= new View("admin_graphics_$id.html", array("tk" => $tk->$id, "is_active" => false)) ?>
+ <? endif ?>
+ <? endforeach ?>
</div>
</div>
diff --git a/modules/gallery/views/admin_graphics_gd.html.php b/modules/gallery/views/admin_graphics_gd.html.php
index b77da8e3..010a31b4 100644
--- a/modules/gallery/views/admin_graphics_gd.html.php
+++ b/modules/gallery/views/admin_graphics_gd.html.php
@@ -1,29 +1,30 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
-<div id="gd" class="gBlock<?= $is_active ? " gSelected" : "" ?><?= $tk->gd["GD Version"] ? " gInstalledToolkit" : " gUnavailable" ?>">
+<div id="gd" class="gBlock<?= $is_active ? " gSelected" : "" ?><?= $tk->installed ? " gInstalledToolkit" : " gUnavailable" ?>">
<img class="logo" width="170" height="110" src="<?= url::file("modules/gallery/images/gd.png"); ?>" alt="<? t("Visit the GD lib project site") ?>" />
<h3> <?= t("GD") ?> </h3>
<p>
<?= t("The GD graphics library is an extension to PHP commonly installed most webservers. Please refer to the <a href=\"%url\">GD website</a> for more information.",
array("url" => "http://www.boutell.com/gd")) ?>
</p>
- <? if ($tk->gd["GD Version"] && function_exists('imagerotate')): ?>
- <p class="gSuccess">
- <?= t("You have GD version %version.", array("version" => $tk->gd["GD Version"])) ?>
- </p>
+ <? if ($tk->installed && $tk->rotate): ?>
+ <div class="gModuleStatus gInfo">
+ <?= t("You have GD version %version.", array("version" => $tk->version)) ?>
+ </div>
<p>
<a class="gButtonLink ui-state-default ui-corner-all"><?= t("Activate GD") ?></a>
</p>
- <? elseif ($tk->gd["GD Version"]): ?>
- <p class="gWarning">
- <?= t("You have GD version %version, but it lacks image rotation.",
- array("version" => $tk->gd["GD Version"])) ?>
+ <? elseif ($tk->installed): ?>
+ <? if ($tk->error): ?>
+ <p class="gModuleStatus gWarning">
+ <?= $tk->error ?>
</p>
+ <? endif ?>
<p>
<a class="gButtonLink ui-state-default ui-corner-all"><?= t("Activate GD") ?></a>
</p>
<? else: ?>
- <p class="gInfo">
+ <div class="gModuleStatus gInfo">
<?= t("You do not have GD installed.") ?>
- </p>
+ </div>
<? endif ?>
</div>
diff --git a/modules/gallery/views/admin_graphics_graphicsmagick.html.php b/modules/gallery/views/admin_graphics_graphicsmagick.html.php
index e2cd0777..97624850 100644
--- a/modules/gallery/views/admin_graphics_graphicsmagick.html.php
+++ b/modules/gallery/views/admin_graphics_graphicsmagick.html.php
@@ -1,21 +1,21 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
-<div id="graphicsmagick" class="gBlock<?= $is_active ? " gSelected" : "" ?><?= $tk->graphicsmagick ? " gInstalledToolkit" : " gUnavailable" ?>">
- <h3> <?= t("GraphicsMagick") ?> </h3>
+<div id="graphicsmagick" class="gBlock<?= $is_active ? " gSelected" : "" ?><?= $tk->installed ? " gInstalledToolkit" : " gUnavailable" ?>">
<img class="logo" width="107" height="76" src="<?= url::file("modules/gallery/images/graphicsmagick.png"); ?>" alt="<? t("Visit the GraphicsMagick project site") ?>" />
+ <h3> <?= t("GraphicsMagick") ?> </h3>
<p>
<?= t("GraphicsMagick is a standalone graphics program available on most Linux systems. Please refer to the <a href=\"%url\">GraphicsMagick website</a> for more information.",
array("url" => "http://www.graphicsmagick.org")) ?>
</p>
- <? if ($tk->graphicsmagick): ?>
- <p class="gSuccess">
- <?= t("GraphicsMagick is available in %path", array("path" => $tk->graphicsmagick)) ?>
- </p>
+ <? if ($tk->installed): ?>
+ <div class="gModuleStatus gInfo">
+ <?= t("GraphicsMagick version %version is available in %dir", array("version" => $tk->version, "dir" => $tk->dir)) ?>
+ </div>
<p>
<a class="gButtonLink ui-state-default ui-corner-all"><?= t("Activate Graphics Magic") ?></a>
</p>
<? else: ?>
- <p class="gInfo">
- <?= t("GraphicsMagick is not available on your system.") ?>
- </p>
+ <div class="gModuleStatus gWarning">
+ <?= $tk->error ?>
+ </div>
<? endif ?>
</div>
diff --git a/modules/gallery/views/admin_graphics_imagemagick.html.php b/modules/gallery/views/admin_graphics_imagemagick.html.php
index 081ddc15..cdff7c2c 100644
--- a/modules/gallery/views/admin_graphics_imagemagick.html.php
+++ b/modules/gallery/views/admin_graphics_imagemagick.html.php
@@ -1,21 +1,21 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
-<div id="imagemagick" class="gBlock<?= $is_active ? " gSelected" : "" ?><?= $tk->imagemagick ? " gInstalledToolkit" : " gUnavailable" ?>">
- <h3> <?= t("ImageMagick") ?> </h3>
+<div id="imagemagick" class="gBlock<?= $is_active ? " gSelected" : "" ?><?= $tk->installed ? " gInstalledToolkit" : " gUnavailable" ?>">
<img class="logo" width="114" height="118" src="<?= url::file("modules/gallery/images/imagemagick.jpg"); ?>" alt="<? t("Visit the ImageMagick project site") ?>" />
+ <h3> <?= t("ImageMagick") ?> </h3>
<p>
<?= t("ImageMagick is a standalone graphics program available on most Linux systems. Please refer to the <a href=\"%url\">ImageMagick website</a> for more information.",
array("url" => "http://www.imagemagick.org")) ?>
</p>
- <? if ($tk->imagemagick): ?>
- <p class="gSuccess">
- <?= t("ImageMagick is available in %path", array("path" => $tk->imagemagick)) ?>
- </p>
+ <? if ($tk->installed): ?>
+ <div class="gModuleStatus gInfo">
+ <?= t("ImageMagick version %version is available in %dir", array("version" => $tk->version, "dir" => $tk->dir)) ?>
+ </div>
<p>
<a class="gButtonLink ui-state-default ui-corner-all"><?= t("Activate ImageMagick") ?></a>
</p>
- <? else: ?>
- <p class="gInfo">
- <?= t("ImageMagick is not available on your system.") ?>
- </p>
+ <? elseif ($tk->error): ?>
+ <div class="gModuleStatus gWarning">
+ <?= $tk->error ?>
+ </div>
<? endif ?>
</div>
diff --git a/modules/gallery/views/admin_graphics_none.html.php b/modules/gallery/views/admin_graphics_none.html.php
index 5306a70d..e6923a5a 100644
--- a/modules/gallery/views/admin_graphics_none.html.php
+++ b/modules/gallery/views/admin_graphics_none.html.php
@@ -1,7 +1,8 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
-<div id="none" class="gBlock">
- <h3 class="gWarning"> <?= t("No Active Toolkit") ?> </h3>
+
+<div id="none" class="gModuleStatus gWarning gBlock">
+ <h3> <?= t("No Active Toolkit") ?> </h3>
<p>
- <?= t("We were unable to detect a graphics program. You must install one of the toolkits below in order to many Gallery features.") ?>
+ <?= t("We were unable to detect a graphics program. You must install one of the toolkits below in order to use many Gallery features.") ?>
</p>
</div>
diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php
index f41694b4..4025437a 100644
--- a/modules/gallery/views/admin_languages.html.php
+++ b/modules/gallery/views/admin_languages.html.php
@@ -1,15 +1,100 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="gLanguages">
- <h2> <?= t("Languages") ?> </h2>
+ <h1> <?= t("Languages") ?> </h1>
+ <p>
+ <?= t("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>
+</div>
- <h2> <?= t("Your Own Translations") ?> </h2>
+<div id="gTranslations">
+ <h1> <?= t("Translations") ?> </h1>
+ <p>
+ <?= t("Create your own translations and share them with the rest of the Gallery community.") ?>
+ </p>
+
+ <h3><?= t("Translating Gallery") ?></h3>
+
+ <div class="gBlock">
+ <a href="http://codex.gallery2.org/Gallery3:Localization" target="_blank"
+ class="gDocLink ui-state-default ui-corner-all ui-icon ui-icon-help"
+ title="<?= t("Localization documentation") ?>">
+ <?= t("Localization documentation") ?>
+ </a>
+
+ <p><strong><?= t("Step 1") ?>:</strong> <?= t("Make sure the target language is installed and updated (check above).") ?></p>
+
+ <p><strong><?= t("Step 2") ?>:</strong> <?= t("Make sure the target language is the active one (currently '").locales::display_name()."')." ?></p>
+
+ <p><strong><?= t("Step 3") ?>:</strong> <?= t("Start the translation mode and the translation interface will appear at the bottom of each Gallery page.") ?></p>
+
+ <a href="<?= url::site("l10n_client/toggle_l10n_mode?csrf=".access::csrf_token()) ?>"
+ class="gButtonLink ui-state-default ui-corner-all ui-icon-left">
+ <span class="ui-icon ui-icon-power"></span>
+ <?= t((Session::instance()->get("l10n_mode", false)) ? "Stop translation mode" : "Start translation mode") ?>
+ </a>
+ </div>
+
+ <h3>Sharing your translations</h3>
+
<?= $share_translations_form ?>
</div>
diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php
index a4db38ce..a0a6a19e 100644
--- a/modules/gallery/views/admin_maintenance.html.php
+++ b/modules/gallery/views/admin_maintenance.html.php
@@ -7,7 +7,7 @@
<div id="gAvailableTasks">
<h2> <?= t("Available Tasks") ?> </h2>
- <table>
+ <table class="gMessages">
<tr>
<th>
<?= t("Name") ?>
@@ -19,8 +19,9 @@
<?= t("Action") ?>
</th>
</tr>
+ <? $i = 0; ?>
<? foreach ($task_definitions as $task): ?>
- <tr class="<?= log::severity_class($task->severity) ?>">
+ <tr class="<?= log::severity_class($task->severity) ?> <?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?>">
<td>
<?= $task->name ?>
</td>
@@ -34,17 +35,18 @@
</a>
</td>
</tr>
+ <? $i++ ?>
<? endforeach ?>
</table>
</div>
<? if ($running_tasks->count()): ?>
<div id="gRunningTasks">
- <h2> <?= t("Running Tasks") ?> </h2>
<a href="<?= url::site("admin/maintenance/cancel_running_tasks?csrf=$csrf") ?>"
class="gButtonLink ui-icon-left ui-state-default ui-corner-all right">
<?= t("cancel all") ?></a>
+ <h2> <?= t("Running Tasks") ?> </h2>
<table>
<tr>
<th>
@@ -66,8 +68,9 @@
<?= t("Action") ?>
</th>
</tr>
+ <? $i = 0; ?>
<? foreach ($running_tasks as $task): ?>
- <tr class="<?= $task->state == "stalled" ? "gWarning" : "" ?>">
+ <tr class="<?= $task->state == "stalled" ? "gWarning" : "" ?> <?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?>">
<td>
<?= gallery::date_time($task->updated) ?>
</td>
@@ -105,6 +108,7 @@
</a>
</td>
</tr>
+ <? $i++ ?>
<? endforeach ?>
</table>
</div>
@@ -138,8 +142,9 @@
<?= t("Action") ?>
</th>
</tr>
+ <? $i = 0; ?>
<? foreach ($finished_tasks as $task): ?>
- <tr class="<?= $task->state == "success" ? "gSuccess" : "gError" ?>">
+ <tr class="<?= $task->state == "success" ? "gSuccess" : "gError" ?> <?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?>">
<td>
<?= gallery::date_time($task->updated) ?>
</td>
@@ -183,6 +188,7 @@
</td>
</tr>
<? endforeach ?>
+ <? $i++ ?>
</table>
</div>
<? endif ?>
diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php
index 3fddd6cd..168e20d0 100644
--- a/modules/gallery/views/admin_modules.html.php
+++ b/modules/gallery/views/admin_modules.html.php
@@ -16,7 +16,7 @@
</tr>
<? $i = 0 ?>
<? foreach ($available as $module_name => $module_info): ?>
- <tr class="<?= ($i % 2 == 0) ? "gEvenRow" : "gOddRow" ?>">
+ <tr class="<?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?>">
<? $data = array("name" => $module_name); ?>
<? if ($module_info->locked) $data["disabled"] = 1; ?>
<td> <?= form::checkbox($data, '1', module::is_active($module_name)) ?> </td>
diff --git a/modules/gallery/views/after_install.html.php b/modules/gallery/views/after_install.html.php
index 2cf8ec8f..b77a1707 100644
--- a/modules/gallery/views/after_install.html.php
+++ b/modules/gallery/views/after_install.html.php
@@ -16,7 +16,7 @@
title="<?= t("Edit Your Profile") ?>"
id="gAfterInstallChangePasswordLink" class="gButtonLink ui-state-default ui-corners-all"><?= t("Change Password Now") ?></a>
<script>
- $("#gAfterInstallChangePasswordLink").bind("click", handleDialogEvent);
+ $("#gAfterInstallChangePasswordLink").gallery_dialog();
</script>
</p>
diff --git a/modules/gallery/views/after_install_loader.html.php b/modules/gallery/views/after_install_loader.html.php
index baf91eed..54484963 100644
--- a/modules/gallery/views/after_install_loader.html.php
+++ b/modules/gallery/views/after_install_loader.html.php
@@ -3,5 +3,5 @@
title="<?= t("Welcome to Gallery 3") ?>"
href="<?= url::site("after_install") ?>"/>
<script type="text/javascript">
- $(document).ready(function(){openDialog($("#gAfterInstall"));});
+ $(document).ready(function(){$("#gAfterInstall").gallery_dialog({immediate: true});});
</script>
diff --git a/modules/gallery/views/l10n_client.html.php b/modules/gallery/views/l10n_client.html.php
index 523552c3..520fd79e 100644
--- a/modules/gallery/views/l10n_client.html.php
+++ b/modules/gallery/views/l10n_client.html.php
@@ -1,7 +1,10 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="l10n-client" class="hidden">
<div class="labels">
- <span id="l10n-client-toggler">X</span>
+ <span id="l10n-client-toggler">
+ <a id="gMinimizeL10n">_</a>
+ <a id="gCloseL10n" href="<?= url::site("l10n_client/toggle_l10n_mode?csrf=".access::csrf_token()) ?>">X</a>
+ </span>
<div class="label strings"><h2><?= t("Page Text") ?>
<? if (!Input::instance()->get('show_all_l10n_messages')): ?>
<a style="background-color:#fff" href="<?= url::site("admin/languages?show_all_l10n_messages=1") ?>"><?= t("(Show All)") ?></a>
diff --git a/modules/gallery/views/permissions_browse.html.php b/modules/gallery/views/permissions_browse.html.php
index 9ea0da25..90970112 100644
--- a/modules/gallery/views/permissions_browse.html.php
+++ b/modules/gallery/views/permissions_browse.html.php
@@ -5,8 +5,9 @@
$.ajax({
url: form_url.replace("__ITEM__", id),
success: function(data) {
- $("div.form").slideUp();
- $("div#edit-" + id).html(data).slideDown();
+ $("#gEditPermissionForm").html(data);
+ $(".active").removeClass("active");
+ $("#item-" + id).addClass("active");
}
});
}
@@ -18,7 +19,7 @@
url: action_url.replace("__CMD__", cmd).replace("__GROUP__", group_id).
replace("__PERM__", perm_id).replace("__ITEM__", item_id),
success: function(data) {
- $("div#edit-" + item_id).load(form_url.replace("__ITEM__", item_id));
+ $("#gEditPermissionForm").load(form_url.replace("__ITEM__", item_id));
}
});
}
@@ -31,26 +32,25 @@
</li>
</ul>
<? endif ?>
- <ul>
+
+ <p><?= t("Edit permissions for album:") ?></p>
+
+ <ul class="gBreadcrumbs">
<? foreach ($parents as $parent): ?>
- <li>
+ <li id="item-<?= $parent->id ?>">
<a href="javascript:show(<?= $parent->id ?>)">
- <?= SafeString::of($parent->title) ?>
+ <?= SafeString::purify($parent->title) ?>
+ </a>
+ </li>
+ <? endforeach ?>
+ <li class="active" id="item-<?= $item->id ?>">
+ <a href="javascript:show(<?= $item->id ?>)">
+ <?= SafeString::purify($item->title) ?>
</a>
- <div class="form" id="edit-<?= $parent->id ?>"></div>
- <ul>
- <? endforeach ?>
- <li>
- <a href="javascript:show(<?= $item->id ?>)">
- <?= SafeString::purify($item->title) ?>
- </a>
- <div class="form" id="edit-<?= $item->id ?>">
- <?= $form ?>
- </div>
- </li>
- <? foreach ($parents as $parent): ?>
- </ul>
</li>
</ul>
- <? endforeach ?>
-</div>
+
+ <div id="gEditPermissionForm">
+ <?= $form ?>
+ </div>
+</div> \ No newline at end of file
diff --git a/modules/gallery/views/quick_pane.html.php b/modules/gallery/views/quick_pane.html.php
deleted file mode 100644
index e5469696..00000000
--- a/modules/gallery/views/quick_pane.html.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.") ?>
-<? foreach ($button_list->main as $button): ?>
-<a class="<?= $button->class ?> ui-corner-all ui-state-default" href="<?= $button->href ?>"
- title="<?= $button->title ?>">
- <span class="ui-icon <?= $button->icon ?>">
- <?= $button->title ?>
- </span>
-</a>
-<? endforeach ?>
-
-<? if (!empty($button_list->additional)): ?>
-<a class="gButtonLink ui-corner-all ui-state-default options" href="#" title="<?= t("additional options") ?>">
- <span class="ui-icon ui-icon-triangle-1-s">
- <?= t("Additional options") ?>
- </span>
-</a>
-
-<ul class="gQuickPaneOptions" style="display: none">
- <? foreach ($button_list->additional as $button): ?>
- <li><a class="<?= $button->class ?>" href="<?= $button->href ?>"
- title="<?= $button->title ?>">
- <?= $button->title ?>
- </a></li>
- <? endforeach ?>
-</ul>
-<? endif ?>
diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php
index fc426e8f..1f185780 100644
--- a/modules/gallery/views/simple_uploader.html.php
+++ b/modules/gallery/views/simple_uploader.html.php
@@ -217,7 +217,7 @@
var fp = new File_Progress(file);
switch (error_code) {
case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
- fp.set_status("error", "<?= t("Upload error: ")->for_js() ?>" + message);
+ fp.set_status("error", "<?= t("Upload error: bad image file")->for_js() ?>");
break;
case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
fp.set_status("error", "<?= t("Upload failed")->for_js() ?>");