1<?php
2/*
3    +-----------------------------------------------------------------------------+
4    | ILIAS open source                                                           |
5    +-----------------------------------------------------------------------------+
6    | Copyright (c) 1998-2007 ILIAS open source, University of Cologne            |
7    |                                                                             |
8    | This program is free software; you can redistribute it and/or               |
9    | modify it under the terms of the GNU General Public License                 |
10    | as published by the Free Software Foundation; either version 2              |
11    | of the License, or (at your option) any later version.                      |
12    |                                                                             |
13    | This program is distributed in the hope that it will be useful,             |
14    | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
15    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
16    | GNU General Public License for more details.                                |
17    |                                                                             |
18    | You should have received a copy of the GNU General Public License           |
19    | along with this program; if not, write to the Free Software                 |
20    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
21    +-----------------------------------------------------------------------------+
22*/
23/*
24    Script to mimimze all JS sources for the RTE into one file
25    @author Hendrik Holtmann <holtmann@mac.com>
26
27    This software is provided "AS IS," without a warranty of any kind.  ALL
28    EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
29    ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
30    OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.  ADL Co-Lab Hub AND ITS LICENSORS
31    SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
32    USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES.  IN NO
33    EVENT WILL ADL Co-Lab Hub OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE,
34    PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
35    INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE
36    THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
37    SOFTWARE, EVEN IF ADL Co-Lab Hub HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
38    DAMAGES.
39*/
40
41    require_once "JSMin_lib.php";
42
43    //location of the RTE-script-files
44    $location = "../scripts";
45
46    //list all scripts that are needed for the RTE
47    $mandatory_scripts = array( "sequencer/ADLAuxiliaryResource.js",
48                                "sequencer/ADLDuration.js",
49                                "sequencer/ADLLaunch.js",
50                                "sequencer/ADLObjStatus.js",
51                                "sequencer/ADLSeqUtilities.js",
52                                "sequencer/ADLSequencer.js",
53                                "sequencer/ADLTOC.js",
54                                "sequencer/ADLTracking.js",
55                                "sequencer/ADLValidRequests.js",
56                                "sequencer/Basics.js",
57                                "sequencer/SeqActivity.js",
58                                "sequencer/SeqActivityTree.js",
59                                "sequencer/SeqCondition.js",
60                                "sequencer/SeqConditionSet.js",
61                                "sequencer/SeqNavRequest.js",
62                                "sequencer/SeqObjective.js",
63                                "sequencer/SeqObjectiveMap.js",
64                                "sequencer/SeqObjectiveTracking.js",
65                                "sequencer/SeqRollupRule.js",
66                                "sequencer/SeqRollupRuleset.js",
67                                "sequencer/SeqRule.js",
68                                "sequencer/SeqRuleset.js",
69                                "rtemain/main.js",
70                                "rtemain/rte.js");
71
72
73    //minimize all scripts
74    foreach ($mandatory_scripts as $file) {
75        $inp = file_get_contents($location . "/" . $file);
76        $jsMin = new JSMin($inp, false);
77        $jsMin->minify();
78        $outjsmin[] = $jsMin->out;
79        $out[] = $inp;
80    }
81    $timestamp = time();
82    $f_time = date("YndHis", $timestamp);
83    $comment = "// Build: $f_time \n";
84    $outjsmin = implode("", $outjsmin);
85    $out = implode("", $out);
86    $outjsmin = $comment . $outjsmin;
87    $out = $comment . $out;
88    $filenamemin = "../scripts/buildrte/rte-min.js";
89    $filename = "../scripts/buildrte/rte.js";
90    file_put_contents($filenamemin, $outjsmin);
91    file_put_contents($filename, $out);
92