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.php8
-rw-r--r--modules/gallery/controllers/albums.php27
-rw-r--r--modules/gallery/controllers/combined.php5
-rw-r--r--modules/gallery/controllers/file_proxy.php43
-rw-r--r--modules/gallery/controllers/movies.php14
-rw-r--r--modules/gallery/controllers/packager.php8
-rw-r--r--modules/gallery/controllers/photos.php16
-rw-r--r--modules/gallery/controllers/quick.php15
-rw-r--r--modules/gallery/controllers/simple_uploader.php26
-rw-r--r--modules/gallery/css/quick.css40
-rw-r--r--modules/gallery/helpers/MY_remote.php27
-rw-r--r--modules/gallery/helpers/access.php108
-rw-r--r--modules/gallery/helpers/album.php12
-rw-r--r--modules/gallery/helpers/gallery.php234
-rw-r--r--modules/gallery/helpers/gallery_event.php14
-rw-r--r--modules/gallery/helpers/gallery_installer.php84
-rw-r--r--modules/gallery/helpers/gallery_menu.php163
-rw-r--r--modules/gallery/helpers/gallery_quick.php144
-rw-r--r--modules/gallery/helpers/gallery_rss.php5
-rw-r--r--modules/gallery/helpers/gallery_search.php24
-rw-r--r--modules/gallery/helpers/gallery_task.php227
-rw-r--r--modules/gallery/helpers/gallery_theme.php63
-rw-r--r--modules/gallery/helpers/graphics.php105
-rw-r--r--modules/gallery/helpers/item.php20
-rw-r--r--modules/gallery/helpers/l10n_client.php13
-rw-r--r--modules/gallery/helpers/locales.php (renamed from modules/gallery/helpers/locale.php)2
-rw-r--r--modules/gallery/helpers/model_cache.php6
-rw-r--r--modules/gallery/helpers/module.php8
-rw-r--r--modules/gallery/helpers/movie.php6
-rw-r--r--modules/gallery/helpers/photo.php8
-rw-r--r--modules/gallery/helpers/task.php3
-rw-r--r--modules/gallery/js/quick.js90
-rw-r--r--modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php2
-rw-r--r--modules/gallery/lib/HTMLPurifier/HTMLPurifier.php6
-rw-r--r--modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php2
-rw-r--r--modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php2
-rw-r--r--modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php2
-rw-r--r--modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php4
-rw-r--r--modules/gallery/libraries/Admin_View.php17
-rw-r--r--modules/gallery/libraries/Form_Script.php66
-rw-r--r--modules/gallery/libraries/Gallery_View.php74
-rw-r--r--modules/gallery/libraries/HtmlPurifier.php5
-rw-r--r--modules/gallery/libraries/I18n.php9
-rw-r--r--modules/gallery/libraries/MY_ORM.php29
-rw-r--r--modules/gallery/libraries/MY_View.php10
-rw-r--r--modules/gallery/libraries/Menu.php47
-rw-r--r--modules/gallery/libraries/ORM_MPTT.php142
-rw-r--r--modules/gallery/libraries/Theme_View.php64
-rw-r--r--modules/gallery/models/item.php70
-rw-r--r--modules/gallery/module.info6
-rw-r--r--modules/gallery/tests/Access_Helper_Test.php73
-rw-r--r--modules/gallery/tests/Database_Test.php8
-rw-r--r--modules/gallery/tests/DrawForm_Test.php39
-rw-r--r--modules/gallery/tests/File_Structure_Test.php37
-rw-r--r--modules/gallery/tests/Gallery_Installer_Test.php10
-rw-r--r--modules/gallery/tests/Item_Model_Test.php10
-rw-r--r--modules/gallery/tests/ORM_MPTT_Test.php22
-rw-r--r--modules/gallery/tests/Photo_Helper_Test.php4
-rw-r--r--modules/gallery/tests/Xss_Security_Test.php2
-rw-r--r--modules/gallery/tests/xss_data.txt209
-rw-r--r--modules/gallery/views/admin_block_platform.html.php5
-rw-r--r--modules/gallery/views/admin_block_stats.html.php2
-rw-r--r--modules/gallery/views/admin_graphics.html.php14
-rw-r--r--modules/gallery/views/admin_graphics_gd.html.php15
-rw-r--r--modules/gallery/views/admin_graphics_graphicsmagick.html.php10
-rw-r--r--modules/gallery/views/admin_graphics_imagemagick.html.php12
-rw-r--r--modules/gallery/views/admin_graphics_none.html.php2
-rw-r--r--modules/gallery/views/admin_maintenance.html.php19
-rw-r--r--modules/gallery/views/admin_maintenance_task.html.php32
-rw-r--r--modules/gallery/views/after_install.html.php4
-rw-r--r--modules/gallery/views/after_install_loader.html.php2
-rw-r--r--modules/gallery/views/form.html.php2
-rw-r--r--modules/gallery/views/l10n_client.html.php2
-rw-r--r--modules/gallery/views/movieplayer.html.php25
-rw-r--r--modules/gallery/views/permissions_form.html.php2
-rw-r--r--modules/gallery/views/quick_pane.html.php26
-rw-r--r--modules/gallery/views/simple_uploader.html.php22
78 files changed, 1521 insertions, 1253 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 4639de89..ae90ad07 100644
--- a/modules/gallery/controllers/admin_languages.php
+++ b/modules/gallery/controllers/admin_languages.php
@@ -36,7 +36,7 @@ class Admin_Languages_Controller extends Admin_Controller {
$form = $this->_languages_form();
if ($form->validate()) {
module::set_var("gallery", "default_locale", $form->choose_language->locale->value);
- locale::update_installed($form->choose_language->installed_locales->value);
+ locales::update_installed($form->choose_language->installed_locales->value);
message::success(t("Settings saved"));
}
url::redirect("admin/languages");
@@ -89,8 +89,8 @@ class Admin_Languages_Controller extends Admin_Controller {
}
private function _languages_form() {
- $all_locales = locale::available();
- $installed_locales = locale::installed();
+ $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"));
@@ -119,7 +119,7 @@ class Admin_Languages_Controller extends Admin_Controller {
private function _share_translations_form() {
$form = new Forge("admin/languages/share", "", "post", array("id" => "gShareTranslationsForm"));
$group = $form->group("sharing")
- ->label(t("Sharing you own translations with the Gallery community is easy. Please do!"));
+ ->label(t("Sharing your own translations with the Gallery community is easy. Please do!"));
$api_key = l10n_client::api_key();
$server_link = l10n_client::server_api_key_url();
$group->input("api_key")
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index d141d157..cdfa823d 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -122,7 +122,7 @@ class Albums_Controller extends Items_Controller {
print json_encode(
array(
"result" => "error",
- "form" => $form->__toString() . html::script("modules/gallery/js/albums_form_add.js")));
+ "form" => $form->__toString()));
}
}
@@ -174,29 +174,23 @@ class Albums_Controller extends Items_Controller {
->from("items")
->where("parent_id", $album->parent_id)
->where("id <>", $album->id)
- ->where("name", $form->edit_album->dirname->value)
+ ->where("name", $form->edit_item->dirname->value)
->count_records()) {
- $form->edit_album->dirname->add_error("conflict", 1);
+ $form->edit_item->dirname->add_error("conflict", 1);
$valid = false;
}
}
- // @todo
- // @todo we need to make sure that filename / dirname components can't contain a /
- // @todo
-
if ($valid) {
- $orig = clone $album;
- $album->title = $form->edit_album->title->value;
- $album->description = $form->edit_album->description->value;
- $album->sort_column = $form->edit_album->sort_order->column->value;
- $album->sort_order = $form->edit_album->sort_order->direction->value;
+ $album->title = $form->edit_item->title->value;
+ $album->description = $form->edit_item->description->value;
+ $album->sort_column = $form->edit_item->sort_order->column->value;
+ $album->sort_order = $form->edit_item->sort_order->direction->value;
if ($album->id != 1) {
- $album->rename($form->edit_album->dirname->value);
+ $album->rename($form->edit_item->dirname->value);
}
$album->save();
-
- module::event("item_updated", $orig, $album);
+ module::event("item_edit_form_completed", $album, $form);
log::success("content", "Updated album", "<a href=\"albums/$album->id\">view</a>");
message::success(
@@ -222,8 +216,7 @@ class Albums_Controller extends Items_Controller {
switch ($this->input->get("type")) {
case "album":
- print album::get_add_form($album) .
- html::script("modules/gallery/js/albums_form_add.js");
+ print album::get_add_form($album);
break;
case "photo":
diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php
index 925d052d..9a790fdf 100644
--- a/modules/gallery/controllers/combined.php
+++ b/modules/gallery/controllers/combined.php
@@ -60,14 +60,15 @@ class Combined_Controller extends Controller {
$cache = Cache::instance();
$use_gzip = function_exists("gzencode") &&
- (strpos($input->server("HTTP_ACCEPT_ENCODING"), "gzip") !== false);
+ stripos($input->server("HTTP_ACCEPT_ENCODING"), "gzip") !== false &&
+ (int) ini_get("zlib.output_compression") === 0;
+
if ($use_gzip && $content = $cache->get("{$key}_gz")) {
header("Content-Encoding: gzip");
} else {
// Fall back to non-gzipped if we have to
$content = $cache->get($key);
}
-
if (empty($content)) {
Kohana::show_404();
}
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index 0d64bcd9..8cb90c50 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -32,8 +32,9 @@ class File_Proxy_Controller extends Controller {
$request_uri = $this->input->server("REQUEST_URI");
$request_uri = preg_replace("/\?.*/", "", $request_uri);
- // Unescape %7E ("~") and %20 (" ")
- $request_uri = str_replace(array("%7E", "%20"), array("~", " "), $request_uri);
+ // Unescape %7E (~), %20 ( ) and %27 (')
+ // @todo: figure out why we have to do this and unescape everything appropriate
+ $request_uri = str_replace(array("%7E", "%20", "%27"), array("~", " ", "'"), $request_uri);
// var_uri: http://example.com/gallery3/var/
$var_uri = url::file("var/");
@@ -62,21 +63,20 @@ class File_Proxy_Controller extends Controller {
// We now have the relative path to the item. Search for it in the path cache
$item = ORM::factory("item")->where("relative_path_cache", $path)->find();
if (!$item->loaded) {
- // We didn't turn it up. This may mean that the path cache is out of date, so look it up
- // the hard way.
- //
- // Find all items that match the level and name, then iterate over those to find a match.
- // In most cases we'll get it in one. Note that for the level calculation, we just count the
- // size of $paths.
- $paths = explode("/", $path);
- $count = count($paths);
- foreach (ORM::factory("item")
- ->where("name", $paths[$count - 1])
- ->where("level", $count + 1)
- ->find_all() as $match) {
- if ($match->relative_path() == $path) {
- $item = $match;
- break;
+ // We didn't turn it up. It's possible that the relative_path_cache is out of date here.
+ // There was fallback code, but bharat deleted it in 8f1bca74. If it turns out to be
+ // necessary, it's easily resurrected.
+
+ // If we're looking for a .jpg then it's it's possible that we're requesting the thumbnail
+ // for a movie. In that case, the .flv or .mp4 file would have been converted to a .jpg.
+ // So try some alternate types:
+ if (preg_match('/.jpg$/', $path)) {
+ foreach (array("flv", "mp4") as $ext) {
+ $movie_path = preg_replace('/.jpg$/', ".$ext", $path);
+ $item = ORM::factory("item")->where("relative_path_cache", $movie_path)->find();
+ if ($item->loaded) {
+ break;
+ }
}
}
}
@@ -115,8 +115,13 @@ class File_Proxy_Controller extends Controller {
// We don't need to save the session for this request
Session::abort_save();
- // Dump out the image
- header("Content-Type: $item->mime_type");
+ // Dump out the image. If the item is a movie, then its thumbnail will be a JPG.
+ if (in_array($item->mime_type, array("video/x-flv", "video/mp4"))) {
+ header("Content-type: image/jpeg");
+ } else {
+ header("Content-Type: $item->mime_type");
+ }
+
Kohana::close_buffers(false);
$fd = fopen($file, "rb");
fpassthru($fd);
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 30a5d78c..c8227d74 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -77,21 +77,19 @@ class Movies_Controller extends Items_Controller {
->from("items")
->where("parent_id", $photo->parent_id)
->where("id <>", $photo->id)
- ->where("name", $form->edit_photo->filename->value)
+ ->where("name", $form->edit_item->filename->value)
->count_records()) {
- $form->edit_photo->filename->add_error("conflict", 1);
+ $form->edit_item->filename->add_error("conflict", 1);
$valid = false;
}
}
if ($valid) {
- $orig = clone $photo;
- $photo->title = $form->edit_photo->title->value;
- $photo->description = $form->edit_photo->description->value;
- $photo->rename($form->edit_photo->filename->value);
+ $photo->title = $form->edit_item->title->value;
+ $photo->description = $form->edit_item->description->value;
+ $photo->rename($form->edit_item->filename->value);
$photo->save();
-
- module::event("item_updated", $orig, $photo);
+ module::event("item_edit_form_completed", $photo, $form);
log::success("content", "Updated photo", "<a href=\"photos/$photo->id\">view</a>");
message::success(
diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php
index da0a7983..fbb1d07d 100644
--- a/modules/gallery/controllers/packager.php
+++ b/modules/gallery/controllers/packager.php
@@ -98,7 +98,7 @@ class Packager_Controller extends Controller {
print "$sql_file is not writeable";
return;
}
- $command = "mysqldump --compact --add-drop-table -h{$conn['host']} " .
+ $command = "mysqldump --compact --skip-extended-insert --add-drop-table -h{$conn['host']} " .
"-u{$conn['user']} $pass {$conn['database']} > $sql_file";
exec($command, $output, $status);
if ($status) {
@@ -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");
@@ -153,7 +157,7 @@ class Packager_Controller extends Controller {
$paths[] = "VARPATH . \"" . substr($name, strlen(VARPATH)) . "\"";
} else {
// @todo: serialize non-directories
- print "Unknown file: $name";
+ print "IGNORING FILE: $name\n";
return;
}
}
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 6a62e859..8ee24da8 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -63,28 +63,26 @@ class Photos_Controller extends Items_Controller {
$form = photo::get_edit_form($photo);
if ($valid = $form->validate()) {
- if ($form->edit_photo->filename->value != $photo->name) {
+ if ($form->edit_item->filename->value != $photo->name) {
// Make sure that there's not a conflict
if (Database::instance()
->from("items")
->where("parent_id", $photo->parent_id)
->where("id <>", $photo->id)
- ->where("name", $form->edit_photo->filename->value)
+ ->where("name", $form->edit_item->filename->value)
->count_records()) {
- $form->edit_photo->filename->add_error("conflict", 1);
+ $form->edit_item->filename->add_error("conflict", 1);
$valid = false;
}
}
}
if ($valid) {
- $orig = clone $photo;
- $photo->title = $form->edit_photo->title->value;
- $photo->description = $form->edit_photo->description->value;
- $photo->rename($form->edit_photo->filename->value);
+ $photo->title = $form->edit_item->title->value;
+ $photo->description = $form->edit_item->description->value;
+ $photo->rename($form->edit_item->filename->value);
$photo->save();
-
- module::event("item_updated", $orig, $photo);
+ module::event("item_edit_form_completed", $photo, $form);
log::success("content", "Updated photo", "<a href=\"photos/$photo->id\">view</a>");
message::success(
diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php
index 53af2ba6..82176e02 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);
@@ -127,6 +113,7 @@ class Quick_Controller extends Controller {
$msg = t("Deleted photo <b>%title</b>", array("title" => p::purify($item->title)));
}
+ $parent = $item->parent();
$item->delete();
message::success($msg);
diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php
index 713e30af..e7c0bd6f 100644
--- a/modules/gallery/controllers/simple_uploader.php
+++ b/modules/gallery/controllers/simple_uploader.php
@@ -43,7 +43,7 @@ class Simple_Uploader_Controller extends Controller {
$file_validation = new Validation($_FILES);
$file_validation->add_rules(
- "Filedata", "upload::valid", "upload::type[gif,jpg,jpeg,png,flv,mp4]");
+ "Filedata", "upload::valid", "upload::required", "upload::type[gif,jpg,jpeg,png,flv,mp4]");
if ($file_validation->validate()) {
// SimpleUploader.swf does not yet call /start directly, so simulate it here for now.
if (!batch::in_progress()) {
@@ -54,24 +54,32 @@ class Simple_Uploader_Controller extends Controller {
try {
$name = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds
$title = item::convert_filename_to_title($name);
- $path_info = pathinfo($temp_filename);
+ $path_info = @pathinfo($temp_filename);
if (array_key_exists("extension", $path_info) &&
in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) {
- $movie = movie::create($album, $temp_filename, $name, $title);
+ $item = movie::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a movie"),
- html::anchor("movies/$movie->id", t("view movie")));
+ html::anchor("movies/$item->id", t("view movie")));
} else {
- $photo = photo::create($album, $temp_filename, $name, $title);
+ $item = photo::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a photo"),
- html::anchor("photos/$photo->id", t("view photo")));
+ html::anchor("photos/$item->id", t("view photo")));
}
} catch (Exception $e) {
- unlink($temp_filename);
- throw $e;
+ Kohana::log("alert", $e->__toString());
+ if (file_exists($temp_filename)) {
+ unlink($temp_filename);
+ }
+ header("HTTP/1.1 500 Internal Server Error");
+ print "ERROR:" . $e->getMessage();
+ return;
}
unlink($temp_filename);
+ print "FILEID: $item->id";
+ } else {
+ header("HTTP/1.1 400 Bad Request");
+ print "ERROR: Invalid Upload";
}
- print "File Received";
}
public function finish() {
diff --git a/modules/gallery/css/quick.css b/modules/gallery/css/quick.css
deleted file mode 100644
index 02f9953e..00000000
--- a/modules/gallery/css/quick.css
+++ /dev/null
@@ -1,40 +0,0 @@
-.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;
-}
-
-#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/MY_remote.php b/modules/gallery/helpers/MY_remote.php
index 4abf5bf1..af2a05d8 100644
--- a/modules/gallery/helpers/MY_remote.php
+++ b/modules/gallery/helpers/MY_remote.php
@@ -21,11 +21,11 @@ class remote extends remote_Core {
static function post($url, $post_data_array, $extra_headers=array()) {
$post_data_raw = self::_encode_post_data($post_data_array, $extra_headers);
-
+
/* Read the web page into a buffer */
list ($response_status, $response_headers, $response_body) =
self::do_request($url, 'POST', $extra_headers, $post_data_raw);
-
+
return array($response_body, $response_status, $response_headers);
}
@@ -49,22 +49,23 @@ class remote extends remote_Core {
}
$post_data_raw .= urlencode($key) . '=' . urlencode($value);
}
-
+
$extra_headers['Content-Type'] = 'application/x-www-form-urlencoded';
$extra_headers['Content-Length'] = strlen($post_data_raw);
-
+
return $post_data_raw;
}
/**
* A single request, without following redirects
*
- * @todo: Handle redirects? If so, only for GET (i.e. not for POST), and use G2's WebHelper_simple::_parseLocation logic.
+ * @todo: Handle redirects? If so, only for GET (i.e. not for POST), and use G2's
+ * WebHelper_simple::_parseLocation logic.
*/
static function do_request($url, $method='GET', $headers=array(), $body='') {
/* Convert illegal characters */
$url = str_replace(' ', '%20', $url);
-
+
$url_components = self::_parse_url_for_fsockopen($url);
$handle = fsockopen(
$url_components['fsockhost'], $url_components['port'], $errno, $errstr, 5);
@@ -72,12 +73,12 @@ class remote extends remote_Core {
// log "Error $errno: '$errstr' requesting $url";
return array(null, null, null);
}
-
+
$header_lines = array('Host: ' . $url_components['host']);
foreach ($headers as $key => $value) {
$header_lines[] = $key . ': ' . $value;
}
-
+
$success = fwrite($handle, sprintf("%s %s HTTP/1.0\r\n%s\r\n\r\n%s",
$method,
$url_components['uri'],
@@ -89,7 +90,7 @@ class remote extends remote_Core {
return array(null, null, null);
}
fflush($handle);
-
+
/*
* Read the status line. fgets stops after newlines. The first line is the protocol
* version followed by a numeric status code and its associated textual phrase.
@@ -99,7 +100,7 @@ class remote extends remote_Core {
// 'Empty http response code, maybe timeout'
return array(null, null, null);
}
-
+
/* Read the headers */
$response_headers = array();
while (!feof($handle)) {
@@ -107,10 +108,10 @@ class remote extends remote_Core {
if (empty($line)) {
break;
}
-
+
/* Normalize the line endings */
$line = str_replace("\r", '', $line);
-
+
list ($key, $value) = explode(':', $line, 2);
if (isset($response_headers[$key])) {
if (!is_array($response_headers[$key])) {
@@ -121,7 +122,7 @@ class remote extends remote_Core {
$response_headers[$key] = trim($value);
}
}
-
+
/* Read the body */
$response_body = '';
while (!feof($handle)) {
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index c48f0b79..949aea84 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -66,9 +66,10 @@
* the Access_Intent_Model
*/
class access_Core {
- const DENY = 0;
- const ALLOW = 1;
- const UNKNOWN = 2;
+ const DENY = false;
+ const ALLOW = true;
+ const INHERIT = null; // access_intent
+ const UNKNOWN = null; // cache (access_cache, items)
/**
* Does the active user have this permission on this item?
@@ -78,18 +79,30 @@ class access_Core {
* @return boolean
*/
static function can($perm_name, $item) {
+ return self::user_can(user::active(), $perm_name, $item);
+ }
+
+ /**
+ * Does the user have this permission on this item?
+ *
+ * @param User_Model $user
+ * @param string $perm_name
+ * @param Item_Model $item
+ * @return boolean
+ */
+ static function user_can($user, $perm_name, $item) {
if (!$item->loaded) {
return false;
}
- if (user::active()->admin) {
+ if ($user->admin) {
return true;
}
$resource = $perm_name == "view" ?
$item : model_cache::get("access_cache", $item->id, "item_id");
- foreach (user::group_ids() as $id) {
- if ($resource->__get("{$perm_name}_$id") === self::ALLOW) {
+ foreach ($user->groups as $group) {
+ if ($resource->__get("{$perm_name}_{$group->id}") === self::ALLOW) {
return true;
}
}
@@ -129,7 +142,7 @@ class access_Core {
* @param Group_Model $group
* @param string $perm_name
* @param Item_Model $item
- * @return integer access::ALLOW, access::DENY or null for no intent
+ * @return boolean access::ALLOW, access::DENY or access::INHERIT (null) for no intent
*/
static function group_intent($group, $perm_name, $item) {
$intent = model_cache::get("access_intent", $item->id, "item_id");
@@ -153,11 +166,11 @@ class access_Core {
// For view permissions, if any parent is self::DENY, then those parents lock this one.
// Return
$lock = ORM::factory("item")
- ->where("`left` <= $item->left")
- ->where("`right` >= $item->right")
+ ->where("`left_ptr` <= $item->left_ptr")
+ ->where("`right_ptr` >= $item->right_ptr")
->where("items.id <> $item->id")
->join("access_intents", "items.id", "access_intents.item_id")
- ->where("access_intents.view_$group->id", 0)
+ ->where("access_intents.view_$group->id", self::DENY)
->orderby("level", "DESC")
->limit(1)
->find();
@@ -205,6 +218,7 @@ class access_Core {
}
self::_update_htaccess_files($album, $group, $perm_name, $value);
+ model_cache::clear();
}
/**
@@ -240,7 +254,23 @@ class access_Core {
if ($item->id == 1) {
throw new Exception("@todo CANT_RESET_ROOT_PERMISSION");
}
- self::_set($group, $perm_name, $item, null);
+ self::_set($group, $perm_name, $item, self::INHERIT);
+ }
+
+ /**
+ * Recalculate the permissions for a given item and its hierarchy. $item must be an album.
+ */
+ static function recalculate_permissions($item) {
+ foreach (self::_get_all_groups() as $group) {
+ foreach (ORM::factory("permission")->find_all() as $perm) {
+ if ($perm->name == "view") {
+ self::_update_access_view_cache($group, $item);
+ } else {
+ self::_update_access_non_view_cache($group, $perm->name, $item);
+ }
+ }
+ }
+ model_cache::clear();
}
/**
@@ -411,6 +441,7 @@ class access_Core {
$cache_table = $perm_name == "view" ? "items" : "access_caches";
$db->query("ALTER TABLE {{$cache_table}} DROP `$field`");
$db->query("ALTER TABLE {access_intents} DROP `$field`");
+ model_cache::clear();
ORM::factory("access_intent")->clear_cache();
}
@@ -425,9 +456,11 @@ class access_Core {
$db = Database::instance();
$field = "{$perm_name}_{$group->id}";
$cache_table = $perm_name == "view" ? "items" : "access_caches";
- $db->query("ALTER TABLE {{$cache_table}} ADD `$field` SMALLINT NOT NULL DEFAULT 0");
- $db->query("ALTER TABLE {access_intents} ADD `$field` BOOLEAN DEFAULT NULL");
- $db->update("access_intents", array($field => 0), array("item_id" => 1));
+ $not_null = $cache_table == "items" ? "" : "NOT NULL";
+ $db->query("ALTER TABLE {{$cache_table}} ADD `$field` BINARY $not_null DEFAULT FALSE");
+ $db->query("ALTER TABLE {access_intents} ADD `$field` BINARY DEFAULT NULL");
+ $db->update("access_intents", array($field => self::DENY), array("item_id" => 1));
+ model_cache::clear();
ORM::factory("access_intent")->clear_cache();
}
@@ -457,11 +490,11 @@ class access_Core {
// item, then its safe to propagate from here.
if ($access->$field !== self::DENY) {
$tmp_item = ORM::factory("item")
- ->where("left <", $item->left)
- ->where("right >", $item->right)
+ ->where("left_ptr <", $item->left_ptr)
+ ->where("right_ptr >", $item->right_ptr)
->join("access_intents", "access_intents.item_id", "items.id")
->where("access_intents.$field", self::DENY)
- ->orderby("left", "DESC")
+ ->orderby("left_ptr", "DESC")
->limit(1)
->find();
if ($tmp_item->loaded) {
@@ -474,26 +507,26 @@ class access_Core {
// them according the rule above. So mark every permission below this level as UNKNOWN so
// that we can tell which permissions have been changed, and which ones need to be updated.
$db->update("items", array($field => self::UNKNOWN),
- array("left >=" => $item->left, "right <=" => $item->right));
+ array("left_ptr >=" => $item->left_ptr, "right_ptr <=" => $item->right_ptr));
$query = ORM::factory("access_intent")
- ->select(array("access_intents.$field", "items.left", "items.right", "items.id"))
+ ->select(array("access_intents.$field", "items.left_ptr", "items.right_ptr", "items.id"))
->join("items", "items.id", "access_intents.item_id")
- ->where("left >=", $item->left)
- ->where("right <=", $item->right)
+ ->where("left_ptr >=", $item->left_ptr)
+ ->where("right_ptr <=", $item->right_ptr)
->where("type", "album")
- ->where("access_intents.$field IS NOT", null)
+ ->where("access_intents.$field IS NOT", self::INHERIT)
->orderby("level", "DESC")
->find_all();
foreach ($query as $row) {
if ($row->$field == self::ALLOW) {
// Propagate ALLOW for any row that is still UNKNOWN.
$db->update("items", array($field => $row->$field),
- array($field => self::UNKNOWN, "left >=" => $row->left, "right <=" => $row->right));
+ array($field => self::UNKNOWN, "left_ptr >=" => $row->left_ptr, "right_ptr <=" => $row->right_ptr));
} else if ($row->$field == self::DENY) {
// DENY overwrites everything below it
$db->update("items", array($field => $row->$field),
- array("left >=" => $row->left, "right <=" => $row->right));
+ array("left_ptr >=" => $row->left_ptr, "right_ptr <=" => $row->right_ptr));
}
}
@@ -501,7 +534,7 @@ class access_Core {
// DENY parent in the hierarchy to propagate from. So we'll still have a UNKNOWN values in
// the hierarchy, and all of those are safe to change to ALLOW.
$db->update("items", array($field => self::ALLOW),
- array($field => self::UNKNOWN, "left >=" => $item->left, "right <=" => $item->right));
+ array($field => self::UNKNOWN, "left_ptr >=" => $item->left_ptr, "right_ptr <=" => $item->right_ptr));
}
/**
@@ -526,13 +559,13 @@ class access_Core {
//
// @todo To optimize this, we wouldn't need to propagate from the parent, we could just
// propagate from here with the parent's intent.
- if ($access->$field === null) {
+ if ($access->$field === self::INHERIT) {
$tmp_item = ORM::factory("item")
->join("access_intents", "items.id", "access_intents.item_id")
- ->where("left <", $item->left)
- ->where("right >", $item->right)
- ->where("$field IS NOT", null)
- ->orderby("left", "DESC")
+ ->where("left_ptr <", $item->left_ptr)
+ ->where("right_ptr >", $item->right_ptr)
+ ->where("$field IS NOT", self::UNKNOWN)
+ ->orderby("left_ptr", "DESC")
->limit(1)
->find();
if ($tmp_item->loaded) {
@@ -543,20 +576,21 @@ class access_Core {
// With non-view permissions, each level can override any permissions that came above it
// so start at the top and work downwards, overlaying permissions as we go.
$query = ORM::factory("access_intent")
- ->select(array("access_intents.$field", "items.left", "items.right"))
+ ->select(array("access_intents.$field", "items.left_ptr", "items.right_ptr"))
->join("items", "items.id", "access_intents.item_id")
- ->where("left >=", $item->left)
- ->where("right <=", $item->right)
- ->where("$field IS NOT", null)
+ ->where("left_ptr >=", $item->left_ptr)
+ ->where("right_ptr <=", $item->right_ptr)
+ ->where("$field IS NOT", self::INHERIT)
->orderby("level", "ASC")
->find_all();
foreach ($query as $row) {
+ $value = ($row->$field === self::ALLOW) ? "TRUE" : "FALSE";
$db->query(
- "UPDATE {access_caches} SET `$field` = {$row->$field} " .
+ "UPDATE {access_caches} SET `$field` = $value " .
"WHERE `item_id` IN " .
" (SELECT `id` FROM {items} " .
- " WHERE `left` >= $row->left " .
- " AND `right` <= $row->right)");
+ " WHERE `left_ptr` >= $row->left_ptr " .
+ " AND `right_ptr` <= $row->right_ptr)");
}
}
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php
index 362b93d0..8a7c9951 100644
--- a/modules/gallery/helpers/album.php
+++ b/modules/gallery/helpers/album.php
@@ -71,6 +71,8 @@ class album_Core {
mkdir(dirname($album->thumb_path()));
mkdir(dirname($album->resize_path()));
+ // @todo: publish this from inside Item_Model::save() when we refactor to the point where
+ // there's only one save() happening here.
module::event("item_created", $album);
return $album;
@@ -88,18 +90,21 @@ class album_Core {
$group->hidden("type")->value("album");
$group->submit("")->value(t("Create"));
$form->add_rules_from(ORM::factory("item"));
+ $form->script("")
+ ->url(url::abs_file("modules/gallery/js/albums_form_add.js"));
return $form;
}
static function get_edit_form($parent) {
$form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gEditAlbumForm"));
$form->hidden("_method")->value("put");
- $group = $form->group("edit_album")->label(t("Edit Album"));
+ $group = $form->group("edit_item")->label(t("Edit Album"));
$group->input("title")->label(t("Title"))->value($parent->title);
$group->textarea("description")->label(t("Description"))->value($parent->description);
if ($parent->id != 1) {
$group->input("dirname")->label(t("Directory Name"))->value($parent->name)
+ ->rules("required")
->callback("item::validate_no_slashes")
->error_messages("no_slashes", t("The directory name can't contain a \"/\""))
->callback("item::validate_no_trailing_period")
@@ -111,7 +116,7 @@ class album_Core {
$sort_order->dropdown("column", array("id" => "gAlbumSortColumn"))
->label(t("Sort by"))
- ->options(array("weight" => t("Default"),
+ ->options(array("weight" => t("Order Added"),
"captured" => t("Capture Date"),
"created" => t("Creation Date"),
"title" => t("Title"),
@@ -124,6 +129,9 @@ class album_Core {
->options(array("ASC" => t("Ascending"),
"DESC" => t("Descending")))
->selected($parent->sort_order);
+
+ module::event("item_edit_form", $parent, $form);
+
$group->hidden("type")->value("album");
$group->submit("")->value(t("Modify"));
$form->add_rules_from(ORM::factory("item"));
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index e22cc17f..c81af842 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class gallery_Core {
+ const VERSION = "3.0 git (pre-beta3)";
+
/**
* If Gallery is in maintenance mode, then force all non-admins to get routed to a "This site is
* down for maintenance" page.
@@ -76,4 +78,236 @@ class gallery_Core {
static function time($timestamp) {
return date(module::get_var("gallery", "time_format", "H:i:s"), $timestamp);
}
+
+ 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")));
+
+ $item = $theme->item();
+
+ $can_edit = $item && access::can("edit", $item);
+ $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($options_menu = Menu::factory("submenu")
+ ->id("options_menu")
+ ->label(t("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")));
+ }
+
+ // @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")));
+ }
+
+ if ($can_edit) {
+ $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")));
+ gallery::admin_menu($admin_menu, $theme);
+ module::event("admin_menu", $admin_menu, $theme);
+ }
+
+ module::event("site_menu", $menu, $theme);
+ }
+ }
+
+ static function admin_menu($menu, $theme) {
+ $menu
+ ->append(Menu::factory("link")
+ ->id("dashboard")
+ ->label(t("Dashboard"))
+ ->url(url::site("admin")))
+ ->append(Menu::factory("submenu")
+ ->id("settings_menu")
+ ->label(t("Settings"))
+ ->append(Menu::factory("link")
+ ->id("graphics_toolkits")
+ ->label(t("Graphics"))
+ ->url(url::site("admin/graphics")))
+ ->append(Menu::factory("link")
+ ->id("languages")
+ ->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"))))
+ ->append(Menu::factory("link")
+ ->id("modules")
+ ->label(t("Modules"))
+ ->url(url::site("admin/modules")))
+ ->append(Menu::factory("submenu")
+ ->id("content_menu")
+ ->label(t("Content")))
+ ->append(Menu::factory("submenu")
+ ->id("appearance_menu")
+ ->label(t("Appearance"))
+ ->append(Menu::factory("link")
+ ->id("themes")
+ ->label(t("Theme Choice"))
+ ->url(url::site("admin/themes")))
+ ->append(Menu::factory("link")
+ ->id("theme_options")
+ ->label(t("Theme Options"))
+ ->url(url::site("admin/theme_options"))))
+ ->append(Menu::factory("submenu")
+ ->id("statistics_menu")
+ ->label(t("Statistics")))
+ ->append(Menu::factory("link")
+ ->id("maintenance")
+ ->label(t("Maintenance"))
+ ->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&deg; 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&deg; 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_event.php b/modules/gallery/helpers/gallery_event.php
index aa11b7c0..64f2a9ff 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -23,7 +23,7 @@ class gallery_event_Core {
access::add_group($group);
}
- static function group_before_delete($group) {
+ static function group_deleted($group) {
access::delete_group($group);
}
@@ -31,10 +31,14 @@ class gallery_event_Core {
access::add_item($item);
}
- static function item_before_delete($item) {
+ static function item_deleted($item) {
access::delete_item($item);
}
+ static function item_moved($item, $old_parent) {
+ access::recalculate_permissions($item->parent());
+ }
+
static function user_login($user) {
// If this user is an admin, check to see if there are any post-install tasks that we need
// to run and take care of those now.
@@ -43,4 +47,10 @@ class gallery_event_Core {
module::clear_var("gallery", "choose_default_tookit");
}
}
+
+ static function item_index_data($item, $data) {
+ $data[] = $item->description;
+ $data[] = $item->name;
+ $data[] = $item->title;
+ }
}
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 0e5d29b9..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,
@@ -72,7 +72,7 @@ class gallery_installer {
`created` int(9) default NULL,
`description` varchar(2048) default NULL,
`height` int(9) default NULL,
- `left` int(9) NOT NULL,
+ `left_ptr` int(9) NOT NULL,
`level` int(9) NOT NULL,
`mime_type` varchar(64) default NULL,
`name` varchar(255) default NULL,
@@ -83,7 +83,7 @@ class gallery_installer {
`resize_dirty` boolean default 1,
`resize_height` int(9) default NULL,
`resize_width` int(9) default NULL,
- `right` int(9) NOT NULL,
+ `right_ptr` int(9) NOT NULL,
`sort_column` varchar(64) default NULL,
`sort_order` char(4) default 'ASC',
`thumb_dirty` boolean default 1,
@@ -98,8 +98,9 @@ class gallery_installer {
PRIMARY KEY (`id`),
KEY `parent_id` (`parent_id`),
KEY `type` (`type`),
- KEY `random` (`rand_key`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ KEY `random` (`rand_key`),
+ KEY `weight` (`weight` DESC))
+ DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {logs} (
`id` int(9) NOT NULL auto_increment,
@@ -112,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,
@@ -121,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,
@@ -130,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,
@@ -142,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,
@@ -150,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,
@@ -172,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,
@@ -180,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,
@@ -189,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);
@@ -204,8 +205,8 @@ class gallery_installer {
$root->type = "album";
$root->title = "Gallery";
$root->description = "";
- $root->left = 1;
- $root->right = 2;
+ $root->left_ptr = 1;
+ $root->right_ptr = 2;
$root->parent_id = 0;
$root->level = 1;
$root->thumb_dirty = 1;
@@ -251,7 +252,6 @@ class gallery_installer {
block_manager::add("dashboard_center", "gallery", "photo_stream");
block_manager::add("dashboard_center", "gallery", "log_entries");
- module::set_var("gallery", "version", "3.0 pre beta 2 (git)");
module::set_var("gallery", "choose_default_tookit", 1);
module::set_var("gallery", "date_format", "Y-M-d");
module::set_var("gallery", "date_time_format", "Y-M-d H:i:s");
@@ -259,7 +259,7 @@ class gallery_installer {
module::set_var("gallery", "show_credits", 1);
// @todo this string needs to be picked up by l10n_scanner
module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>");
- module::set_version("gallery", 6);
+ module::set_version("gallery", 10);
}
static function upgrade($version) {
@@ -268,7 +268,6 @@ class gallery_installer {
module::set_var("gallery", "date_format", "Y-M-d");
module::set_var("gallery", "date_time_format", "Y-M-d H:i:s");
module::set_var("gallery", "time_format", "H:i:s");
- module::set_var("gallery", "version", "3.0 pre beta 2 (git)");
module::set_version("gallery", $version = 2);
}
@@ -285,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);
}
@@ -302,7 +301,42 @@ class gallery_installer {
$db->query("ALTER TABLE {caches} ADD COLUMN `id` int(9) NOT NULL auto_increment PRIMARY KEY");
module::set_version("gallery", $version = 6);
}
- }
+
+ if ($version == 6) {
+ module::clear_var("gallery", "version");
+ module::set_version("gallery", $version = 7);
+ }
+
+ if ($version == 7) {
+ $groups = ORM::factory("group")->find_all();
+ $permissions = ORM::factory("permission")->find_all();
+ foreach($groups as $group) {
+ foreach($permissions as $permission) {
+ // Update access intents
+ $db->query("ALTER TABLE {access_intents} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) DEFAULT NULL");
+ // Update access cache
+ if ($permission->name === "view") {
+ $db->query("ALTER TABLE {items} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) DEFAULT FALSE");
+ } else {
+ $db->query("ALTER TABLE {access_caches} MODIFY COLUMN {$permission->name}_{$group->id} BINARY(1) NOT NULL DEFAULT FALSE");
+ }
+ }
+ }
+ module::set_version("gallery", $version = 8);
+ }
+
+ if ($version == 8) {
+ $db->query("ALTER TABLE {items} CHANGE COLUMN `left` `left_ptr` INT(9) NOT NULL;");
+ $db->query("ALTER TABLE {items} CHANGE COLUMN `right` `right_ptr` INT(9) NOT NULL;");
+ module::set_version("gallery", $version = 9);
+ }
+
+ if ($version == 9) {
+ $db->query("ALTER TABLE {items} ADD KEY `weight` (`weight` DESC);");
+
+ module::set_version("gallery", $version = 10);
+ }
+}
static function uninstall() {
$db = Database::instance();
diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php
deleted file mode 100644
index 1f1e1ce2..00000000
--- a/modules/gallery/helpers/gallery_menu.php
+++ /dev/null
@@ -1,163 +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_menu_Core {
- static function site($menu, $theme) {
- $is_admin = user::active()->admin;
-
- $menu->append(Menu::factory("link")
- ->id("home")
- ->label(t("Home"))
- ->url(url::site("albums/1")));
-
- $item = $theme->item();
-
- $can_edit = $item && access::can("edit", $item) || $is_admin;
- $can_add = $item && (access::can("add", $item) || $is_admin);
-
- if ($can_add) {
- $menu->append(Menu::factory("dialog")
- ->id("add_photos_item")
- ->label(t("Add photos"))
- ->url(url::site("simple_uploader/app/$item->id")));
- }
-
- if ($item && $can_edit || $can_add) {
- $menu->append($options_menu = Menu::factory("submenu")
- ->id("options_menu")
- ->label(t("Options")));
-
- 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")));
- }
-
- // @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")));
- }
-
- if ($can_edit) {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("edit_permissions")
- ->label(t("Edit permissions"))
- ->url(url::site("permissions/browse/$item->id")));
- }
- }
- }
-
- if ($is_admin) {
- $menu->append($admin_menu = Menu::factory("submenu")
- ->id("admin_menu")
- ->label(t("Admin")));
- self::admin($admin_menu, $theme);
- foreach (module::active() as $module) {
- if ($module->name == "gallery") {
- continue;
- }
- $class = "{$module->name}_menu";
- if (method_exists($class, "admin")) {
- call_user_func_array(array($class, "admin"), array(&$admin_menu, $theme));
- }
- }
- }
- }
-
- static function album($menu, $theme) {
- }
-
- static function tag($menu, $theme) {
- }
-
- static function thumb($menu, $theme, $item) {
- }
-
- static function photo($menu, $theme) {
- if (access::can("view_full", $theme->item())) {
- $menu->append(Menu::factory("link")
- ->id("fullsize")
- ->label(t("View full size"))
- ->url($theme->item()->file_url())
- ->css_class("gFullSizeLink"));
- }
- }
-
- static function admin($menu, $theme) {
- $menu
- ->append(Menu::factory("link")
- ->id("dashboard")
- ->label(t("Dashboard"))
- ->url(url::site("admin")))
- ->append(Menu::factory("submenu")
- ->id("settings_menu")
- ->label(t("Settings"))
- ->append(Menu::factory("link")
- ->id("graphics_toolkits")
- ->label(t("Graphics"))
- ->url(url::site("admin/graphics")))
- ->append(Menu::factory("link")
- ->id("languages")
- ->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"))))
- ->append(Menu::factory("link")
- ->id("modules")
- ->label(t("Modules"))
- ->url(url::site("admin/modules")))
- ->append(Menu::factory("submenu")
- ->id("content_menu")
- ->label(t("Content")))
- ->append(Menu::factory("submenu")
- ->id("appearance_menu")
- ->label(t("Appearance"))
- ->append(Menu::factory("link")
- ->id("themes")
- ->label(t("Theme Choice"))
- ->url(url::site("admin/themes")))
- ->append(Menu::factory("link")
- ->id("theme_options")
- ->label(t("Theme Options"))
- ->url(url::site("admin/theme_options"))))
- ->append(Menu::factory("submenu")
- ->id("statistics_menu")
- ->label(t("Statistics")))
- ->append(Menu::factory("link")
- ->id("maintenance")
- ->label(t("Maintenance"))
- ->url(url::site("admin/maintenance")));
- }
-}
diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php
deleted file mode 100644
index d0ffc584..00000000
--- a/modules/gallery/helpers/gallery_quick.php
+++ /dev/null
@@ -1,144 +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"));
- }
-
- if (access::can("edit", $item->parent())) {
- $disabledState =
- $item->type == "album" && empty($item->album_cover_item_id) ? " ui-state-disabled" : "";
- $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 7daf6170..8e887368 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 = p::purify($item->title);
$feed->link = url::abs_site("albums/{$item->id}");
$feed->description = nl2br(p::purify($item->description));
diff --git a/modules/gallery/helpers/gallery_search.php b/modules/gallery/helpers/gallery_search.php
deleted file mode 100644
index 2a4029d3..00000000
--- a/modules/gallery/helpers/gallery_search.php
+++ /dev/null
@@ -1,24 +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_search_Core {
- static function item_index_data($item) {
- return join(" ", array($item->description, $item->name, $item->title));
- }
-}
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php
index 1152cda2..9edc3acd 100644
--- a/modules/gallery/helpers/gallery_task.php
+++ b/modules/gallery/helpers/gallery_task.php
@@ -45,131 +45,158 @@ class gallery_task_Core {
* @param Task_Model the task
*/
static function rebuild_dirty_images($task) {
- $result = graphics::find_dirty_images_query();
- $completed = $task->get("completed", 0);
- $ignored = $task->get("ignored", array());
- $remaining = $result->count() - count($ignored);
-
- $i = 0;
- foreach ($result as $row) {
- if (array_key_exists($row->id, $ignored)) {
- continue;
- }
+ $errors = array();
+ try {
+ $result = graphics::find_dirty_images_query();
+ $completed = $task->get("completed", 0);
+ $ignored = $task->get("ignored", array());
+ $remaining = $result->count() - count($ignored);
+
+ $i = 0;
+ foreach ($result as $row) {
+ if (array_key_exists($row->id, $ignored)) {
+ continue;
+ }
- $item = ORM::factory("item", $row->id);
- if ($item->loaded) {
- $success = graphics::generate($item);
- if (!$success) {
- $ignored[$item->id] = 1;
+ $item = ORM::factory("item", $row->id);
+ if ($item->loaded) {
+ $success = graphics::generate($item);
+ if (!$success) {
+ $ignored[$item->id] = 1;
+ $errors[] = t("Unable to rebuild images for '%title'",
+ array("title" => p::purify($item->title)));
+ } else {
+ $errors[] = t("Successfully rebuilt images for '%title'",
+ array("title" => p::purify($item->title)));
+ }
}
- }
- $completed++;
- $remaining--;
+ $completed++;
+ $remaining--;
- if (++$i == 2) {
- break;
+ if (++$i == 2) {
+ break;
+ }
}
- }
- $task->status = t2("Updated: 1 image. Total: %total_count.",
- "Updated: %count images. Total: %total_count.",
- $completed,
- array("total_count" => ($remaining + $completed)));
+ $task->status = t2("Updated: 1 image. Total: %total_count.",
+ "Updated: %count images. Total: %total_count.",
+ $completed,
+ array("total_count" => ($remaining + $completed)));
- if ($completed + $remaining > 0) {
- $task->percent_complete = (int)(100 * $completed / ($completed + $remaining));
- } else {
- $task->percent_complete = 100;
- }
+ if ($completed + $remaining > 0) {
+ $task->percent_complete = (int)(100 * $completed / ($completed + $remaining));
+ } else {
+ $task->percent_complete = 100;
+ }
- $task->set("completed", $completed);
- $task->set("ignored", $ignored);
- if ($remaining == 0) {
+ $task->set("completed", $completed);
+ $task->set("ignored", $ignored);
+ if ($remaining == 0) {
+ $task->done = true;
+ $task->state = "success";
+ site_status::clear("graphics_dirty");
+ }
+ } catch (Exception $e) {
$task->done = true;
- $task->state = "success";
- site_status::clear("graphics_dirty");
+ $task->state = "error";
+ $task->status = $e->getMessage();
+ $errors[] = $e->__toString();
+ }
+ if ($errors) {
+ $task->log($errors);
}
}
static function update_l10n(&$task) {
- $start = microtime(true);
- $dirs = $task->get("dirs");
- $files = $task->get("files");
- $cache = $task->get("cache", array());
- $i = 0;
-
- switch ($task->get("mode", "init")) {
- case "init": // 0%
- $dirs = array("gallery", "modules", "themes", "installer");
- $files = array();
- $task->set("mode", "find_files");
- $task->status = t("Finding files");
- break;
-
- case "find_files": // 0% - 10%
- while (($dir = array_pop($dirs)) && microtime(true) - $start < 0.5) {
- if (in_array(basename($dir), array("tests", "lib"))) {
- continue;
- }
+ $errors = array();
+ try {
+ $start = microtime(true);
+ $dirs = $task->get("dirs");
+ $files = $task->get("files");
+ $cache = $task->get("cache", array());
+ $i = 0;
+
+ switch ($task->get("mode", "init")) {
+ case "init": // 0%
+ $dirs = array("gallery", "modules", "themes", "installer");
+ $files = array();
+ $task->set("mode", "find_files");
+ $task->status = t("Finding files");
+ break;
- foreach (glob(DOCROOT . "$dir/*") as $path) {
- $relative_path = str_replace(DOCROOT, "", $path);
- if (is_dir($path)) {
- $dirs[] = $relative_path;
- } else {
- $files[] = $relative_path;
+ case "find_files": // 0% - 10%
+ while (($dir = array_pop($dirs)) && microtime(true) - $start < 0.5) {
+ if (in_array(basename($dir), array("tests", "lib"))) {
+ continue;
+ }
+
+ foreach (glob(DOCROOT . "$dir/*") as $path) {
+ $relative_path = str_replace(DOCROOT, "", $path);
+ if (is_dir($path)) {
+ $dirs[] = $relative_path;
+ } else {
+ $files[] = $relative_path;
+ }
}
}
- }
- $task->status = t2("Finding files: found 1 file",
- "Finding files: found %count files", count($files));
+ $task->status = t2("Finding files: found 1 file",
+ "Finding files: found %count files", count($files));
- if (!$dirs) {
- $task->set("mode", "scan_files");
- $task->set("total_files", count($files));
- $task->status = t("Scanning files");
- $task->percent_complete = 10;
- }
- break;
-
- case "scan_files": // 10% - 90%
- while (($file = array_pop($files)) && microtime(true) - $start < 0.5) {
- $file = DOCROOT . $file;
- switch (pathinfo($file, PATHINFO_EXTENSION)) {
- case "php":
- l10n_scanner::scan_php_file($file, $cache);
- break;
+ if (!$dirs) {
+ $task->set("mode", "scan_files");
+ $task->set("total_files", count($files));
+ $task->status = t("Scanning files");
+ $task->percent_complete = 10;
+ }
+ break;
- case "info":
- l10n_scanner::scan_info_file($file, $cache);
- break;
+ case "scan_files": // 10% - 90%
+ while (($file = array_pop($files)) && microtime(true) - $start < 0.5) {
+ $file = DOCROOT . $file;
+ switch (pathinfo($file, PATHINFO_EXTENSION)) {
+ case "php":
+ l10n_scanner::scan_php_file($file, $cache);
+ break;
+
+ case "info":
+ l10n_scanner::scan_info_file($file, $cache);
+ break;
+ }
}
- }
- $total_files = $task->get("total_files");
- $task->status = t2("Scanning files: scanned 1 file",
- "Scanning files: scanned %count files", $total_files - count($files));
+ $total_files = $task->get("total_files");
+ $task->status = t2("Scanning files: scanned 1 file",
+ "Scanning files: scanned %count files", $total_files - count($files));
+
+ $task->percent_complete = 10 + 80 * ($total_files - count($files)) / $total_files;
+ if (empty($files)) {
+ $task->set("mode", "fetch_updates");
+ $task->status = t("Fetching updates");
+ $task->percent_complete = 90;
+ }
+ break;
- $task->percent_complete = 10 + 80 * ($total_files - count($files)) / $total_files;
- if (empty($files)) {
- $task->set("mode", "fetch_updates");
- $task->status = t("Fetching updates");
- $task->percent_complete = 90;
+ case "fetch_updates": // 90% - 100%
+ l10n_client::fetch_updates();
+ $task->done = true;
+ $task->state = "success";
+ $task->status = t("Translations installed/updated");
+ $task->percent_complete = 100;
}
- break;
- case "fetch_updates": // 90% - 100%
- l10n_client::fetch_updates();
+ $task->set("files", $files);
+ $task->set("dirs", $dirs);
+ $task->set("cache", $cache);
+ } catch (Exception $e) {
$task->done = true;
- $task->state = "success";
- $task->status = t("Translations installed/updated");
- $task->percent_complete = 100;
+ $task->state = "error";
+ $task->status = $e->getMessage();
+ $errors[] = $e->__toString();
+ }
+ if ($errors) {
+ $task->log($errors);
}
-
- $task->set("files", $files);
- $task->set("dirs", $dirs);
- $task->set("cache", $cache);
}
} \ No newline at end of file
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index 0e3150bc..69c5a091 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -22,67 +22,41 @@ class gallery_theme_Core {
$session = Session::instance();
$buf = "";
if ($session->get("debug")) {
- $theme->css("modules/gallery/css/debug.css");
- }
- if (($theme->page_type == "album" || $theme->page_type == "photo")
- && access::can("edit", $theme->item())) {
- $theme->css("modules/gallery/css/quick.css");
- $theme->script("modules/gallery/js/quick.js");
+ $theme->css("debug.css");
}
if (module::is_active("rss")) {
if ($item = $theme->item()) {
- $buf .= rss::feed_link("gallery/album/{$item->id}");
+ if ($item->is_album()) {
+ $buf .= rss::feed_link("gallery/album/{$item->id}");
+ } else {
+ $buf .= rss::feed_link("gallery/album/{$item->parent()->id}");
+ }
} else if ($tag = $theme->tag()) {
$buf .= rss::feed_link("tag/tag/{$tag->id}");
}
}
if ($session->get("l10n_mode", false)) {
- $theme->css("modules/gallery/css/l10n_client.css");
- $theme->script("lib/jquery.cookie.js");
- $theme->script("modules/gallery/js/l10n_client.js");
+ $theme->css("l10n_client.css");
+ $theme->script("jquery.cookie.js");
+ $theme->script("l10n_client.js");
}
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("modules/gallery/css/debug.css");
+ $theme->css("debug.css");
}
if ($session->get("l10n_mode", false)) {
- $theme->css("modules/gallery/css/l10n_client.css");
- $theme->script("lib/jquery.cookie.js");
- $theme->script("modules/gallery/js/l10n_client.js");
+ $theme->css("l10n_client.css");
+ $theme->script("jquery.cookie.js");
+ $theme->script("l10n_client.js");
}
}
@@ -116,12 +90,17 @@ class gallery_theme_Core {
static function credits() {
return "<li class=\"first\">" .
t(module::get_var("gallery", "credits"),
- array("url" => "http://gallery.menalto.com",
- "version" => module::get_var("gallery", "version"))) .
+ array("url" => "http://gallery.menalto.com", "version" => gallery::VERSION)) .
"</li>";
}
static function admin_credits() {
return gallery_theme::credits();
}
+
+ static function body_attributes() {
+ if (locales::is_rtl()) {
+ return 'class="rtl"';
+ }
+ }
} \ No newline at end of file
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index bbae0602..7dc46eeb 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -195,6 +195,8 @@ class graphics_Core {
self::init_toolkit();
}
+ module::event("graphics_resize", $input_file, $output_file, $options);
+
if (@filesize($input_file) == 0) {
throw new Exception("@todo EMPTY_INPUT_FILE");
}
@@ -209,6 +211,8 @@ class graphics_Core {
->quality(module::get_var("gallery", "image_quality"))
->save($output_file);
}
+
+ module::event("graphics_resize_completed", $input_file, $output_file, $options);
}
/**
@@ -223,10 +227,14 @@ class graphics_Core {
self::init_toolkit();
}
+ module::event("graphics_rotate", $input_file, $output_file, $options);
+
Image::factory($input_file)
->quality(module::get_var("gallery", "image_quality"))
->rotate($options["degrees"])
->save($output_file);
+
+ module::event("graphics_rotate_completed", $input_file, $output_file, $options);
}
/**
@@ -249,6 +257,8 @@ class graphics_Core {
self::init_toolkit();
}
+ module::event("graphics_composite", $input_file, $output_file, $options);
+
list ($width, $height) = getimagesize($input_file);
list ($w_width, $w_height) = getimagesize($options["file"]);
@@ -276,6 +286,9 @@ class graphics_Core {
->composite($options["file"], $x, $y, $options["transparency"])
->quality(module::get_var("gallery", "image_quality"))
->save($output_file);
+
+
+ module::event("graphics_composite_completed", $input_file, $output_file, $options);
}
/**
@@ -326,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"]));
+ }
}
- putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin");
- return array("gd" => $gd,
- "imagemagick" => $exec ? dirname(exec("which convert")) : false,
- "graphicsmagick" => $exec ? dirname(exec("which gm")) : false);
+
+ 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.");
+ }
+ }
+
+ return $toolkits;
}
/**
@@ -344,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 f40b5c97..a2d3859f 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -53,7 +53,7 @@ class item_Core {
access::required("view", $parent);
access::required("edit", $parent);
- model_cache::clear("item", $parent->album_cover_item_id);
+ model_cache::clear();
$parent->album_cover_item_id = $item->is_album() ? $item->album_cover_item_id : $item->id;
$parent->thumb_dirty = 1;
$parent->save();
@@ -69,7 +69,7 @@ class item_Core {
access::required("edit", $album);
@unlink($album->thumb_path());
- model_cache::clear("item", $album->album_cover_item_id) ;
+ model_cache::clear();
$album->album_cover_item_id = null;
$album->thumb_width = 0;
$album->thumb_height = 0;
@@ -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,18 @@ 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;
+ }
} \ No newline at end of file
diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php
index e153532c..3460cc65 100644
--- a/modules/gallery/helpers/l10n_client.php
+++ b/modules/gallery/helpers/l10n_client.php
@@ -67,11 +67,14 @@ class l10n_client_Core {
return true;
}
+ /**
+ * @return an array of messages that will be written to the task log
+ */
static function fetch_updates() {
$request->locales = array();
$request->messages = new stdClass();
- $locales = locale::installed();
+ $locales = locales::installed();
foreach ($locales as $locale => $locale_data) {
$request->locales[] = $locale;
}
@@ -101,8 +104,7 @@ class l10n_client_Core {
throw new Exception("@todo TRANSLATIONS_FETCH_REQUEST_FAILED " . $response_status);
}
if (empty($response_data)) {
- log::info("translations", "Translations fetch request resulted in an empty response");
- return;
+ return array(t("Translations fetch request resulted in an empty response"));
}
$response = json_decode($response_data);
@@ -111,11 +113,6 @@ class l10n_client_Core {
// [{key:<key_1>, translation: <JSON encoded translation>, rev:<rev>, locale:<locale>},
// {key:<key_2>, ...}
// ]
- $count = count($response);
- log::info("translations",
- t2("Installed 1 new / updated translation message",
- "Installed %count new / updated translation messages", $count));
-
foreach ($response as $message_data) {
// @todo Better input validation
if (empty($message_data->key) || empty($message_data->translation) ||
diff --git a/modules/gallery/helpers/locale.php b/modules/gallery/helpers/locales.php
index 41b78834..3762b97b 100644
--- a/modules/gallery/helpers/locale.php
+++ b/modules/gallery/helpers/locales.php
@@ -21,7 +21,7 @@
/**
* This is the API for handling locales.
*/
-class locale_Core {
+class locales_Core {
private static $locales;
/**
diff --git a/modules/gallery/helpers/model_cache.php b/modules/gallery/helpers/model_cache.php
index 2649fdbd..a3e09862 100644
--- a/modules/gallery/helpers/model_cache.php
+++ b/modules/gallery/helpers/model_cache.php
@@ -32,10 +32,8 @@ class model_cache_Core {
return self::$cache->$model_name->$field_name->$id;
}
- static function clear($model_name, $id, $field_name="id") {
- if (!empty(self::$cache->$model_name->$field_name->$id)) {
- unset(self::$cache->$model_name->$field_name->$id);
- }
+ static function clear() {
+ self::$cache = new stdClass();
}
static function set($model) {
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/movie.php b/modules/gallery/helpers/movie.php
index fcf1cc54..4f4169d5 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -82,7 +82,7 @@ class movie_Core {
$movie->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
// Randomize the name if there's a conflict
- while (ORM::Factory("item")
+ while (ORM::factory("item")
->where("parent_id", $parent->id)
->where("name", $movie->name)
->find()->id) {
@@ -102,6 +102,8 @@ class movie_Core {
copy($filename, $movie->file_path());
+ // @todo: publish this from inside Item_Model::save() when we refactor to the point where
+ // there's only one save() happening here.
module::event("item_created", $movie);
// Build our thumbnail
@@ -145,7 +147,7 @@ class movie_Core {
static function find_ffmpeg() {
if (!$ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) {
- putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin");
+ putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin:/opt/bin");
if (function_exists("exec")) {
$ffmpeg_path = exec("which ffmpeg");
}
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index a4bc853b..5cf37de1 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -81,7 +81,7 @@ class photo_Core {
$photo->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
// Randomize the name if there's a conflict
- while (ORM::Factory("item")
+ while (ORM::factory("item")
->where("parent_id", $parent->id)
->where("name", $photo->name)
->find()->id) {
@@ -105,6 +105,8 @@ class photo_Core {
copy($filename, $photo->file_path());
+ // @todo: publish this from inside Item_Model::save() when we refactor to the point where
+ // there's only one save() happening here.
module::event("item_created", $photo);
// Build our thumbnail/resizes
@@ -135,7 +137,7 @@ class photo_Core {
static function get_edit_form($photo) {
$form = new Forge("photos/$photo->id", "", "post", array("id" => "gEditPhotoForm"));
$form->hidden("_method")->value("put");
- $group = $form->group("edit_photo")->label(t("Edit Photo"));
+ $group = $form->group("edit_item")->label(t("Edit Photo"));
$group->input("title")->label(t("Title"))->value($photo->title);
$group->textarea("description")->label(t("Description"))->value($photo->description);
$group->input("filename")->label(t("Filename"))->value($photo->name)
@@ -145,6 +147,8 @@ class photo_Core {
->callback("item::validate_no_trailing_period")
->error_messages("no_trailing_period", t("The photo name can't end in \".\""));
+ module::event("item_edit_form", $photo, $form);
+
$group->submit("")->value(t("Modify"));
$form->add_rules_from(ORM::factory("item"));
return $form;
diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php
index 6a9f63c2..9fa04305 100644
--- a/modules/gallery/helpers/task.php
+++ b/modules/gallery/helpers/task.php
@@ -84,10 +84,11 @@ class task_Core {
}
$task->save();
} catch (Exception $e) {
+ Kohana::log("error", $e->__toString());
$task->log($e->__toString());
$task->state = "error";
$task->done = true;
- $task->status = $e->getMessage();
+ $task->status = substr($e->getMessage(), 0, 255);
$task->save();
}
diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js
deleted file mode 100644
index 4ebdac47..00000000
--- a/modules/gallery/js/quick.js
+++ /dev/null
@@ -1,90 +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");
- $("#gQuickPane").remove();
- cont.append("<div id=\"gQuickPane\"></div>");
- var img = cont.find(".gThumbnail,.gResize");
- var pos = cont.position();
- $("#gQuickPane").css({
- "position": "absolute",
- "top": pos.top,
- "left": pos.left,
- "text-align": "center",
- "width": cont.innerWidth() + 1,
- "height": "auto"
- }).hide();
- cont.hover(function() {}, hide_quick);
- $.get(
- quick.attr("href"),
- {},
- function(data, textStatus) {
- $("#gQuickPane").html(data).slideDown("fast");
- $(".ui-state-default").hover(
- function(){
- $(this).addClass("ui-state-hover");
- },
- function(){
- $(this).removeClass("ui-state-hover");
- }
- );
- $("#gQuickPane a:not(.options)").click(function(e) {
- e.preventDefault();
- quick_do(cont, $(this), img);
- });
- $("#gQuickPane a.options").click(function(e) {
- e.preventDefault();
- $("#gQuickPaneOptions").slideToggle("fast");
- });
- }
- );
-};
-
-var quick_do = function(cont, pane, img) {
- if (pane.hasClass("ui-state-disabled")) {
- return false;
- }
- if (pane.hasClass("gDialogLink")) {
- openDialog(pane, function() { window.location.reload(); });
- } 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;
-};
-
-var hide_quick = function() {
- $("#gQuickPane").remove();
-};
diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php
index 6ea32f72..e57f2ab3 100644
--- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php
+++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php
@@ -7,7 +7,7 @@
* primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS
* FILE, changes will be overwritten the next time the script is run.
*
- * @version 3.3.0
+ * @version 4.0.0
*
* @warning
* You must *not* include any other HTML Purifier files before this file,
diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php
index 0b53d1b4..71e90632 100644
--- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php
+++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php
@@ -19,7 +19,7 @@
*/
/*
- HTML Purifier 3.3.0 - Standards Compliant HTML Filtering
+ HTML Purifier 4.0.0 - Standards Compliant HTML Filtering
Copyright (C) 2006-2008 Edward Z. Yang
This library is free software; you can redistribute it and/or
@@ -55,10 +55,10 @@ class HTMLPurifier
{
/** Version of HTML Purifier */
- public $version = '3.3.0';
+ public $version = '4.0.0';
/** Constant with version of HTML Purifier */
- const VERSION = '3.3.0';
+ const VERSION = '4.0.0';
/** Global configuration object */
public $config;
diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php
index 5b2592b5..28529e7f 100644
--- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php
+++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php
@@ -20,7 +20,7 @@ class HTMLPurifier_Config
/**
* HTML Purifier's version
*/
- public $version = '3.3.0';
+ public $version = '4.0.0';
/**
* Bool indicator whether or not to automatically finalize
diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php
index 3d8010f4..9f20a412 100644
--- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php
+++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php
@@ -285,7 +285,7 @@ class HTMLPurifier_Lexer
*/
public function extractBody($html) {
$matches = array();
- $result = preg_match('!<body[^>]*>(.+?)</body>!is', $html, $matches);
+ $result = preg_match('!<body[^>]*>(.*)</body>!is', $html, $matches);
if ($result) {
return $matches[1];
} else {
diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php
index 731c3171..0d20c0ce 100644
--- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php
+++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php
@@ -3903,4 +3903,4 @@ class HTML5TreeConstructer {
return $this->dom;
}
}
-?>
+
diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php
index 19676e51..16969bed 100644
--- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php
+++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php
@@ -23,6 +23,10 @@ class HTMLPurifier_URIFilter_Munge extends HTMLPurifier_URIFilter
if (is_null($uri->host) || empty($scheme_obj->browsable)) {
return true;
}
+ // don't redirect if target host is our host
+ if ($uri->host === $config->getDefinition('URI')->host) {
+ return true;
+ }
$this->makeReplace($uri, $config, $context);
$this->replace = array_map('rawurlencode', $this->replace);
diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php
index 47770a90..21b70df6 100644
--- a/modules/gallery/libraries/Admin_View.php
+++ b/modules/gallery/libraries/Admin_View.php
@@ -46,20 +46,10 @@ class Admin_View_Core extends Gallery_View {
public function admin_menu() {
$menu = Menu::factory("root");
- gallery_menu::admin($menu, $this);
-
- foreach (module::active() as $module) {
- if ($module->name == "gallery") {
- continue;
- }
- $class = "{$module->name}_menu";
- if (method_exists($class, "admin")) {
- call_user_func_array(array($class, "admin"), array(&$menu, $this));
- }
- }
-
+ gallery::admin_menu($menu, $this);
+ module::event("admin_menu", $menu, $this);
$menu->compact();
- print $menu;
+ return $menu;
}
/**
@@ -88,6 +78,7 @@ class Admin_View_Core extends Gallery_View {
case "admin_page_bottom":
case "admin_page_top":
case "admin_head":
+ case "body_attributes":
$blocks = array();
foreach (module::active() as $module) {
$helper_class = "{$module->name}_theme";
diff --git a/modules/gallery/libraries/Form_Script.php b/modules/gallery/libraries/Form_Script.php
new file mode 100644
index 00000000..e841408d
--- /dev/null
+++ b/modules/gallery/libraries/Form_Script.php
@@ -0,0 +1,66 @@
+<?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 Form_Script_Core extends Forge {
+ protected $data = array(
+ "name" => false,
+ "type" => "script",
+ "url" => "",
+ "text" => "");
+
+ public function __construct($name) {
+ // Set dummy data so we don"t get errors
+ $this->attr["action"] = "";
+ $this->attr["method"] = "post";
+ $this->data["name"] = $name;
+ }
+
+ public function __get($key) {
+ return isset($this->data[$key]) ? $this->data[$key] : null;
+ }
+
+ /**
+ * Sets url attribute
+ */
+ public function url($url) {
+ $this->data["url"] = $url;
+
+ return $this;
+ }
+
+ public function text($script_text) {
+ $this->data["text"] = $script_text;
+
+ return $this;
+ }
+
+ public function render() {
+ $script = array();
+ if (!empty($this->data["url"])) {
+ $script[] = html::script($this->data["url"]);
+ }
+
+ if (!empty($this->data["text"])) {
+ $script[] = "<script type=\"text/javascript\">\n{$this->data['text']}\n</script>\n";
+ }
+
+ return implode("\n", $script);
+ }
+
+} // End Form Script \ No newline at end of file
diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php
index 8a0be7f2..219cc883 100644
--- a/modules/gallery/libraries/Gallery_View.php
+++ b/modules/gallery/libraries/Gallery_View.php
@@ -27,24 +27,20 @@ class Gallery_View_Core extends View {
* @param $file the relative path to a script from the gallery3 directory
*/
public function script($file) {
- $this->scripts[$file] = 1;
- }
-
- /**
- * Add a script to the combined scripts list.
- * @param $file the relative path to a script from the base of the active theme
- * @param
- */
- public function theme_script($file) {
- $file = "themes/{$this->theme_name}/$file";
- $this->scripts[$file] = 1;
+ $base_file = str_replace(".js", "", $file);
+ if (($path = Kohana::find_file("js", $base_file, false, "js")) ||
+ file_exists($path = DOCROOT . "lib/$file")) {
+ $this->scripts[$path] = 1;
+ } else {
+ Kohana::log("error", "Can't find script file: $file");
+ }
}
/**
* Provide a url to a resource within the current theme. This allows us to refer to theme
* resources without naming the theme itself which makes themes easier to copy.
*/
- public function theme_url($path, $absolute_url=false) {
+ public function url($path, $absolute_url=false) {
$arg = "themes/{$this->theme_name}/$path";
return $absolute_url ? url::abs_file($arg) : url::file($arg);
}
@@ -53,40 +49,34 @@ class Gallery_View_Core extends View {
* Add a css file to the combined css list.
* @param $file the relative path to a script from the gallery3 directory
*/
- public function css($file, $theme_relative=false) {
- $this->css[$file] = 1;
- }
-
- /**
- * Add a css file to the combined css list.
- * @param $file the relative path to a script from the base of the active theme
- * @param
- */
- public function theme_css($file) {
- $file = "themes/{$this->theme_name}/$file";
- $this->css[$file] = 1;
+ public function css($file) {
+ $base_file = str_replace(".css", "", $file);
+ if (($path = Kohana::find_file("css", $base_file, false, "css")) ||
+ file_exists($path = DOCROOT . "lib/$file")) {
+ $this->css[$path] = 1;
+ } else {
+ Kohana::log("error", "Can't find css file: $file");
+ }
}
/**
* Combine a series of files into a single one and cache it in the database.
*/
- protected function combine_files($files, $type) {
+ protected function combine_files($paths, $type) {
$links = array();
+ if (empty($paths)) {
+ return;
+ }
+
// Include the url in the cache key so that if the Gallery moves, we don't use old cached
// entries.
$key = array(url::abs_file(""));
- foreach (array_keys($files) as $file) {
- $path = DOCROOT . $file;
- if (file_exists($path)) {
- $stats = stat($path);
- $links[$file] = $path;
- // 7 == size, 9 == mtime, see http://php.net/stat
- $key[] = "$file $stats[7] $stats[9]";
- } else {
- Kohana::log("error", "missing file ($type): $file");
- }
+ foreach (array_keys($paths) as $path) {
+ $stats = stat($path);
+ // 7 == size, 9 == mtime, see http://php.net/stat
+ $key[] = "$path $stats[7] $stats[9]";
}
$key = md5(join(" ", $key));
@@ -95,16 +85,21 @@ class Gallery_View_Core extends View {
if (empty($contents)) {
$contents = "";
- foreach ($links as $file => $link) {
+ $docroot_len = strlen(DOCROOT);
+ foreach (array_keys($paths) as $path) {
+ $relative = substr($path, $docroot_len);
if ($type == "css") {
- $contents .= "/* $file */\n" . $this->process_css($link) . "\n";
+ $contents .= "/* $relative */\n" . $this->process_css($path) . "\n";
} else {
- $contents .= "/* $file */\n" . file_get_contents($link) . "\n";
+ $contents .= "/* $relative */\n" . file_get_contents($path) . "\n";
}
}
$cache->set($key, $contents, array($type), 30 * 84600);
- if (function_exists("gzencode")) {
+
+ $use_gzip = function_exists("gzencode") &&
+ (int) ini_get("zlib.output_compression") === 0;
+ if ($use_gzip) {
$cache->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP),
array($type, "gzip"), 30 * 84600);
}
@@ -140,6 +135,7 @@ class Gallery_View_Core extends View {
Kohana::log("error", "Missing URL reference '{$match[1]}' in CSS file '$css_file'");
}
}
+ $replace = str_replace(DIRECTORY_SEPARATOR, "/", $replace);
$css = str_replace($search, $replace, $css);
}
$imports = preg_match_all("#@import\s*['|\"]{0,1}(.*?)['|\"]{0,1};#",
diff --git a/modules/gallery/libraries/HtmlPurifier.php b/modules/gallery/libraries/HtmlPurifier.php
index f9d5353b..daa5896e 100644
--- a/modules/gallery/libraries/HtmlPurifier.php
+++ b/modules/gallery/libraries/HtmlPurifier.php
@@ -20,11 +20,6 @@
class HtmlPurifier_Core {
private static $_instance;
- public function __construct($name = NULL, $data = NULL, $type = NULL) {
- parent::__construct($name, $data, $type);
- $this->set_global("csrf", access::csrf_token());
- }
-
static function instance($config=null) {
require_once(dirname(__file__) . "/HTMLPurifier/HTMLPurifier.auto.php");
if (self::$_instance == NULL) {
diff --git a/modules/gallery/libraries/I18n.php b/modules/gallery/libraries/I18n.php
index 03a6d8f6..d0531b9a 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'];
}
@@ -178,7 +183,7 @@ class I18n_Core {
static function is_plural_message($message) {
return is_array($message);
}
-
+
private function interpolate($locale, $string, $values) {
// TODO: Handle locale specific number formatting.
diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php
index 2bd9b4eb..de8adc1d 100644
--- a/modules/gallery/libraries/MY_ORM.php
+++ b/modules/gallery/libraries/MY_ORM.php
@@ -18,6 +18,9 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class ORM extends ORM_Core {
+ // Track the original value of this ORM so that we can look it up in ORM::original()
+ protected $original = null;
+
public function open_paren() {
$this->db->open_paren();
return $this;
@@ -29,8 +32,30 @@ class ORM extends ORM_Core {
}
public function save() {
- model_cache::clear($this->object_name, $this->{$this->primary_key}, $this->primary_key);
- return parent::save();
+ model_cache::clear();
+ $result = parent::save();
+ $this->original = clone $this;
+ return $result;
+ }
+
+ public function __set($column, $value) {
+ if (!isset($this->original)) {
+ $this->original = clone $this;
+ }
+
+ return parent::__set($column, $value);
+ }
+
+ public function __unset($column) {
+ if (!isset($this->original)) {
+ $this->original = clone $this;
+ }
+
+ return parent::__unset($column);
+ }
+
+ public function original() {
+ return $this->original;
}
}
diff --git a/modules/gallery/libraries/MY_View.php b/modules/gallery/libraries/MY_View.php
index 96dcc71b..eb55aca6 100644
--- a/modules/gallery/libraries/MY_View.php
+++ b/modules/gallery/libraries/MY_View.php
@@ -38,16 +38,8 @@ class View extends View_Core {
try {
return parent::render($print, $renderer);
} catch (Exception $e) {
- Kohana::Log('error', $e->getTraceAsString());
- Kohana::Log('debug', $e->getMessage());
+ Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString());
return "";
}
}
-
- public function body_attributes() {
- if (locale::is_rtl()) {
- return 'class="rtl"';
- }
- return '';
- }
}
diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php
index 6d0881ce..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,11 +163,16 @@ 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);
case "root":
- return new Menu("root");
+ $menu = new Menu("root");
+ $menu->css_class("gMenu");
+ return $menu;
case "submenu":
return new Menu("submenu");
@@ -156,6 +192,7 @@ class Menu_Core extends Menu_Element {
}
}
}
+ return $this;
}
public function __construct($type) {
@@ -206,8 +243,8 @@ class Menu_Core extends Menu_Element {
}
public function __toString() {
- $html = $this->is_root ? "<ul class=\"gMenu\">" :
- "<li><a href=#>$this->label</a><ul class=\"gMenu\">";
+ $html = $this->is_root ? "<ul class=\"$this->css_class\">" :
+ "<li title=\"$this->label\"><a href=\"#\">$this->label</a><ul>";
$html .= implode("\n", $this->elements);
$html .= $this->is_root ? "</ul>" : "</ul></li>";
return $html;
diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php
index 46280d95..a7defba9 100644
--- a/modules/gallery/libraries/ORM_MPTT.php
+++ b/modules/gallery/libraries/ORM_MPTT.php
@@ -52,14 +52,14 @@ class ORM_MPTT_Core extends ORM {
try {
// Make a hole in the parent for this new item
$this->db->query(
- "UPDATE {{$this->table_name}} SET `left` = `left` + 2 WHERE `left` >= {$parent->right}");
+ "UPDATE {{$this->table_name}} SET `left_ptr` = `left_ptr` + 2 WHERE `left_ptr` >= {$parent->right_ptr}");
$this->db->query(
- "UPDATE {{$this->table_name}} SET `right` = `right` + 2 WHERE `right` >= {$parent->right}");
- $parent->right += 2;
+ "UPDATE {{$this->table_name}} SET `right_ptr` = `right_ptr` + 2 WHERE `right_ptr` >= {$parent->right_ptr}");
+ $parent->right_ptr += 2;
// Insert this item into the hole
- $this->left = $parent->right - 2;
- $this->right = $parent->right - 1;
+ $this->left_ptr = $parent->right_ptr - 2;
+ $this->right_ptr = $parent->right_ptr - 1;
$this->parent_id = $parent->id;
$this->level = $parent->level + 1;
$this->save();
@@ -81,7 +81,7 @@ class ORM_MPTT_Core extends ORM {
if ($children) {
foreach ($this->children() as $item) {
// Deleting children affects the MPTT tree, so we have to reload each child before we
- // delete it so that we have current left/right pointers. This is inefficient.
+ // delete it so that we have current left_ptr/right_ptr pointers. This is inefficient.
// @todo load each child once, not twice.
$item->reload()->delete();
}
@@ -93,9 +93,9 @@ class ORM_MPTT_Core extends ORM {
$this->lock();
try {
$this->db->query(
- "UPDATE {{$this->table_name}} SET `left` = `left` - 2 WHERE `left` > {$this->right}");
+ "UPDATE {{$this->table_name}} SET `left_ptr` = `left_ptr` - 2 WHERE `left_ptr` > {$this->right_ptr}");
$this->db->query(
- "UPDATE {{$this->table_name}} SET `right` = `right` - 2 WHERE `right` > {$this->right}");
+ "UPDATE {{$this->table_name}} SET `right_ptr` = `right_ptr` - 2 WHERE `right_ptr` > {$this->right_ptr}");
} catch (Exception $e) {
$this->unlock();
throw $e;
@@ -111,7 +111,7 @@ class ORM_MPTT_Core extends ORM {
* @return boolean
*/
function is_descendant($target) {
- return ($this->left <= $target->left && $this->right >= $target->right);
+ return ($this->left_ptr <= $target->left_ptr && $this->right_ptr >= $target->right_ptr);
}
/**
@@ -133,10 +133,10 @@ class ORM_MPTT_Core extends ORM {
*/
function parents() {
return $this
- ->where("`left` <= {$this->left}")
- ->where("`right` >= {$this->right}")
+ ->where("`left_ptr` <= {$this->left_ptr}")
+ ->where("`right_ptr` >= {$this->right_ptr}")
->where("id <> {$this->id}")
- ->orderby("left", "ASC")
+ ->orderby("left_ptr", "ASC")
->find_all();
}
@@ -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 >", $this->left)
- ->where("right <=", $this->right);
- 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 >", $this->left)
- ->where("right <=", $this->right);
- 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();
}
/**
@@ -219,16 +212,16 @@ class ORM_MPTT_Core extends ORM {
* @return ORM_MTPP
*/
function move_to($target) {
- if ($this->left <= $target->left &&
- $this->right >= $target->right) {
+ if ($this->left_ptr <= $target->left_ptr &&
+ $this->right_ptr >= $target->right_ptr) {
throw new Exception("@todo INVALID_TARGET can't move item inside itself");
}
- $number_to_move = (int)(($this->right - $this->left) / 2 + 1);
+ $number_to_move = (int)(($this->right_ptr - $this->left_ptr) / 2 + 1);
$size_of_hole = $number_to_move * 2;
- $original_left = $this->left;
- $original_right = $this->right;
- $target_right = $target->right;
+ $original_left_ptr = $this->left_ptr;
+ $original_right_ptr = $this->right_ptr;
+ $target_right_ptr = $target->right_ptr;
$level_delta = ($target->level + 1) - $this->level;
$this->lock();
@@ -237,45 +230,45 @@ class ORM_MPTT_Core extends ORM {
// Update the levels for the to-be-moved items
$this->db->query(
"UPDATE {{$this->table_name}} SET `level` = `level` + $level_delta" .
- " WHERE `left` >= $original_left AND `right` <= $original_right");
+ " WHERE `left_ptr` >= $original_left_ptr AND `right_ptr` <= $original_right_ptr");
}
// Make a hole in the target for the move
$target->db->query(
- "UPDATE {{$this->table_name}} SET `left` = `left` + $size_of_hole" .
- " WHERE `left` >= $target_right");
+ "UPDATE {{$this->table_name}} SET `left_ptr` = `left_ptr` + $size_of_hole" .
+ " WHERE `left_ptr` >= $target_right_ptr");
$target->db->query(
- "UPDATE {{$this->table_name}} SET `right` = `right` + $size_of_hole" .
- " WHERE `right` >= $target_right");
+ "UPDATE {{$this->table_name}} SET `right_ptr` = `right_ptr` + $size_of_hole" .
+ " WHERE `right_ptr` >= $target_right_ptr");
// Change the parent.
$this->db->query(
"UPDATE {{$this->table_name}} SET `parent_id` = {$target->id}" .
" WHERE `id` = {$this->id}");
- // If the source is to the right of the target then we just adjusted its left and right above.
- $left = $original_left;
- $right = $original_right;
- if ($original_left > $target_right) {
- $left += $size_of_hole;
- $right += $size_of_hole;
+ // If the source is to the right of the target then we just adjusted its left_ptr and right_ptr above.
+ $left_ptr = $original_left_ptr;
+ $right_ptr = $original_right_ptr;
+ if ($original_left_ptr > $target_right_ptr) {
+ $left_ptr += $size_of_hole;
+ $right_ptr += $size_of_hole;
}
- $new_offset = $target->right - $left;
+ $new_offset = $target->right_ptr - $left_ptr;
$this->db->query(
"UPDATE {{$this->table_name}}" .
- " SET `left` = `left` + $new_offset," .
- " `right` = `right` + $new_offset" .
- " WHERE `left` >= $left" .
- " AND `right` <= $right");
+ " SET `left_ptr` = `left_ptr` + $new_offset," .
+ " `right_ptr` = `right_ptr` + $new_offset" .
+ " WHERE `left_ptr` >= $left_ptr" .
+ " AND `right_ptr` <= $right_ptr");
// Close the hole in the source's parent after the move
$this->db->query(
- "UPDATE {{$this->table_name}} SET `left` = `left` - $size_of_hole" .
- " WHERE `left` > $right");
+ "UPDATE {{$this->table_name}} SET `left_ptr` = `left_ptr` - $size_of_hole" .
+ " WHERE `left_ptr` > $right_ptr");
$this->db->query(
- "UPDATE {{$this->table_name}} SET `right` = `right` - $size_of_hole" .
- " WHERE `right` > $right");
+ "UPDATE {{$this->table_name}} SET `right_ptr` = `right_ptr` - $size_of_hole" .
+ " WHERE `right_ptr` > $right_ptr");
} catch (Exception $e) {
$this->unlock();
throw $e;
@@ -285,6 +278,7 @@ class ORM_MPTT_Core extends ORM {
// Lets reload to get the changes.
$this->reload();
+ $target->reload();
return $this;
}
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 898574d7..541bce88 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -80,54 +80,47 @@ class Theme_View_Core extends Gallery_View {
public function site_menu() {
$menu = Menu::factory("root");
- if ($this->page_type != "login") {
- gallery_menu::site($menu, $this);
-
- foreach (module::active() as $module) {
- if ($module->name == "gallery") {
- continue;
- }
- $class = "{$module->name}_menu";
- if (method_exists($class, "site")) {
- call_user_func_array(array($class, "site"), array(&$menu, $this));
- }
- }
- }
-
- $menu->compact();
- print $menu;
+ gallery::site_menu($menu, $this);
+ module::event("site_menu", $menu, $this);
+ return $menu->compact();
}
public function album_menu() {
- $this->_menu("album");
+ $menu = Menu::factory("root");
+ module::event("album_menu", $menu, $this);
+ return $menu->compact();
}
public function tag_menu() {
- $this->_menu("tag");
+ $menu = Menu::factory("root");
+ module::event("tag_menu", $menu, $this);
+ return $menu->compact();
}
public function photo_menu() {
- $this->_menu("photo");
- }
+ $menu = Menu::factory("root");
+ if (access::can("view_full", $this->item())) {
+ $menu->append(Menu::factory("link")
+ ->id("fullsize")
+ ->label(t("View full size"))
+ ->url($this->item()->file_url())
+ ->css_class("gFullSizeLink"));
+ }
- public function thumb_menu($item) {
- $this->_menu("thumb", $item);
+ module::event("photo_menu", $menu, $this);
+ return $menu->compact();
}
- private function _menu($type, $item=null) {
- $menu = Menu::factory("root");
- call_user_func_array(array("gallery_menu", $type), array(&$menu, $this, $item));
- foreach (module::active() as $module) {
- if ($module->name == "gallery") {
- continue;
- }
- $class = "{$module->name}_menu";
- if (method_exists($class, $type)) {
- call_user_func_array(array($class, $type), array(&$menu, $this, $item));
- }
- }
+ public function context_menu($item, $thumbnail_css_selector) {
+ $menu = Menu::factory("root")
+ ->append(Menu::factory("submenu")
+ ->id("context_menu")
+ ->label(t("Options")))
+ ->css_class("gContextMenu");
- print $menu;
+ gallery::context_menu($menu, $this, $item, $thumbnail_css_selector);
+ module::event("context_menu", $menu, $this, $item, $thumbnail_css_selector);
+ return $menu->compact();
}
public function pager() {
@@ -164,6 +157,7 @@ class Theme_View_Core extends Gallery_View {
case "album_blocks":
case "album_bottom":
case "album_top":
+ case "body_attributes":
case "credits";
case "dynamic_bottom":
case "dynamic_top":
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 51037073..7a3a2ba7 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -93,6 +93,7 @@ class Item_Model extends ORM_MPTT {
}
public function delete() {
+ $old = clone $this;
module::event("item_before_delete", $this);
$parent = $this->parent();
@@ -114,13 +115,15 @@ class Item_Model extends ORM_MPTT {
@unlink($resize_path);
@unlink($thumb_path);
}
+
+ module::event("item_deleted", $old);
}
/**
* Move this item to the specified target.
* @chainable
- * @param Item_Model $target Target item (must be an album
- * @return ORM_MTPP
+ * @param Item_Model $target Target item (must be an album)
+ * @return ORM_MPTT
*/
function move_to($target) {
if (!$target->is_album()) {
@@ -134,8 +137,10 @@ class Item_Model extends ORM_MPTT {
$original_path = $this->file_path();
$original_resize_path = $this->resize_path();
$original_thumb_path = $this->thumb_path();
+ $original_parent = $this->parent();
parent::move_to($target, true);
+ model_cache::clear();
$this->relative_path_cache = null;
rename($original_path, $this->file_path());
@@ -145,12 +150,13 @@ class Item_Model extends ORM_MPTT {
Database::instance()
->update("items",
array("relative_path_cache" => null),
- array("left >" => $this->left, "right <" => $this->right));
+ array("left_ptr >" => $this->left_ptr, "right_ptr <" => $this->right_ptr));
} else {
@rename($original_resize_path, $this->resize_path());
@rename($original_thumb_path, $this->thumb_path());
}
+ module::event("item_moved", $this, $original_parent);
return $this;
}
@@ -180,7 +186,7 @@ class Item_Model extends ORM_MPTT {
Database::instance()
->update("items",
array("relative_path_cache" => null),
- array("left >" => $this->left, "right <" => $this->right));
+ array("left_ptr >" => $this->left_ptr, "right_ptr <" => $this->right_ptr));
}
return $this;
@@ -296,10 +302,10 @@ class Item_Model extends ORM_MPTT {
foreach (Database::instance()
->select("name")
->from("items")
- ->where("left <=", $this->left)
- ->where("right >=", $this->right)
+ ->where("left_ptr <=", $this->left_ptr)
+ ->where("right_ptr >=", $this->right_ptr)
->where("id <>", 1)
- ->orderby("left", "ASC")
+ ->orderby("left_ptr", "ASC")
->get() as $row) {
$paths[] = $row->name;
}
@@ -345,11 +351,16 @@ class Item_Model extends ORM_MPTT {
$this->updated = time();
if (!$this->loaded) {
$this->created = $this->updated;
- $r = ORM::factory("item")->select("MAX(weight) as max_weight")->find();
- $this->weight = $r->max_weight + 1;
+ $this->weight = item::get_max_weight();
+ } else {
+ $send_event = 1;
}
}
- return parent::save();
+ parent::save();
+ if (isset($send_event)) {
+ module::event("item_updated", $this->original(), $this);
+ }
+ return $this;
}
/**
@@ -387,10 +398,10 @@ class Item_Model extends ORM_MPTT {
$db = Database::instance();
$position = $db->query("
SELECT COUNT(*) AS position FROM {items}
- WHERE parent_id = {$this->id}
+ WHERE `parent_id` = {$this->id}
AND `{$this->sort_column}` $comp (SELECT `{$this->sort_column}`
- FROM {items} WHERE id = $child_id)
- ORDER BY `{$this->sort_column}` {$this->sort_order}")->current()->position;
+ FROM {items} WHERE `id` = $child_id)")
+ ->current()->position;
// We stopped short of our target value in the sort (notice that we're using a < comparator
// above) because it's possible that we have duplicate values in the sort column. An
@@ -402,9 +413,10 @@ class Item_Model extends ORM_MPTT {
// our base value.
$result = $db->query("
SELECT id FROM {items}
- WHERE parent_id = {$this->id}
+ WHERE `parent_id` = {$this->id}
AND `{$this->sort_column}` = (SELECT `{$this->sort_column}`
- FROM {items} WHERE id = $child_id)");
+ FROM {items} WHERE `id` = $child_id)
+ ORDER BY `id` ASC");
foreach ($result as $row) {
$position++;
if ($row->id == $child_id) {
@@ -502,26 +514,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/module.info b/modules/gallery/module.info
index c184aba7..dfb1a7a2 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
-name = Gallery 3
-description = Gallery core application
-version = 6
+name = "Gallery 3"
+description = "Gallery core application"
+version = 10
diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php
index d71bf971..59cec453 100644
--- a/modules/gallery/tests/Access_Helper_Test.php
+++ b/modules/gallery/tests/Access_Helper_Test.php
@@ -64,6 +64,43 @@ class Access_Helper_Test extends Unit_Test_Case {
$this->assert_false(array_key_exists("access_test_{$group->id}", $fields));
}
+ public function user_can_access_test() {
+ $access_test = group::create("access_test");
+
+ $root = ORM::factory("item", 1);
+ access::allow($access_test, "view", $root);
+
+ $item = album::create($root, rand(), "test album");
+
+ access::deny(group::everybody(), "view", $item);
+ access::deny(group::registered_users(), "view", $item);
+
+ $user = user::create("access_test", "Access Test", "");
+ foreach ($user->groups as $group) {
+ $user->remove($group);
+ }
+ $user->add($access_test);
+ $user->save();
+
+ $this->assert_true(access::user_can($user, "view", $item), "Should be able to view");
+ }
+
+ public function user_can_no_access_test() {
+ $root = ORM::factory("item", 1);
+ $item = album::create($root, rand(), "test album");
+
+ access::deny(group::everybody(), "view", $item);
+ access::deny(group::registered_users(), "view", $item);
+
+ $user = user::create("access_test", "Access Test", "");
+ foreach ($user->groups as $group) {
+ $user->remove($group);
+ }
+ $user->save();
+
+ $this->assert_false(access::user_can($user, "view", $item), "Should be unable to view");
+ }
+
public function adding_and_removing_items_adds_ands_removes_rows_test() {
$root = ORM::factory("item", 1);
$item = album::create($root, rand(), "test album");
@@ -324,4 +361,40 @@ class Access_Helper_Test extends Unit_Test_Case {
$this->assert_false(file_exists($album->resize_path() . "/.htaccess"));
$this->assert_false(file_exists($album->thumb_path() . "/.htaccess"));
}
+
+ public function moved_items_inherit_new_permissions_test() {
+ user::set_active(user::lookup_by_name("admin"));
+
+ $root = ORM::factory("item", 1);
+ $public_album = album::create($root, rand(), "public album");
+ $public_photo = photo::create($public_album, MODPATH . "gallery/images/gallery.png", "", "");
+ access::allow(group::everybody(), "view", $public_album);
+
+ $root->reload(); // Account for MPTT changes
+
+ $private_album = album::create($root, rand(), "private album");
+ access::deny(group::everybody(), "view", $private_album);
+ $private_photo = photo::create($private_album, MODPATH . "gallery/images/gallery.png", "", "");
+
+ // Make sure that we now have a public photo and private photo.
+ $this->assert_true(access::group_can(group::everybody(), "view", $public_photo));
+ $this->assert_false(access::group_can(group::everybody(), "view", $private_photo));
+
+ // Swap the photos
+ item::move($public_photo, $private_album);
+ $private_album->reload(); // Reload to get new MPTT pointers and cached perms.
+ $public_album->reload();
+ $private_photo->reload();
+ $public_photo->reload();
+
+ item::move($private_photo, $public_album);
+ $private_album->reload(); // Reload to get new MPTT pointers and cached perms.
+ $public_album->reload();
+ $private_photo->reload();
+ $public_photo->reload();
+
+ // Make sure that the public_photo is now private, and the private_photo is now public.
+ $this->assert_false(access::group_can(group::everybody(), "view", $public_photo));
+ $this->assert_true(access::group_can(group::everybody(), "view", $private_photo));
+ }
}
diff --git a/modules/gallery/tests/Database_Test.php b/modules/gallery/tests/Database_Test.php
index bd3d2f53..d83212ad 100644
--- a/modules/gallery/tests/Database_Test.php
+++ b/modules/gallery/tests/Database_Test.php
@@ -103,15 +103,15 @@ class Database_Test extends Unit_Test_Case {
$sql = "UPDATE {test_tables} SET `name` = '{test string}' " .
"WHERE `item_id` IN " .
" (SELECT `id` FROM {items} " .
- " WHERE `left` >= 1 " .
- " AND `right` <= 6)";
+ " WHERE `left_ptr` >= 1 " .
+ " AND `right_ptr` <= 6)";
$sql = $db->add_table_prefixes($sql);
$expected = "UPDATE g3test_test_tables SET `name` = '{test string}' " .
"WHERE `item_id` IN " .
" (SELECT `id` FROM g3test_items " .
- " WHERE `left` >= 1 " .
- " AND `right` <= 6)";
+ " WHERE `left_ptr` >= 1 " .
+ " AND `right_ptr` <= 6)";
$this->assert_same($expected, $sql);
}
diff --git a/modules/gallery/tests/DrawForm_Test.php b/modules/gallery/tests/DrawForm_Test.php
index 2c5aaba4..dde54257 100644
--- a/modules/gallery/tests/DrawForm_Test.php
+++ b/modules/gallery/tests/DrawForm_Test.php
@@ -80,5 +80,44 @@ class DrawForm_Test extends Unit_Test_Case {
$this->assert_same($expected, $rendered);
}
+ function form_script_test() {
+ $form = new Forge("test/controller", "", "post", array("id" => "gTestGroupForm"));
+ $group = $form->group("test_group")->label(t("Test Group"));
+ $group->input("title")->label(t("Title"));
+ $group->textarea("description")->label(t("Text Area"));
+ $form->script("")
+ ->url(url::file("test.js"))
+ ->text("alert('Test Javascript');");
+ $group->submit("")->value(t("Submit"));
+ $rendered = $form->__toString();
+
+ $expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " .
+ "id=\"gTestGroupForm\">\n" .
+ "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" .
+ " <fieldset>\n" .
+ " <legend>Test Group</legend>\n" .
+ " <ul>\n" .
+ " <li>\n" .
+ " <label for=\"title\" >Title</label>\n" .
+ " <input type=\"text\" id=\"title\" name=\"title\" value=\"\" " .
+ "class=\"textbox\" />\n" .
+ " </li>\n" .
+ " <li>\n" .
+ " <label for=\"description\" >Text Area</label>\n" .
+ " <textarea id=\"description\" name=\"description\" " .
+ "class=\"textarea\" ></textarea>\n" .
+ " </li>\n" .
+ " <li>\n" .
+ " <input type=\"submit\" value=\"Submit\" class=\"submit\" />\n" .
+ " </li>\n" .
+ " </ul>\n" .
+ " </fieldset>\n" .
+ "<script type=\"text/javascript\" src=\"http://./test.js\"></script>\n\n" .
+ "<script type=\"text/javascript\">\n" .
+ "alert('Test Javascript');\n" .
+ "</script>\n" .
+ "</form>\n";
+ $this->assert_same($expected, $rendered);
+ }
}
diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php
index 06f456ff..8a97e00b 100644
--- a/modules/gallery/tests/File_Structure_Test.php
+++ b/modules/gallery/tests/File_Structure_Test.php
@@ -213,6 +213,43 @@ class File_Structure_Test extends Unit_Test_Case {
}
}
}
+
+ public function module_info_is_well_formed_test() {
+ $info_files = array_merge(
+ glob("modules/*/module.info"),
+ glob("themes/*/module.info"));
+
+ $errors = array();
+ foreach ($info_files as $file) {
+ foreach (file($file) as $line) {
+ $parts = explode("=", $line, 2);
+ $values[trim($parts[0])] = trim($parts[1]);
+ }
+
+ $module = dirname($file);
+ // Certain keys must exist
+ foreach (array("name", "description", "version") as $key) {
+ if (!array_key_exists($key, $values)) {
+ $errors[] = "$module: missing key $key";
+ }
+ }
+
+ // Any values containing spaces must be quoted
+ foreach ($values as $key => $value) {
+ if (strpos($value, " ") !== false && !preg_match('/^".*"$/', $value)) {
+ $errors[] = "$module: value for $key must be quoted";
+ }
+ }
+
+ // The file must parse
+ if (!is_array(parse_ini_file($file))) {
+ $errors[] = "$module: info file is not parseable";
+ }
+ }
+ if ($errors) {
+ $this->assert_true(false, $errors);
+ }
+ }
}
class PhpCodeFilterIterator extends FilterIterator {
diff --git a/modules/gallery/tests/Gallery_Installer_Test.php b/modules/gallery/tests/Gallery_Installer_Test.php
index 27157d6e..36ced2bb 100644
--- a/modules/gallery/tests/Gallery_Installer_Test.php
+++ b/modules/gallery/tests/Gallery_Installer_Test.php
@@ -34,13 +34,13 @@ class Gallery_Installer_Test extends Unit_Test_Case {
}
public function install_creates_root_item_test() {
- $max_right = ORM::factory("item")
- ->select("MAX(`right`) AS `right`")
- ->find()->right;
+ $max_right_ptr = ORM::factory("item")
+ ->select("MAX(`right_ptr`) AS `right_ptr`")
+ ->find()->right_ptr;
$root = ORM::factory('item')->find(1);
$this->assert_equal("Gallery", $root->title);
- $this->assert_equal(1, $root->left);
- $this->assert_equal($max_right, $root->right);
+ $this->assert_equal(1, $root->left_ptr);
+ $this->assert_equal($max_right_ptr, $root->right_ptr);
$this->assert_equal(null, $root->parent_id);
$this->assert_equal(1, $root->level);
}
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 615b8997..0940d076 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -140,4 +140,14 @@ class Item_Model_Test extends Unit_Test_Case {
}
$this->assert_false(true, "Item_Model::rename should not accept / characters");
}
+
+ public function save_original_values_test() {
+ $item = $this->create_random_item();
+ $item->title = "ORIGINAL_VALUE";
+ $item->save();
+ $item->title = "NEW_VALUE";
+
+ $this->assert_same("ORIGINAL_VALUE", $item->original()->title);
+ $this->assert_same("NEW_VALUE", $item->title);
+ }
}
diff --git a/modules/gallery/tests/ORM_MPTT_Test.php b/modules/gallery/tests/ORM_MPTT_Test.php
index 200c8a74..f77f1f34 100644
--- a/modules/gallery/tests/ORM_MPTT_Test.php
+++ b/modules/gallery/tests/ORM_MPTT_Test.php
@@ -33,8 +33,8 @@ class ORM_MPTT_Test extends Unit_Test_Case {
$album->sort_order = "ASC";
$album->add_to_parent($root);
- $this->assert_equal($album->parent()->right - 2, $album->left);
- $this->assert_equal($album->parent()->right - 1, $album->right);
+ $this->assert_equal($album->parent()->right_ptr - 2, $album->left_ptr);
+ $this->assert_equal($album->parent()->right_ptr - 1, $album->right_ptr);
$this->assert_equal($album->parent()->level + 1, $album->level);
$this->assert_equal($album->parent()->id, $album->parent_id);
}
@@ -48,10 +48,10 @@ class ORM_MPTT_Test extends Unit_Test_Case {
$album1_1_2 = self::create_item_and_add_to_parent($album1_1);
$album1->reload();
- $this->assert_equal(9, $album1->right - $album1->left);
+ $this->assert_equal(9, $album1->right_ptr - $album1->left_ptr);
$album1_1->reload();
- $this->assert_equal(5, $album1_1->right - $album1_1->left);
+ $this->assert_equal(5, $album1_1->right_ptr - $album1_1->left_ptr);
}
public function delete_hierarchy_test() {
@@ -66,7 +66,7 @@ class ORM_MPTT_Test extends Unit_Test_Case {
$album1->reload();
// Now album1 contains only album1_2
- $this->assert_equal(3, $album1->right - $album1->left);
+ $this->assert_equal(3, $album1->right_ptr - $album1->left_ptr);
}
public function move_to_test() {
@@ -85,8 +85,8 @@ class ORM_MPTT_Test extends Unit_Test_Case {
$album1_1->reload();
$album1_2->reload();
- $this->assert_equal(3, $album1_1->right - $album1_1->left);
- $this->assert_equal(3, $album1_2->right - $album1_2->left);
+ $this->assert_equal(3, $album1_1->right_ptr - $album1_1->left_ptr);
+ $this->assert_equal(3, $album1_2->right_ptr - $album1_2->left_ptr);
$this->assert_equal(
array($album1_1_2->id => "move_to_test_1_1_2"),
@@ -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/tests/Photo_Helper_Test.php b/modules/gallery/tests/Photo_Helper_Test.php
index cc1f20da..c0641ef4 100644
--- a/modules/gallery/tests/Photo_Helper_Test.php
+++ b/modules/gallery/tests/Photo_Helper_Test.php
@@ -43,8 +43,8 @@ class Photo_Helper_Test extends Unit_Test_Case {
$this->assert_equal($image_info[0], $photo->width);
$this->assert_equal($image_info[1], $photo->height);
- $this->assert_equal($photo->parent()->right - 2, $photo->left);
- $this->assert_equal($photo->parent()->right - 1, $photo->right);
+ $this->assert_equal($photo->parent()->right_ptr - 2, $photo->left_ptr);
+ $this->assert_equal($photo->parent()->right_ptr - 1, $photo->right_ptr);
}
public function create_conflicting_photo_test() {
diff --git a/modules/gallery/tests/Xss_Security_Test.php b/modules/gallery/tests/Xss_Security_Test.php
index e179482c..9bde11dc 100644
--- a/modules/gallery/tests/Xss_Security_Test.php
+++ b/modules/gallery/tests/Xss_Security_Test.php
@@ -36,7 +36,7 @@ class Xss_Security_Test extends Unit_Test_Case {
// If we find a "(" after a "p::clean" then start counting levels of parens and assume
// that we're inside a p::clean() call until we find the matching close paren.
- if ($token[0] == "(" && $str == "p::clean") {
+ if ($token[0] == "(" && ($str == "p::clean" || $str == "p::purify")) {
$in_p_clean = 1;
} else if ($token[0] == "(" && $in_p_clean) {
$in_p_clean++;
diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt
index 982343f6..0e118ce7 100644
--- a/modules/gallery/tests/xss_data.txt
+++ b/modules/gallery/tests/xss_data.txt
@@ -2,7 +2,7 @@ modules/akismet/views/admin_akismet.html.php 14 DIRTY $form
modules/akismet/views/admin_akismet_stats.html.php 9 DIRTY $api_key
modules/akismet/views/admin_akismet_stats.html.php 9 DIRTY $blog_url
modules/comment/views/admin_block_recent_comments.html.php 4 DIRTY $i
-modules/comment/views/admin_block_recent_comments.html.php 5 DIRTY $comment->author()->avatar_url(32, $theme->theme_url("images/avatar.jpg", true))
+modules/comment/views/admin_block_recent_comments.html.php 5 DIRTY $comment->author()->avatar_url(32, $theme->url("images/avatar.jpg", true))
modules/comment/views/admin_block_recent_comments.html.php 7 $comment->author_name()
modules/comment/views/admin_block_recent_comments.html.php 10 DIRTY $comment->created
modules/comment/views/admin_block_recent_comments.html.php 12 $comment->author_name()
@@ -15,7 +15,7 @@ modules/comment/views/admin_comments.html.php 72 DIRTY $counts->
modules/comment/views/admin_comments.html.php 75 DIRTY $csrf
modules/comment/views/admin_comments.html.php 106 DIRTY $comment->id
modules/comment/views/admin_comments.html.php 106 DIRTY $i
-modules/comment/views/admin_comments.html.php 109 DIRTY $comment->author()->avatar_url(40, $theme->theme_url("images/avatar.jpg", true))
+modules/comment/views/admin_comments.html.php 109 DIRTY $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true))
modules/comment/views/admin_comments.html.php 111 $comment->author_name()
modules/comment/views/admin_comments.html.php 115 $comment->author_email()
modules/comment/views/admin_comments.html.php 116 $comment->author_email()
@@ -35,7 +35,7 @@ modules/comment/views/admin_comments.html.php 175 DIRTY $comment-
modules/comment/views/admin_comments.html.php 183 DIRTY $comment->id
modules/comment/views/admin_comments.html.php 196 DIRTY $pager
modules/comment/views/comment.html.php 2 DIRTY $comment->id
-modules/comment/views/comment.html.php 5 DIRTY $comment->author()->avatar_url(40, $theme->theme_url("images/avatar.jpg", true))
+modules/comment/views/comment.html.php 5 DIRTY $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true))
modules/comment/views/comment.html.php 7 $comment->author_name()
modules/comment/views/comment.html.php 12 DIRTY $comment->created
modules/comment/views/comment.html.php 13 $comment->author_name()
@@ -58,7 +58,7 @@ modules/comment/views/comment.mrss.php 34 DIRTY $child->t
modules/comment/views/comment.mrss.php 35 DIRTY $child->thumb_height
modules/comment/views/comment.mrss.php 35 DIRTY $child->thumb_width
modules/comment/views/comments.html.php 10 DIRTY $comment->id
-modules/comment/views/comments.html.php 13 DIRTY $comment->author()->avatar_url(40, $theme->theme_url("images/avatar.jpg", true))
+modules/comment/views/comments.html.php 13 DIRTY $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true))
modules/comment/views/comments.html.php 15 $comment->author_name()
modules/comment/views/comments.html.php 20 DIRTY $comment->created
modules/comment/views/comments.html.php 21 $comment->author_name()
@@ -108,7 +108,7 @@ modules/gallery/views/admin_block_photo_stream.html.php 6 DIRTY $photo->w
modules/gallery/views/admin_block_photo_stream.html.php 6 DIRTY $photo->height
modules/gallery/views/admin_block_photo_stream.html.php 7 DIRTY $photo->thumb_url()
modules/gallery/views/admin_block_photo_stream.html.php 7 $photo->title
-modules/gallery/views/admin_block_platform.html.php 16 DIRTY $load_average
+modules/gallery/views/admin_block_platform.html.php 19 DIRTY $load_average
modules/gallery/views/admin_block_stats.html.php 7 DIRTY $album_count
modules/gallery/views/admin_block_stats.html.php 10 DIRTY $photo_count
modules/gallery/views/admin_dashboard.html.php 5 DIRTY $csrf
@@ -141,25 +141,31 @@ modules/gallery/views/admin_maintenance.html.php 75 DIRTY $task->na
modules/gallery/views/admin_maintenance.html.php 86 DIRTY $task->percent_complete
modules/gallery/views/admin_maintenance.html.php 90 DIRTY $task->status
modules/gallery/views/admin_maintenance.html.php 93 $task->owner()->name
-modules/gallery/views/admin_maintenance.html.php 97 DIRTY $task->id
-modules/gallery/views/admin_maintenance.html.php 97 DIRTY $csrf
-modules/gallery/views/admin_maintenance.html.php 101 DIRTY $task->id
-modules/gallery/views/admin_maintenance.html.php 101 DIRTY $csrf
-modules/gallery/views/admin_maintenance.html.php 113 DIRTY $csrf
-modules/gallery/views/admin_maintenance.html.php 140 DIRTY $task->state
-modules/gallery/views/admin_maintenance.html.php 142 DIRTY $task->updated
-modules/gallery/views/admin_maintenance.html.php 145 DIRTY $task->name
-modules/gallery/views/admin_maintenance.html.php 157 DIRTY $task->status
-modules/gallery/views/admin_maintenance.html.php 160 DIRTY $task->owner()->name
-modules/gallery/views/admin_maintenance.html.php 164 DIRTY $task->id
-modules/gallery/views/admin_maintenance.html.php 164 DIRTY $csrf
-modules/gallery/views/admin_maintenance.html.php 168 DIRTY $task->id
-modules/gallery/views/admin_maintenance.html.php 168 DIRTY $csrf
-modules/gallery/views/admin_maintenance.html.php 171 DIRTY $task->id
-modules/gallery/views/admin_maintenance.html.php 171 DIRTY $csrf
-modules/gallery/views/admin_maintenance_task.html.php 5 DIRTY $task->id
-modules/gallery/views/admin_maintenance_task.html.php 5 DIRTY $csrf
-modules/gallery/views/admin_maintenance_task.html.php 26 DIRTY $task->name
+modules/gallery/views/admin_maintenance.html.php 98 DIRTY $task->id
+modules/gallery/views/admin_maintenance.html.php 98 DIRTY $csrf
+modules/gallery/views/admin_maintenance.html.php 102 DIRTY $task->id
+modules/gallery/views/admin_maintenance.html.php 102 DIRTY $csrf
+modules/gallery/views/admin_maintenance.html.php 115 DIRTY $csrf
+modules/gallery/views/admin_maintenance.html.php 142 DIRTY $task->state
+modules/gallery/views/admin_maintenance.html.php 144 DIRTY $task->updated
+modules/gallery/views/admin_maintenance.html.php 147 DIRTY $task->name
+modules/gallery/views/admin_maintenance.html.php 159 DIRTY $task->status
+modules/gallery/views/admin_maintenance.html.php 162 DIRTY $task->owner()->name
+modules/gallery/views/admin_maintenance.html.php 166 DIRTY $task->id
+modules/gallery/views/admin_maintenance.html.php 166 DIRTY $csrf
+modules/gallery/views/admin_maintenance.html.php 170 DIRTY $task->id
+modules/gallery/views/admin_maintenance.html.php 170 DIRTY $csrf
+modules/gallery/views/admin_maintenance.html.php 175 DIRTY $task->id
+modules/gallery/views/admin_maintenance.html.php 175 DIRTY $csrf
+modules/gallery/views/admin_maintenance.html.php 178 DIRTY $task->id
+modules/gallery/views/admin_maintenance.html.php 178 DIRTY $csrf
+modules/gallery/views/admin_maintenance_show_log.html.php 8 DIRTY $task->id
+modules/gallery/views/admin_maintenance_show_log.html.php 8 DIRTY $csrf
+modules/gallery/views/admin_maintenance_show_log.html.php 13 DIRTY $task->name
+modules/gallery/views/admin_maintenance_show_log.html.php 15 $task->get_log()
+modules/gallery/views/admin_maintenance_task.html.php 30 DIRTY $task->id
+modules/gallery/views/admin_maintenance_task.html.php 30 DIRTY $csrf
+modules/gallery/views/admin_maintenance_task.html.php 54 DIRTY $task->name
modules/gallery/views/admin_modules.html.php 19 DIRTY $i
modules/gallery/views/admin_modules.html.php 22 DIRTY $data
modules/gallery/views/admin_modules.html.php 22 DIRTY $module_name
@@ -201,10 +207,10 @@ modules/gallery/views/admin_themes_preview.html.php 4 DIRTY $info->na
modules/gallery/views/admin_themes_preview.html.php 7 DIRTY $url
modules/gallery/views/after_install.html.php 11 $user->name
modules/gallery/views/after_install.html.php 15 DIRTY $user->id
-modules/gallery/views/kohana_error_page.php 98 DIRTY $message
-modules/gallery/views/kohana_error_page.php 100 DIRTY $file
-modules/gallery/views/kohana_error_page.php 100 DIRTY $line
-modules/gallery/views/kohana_error_page.php 112 DIRTY $trace
+modules/gallery/views/kohana_error_page.php 102 DIRTY $message
+modules/gallery/views/kohana_error_page.php 104 DIRTY $file
+modules/gallery/views/kohana_error_page.php 104 DIRTY $line
+modules/gallery/views/kohana_error_page.php 116 DIRTY $trace
modules/gallery/views/kohana_profiler.php 32 DIRTY $profile->render()
modules/gallery/views/kohana_profiler.php 34 DIRTY $execution_time
modules/gallery/views/l10n_client.html.php 17 DIRTY $string
@@ -212,8 +218,8 @@ modules/gallery/views/l10n_client.html.php 19 DIRTY $string
modules/gallery/views/l10n_client.html.php 20 DIRTY $string
modules/gallery/views/l10n_client.html.php 22 DIRTY $string
modules/gallery/views/l10n_client.html.php 28 DIRTY $l10n_search_form
-modules/gallery/views/l10n_client.html.php 72 DIRTY $string_list
-modules/gallery/views/l10n_client.html.php 73 DIRTY $plural_forms
+modules/gallery/views/l10n_client.html.php 74 DIRTY $string_list
+modules/gallery/views/l10n_client.html.php 75 DIRTY $plural_forms
modules/gallery/views/move_browse.html.php 4 DIRTY $source->id
modules/gallery/views/move_browse.html.php 39 DIRTY $tree
modules/gallery/views/move_browse.html.php 42 DIRTY $source->id
@@ -231,7 +237,7 @@ modules/gallery/views/move_tree.html.php 15 DIRTY $child->i
modules/gallery/views/move_tree.html.php 15 $child->title
modules/gallery/views/movieplayer.html.php 2 DIRTY $item->file_url(true)
modules/gallery/views/movieplayer.html.php 2 DIRTY $attrs
-modules/gallery/views/movieplayer.html.php 4 DIRTY $attrs
+modules/gallery/views/movieplayer.html.php 5 DIRTY $attrs
modules/gallery/views/permissions_browse.html.php 15 DIRTY $csrf
modules/gallery/views/permissions_browse.html.php 37 DIRTY $parent->id
modules/gallery/views/permissions_browse.html.php 38 $parent->title
@@ -280,8 +286,8 @@ modules/gallery/views/simple_uploader.html.php 7 DIRTY $csrf
modules/gallery/views/simple_uploader.html.php 9 $item->title
modules/gallery/views/simple_uploader.html.php 29 $parent->title
modules/gallery/views/simple_uploader.html.php 31 $item->title
-modules/gallery/views/simple_uploader.html.php 85 DIRTY $item->id
-modules/gallery/views/simple_uploader.html.php 89 DIRTY $csrf
+modules/gallery/views/simple_uploader.html.php 86 DIRTY $item->id
+modules/gallery/views/simple_uploader.html.php 90 DIRTY $csrf
modules/gallery/views/upgrader.html.php 44 DIRTY $module->version
modules/gallery/views/upgrader.html.php 44 DIRTY $module->code_version
modules/gallery/views/upgrader.html.php 45 DIRTY $id
@@ -297,8 +303,8 @@ modules/info/views/info_block.html.php 10 $item->de
modules/info/views/info_block.html.php 16 $item->name
modules/info/views/info_block.html.php 22 DIRTY $item->captured
modules/info/views/info_block.html.php 29 DIRTY $item->owner->url
-modules/info/views/info_block.html.php 29 $item->owner->full_name
-modules/info/views/info_block.html.php 31 $item->owner->name
+modules/info/views/info_block.html.php 29 $item->owner->display_name()
+modules/info/views/info_block.html.php 31 $item->owner->display_name()
modules/notification/views/comment_published.html.php 4 $subject
modules/notification/views/comment_published.html.php 7 $subject
modules/notification/views/comment_published.html.php 11 $comment->text
@@ -320,12 +326,12 @@ modules/notification/views/item_deleted.html.php 18 DIRTY $item->pa
modules/notification/views/item_deleted.html.php 19 DIRTY $item->parent()->url(array(), true)
modules/notification/views/item_updated.html.php 4 $subject
modules/notification/views/item_updated.html.php 7 $subject
-modules/notification/views/item_updated.html.php 12 $new->title
-modules/notification/views/item_updated.html.php 15 $new->title
-modules/notification/views/item_updated.html.php 20 DIRTY $new->url(array(), true)
-modules/notification/views/item_updated.html.php 20 DIRTY $new->url(array(), true)
-modules/notification/views/item_updated.html.php 25 $new->description
-modules/notification/views/item_updated.html.php 30 $new->description
+modules/notification/views/item_updated.html.php 12 $item->title
+modules/notification/views/item_updated.html.php 15 $item->title
+modules/notification/views/item_updated.html.php 20 DIRTY $item->url(array(), true)
+modules/notification/views/item_updated.html.php 20 DIRTY $item->url(array(), true)
+modules/notification/views/item_updated.html.php 25 $item->description
+modules/notification/views/item_updated.html.php 30 $item->description
modules/organize/views/organize.html.php 10 DIRTY $item->id
modules/organize/views/organize.html.php 12 DIRTY $csrf
modules/organize/views/organize.html.php 13 DIRTY $csrf
@@ -417,16 +423,17 @@ modules/server_add/views/admin_server_add.html.php 14 DIRTY $csrf
modules/server_add/views/admin_server_add.html.php 15 DIRTY $id
modules/server_add/views/admin_server_add.html.php 19 DIRTY $path
modules/server_add/views/admin_server_add.html.php 24 DIRTY $form
-modules/server_add/views/server_add_tree.html.php 4 DIRTY $tree_id
-modules/server_add/views/server_add_tree.html.php 6 DIRTY $file_info
-modules/server_add/views/server_add_tree.html.php 10 $file_info
-modules/server_add/views/server_add_tree.html.php 10 DIRTY $checked
-modules/server_add/views/server_add_tree.html.php 10 $file
-modules/server_add/views/server_add_tree_dialog.html.php 10 $album_title
-modules/server_add/views/server_add_tree_dialog.html.php 15 $parent->title
-modules/server_add/views/server_add_tree_dialog.html.php 17 $album_title
-modules/server_add/views/server_add_tree_dialog.html.php 20 DIRTY $action
-modules/server_add/views/server_add_tree_dialog.html.php 22 DIRTY $tree
+modules/server_add/views/server_add_tree.html.php 12 DIRTY $dir
+modules/server_add/views/server_add_tree.html.php 13 DIRTY $dir
+modules/server_add/views/server_add_tree.html.php 20 DIRTY $file
+modules/server_add/views/server_add_tree.html.php 25 DIRTY $file
+modules/server_add/views/server_add_tree.html.php 27 $file
+modules/server_add/views/server_add_tree_dialog.html.php 4 DIRTY $item->id
+modules/server_add/views/server_add_tree_dialog.html.php 4 DIRTY $csrf
+modules/server_add/views/server_add_tree_dialog.html.php 8 $item->title
+modules/server_add/views/server_add_tree_dialog.html.php 14 $parent->title
+modules/server_add/views/server_add_tree_dialog.html.php 18 $item->title
+modules/server_add/views/server_add_tree_dialog.html.php 23 DIRTY $tree
modules/tag/views/admin_tags.html.php 13 DIRTY $csrf
modules/tag/views/admin_tags.html.php 27 DIRTY $tags->count()
modules/tag/views/admin_tags.html.php 35 DIRTY $current_letter
@@ -435,8 +442,8 @@ modules/tag/views/admin_tags.html.php 50 DIRTY $tag->id
modules/tag/views/admin_tags.html.php 50 $tag->name
modules/tag/views/admin_tags.html.php 51 DIRTY $tag->count
modules/tag/views/admin_tags.html.php 52 DIRTY $tag->id
-modules/tag/views/tag_block.html.php 3 DIRTY $cloud
-modules/tag/views/tag_block.html.php 5 DIRTY $form
+modules/tag/views/tag_block.html.php 15 DIRTY $cloud
+modules/tag/views/tag_block.html.php 17 DIRTY $form
modules/tag/views/tag_cloud.html.php 4 DIRTY $tag->count
modules/tag/views/tag_cloud.html.php 4 DIRTY $max_count
modules/tag/views/tag_cloud.html.php 5 DIRTY $tag->count
@@ -447,7 +454,7 @@ modules/user/views/admin_users.html.php 36 DIRTY $csrf
modules/user/views/admin_users.html.php 67 DIRTY $user->id
modules/user/views/admin_users.html.php 67 DIRTY $user->admin
modules/user/views/admin_users.html.php 68 DIRTY $user->id
-modules/user/views/admin_users.html.php 69 DIRTY $user->avatar_url(20, $theme->theme_url("images/avatar.jpg", true))
+modules/user/views/admin_users.html.php 69 DIRTY $user->avatar_url(20, $theme->url("images/avatar.jpg", true))
modules/user/views/admin_users.html.php 71 $user->name
modules/user/views/admin_users.html.php 74 $user->name
modules/user/views/admin_users.html.php 77 $user->full_name
@@ -468,9 +475,7 @@ modules/user/views/admin_users_group.html.php 22 DIRTY $group->i
modules/user/views/admin_users_group.html.php 25 $user->name
modules/user/views/admin_users_group.html.php 25 $group->name
modules/user/views/login.html.php 12 DIRTY $user->id
-modules/user/views/login.html.php 15 $user->full_name
-modules/user/views/login.html.php 15 $user->name
-modules/user/views/login.html.php 15 $user->full_name
+modules/user/views/login.html.php 15 $user->display_name()
modules/user/views/login.html.php 18 DIRTY $csrf
modules/user/views/login_ajax.html.php 37 DIRTY $form
modules/user/views/reset_password.html.php 9 $user->full_name
@@ -481,34 +486,34 @@ modules/watermark/views/admin_watermarks.html.php 19 DIRTY $width
modules/watermark/views/admin_watermarks.html.php 19 DIRTY $height
modules/watermark/views/admin_watermarks.html.php 19 DIRTY $url
modules/watermark/views/admin_watermarks.html.php 21 DIRTY $position
-themes/admin_default/views/admin.html.php 10 DIRTY $theme->css("lib/yui/reset-fonts-grids.css")
-themes/admin_default/views/admin.html.php 11 DIRTY $theme->css("lib/themeroller/ui.base.css")
-themes/admin_default/views/admin.html.php 12 DIRTY $theme->css("lib/superfish/css/superfish.css")
-themes/admin_default/views/admin.html.php 13 DIRTY $theme->css("themes/default/css/screen.css")
-themes/admin_default/views/admin.html.php 14 DIRTY $theme->theme_css("css/screen.css")
-themes/admin_default/views/admin.html.php 16 DIRTY $theme->theme_url("css/fix-ie.css")
-themes/admin_default/views/admin.html.php 20 DIRTY $theme->script("lib/jquery.js")
-themes/admin_default/views/admin.html.php 21 DIRTY $theme->script("lib/jquery.form.js")
-themes/admin_default/views/admin.html.php 22 DIRTY $theme->script("lib/jquery-ui.js")
-themes/admin_default/views/admin.html.php 23 DIRTY $theme->script("lib/gallery.common.js")
-themes/admin_default/views/admin.html.php 28 DIRTY $theme->script("lib/gallery.dialog.js")
-themes/admin_default/views/admin.html.php 29 DIRTY $theme->script("lib/superfish/js/superfish.js")
-themes/admin_default/views/admin.html.php 30 DIRTY $theme->theme_script("js/jquery.dropshadow.js")
-themes/admin_default/views/admin.html.php 31 DIRTY $theme->theme_script("js/ui.init.js")
+themes/admin_default/views/admin.html.php 10 DIRTY $theme->css("yui/reset-fonts-grids.css")
+themes/admin_default/views/admin.html.php 11 DIRTY $theme->css("themeroller/ui.base.css")
+themes/admin_default/views/admin.html.php 12 DIRTY $theme->css("superfish/css/superfish.css")
+themes/admin_default/views/admin.html.php 13 DIRTY $theme->css("screen.css")
+themes/admin_default/views/admin.html.php 14 DIRTY $theme->css("admin_screen.css")
+themes/admin_default/views/admin.html.php 16 DIRTY $theme->url("fix-ie.css")
+themes/admin_default/views/admin.html.php 20 DIRTY $theme->script("jquery.js")
+themes/admin_default/views/admin.html.php 21 DIRTY $theme->script("jquery.form.js")
+themes/admin_default/views/admin.html.php 22 DIRTY $theme->script("jquery-ui.js")
+themes/admin_default/views/admin.html.php 23 DIRTY $theme->script("gallery.common.js")
+themes/admin_default/views/admin.html.php 28 DIRTY $theme->script("gallery.dialog.js")
+themes/admin_default/views/admin.html.php 29 DIRTY $theme->script("superfish/js/superfish.js")
+themes/admin_default/views/admin.html.php 30 DIRTY $theme->script("jquery.dropshadow.js")
+themes/admin_default/views/admin.html.php 31 DIRTY $theme->script("ui.init.js")
themes/admin_default/views/admin.html.php 33 DIRTY $theme->admin_head()
themes/admin_default/views/admin.html.php 36 DIRTY $theme->body_attributes()
themes/admin_default/views/admin.html.php 37 DIRTY $theme->admin_page_top()
themes/admin_default/views/admin.html.php 43 DIRTY $theme->site_status()
themes/admin_default/views/admin.html.php 45 DIRTY $theme->admin_header_top()
themes/admin_default/views/admin.html.php 48 DIRTY $csrf
-themes/admin_default/views/admin.html.php 52 DIRTY $theme->admin_menu()
-themes/admin_default/views/admin.html.php 54 DIRTY $theme->admin_header_bottom()
-themes/admin_default/views/admin.html.php 60 DIRTY $theme->messages()
-themes/admin_default/views/admin.html.php 61 DIRTY $content
-themes/admin_default/views/admin.html.php 67 DIRTY $sidebar
-themes/admin_default/views/admin.html.php 72 DIRTY $theme->admin_footer()
-themes/admin_default/views/admin.html.php 74 DIRTY $theme->admin_credits()
-themes/admin_default/views/admin.html.php 78 DIRTY $theme->admin_page_bottom()
+themes/admin_default/views/admin.html.php 54 DIRTY $theme->admin_menu()
+themes/admin_default/views/admin.html.php 56 DIRTY $theme->admin_header_bottom()
+themes/admin_default/views/admin.html.php 62 DIRTY $theme->messages()
+themes/admin_default/views/admin.html.php 63 DIRTY $content
+themes/admin_default/views/admin.html.php 69 DIRTY $sidebar
+themes/admin_default/views/admin.html.php 74 DIRTY $theme->admin_footer()
+themes/admin_default/views/admin.html.php 76 DIRTY $theme->admin_credits()
+themes/admin_default/views/admin.html.php 80 DIRTY $theme->admin_page_bottom()
themes/admin_default/views/block.html.php 2 DIRTY $id
themes/admin_default/views/block.html.php 2 DIRTY $css_id
themes/admin_default/views/block.html.php 5 DIRTY $id
@@ -544,7 +549,7 @@ themes/default/views/block.html.php 3 DIRTY $css_id
themes/default/views/block.html.php 4 DIRTY $title
themes/default/views/block.html.php 6 DIRTY $content
themes/default/views/dynamic.html.php 4 DIRTY $theme->dynamic_top()
-themes/default/views/dynamic.html.php 6 $tag->name
+themes/default/views/dynamic.html.php 6 $title
themes/default/views/dynamic.html.php 11 DIRTY $child->is_album()
themes/default/views/dynamic.html.php 12 DIRTY $theme->thumb_top($child)
themes/default/views/dynamic.html.php 13 DIRTY $child->url()
@@ -560,11 +565,11 @@ themes/default/views/dynamic.html.php 29 DIRTY $theme->p
themes/default/views/footer.html.php 2 DIRTY $theme->footer()
themes/default/views/footer.html.php 4 DIRTY $footer_text
themes/default/views/footer.html.php 9 DIRTY $theme->credits()
-themes/default/views/header.html.php 2 DIRTY $theme->header_top()
-themes/default/views/header.html.php 4 DIRTY $header_text
-themes/default/views/header.html.php 7 DIRTY $theme->theme_url("images/logo.png")
+themes/default/views/header.html.php 3 DIRTY $theme->header_top()
+themes/default/views/header.html.php 5 DIRTY $header_text
+themes/default/views/header.html.php 8 DIRTY $theme->url("images/logo.png")
themes/default/views/header.html.php 12 DIRTY $theme->site_menu()
-themes/default/views/header.html.php 15 DIRTY $theme->header_bottom()
+themes/default/views/header.html.php 14 DIRTY $theme->header_bottom()
themes/default/views/header.html.php 21 DIRTY $parent->id
themes/default/views/header.html.php 21 DIRTY $item->id
themes/default/views/header.html.php 22 $parent->title
@@ -583,27 +588,27 @@ themes/default/views/page.html.php 13 $theme->i
themes/default/views/page.html.php 15 $theme->item()->title
themes/default/views/page.html.php 17 $theme->item()->title
themes/default/views/page.html.php 20 $theme->tag()->name
-themes/default/views/page.html.php 26 DIRTY $theme->theme_url("images/favicon.ico")
-themes/default/views/page.html.php 27 DIRTY $theme->css("lib/yui/reset-fonts-grids.css")
-themes/default/views/page.html.php 28 DIRTY $theme->css("lib/superfish/css/superfish.css")
-themes/default/views/page.html.php 29 DIRTY $theme->css("lib/themeroller/ui.base.css")
-themes/default/views/page.html.php 30 DIRTY $theme->theme_css("css/screen.css")
-themes/default/views/page.html.php 32 DIRTY $theme->theme_url("css/fix-ie.css")
+themes/default/views/page.html.php 26 DIRTY $theme->url("images/favicon.ico")
+themes/default/views/page.html.php 27 DIRTY $theme->css("yui/reset-fonts-grids.css")
+themes/default/views/page.html.php 28 DIRTY $theme->css("superfish/css/superfish.css")
+themes/default/views/page.html.php 29 DIRTY $theme->css("themeroller/ui.base.css")
+themes/default/views/page.html.php 30 DIRTY $theme->css("screen.css")
+themes/default/views/page.html.php 32 DIRTY $theme->url("css/fix-ie.css")
themes/default/views/page.html.php 41 DIRTY $new_width
themes/default/views/page.html.php 42 DIRTY $new_height
themes/default/views/page.html.php 43 DIRTY $thumb_proportion
-themes/default/views/page.html.php 48 DIRTY $theme->script("lib/jquery.js")
-themes/default/views/page.html.php 49 DIRTY $theme->script("lib/jquery.form.js")
-themes/default/views/page.html.php 50 DIRTY $theme->script("lib/jquery-ui.js")
-themes/default/views/page.html.php 51 DIRTY $theme->script("lib/gallery.common.js")
-themes/default/views/page.html.php 56 DIRTY $theme->script("lib/gallery.dialog.js")
-themes/default/views/page.html.php 57 DIRTY $theme->script("lib/gallery.form.js")
-themes/default/views/page.html.php 58 DIRTY $theme->script("lib/superfish/js/superfish.js")
-themes/default/views/page.html.php 59 DIRTY $theme->script("lib/jquery.localscroll.js")
-themes/default/views/page.html.php 60 DIRTY $theme->theme_script("js/ui.init.js")
-themes/default/views/page.html.php 64 DIRTY $theme->script("lib/jquery.scrollTo.js")
-themes/default/views/page.html.php 65 DIRTY $theme->script("lib/gallery.show_full_size.js")
-themes/default/views/page.html.php 67 DIRTY $theme->script("lib/flowplayer.js")
+themes/default/views/page.html.php 48 DIRTY $theme->script("jquery.js")
+themes/default/views/page.html.php 49 DIRTY $theme->script("jquery.form.js")
+themes/default/views/page.html.php 50 DIRTY $theme->script("jquery-ui.js")
+themes/default/views/page.html.php 51 DIRTY $theme->script("gallery.common.js")
+themes/default/views/page.html.php 56 DIRTY $theme->script("gallery.dialog.js")
+themes/default/views/page.html.php 57 DIRTY $theme->script("gallery.form.js")
+themes/default/views/page.html.php 58 DIRTY $theme->script("superfish/js/superfish.js")
+themes/default/views/page.html.php 59 DIRTY $theme->script("jquery.localscroll.js")
+themes/default/views/page.html.php 60 DIRTY $theme->script("ui.init.js")
+themes/default/views/page.html.php 64 DIRTY $theme->script("jquery.scrollTo.js")
+themes/default/views/page.html.php 65 DIRTY $theme->script("gallery.show_full_size.js")
+themes/default/views/page.html.php 67 DIRTY $theme->script("flowplayer.js")
themes/default/views/page.html.php 70 DIRTY $theme->head()
themes/default/views/page.html.php 73 DIRTY $theme->body_attributes()
themes/default/views/page.html.php 74 DIRTY $theme->page_top()
diff --git a/modules/gallery/views/admin_block_platform.html.php b/modules/gallery/views/admin_block_platform.html.php
index 6b79f047..f27b9e7a 100644
--- a/modules/gallery/views/admin_block_platform.html.php
+++ b/modules/gallery/views/admin_block_platform.html.php
@@ -1,7 +1,10 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<ul>
<li>
- <?= t("Operating System: %operating_system", array("operating_system" => PHP_OS)) ?>
+ <?= t("Host name: %host_name", array("host_name" => php_uname("n"))) ?>
+ </li>
+ <li>
+ <?= t("Operating System: %os %version", array("os" => php_uname("s"), "version" => php_uname("r"))) ?>
</li>
<li>
<?= t("Apache: %apache_version", array("apache_version" => function_exists("apache_get_version") ? apache_get_version() : t("Unknown"))) ?>
diff --git a/modules/gallery/views/admin_block_stats.html.php b/modules/gallery/views/admin_block_stats.html.php
index 395ed71d..1dec8ccd 100644
--- a/modules/gallery/views/admin_block_stats.html.php
+++ b/modules/gallery/views/admin_block_stats.html.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<ul>
<li>
- <?= t("Version: %version", array("version" => module::get_var("gallery", "version"))) ?>
+ <?= t("Version: %version", array("version" => gallery::VERSION)) ?>
</li>
<li>
<?= t("Albums: %count", array("count" => $album_count)) ?>
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..aa9ee67c 100644
--- a/modules/gallery/views/admin_graphics_gd.html.php
+++ b/modules/gallery/views/admin_graphics_gd.html.php
@@ -1,23 +1,26 @@
<?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')): ?>
+ <? if ($tk->installed && $tk->rotate): ?>
<p class="gSuccess">
- <?= t("You have GD version %version.", array("version" => $tk->gd["GD Version"])) ?>
+ <?= t("You have GD version %version.", array("version" => $tk->version)) ?>
</p>
<p>
<a class="gButtonLink ui-state-default ui-corner-all"><?= t("Activate GD") ?></a>
</p>
- <? elseif ($tk->gd["GD Version"]): ?>
+ <? elseif ($tk->installed): ?>
+
+ <? if ($tk->error): ?>
<p class="gWarning">
- <?= t("You have GD version %version, but it lacks image rotation.",
- array("version" => $tk->gd["GD Version"])) ?>
+ <?= $tk->error ?>
</p>
+ <? endif ?>
+
<p>
<a class="gButtonLink ui-state-default ui-corner-all"><?= t("Activate GD") ?></a>
</p>
diff --git a/modules/gallery/views/admin_graphics_graphicsmagick.html.php b/modules/gallery/views/admin_graphics_graphicsmagick.html.php
index e2cd0777..bf3ad339 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" ?>">
+<div id="graphicsmagick" class="gBlock<?= $is_active ? " gSelected" : "" ?><?= $tk->installed ? " gInstalledToolkit" : " gUnavailable" ?>">
<h3> <?= t("GraphicsMagick") ?> </h3>
<img class="logo" width="107" height="76" src="<?= url::file("modules/gallery/images/graphicsmagick.png"); ?>" alt="<? t("Visit the GraphicsMagick project site") ?>" />
<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): ?>
+ <? if ($tk->installed): ?>
<p class="gSuccess">
- <?= t("GraphicsMagick is available in %path", array("path" => $tk->graphicsmagick)) ?>
+ <?= t("GraphicsMagick version %version is available in %dir", array("version" => $tk->version, "dir" => $tk->dir)) ?>
</p>
<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 class="gWarning">
+ <?= $tk->error ?>
</p>
<? endif ?>
</div>
diff --git a/modules/gallery/views/admin_graphics_imagemagick.html.php b/modules/gallery/views/admin_graphics_imagemagick.html.php
index 081ddc15..b8f7ffb8 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" ?>">
+<div id="imagemagick" class="gBlock<?= $is_active ? " gSelected" : "" ?><?= $tk->installed ? " gInstalledToolkit" : " gUnavailable" ?>">
<h3> <?= t("ImageMagick") ?> </h3>
<img class="logo" width="114" height="118" src="<?= url::file("modules/gallery/images/imagemagick.jpg"); ?>" alt="<? t("Visit the ImageMagick project site") ?>" />
<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): ?>
+ <? if ($tk->installed): ?>
<p class="gSuccess">
- <?= t("ImageMagick is available in %path", array("path" => $tk->imagemagick)) ?>
+ <?= t("ImageMagick version %version is available in %dir", array("version" => $tk->version, "dir" => $tk->dir)) ?>
</p>
<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.") ?>
+ <? elseif ($tk->error): ?>
+ <p class="gWarning">
+ <?= $tk->error ?>
</p>
<? endif ?>
</div>
diff --git a/modules/gallery/views/admin_graphics_none.html.php b/modules/gallery/views/admin_graphics_none.html.php
index 5306a70d..be2a580d 100644
--- a/modules/gallery/views/admin_graphics_none.html.php
+++ b/modules/gallery/views/admin_graphics_none.html.php
@@ -2,6 +2,6 @@
<div id="none" class="gBlock">
<h3 class="gWarning"> <?= 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_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php
index eecc045c..450eb754 100644
--- a/modules/gallery/views/admin_maintenance.html.php
+++ b/modules/gallery/views/admin_maintenance.html.php
@@ -29,7 +29,7 @@
</td>
<td>
<a href="<?= url::site("admin/maintenance/start/$task->callback?csrf=$csrf") ?>"
- class="gDialogLink">
+ class="gDialogLink gButtonLink ui-icon-left ui-state-default ui-corner-all">
<?= t("run") ?>
</a>
</td>
@@ -79,7 +79,7 @@
<? if ($task->state == "cancelled"): ?>
<?= t("Cancelled") ?>
<? endif ?>
- <?= t("Done") ?>
+ <?= t("Close") ?>
<? elseif ($task->state == "stalled"): ?>
<?= t("Stalled") ?>
<? else: ?>
@@ -94,11 +94,13 @@
</td>
<td>
<? if ($task->state == "stalled"): ?>
- <a class="gDialogLink" href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>">
+ <a class="gDialogLink gButtonLink ui-icon-left ui-state-default ui-corner-all"
+ href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>">
<?= t("resume") ?>
</a>
<? endif ?>
- <a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>">
+ <a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>"
+ class="gButtonLink ui-icon-left ui-state-default ui-corner-all right">
<?= t("cancel") ?>
</a>
</td>
@@ -161,22 +163,23 @@
</td>
<td>
<? if ($task->done): ?>
- <a href="<?= url::site("admin/maintenance/remove/$task->id?csrf=$csrf") ?>">
+ <a href="<?= url::site("admin/maintenance/remove/$task->id?csrf=$csrf") ?>" class="gButtonLink ui-state-default ui-corner-all">
<?= t("remove") ?>
</a>
<? if ($task->get_log()): ?>
- <a class="gDialogLink" href="<?= url::site("admin/maintenance/show_log/$task->id?csrf=$csrf") ?>">
+ <a href="<?= url::site("admin/maintenance/show_log/$task->id?csrf=$csrf") ?>" class="gDialogLink gButtonLink ui-state-default ui-corner-all">
<?= t("browse log") ?>
</a>
<? endif ?>
<? else: ?>
- <a class="gDialogLink" href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>">
+ <a href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>" class="gDialogLink gButtonLink" ui-state-default ui-corner-all>
<?= t("resume") ?>
</a>
- <a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>">
+ <a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>" class="gButtonLink ui-state-default ui-corner-all">
<?= t("cancel") ?>
</a>
<? endif ?>
+ </ul>
</td>
</tr>
<? endforeach ?>
diff --git a/modules/gallery/views/admin_maintenance_task.html.php b/modules/gallery/views/admin_maintenance_task.html.php
index d9aecc60..0eb0b38c 100644
--- a/modules/gallery/views/admin_maintenance_task.html.php
+++ b/modules/gallery/views/admin_maintenance_task.html.php
@@ -1,11 +1,39 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<script type="text/javascript">
+ var target_value;
+ var animation = null;
+ var delta = 1;
+ animate_progress_bar = function() {
+ var current_value = Number($(".gProgressBar div").css("width").replace("%", ""));
+ if (target_value > current_value) {
+ // speed up
+ delta = Math.min(delta + 0.04, 3);
+ } else {
+ // slow down
+ delta = Math.max(delta - 0.05, 1);
+ }
+
+ if (target_value == 100) {
+ $(".gProgressBar").progressbar("value", 100);
+ } else if (current_value != target_value || delta != 1) {
+ var new_value = Math.min(current_value + delta, target_value);
+ $(".gProgressBar").progressbar("value", new_value);
+ animation = setTimeout(function() { animate_progress_bar(target_value); }, 100);
+ } else {
+ animation = null;
+ delta = 1;
+ }
+ }
+
update = function() {
$.ajax({
url: "<?= url::site("admin/maintenance/run/$task->id?csrf=$csrf") ?>",
dataType: "json",
success: function(data) {
- $(".gProgressBar").progressbar("value", data.task.percent_complete);
+ target_value = data.task.percent_complete;
+ if (!animation) {
+ animate_progress_bar();
+ }
$("#gStatus").html("" + data.task.status);
if (data.task.done) {
$("#gPauseButton").hide();
@@ -30,6 +58,6 @@
</div>
<div>
<button id="gPauseButton" class="ui-state-default ui-corner-all" onclick="dismiss()"><?= t("Pause") ?></button>
- <button id="gDoneButton" class="ui-state-default ui-corner-all" style="display: none" onclick="dismiss()"><?= t("Done") ?></button>
+ <button id="gDoneButton" class="ui-state-default ui-corner-all" style="display: none" onclick="dismiss()"><?= t("Close") ?></button>
</div>
</div>
diff --git a/modules/gallery/views/after_install.html.php b/modules/gallery/views/after_install.html.php
index d6ba8e7c..bfce46f0 100644
--- a/modules/gallery/views/after_install.html.php
+++ b/modules/gallery/views/after_install.html.php
@@ -16,12 +16,12 @@
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>
<p>
- <?= t("Want to learn more? The <a href=\"%url\">Gallery website</a> has news and information about Gallery Project and community.", array("url" => "http://gallery.menalto.com")) ?>
+ <?= t("Want to learn more? The <a href=\"%url\">Gallery website</a> has news and information about the Gallery project and community.", array("url" => "http://gallery.menalto.com")) ?>
</p>
<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/form.html.php b/modules/gallery/views/form.html.php
index ec2a56a9..730d77cb 100644
--- a/modules/gallery/views/form.html.php
+++ b/modules/gallery/views/form.html.php
@@ -40,6 +40,8 @@ if (!function_exists("DrawForm")) {
print "$prefix {$hidden->render()}\n";
}
print "$prefix</fieldset>\n";
+ } else if ($input->type == 'script') {
+ print $input->render();
} else {
if ($input->error_messages()) {
print "$prefix<li class=\"gError\">\n";
diff --git a/modules/gallery/views/l10n_client.html.php b/modules/gallery/views/l10n_client.html.php
index c0cbbfa2..c73719ca 100644
--- a/modules/gallery/views/l10n_client.html.php
+++ b/modules/gallery/views/l10n_client.html.php
@@ -9,7 +9,7 @@
</h2></div>
<div class="label source"><h2><?= t("Source") ?></div>
<div class="label translation"><h2><?= t("Translation to %language",
- array("language" => locale::display_name())) ?></h2></div>
+ array("language" => locales::display_name())) ?></h2></div>
</div>
<div id="l10n-client-string-select">
<ul class="string-list">
diff --git a/modules/gallery/views/movieplayer.html.php b/modules/gallery/views/movieplayer.html.php
index e8cabd31..e9783eb8 100644
--- a/modules/gallery/views/movieplayer.html.php
+++ b/modules/gallery/views/movieplayer.html.php
@@ -1,15 +1,22 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<?= html::anchor($item->file_url(true), "", $attrs) ?>
<script>
- flowplayer("<?= $attrs["id"] ?>", "<?= url::abs_file("lib/flowplayer.swf") ?>", {
- plugins: {
- h264streaming: {
- url: "<?= url::abs_file("lib/flowplayer.h264streaming.swf") ?>"
- },
- controls: {
- autoHide: 'always',
- hideDelay: 2000
+ flowplayer(
+ "<?= $attrs["id"] ?>",
+ {
+ src: "<?= url::abs_file("lib/flowplayer.swf") ?>",
+ wmode: "transparent"
+ },
+ {
+ plugins: {
+ h264streaming: {
+ url: "<?= url::abs_file("lib/flowplayer.h264streaming.swf") ?>"
+ },
+ controls: {
+ autoHide: 'always',
+ hideDelay: 2000
+ }
}
}
- })
+ )
</script>
diff --git a/modules/gallery/views/permissions_form.html.php b/modules/gallery/views/permissions_form.html.php
index 0f60070a..ee5e3a24 100644
--- a/modules/gallery/views/permissions_form.html.php
+++ b/modules/gallery/views/permissions_form.html.php
@@ -26,7 +26,7 @@
</a>
</td>
<? else: ?>
- <? if ($intent === null): ?>
+ <? if ($intent === access::INHERIT): ?>
<? if ($allowed): ?>
<td class="gAllowed">
<a href="javascript:set('allow',<?= $group->id ?>,<?= $permission->id ?>,<?= $item->id ?>)"
diff --git a/modules/gallery/views/quick_pane.html.php b/modules/gallery/views/quick_pane.html.php
deleted file mode 100644
index eabf4a67..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 id="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 56b1c656..38ac518c 100644
--- a/modules/gallery/views/simple_uploader.html.php
+++ b/modules/gallery/views/simple_uploader.html.php
@@ -32,8 +32,9 @@
</ul>
<p>
- <?= t("Upload Queue") ?>
- <span id="gUploadQueueInfo"></span>
+ <span id="gUploadQueueInfo">
+ <?= t("Upload Queue") ?>
+ </span>
<a id="gUploadCancel" title="<?= t("Cancel all the pending uploads") ?>" onclick="swfu.cancelQueue();"><?= t("cancel") ?></a>
</p>
<div id="gAddPhotosCanvas" style="text-align: center;">
@@ -51,7 +52,7 @@
<!-- Proxy the done request back to our form, since its been ajaxified -->
<button class="ui-state-default ui-corner-all" onclick="$('#gAddPhotosForm').submit()">
- <?= t("Done") ?>
+ <?= t("Close") ?>
</button>
</div>
@@ -181,9 +182,7 @@
function file_dialog_complete(num_files_selected, num_files_queued) {
if (num_files_selected > 0) {
$("#gUploadCancel").show();
- var stats = this.getStats();
- $("#gUploadQueueInfo").text("(completed " + stats.successful_uploads +
- " of " + (stats.files_queued + stats.successful_uploads + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")");
+ $("#gUploadQueueInfo").text(get_completed_status_msg(this.getStats()));
}
// Auto start the upload
@@ -254,13 +253,20 @@
function upload_complete(file) {
var stats = this.getStats();
- $("#gUploadQueueInfo").text("(completed " + stats.successful_uploads +
- " of " + (stats.files_queued + stats.successful_uploads + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")");
+ $("#gUploadQueueInfo").text(get_completed_status_msg(stats));
if (stats.files_queued === 0) {
$("#gUploadCancel").hide();
}
}
+ function get_completed_status_msg(stats) {
+ var msg = "<?= t("Upload Queue (completed %completed of %total)", array("completed" => "__COMPLETED__", "total" => "__TOTAL__")) ?>";
+ msg = msg.replace("__COMPLETED__", stats.successful_uploads);
+ msg = msg.replace("__TOTAL__", stats.files_queued + stats.successful_uploads +
+ stats.upload_errors + stats.upload_cancelled + stats.queue_errors);
+ return msg;
+ }
+
// This event comes from the Queue Plugin
function queue_complete(num_files_uploaded) {
var status_msg = "<?= t("Uploaded: __COUNT__") ?>";