public static function reimportArchive( $context, $archiveFilename ) { $db = MMImportMonitorHelper::db(); $ini = eZINI::instance( 'merck.ini' ); $basePath = $ini->variable( 'ImportMonitor' , 'BasePath' ); $archive = MMImportMonotorArchive::instance( $context ); $zip = $archive->getZipData( $archiveFilename ); $xmlFiles = $archive->getXmlFiles(); $fileList = array(); foreach( $zip['files'] as $file ) { if( preg_match( '/(.*)\/([^\/]+\/[^\/]+)$/', $file['name'], $matches ) ) { $fileList[] = "{$basePath}/{$matches[1]}/archived/{$matches[2]}"; } } foreach ( $xmlFiles as $xmlFile ) { $xmlFiles = glob( "archived/*{$xmlFile['name']}" ); if ( !empty( $xmlFiles ) ) { rsort( $xmlFiles, SORT_STRING ); $fileList[] = array_current( $xmlFiles ); } } self::moveFilesToImport( $fileList ); }
case 'clean': { $pid = (integer)$Params['Param1']; if ( !empty( $pid ) ) { $shellScript = $ini->variable( 'ImportMonitor' , 'ShellScript' ); exec( "{$shellScript} clean {$pid}" ); return $module->redirectTo( "/importmonitor/lock" ); } break; } case 'reimportxml': { $xmlFiles = ImportStatus::getXmlFilenames( $http->postVariable( 'xml', array() ) ); MMImportMonotorArchive::reimportXml( $xmlFiles ); break; } case 'reimportarchive': { $context = $http->postVariable( 'context', false ); $archiveFilename = $http->postVariable( 'archive', false ); MMImportMonotorArchive::reimportArchive( $context, $archiveFilename ); return $module->redirectTo( "/importmonitor/archive/(context)/{$context}/(name)/{$archiveFilename}" ); break; } } return eZExecution::cleanExit();
<?php $module = $Params['Module']; $http = eZHTTPTool::instance(); $tpl = eZTemplate::factory(); $xmlFile = $http->postVariable( 'xmlFilename', false ); $archiveFilename = $http->postVariable( 'archiveFilename', false ); $archiveContext = $http->postVariable( 'archiveContext', false ); if ( !( $xmlFile && $archiveFilename && $archiveContext ) ) { return $module->handleError( eZError::KERNEL_NOT_FOUND ); } $archive = MMImportMonotorArchive::instance( $archiveContext ); if ( !( $archive instanceof MMImportMonotorArchive ) ) { return $module->handleError( eZError::KERNEL_NOT_FOUND ); } $cmd = 'unzip -o "' . $archive->getPath() . '/' . $archiveFilename . '" "' . $xmlFile . '" -d /tmp'; exec( $cmd, $output ); $filename = "/tmp/$xmlFile"; $xml = file_get_contents( $filename ); if ( preg_match( '/\/.*([a-f0-9]{32}_.+\.xml)$/', $xmlFile, $matches ) ) { $xmlFile = $matches[1];
$module = $Params['Module']; $Result = array(); $tpl = eZTemplate::factory(); $tabs = MMImportMonotorArchive::getArchiveSettings(); if ( !empty($tabs) && !isset( $module->UserParameters['tab'] ) ) { $identifiers = array_keys( $tabs ); $module->UserParameters['tab'] = $identifiers[0]; } $tabContents = array( 'files' => array() ); if ( isset( $module->UserParameters['tab'] ) ) { $archive = MMImportMonotorArchive::instance( $module->UserParameters['tab'] ); $tabContents['files'] = $archive->getFiles(); } $tpl->setVariable( 'view_parameters', $module->UserParameters ); $tpl->setVariable( 'tabs', $tabs ); $tpl->setVariable( 'tab_contents', $tabContents ); $Result['content'] = $tpl->fetch( 'design:importmonitor/archives.tpl' ); $Result['path'] = array( array('url' => '/monitor/dashboard', 'text' => 'Dashboard'), array('url' => false, 'text' => 'Archives'), );