From 050c5a0383b6b1729dbd828d820d5eb347d1b795 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 30 Jun 2009 17:58:33 -0700 Subject: Unlink the old rewritten path files in var/modules/g2_import when we validate the embed path. This resolves an issue with b1 installs which had versions of the rewritten code that were buggy and can be replaced. --- modules/g2_import/helpers/g2_import.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 91ca1e63..910f9342 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -46,6 +46,10 @@ class g2_import_Core { } static function is_valid_embed_path($embed_path) { + $mod_path = VARPATH . "modules/g2_import/" . md5($embed_path); + if (file_exists($mod_path)) { + dir::unlink($mod_path); + } return file_exists($embed_path) && g2_import::init_embed($embed_path); } -- cgit v1.2.3 From 6f3ec5f03914324f596e51f22f2df49ec48e8053 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 1 Jul 2009 22:18:52 -0700 Subject: Fix for ticket #357. Changed the set the created date as part of the import and change models/comment::save() to not set the creation date if it is already set. --- modules/comment/models/comment.php | 2 +- modules/g2_import/helpers/g2_import.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index ec4d4794..22c465df 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -59,7 +59,7 @@ class Comment_Model extends ORM { public function save() { if (!empty($this->changed)) { $this->updated = time(); - if (!$this->loaded) { + if (!$this->loaded && empty($this->created)) { $this->created = $this->updated; } } diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 910f9342..c2ad443c 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -554,6 +554,7 @@ class g2_import_Core { $comment->text = $text; $comment->state = "published"; $comment->server_http_host = $g2_comment->getHost(); + $comment->created = $g2_comment->getDate(); $comment->save(); self::map($g2_comment->getId(), $comment->id); -- cgit v1.2.3 From 7bc40fd3152c35d95b69b320c351d91a7ca0675a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 1 Jul 2009 23:14:01 -0700 Subject: Start of fixing a problem with importing movies w/o a thumbnail --- modules/g2_import/helpers/g2_import.php | 48 ++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index c2ad443c..93d92659 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -638,33 +638,37 @@ class g2_import_Core { $target_thumb_size = module::get_var("gallery", "thumb_size"); $target_resize_size = module::get_var("gallery", "resize_size"); - foreach ($derivatives[$g2_item_id] as $derivative) { - if ($derivative->getPostFilterOperations()) { - // Let's assume for now that this is a watermark operation, which we can't handle. - continue; - } + if (!empty($derivatives[$g2_item_id])) { + foreach ($derivatives[$g2_item_id] as $derivative) { + if ($derivative->getPostFilterOperations()) { + // Let's assume for now that this is a watermark operation, which we can't handle. + continue; + } - if ($derivative->getDerivativeType() == DERIVATIVE_TYPE_IMAGE_THUMBNAIL && - $item->thumb_dirty && - ($derivative->getWidth() == $target_thumb_size || - $derivative->getHeight() == $target_thumb_size)) { - if (@copy(g2($derivative->fetchPath()), $item->thumb_path())) { - $item->thumb_height = $derivative->getHeight(); - $item->thumb_width = $derivative->getWidth(); - $item->thumb_dirty = false; + if ($derivative->getDerivativeType() == DERIVATIVE_TYPE_IMAGE_THUMBNAIL && + $item->thumb_dirty && + ($derivative->getWidth() == $target_thumb_size || + $derivative->getHeight() == $target_thumb_size)) { + if (@copy(g2($derivative->fetchPath()), $item->thumb_path())) { + $item->thumb_height = $derivative->getHeight(); + $item->thumb_width = $derivative->getWidth(); + $item->thumb_dirty = false; + } } - } - if ($derivative->getDerivativeType() == DERIVATIVE_TYPE_IMAGE_RESIZE && - $item->resize_dirty && - ($derivative->getWidth() == $target_resize_size || - $derivative->getHeight() == $target_resize_size)) { - if (@copy(g2($derivative->fetchPath()), $item->resize_path())) { - $item->resize_height = $derivative->getHeight(); - $item->resize_width = $derivative->getWidth(); - $item->resize_dirty = false; + if ($derivative->getDerivativeType() == DERIVATIVE_TYPE_IMAGE_RESIZE && + $item->resize_dirty && + ($derivative->getWidth() == $target_resize_size || + $derivative->getHeight() == $target_resize_size)) { + if (@copy(g2($derivative->fetchPath()), $item->resize_path())) { + $item->resize_height = $derivative->getHeight(); + $item->resize_width = $derivative->getWidth(); + $item->resize_dirty = false; + } } } + } else { + // @todo Figure out away to create the thumbnail and resizes? } $item->save(); } -- cgit v1.2.3 From a13ddfea8fb461d38263fc90f40ecbe37a15029b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 2 Jul 2009 07:53:24 -0700 Subject: Suppress the filesize error if the thumbnail is not found so we can get an EMPTY_INPUT_FILE exception which we can then log and continue. --- modules/g2_import/helpers/g2_import.php | 2 -- modules/gallery/helpers/graphics.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 93d92659..71199eaf 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -667,8 +667,6 @@ class g2_import_Core { } } } - } else { - // @todo Figure out away to create the thumbnail and resizes? } $item->save(); } diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 71b8ddd8..bbae0602 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -195,7 +195,7 @@ class graphics_Core { self::init_toolkit(); } - if (filesize($input_file) == 0) { + if (@filesize($input_file) == 0) { throw new Exception("@todo EMPTY_INPUT_FILE"); } -- cgit v1.2.3 From 1c9dee93de837e7bf4a2ba038388ae1836653e0a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 2 Jul 2009 09:54:50 -0700 Subject: Fix for ticket #390. Added a call to GalleryCoreApi::fetchItemViewCounts to retrieve the gallery2 view counts forthe imported items. --- modules/g2_import/helpers/g2_import.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 71199eaf..0a4013ca 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -402,6 +402,7 @@ class g2_import_Core { $g2_album = ORM::factory("item", $g3_album_id); $g2_album->album_cover_item_id = $item->id; $g2_album->thumb_dirty = 1; + $g2_album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id)); $g2_album->save(); graphics::generate($g2_album); } @@ -498,6 +499,8 @@ class g2_import_Core { if (isset($item)) { self::set_map($g2_item_id, $item->id); + $item->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_item_id)); + $item->save(); } if ($corrupt) { -- cgit v1.2.3 From adb820e37c95277b07ade93b2404fb3bc213380a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 2 Jul 2009 20:48:47 -0700 Subject: Fix for ticket #359 and a partial fix for ticket #345. In G2, text strings have the &, ", < and > replaced by &, "e;, < and > respectively. Created the _decode_html_special_chars method in helpers/g2_import.php to revert these character strings. --- modules/g2_import/helpers/g2_import.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 0a4013ca..a2d0797d 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -341,8 +341,8 @@ class g2_import_Core { $album = album::create( $parent_album, $g2_album->getPathComponent(), - $g2_album->getTitle(), - self::extract_description($g2_album), + self::_decode_html_special_chars($g2_album->getTitle()), + self::_decode_html_special_chars(self::extract_description($g2_album)), self::map($g2_album->getOwnerId())); $album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id)); @@ -455,12 +455,14 @@ class g2_import_Core { $corrupt = 1; } try { + Kohana::log("error", "description: " . self::extract_description($g2_item)); + Kohana::log("error", "title: " . $g2_item->getTitle()); $item = photo::create( $parent, $g2_path, $g2_item->getPathComponent(), - $g2_item->getTitle(), - self::extract_description($g2_item), + self::_decode_html_special_chars($g2_item->getTitle()), + self::_decode_html_special_chars(self::extract_description($g2_item)), self::map($g2_item->getOwnerId())); } catch (Exception $e) { Kohana::log( @@ -477,8 +479,8 @@ class g2_import_Core { $parent, $g2_path, $g2_item->getPathComponent(), - $g2_item->getTitle(), - self::extract_description($g2_item), + self::_decode_html_special_chars($g2_item->getTitle()), + self::_decode_html_special_chars(self::extract_description($g2_item)), self::map($g2_item->getOwnerId())); } catch (Exception $e) { Kohana::log("alert", "Corrupt movie $g2_path\n" . @@ -528,6 +530,15 @@ class g2_import_Core { self::$current_g2_item = null; } + /** + * g2 encoded'&', '"', '<' and '>' as '&', '"', '<' and '>' respectively. + * This function undoes that encoding. + */ + private static function _decode_html_special_chars($value) { + return str_replace(array("&", """, "<", ">"), + array("&", "\"", "<", ">"), $value); + } + /** * Import a single comment. */ -- cgit v1.2.3 From cf279fc315841836f92c8a81935db00bb3a919ff Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 3 Jul 2009 08:14:28 -0700 Subject: Fix for #364 = G2 Import Doesn't support markup Create a _transform_bbcode which coverts the g2 bbcode to html. The html won't be rendered until ticket #400 is implemented as pclean() excapse the html --- modules/g2_import/helpers/g2_import.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index a2d0797d..91fcbe8e 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -565,7 +565,7 @@ class g2_import_Core { $comment->author_id = self::map($g2_comment->getCommenterId()); $comment->guest_name = $g2_comment->getAuthor(); $comment->item_id = self::map($g2_comment->getParentId()); - $comment->text = $text; + $comment->text = self::_transform_bbcode($text); $comment->state = "published"; $comment->server_http_host = $g2_comment->getHost(); $comment->created = $g2_comment->getDate(); @@ -752,7 +752,29 @@ class g2_import_Core { } else { $description = $g2_summary . " " . $g2_description; } - return $description; + return self::_transform_bbcode($description); + } + + static $bbcode_mappings = array( + "#\\[b\\](.*?)\\[/b\\]#" => "$1", + "#\\[i\\](.*?)\\[/i\\]#" => "$1", + "#\\[u\\](.*?)\\[/u\\]#" => "$1", + "#\\[s\\](.*?)\\[/s\\]#" => "$1", + "#\\[url\\](.*?)\[/url\\]#" => "$1", + "#\\[url=(.*?)\\](.*?)\[/url\\]#" => "$2", + "#\\[img\\](.*?)\\[/img\\]#" => "", + "#\\[quote\\](.*?)\\[/quote\\]#" => "

