1
0

printing a warning in case of nonstandard chars in g1 folder names

This commit is contained in:
Thomas E. Horner 2011-06-30 16:14:49 +02:00
parent 05c322810a
commit 30f3645a35
2 changed files with 20 additions and 6 deletions

View File

@ -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: <pre>%names</pre>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: <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")));
}
@ -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;
}
}
}

View File

@ -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;
}