/**
  * (non-PHPdoc)
  * @see tao_models_classes_import_ImportHandler::import()
  */
 public function import($class, $form)
 {
     $fileInfo = $form->getValue('source');
     //import for CSV
     if (isset($fileInfo)) {
         set_time_limit(200);
         //the zip extraction is a long process that can exced the 30s timeout
         //get the services instances we will need
         $itemService = taoItems_models_classes_ItemsService::singleton();
         $uploadedFile = $fileInfo['uploaded_file'];
         $uploadedFileBaseName = basename($uploadedFile);
         // uploaded file name contains an extra prefix that we have to remove.
         $uploadedFileBaseName = preg_replace('/^([0-9a-z])+_/', '', $uploadedFileBaseName, 1);
         $uploadedFileBaseName = preg_replace('/.zip|.ZIP$/', '', $uploadedFileBaseName);
         $validate = count($form->getValue('disable_validation')) == 0 ? true : false;
         try {
             $importer = new taoDelivery_models_classes_import_Assembler();
             $report = $importer->importDelivery($class, $uploadedFile);
         } catch (common_Exception $e) {
             $report = common_report_Report::createFailure(__('An error occured during the import'));
             if ($e instanceof common_exception_UserReadableException) {
                 $report->add($e);
             }
         }
         tao_helpers_File::remove($uploadedFile);
     } else {
         throw new common_exception_Error('No file provided as parameter \'source\' for OWI import');
     }
     return $report;
 }
 /**
  * (non-PHPdoc)
  * @see tao_models_classes_export_ExportHandler::export()
  */
 public function export($formValues, $destination)
 {
     if (!isset($formValues['exportInstance']) || empty($formValues['exportInstance'])) {
         throw new common_Exception('No instance selected');
     }
     $delivery = new core_kernel_classes_Resource($formValues['exportInstance']);
     $path = taoDelivery_models_classes_import_Assembler::exportCompiledDelivery($delivery);
     return $path;
 }
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; under version 2
 * of the License (non-upgradable).
 * 
 * This program 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.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
 *               2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
 *               2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
 * 
 */
require_once dirname(__FILE__) . '/../includes/raw_start.php';
$parms = $argv;
$script = array_shift($parms);
if (count($parms) != 2) {
    echo "Usage: " . $script . " DELIVERY_URI OUTPUT_FILE\n";
} else {
    $deliveryUri = array_shift($parms);
    $file = array_shift($parms);
    $delivery = new core_kernel_classes_Resource($deliveryUri);
    $tmpFile = taoDelivery_models_classes_import_Assembler::exportCompiledDelivery($delivery);
    tao_helpers_File::move($tmpFile, $file);
    echo "Done";
}
/*  
 * This program 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; under version 2
 * of the License (non-upgradable).
 * 
 * This program 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.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
 *               2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
 *               2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
 * 
 */
require_once dirname(__FILE__) . '/../includes/raw_start.php';
$parms = $argv;
$script = array_shift($parms);
if (count($parms) != 1) {
    echo "Usage: " . $script . " FILE\n";
} else {
    $file = array_shift($parms);
    $deliveryClass = taoDelivery_models_classes_DeliveryAssemblyService::singleton()->getRootClass();
    $report = taoDelivery_models_classes_import_Assembler::importDelivery($deliveryClass, $file);
    var_dump($report);
}
 * This program 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; under version 2
 * of the License (non-upgradable).
 * 
 * This program 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.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
 *               2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
 *               2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
 * 
 */
require_once dirname(__FILE__) . '/../includes/raw_start.php';
$parms = $argv;
$script = array_shift($parms);
if (count($parms) != 1) {
    echo "Usage: " . $script . " FILE\n";
} else {
    $file = array_shift($parms);
    $deliveryClass = taoDelivery_models_classes_DeliveryAssemblyService::singleton()->getRootClass();
    $importer = new taoDelivery_models_classes_import_Assembler();
    $report = $importer->importDelivery($deliveryClass, $file);
    echo tao_helpers_report_Rendering::renderToCommandline($report);
}