$1

", + "#\\[code\\](.*?)\\[/code\\]#" => "
$1
", + "#\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]#" => "$2/span>", + "#\\[ul\\](.*?)\\/ul\\]#" => "
    $1
", + "#\\[li\\](.*?)\\[/li\\]#" => "
  • $1
  • ", + ); + private static function _transform_bbcode($text) { + if (strpos($text, "[") !== false) { + $text = preg_replace(array_keys(self::$bbcode_mappings), array_values(self::$bbcode_mappings), + $text); + } + return $text; } /** -- cgit v1.2.3 From 4ba022438e29dd305435a18e94a0bc08b5dd76a4 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 4 Jul 2009 16:18:48 -0700 Subject: Change the bbcode transformation to more standard tags that can be easily style via css --- modules/g2_import/helpers/g2_import.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 91fcbe8e..79f3b197 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -756,16 +756,17 @@ class g2_import_Core { } static $bbcode_mappings = array( - "#\\[b\\](.*?)\\[/b\\]#" => "$1", - "#\\[i\\](.*?)\\[/i\\]#" => "$1", - "#\\[u\\](.*?)\\[/u\\]#" => "$1", - "#\\[s\\](.*?)\\[/s\\]#" => "$1", + "#\\[b\\](.*?)\\[/b\\]#" => "$1", + "#\\[i\\](.*?)\\[/i\\]#" => "$1", + "#\\[u\\](.*?)\\[/u\\]#" => "$1", + "#\\[s\\](.*?)\\[/s\\]#" => "$1", "#\\[url\\](.*?)\[/url\\]#" => "$1", "#\\[url=(.*?)\\](.*?)\[/url\\]#" => "$2", "#\\[img\\](.*?)\\[/img\\]#" => "", "#\\[quote\\](.*?)\\[/quote\\]#" => "

    $1

    ", "#\\[code\\](.*?)\\[/code\\]#" => "
    $1
    ", - "#\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]#" => "$2/span>", + "#\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]#" => "$2", + "#\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]#" => "$2", "#\\[ul\\](.*?)\\/ul\\]#" => "
      $1
    ", "#\\[li\\](.*?)\\[/li\\]#" => "
  • $1
  • ", ); -- cgit v1.2.3 From 799d82fd6a47196bc69d1e9f23fc61ea2d331208 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 4 Jul 2009 17:01:47 -0700 Subject: Revert "Change the bbcode transformation to more standard tags that can be" This reverts commit 4ba022438e29dd305435a18e94a0bc08b5dd76a4. --- modules/g2_import/helpers/g2_import.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 79f3b197..91fcbe8e 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -756,17 +756,16 @@ class g2_import_Core { } static $bbcode_mappings = array( - "#\\[b\\](.*?)\\[/b\\]#" => "$1", - "#\\[i\\](.*?)\\[/i\\]#" => "$1", - "#\\[u\\](.*?)\\[/u\\]#" => "$1", - "#\\[s\\](.*?)\\[/s\\]#" => "$1", + "#\\[b\\](.*?)\\[/b\\]#" => "$1", + "#\\[i\\](.*?)\\[/i\\]#" => "$1", + "#\\[u\\](.*?)\\[/u\\]#" => "$1", + "#\\[s\\](.*?)\\[/s\\]#" => "$1", "#\\[url\\](.*?)\[/url\\]#" => "$1", "#\\[url=(.*?)\\](.*?)\[/url\\]#" => "$2", "#\\[img\\](.*?)\\[/img\\]#" => "", "#\\[quote\\](.*?)\\[/quote\\]#" => "

    $1

    ", "#\\[code\\](.*?)\\[/code\\]#" => "
    $1
    ", - "#\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]#" => "$2", - "#\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]#" => "$2", + "#\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]#" => "$2/span>", "#\\[ul\\](.*?)\\/ul\\]#" => "
      $1
    ", "#\\[li\\](.*?)\\[/li\\]#" => "
  • $1
  • ", ); -- cgit v1.2.3 From 50462edd9c72156d841991245a4ef34624f9a3c7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 4 Jul 2009 17:14:21 -0700 Subject: Change the BBCode Transformation to use the where possible --- modules/g2_import/helpers/g2_import.php | 9 +++++---- themes/default/css/screen.css | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 91fcbe8e..cba1d429 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -756,15 +756,16 @@ class g2_import_Core { } static $bbcode_mappings = array( - "#\\[b\\](.*?)\\[/b\\]#" => "$1", - "#\\[i\\](.*?)\\[/i\\]#" => "$1", - "#\\[u\\](.*?)\\[/u\\]#" => "$1", - "#\\[s\\](.*?)\\[/s\\]#" => "$1", + "#\\[b\\](.*?)\\[/b\\]#" => "$1", + "#\\[i\\](.*?)\\[/i\\]#" => "$1", + "#\\[u\\](.*?)\\[/u\\]#" => "$1", + "#\\[s\\](.*?)\\[/s\\]#" => "$1", "#\\[url\\](.*?)\[/url\\]#" => "$1", "#\\[url=(.*?)\\](.*?)\[/url\\]#" => "$2", "#\\[img\\](.*?)\\[/img\\]#" => "", "#\\[quote\\](.*?)\\[/quote\\]#" => "

    $1

    ", "#\\[code\\](.*?)\\[/code\\]#" => "
    $1
    ", + "#\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]#" => "$2", "#\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]#" => "$2/span>", "#\\[ul\\](.*?)\\/ul\\]#" => "
      $1
    ", "#\\[li\\](.*?)\\[/li\\]#" => "
  • $1
  • ", diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index 7a41e970..750639f1 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -13,6 +13,7 @@ * 7) Browser hacks * 8) jQuery and jQuery UI * 9) Right-to-left language styles + * 10) BBCode Styles */ /** ******************************************************************* @@ -1064,3 +1065,21 @@ form .gError, .rtl .ui-icon-left .ui-icon { float: right; } + +/* BBCode ~~~~~~~~~~~~~~~~~~~~ */ +.gBBCodeBold { + font-weight: bold; +} + +.gBBCodeItalic { + font-style: italic; +} + +.gBBCodeUnderline { + text-decoration: underline; +} + +.gBBCodeStrike { + font-decoration: line-through; +} + -- cgit v1.2.3 From 85de2088798e2b5eac7cb26bf48e17b8034f3fb7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 4 Jul 2009 20:30:13 -0700 Subject: Lets try the BBCode conversion again... go with basic tags even if some are deprecated. --- modules/g2_import/helpers/g2_import.php | 12 ++++++------ themes/default/css/screen.css | 18 ------------------ 2 files changed, 6 insertions(+), 24 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index cba1d429..2e40eb7f 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -756,17 +756,17 @@ class g2_import_Core { } static $bbcode_mappings = array( - "#\\[b\\](.*?)\\[/b\\]#" => "$1", - "#\\[i\\](.*?)\\[/i\\]#" => "$1", - "#\\[u\\](.*?)\\[/u\\]#" => "$1", - "#\\[s\\](.*?)\\[/s\\]#" => "$1", + "#\\[b\\](.*?)\\[/b\\]#" => "$1", + "#\\[i\\](.*?)\\[/i\\]#" => "$1", + "#\\[u\\](.*?)\\[/u\\]#" => "$1", + "#\\[s\\](.*?)\\[/s\\]#" => "$1", "#\\[url\\](.*?)\[/url\\]#" => "$1", "#\\[url=(.*?)\\](.*?)\[/url\\]#" => "$2", "#\\[img\\](.*?)\\[/img\\]#" => "", "#\\[quote\\](.*?)\\[/quote\\]#" => "

    $1

    ", "#\\[code\\](.*?)\\[/code\\]#" => "
    $1
    ", - "#\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]#" => "$2", - "#\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]#" => "$2/span>", + "#\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]#" => "$2", + "#\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]#" => "$2/font>", "#\\[ul\\](.*?)\\/ul\\]#" => "
      $1
    ", "#\\[li\\](.*?)\\[/li\\]#" => "
  • $1
  • ", ); diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index 750639f1..41e51623 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -13,7 +13,6 @@ * 7) Browser hacks * 8) jQuery and jQuery UI * 9) Right-to-left language styles - * 10) BBCode Styles */ /** ******************************************************************* @@ -1066,20 +1065,3 @@ form .gError, float: right; } -/* BBCode ~~~~~~~~~~~~~~~~~~~~ */ -.gBBCodeBold { - font-weight: bold; -} - -.gBBCodeItalic { - font-style: italic; -} - -.gBBCodeUnderline { - text-decoration: underline; -} - -.gBBCodeStrike { - font-decoration: line-through; -} - -- cgit v1.2.3 From dff0ffc4f533f02193472438ba804801ccb81449 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 6 Jul 2009 20:05:35 -0700 Subject: Fix for tickets #312 and #370. Added a task logging api. Changed g2_import to write all activity to the "log file". The "log file" is stored in the persistent cache. --- modules/g2_import/helpers/g2_import.php | 114 ++++++++++++++++++--------- modules/g2_import/helpers/g2_import_task.php | 35 ++++++-- 2 files changed, 106 insertions(+), 43 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 2e40eb7f..7cce4aa2 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -217,15 +217,14 @@ class g2_import_Core { static function import_group(&$queue) { $g2_group_id = array_shift($queue); if (self::map($g2_group_id)) { - return; + return t("Group with id: %id already imported, skipping", array("id" => $g2_group_id)); } try { $g2_group = g2(GalleryCoreApi::loadEntitiesById($g2_group_id)); } catch (Exception $e) { - g2_import::log( - t("Failed to import Gallery 2 group with id: %id", array("id" => $g2_group_id))); - return; + return t("Failed to import Gallery 2 group with id: %id\n%exception", + array("id" => $g2_group_id, "exception" => $e->__toString())); } switch ($g2_group->getGroupType()) { @@ -236,24 +235,29 @@ class g2_import_Core { // @todo For now we assume this is a "duplicate group" exception $group = group::lookup_by_name($g2_group->getGroupname()); } - + $message = t("Group '%name' was imported", array("name" => $g2_group->getGroupname())); break; case GROUP_ALL_USERS: $group = group::registered_users(); + $message = t("Group 'Registered' was converted to '%name'", array("name" => $group->name)); break; case GROUP_SITE_ADMINS: + $message = t("Group 'Admin'does not exist in gallery3, skipping"); break; // This is not a group in G3 case GROUP_EVERYBODY: $group = group::everybody(); + $message = t("Group 'Everybody' was converted to '%name'", array("name" => $group->name)); break; } if (isset($group)) { self::set_map($g2_group->getId(), $group->id); } + + return $message; } /** @@ -262,12 +266,12 @@ class g2_import_Core { static function import_user(&$queue) { $g2_user_id = array_shift($queue); if (self::map($g2_user_id)) { - return; + return t("User with id: %id already imported, skipping", array("id" => $g2_user_id)); } if (g2(GalleryCoreApi::isAnonymousUser($g2_user_id))) { self::set_map($g2_user_id, user::guest()->id); - return; + return t("Skipping Anonymous User"); } $g2_admin_group_id = @@ -275,17 +279,18 @@ class g2_import_Core { try { $g2_user = g2(GalleryCoreApi::loadEntitiesById($g2_user_id)); } catch (Exception $e) { - g2_import::log( - t("Failed to import Gallery 2 user with id: %id", array("id" => $g2_user_id))); - return; + return t("Failed to import Gallery 2 user with id: %id\n%exception", + array("id" => $g2_user_id, "exception" => $e->__toString())); } $g2_groups = g2(GalleryCoreApi::fetchGroupsForUser($g2_user->getId())); try { $user = user::create($g2_user->getUsername(), $g2_user->getfullname(), ""); + $message = t("Created user: '%name'.", array("name" => $user->name)); } catch (Exception $e) { // @todo For now we assume this is a "duplicate user" exception $user = user::lookup_by_name($g2_user->getUsername()); + $message = t("Loaded existing user: '%name'.", array("name" => $user->name)); } $user->hashed_password = $g2_user->getHashedPassword(); @@ -294,13 +299,18 @@ class g2_import_Core { foreach ($g2_groups as $g2_group_id => $g2_group_name) { if ($g2_group_id == $g2_admin_group_id) { $user->admin = true; + $message .= t("\n\tAdded 'admin' flag to user"); } else { - $user->add(ORM::factory("group", self::map($g2_group_id))); + $group = ORM::factory("group", self::map($g2_group_id)); + $user->add($group); + $message .= t("\n\tAdded user to group '%group'.", array("group" => $group->name)); } } $user->save(); self::set_map($g2_user->getId(), $user->id); + + return $message; } @@ -321,20 +331,19 @@ class g2_import_Core { } if (self::map($g2_album_id)) { - return; + return t("Album with id: %id already imported, skipping", array("id" => $g2_album_id)); } try { // Load the G2 album item, and figure out its parent in G3. $g2_album = g2(GalleryCoreApi::loadEntitiesById($g2_album_id)); } catch (Exception $e) { - g2_import::log( - t("Failed to import Gallery 2 album with id: %id", array("id" => $g2_album_id))); - return; + return t("Failed to import Gallery 2 album with id: %id\n%exception", + array("id" => $g2_album_id, "exception" => $e->__toString())); } if ($g2_album->getParentId() == null) { - return; + return t("Skipping Gallery2 root album"); } $parent_album = ORM::factory("item", self::map($g2_album->getParentId())); @@ -367,10 +376,12 @@ class g2_import_Core { } $album->save(); - self::import_keywords_as_tags($g2_album->getKeywords(), $album); + $message = t("Album '%name' imported.", array("name" => $album->name)); + $message .= self::import_keywords_as_tags($g2_album->getKeywords(), $album); self::set_map($g2_album_id, $album->id); // @todo import album highlights + return $message; } /** @@ -386,10 +397,11 @@ class g2_import_Core { $g3_album_id = self::map($g2_album_id); if (!$g3_album_id) { - return; + return t("Album with id: %id not imported", array("id" => $g3_album_id)); } $table = g2(GalleryCoreApi::fetchThumbnailsByItemIds(array($g2_album_id))); + $message = ""; if (isset($table[$g2_album_id])) { // Backtrack the source id to an item $g2_source = $table[$g2_album_id]; @@ -405,8 +417,10 @@ class g2_import_Core { $g2_album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id)); $g2_album->save(); graphics::generate($g2_album); + $message = t("Highlight created for album '%name'", array("name" => $g2_album->name)); } } + return $message; } /** @@ -416,16 +430,15 @@ class g2_import_Core { $g2_item_id = array_shift($queue); if (self::map($g2_item_id)) { - return; + return t("Item with id: %id already imported, skipping", array("id" => $g2_item_id)); } try { self::$current_g2_item = $g2_item = g2(GalleryCoreApi::loadEntitiesById($g2_item_id)); $g2_path = g2($g2_item->fetchPath()); } catch (Exception $e) { - g2_import::log( - t("Failed to import Gallery 2 item with id: %id", array("id" => $g2_item_id))); - return; + return t("Failed to import Gallery 2 item with id: %id\n%exception", + array("id" => $g2_item_id, "exception" => $e->__toString())); } $parent = ORM::factory("item", self::map($g2_item->getParentId())); @@ -447,10 +460,13 @@ class g2_import_Core { $corrupt = 1; } + $message = ""; switch ($g2_type) { case "GalleryPhotoItem": if (!in_array($g2_item->getMimeType(), array("image/jpeg", "image/gif", "image/png"))) { Kohana::log("alert", "$g2_path is an unsupported image type; using a placeholder gif"); + $message = t("'%path' is an unsupported image type, using a placeholder", + array("path" => $g2_path)); $g2_path = MODPATH . "g2_import/data/broken-image.gif"; $corrupt = 1; } @@ -464,9 +480,13 @@ class g2_import_Core { self::_decode_html_special_chars($g2_item->getTitle()), self::_decode_html_special_chars(self::extract_description($g2_item)), self::map($g2_item->getOwnerId())); + $message .= (strlen($message) ? "\n" : "") . + t("Imported photo: '%title'", array("title" => p::purify($item->title))); } catch (Exception $e) { Kohana::log( - "alert", "Corrupt image $g2_path\n" . $e->getMessage() . "\n" . $e->getTraceAsString()); + "alert", "Corrupt image $g2_path\n" . $e->__toString()); + $message .= (strlen($message) ? "\n" : "") . t("Corrupt image '%path'\n$exception", + array("path" => $g2_path,"exception" => $e->__toString())); $corrupt = 1; } break; @@ -482,12 +502,20 @@ class g2_import_Core { self::_decode_html_special_chars($g2_item->getTitle()), self::_decode_html_special_chars(self::extract_description($g2_item)), self::map($g2_item->getOwnerId())); + $message .= (strlen($message) ? "\n" : "") . + t("Imported movie: '%title'", array("title" => p::purify($item->title))); } catch (Exception $e) { - Kohana::log("alert", "Corrupt movie $g2_path\n" . - $e->getMessage() . "\n" . $e->getTraceAsString()); + Kohana::log("alert", "Corrupt movie $g2_path\n" . $e->__toString()); + $message .= (strlen($message) ? "\n" : "") . t("Corrupt movie '%path'\n$exception", + array("path" => $g2_path,"exception" => $e->__toString())); $corrupt = 1; } + } else { + Kohana::log("alert", "$g2_path is an unsupported movie type"); + $message .= t("'%path' is an unsupported movie type", array("path" => $g2_path)); + $corrupt = 1; } + break; default: @@ -496,13 +524,16 @@ class g2_import_Core { } if (!empty($item)) { - self::import_keywords_as_tags($g2_item->getKeywords(), $item); + $message .= (strlen($message) ? "\n" : "") . + self::import_keywords_as_tags($g2_item->getKeywords(), $item); } if (isset($item)) { self::set_map($g2_item_id, $item->id); $item->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_item_id)); $item->save(); + $message .= (strlen($message) ? "\n" : "") . + t("View count updated: %count", array("count" => $item->view_count)); } if ($corrupt) { @@ -524,7 +555,7 @@ class g2_import_Core { t("%title from Gallery 2 could not be processed", array("g2_url" => $g2_item_url, "title" => $g2_item->getTitle())); } - g2_import::log($warning); + $message .= (strlen($message) ? "\n" : "") . $warning; } self::$current_g2_item = null; @@ -548,9 +579,8 @@ class g2_import_Core { try { $g2_comment = g2(GalleryCoreApi::loadEntitiesById($g2_comment_id)); } catch (Exception $e) { - g2_import::log("Failed to import Gallery 2 comment with id: %id", - array("id" => $g2_comment_id)); - return; + return t("Failed to import Gallery 2 comment with id: %id\%exception", + array("id" => $g2_comment_id, "exception" => $e->__toString())); } $text = $g2_comment->getSubject(); @@ -572,12 +602,19 @@ class g2_import_Core { $comment->save(); self::map($g2_comment->getId(), $comment->id); + return t("Imported comment '%comment' for item with id: %id", + array("id" => $comment->item_id, + "comment" => text::limit_words(nl2br(p::purify($comment->text)), 50))); } /** * Import all the tags for a single item */ static function import_tags_for_item(&$queue) { + if (!module::is_active("tag")) { + return t("Gallery 3 tag module is inactive, no tags will be imported"); + } + GalleryCoreApi::requireOnce("modules/tags/classes/TagsHelper.class"); $g2_item_id = array_shift($queue); $g3_item = ORM::factory("item", self::map($g2_item_id)); @@ -585,22 +622,24 @@ class g2_import_Core { try { $tag_names = array_values(g2(TagsHelper::getTagsByItemId($g2_item_id))); } catch (Exception $e) { - g2_import::log("Failed to import tags for Gallery 2 item with id: %id", - array("id" => $g2_item_id)); - return; + return t("Failed to import tags for Gallery 2 item with id: %id\n%exception", + array("id" => $g2_item_id, "exception" => $e->__toString())); } + $tags = ""; foreach ($tag_names as $tag_name) { - $tag = tag::add($g3_item, $tag_name); + $tags .= (strlen($tags) ? ", " : "") . tag::add($g3_item, $tag_name); } // Tag operations are idempotent so we don't need to map them. Which is good because we don't // have an id for each individual tag mapping anyway so it'd be hard to set up the mapping. + return t("Added '%tags' to '%title'", array("tags" => $tags, + "title" => p::purify($item->title))); } static function import_keywords_as_tags($keywords, $item) { if (!module::is_active("tag")) { - return; + return t("Gallery 3 tag module is inactive, no keywords will be imported"); } // Keywords in G2 are free form. So we don't know what our user used as a separator. Try to @@ -614,12 +653,15 @@ class g2_import_Core { $delim = " "; } + $tags = ""; foreach (preg_split("/$delim/", $keywords) as $keyword) { $keyword = trim($keyword); if ($keyword) { - tag::add($item, $keyword); + $tags .= (strlen($tags) ? ", " : "") . tag::add($item, $keyword); } } + return strlen($tags) ? t("Added '%keywords' to '%title'", + array("tags" => $tags, "title" => p::purify($item->title))) : ""; } /** diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php index 3961097d..47a205bd 100644 --- a/modules/g2_import/helpers/g2_import_task.php +++ b/modules/g2_import/helpers/g2_import_task.php @@ -94,7 +94,10 @@ class g2_import_task_Core { if (empty($queue)) { $task->set("queue", $queue = array_keys(g2(GalleryCoreApi::fetchGroupNames()))); } - g2_import::import_group($queue); + $log_message = g2_import::import_group($queue); + if ($log_message) { + $task->log($log_message); + } $task->status = t( "Importing groups (%count of %total)", array("count" => $done["groups"] + 1, "total" => $stats["groups"])); @@ -105,7 +108,10 @@ class g2_import_task_Core { $task->set( "queue", $queue = array_keys(g2(GalleryCoreApi::fetchUsersForGroup(GROUP_EVERYBODY)))); } - g2_import::import_user($queue); + $log_message = g2_import::import_user($queue); + if ($log_message) { + $task->log($log_message); + } $task->status = t( "Importing users (%count of %total)", array("count" => $done["users"] + 1, "total" => $stats["users"])); @@ -115,7 +121,10 @@ class g2_import_task_Core { if (empty($queue)) { $task->set("queue", $queue = g2(GalleryCoreApi::fetchAlbumTree())); } - g2_import::import_album($queue); + $log_message = g2_import::import_album($queue); + if ($log_message) { + $task->log($log_message); + } $task->status = t( "Importing albums (%count of %total)", array("count" => $done["albums"] + 1, "total" => $stats["albums"])); @@ -127,7 +136,10 @@ class g2_import_task_Core { $task->set("last_id", end($queue)); } - g2_import::import_item($queue); + $log_message = g2_import::import_item($queue); + if ($log_message) { + $task->log($log_message); + } $task->status = t( "Importing photos (%count of %total)", array("count" => $done["items"] + 1, "total" => $stats["items"])); @@ -138,7 +150,10 @@ class g2_import_task_Core { $task->set("queue", $queue = g2_import::get_comment_ids($task->get("last_id", 0))); $task->set("last_id", end($queue)); } - g2_import::import_comment($queue); + $log_message = g2_import::import_comment($queue); + if ($log_message) { + $task->log($log_message); + } $task->status = t( "Importing comments (%count of %total)", array("count" => $done["comments"] + 1, "total" => $stats["comments"])); @@ -150,7 +165,10 @@ class g2_import_task_Core { $task->set("queue", $queue = g2_import::get_tag_item_ids($task->get("last_id", 0))); $task->set("last_id", end($queue)); } - g2_import::import_tags_for_item($queue); + $log_message = g2_import::import_tags_for_item($queue); + if ($log_message) { + $task->log($log_message); + } $task->status = t( "Importing tags (%count of %total)", array("count" => $done["tags"] + 1, "total" => $stats["tags"])); @@ -161,7 +179,10 @@ class g2_import_task_Core { if (empty($queue)) { $task->set("queue", $queue = g2(GalleryCoreApi::fetchAlbumTree())); } - g2_import::set_album_highlight($queue); + $log_message = g2_import::set_album_highlight($queue); + if ($log_message) { + $task->log($log_message); + } $task->status = t( "Album highlights (%count of %total)", array("count" => $done["tags"] + 1, "total" => $stats["albums"])); -- cgit v1.2.3 From dfc704516ac8fe850874a62e5b982addabe813c6 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 6 Jul 2009 21:10:59 -0700 Subject: correct spacing in a message. thanks shai --- modules/g2_import/helpers/g2_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 7cce4aa2..cc9d0a21 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -244,7 +244,7 @@ class g2_import_Core { break; case GROUP_SITE_ADMINS: - $message = t("Group 'Admin'does not exist in gallery3, skipping"); + $message = t("Group 'Admin' does not exist in gallery3, skipping"); break; // This is not a group in G3 case GROUP_EVERYBODY: -- cgit v1.2.3 From 6588f3bbd16c0ca91809a11a2e9b341d6a7c85a6 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 6 Jul 2009 21:46:50 -0700 Subject: Change wording of failed to import tags to make it consistent with the other failed import messages. Thanks shai --- modules/g2_import/helpers/g2_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index cc9d0a21..e86558b7 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -622,7 +622,7 @@ class g2_import_Core { try { $tag_names = array_values(g2(TagsHelper::getTagsByItemId($g2_item_id))); } catch (Exception $e) { - return t("Failed to import tags for Gallery 2 item with id: %id\n%exception", + return t("Failed to import Gallery 2 tags for item with id: %id\n%exception", array("id" => $g2_item_id, "exception" => $e->__toString())); } -- cgit v1.2.3 From b59e94e7dccc2ce1710ae98bda97ef537fd0c9b7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 7 Jul 2009 07:32:36 -0700 Subject: Change references to Gallery 2 and Gallery 3 to consistently refer to Gallery n as opposed any variants of this. --- .htaccess | 2 +- installer/cli.php | 2 +- installer/views/already_installed.html.php | 2 +- installer/views/install.html.php | 2 +- installer/views/success.html.php | 2 +- modules/comment/views/comment.mrss.php | 2 +- modules/g2_import/helpers/g2_import.php | 18 +++++++++--------- modules/gallery/helpers/gallery_block.php | 2 +- modules/gallery/views/upgrader.html.php | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/.htaccess b/.htaccess index f1996eed..08b9c5bb 100644 --- a/.htaccess +++ b/.htaccess @@ -36,7 +36,7 @@ # block below. You just need to change RewriteBase line to match your # Gallery 3 URL. Here are some examples: # -# Gallery3 URL RewriteBase line +# Gallery 3 URL RewriteBase line # ============= ==================== # http://example.com/gallery3 RewriteBase /gallery3 # http://example.com/~bob/photos RewriteBase /~bob/photos diff --git a/installer/cli.php b/installer/cli.php index e2fdffce..50845ea4 100644 --- a/installer/cli.php +++ b/installer/cli.php @@ -69,7 +69,7 @@ function oops($message) { print "==> " . $message; print "\n"; print "For help you can try:\n"; - print " * The Gallery3 FAQ - http://codex.gallery2.org/Gallery3:FAQ\n"; + print " * The Gallery 3 FAQ - http://codex.gallery2.org/Gallery3:FAQ\n"; print " * The Gallery Forums - http://gallery.menalto.com/forum\n"; print "\n\n** INSTALLATION FAILED **\n"; exit(1); diff --git a/installer/views/already_installed.html.php b/installer/views/already_installed.html.php index 0d7fc193..f6ac1bff 100644 --- a/installer/views/already_installed.html.php +++ b/installer/views/already_installed.html.php @@ -1,5 +1,5 @@

    - Your Gallery3 install is complete. + Your Gallery 3 install is complete.

    diff --git a/installer/views/install.html.php b/installer/views/install.html.php index 18060219..a0eddaf3 100644 --- a/installer/views/install.html.php +++ b/installer/views/install.html.php @@ -1,7 +1,7 @@ - Gallery3 Installer + Gallery 3 Installer diff --git a/installer/views/success.html.php b/installer/views/success.html.php index 4bca2fb1..e9ee9818 100644 --- a/installer/views/success.html.php +++ b/installer/views/success.html.php @@ -1,7 +1,7 @@

    Success!

    - Your Gallery3 install is complete! + Your Gallery 3 install is complete!

    diff --git a/modules/comment/views/comment.mrss.php b/modules/comment/views/comment.mrss.php index e27bc44f..2b5b13c1 100644 --- a/modules/comment/views/comment.mrss.php +++ b/modules/comment/views/comment.mrss.php @@ -5,7 +5,7 @@ xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:fh="http://purl.org/syndication/history/1.0"> - gallery3 + Gallery 3 <?= p::clean($feed->title) ?> uri ?> description) ?> diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index e86558b7..0d72c139 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -54,14 +54,14 @@ class g2_import_Core { } /** - * Initialize the embedded Gallery2 instance. Call this before any other Gallery2 calls. + * Initialize the embedded Gallery 2 instance. Call this before any other Gallery 2 calls. */ static function init_embed($embed_path) { if (!is_file($embed_path)) { return false; } - // Gallery2 defines a class called Gallery. So does Gallery 3. They don't get along. So do + // Gallery 2 defines a class called Gallery. So does Gallery 3. They don't get along. So do // a total hack here and copy over a few critical files (embed.php, main.php, bootstrap.inc // and Gallery.class) and munge them so that we can rename the Gallery class to be // G2_Gallery. Is this retarded? Why yes it is. @@ -244,7 +244,7 @@ class g2_import_Core { break; case GROUP_SITE_ADMINS: - $message = t("Group 'Admin' does not exist in gallery3, skipping"); + $message = t("Group 'Admin' does not exist in Gallery 3, skipping"); break; // This is not a group in G3 case GROUP_EVERYBODY: @@ -343,7 +343,7 @@ class g2_import_Core { } if ($g2_album->getParentId() == null) { - return t("Skipping Gallery2 root album"); + return t("Skipping Gallery 2 root album"); } $parent_album = ORM::factory("item", self::map($g2_album->getParentId())); @@ -446,7 +446,7 @@ class g2_import_Core { $g2_type = $g2_item->getEntityType(); $corrupt = 0; if (!file_exists($g2_path)) { - // If the Gallery2 source image isn't available, this operation is going to fail. That can + // If the Gallery 2 source image isn't available, this operation is going to fail. That can // happen in cases where there's corruption in the source Gallery 2. In that case, fall // back on using a broken image. It's important that we import *something* otherwise // anything that refers to this item in Gallery 2 will have a dangling pointer in Gallery 3 @@ -665,8 +665,8 @@ class g2_import_Core { } /** - * If the thumbnails and resizes created for the Gallery2 photo match the dimensions of the - * ones we expect to create for Gallery3, then copy the files over instead of recreating them. + * If the thumbnails and resizes created for the Gallery 2 photo match the dimensions of the + * ones we expect to create for Gallery 3, then copy the files over instead of recreating them. */ static function copy_matching_thumbnails_and_resizes($item) { // We only operate on items that are being imported @@ -674,7 +674,7 @@ class g2_import_Core { return; } - // Precaution: if the Gallery2 item was watermarked, or we have the Gallery3 watermark module + // Precaution: if the Gallery 2 item was watermarked, or we have the Gallery 3 watermark module // active then we'd have to do something a lot more sophisticated here. For now, just skip // this step in those cases. // @todo we should probably use an API here, eventually. @@ -927,7 +927,7 @@ function g2() { $args = func_get_arg(0); $ret = array_shift($args); if ($ret) { - Kohana::log("error", "Gallery2 call failed with: " . $ret->getAsText()); + Kohana::log("error", "Gallery 2 call failed with: " . $ret->getAsText()); throw new Exception("@todo G2_FUNCTION_FAILED"); } if (count($args) == 1) { diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index a10f2bbf..b7816954 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -33,7 +33,7 @@ class gallery_block_Core { switch($block_id) { case "welcome": $block->css_id = "gWelcome"; - $block->title = t("Welcome to Gallery3"); + $block->title = t("Welcome to Gallery 3"); $block->content = new View("admin_block_welcome.html"); break; diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php index f9e242a8..37578855 100644 --- a/modules/gallery/views/upgrader.html.php +++ b/modules/gallery/views/upgrader.html.php @@ -1,7 +1,7 @@ - <?= t("Gallery3 Upgrader") ?> + <?= t("Gallery 3 Upgrader") ?> " media="screen,print,projection" /> -- cgit v1.2.3 From 4e0848a1a5d024cecae6bacb524bb73ed861fad7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 7 Jul 2009 11:22:13 -0700 Subject: Clean up some indentation. --- modules/g2_import/helpers/g2_import.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 0d72c139..bbd8a6d8 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -339,7 +339,7 @@ class g2_import_Core { $g2_album = g2(GalleryCoreApi::loadEntitiesById($g2_album_id)); } catch (Exception $e) { return t("Failed to import Gallery 2 album with id: %id\n%exception", - array("id" => $g2_album_id, "exception" => $e->__toString())); + array("id" => $g2_album_id, "exception" => $e->__toString())); } if ($g2_album->getParentId() == null) { @@ -438,7 +438,7 @@ class g2_import_Core { $g2_path = g2($g2_item->fetchPath()); } catch (Exception $e) { return t("Failed to import Gallery 2 item with id: %id\n%exception", - array("id" => $g2_item_id, "exception" => $e->__toString())); + array("id" => $g2_item_id, "exception" => $e->__toString())); } $parent = ORM::factory("item", self::map($g2_item->getParentId())); @@ -485,8 +485,9 @@ class g2_import_Core { } catch (Exception $e) { Kohana::log( "alert", "Corrupt image $g2_path\n" . $e->__toString()); - $message .= (strlen($message) ? "\n" : "") . t("Corrupt image '%path'\n$exception", - array("path" => $g2_path,"exception" => $e->__toString())); + $message .= (strlen($message) ? "\n" : "") . + t("Corrupt image '%path'\n$exception", + array("path" => $g2_path,"exception" => $e->__toString())); $corrupt = 1; } break; @@ -502,12 +503,13 @@ class g2_import_Core { self::_decode_html_special_chars($g2_item->getTitle()), self::_decode_html_special_chars(self::extract_description($g2_item)), self::map($g2_item->getOwnerId())); - $message .= (strlen($message) ? "\n" : "") . - t("Imported movie: '%title'", array("title" => p::purify($item->title))); + $message .= (strlen($message) ? "\n" : "") . + t("Imported movie: '%title'", array("title" => p::purify($item->title))); } catch (Exception $e) { Kohana::log("alert", "Corrupt movie $g2_path\n" . $e->__toString()); - $message .= (strlen($message) ? "\n" : "") . t("Corrupt movie '%path'\n$exception", - array("path" => $g2_path,"exception" => $e->__toString())); + $message .= (strlen($message) ? "\n" : "") . + t("Corrupt movie '%path'\n$exception", + array("path" => $g2_path,"exception" => $e->__toString())); $corrupt = 1; } } else { @@ -580,7 +582,7 @@ class g2_import_Core { $g2_comment = g2(GalleryCoreApi::loadEntitiesById($g2_comment_id)); } catch (Exception $e) { return t("Failed to import Gallery 2 comment with id: %id\%exception", - array("id" => $g2_comment_id, "exception" => $e->__toString())); + array("id" => $g2_comment_id, "exception" => $e->__toString())); } $text = $g2_comment->getSubject(); @@ -623,7 +625,7 @@ class g2_import_Core { $tag_names = array_values(g2(TagsHelper::getTagsByItemId($g2_item_id))); } catch (Exception $e) { return t("Failed to import Gallery 2 tags for item with id: %id\n%exception", - array("id" => $g2_item_id, "exception" => $e->__toString())); + array("id" => $g2_item_id, "exception" => $e->__toString())); } $tags = ""; -- cgit v1.2.3 From b0cd0a52be1d58e451daa52950deb7d5257e1162 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 7 Jul 2009 12:10:50 -0700 Subject: Allow the task::log method to take an array of lines and change g2_import.php helper to use this approach. --- modules/g2_import/helpers/g2_import.php | 36 +++++++++++++++------------------ modules/gallery/models/task.php | 4 ++++ 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 0d72c139..f9a15869 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -376,8 +376,8 @@ class g2_import_Core { } $album->save(); - $message = t("Album '%name' imported.", array("name" => $album->name)); - $message .= self::import_keywords_as_tags($g2_album->getKeywords(), $album); + $message[] = t("Album '%name' imported.", array("name" => $album->name)); + $message[] = self::import_keywords_as_tags($g2_album->getKeywords(), $album); self::set_map($g2_album_id, $album->id); // @todo import album highlights @@ -460,12 +460,12 @@ class g2_import_Core { $corrupt = 1; } - $message = ""; + $message = array(); switch ($g2_type) { case "GalleryPhotoItem": if (!in_array($g2_item->getMimeType(), array("image/jpeg", "image/gif", "image/png"))) { Kohana::log("alert", "$g2_path is an unsupported image type; using a placeholder gif"); - $message = t("'%path' is an unsupported image type, using a placeholder", + $message[] = t("'%path' is an unsupported image type, using a placeholder", array("path" => $g2_path)); $g2_path = MODPATH . "g2_import/data/broken-image.gif"; $corrupt = 1; @@ -480,12 +480,11 @@ class g2_import_Core { self::_decode_html_special_chars($g2_item->getTitle()), self::_decode_html_special_chars(self::extract_description($g2_item)), self::map($g2_item->getOwnerId())); - $message .= (strlen($message) ? "\n" : "") . - t("Imported photo: '%title'", array("title" => p::purify($item->title))); + $message[].= t("Imported photo: '%title'", array("title" => p::purify($item->title))); } catch (Exception $e) { Kohana::log( "alert", "Corrupt image $g2_path\n" . $e->__toString()); - $message .= (strlen($message) ? "\n" : "") . t("Corrupt image '%path'\n$exception", + $message[] = t("Corrupt image '%path'\n$exception", array("path" => $g2_path,"exception" => $e->__toString())); $corrupt = 1; } @@ -502,17 +501,16 @@ class g2_import_Core { self::_decode_html_special_chars($g2_item->getTitle()), self::_decode_html_special_chars(self::extract_description($g2_item)), self::map($g2_item->getOwnerId())); - $message .= (strlen($message) ? "\n" : "") . - t("Imported movie: '%title'", array("title" => p::purify($item->title))); + $message[] = t("Imported movie: '%title'", array("title" => p::purify($item->title))); } catch (Exception $e) { Kohana::log("alert", "Corrupt movie $g2_path\n" . $e->__toString()); - $message .= (strlen($message) ? "\n" : "") . t("Corrupt movie '%path'\n$exception", - array("path" => $g2_path,"exception" => $e->__toString())); + $message[] = t("Corrupt movie '%path'\n$exception", + array("path" => $g2_path,"exception" => $e->__toString())); $corrupt = 1; } } else { Kohana::log("alert", "$g2_path is an unsupported movie type"); - $message .= t("'%path' is an unsupported movie type", array("path" => $g2_path)); + $message[] = t("'%path' is an unsupported movie type", array("path" => $g2_path)); $corrupt = 1; } @@ -524,16 +522,14 @@ class g2_import_Core { } if (!empty($item)) { - $message .= (strlen($message) ? "\n" : "") . - self::import_keywords_as_tags($g2_item->getKeywords(), $item); + $message[] = self::import_keywords_as_tags($g2_item->getKeywords(), $item); } if (isset($item)) { self::set_map($g2_item_id, $item->id); $item->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_item_id)); $item->save(); - $message .= (strlen($message) ? "\n" : "") . - t("View count updated: %count", array("count" => $item->view_count)); + $message[] = t("View count updated: %count", array("count" => $item->view_count)); } if ($corrupt) { @@ -544,21 +540,21 @@ class g2_import_Core { $g2_item_url = str_replace('&g2_GALLERYSID=TMP_SESSION_ID_DI_NOISSES_PMT', '', $g2_item_url); if (!empty($item)) { - $warning = + $message[] = t("%title from Gallery 2 could not be processed; " . "(imported as %title)", array("g2_url" => $g2_item_url, "g3_url" => $item->url(), "title" => $g2_item->getTitle())); } else { - $warning = + $message[] = t("%title from Gallery 2 could not be processed", array("g2_url" => $g2_item_url, "title" => $g2_item->getTitle())); } - $message .= (strlen($message) ? "\n" : "") . $warning; } self::$current_g2_item = null; + return $message; } /** @@ -661,7 +657,7 @@ class g2_import_Core { } } return strlen($tags) ? t("Added '%keywords' to '%title'", - array("tags" => $tags, "title" => p::purify($item->title))) : ""; + array("keywords" => $tags, "title" => p::purify($item->title))) : ""; } /** diff --git a/modules/gallery/models/task.php b/modules/gallery/models/task.php index 012b88cf..55bb8e21 100644 --- a/modules/gallery/models/task.php +++ b/modules/gallery/models/task.php @@ -53,6 +53,10 @@ class Task_Model extends ORM { $key = $this->_cache_key(); $log = Cache::instance()->get($key); + if (is_array($msg)) { + $msg = implode("\n", $msg); + } + // Save for 30 days. $log .= !empty($log) ? "\n" : ""; Cache::instance()->set($key, "$log{$msg}", -- cgit v1.2.3 From 512f22a600362415f58197842248acc2f2f68be8 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 9 Jul 2009 17:18:58 -0700 Subject: Change the tag importer to convert spaces to a dot in multi word tags. --- modules/g2_import/helpers/g2_import.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index d67d4c04..66787467 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -623,8 +623,10 @@ class g2_import_Core { } $tags = ""; + // Multiword tags have the space changed to dots.s foreach ($tag_names as $tag_name) { - $tags .= (strlen($tags) ? ", " : "") . tag::add($g3_item, $tag_name); + $tags .= (strlen($tags) ? ", " : "") . + tag::add($g3_item, preg_replace('/\s\s+/', '.', $tag_name)); } // Tag operations are idempotent so we don't need to map them. Which is good because we don't -- cgit v1.2.3 From 67d78e8d58fa5060e42fcef73d3c6de19209c216 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 9 Jul 2009 21:41:59 -0700 Subject: Correct the pattern match to compress multiple spaces into a single dot. --- modules/g2_import/helpers/g2_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 66787467..7dd799c8 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -626,7 +626,7 @@ class g2_import_Core { // Multiword tags have the space changed to dots.s foreach ($tag_names as $tag_name) { $tags .= (strlen($tags) ? ", " : "") . - tag::add($g3_item, preg_replace('/\s\s+/', '.', $tag_name)); + tag::add($g3_item, preg_replace('/\s+/', '.', $tag_name)); } // Tag operations are idempotent so we don't need to map them. Which is good because we don't -- cgit v1.2.3 From 7de339a676f32ed445f3e4215c994a5fe16c1188 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 16:10:37 -0700 Subject: Remove extra debug statements. --- modules/g2_import/helpers/g2_import.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 7dd799c8..8b4169dd 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -471,8 +471,6 @@ class g2_import_Core { $corrupt = 1; } try { - Kohana::log("error", "description: " . self::extract_description($g2_item)); - Kohana::log("error", "title: " . $g2_item->getTitle()); $item = photo::create( $parent, $g2_path, -- cgit v1.2.3