blob: 843597089453ac54ae2206462ebe7e5f1ed03e27 [file] [log] [blame]
atoulmee45629f2009-01-21 08:52:55 +00001<?php
2/*******************************************************************************
3 * Copyright (c) 2009 Intalio, Inc.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Antoine Toulme, Intalio Inc. bug 260493: Provide a CSV export and import script
11*******************************************************************************/
12
13error_reporting(E_ALL);
14ini_set('display_errors', '1');
15// This script exports all the translations for each language as a CSV file.
16
17ob_start();
18ini_set("memory_limit", "256M");
19define("BABEL_BASE_DIR", "../../");
20require(BABEL_BASE_DIR . "html/common_functions.php");
21require(BABEL_BASE_DIR . "classes/system/dbconnection.class.php");
22require(BABEL_BASE_DIR . "classes/system/feature.class.php");
23$dbc = new DBConnection();
24$dbh = $dbc->connect();
25
26$work_dir = "/tmp/babel-working/";
27
28$work_context_dir = $work_dir . $context . "_csv/";
29$tmp_dir = $work_context_dir . "tmp/";
30$output_dir = $work_context_dir . "output/";
31
32exec("rm -rf $tmp_dir");
33exec("mkdir -p $tmp_dir");
34exec("mkdir -p $output_dir");
35
36//iterate over all the release trains
37foreach(ReleaseTrain::all() as $train) {
38 // create a dedicated folder for each of them
39 exec("mkdir -p $work_context_dir/$train->id");
40 // create the output folder for temporary artifacts
41 $output_dir_for_train = "$output_dir/$train->id/";
42 exec("mkdir -p $output_dir_for_train");
43 // iterate over each language
44 foreach(Language::all() as $lang) {
45 // create a new feature object
46 $feature = new Feature($lang, $train, $tmp_dir, $output_dir_for_train);
47 // make it generate itself
48 $feature->generateAsCSV();
49 // now zip it directly
50 $featureZip = $feature->zipAsCSV("$work_context_dir/$train->id");
51 // output the creation of the feature notification
52 echo "Feature created here: $featureZip\n";
53 }
54 break;
55}