diff options
Diffstat (limited to 'modules/gallery')
-rw-r--r-- | modules/gallery/controllers/items.php | 9 | ||||
-rw-r--r-- | modules/gallery/helpers/access.php | 1 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery.php | 15 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_rss.php | 10 | ||||
-rw-r--r-- | modules/gallery/helpers/identity.php | 8 | ||||
-rw-r--r-- | modules/gallery/helpers/locales.php | 1 | ||||
-rw-r--r-- | modules/gallery/helpers/module.php | 12 | ||||
-rw-r--r-- | modules/gallery/libraries/Gallery_I18n.php | 6 | ||||
-rw-r--r-- | modules/gallery/libraries/drivers/IdentityProvider.php | 12 | ||||
-rw-r--r-- | modules/gallery/models/item.php | 2 | ||||
-rw-r--r-- | modules/gallery/tests/controller_auth_data.txt | 1 | ||||
-rw-r--r-- | modules/gallery/tests/xss_data.txt | 90 | ||||
-rw-r--r-- | modules/gallery/views/admin_maintenance.html.php | 15 | ||||
-rw-r--r-- | modules/gallery/views/admin_maintenance_task.html.php | 20 |
15 files changed, 130 insertions, 74 deletions
diff --git a/modules/gallery/controllers/items.php b/modules/gallery/controllers/items.php index f205bf86..39b0f638 100644 --- a/modules/gallery/controllers/items.php +++ b/modules/gallery/controllers/items.php @@ -31,4 +31,13 @@ class Items_Controller extends Controller { access::required("view", $item); url::redirect($item->abs_url()); } + + // Return the width/height dimensinons for the given item + public function dimensions($id) { + $item = ORM::factory("item", $id); + access::required("view", $item); + json::reply(array("thumb" => array((int)$item->thumb_width, (int)$item->thumb_height), + "resize" => array((int)$item->resize_width, (int)$item->resize_height), + "full" => array((int)$item->width, (int)$item->height))); + } } diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index f1ea00c0..86ea9572 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -694,6 +694,7 @@ class access_Core { @mkdir(VARPATH . "security_test"); try { if ($fp = @fopen(VARPATH . "security_test/.htaccess", "w+")) { + fwrite($fp, "Options +FollowSymLinks\n"); fwrite($fp, "RewriteEngine On\n"); fwrite($fp, "RewriteRule verify $success_url [L]\n"); fclose($fp); diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 924ee76a..9430231c 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -45,10 +45,17 @@ class gallery_Core { Router::$controller != "combined" && identity::active_user()->guest && !access::user_can(identity::guest(), "view", item::root())) { - Session::instance()->set("continue_url", url::abs_current()); - Router::$controller = "login"; - Router::$controller_path = MODPATH . "gallery/controllers/login.php"; - Router::$method = "html"; + if (Router::$controller == "admin") { + // At this point we're in the admin theme and it doesn't have a themed login page, so + // we can't just swap in the login controller and have it work. So redirect back to the + // root item where we'll run this code again with the site theme. + url::redirect(item::root()->abs_url()); + } else { + Session::instance()->set("continue_url", url::abs_current()); + Router::$controller = "login"; + Router::$controller_path = MODPATH . "gallery/controllers/login.php"; + Router::$method = "html"; + } } } diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index ec7d1882..0ba98025 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -210,7 +210,7 @@ class gallery_event_Core { ->label($user->display_name())); if (Router::$controller == "admin") { - $continue_url = url::site(""); + $continue_url = url::abs_site(""); } else if (isset($theme->item)) { if (access::user_can(identity::guest(), "view", $theme->item)) { $continue_url = $theme->item->abs_url(); diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php index bec34912..fb617934 100644 --- a/modules/gallery/helpers/gallery_rss.php +++ b/modules/gallery/helpers/gallery_rss.php @@ -40,7 +40,7 @@ class gallery_rss_Core { ->order_by("created", "DESC"); $feed->max_pages = ceil($all_items->find_all()->count() / $limit); - $feed->title = t("Recent updates"); + $feed->title = t("%site_title - Recent updates", array("site_title" => item::root()->title)); $feed->description = t("Recent updates"); return $feed; @@ -53,7 +53,13 @@ class gallery_rss_Core { ->descendants($limit, $offset, array(array("type", "=", "photo"))); $feed->max_pages = ceil( $item->viewable()->descendants_count(array(array("type", "=", "photo"))) / $limit); - $feed->title = html::purify($item->title); + if ($item->id == item::root()->id) { + $feed->title = html::purify($item->title); + } else { + $feed->title = t("%site_title - %item_title", + array("site_title" => item::root()->title, + "item_title" => $item->title)); + } $feed->description = nl2br(html::purify($item->description)); return $feed; diff --git a/modules/gallery/helpers/identity.php b/modules/gallery/helpers/identity.php index 5de05948..5ca024e9 100644 --- a/modules/gallery/helpers/identity.php +++ b/modules/gallery/helpers/identity.php @@ -233,14 +233,14 @@ class identity_Core { /** * @see IdentityProvider_Driver::add_user_to_group. */ - static function add_user_to_group($user, $group_id) { - return IdentityProvider::instance()->add_user_to_group($user, $group_id); + static function add_user_to_group($user, $group) { + return IdentityProvider::instance()->add_user_to_group($user, $group); } /** * @see IdentityProvider_Driver::remove_user_to_group. */ - static function remove_user_from_group($user, $group_id) { - return IdentityProvider::instance()->remove_user_from_group($user, $group_id); + static function remove_user_from_group($user, $group) { + return IdentityProvider::instance()->remove_user_from_group($user, $group); } }
\ No newline at end of file diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php index aacb37ca..1f5473ff 100644 --- a/modules/gallery/helpers/locales.php +++ b/modules/gallery/helpers/locales.php @@ -103,6 +103,7 @@ class locales_Core { $l["sl_SI"] = "Slovenščina"; // Slovenian $l["sr_CS"] = "Srpski"; // Serbian $l["sv_SE"] = "Svenska"; // Swedish + $l["tn_ZA"] = "Setswana"; // Setswana $l["tr_TR"] = "Türkçe"; // Turkish $l["uk_UA"] = "українська"; // Ukrainian $l["vi_VN"] = "Tiếng Việt"; // Vietnamese diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index ca6651f1..736b6854 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -448,7 +448,17 @@ class module_Core { $cache->module_name = "gallery"; $cache->name = "_cache"; $cache->value = serialize(self::$var_cache); - $cache->save(); + try { + $cache->save(); + } catch (Database_Exception $e) { + // There's a potential race condition here. Don't fail if that happens because it's + // bound to be transient and not a huge deal, but at least put something in the logs. + if (stristr($e->getMessage(), "duplicate entry")) { + Kohana_Log::add("error", "Failed to cache vars"); + } else { + throw $e; + } + } } } diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php index f8068eec..6cb36f07 100644 --- a/modules/gallery/libraries/Gallery_I18n.php +++ b/modules/gallery/libraries/Gallery_I18n.php @@ -44,7 +44,7 @@ function t($message, $options=array()) { */ function t2($singular, $plural, $count, $options=array()) { return Gallery_I18n::instance()->translate(array("one" => $singular, "other" => $plural), - array_merge($options, array("count" => $count))); + array_merge($options, array("count" => $count))); } class Gallery_I18n_Core { @@ -175,7 +175,7 @@ class Gallery_I18n_Core { ->execute() as $row) { $translations[$row->key] = unserialize($row->translation); } - + // Override incoming with outgoing... foreach (db::build() ->select("key", "translation") @@ -184,7 +184,7 @@ class Gallery_I18n_Core { ->execute() as $row) { $translations[$row->key] = unserialize($row->translation); } - + $cache->set($cache_key, $translations, array("translation"), 0); } return $translations; diff --git a/modules/gallery/libraries/drivers/IdentityProvider.php b/modules/gallery/libraries/drivers/IdentityProvider.php index 3e85a57b..ac2473f5 100644 --- a/modules/gallery/libraries/drivers/IdentityProvider.php +++ b/modules/gallery/libraries/drivers/IdentityProvider.php @@ -116,17 +116,17 @@ interface IdentityProvider_Driver { /** * Add the user to the specified group - * @param User_Definition the user to add to the group - * @param int the group_id + * @param User_Definition the user to add + * @param Group_Definition the target group */ - static function add_user_to_group($user, $group_id); + public function add_user_to_group($user, $group); /** * Remove the user to the specified group - * @param User_Definition the user to add to the group - * @param int the group id + * @param User_Definition the user to remove + * @param Group_Definition the owning group */ - static function remove_user_from_group($user, $group_id); + public function remove_user_from_group($user, $group); } // End Identity Driver Definition interface Group_Definition {} diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 1db766e9..34c22021 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -975,6 +975,8 @@ class Item_Model extends ORM_MPTT { } unset($data["album_cover_item_id"]); + $data["web_url"] = $this->abs_url(); + if (access::can("view_full", $this) && !$this->is_album()) { $data["file_url"] = rest::url("data", $this, "full"); } diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt index 8b776fb9..212577c7 100644 --- a/modules/gallery/tests/controller_auth_data.txt +++ b/modules/gallery/tests/controller_auth_data.txt @@ -17,6 +17,7 @@ modules/gallery/controllers/logout.php index modules/gallery/controllers/quick.php form_edit DIRTY_CSRF modules/gallery/controllers/upgrader.php index DIRTY_AUTH modules/gallery/controllers/uploader.php start DIRTY_AUTH +modules/gallery/controllers/uploader.php status DIRTY_AUTH modules/gallery/controllers/uploader.php finish DIRTY_AUTH modules/gallery/controllers/user_profile.php show DIRTY_AUTH modules/gallery/controllers/user_profile.php contact DIRTY_AUTH diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 3eae3d07..4405dad3 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -88,15 +88,15 @@ modules/gallery/views/admin_maintenance.html.php 87 DIRTY_ATTR $tas modules/gallery/views/admin_maintenance.html.php 88 DIRTY gallery::date_time($task->updated) modules/gallery/views/admin_maintenance.html.php 91 DIRTY $task->name modules/gallery/views/admin_maintenance.html.php 106 DIRTY $task->status -modules/gallery/views/admin_maintenance.html.php 157 DIRTY_ATTR text::alternate("g-odd","g-even") -modules/gallery/views/admin_maintenance.html.php 157 DIRTY_ATTR $task->state=="success"?"g-success":"g-error" -modules/gallery/views/admin_maintenance.html.php 158 DIRTY_ATTR $task->state=="success"?"g-success":"g-error" -modules/gallery/views/admin_maintenance.html.php 159 DIRTY gallery::date_time($task->updated) -modules/gallery/views/admin_maintenance.html.php 162 DIRTY $task->name -modules/gallery/views/admin_maintenance.html.php 174 DIRTY $task->status +modules/gallery/views/admin_maintenance.html.php 162 DIRTY_ATTR text::alternate("g-odd","g-even") +modules/gallery/views/admin_maintenance.html.php 162 DIRTY_ATTR $task->state=="success"?"g-success":"g-error" +modules/gallery/views/admin_maintenance.html.php 163 DIRTY_ATTR $task->state=="success"?"g-success":"g-error" +modules/gallery/views/admin_maintenance.html.php 164 DIRTY gallery::date_time($task->updated) +modules/gallery/views/admin_maintenance.html.php 167 DIRTY $task->name +modules/gallery/views/admin_maintenance.html.php 179 DIRTY $task->status modules/gallery/views/admin_maintenance_show_log.html.php 8 DIRTY_JS url::site("admin/maintenance/save_log/$task->id?csrf=$csrf") modules/gallery/views/admin_maintenance_show_log.html.php 13 DIRTY $task->name -modules/gallery/views/admin_maintenance_task.html.php 55 DIRTY $task->name +modules/gallery/views/admin_maintenance_task.html.php 75 DIRTY $task->name modules/gallery/views/admin_modules.html.php 51 DIRTY access::csrf_form_field() modules/gallery/views/admin_modules.html.php 60 DIRTY_ATTR text::alternate("g-odd","g-even") modules/gallery/views/admin_modules.html.php 63 DIRTY form::checkbox($data,'1',module::is_active($module_name)) @@ -109,7 +109,7 @@ modules/gallery/views/admin_sidebar.html.php 50 DIRTY $avail modules/gallery/views/admin_sidebar.html.php 58 DIRTY $active modules/gallery/views/admin_sidebar_blocks.html.php 4 DIRTY_ATTR $ref modules/gallery/views/admin_sidebar_blocks.html.php 4 DIRTY $text -modules/gallery/views/admin_theme_options.html.php 36 DIRTY $form +modules/gallery/views/admin_theme_options.html.php 5 DIRTY $form modules/gallery/views/admin_themes.html.php 3 DIRTY_JS url::site("admin/themes/choose") modules/gallery/views/admin_themes.html.php 5 DIRTY_JS $csrf modules/gallery/views/admin_themes.html.php 22 DIRTY $themes[$site]->name @@ -168,10 +168,13 @@ modules/gallery/views/error_admin.html.php 284 DIRTY $var modules/gallery/views/error_admin.html.php 285 DIRTY_ATTR $env_id modules/gallery/views/error_admin.html.php 291 DIRTY $key modules/gallery/views/error_admin.html.php 295 DIRTY Kohana_Exception::safe_dump($value,$key) -modules/gallery/views/form_uploadify.html.php 9 DIRTY_JS url::file("lib/uploadify/uploadify.swf") -modules/gallery/views/form_uploadify.html.php 10 DIRTY_JS url::site("uploader/add_photo/{$album->id}") -modules/gallery/views/form_uploadify.html.php 14 DIRTY_JS url::file("lib/uploadify/cancel.png") -modules/gallery/views/form_uploadify.html.php 15 DIRTY_JS $simultaneous_upload_limit +modules/gallery/views/form_uploadify.html.php 16 DIRTY_JS url::site("uploader/status/_S/_E") +modules/gallery/views/form_uploadify.html.php 24 DIRTY_JS $flash_minimum_version +modules/gallery/views/form_uploadify.html.php 28 DIRTY_JS url::file("lib/uploadify/uploadify.swf") +modules/gallery/views/form_uploadify.html.php 29 DIRTY_JS url::site("uploader/add_photo/{$album->id}") +modules/gallery/views/form_uploadify.html.php 33 DIRTY_JS url::file("lib/uploadify/cancel.png") +modules/gallery/views/form_uploadify.html.php 34 DIRTY_JS $simultaneous_upload_limit +modules/gallery/views/form_uploadify.html.php 160 DIRTY_ATTR request::protocol() modules/gallery/views/in_place_edit.html.php 2 DIRTY form::open($action,array("method"=>"post","id"=>"g-in-place-edit-form","class"=>"g-short-form")) modules/gallery/views/in_place_edit.html.php 3 DIRTY access::csrf_form_field() modules/gallery/views/in_place_edit.html.php 6 DIRTY form::input("input",$form["input"]," class=\"textbox\"") @@ -207,17 +210,6 @@ modules/gallery/views/menu_dialog.html.php 5 DIRTY_JS $menu- modules/gallery/views/menu_link.html.php 3 DIRTY $menu->css_id?"id='{$menu->css_id}'":"" modules/gallery/views/menu_link.html.php 4 DIRTY_ATTR $menu->css_class modules/gallery/views/menu_link.html.php 5 DIRTY_JS $menu->url -modules/gallery/views/move_browse.html.php 5 DIRTY_JS url::site("move/show_sub_tree/{$source->id}/__TARGETID__") -modules/gallery/views/move_browse.html.php 40 DIRTY $tree -modules/gallery/views/move_browse.html.php 44 DIRTY access::csrf_form_field() -modules/gallery/views/move_tree.html.php 2 DIRTY $parent->thumb_img(array(),25); -modules/gallery/views/move_tree.html.php 4 DIRTY_JS $parent->id -modules/gallery/views/move_tree.html.php 6 DIRTY_JS $parent->id -modules/gallery/views/move_tree.html.php 8 DIRTY_ATTR $parent->id -modules/gallery/views/move_tree.html.php 10 DIRTY_ATTR $child->id -modules/gallery/views/move_tree.html.php 11 DIRTY $child->thumb_img(array(),25); -modules/gallery/views/move_tree.html.php 13 DIRTY_JS $child->id -modules/gallery/views/move_tree.html.php 15 DIRTY_JS $child->id modules/gallery/views/movieplayer.html.php 2 DIRTY html::anchor($item->file_url(true),"",$attrs) modules/gallery/views/movieplayer.html.php 5 DIRTY_JS $attrs["id"] modules/gallery/views/movieplayer.html.php 7 DIRTY_JS url::abs_file("lib/flowplayer.swf") @@ -281,18 +273,19 @@ modules/notification/views/item_updated.html.php 20 DIRTY_JS $item- modules/notification/views/item_updated.html.php 20 DIRTY $item->abs_url() modules/notification/views/user_profile_notification.html.php 5 DIRTY_ATTR $subscription->id modules/notification/views/user_profile_notification.html.php 6 DIRTY_JS $subscription->url -modules/organize/views/organize_dialog.html.php 90 DIRTY_JS $domain -modules/organize/views/organize_dialog.html.php 91 DIRTY_JS $access_key -modules/organize/views/organize_dialog.html.php 92 DIRTY_JS request::protocol() -modules/organize/views/organize_dialog.html.php 93 DIRTY_JS $file_filter -modules/organize/views/organize_dialog.html.php 94 DIRTY_JS $sort_order -modules/organize/views/organize_dialog.html.php 95 DIRTY_JS $sort_fields -modules/organize/views/organize_dialog.html.php 96 DIRTY_JS $album->id -modules/organize/views/organize_dialog.html.php 97 DIRTY_JS $rest_uri -modules/organize/views/organize_dialog.html.php 98 DIRTY_JS $controller_uri -modules/organize/views/organize_dialog.html.php 104 DIRTY_JS $flash_minimum_version="10.0.0" -modules/organize/views/organize_dialog.html.php 122 DIRTY_JS $swf_uri -modules/organize/views/organize_dialog.html.php 136 DIRTY_ATTR request::protocol() +modules/organize/views/organize_dialog.html.php 86 DIRTY_JS $domain +modules/organize/views/organize_dialog.html.php 87 DIRTY_JS $access_key +modules/organize/views/organize_dialog.html.php 88 DIRTY_JS request::protocol() +modules/organize/views/organize_dialog.html.php 89 DIRTY_JS $file_filter +modules/organize/views/organize_dialog.html.php 90 DIRTY_JS $sort_order +modules/organize/views/organize_dialog.html.php 91 DIRTY_JS $sort_fields +modules/organize/views/organize_dialog.html.php 92 DIRTY_JS $album->id +modules/organize/views/organize_dialog.html.php 93 DIRTY_JS $selected_id +modules/organize/views/organize_dialog.html.php 94 DIRTY_JS $rest_uri +modules/organize/views/organize_dialog.html.php 95 DIRTY_JS $controller_uri +modules/organize/views/organize_dialog.html.php 101 DIRTY_JS $flash_minimum_version="10.0.0" +modules/organize/views/organize_dialog.html.php 119 DIRTY_JS $swf_uri +modules/organize/views/organize_dialog.html.php 132 DIRTY_ATTR request::protocol() modules/recaptcha/views/admin_recaptcha.html.php 11 DIRTY $form modules/recaptcha/views/admin_recaptcha.html.php 23 DIRTY_JS $public_key modules/recaptcha/views/form_recaptcha.html.php 7 DIRTY_JS $public_key @@ -385,10 +378,10 @@ themes/admin_wind/views/pager.html.php 37 DIRTY_JS str_re themes/wind/views/album.html.php 16 DIRTY_ATTR $child->id themes/wind/views/album.html.php 16 DIRTY_ATTR $item_class themes/wind/views/album.html.php 18 DIRTY_JS $child->url() -themes/wind/views/album.html.php 19 DIRTY $child->thumb_img(array("class"=>"g-thumbnail")) -themes/wind/views/album.html.php 23 DIRTY_ATTR $item_class -themes/wind/views/album.html.php 24 DIRTY_JS $child->url() -themes/wind/views/album.html.php 42 DIRTY $theme->paginator() +themes/wind/views/album.html.php 20 DIRTY $child->thumb_img(array("class"=>"g-thumbnail")) +themes/wind/views/album.html.php 25 DIRTY_ATTR $item_class +themes/wind/views/album.html.php 26 DIRTY_JS $child->url() +themes/wind/views/album.html.php 44 DIRTY $theme->paginator() themes/wind/views/block.html.php 3 DIRTY_ATTR $anchor themes/wind/views/block.html.php 5 DIRTY_ATTR $css_id themes/wind/views/block.html.php 6 DIRTY $title @@ -410,16 +403,17 @@ themes/wind/views/page.html.php 44 DIRTY $thumb themes/wind/views/page.html.php 81 DIRTY $header_text themes/wind/views/page.html.php 83 DIRTY_JS item::root()->url() themes/wind/views/page.html.php 87 DIRTY $theme->user_menu() -themes/wind/views/page.html.php 108 DIRTY_JS $parent->url($parent==$theme->item()->parent()?"show={$theme->item()->id}":null) -themes/wind/views/page.html.php 126 DIRTY $content -themes/wind/views/page.html.php 132 DIRTY newView("sidebar.html") -themes/wind/views/page.html.php 139 DIRTY $footer_text +themes/wind/views/page.html.php 108 DIRTY_JS $parent->url($parent->id==$theme->item()->parent_id?"show={$theme->item()->id}":null) +themes/wind/views/page.html.php 129 DIRTY $content +themes/wind/views/page.html.php 135 DIRTY newView("sidebar.html") +themes/wind/views/page.html.php 142 DIRTY $footer_text themes/wind/views/paginator.html.php 33 DIRTY_JS $first_page_url themes/wind/views/paginator.html.php 42 DIRTY_JS $previous_page_url themes/wind/views/paginator.html.php 70 DIRTY_JS $next_page_url themes/wind/views/paginator.html.php 79 DIRTY_JS $last_page_url -themes/wind/views/photo.html.php 8 DIRTY_JS $theme->item()->width -themes/wind/views/photo.html.php 8 DIRTY_JS $theme->item()->height -themes/wind/views/photo.html.php 18 DIRTY $theme->paginator() -themes/wind/views/photo.html.php 23 DIRTY_JS $item->file_url() -themes/wind/views/photo.html.php 25 DIRTY $item->resize_img(array("id"=>"g-item-id-{$item->id}","class"=>"g-resize")) +themes/wind/views/photo.html.php 7 DIRTY_JS $theme->item()->width +themes/wind/views/photo.html.php 7 DIRTY_JS $theme->item()->height +themes/wind/views/photo.html.php 17 DIRTY_JS url::site("items/dimensions/".$theme->item()->id) +themes/wind/views/photo.html.php 31 DIRTY $theme->paginator() +themes/wind/views/photo.html.php 36 DIRTY_JS $item->file_url() +themes/wind/views/photo.html.php 38 DIRTY $item->resize_img(array("id"=>"g-item-id-{$item->id}","class"=>"g-resize")) diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index 4bfc57f0..c28def1d 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -109,16 +109,21 @@ <?= html::clean($task->owner()->name) ?> </td> <td> - <a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>" - class="g-button g-right ui-icon-left ui-state-default ui-corner-all"> - <?= t("cancel") ?> - </a> <? if ($task->state == "stalled"): ?> <a class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all" href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>"> <?= t("resume") ?> </a> <? endif ?> + <? if ($task->get_log()): ?> + <a href="<?= url::site("admin/maintenance/show_log/$task->id?csrf=$csrf") ?>" class="g-dialog-link g-button ui-state-default ui-corner-all"> + <?= t("view log") ?> + </a> + <? endif ?> + <a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>" + class="g-button ui-icon-left ui-state-default ui-corner-all"> + <?= t("cancel") ?> + </a> </td> </tr> <? endforeach ?> @@ -183,7 +188,7 @@ </a> <? if ($task->get_log()): ?> <a href="<?= url::site("admin/maintenance/show_log/$task->id?csrf=$csrf") ?>" class="g-dialog-link g-button ui-state-default ui-corner-all"> - <?= t("browse log") ?> + <?= t("view log") ?> </a> <? endif ?> <? else: ?> diff --git a/modules/gallery/views/admin_maintenance_task.html.php b/modules/gallery/views/admin_maintenance_task.html.php index 76756b66..013ac01f 100644 --- a/modules/gallery/views/admin_maintenance_task.html.php +++ b/modules/gallery/views/admin_maintenance_task.html.php @@ -3,6 +3,7 @@ var target_value; var animation = null; var delta = 1; + var consecutive_error_count = 0; animate_progress_bar = function() { var current_value = parseInt($(".g-progress-bar div").css("width").replace("%", "")); if (target_value > current_value) { @@ -26,12 +27,15 @@ $.fn.gallery_hover_init(); } + var FAILED_MSG = <?= t("Something went wrong...sorry! <a>Retry</a> or check the task log for details")->for_js() ?>; + var ERROR_MSG = <?= t("Something went wrong! Trying again in a moment... (__COUNT__)")->for_js() ?>; update = function() { $.ajax({ url: <?= html::js_string(url::site("admin/maintenance/run/$task->id?csrf=$csrf")) ?>, dataType: "json", success: function(data) { target_value = data.task.percent_complete; + consecutive_error_count = 0; if (!animation) { animate_progress_bar(); } @@ -42,6 +46,22 @@ } else { setTimeout(update, 100); } + }, + error: function(req, textStatus, errorThrown) { + if (textStatus == "timeout" || textStatus == "parsererror") { + consecutive_error_count++; + if (consecutive_error_count == 5) { + $("#g-status").html(FAILED_MSG); + $("#g-pause-button").hide(); + $("#g-done-button").show(); + consecutive_error_count = 0; // in case of a manual retry + $("#g-status a").attr("href", "javascript:update()"); + } else { + $("#g-status").html(ERROR_MSG.replace("__COUNT__", consecutive_error_count)); + // Give a little time to back off before retrying + setTimeout(update, 1500 * consecutive_error_count); + } + } } }); } |