Dotclear

Changeset 841:e1c6ec0a0736


Ignore:
Timestamp:
07/09/12 16:53:05 (13 years ago)
Author:
JcDenis
Branch:
default
Message:

Flat import errors are now more verbose, fixes #888

Location:
plugins/importExport
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • plugins/importExport/_define.php

    r840 r841  
    1616     /* Description*/         "Import and Export your blog", 
    1717     /* Author */             "Olivier Meunier & Contributors", 
    18      /* Version */            '3.0', 
     18     /* Version */            '3.1', 
    1919     /* Perm */               'admin' 
    2020); 
  • plugins/importExport/inc/flat/class.flat.backup.php

    r840 r841  
    1717     private $line_cols = array(); 
    1818     private $line_name; 
     19     private $line_num; 
    1920      
    2021     private $replacement = array( 
     
    2930          if (file_exists($file) && is_readable($file)) { 
    3031               $this->fp = fopen($file,'rb'); 
     32               $this->line_num = 1; 
    3133          } else { 
    3234               throw new Exception(__('No file to read.')); 
     
    4345     public function getLine() 
    4446     { 
    45           if (feof($this->fp)) { 
     47          if (($line = $this->nextLine()) === false) { 
    4648               return false; 
    4749          } 
    48            
    49           $line = trim(fgets($this->fp)); 
    5050           
    5151          if (substr($line,0,1) == '[') 
     
    6464                
    6565               if (count($this->line_cols) != count($line)) { 
    66                     throw new Exception('Invalid row count'); 
     66                    throw new Exception(sprintf('Invalid row count at line %s',$this->line_num)); 
    6767               } 
    6868                
     
    7474               } 
    7575                
    76                return new flatBackupItem($this->line_name,$res); 
     76               return new flatBackupItem($this->line_name,$res,$this->line_num); 
    7777          } 
    7878          else 
     
    8181          } 
    8282     } 
     83      
     84     private function nextLine() 
     85     { 
     86          if (feof($this->fp)) { 
     87               return false; 
     88          } 
     89          $this->line_num++; 
     90           
     91          $line = fgets($this->fp); 
     92          $line = trim($line); 
     93           
     94          return empty($line) ? $this->nextLine() : $line; 
     95     } 
    8396} 
    8497 
     
    8699{ 
    87100     public $__name; 
     101     public $__line; 
    88102     private $__data = array(); 
    89103      
    90      public function __construct($name,$data) 
     104     public function __construct($name,$data,$line) 
    91105     { 
    92106          $this->__name = $name; 
    93107          $this->__data = $data; 
     108          $this->__line = $line; 
    94109     } 
    95110      
  • plugins/importExport/inc/flat/class.flat.import.php

    r840 r841  
    630630               $this->stack['post_id']++; 
    631631          } else { 
    632                throw new Exception(__('The backup file does not appear to be well formed.')); 
     632               self::throwIdError($post->__name,$post->__line,'category'); 
    633633          } 
    634634     } 
     
    640640               $this->insertMeta($meta); 
    641641          } else { 
    642                throw new Exception(__('The backup file does not appear to be well formed.')); 
     642               self::throwIdError($meta->__name,$meta->__line,'post'); 
    643643          } 
    644644     } 
     
    666666                
    667667               $this->insertPostMedia($post_media); 
    668           } else { 
    669                throw new Exception(__('The backup file does not appear to be well formed.')); 
     668          } elseif (!isset($this->old_ids['media'][(integer) $post_media->media_id])) { 
     669               self::throwIdError($post_media->__name,$post_media->__line,'media'); 
     670          }else { 
     671               self::throwIdError($post_media->__name,$post_media->__line,'post'); 
    670672          } 
    671673     } 
     
    678680               $this->insertPing($ping); 
    679681          } else { 
    680                throw new Exception(__('The backup file does not appear to be well formed.')); 
     682               self::throwIdError($ping->__name,$ping->__line,'post'); 
    681683          } 
    682684     } 
     
    693695               $this->stack['comment_id']++; 
    694696          } else { 
    695                throw new Exception(__('The backup file does not appear to be well formed.')); 
    696           } 
     697               self::throwIdError($comment->__name,$comment->__line,'post'); 
     698          } 
     699     } 
     700      
     701     private static function throwIdError($name,$line,$related) 
     702     { 
     703          throw new Exception(sprintf( 
     704               __('ID of "%3$s" does not match on record "%1$s" at line %2$s of backup file.'), 
     705               html::escapeHTML($name), 
     706               html::escapeHTML($line), 
     707               html::escapeHTML($related) 
     708          )); 
    697709     } 
    698710      
  • plugins/importExport/locales/fr/main.po

    r840 r841  
    11# Language: Français 
    2 # Module: importExport - 3.0 
    3 # Date: 2012-07-09 12:33:59 
     2# Module: importExport - 3.1 
     3# Date: 2012-07-09 14:37:32 
    44# Translated with translater 1.5 
    55 
     
    77msgstr "" 
    88"Content-Type: text/plain; charset=UTF-8\n" 
    9 "Project-Id-Version: importExport 3.0\n" 
     9"Project-Id-Version: importExport 3.1\n" 
    1010"POT-Creation-Date: \n" 
    11 "PO-Revision-Date: 2012-07-09T12:33:59+00:00\n" 
     11"PO-Revision-Date: 2012-07-09T14:37:32+00:00\n" 
    1212"Last-Translator: Jean-Christian Denis\n" 
    1313"Language-Team: \n" 
     
    308308msgstr "Tables WordPress non trouvées" 
    309309 
    310 #: inc/flat/class.flat.backup.php:32 
     310#: inc/flat/class.flat.backup.php:34 
    311311msgid "No file to read." 
    312312msgstr "Aucun fichier lisible." 
     
    324324msgstr "Le fichier n'est pas un fichier d'export complet." 
    325325 
    326 #: inc/flat/class.flat.import.php:632 
    327 #: inc/flat/class.flat.import.php:642 
    328 #: inc/flat/class.flat.import.php:669 
    329 #: inc/flat/class.flat.import.php:680 
    330 #: inc/flat/class.flat.import.php:695 
    331 msgid "The backup file does not appear to be well formed." 
    332 msgstr "Le fichier de sauvegarde ne semble pas être correctement formaté" 
     326#: inc/flat/class.flat.import.php:704 
     327msgid "ID of \"%3$s\" does not match on record \"%1$s\" at line %2$s of backup file." 
     328msgstr "L'ID de \"%3$s\" ne correspond pas dans l'enregistrement de \"%1$s\" à la ligne %2$s du fichier de sauvegarde." 
    333329 
    334330#: index.php:69 
Note: See TracChangeset for help on using the changeset viewer.

Sites map