From 30f3645a3531de22e2406fd05bfba812044a8cc2 Mon Sep 17 00:00:00 2001 From: "Thomas E. Horner" Date: Thu, 30 Jun 2011 16:14:49 +0200 Subject: [PATCH] printing a warning in case of nonstandard chars in g1 folder names --- .../g1_import/controllers/admin_g1_import.php | 7 ++++++- 3.0/modules/g1_import/helpers/g1_import.php | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/3.0/modules/g1_import/controllers/admin_g1_import.php b/3.0/modules/g1_import/controllers/admin_g1_import.php index 40c96c46..9f49de24 100644 --- a/3.0/modules/g1_import/controllers/admin_g1_import.php +++ b/3.0/modules/g1_import/controllers/admin_g1_import.php @@ -48,6 +48,11 @@ class Admin_g1_import_Controller extends Admin_Controller { $view->content->resize_size = module::get_var('gallery', 'resize_size'); if (g1_import::is_initialized()) { + + if (count(g1_import::$warn_utf8)>0) { + message::error(t('Your G1 contains %count folder(s) containing nonstandard characters that G3 doesn\'t work with:
%names
Please rename the above folders in G1 before trying to import your data.', array('count' => count(g1_import::$warn_utf8), 'names' => "\n\n ".implode("\n ", g1_import::$warn_utf8)."\n\n"))); + } + 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:
%lines
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"))); } @@ -123,4 +128,4 @@ class Admin_g1_import_Controller extends Admin_Controller { $group->submit('')->value(g1_import::$album_dir=='' ? t('Change') : t('Continue')); return $form; } -} \ No newline at end of file +} diff --git a/3.0/modules/g1_import/helpers/g1_import.php b/3.0/modules/g1_import/helpers/g1_import.php index 72396a68..6e139f00 100644 --- a/3.0/modules/g1_import/helpers/g1_import.php +++ b/3.0/modules/g1_import/helpers/g1_import.php @@ -30,6 +30,7 @@ class g1_import_Core { public static $thumb_size = null; public static $tree = array(); public static $version = null; + public static $warn_utf8 = array(); public static $queued_items = array(); public static $queued_comments = array(); @@ -146,8 +147,15 @@ class g1_import_Core { return self::$version; } - static function recursiveCountGallery($albumDir, $array, $level) { + static function recursiveCountGallery($albumDir, &$array, $level) { $countAlbum = 0; + + foreach($array as $key => &$value) { + $converted = utf8_encode($key); + if( $converted != $key ) + self::$warn_utf8[] = $converted; + } + foreach($array as $key => $value) { if($key!='') { $countAlbum++; @@ -236,6 +244,7 @@ class g1_import_Core { self::$queued_highlights = array(); self::$albums_flat = array(); self::$albums_hidden = array(); + self::$warn_utf8 = array(); if(count(self::$tree)) $stats['albums'] = 1 /* <= THE ROOT ALBUM!!!*/ + g1_import::recursiveCountGallery($albumDir, self::$tree, 0); $stats['photos'] = count(self::$queued_items); @@ -291,16 +300,16 @@ class g1_import_Core { list($album, $tree) = each($queue); unset($queue[$album]); - foreach($tree as $key => $value) { + foreach($tree as $key => $value) { $queue[$album.'/'.$key] = $value; } // Special handling for the root album if ($album == '') { - if (!self::map('', '', 'album')) { + if (!self::map('', '', 'album')) { $album = item::root(); - self::set_map($album->id, '', '', 'album'); - } + self::set_map($album->id, '', '', 'album'); + } return $messages; }