diff options
Diffstat (limited to 'modules/gallery/helpers')
| -rw-r--r-- | modules/gallery/helpers/MY_url.php | 2 | ||||
| -rw-r--r-- | modules/gallery/helpers/gallery_block.php | 5 | ||||
| -rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 475 | ||||
| -rw-r--r-- | modules/gallery/helpers/gallery_menu.php | 6 | ||||
| -rw-r--r-- | modules/gallery/helpers/gallery_quick.php | 144 | ||||
| -rw-r--r-- | modules/gallery/helpers/gallery_theme.php | 14 | ||||
| -rw-r--r-- | modules/gallery/helpers/graphics.php | 9 | ||||
| -rw-r--r-- | modules/gallery/helpers/l10n_scanner.php | 4 | ||||
| -rw-r--r-- | modules/gallery/helpers/module.php | 34 | ||||
| -rw-r--r-- | modules/gallery/helpers/movie.php | 9 | ||||
| -rw-r--r-- | modules/gallery/helpers/theme.php | 2 | 
11 files changed, 470 insertions, 234 deletions
| diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index 7bee70ca..c4967c52 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -58,7 +58,7 @@ class url extends url_Core {     * Return the item that the uri is referencing     */    static function get_item_from_uri($uri) { -    $current_uri = html_entity_decode($uri); +    $current_uri = html_entity_decode($uri, ENT_QUOTES);      $item = ORM::factory("item")->where("relative_path_cache", $current_uri)->find();      if (!$item->loaded) {        // It's possible that the relative path cache for the item we're looking for is out of date, diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index c3837f54..a10f2bbf 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -49,8 +49,9 @@ class gallery_block_Core {        $block->css_id = "gLogEntries";        $block->title = t("Log Entries");        $block->content = new View("admin_block_log_entries.html"); -      $block->content->entries = ORM::factory("log")->orderby("timestamp", "DESC")->find_all(5); -        break; +      $block->content->entries = ORM::factory("log") +        ->orderby(array("timestamp" => "DESC", "id" => "DESC"))->find_all(5); +      break;      case "stats":        $block->css_id = "gStats"; diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index b2be63be..0e5d29b9 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -18,248 +18,289 @@   * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.   */  class gallery_installer { -  static function install($initial_install=false) { +  static function install() {      $db = Database::instance(); -    if ($initial_install) { -      $version = 0; -    } else { -      $version = module::get_version("gallery"); -    } +    $db->query("CREATE TABLE {access_caches} ( +                 `id` int(9) NOT NULL auto_increment, +                 `item_id` int(9), +                 PRIMARY KEY (`id`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -    if ($version == 0) { -      $db->query("CREATE TABLE {access_caches} ( -                   `id` int(9) NOT NULL auto_increment, -                   `item_id` int(9), -                   PRIMARY KEY (`id`)) -                 ENGINE=InnoDB 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;"); -      $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;"); +    $db->query("CREATE TABLE {caches} ( +                `id` int(9) NOT NULL auto_increment, +                `key` varchar(255) NOT NULL, +                `tags` varchar(255), +                `expiration` int(9) NOT NULL, +                `cache` longblob, +                PRIMARY KEY (`id`), +                KEY (`tags`)) +                ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      $db->query("CREATE TABLE {graphics_rules} ( -                   `id` int(9) NOT NULL auto_increment, -                   `active` BOOLEAN default 0, -                   `args` varchar(255) default NULL, -                   `module_name` varchar(64) NOT NULL, -                   `operation` varchar(64) NOT NULL, -                   `priority` int(9) NOT NULL, -                   `target`  varchar(32) NOT NULL, -                   PRIMARY KEY (`id`)) -                 ENGINE=InnoDB DEFAULT CHARSET=utf8;"); +    $db->query("CREATE TABLE {graphics_rules} ( +                 `id` int(9) NOT NULL auto_increment, +                 `active` BOOLEAN default 0, +                 `args` varchar(255) default NULL, +                 `module_name` varchar(64) NOT NULL, +                 `operation` varchar(64) NOT NULL, +                 `priority` int(9) NOT NULL, +                 `target`  varchar(32) NOT NULL, +                 PRIMARY KEY (`id`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      $db->query("CREATE TABLE {items} ( -                   `id` int(9) NOT NULL auto_increment, -                   `album_cover_item_id` int(9) default NULL, -                   `captured` int(9) default NULL, -                   `created` int(9) default NULL, -                   `description` varchar(2048) default NULL, -                   `height` int(9) default NULL, -                   `left` int(9) NOT NULL, -                   `level` int(9) NOT NULL, -                   `mime_type` varchar(64) default NULL, -                   `name` varchar(255) default NULL, -                   `owner_id` int(9) default NULL, -                   `parent_id` int(9) NOT NULL, -                   `rand_key` float default NULL, -                   `relative_path_cache` varchar(255) default NULL, -                   `resize_dirty` boolean default 1, -                   `resize_height` int(9) default NULL, -                   `resize_width` int(9) default NULL, -                   `right` int(9) NOT NULL, -                   `sort_column` varchar(64) default NULL, -                   `sort_order` char(4) default 'ASC', -                   `thumb_dirty` boolean default 1, -                   `thumb_height` int(9) default NULL, -                   `thumb_width` int(9) default NULL, -                   `title` varchar(255) default NULL, -                   `type` varchar(32) NOT NULL, -                   `updated` int(9) default NULL, -                   `view_count` int(9) default 0, -                   `weight` int(9) NOT NULL default 0, -                   `width` int(9) default NULL, -                   PRIMARY KEY (`id`), -                   KEY `parent_id` (`parent_id`), -                   KEY `type` (`type`), -                   KEY `random` (`rand_key`)) -                 ENGINE=InnoDB DEFAULT CHARSET=utf8;"); +    $db->query("CREATE TABLE {incoming_translations} ( +                 `id` int(9) NOT NULL auto_increment, +                 `key` char(32) NOT NULL, +                 `locale` char(10) NOT NULL, +                 `message` text NOT NULL, +                 `revision` int(9) DEFAULT NULL, +                 `translation` text, +                 PRIMARY KEY (`id`), +                 UNIQUE KEY(`key`, `locale`), +                 KEY `locale_key` (`locale`, `key`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      $db->query("CREATE TABLE {logs} ( -                   `id` int(9) NOT NULL auto_increment, -                   `category` varchar(64) default NULL, -                   `html` varchar(255) default NULL, -                   `message` text default NULL, -                   `referer` varchar(255) default NULL, -                   `severity` int(9) default 0, -                   `timestamp` int(9) default 0, -                   `url` varchar(255) default NULL, -                   `user_id` int(9) default 0, -                   PRIMARY KEY (`id`)) -                 ENGINE=InnoDB DEFAULT CHARSET=utf8;"); +    $db->query("CREATE TABLE {items} ( +                 `id` int(9) NOT NULL auto_increment, +                 `album_cover_item_id` int(9) default NULL, +                 `captured` int(9) default NULL, +                 `created` int(9) default NULL, +                 `description` varchar(2048) default NULL, +                 `height` int(9) default NULL, +                 `left` int(9) NOT NULL, +                 `level` int(9) NOT NULL, +                 `mime_type` varchar(64) default NULL, +                 `name` varchar(255) default NULL, +                 `owner_id` int(9) default NULL, +                 `parent_id` int(9) NOT NULL, +                 `rand_key` float default NULL, +                 `relative_path_cache` varchar(255) default NULL, +                 `resize_dirty` boolean default 1, +                 `resize_height` int(9) default NULL, +                 `resize_width` int(9) default NULL, +                 `right` int(9) NOT NULL, +                 `sort_column` varchar(64) default NULL, +                 `sort_order` char(4) default 'ASC', +                 `thumb_dirty` boolean default 1, +                 `thumb_height` int(9) default NULL, +                 `thumb_width` int(9) default NULL, +                 `title` varchar(255) default NULL, +                 `type` varchar(32) NOT NULL, +                 `updated` int(9) default NULL, +                 `view_count` int(9) default 0, +                 `weight` int(9) NOT NULL default 0, +                 `width` int(9) default NULL, +                 PRIMARY KEY (`id`), +                 KEY `parent_id` (`parent_id`), +                 KEY `type` (`type`), +                 KEY `random` (`rand_key`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      $db->query("CREATE TABLE {messages} ( -                   `id` int(9) NOT NULL auto_increment, -                   `key` varchar(255) default NULL, -                   `severity` varchar(32) default NULL, -                   `value` varchar(255) default NULL, -                   PRIMARY KEY (`id`), -                   UNIQUE KEY(`key`)) -                 ENGINE=InnoDB DEFAULT CHARSET=utf8;"); +    $db->query("CREATE TABLE {logs} ( +                 `id` int(9) NOT NULL auto_increment, +                 `category` varchar(64) default NULL, +                 `html` varchar(255) default NULL, +                 `message` text default NULL, +                 `referer` varchar(255) default NULL, +                 `severity` int(9) default 0, +                 `timestamp` int(9) default 0, +                 `url` varchar(255) default NULL, +                 `user_id` int(9) default 0, +                 PRIMARY KEY (`id`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      $db->query("CREATE TABLE {modules} ( -                   `id` int(9) NOT NULL auto_increment, -                   `active` BOOLEAN default 0, -                   `name` varchar(64) default NULL, -                   `version` int(9) default NULL, -                   PRIMARY KEY (`id`), -                   UNIQUE KEY(`name`)) -                 ENGINE=InnoDB DEFAULT CHARSET=utf8;"); +    $db->query("CREATE TABLE {messages} ( +                 `id` int(9) NOT NULL auto_increment, +                 `key` varchar(255) default NULL, +                 `severity` varchar(32) default NULL, +                 `value` varchar(255) default NULL, +                 PRIMARY KEY (`id`), +                 UNIQUE KEY(`key`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      $db->query("CREATE TABLE {themes} ( -                   `id` int(9) NOT NULL auto_increment, -                   `name` varchar(64) default NULL, -                   `version` int(9) default NULL, -                   PRIMARY KEY (`id`), -                   UNIQUE KEY(`name`)) -                 ENGINE=InnoDB DEFAULT CHARSET=utf8;"); +    $db->query("CREATE TABLE {modules} ( +                 `id` int(9) NOT NULL auto_increment, +                 `active` BOOLEAN default 0, +                 `name` varchar(64) default NULL, +                 `version` int(9) default NULL, +                 PRIMARY KEY (`id`), +                 UNIQUE KEY(`name`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      $db->query("CREATE TABLE {permissions} ( -                   `id` int(9) NOT NULL auto_increment, -                   `display_name` varchar(64) default NULL, -                   `name` varchar(64) default NULL, -                   PRIMARY KEY (`id`), -                   UNIQUE KEY(`name`)) -                 ENGINE=InnoDB DEFAULT CHARSET=utf8;"); +    $db->query("CREATE TABLE {outgoing_translations} ( +                 `id` int(9) NOT NULL auto_increment, +                 `base_revision` int(9) DEFAULT NULL, +                 `key` char(32) NOT NULL, +                 `locale` char(10) NOT NULL, +                 `message` text NOT NULL, +                 `translation` text, +                 PRIMARY KEY (`id`), +                 UNIQUE KEY(`key`, `locale`), +                 KEY `locale_key` (`locale`, `key`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      $db->query("CREATE TABLE {incoming_translations} ( -                   `id` int(9) NOT NULL auto_increment, -                   `key` char(32) NOT NULL, -                   `locale` char(10) NOT NULL, -                   `message` text NOT NULL, -                   `revision` int(9) DEFAULT NULL, -                   `translation` text, -                   PRIMARY KEY (`id`), -                   UNIQUE KEY(`key`, `locale`), -                   KEY `locale_key` (`locale`, `key`)) -                 ENGINE=InnoDB DEFAULT CHARSET=utf8;"); +    $db->query("CREATE TABLE {permissions} ( +                 `id` int(9) NOT NULL auto_increment, +                 `display_name` varchar(64) default NULL, +                 `name` varchar(64) default NULL, +                 PRIMARY KEY (`id`), +                 UNIQUE KEY(`name`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      $db->query("CREATE TABLE {outgoing_translations} ( -                   `id` int(9) NOT NULL auto_increment, -                   `base_revision` int(9) DEFAULT NULL, -                   `key` char(32) NOT NULL, -                   `locale` char(10) NOT NULL, -                   `message` text NOT NULL, -                   `translation` text, -                   PRIMARY KEY (`id`), -                   UNIQUE KEY(`key`, `locale`), -                   KEY `locale_key` (`locale`, `key`)) -                 ENGINE=InnoDB 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;"); -      $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;"); +    $db->query("CREATE TABLE {tasks} ( +                `id` int(9) NOT NULL auto_increment, +                `callback` varchar(128) default NULL, +                `context` text NOT NULL, +                `done` boolean default 0, +                `name` varchar(128) default NULL, +                `owner_id` int(9) default NULL, +                `percent_complete` int(9) default 0, +                `state` varchar(32) default NULL, +                `status` varchar(255) default NULL, +                `updated` int(9) default NULL, +                PRIMARY KEY (`id`), +                KEY (`owner_id`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      $db->query("CREATE TABLE {tasks} ( -                  `id` int(9) NOT NULL auto_increment, -                  `callback` varchar(128) default NULL, -                  `context` text NOT NULL, -                  `done` boolean default 0, -                  `name` varchar(128) default NULL, -                  `owner_id` int(9) default NULL, -                  `percent_complete` int(9) default 0, -                  `state` varchar(32) default NULL, -                  `status` varchar(255) default NULL, -                  `updated` int(9) default NULL, -                  PRIMARY KEY (`id`), -                  KEY (`owner_id`)) -                 ENGINE=InnoDB DEFAULT CHARSET=utf8;"); +    $db->query("CREATE TABLE {themes} ( +                 `id` int(9) NOT NULL auto_increment, +                 `name` varchar(64) default NULL, +                 `version` int(9) default NULL, +                 PRIMARY KEY (`id`), +                 UNIQUE KEY(`name`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      $db->query("CREATE TABLE {vars} ( -                  `id` int(9) NOT NULL auto_increment, -                  `module_name` varchar(64) NOT NULL, -                  `name` varchar(64) NOT NULL, -                  `value` text, -                  PRIMARY KEY (`id`), -                  UNIQUE KEY(`module_name`, `name`)) -                 ENGINE=InnoDB DEFAULT CHARSET=utf8;"); +    $db->query("CREATE TABLE {vars} ( +                `id` int(9) NOT NULL auto_increment, +                `module_name` varchar(64) NOT NULL, +                `name` varchar(64) NOT NULL, +                `value` text, +                PRIMARY KEY (`id`), +                UNIQUE KEY(`module_name`, `name`)) +               ENGINE=InnoDB DEFAULT CHARSET=utf8;"); -      foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) { -        @mkdir(VARPATH . $dir); -      } +    foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) { +      @mkdir(VARPATH . $dir); +    } -      access::register_permission("view", "View"); -      access::register_permission("view_full", "View Full Size"); -      access::register_permission("edit", "Edit"); -      access::register_permission("add", "Add"); +    access::register_permission("view", "View"); +    access::register_permission("view_full", "View Full Size"); +    access::register_permission("edit", "Edit"); +    access::register_permission("add", "Add"); -      $root = ORM::factory("item"); -      $root->type = "album"; -      $root->title = "Gallery"; -      $root->description = ""; -      $root->left = 1; -      $root->right = 2; -      $root->parent_id = 0; -      $root->level = 1; -      $root->thumb_dirty = 1; -      $root->resize_dirty = 1; -      $root->sort_column = "weight"; -      $root->sort_order = "ASC"; -      $root->save(); -      access::add_item($root); +    $root = ORM::factory("item"); +    $root->type = "album"; +    $root->title = "Gallery"; +    $root->description = ""; +    $root->left = 1; +    $root->right = 2; +    $root->parent_id = 0; +    $root->level = 1; +    $root->thumb_dirty = 1; +    $root->resize_dirty = 1; +    $root->sort_column = "weight"; +    $root->sort_order = "ASC"; +    $root->save(); +    access::add_item($root); -      module::set_var("gallery", "active_site_theme", "default"); -      module::set_var("gallery", "active_admin_theme", "admin_default"); -      module::set_var("gallery", "page_size", 9); -      module::set_var("gallery", "thumb_size", 200); -      module::set_var("gallery", "resize_size", 640); -      module::set_var("gallery", "default_locale", "en_US"); -      module::set_var("gallery", "image_quality", 75); +    module::set_var("gallery", "active_site_theme", "default"); +    module::set_var("gallery", "active_admin_theme", "admin_default"); +    module::set_var("gallery", "page_size", 9); +    module::set_var("gallery", "thumb_size", 200); +    module::set_var("gallery", "resize_size", 640); +    module::set_var("gallery", "default_locale", "en_US"); +    module::set_var("gallery", "image_quality", 75); -      // Add rules for generating our thumbnails and resizes -      graphics::add_rule( -        "gallery", "thumb", "resize", -        array("width" => 200, "height" => 200, "master" => Image::AUTO), -        100); -      graphics::add_rule( -        "gallery", "resize", "resize", -        array("width" => 640, "height" => 480, "master" => Image::AUTO), -        100); +    // Add rules for generating our thumbnails and resizes +    graphics::add_rule( +      "gallery", "thumb", "resize", +      array("width" => 200, "height" => 200, "master" => Image::AUTO), +      100); +    graphics::add_rule( +      "gallery", "resize", "resize", +      array("width" => 640, "height" => 480, "master" => Image::AUTO), +      100); -      // Instantiate default themes (site and admin) -      foreach (array("default", "admin_default") as $theme_name) { -        $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), -                                      ArrayObject::ARRAY_AS_PROPS); -        $theme = ORM::factory("theme"); -        $theme->name = $theme_name; -        $theme->version = $theme_info->version; -        $theme->save(); -      } +    // Instantiate default themes (site and admin) +    foreach (array("default", "admin_default") as $theme_name) { +      $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), +                                    ArrayObject::ARRAY_AS_PROPS); +      $theme = ORM::factory("theme"); +      $theme->name = $theme_name; +      $theme->version = $theme_info->version; +      $theme->save(); +    } -      block_manager::add("dashboard_sidebar", "gallery", "block_adder"); -      block_manager::add("dashboard_sidebar", "gallery", "stats"); -      block_manager::add("dashboard_sidebar", "gallery", "platform_info"); -      block_manager::add("dashboard_sidebar", "gallery", "project_news"); -      block_manager::add("dashboard_center", "gallery", "welcome"); -      block_manager::add("dashboard_center", "gallery", "photo_stream"); -      block_manager::add("dashboard_center", "gallery", "log_entries"); +    block_manager::add("dashboard_sidebar", "gallery", "block_adder"); +    block_manager::add("dashboard_sidebar", "gallery", "stats"); +    block_manager::add("dashboard_sidebar", "gallery", "platform_info"); +    block_manager::add("dashboard_sidebar", "gallery", "project_news"); +    block_manager::add("dashboard_center", "gallery", "welcome"); +    block_manager::add("dashboard_center", "gallery", "photo_stream"); +    block_manager::add("dashboard_center", "gallery", "log_entries"); -      module::set_version("gallery", 1); -      module::set_var("gallery", "version", "3.0 beta 1"); -      module::set_var("gallery", "choose_default_tookit", 1); +    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"); +    module::set_var("gallery", "time_format", "H:i:s"); +    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); +  } -      // @todo this string needs to be picked up by l10n_scanner -      module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>"); -    } else if ($version == 1) { +  static function upgrade($version) { +    $db = Database::instance(); +    if ($version == 1) {        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", 2); +      module::set_version("gallery", $version = 2); +    } + +    if ($version == 2) { +      module::set_var("gallery", "show_credits", 1); +      module::set_version("gallery", $version = 3); +    } + +    if ($version == 3) { +      $db->query("CREATE TABLE {caches} ( +                 `id` varchar(255) NOT NULL, +                 `tags` varchar(255), +                 `expiration` int(9) NOT NULL, +                 `cache` text, +                 PRIMARY KEY (`id`), +                 KEY (`tags`)) +                 ENGINE=InnoDB DEFAULT CHARSET=utf8;"); +      module::set_version("gallery", $version = 4); +    } + +    if ($version == 4) { +      Cache::instance()->delete_all(); +      $db->query("ALTER TABLE {caches} MODIFY COLUMN `cache` LONGBLOB"); +      module::set_version("gallery", $version = 5); +    } + +    if ($version == 5) { +      Cache::instance()->delete_all(); +      $db->query("ALTER TABLE {caches} DROP COLUMN `id`"); +      $db->query("ALTER TABLE {caches} ADD COLUMN `key` varchar(255) NOT NULL"); +      $db->query("ALTER TABLE {caches} ADD COLUMN `id` int(9) NOT NULL auto_increment PRIMARY KEY"); +      module::set_version("gallery", $version = 6);      }    } @@ -268,17 +309,17 @@ class gallery_installer {      $db->query("DROP TABLE IF EXISTS {access_caches}");      $db->query("DROP TABLE IF EXISTS {access_intents}");      $db->query("DROP TABLE IF EXISTS {graphics_rules}"); +    $db->query("DROP TABLE IF EXISTS {incoming_translations}");      $db->query("DROP TABLE IF EXISTS {items}");      $db->query("DROP TABLE IF EXISTS {logs}"); -    $db->query("DROP TABLE IF EXISTS {messages}");      $db->query("DROP TABLE IF EXISTS {modules}"); -    $db->query("DROP TABLE IF EXISTS {themes}"); -    $db->query("DROP TABLE IF EXISTS {incoming_translations}");      $db->query("DROP TABLE IF EXISTS {outgoing_translations}");      $db->query("DROP TABLE IF EXISTS {permissions}");      $db->query("DROP TABLE IF EXISTS {sessions}");      $db->query("DROP TABLE IF EXISTS {tasks}"); +    $db->query("DROP TABLE IF EXISTS {themes}");      $db->query("DROP TABLE IF EXISTS {vars}"); +    $db->query("DROP TABLE IF EXISTS {caches}");      foreach (array("albums", "resizes", "thumbs", "uploads",                     "modules", "logs", "database.php") as $entry) {        system("/bin/rm -rf " . VARPATH . $entry); diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php index fb0234b1..1f1e1ce2 100644 --- a/modules/gallery/helpers/gallery_menu.php +++ b/modules/gallery/helpers/gallery_menu.php @@ -94,6 +94,9 @@ class gallery_menu_Core {    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") @@ -149,6 +152,9 @@ class gallery_menu_Core {                          ->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")) diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php new file mode 100644 index 00000000..d0ffc584 --- /dev/null +++ b/modules/gallery/helpers/gallery_quick.php @@ -0,0 +1,144 @@ +<?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_theme.php b/modules/gallery/helpers/gallery_theme.php index 44c1d3f1..cffecb12 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -29,22 +29,22 @@ class gallery_theme_Core {          && access::can("edit", $theme->item())) {        $buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .          url::file("modules/gallery/css/quick.css") . "\" />"; -      $buf .= html::script("modules/gallery/js/quick.js"); +      $theme->script("modules/gallery/js/quick.js");      }      if (module::is_active("rss")) {        if ($item = $theme->item()) { -        $buf = rss::feed_link("gallery/album/{$item->id}"); +        $buf .= rss::feed_link("gallery/album/{$item->id}");        } else if ($tag = $theme->tag()) { -        $buf = rss::feed_link("tag/tag/{$tag->id}"); +        $buf .= rss::feed_link("tag/tag/{$tag->id}");        }      }      if ($session->get("l10n_mode", false)) {        $buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .          url::file("modules/gallery/css/l10n_client.css") . "\" />"; -      $buf .= html::script("lib/jquery.cookie.js"); -      $buf .= html::script("modules/gallery/js/l10n_client.js"); +      $theme->script("lib/jquery.cookie.js"); +      $theme->script("modules/gallery/js/l10n_client.js");      }      return $buf; @@ -87,8 +87,8 @@ class gallery_theme_Core {      if ($session->get("l10n_mode", false)) {        $buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .          url::file("modules/gallery/css/l10n_client.css") . "\" />"; -      $buf .= html::script("lib/jquery.cookie.js"); -      $buf .= html::script("modules/gallery/js/l10n_client.js"); +      $theme->script("lib/jquery.cookie.js"); +      $theme->script("modules/gallery/js/l10n_client.js");      }      return $buf; diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index feebfb34..71b8ddd8 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -135,7 +135,12 @@ class graphics_Core {          if ($input_item->is_movie()) {            // Convert the movie to a JPG first            $output_file = preg_replace("/...$/", "jpg", $output_file); -          movie::extract_frame($input_file, $output_file); +          try { +            movie::extract_frame($input_file, $output_file); +          } catch (Exception $e) { +            // Assuming this is MISSING_FFMPEG for now +            copy(MODPATH . "gallery/images/missing_movie.png", $output_file); +          }            $working_file = $output_file;          } else {            $working_file = $input_file; @@ -326,7 +331,7 @@ class graphics_Core {      if (!isset($gd["GD Version"])) {        $gd["GD Version"] = false;      } -    putenv("PATH=" . getenv("PATH") . ":/usr/local/bin"); +    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); diff --git a/modules/gallery/helpers/l10n_scanner.php b/modules/gallery/helpers/l10n_scanner.php index 80b6f01c..a68aa28b 100644 --- a/modules/gallery/helpers/l10n_scanner.php +++ b/modules/gallery/helpers/l10n_scanner.php @@ -125,7 +125,7 @@ class l10n_scanner_Core {              && is_array($first_param) && $first_param[0] == T_CONSTANT_ENCAPSED_STRING              && is_array($second_param) && $second_param[0] == T_CONSTANT_ENCAPSED_STRING) {            $singular = self::_escape_quoted_string($first_param[1]); -          $plural = self::_escape_quoted_string($first_param[1]); +          $plural = self::_escape_quoted_string($second_param[1]);            l10n_scanner::process_message(array("one" => $singular, "other" => $plural), $cache);          } else {            // t2() found, but inside is something which is not a string literal. @@ -149,6 +149,6 @@ class l10n_scanner_Core {      } else {        $str = strtr($str, array("\\'" => "'", "\\\\" => "\\"));      } -    return addcslashes($str, "\0..\37\\\""); +    return $str;    }  } diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index dea8e22c..0d483206 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -107,7 +107,7 @@ class module_Core {    /**     * Install a module.  This will call <module>_installer::install(), which is responsible for -   * creating database tables, setting module variables and and calling module::set_version(). +   * creating database tables, setting module variables and calling module::set_version().     * Note that after installing, the module must be activated before it is available for use.     * @param string $module_name     */ @@ -131,6 +131,38 @@ class module_Core {    }    /** +   * Upgrade a module.  This will call <module>_installer::upgrade(), which is responsible for +   * modifying database tables, changing module variables and calling module::set_version(). +   * Note that after upgrading, the module must be activated before it is available for use. +   * @param string $module_name +   */ +  static function upgrade($module_name) { +    $kohana_modules = Kohana::config("core.modules"); +    array_unshift($kohana_modules, MODPATH . $module_name); +    Kohana::config_set("core.modules",  $kohana_modules); + +    $version_before = module::get_version($module_name); +    $installer_class = "{$module_name}_installer"; +    if (method_exists($installer_class, "upgrade")) { +      call_user_func_array(array($installer_class, "upgrade"), array($version_before)); +    } +    module::load_modules(); + +    // Now the module is upgraded but inactive, so don't leave it in the active path +    array_shift($kohana_modules); +    Kohana::config_set("core.modules",  $kohana_modules); + +    $version_after = module::get_version($module_name); +    if ($version_before != $version_after) { +      log::success( +        "module", t("Upgraded module %module_name from %version_before to %version_after", +                    array("module_name" => $module_name, +                          "version_before" => $version_before, +                          "version_after" => $version_after))); +    } +  } + +  /**     * Activate an installed module.  This will call <module>_installer::activate() which should take     * any steps to make sure that the module is ready for use.  This will also activate any     * existing graphics rules for this module. diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 1d1d29d1..fcf1cc54 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -53,7 +53,12 @@ class movie_Core {        throw new Exception("@todo NAME_CANNOT_END_IN_PERIOD");      } -    $movie_info = movie::getmoviesize($filename); +    try { +      $movie_info = movie::getmoviesize($filename); +    } catch (Exception $e) { +      // Assuming this is MISSING_FFMPEG for now +      $movie_info = getimagesize(MODPATH . "gallery/images/missing_movie.png"); +    }      // Force an extension onto the name      $pi = pathinfo($filename); @@ -140,7 +145,7 @@ class movie_Core {    static function find_ffmpeg() {      if (!$ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) { -      putenv("PATH=" . getenv("PATH") . ":/usr/local/bin"); +      putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin");        if (function_exists("exec")) {          $ffmpeg_path = exec("which ffmpeg");        } diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 0a43f25c..b46a2c14 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -55,6 +55,8 @@ class theme_Core {        ->value(module::get_var("gallery", "header_text"));      $group->textarea("footer_text")->label(t("Footer text"))->id("gFooterText")        ->value(module::get_var("gallery", "footer_text")); +    $group->checkbox("show_credits")->label(t("Show site credits"))->id("gFooterText") +      ->checked(module::get_var("gallery", "show_credits"));      $group->submit("")->value(t("Save"));      return $form;    } | 
