LayoutMgr.evalImport (param, creator)
import a new Layout that was uploaded as a zip file

Sourcecode in LayoutMgr/objectFunctions.js:
1:   function evalImport(param, creator) {
2:      if (param.uploadError) {
3:         // looks like the file uploaded has exceeded uploadLimit ...
4:         throw new Exception("layoutImportTooBig");
5:      } else if (!param.zipfile || param.zipfile.contentLength == 0) {
6:         // looks like nothing was uploaded ...
7:         throw new Exception("layoutImportNoUpload");
8:      }
9:      try {
10:        var contents = ZipLib.extractAll(param.zipfile.getContent());
11:        // first, check if there's a file called "preferences" in the archive
12:        // and convert it into a HopObject
13:        var data = contents.files["preferences.xml"].data;
14:        var importLayout = Xml.readFromString(new java.lang.String(data, 0, data.length));
15:        // start with the actual import
16:        var newLayout = new Layout(this._parent instanceof Site ? this._parent : null, 
17:                                   importLayout.title, session.user);
18:        newLayout.parent = param.layout ? root.layouts.get(param.layout) : null;
19:        newLayout.preferences.setAll(importLayout.preferences);
20:        newLayout.shareable = 0;
21:        newLayout.imported = 1;
22:        newLayout.alias = buildAlias(importLayout.alias, this);
23:        newLayout.description = importLayout.description;
24:        newLayout.creator = session.user;
25:        // FIXME: this should be done after importing skins
26:        // and images, buf for some reasons skins then
27:        // won't be stored persistent
28:        this.add(newLayout);
29:        // import skins
30:        newLayout.skins.evalImport(contents.files.skins);
31:        // import images
32:        newLayout.images.evalImport(contents.files.imagedata, contents.files.images);
33:        return new Message("layoutImport", newLayout.title);
34:     } catch (err) {
35:        throw new Exception("layoutImportCorrupt");
36:     }
37:     return;
38:  }