コード例 #1
0
<?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];
コード例 #2
0
    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 );
    }
コード例 #3
0
$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'),
);