Ok ich habe das Problem lösen können, nachdem ich mir die Fehler des jeweiligen TCEMain, der von tx_impexp verwendet wird, hab ausgeben lassen. Das Problem war, dass ich zunächst das all Flag im Aufruf von loadFile net gesetzt hatte, und dann immer die falsche ID für die übergeordnete Seite angegeben hatte.
Das ganze Skript sieht derzeit so aus, falls es jemanden interessiert:
PHP-Code:
<?php
/*
* Copyright notice
*
* (c) 2011 Anonymous <anonymous@somwhere.com>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project 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.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
if (!defined('TYPO3_cliMode'))
die('You cannot run this script directly!');
// Include basis cli class
require_once(PATH_t3lib.'class.t3lib_cli.php');
require_once (PATH_site.'typo3/sysext/impexp/class.tx_impexp.php');
/**
* tx_weeshell command line interface
*
* @author Anonymous <anonymous@somewhere.com>
* @package TYPO3
* @subpackage wee_shell
* @todo Formating outputs
*/
class tx_weeshell_cli extends t3lib_cli {
var $prefixId = 'tx_weeshell_cli';
var $scriptRelPath = 'cli/class.tx_weeshell_cli.php';
var $extKey = 'wee_shell';
/**
* Constructor
*
* @return tx_weeshell_cli
*/
function tx_weeshell_cli() {
// Running parent class constructor
parent::t3lib_cli();
// Setting help texts:
$this->cli_help['name'] = 'Wee Shell';
$this->cli_help['synopsis'] = '###OPTIONS###';
$this->cli_help['description'] = "Basic CLI for TYPO3";
$this->cli_help['examples'] = '/.../cli_dispatch.phpsh '.$this->extKey.' <task> <args>';
$this->cli_help['author'] = '(c) 2011 Anonymous <anonymous@somewhere.com>';
}
/**
* Register handler for a hook
*
* @param array $hook
* @param string $handler Method name
* @return tx_weeshell_cli
*/
function registerHandler(&$hook, $handler) {
$hook[] = 'EXT:wee_shell/cli/class.tx_weeshell_cli.php:&tx_weeshell_cli->'.$handler;
}
/**
* Main entry point
*
* @param array Command line arguments
* @return string
*/
function cli_main($argv) {
// validate input
$this->cli_validateArgs();
// get task (function)
$task = (string)$this->cli_args['_DEFAULT'][1];
if (!$task) {
$this->cli_help();
exit;
}
// select called function
switch ($task) {
case 'enable':
$this->enableExtension();
break;
case 'import':
$this->importT3d();
break;
default:
$this->cli_echo('Unknown task "'.$task.'"');
}
}
/**
* Enable extension
*
* @todo Error handling
* @return void
*/
function enableExtension() {
// get extension key
$key = (string)$this->cli_args['_DEFAULT'][2];
t3lib_div::makeInstance('tx_em_Connection_ExtDirectServer')->enableExtension($key);
}
/**
* Import T3D File
*
* @return void
*/
function importT3d() {
global $GLOBALS;
$hooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/impexp/class.tx_impexp.php'];
// get file path
$fileName = (string)$this->cli_args['_DEFAULT'][2];
// get pid
$pid = (int)$this->cli_args['_DEFAULT'][3];
$import = t3lib_div::makeInstance('tx_impexp');
$import->init(0, 'import');
$import->enableLogging = true;
if ($fileName && @is_file($fileName)) {
if ($import->loadFile($fileName,true)) {
$this->cli_echo('Importing "'.$fileName.'"');
$this->registerHandler($hooks['after_writeRecordsPages'], 'showErrors');
$this->registerHandler($hooks['after_writeRecordsPagesOrder'], 'showErrors');
$this->registerHandler($hooks['after_writeRecordsRecords'], 'showErrors');
$this->registerHandler($hooks['after_writeRecordsRecordsOrder'], 'showErrors');
$import->importData($pid);
} else {
$this->cli_echo('Can\'t load file "'.$fileName.'"');
}
} else {
$this->cli_echo('File "'.$fileName.'" not found');
}
}
function showErrors(&$params, &$reference) {
if ($params['tce'] && $params['tce']->errorLog) {
foreach ($params['tce']->errorLog as $error) {
$this->cli_echo($error);
}
}
}
}
// Call the functionality
$cleanerObj = t3lib_div::makeInstance('tx_weeshell_cli');
$cleanerObj->cli_main($_SERVER['argv']);
?>
Lesezeichen