diff options
46 files changed, 370 insertions, 143 deletions
diff --git a/.build_number b/.build_number index 4521d1ec..e2762f59 100644 --- a/.build_number +++ b/.build_number @@ -3,4 +3,4 @@ ; process. You don't need to edit it. In fact.. ; ; DO NOT EDIT THIS FILE BY HAND! -build_number=71 +build_number=97 diff --git a/installer/install.sql b/installer/install.sql index 865cb2a4..de5250d1 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -67,8 +67,8 @@ CREATE TABLE {comments} ( `server_http_referer` varchar(255) DEFAULT NULL, `server_http_user_agent` varchar(128) DEFAULT NULL, `server_query_string` varchar(64) DEFAULT NULL, - `server_remote_addr` varchar(32) DEFAULT NULL, - `server_remote_host` varchar(64) DEFAULT NULL, + `server_remote_addr` varchar(40) DEFAULT NULL, + `server_remote_host` varchar(255) DEFAULT NULL, `server_remote_port` varchar(16) DEFAULT NULL, `state` varchar(15) DEFAULT 'unpublished', `text` text, @@ -244,15 +244,15 @@ CREATE TABLE {modules} ( KEY `weight` (`weight`) ) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {modules} VALUES (1,1,'gallery',46,1); +INSERT INTO {modules} VALUES (1,1,'gallery',48,1); INSERT INTO {modules} VALUES (2,1,'user',3,2); -INSERT INTO {modules} VALUES (3,1,'comment',3,3); +INSERT INTO {modules} VALUES (3,1,'comment',4,3); INSERT INTO {modules} VALUES (4,1,'organize',4,4); INSERT INTO {modules} VALUES (5,1,'info',2,5); INSERT INTO {modules} VALUES (6,1,'rss',1,6); INSERT INTO {modules} VALUES (7,1,'search',1,7); INSERT INTO {modules} VALUES (8,1,'slideshow',2,8); -INSERT INTO {modules} VALUES (9,1,'tag',2,9); +INSERT INTO {modules} VALUES (9,1,'tag',3,9); DROP TABLE IF EXISTS {outgoing_translations}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -382,7 +382,7 @@ CREATE TABLE {vars} ( `value` text, PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) -) AUTO_INCREMENT=40 DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=43 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind'); INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind'); @@ -406,12 +406,14 @@ INSERT INTO {vars} VALUES (NULL,'gallery','admin_area_timeout','5400'); INSERT INTO {vars} VALUES (NULL,'gallery','maintenance_mode','0'); INSERT INTO {vars} VALUES (NULL,'gallery','visible_title_length','15'); INSERT INTO {vars} VALUES (NULL,'gallery','favicon_url','lib/images/favicon.ico'); +INSERT INTO {vars} VALUES (NULL,'gallery','apple_touch_icon_url','lib/images/apple-touch-icon.png'); INSERT INTO {vars} VALUES (NULL,'gallery','email_from','unknown@unknown.com'); INSERT INTO {vars} VALUES (NULL,'gallery','email_reply_to','unknown@unknown.com'); INSERT INTO {vars} VALUES (NULL,'gallery','email_line_length','70'); INSERT INTO {vars} VALUES (NULL,'gallery','email_header_separator','s:1:\"\n\";'); INSERT INTO {vars} VALUES (NULL,'gallery','show_user_profiles_to','registered_users'); INSERT INTO {vars} VALUES (NULL,'gallery','extra_binary_paths','/usr/local/bin:/opt/local/bin:/opt/bin'); +INSERT INTO {vars} VALUES (NULL,'gallery','timezone','PST8PDT'); INSERT INTO {vars} VALUES (NULL,'gallery','blocks_site_sidebar','a:4:{i:10;a:2:{i:0;s:7:\"gallery\";i:1;s:8:\"language\";}i:11;a:2:{i:0;s:4:\"info\";i:1;s:8:\"metadata\";}i:12;a:2:{i:0;s:3:\"rss\";i:1;s:9:\"rss_feeds\";}i:13;a:2:{i:0;s:3:\"tag\";i:1;s:3:\"tag\";}}'); INSERT INTO {vars} VALUES (NULL,'gallery','identity_provider','user'); INSERT INTO {vars} VALUES (NULL,'user','mininum_password_length','5'); @@ -423,3 +425,4 @@ INSERT INTO {vars} VALUES (NULL,'info','show_owner','1'); INSERT INTO {vars} VALUES (NULL,'info','show_name','1'); INSERT INTO {vars} VALUES (NULL,'info','show_captured','1'); INSERT INTO {vars} VALUES (NULL,'slideshow','max_scale','0'); +INSERT INTO {vars} VALUES (NULL,'tag','tag_cloud_size','30'); diff --git a/lib/images/apple-touch-icon.png b/lib/images/apple-touch-icon.png Binary files differnew file mode 100644 index 00000000..d15ce1a6 --- /dev/null +++ b/lib/images/apple-touch-icon.png diff --git a/lib/jquery-ui.js b/lib/jquery-ui.js index 3398b9e4..74515a5b 100644 --- a/lib/jquery-ui.js +++ b/lib/jquery-ui.js @@ -18,7 +18,7 @@ this.started=false;},_mouseDestroy:function(){this.element.unbind('.'+this.widge (this._mouseStarted&&this._mouseUp(event));this._mouseDownEvent=event;var self=this,btnIsLeft=(event.which==1),elIsCancel=(typeof this.options.cancel=="string"?$(event.target).parents().add(event.target).filter(this.options.cancel).length:false);if(!btnIsLeft||elIsCancel||!this._mouseCapture(event)){return true;} this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){self.mouseDelayMet=true;},this.options.delay);} if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(event)!==false);if(!this._mouseStarted){event.preventDefault();return true;}} -this._mouseMoveDelegate=function(event){return self._mouseMove(event);};this._mouseUpDelegate=function(event){return self._mouseUp(event);};$(document).bind('mousemove.'+this.widgetName,this._mouseMoveDelegate).bind('mouseup.'+this.widgetName,this._mouseUpDelegate);($.browser.safari||event.preventDefault());event.originalEvent.mouseHandled=true;return true;},_mouseMove:function(event){if($.browser.msie&&!event.button){return this._mouseUp(event);} +this._mouseMoveDelegate=function(event){return self._mouseMove(event);};this._mouseUpDelegate=function(event){return self._mouseUp(event);};$(document).bind('mousemove.'+this.widgetName,this._mouseMoveDelegate).bind('mouseup.'+this.widgetName,this._mouseUpDelegate);($.browser.safari||event.preventDefault());event.originalEvent.mouseHandled=true;return true;},_mouseMove:function(event){if($.browser.msie&&!(document.documentMode>=9)&&!event.button){return this._mouseUp(event);} if(this._mouseStarted){this._mouseDrag(event);return event.preventDefault();} if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,event)!==false);(this._mouseStarted?this._mouseDrag(event):this._mouseUp(event));} return!this._mouseStarted;},_mouseUp:function(event){$(document).unbind('mousemove.'+this.widgetName,this._mouseMoveDelegate).unbind('mouseup.'+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(event.target==this._mouseDownEvent.target);this._mouseStop(event);} diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index 48b6ee21..5c6bd586 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -37,8 +37,8 @@ class comment_installer { `server_http_referer` varchar(255) default NULL, `server_http_user_agent` varchar(128) default NULL, `server_query_string` varchar(64) default NULL, - `server_remote_addr` varchar(32) default NULL, - `server_remote_host` varchar(64) default NULL, + `server_remote_addr` varchar(40) default NULL, + `server_remote_host` varchar(255) default NULL, `server_remote_port` varchar(16) default NULL, `state` varchar(15) default 'unpublished', `text` text, @@ -48,7 +48,7 @@ class comment_installer { module::set_var("comment", "spam_caught", 0); module::set_var("comment", "access_permissions", "everybody"); - module::set_version("comment", 3); + module::set_version("comment", 4); } static function upgrade($version) { @@ -62,6 +62,19 @@ class comment_installer { module::set_var("comment", "access_permissions", "everybody"); module::set_version("comment", $version = 3); } + + if ($version == 3) { + // 40 bytes for server_remote_addr is enough to swallow the longest + // representation of an IPv6 addy. + // + // 255 bytes for server_remote_host is enough to swallow the longest + // legit DNS entry, with a few bytes to spare. + $db->query( + "ALTER TABLE {comments} CHANGE `server_remote_addr` `server_remote_addr` varchar(40)"); + $db->query( + "ALTER TABLE {comments} CHANGE `server_remote_host` `server_remote_host` varchar(255)"); + module::set_version("comment", $version = 4); + } } static function uninstall() { diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index d5e952eb..7c189a0e 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -98,8 +98,8 @@ class Comment_Model_Core extends ORM { $this->server_http_referer = substr($input->server("HTTP_REFERER"), 0, 255); $this->server_http_user_agent = substr($input->server("HTTP_USER_AGENT"), 0, 128); $this->server_query_string = substr($input->server("QUERY_STRING"), 0, 64); - $this->server_remote_addr = substr($input->server("REMOTE_ADDR"), 0, 32); - $this->server_remote_host = substr($input->server("REMOTE_HOST"), 0, 64); + $this->server_remote_addr = substr($input->server("REMOTE_ADDR"), 0, 40); + $this->server_remote_host = substr($input->server("REMOTE_HOST"), 0, 255); $this->server_remote_port = substr($input->server("REMOTE_PORT"), 0, 16); } diff --git a/modules/comment/module.info b/modules/comment/module.info index cd34f140..e5aa454d 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -1,3 +1,3 @@ name = "Comments" description = "Allows users and guests to leave comments on photos and albums." -version = 3 +version = 4 diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php index 1cdf7d34..a35a2141 100644 --- a/modules/exif/helpers/exif.php +++ b/modules/exif/helpers/exif.php @@ -36,10 +36,7 @@ class exif_Core { foreach(self::_keys() as $field => $exifvar) { if (isset($exif_raw[$exifvar[0]][$exifvar[1]])) { $value = $exif_raw[$exifvar[0]][$exifvar[1]]; - if (function_exists("mb_detect_encoding") && - mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { - $value = utf8_encode($value); - } + $value = encoding::convert_to_utf8($value); $keys[$field] = Input::clean($value); if ($field == "DateTime") { @@ -60,10 +57,7 @@ class exif_Core { foreach (array("Keywords" => "2#025", "Caption" => "2#120") as $keyword => $iptc_key) { if (!empty($iptc[$iptc_key])) { $value = implode(" ", $iptc[$iptc_key]); - if (function_exists("mb_detect_encoding") && - mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { - $value = utf8_encode($value); - } + $value = encoding::convert_to_utf8($value); $keys[$keyword] = Input::clean($value); if ($keyword == "Caption" && !$item->description) { diff --git a/modules/exif/helpers/exif_event.php b/modules/exif/helpers/exif_event.php index e594c765..72e88041 100644 --- a/modules/exif/helpers/exif_event.php +++ b/modules/exif/helpers/exif_event.php @@ -24,6 +24,12 @@ class exif_event_Core { } } + static function item_updated_data_file($item) { + if (!$item->is_album()) { + exif::extract($item); + } + } + static function item_deleted($item) { db::build() ->delete("exif_records") diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index 33186fb5..55a75a3b 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -24,23 +24,42 @@ class Admin_g2_import_Controller extends Admin_Controller { g2_import::init(); } - if (class_exists("GalleryCoreApi")) { - $g2_stats = g2_import::stats(); - $g2_sizes = g2_import::common_sizes(); - } - $view = new Admin_View("admin.html"); $view->page_title = t("Gallery 2 import"); $view->content = new View("admin_g2_import.html"); + + if (class_exists("GalleryCoreApi")) { + $view->content->g2_stats = $g2_stats = g2_import::g2_stats(); + $view->content->g3_stats = $g3_stats = g2_import::g3_stats(); + $view->content->g2_sizes = g2_import::common_sizes(); + $view->content->g2_version = g2_import::version(); + + // Don't count tags because we don't track them in g2_map + $view->content->g2_resource_count = + $g2_stats["users"] + $g2_stats["groups"] + $g2_stats["albums"] + + $g2_stats["photos"] + $g2_stats["movies"] + $g2_stats["comments"]; + $view->content->g3_resource_count = + $g3_stats["user"] + $g3_stats["group"] + $g3_stats["album"] + + $g3_stats["item"] + $g3_stats["comment"] + $g3_stats["tag"]; + } + $view->content->form = $this->_get_import_form(); $view->content->version = ""; + $view->content->thumb_size = module::get_var("gallery", "thumb_size"); + $view->content->resize_size = module::get_var("gallery", "resize_size"); if (g2_import::is_initialized()) { - $view->content->g2_stats = $g2_stats; - $view->content->g2_sizes = $g2_sizes; - $view->content->thumb_size = module::get_var("gallery", "thumb_size"); - $view->content->resize_size = module::get_var("gallery", "resize_size"); - $view->content->version = g2_import::version(); + if ((bool)ini_get("eaccelerator.enable") || (bool)ini_get("xcache.cacher")) { + message::warning(t("The eAccelerator and XCache PHP performance extensions are known to cause issues. If you're using either of those and are having problems, please disable them while you do your import. Add the following lines: <pre>%lines</pre> to gallery3/.htaccess and remove them when the import is done.", array("lines" => "\n\n php_value eaccelerator.enable 0\n php_value xcache.cacher off\n php_value xcache.optimizer off\n\n"))); + } + + foreach (array("notification", "search", "exif") as $module_id) { + if (module::is_active($module_id)) { + message::warning( + t("<a href=\"%url\">Deactivating</a> the <b>%module_id</b> module during your import will make it faster", + array("url" => url::site("admin/modules"), "module_id" => $module_id))); + } + } } else if (g2_import::is_configured()) { $view->content->form->configure_g2_import->embed_path->add_error("invalid", 1); } @@ -76,14 +95,15 @@ class Admin_g2_import_Controller extends Admin_Controller { } private function _get_import_form() { + $embed_path = module::get_var("g2_import", "embed_path", ""); $form = new Forge( "admin/g2_import/save", "", "post", array("id" => "g-admin-configure-g2-import-form")); $group = $form->group("configure_g2_import")->label(t("Configure Gallery 2 Import")); $group->input("embed_path")->label(t("Filesystem path to your Gallery 2 embed.php file")) - ->value(module::get_var("g2_import", "embed_path", "")); + ->value($embed_path); $group->embed_path->error_messages( "invalid", t("The path you entered is not a Gallery 2 installation.")); - $group->submit("")->value(t("Save")); + $group->submit("")->value($embed_path ? t("Change") : t("Continue")); return $form; } }
\ No newline at end of file diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 22fb68c6..23fb29e5 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -219,7 +219,7 @@ class g2_import_Core { * Return a set of statistics about the number of users, groups, albums, photos, movies and * comments available for import from the Gallery 2 instance. */ - static function stats() { + static function g2_stats() { global $gallery; $root_album_id = g2(GalleryCoreApi::getDefaultAlbumId()); $stats["users"] = g2(GalleryCoreApi::fetchUserCount()); @@ -248,6 +248,25 @@ class g2_import_Core { } /** + * Return a set of statistics about the number of users, groups, albums, photos, movies and + * comments already imported into the Gallery 3 instance. + */ + static function g3_stats() { + $g3_stats = array( + "album" => 0, "comment" => 0, "item" => 0, "user" => 0, "group" => 0, "tag" => 0); + foreach (db::build() + ->select("resource_type") + ->select(array("C" => 'COUNT("*")')) + ->from("g2_maps") + ->where("resource_type", "IN", array("album", "comment", "item", "user", "group")) + ->group_by("resource_type") + ->execute() as $row) { + $g3_stats[$row->resource_type] = $row->C; + } + return $g3_stats; + } + + /** * Import a single group. */ static function import_group(&$queue) { diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php index 6bda8f17..5e908676 100644 --- a/modules/g2_import/helpers/g2_import_task.php +++ b/modules/g2_import/helpers/g2_import_task.php @@ -56,7 +56,7 @@ class g2_import_task_Core { $mode = $task->get("mode"); $queue = $task->get("queue"); if (!isset($mode)) { - $stats = g2_import::stats(); + $stats = g2_import::g2_stats(); $stats["items"] = $stats["photos"] + $stats["movies"]; unset($stats["photos"]); unset($stats["movies"]); diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index cb13363a..20b243d5 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -5,20 +5,43 @@ <?= t("Import your Gallery 2 users, photos, movies, comments and tags into your new Gallery 3 installation.") ?> </p> - <div class="g-block-content"> - <?= $form ?> - </div> - - <div class="g-block-content"> - <? if (g2_import::is_initialized()): ?> - <div id="g-admin-g2-import-details"> - <h2> <?= t("Import") ?> </h2> - <ul id="g-action-status" class="g-message-block"> - <li class="g-success"> - <?= t("Gallery version %version detected", array("version" => $version)) ?> + <script type="text/javascript"> + $(document).ready(function() { + $("#g-admin-g2-import-tabs").tabs() + <? if (!isset($g2_version)): ?> + .tabs("disable", 1) + .tabs("disable", 2) + <? elseif ($g3_resource_count > .9 * $g2_resource_count): ?> + .tabs("select", 2) + <? else: ?> + .tabs("select", 1) + <? endif ?> + ; + }); + </script> + <div id="g-admin-g2-import-tabs" class="g-block-content"> + <ul> + <li> + <a href="#g-admin-g2-import-configure"><?= t("1. Configure Gallery2 path") ?></a> + </li> + <li> + <a href="#g-admin-g2-import-import"><?= t("2. Import!") ?></a> + </li> + <li> + <a href="#g-admin-g2-import-notes"><?= t("3. After your import") ?></a> + </li> + </ul> + <div id="g-admin-g2-import-configure" class="g-block-content"> + <?= $form ?> + </div> + <div id="g-admin-g2-import-import"> + <? if (isset($g2_version)): ?> + <ul class="enumeration"> + <li> + <?= t("Gallery version %version detected", array("version" => $g2_version)) ?> </li> <? if ($g2_sizes["thumb"]["size"] && $thumb_size != $g2_sizes["thumb"]["size"]): ?> - <li class="g-warning"> + <li> <?= t("Your most common thumbnail size in Gallery 2 is %g2_pixels pixels, but your Gallery 3 thumbnail size is set to %g3_pixels pixels. <a href=\"%url\">Using the same value</a> will speed up your import.", array("g2_pixels" => $g2_sizes["thumb"]["size"], "g3_pixels" => $thumb_size, @@ -27,73 +50,84 @@ <? endif ?> <? if ($g2_sizes["resize"]["size"] && $resize_size != $g2_sizes["resize"]["size"]): ?> - <li class="g-warning"> + <li> <?= t("Your most common intermediate size in Gallery 2 is %g2_pixels pixels, but your Gallery 3 intermediate size is set to %g3_pixels pixels. <a href=\"%url\">Using the same value</a> will speed up your import.", - array("g2_pixels" => $g2_sizes["resize"]["size"], - "g3_pixels" => $resize_size, - "url" => html::mark_clean(url::site("admin/theme_options")))) ?> + array("g2_pixels" => $g2_sizes["resize"]["size"], + "g3_pixels" => $resize_size, + "url" => html::mark_clean(url::site("admin/theme_options")))) ?> </li> <? endif ?> - <li class="g-info"> - <?= t("Your Gallery 2 has the following importable data in it:") ?> - <p> - <?= t2("1 user", "%count users", $g2_stats["users"]) ?>, - <?= t2("1 group", "%count groups", $g2_stats["groups"]) ?>, - <?= t2("1 album", "%count albums", $g2_stats["albums"]) ?>, - <?= t2("1 photo", "%count photos", $g2_stats["photos"]) ?>, - <?= t2("1 movie", "%count movies", $g2_stats["movies"]) ?>, - <?= t2("1 comment", "%count comments", $g2_stats["comments"]) ?>, - <?= t2("1 tagged photo/movie/album", - "%count tagged photos/movies/albums", $g2_stats["tags"]) ?> - </p> + <li> + <? + $t = array(); + $t[] = t2("1 user", "%count users", $g2_stats["users"]); + $t[] = t2("1 group", "%count groups", $g2_stats["groups"]); + $t[] = t2("1 album", "%count albums", $g2_stats["albums"]); + $t[] = t2("1 photo", "%count photos/movies", $g2_stats["photos"] + $g2_stats["movies"]); + $t[] = t2("1 comment", "%count comments", $g2_stats["comments"]); + $t[] = t2("1 tagged photo/movie/album", "%count tagged photos/movies/albums", + $g2_stats["tags"]); + ?> + <?= t("Your Gallery 2 has the following importable data in it: %t0, %t1, %t2, %t3, %t4, %t5", + array("t0" => $t[0], "t1" => $t[1], "t2" => $t[2], + "t3" => $t[3], "t4" => $t[4], "t5" => $t[5])) ?> </li> - </ul> + <? if ($g3_resource_count): ?> + <li> + <? + $t = array(); + $t[] = t2("1 user", "%count users", $g3_stats["user"]); + $t[] = t2("1 group", "%count groups", $g3_stats["group"]); + $t[] = t2("1 album", "%count albums", $g3_stats["album"]); + $t[] = t2("1 photo/movie", "%count photos/movies", $g3_stats["item"]); + $t[] = t2("1 comment", "%count comments", $g3_stats["comment"]); + $t[] = t2("1 tagged photo/movie/album", "%count tagged photos/movies/albums", $g3_stats["tag"]); + ?> + <?= t("It looks like you've imported the following Gallery 2 data already: %t0, %t1, %t2, %t3, %t4, %t5", + array("t0" => $t[0], "t1" => $t[1], "t2" => $t[2], + "t3" => $t[3], "t4" => $t[4], "t5" => $t[5])) ?> + </li> + <? endif ?> + </ul> <p> <a class="g-button g-dialog-link ui-state-default ui-corner-all" href="<?= url::site("admin/maintenance/start/g2_import_task::import?csrf=$csrf") ?>"> <?= t("Begin import!") ?> </a> </p> + <? endif ?> </div> + <div id="g-admin-g2-import-notes"> + <ul class="enumeration"> + <li> + <?= t("Gallery 3 does not support per-user / per-item permissions. <b>Review permissions!</b>") ?> + </li> + <li> + <?= t("The only supported file formats are JPG, PNG and GIF, FLV and MP4. Other formats will be skipped.") ?> + </li> + <li> + <p> + <?= t("Redirecting Gallery 2 URLs once your migration is complete. Put this block at the top of your gallery2/.htaccess file and all Gallery 2 urls will be redirected to Gallery 3") ?> + </p> - <div class="g-block-content"> - <div id="g-admin-g2-import-notes"> - <h2> <?= t("Notes") ?> </h2> - <ul class="enumeration"> - <li> - <?= t("Gallery 3 does not support per-user / per-item permissions. <b>Review permissions after your import is done.</b>") ?> - </li> - <li> - <?= t("The only supported file formats are JPG, PNG and GIF, FLV and MP4. Other formats will be skipped.") ?> - </li> - <li> - <?= t("Deactivating the <b>notification</b>, <b>search</b> and <b>exif</b> modules during your import will make it go faster.") ?> - </li> - <li> - <?= t("The eAccelerator and XCache PHP performance extensions are known to cause issues. If you're using either of those and are having problems, please disable them while you do your import. Add the following lines: <pre>%lines</pre> to gallery3/.htaccess and remove them when the import is done.", array("lines" => "\n\n php_value eaccelerator.enable 0\n php_value xcache.cacher off\n php_value xcache.optimizer off\n\n")) ?> - </li> - </ul> - </div> - </div> - - <div class="g-block-content"> - <div> - <h2> <?= t("Migrating from Gallery 2") ?> </h2> - <p> - <?= t("Once your migration is complete, put this block at the top of your gallery2/.htaccess file and all Gallery 2 urls will be redirected to Gallery 3") ?> - </p> - - <textarea rows="4" cols="60"><IfModule mod_rewrite.c> - Options +FollowSymLinks - RewriteEngine On - RewriteBase <?= html::clean(g2_import::$g2_base_url) ?> + <textarea id="g-g2-redirect-rules" rows="4" cols="60"><IfModule mod_rewrite.c> + Options +FollowSymLinks + RewriteEngine On + RewriteBase <?= html::clean(g2_import::$g2_base_url) ?> - RewriteRule ^(.*)$ <?= url::site("g2/map?path=\$1") ?> [QSA,L,R=301] -</IfModule></textarea> - </div> - <? endif ?> + RewriteRule ^(.*)$ <?= url::site("g2/map?path=\$1") ?> [QSA,L,R=301] + </IfModule></textarea> + <script type="text/javascript"> + $(document).ready(function() { + $("#g-g2-redirect-rules").click(function(event) { + this.select(); + }); + }); + </script> + </li> + </ul> </div> </div> </div> diff --git a/modules/gallery/config/locale.php b/modules/gallery/config/locale.php index 0509e45f..13de9098 100644 --- a/modules/gallery/config/locale.php +++ b/modules/gallery/config/locale.php @@ -29,14 +29,10 @@ $config['language'] = array('en_US', 'English_United States'); /** - * Locale timezone. Defaults to use the server timezone. + * Locale timezone. Set in 'Advanced' settings, falling back to the server's zone. * @see http://php.net/timezones */ -$config['timezone'] = ini_get('date.timezone'); -if (empty($config['timezone'])) { - // This is a required field. Pick something as a default. - $config['timezone'] = "America/Los_Angeles"; -} +$config['timezone'] = module::get_var("gallery", "timezone", date_default_timezone_get()); // i18n settings diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php index 055e063c..a968a56d 100644 --- a/modules/gallery/controllers/admin_theme_options.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -59,6 +59,7 @@ class Admin_Theme_Options_Controller extends Admin_Controller { module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value); module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value); module::set_var("gallery", "favicon_url", $form->edit_theme->favicon_url->value); + module::set_var("gallery", "apple_touch_icon_url", $form->edit_theme->apple_touch_icon_url->value); module::event("theme_edit_form_completed", $form); @@ -77,8 +78,10 @@ class Admin_Theme_Options_Controller extends Admin_Controller { $group = $form->group("edit_theme")->label(t("Theme layout")); $group->input("page_size")->label(t("Items per page"))->id("g-page-size") ->rules("required|valid_digit") + ->callback(array($this, "_valididate_page_size")) ->error_messages("required", t("You must enter a number")) ->error_messages("valid_digit", t("You must enter a number")) + ->error_messages("valid_min_value", t("The value must be greater than zero")) ->value(module::get_var("gallery", "page_size")); $group->input("thumb_size")->label(t("Thumbnail size (in pixels)"))->id("g-thumb-size") ->rules("required|valid_digit") @@ -93,6 +96,9 @@ class Admin_Theme_Options_Controller extends Admin_Controller { $group->input("favicon_url")->label(t("URL (or relative path) to your favicon.ico")) ->id("g-favicon") ->value(module::get_var("gallery", "favicon_url")); + $group->input("apple_touch_icon_url")->label(t("URL (or relative path) to your Apple Touch icon")) + ->id("g-apple-touch") + ->value(module::get_var("gallery", "apple_touch_icon_url")); $group->textarea("header_text")->label(t("Header text"))->id("g-header-text") ->value(module::get_var("gallery", "header_text")); $group->textarea("footer_text")->label(t("Footer text"))->id("g-footer-text") @@ -106,5 +112,12 @@ class Admin_Theme_Options_Controller extends Admin_Controller { $group->submit("")->value(t("Save")); return $form; } + + function _valididate_page_size($input) { + if ($input->value < 1) { + $input->add_error("valid_min_value", true); + } + + } } diff --git a/modules/gallery/controllers/admin_themes.php b/modules/gallery/controllers/admin_themes.php index cd8a5530..9cdc3db5 100644 --- a/modules/gallery/controllers/admin_themes.php +++ b/modules/gallery/controllers/admin_themes.php @@ -25,6 +25,9 @@ class Admin_Themes_Controller extends Admin_Controller { $view->content->admin = module::get_var("gallery", "active_admin_theme"); $view->content->site = module::get_var("gallery", "active_site_theme"); $view->content->themes = $this->_get_themes(); + + site_status::clear("missing_site_theme"); + site_status::clear("missing_admin_theme"); print $view; } diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php index b203b7d3..fdf5d7b7 100644 --- a/modules/gallery/controllers/login.php +++ b/modules/gallery/controllers/login.php @@ -42,8 +42,9 @@ class Login_Controller extends Controller { public function html() { $view = new Theme_View("page.html", "other", "login"); - $view->page_title = t("Login"); - $view->content = auth::get_login_form("login/auth_html"); + $view->page_title = t("Log in to Gallery"); + $view->content = new View("login_ajax.html"); + $view->content->form = auth::get_login_form("login/auth_html"); print $view; } diff --git a/modules/gallery/helpers/encoding.php b/modules/gallery/helpers/encoding.php new file mode 100644 index 00000000..c5928634 --- /dev/null +++ b/modules/gallery/helpers/encoding.php @@ -0,0 +1,32 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2011 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 encoding_Core { + static function convert_to_utf8($value) { + if (function_exists("mb_detect_encoding") && + function_exists("mb_convert_encoding") && + mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { + $value = mb_convert_encoding($value, "UTF-8", mb_detect_encoding($value)); + } else if (function_exists("mb_detect_encoding") && + mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { + $value = utf8_encode($value); + } + return $value; + } +}
\ No newline at end of file diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 1fafdef7..cbd9b33c 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -193,19 +193,25 @@ class gallery_Core { */ static function version_string() { if (gallery::RELEASE_CHANNEL == "git") { + $build_number = gallery::build_number(); return sprintf( - "%s (branch %s build %s)", gallery::VERSION, gallery::RELEASE_BRANCH, - gallery::build_number()); + "%s (branch %s, %s)", gallery::VERSION, gallery::RELEASE_BRANCH, + $build_number ? " build $build_number" : "unknown build number"); } else { return sprintf("%s (%s)", gallery::VERSION, gallery::CODE_NAME); } } /** - * Return the contents of the .build_number file, which should be a single integer. + * Return the contents of the .build_number file, which should be a single integer + * or return null if the .build_number file is missing. */ static function build_number() { - $result = parse_ini_file(DOCROOT . ".build_number"); - return $result["build_number"]; + $build_file = DOCROOT . ".build_number"; + if (file_exists($build_file)) { + $result = parse_ini_file(DOCROOT . ".build_number"); + return $result["build_number"]; + } + return null; } }
\ No newline at end of file diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index b9ccf25b..0ba7c936 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -112,6 +112,7 @@ class gallery_block_Core { $block->content->version_info = upgrade_checker::version_info(); $block->content->auto_check_enabled = upgrade_checker::auto_check_enabled(); $block->content->new_version = upgrade_checker::get_upgrade_message(); + $block->content->build_number = gallery::build_number(); } return $block; } diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 07817187..fbdb4ad5 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -539,9 +539,9 @@ class gallery_event_Core { $v = new View("user_profile_info.html"); $fields = array("name" => t("Name"), "locale" => t("Language Preference"), - "email" => t("Email"), "full_name" => t("Full name"), "url" => "Web site"); + "email" => t("Email"), "full_name" => t("Full name"), "url" => t("Web site")); if (!$data->user->guest) { - $fields = array("name" => t("Name"), "full_name" => t("Full name"), "url" => "Web site"); + $fields = array("name" => t("Name"), "full_name" => t("Full name"), "url" => t("Web site")); } $v->user_profile_data = array(); foreach ($fields as $field => $label) { @@ -549,6 +549,8 @@ class gallery_event_Core { $value = $data->user->$field; if ($field == "locale") { $value = locales::display_name($value); + } elseif ($field == "url") { + $value = html::mark_clean(html::anchor($data->user->$field)); } $v->user_profile_data[(string) $label] = $value; } diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 01c59eaa..83c5ed71 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -304,14 +304,16 @@ class gallery_installer { module::set_var("gallery", "maintenance_mode", 0); module::set_var("gallery", "visible_title_length", 15); module::set_var("gallery", "favicon_url", "lib/images/favicon.ico"); + module::set_var("gallery", "apple_touch_icon_url", "lib/images/apple-touch-icon.png"); module::set_var("gallery", "email_from", ""); module::set_var("gallery", "email_reply_to", ""); module::set_var("gallery", "email_line_length", 70); module::set_var("gallery", "email_header_separator", serialize("\n")); module::set_var("gallery", "show_user_profiles_to", "registered_users"); module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin"); + module::set_var("gallery", "timezone", Kohana::config("locale.timezone")); - module::set_version("gallery", 46); + module::set_version("gallery", 48); } static function upgrade($version) { @@ -677,6 +679,18 @@ class gallery_installer { module::set_var("gallery", "upgrade_checker_auto_enabled", true); module::set_version("gallery", $version = 46); } + + if ($version == 46) { + module::set_var("gallery", "apple_touch_icon_url", "lib/images/apple-touch-icon.png"); + module::set_version("gallery", $version = 47); + } + + if ($version == 47) { + // Add configuration variable to set timezone. Defaults to the currently + // used timezone (from PHP configuration). + module::set_var("gallery", "timezone", Kohana::config("locale.timezone")); + module::set_version("gallery", $version = 48); + } } static function uninstall() { diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index c4a82390..e07839d9 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -64,7 +64,7 @@ class gallery_theme_Core { if ($session->get("l10n_mode", false)) { $buf .= $theme->css("l10n_client.css"); $buf .= $theme->script("jquery.cookie.js"); - $buf .=$theme->script("l10n_client.js"); + $buf .= $theme->script("l10n_client.js"); } return $buf; } diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 1a5c631e..7e779544 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -152,8 +152,18 @@ class item_Core { * @param string $filename */ static function convert_filename_to_slug($filename) { - $result = pathinfo($filename, PATHINFO_FILENAME); + $result = str_replace("&", "-and-", $filename); + $result = str_replace(" ", "-", $result); + + // It's not easy to extend the text helper since it's called by the Input class which is + // referenced in hooks/init_gallery, so it's + if (class_exists("transliterate")) { + $result = transliterate::utf8_to_ascii($result); + } else { + $result = text::transliterate_to_ascii($result); + } $result = preg_replace("/[^A-Za-z0-9-_]+/", "-", $result); + $result = preg_replace("/-+/", "-", $result); return trim($result, "-"); } diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index f285834c..37707f28 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -41,11 +41,34 @@ class theme_Core { $config = Kohana_Config::instance(); $modules = $config->get("core.modules"); + + // Normally Router::find_uri() strips off the url suffix for us, but we're working off of the + // PATH_INFO here so we need to strip it off manually + if ($suffix = Kohana::config("core.url_suffix")) { + $path = preg_replace("#" . preg_quote($suffix) . "$#u", "", $path); + } + self::$is_admin = $path == "/admin" || !strncmp($path, "/admin/", 7); self::$site_theme_name = module::get_var("gallery", "active_site_theme"); + + // If the site theme doesn't exist, fall back to wind. + if (!file_exists(THEMEPATH . self::$site_theme_name . "/theme.info")) { + site_status::error(t("Theme '%name' is missing. Falling back to the Wind theme.", + array("name" => self::$site_theme_name)), "missing_site_theme"); + module::set_var("gallery", "active_site_theme", self::$site_theme_name = "wind"); + } + if (self::$is_admin) { // Load the admin theme self::$admin_theme_name = module::get_var("gallery", "active_admin_theme"); + + // If the admin theme doesn't exist, fall back to admin_wind. + if (!file_exists(THEMEPATH . self::$admin_theme_name . "/theme.info")) { + site_status::error(t("Admin theme '%name' is missing! Falling back to the Wind theme.", + array("name" => self::$admin_theme_name)), "missing_admin_theme"); + module::set_var("gallery", "active_admin_theme", self::$admin_theme_name = "admin_wind"); + } + array_unshift($modules, THEMEPATH . self::$admin_theme_name); // If the site theme has an admin subdir, load that as a module so that diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 562f7929..77e3d204 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -111,6 +111,8 @@ class Gallery_View_Core extends View { $contents = $cache->get($key); if (empty($contents)) { + module::event("before_combine", $type, $this->combine_queue[$type][$group]); + $contents = ""; foreach (array_keys($this->combine_queue[$type][$group]) as $path) { if ($type == "css") { @@ -120,6 +122,8 @@ class Gallery_View_Core extends View { } } + module::event("after_combine", $type, $contents); + $cache->set($key, $contents, array($type), 30 * 84600); $use_gzip = function_exists("gzencode") && @@ -128,6 +132,7 @@ class Gallery_View_Core extends View { $cache->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP), array($type, "gzip"), 30 * 84600); } + } unset($this->combine_queue[$type][$group]); @@ -158,6 +163,7 @@ class Gallery_View_Core extends View { $replace[] = "url('" . url::abs_file($relative) . "')"; } else { Kohana_Log::add("error", "Missing URL reference '{$match[1]}' in CSS file '$css_file'"); + } } $replace = str_replace(DIRECTORY_SEPARATOR, "/", $replace); diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 8f4bc5e4..f46db696 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -336,9 +336,7 @@ class Item_Model_Core extends ORM_MPTT { // Make an url friendly slug from the name, if necessary if (empty($this->slug)) { - $tmp = pathinfo($this->name, PATHINFO_FILENAME); - $tmp = preg_replace("/[^A-Za-z0-9-_]+/", "-", $tmp); - $this->slug = trim($tmp, "-"); + $this->slug = item::convert_filename_to_slug($this->name); // If the filename is all invalid characters, then the slug may be empty here. Pick a // random value. diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 4c0c8866..807d08fd 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 46 +version = 48 diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php index 4d5aed41..2fde7cc0 100644 --- a/modules/gallery/tests/Item_Helper_Test.php +++ b/modules/gallery/tests/Item_Helper_Test.php @@ -49,6 +49,10 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case { public function convert_filename_to_slug_test() { $this->assert_equal("foo", item::convert_filename_to_slug("{[foo]}")); $this->assert_equal("foo-bar", item::convert_filename_to_slug("{[foo!@#!$@#^$@($!(@bar]}")); + $this->assert_equal("english-text", item::convert_filename_to_slug("english text")); + $this->assert_equal("new-line", item::convert_filename_to_slug("new \n line")); + $this->assert_equal("foo-and-bar", item::convert_filename_to_slug("foo&bar")); + $this->assert_equal("special", item::convert_filename_to_slug("šṗëçîąļ")); } public function move_test() { diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php index 01d1ce3f..eef087e1 100644 --- a/modules/gallery/views/admin_languages.html.php +++ b/modules/gallery/views/admin_languages.html.php @@ -51,7 +51,7 @@ <? foreach ($available_locales as $code => $display_name): ?> <? if ($i == (int) (count($available_locales)/2)): ?> </table> - <table> + <table class="g-left"> <tr> <th> <?= t("Installed") ?> </th> <th> <?= t("Language") ?> </th> diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php index f4ae965c..2cc81b0d 100644 --- a/modules/gallery/views/admin_modules.html.php +++ b/modules/gallery/views/admin_modules.html.php @@ -6,7 +6,7 @@ dataType: "json", success: function(data) { if (data.reload) { - window.location.reload(); + window.location = "<? url::site("/admin/modules") ?>"; } else { $("body").append('<div id="g-dialog">' + data.dialog + '</div>'); $("#g-dialog").dialog({ diff --git a/modules/gallery/views/upgrade_checker_block.html.php b/modules/gallery/views/upgrade_checker_block.html.php index b04887b2..c984d99f 100644 --- a/modules/gallery/views/upgrade_checker_block.html.php +++ b/modules/gallery/views/upgrade_checker_block.html.php @@ -6,8 +6,10 @@ <p> <? if (gallery::RELEASE_CHANNEL == "release"): ?> <?= t("You are using the official Gallery %version release, code named <i>%code_name</i>.", array("version" => gallery::VERSION, "code_name" => gallery::CODE_NAME)) ?> + <? elseif (isset($build_number)): ?> + <?= t("You are using an experimental snapshot of Gallery %version (build %build_number on branch %branch).", array("version" => gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => $build_number)) ?> <? else: ?> - <?= t("You are using an experimental snapshot of Gallery %version (build %build_number on branch %branch).", array("version" => gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => gallery::build_number())) ?> + <?= t("You are using an experimental snapshot of Gallery %version (branch %branch) but your gallery3/.build_number file is missing so we don't know what build you have. You should probably upgrade so that you have that file.", array("version" => gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => $build_number)) ?> <? endif ?> </p> diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index eef009a0..261d67ee 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -22,14 +22,16 @@ class Search_Controller extends Controller { $page_size = module::get_var("gallery", "page_size", 9); $q = Input::instance()->get("q"); $page = Input::instance()->get("page", 1); - $offset = ($page - 1) * $page_size; // Make sure that the page references a valid offset if ($page < 1) { $page = 1; } - list ($count, $result) = search::search($q, $page_size, $offset); + $offset = ($page - 1) * $page_size; + + $q_with_more_terms = search::add_query_terms($q); + list ($count, $result) = search::search($q_with_more_terms, $page_size, $offset); $max_pages = max(ceil($count / $page_size), 1); diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 09e5e83f..bbde8feb 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -18,6 +18,22 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class search_Core { + /** + * Add more terms to the query by wildcarding the stem value of the first + * few terms in the query. + */ + static function add_query_terms($q) { + $MAX_TERMS = 5; + $terms = explode(" ", $q, $MAX_TERMS); + for ($i = 0; $i < min(count($terms), $MAX_TERMS - 1); $i++) { + // Don't wildcard quoted or already wildcarded terms + if ((substr($terms[$i], 0, 1) != '"') && (substr($terms[$i], -1, 1) != "*")) { + $terms[] = rtrim($terms[$i], "s") . "*"; + } + } + return implode(" ", $terms); + } + static function search($q, $limit, $offset) { $db = Database::instance(); $q = $db->escape($q); diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 2afa93a7..ea8907f4 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -286,7 +286,7 @@ class Server_Add_Controller extends Admin_Controller { } catch (Exception $e) { // This can happen if a photo file is invalid, like a BMP masquerading as a .jpg $entry->item_id = 0; - $task->log("Skipping invalid file: {$entry->file}"); + $task->log("Skipping invalid file: {$entry->path}"); } } diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php index fe6d747b..bf41c4df 100644 --- a/modules/tag/controllers/tags.php +++ b/modules/tag/controllers/tags.php @@ -22,7 +22,8 @@ class Tags_Controller extends Controller { // Far from perfection, but at least require view permission for the root album $album = ORM::factory("item", 1); access::required("view", $album); - print tag::cloud(30); + + print tag::cloud(module::get_var("tag", "tag_cloud_size", 30)); } public function create($item_id) { diff --git a/modules/tag/helpers/tag_block.php b/modules/tag/helpers/tag_block.php index 8df58a6e..69a9a1c4 100644 --- a/modules/tag/helpers/tag_block.php +++ b/modules/tag/helpers/tag_block.php @@ -30,7 +30,7 @@ class tag_block_Core { $block->css_id = "g-tag"; $block->title = t("Popular tags"); $block->content = new View("tag_block.html"); - $block->content->cloud = tag::cloud(30); + $block->content->cloud = tag::cloud(module::get_var("tag", "tag_cloud_size", 30)); if ($theme->item() && $theme->page_subtype() != "tag" && access::can("edit", $theme->item())) { $controller = new Tags_Controller(); diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index cd79f734..b415b42d 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -36,10 +36,7 @@ class tag_event_Core { $tag = str_replace("\0", "", $tag); foreach (explode(",", $tag) as $word) { $word = trim($word); - if (function_exists("mb_detect_encoding") && - mb_detect_encoding($word, "ISO-8859-1, UTF-8") != "UTF-8") { - $word = utf8_encode($word); - } + $word = encoding::convert_to_utf8($word); $tags[$word] = 1; } } @@ -113,11 +110,11 @@ class tag_event_Core { } static function add_photos_form($album, $form) { - if (!isset($group->uploadify)) { + $group = $form->add_photos; + if (!is_object($group->uploadify)) { return; } - $group = $form->add_photos; $group->input("tags") ->label(t("Add tags to all uploaded files")) ->value(""); @@ -136,7 +133,8 @@ class tag_event_Core { } static function add_photos_form_completed($album, $form) { - if (!isset($group->uploadify)) { + $group = $form->add_photos; + if (!is_object($group->uploadify)) { return; } @@ -151,7 +149,7 @@ class tag_event_Core { static function info_block_get_metadata($block, $item) { $tags = array(); foreach (tag::item_tags($item) as $tag) { - $tags[] = "<a href=\"" . url::site("tag/{$tag->name}") . "\">{$tag->name}</a>"; + $tags[] = "<a href=\"{$tag->url()}\">{$tag->name}</a>"; } if ($tags) { $info = $block->content->metadata; diff --git a/modules/tag/helpers/tag_installer.php b/modules/tag/helpers/tag_installer.php index 16ad1239..66a78b91 100644 --- a/modules/tag/helpers/tag_installer.php +++ b/modules/tag/helpers/tag_installer.php @@ -36,7 +36,8 @@ class tag_installer { KEY(`tag_id`, `id`), KEY(`item_id`, `id`)) DEFAULT CHARSET=utf8;"); - module::set_version("tag", 2); + module::set_var("tag", "tag_cloud_size", 30); + module::set_version("tag", 3); } static function upgrade($version) { @@ -45,6 +46,10 @@ class tag_installer { $db->query("ALTER TABLE {tags} MODIFY COLUMN `name` VARCHAR(128)"); module::set_version("tag", $version = 2); } + if ($version == 2) { + module::set_var("tag", "tag_cloud_size", 30); + module::set_version("tag", $version = 3); + } } static function uninstall() { diff --git a/modules/tag/helpers/tag_item_rest.php b/modules/tag/helpers/tag_item_rest.php index a8d3d0bc..be1fa653 100644 --- a/modules/tag/helpers/tag_item_rest.php +++ b/modules/tag/helpers/tag_item_rest.php @@ -29,6 +29,7 @@ class tag_item_rest_Core { static function delete($request) { list ($tag, $item) = rest::resolve($request->url); + access::required("edit", $item); $tag->remove($item); $tag->save(); } diff --git a/modules/tag/helpers/tag_items_rest.php b/modules/tag/helpers/tag_items_rest.php index 535ab513..8ed07276 100644 --- a/modules/tag/helpers/tag_items_rest.php +++ b/modules/tag/helpers/tag_items_rest.php @@ -51,6 +51,7 @@ class tag_items_rest_Core { static function delete($request) { list ($tag, $item) = rest::resolve($request->url); + access::required("edit", $item); $tag->remove($item); $tag->save(); } diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index 479a7da0..bd665667 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -132,7 +132,7 @@ class Tag_Model_Core extends ORM { * @param string $query the query string (eg "page=3") */ public function url($query=null) { - $url = url::site("tag/{$this->id}/{$this->name}"); + $url = url::site("tag/{$this->id}/" . urlencode($this->name)); if ($query) { $url .= "?$query"; } diff --git a/modules/tag/module.info b/modules/tag/module.info index 8851d119..d9d34386 100644 --- a/modules/tag/module.info +++ b/modules/tag/module.info @@ -1,3 +1,3 @@ name = "Tags" description = "Allows users to tag photos and albums" -version = 2 +version = 3 diff --git a/modules/user/views/admin_users_group.html.php b/modules/user/views/admin_users_group.html.php index 2362e42b..31b91351 100644 --- a/modules/user/views/admin_users_group.html.php +++ b/modules/user/views/admin_users_group.html.php @@ -17,7 +17,7 @@ <? if ($group->users->count_all() > 0): ?> <ul class="g-member-list"> - <? foreach ($group->users->find_all() as $i => $user): ?> + <? foreach ($group->users->order_by("name", "ASC")->find_all() as $i => $user): ?> <li class="g-user"> <?= html::clean($user->name) ?> <? if (!$group->special): ?> diff --git a/themes/admin_wind/views/admin.html.php b/themes/admin_wind/views/admin.html.php index a56b6f41..12301e02 100644 --- a/themes/admin_wind/views/admin.html.php +++ b/themes/admin_wind/views/admin.html.php @@ -15,6 +15,8 @@ <link rel="shortcut icon" href="<?= url::file(module::get_var("gallery", "favicon_url")) ?>" type="image/x-icon" /> + <link rel="apple-touch-icon-precomposed" + href="<?= url::file(module::get_var("gallery", "apple_touch_icon_url")) ?>" /> <?= $theme->script("jquery.js") ?> <?= $theme->script("jquery.form.js") ?> diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index 2b86556d..1c67ff9d 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -21,7 +21,8 @@ <link rel="shortcut icon" href="<?= url::file(module::get_var("gallery", "favicon_url")) ?>" type="image/x-icon" /> - + <link rel="apple-touch-icon-precomposed" + href="<?= url::file(module::get_var("gallery", "apple_touch_icon_url")) ?>" /> <? if ($theme->page_type == "collection"): ?> <? if ($thumb_proportion != 1): ?> <? $new_width = round($thumb_proportion * 213) ?> |