10-15-2010 10:04 AM
10-15-2010 10:46 AM
10-15-2010 11:09 AM
10-15-2010 11:23 AM
10-15-2010 12:04 PM
function sortByWeightedFolderNameAsc (doc1, doc2) {
var i=0, j=0;
var doc1Type = doc1.type.toString().substr(-6,6);
var doc2Type = doc2.type.toString().substr(-6,6);
var doc1Prop = doc1.properties["name"];
var doc2Prop = doc2.properties["name"];
var doc1Properties = getProperties(doc1);
var doc1Weight = doc1Properties["weight"];
var doc2Properties = getProperties(doc2);
var doc2Weight = doc2Properties["weight"];
if ( doc1Type == "folder" && doc2Type != "folder" ) {
return -1;
} else if ( doc1Type != "folder" && doc2Type == "folder" ) {
return 1;
} else {
if ( doc1Weight < doc2Weight ) {
return -1;
} else if ( doc1Weight > doc2Weight ) {
return 1;
} else {
if ( doc1Prop < doc2Prop ) {
return -1;
} else if ( doc1Prop > doc2Prop ) {
return 1;
} else {
return 0;
}
}
}
}
function sortByWeightedFolderNameDesc (doc1, doc2) {
var doc1Type = "";
var doc2Type = "";
if ( doc1.type.toString().length > 6 )
doc1Type = doc1.type.toString().substr(-6,6);
if ( doc2.type.toString().length > 6 )
doc2Type = doc2.type.toString().substr(-6,6);
var doc1Prop = doc1.properties["name"];
var doc2Prop = doc2.properties["name"];
if ( doc1Type != 'folder' && doc2Type == 'folder' ) {
return -1;
} else if ( doc1Type == 'folder' && doc2Type != 'folder' ) {
return 1;
} else {
if ( doc1Weight > doc2Weight ) {
return -1;
} else if ( doc1Weight < doc2Weight ) {
return 1;
} else {
if ( doc1Prop > doc2Prop ) {
return -1;
} else if ( doc1Prop < doc2Prop ) {
return 1;
} else {
return 0;
}
}
}
}
function sortByFolderNameAsc (doc1, doc2) {
var doc1Type = "";
var doc2Type = "";
doc1Type = doc1.type.toString().substr(-6,6);
doc2Type = doc2.type.toString().substr(-6,6);
var doc1Prop = doc1.properties["name"];
var doc2Prop = doc2.properties["name"];
if ( doc1Type == "folder" && doc2Type != "folder" ) {
return -1;
} else if ( doc1Type != "folder" && doc2Type == "folder" ) {
return 1;
} else {
if ( doc1Prop < doc2Prop ) {
return -1;
} else if ( doc1Prop > doc2Prop ) {
return 1;
} else {
return 0;
}
}
}
function sortByFolderNameDesc (doc1, doc2) {
var doc1Type = "";
var doc2Type = "";
doc1Type = doc1.type.toString().substr(-6,6);
doc2Type = doc2.type.toString().substr(-6,6);
var doc1Prop = doc1.properties["name"];
var doc2Prop = doc2.properties["name"];
if ( doc1Type != 'folder' && doc2Type == 'folder' ) {
return -1;
} else if ( doc1Type == 'folder' && doc2Type != 'folder' ) {
return 1;
} else {
if ( doc1Prop > doc2Prop ) {
return -1;
} else if ( doc1Prop < doc2Prop ) {
return 1;
} else {
return 0;
}
}
}
function sortByNameAsc (doc1, doc2) {
var doc1Prop = doc1.properties["name"];
var doc2Prop = doc2.properties["name"];
if ( doc1Prop < doc2Prop ) {
return -1;
} else if ( doc1Prop > doc2Prop ) {
return 1;
} else {
return 0;
}
}
function sortByNameDesc (doc1, doc2) {
var doc1Prop = doc1.properties["name"];
var doc2Prop = doc2.properties["name"];
if ( doc1Prop > doc2Prop ) {
return -1;
} else if ( doc1Prop < doc2Prop ) {
return 1;
} else {
return 0;
}
}
function getProperties (doc) {
var mapProperties = new Array();
var mapProperty = new Array(); // temp var for mapProperties
for (var k = 0; k < doc.tags.length; k++) {
mapProperty = doc.tags[k].split("=");
mapProperties[mapProperty[0].toLowerCase()] = mapProperty[1];
}
return mapProperties;
}
var iconNames = [
'ksmiletris', 'smily_bad', 'gohome', 'help', 'pencil', 'bell', 'penguin', 'idea', 'licq', 'password', 'korn', 'desktop_new', 'xmag', 'clanbomber', 'flag', 'knotify',
'inner_link', 'mm_link2', 'back', 'Mail', 'Note', 'Atrs', 'kaddressbook', 'forward', 'attach', 'mm_link', 'stop', 'messagebox_warning', 'bookmark', 'wizard', 'button_ok', 'button_cancel',
'full_1', 'full_2', 'full_3', 'full_4', 'full_5', 'full_6', 'full_7'
];
var iconTagNames = [
"iamhappy", "iamnotamused", "home", "question", "toberefined", "bell", "linux", "idea", "nice", "key", "mailbox", "donotforget", "tobediscussed", "dangerous", "redflag", "music",
"innerlink", "mmlink2", "back", "mail", "note", "list", "phone", "forward", "attach", "mmlink", "stop", "important", "excellent", 'magic', "ok", "notok",
"priority1", "priority2", "priority3", "priority4", "priority5", "priority6", "priority7"
];
var iconTitle = new Array();
for (var i=0; i < iconTagNames.length; i++) {
iconTitle[ iconTagNames[i] ] = iconNames[ i ];
}
var siteRoles = [ 'sitemanager', 'sitecollaborator', 'sitecontributor', 'siteconsumer' ];
function processNode (folderPath, parentProperties, roleNumber) {
var folder = companyhome.childByNamePath(folderPath);
var docs = folder.children.sort(sortByWeightedFolderNameAsc);
var name = "";
var childName = "";
var contentType = "";
var typeLength = "";
var nodeRefNum = "";
var arrayNodeRefNum;
var sp = " ";
var sp2 = sp + sp;
var sp3 = sp + sp2;
var sp4 = sp2 + sp2;
var line = "\r\n";
var line2 = line + line;
var sharp_linear_4 = "<edge STYLE='sharp_linear' WIDTH='4' />";
var font1 = "<font BOLD='true' NAME='Clarendon' SIZE='18'/>";
var i=0, j=0, k=0;
var result = "";
var numChildren = 0;
var numFile = 0;
var indFile = 0;
var childFolder = "";
var prePath = "/share/proxy/alfresco/api/node/content/";
var mapProperties = new Array();
for (i = 0; i < docs.length; i++) {
name = docs[i].properties["name"];
contentType = docs[i].type;
mapProperties = getProperties (docs[i]);
for ( var propName1 in parentProperties ) {
if ( mapProperties[propName1] == null || mapProperties[propName1].length == 0 ) {
mapProperties[propName1] = parentProperties[propName1];
}
}
var accessNumber = ( mapProperties["access"] ) ? siteRoles.indexOf(String(mapProperties["access"]).toLowerCase()) : 100;
var edgeline = "<edge COLOR='";
edgeline += ( mapProperties["edge_color"] ) ? mapProperties["edge_color"] : "#808080";
edgeline += "' STYLE='";
edgeline += ( mapProperties["edge_style"] ) ? mapProperties["edge_style"] : "sharp_linear";
edgeline += "' WIDTH='";
edgeline += ( mapProperties["edge_width"] ) ? mapProperties["edge_width"] : "2";
edgeline += "' />";
sharp_linear_4 = edgeline;
var fontProp = "<font BOLD='";
fontProp += ( mapProperties["font_bold"] ) ? mapProperties["font_bold"] : "false";
fontProp += "' ITALIC='";
fontProp += ( mapProperties["font_italic"] ) ? mapProperties["font_italic"] : "false";
fontProp += "' NAME='";
fontProp += ( mapProperties["font_name"] ) ? mapProperties["font_name"] : "Clarendon";
fontProp += "' SIZE='";
fontProp += ( mapProperties["font_size"] ) ? mapProperties["font_size"] : "18";
fontProp += "' COLOR='";
fontProp += ( mapProperties["font_color"] ) ? mapProperties["font_color"] : "#000000";
fontProp += "' />";
font1 = fontProp;
var iconProp = ( mapProperties["icon"] ) ? iconTitle[ mapProperties["icon"] ] : "";
if ( (mapProperties["exclude"] == null || mapProperties["exclude"] != 'true') &&
(name.length != 36 || name.split("-").length != 5) &&
(accessNumber > roleNumber || accessNumber == roleNumber) ) {
if ( contentType.toString().substr(-6,6)=="folder" ) {
if ( name != "MM" ) {
childFolder = companyhome.childByNamePath( folderPath + "/" + name );
numChildren = childFolder.children.length;
if ( numChildren > 1 ) {
numFile = 0;
for (j = 0; j < numChildren; j++) {
if ( childFolder.children[j].type.toString().substr(-6,6) != "folder" ) {
indFile = j;
numFile++;
}
}
if ( numFile == 1 && childFolder.children[0].properties["name"] != "Thumbs.db" ) {
childName = childFolder.children[0].properties["name"];
nodeRefNum = childFolder.children[indFile].nodeRef;
if ( childName.toString().substr(-3,3)==".mm" ) {
arrayNodeRefNum = nodeRefNum.toString().split("/");
if ( arrayNodeRefNum.length > 1 ) {
nodeRefNum = arrayNodeRefNum[arrayNodeRefNum.length-1];
}
nodeRefNum = "../" + nodeRefNum + "/" + childName;
} else {
nodeRefNum = nodeRefNum.toString().replace(":/", "");
nodeRefNum = prePath + nodeRefNum + "/" + childName;
}
result += sp2 + sharp_linear_4 + line + sp2 + "<node BACKGROUND_COLOR='";
result += ( mapProperties["background_color"] ) ? mapProperties["background_color"] : "#33ff66";
result += "' COLOR='";
result += ( mapProperties["color"] ) ? mapProperties["color"] : "#000000";
result += "' LINK=_dq_" + nodeRefNum + "_dq_ TEXT=_dq_" + name;
result += "_dq_ STYLE='";
result += ( mapProperties["style"] ) ? mapProperties["style"] : "bubble";
result += "' FOLDED='";
result += ( mapProperties["folded"] ) ? mapProperties["folded"] : "true";
result += "' POSITION='";
result += ( mapProperties["position"] ) ? mapProperties["position"] : "right";
result += "' HGAP='";
result += ( mapProperties["hgap"] ) ? mapProperties["hgap"] : "50";
result += "' VGAP='";
result += ( mapProperties["vgap"] ) ? mapProperties["vgap"] : "116";
result += "' VSHIFT='";
result += ( mapProperties["vshift"] ) ? mapProperties["vshift"] : "0";
result += "' >" + line;
if ( iconProp != "" ) {
result += sp2 + "<icon BUILTIN='" + iconProp + "'/>" + line;
}
result += sp2 + font1 + line;
result += processNode( folderPath + "/" + name, mapProperties, roleNumber );
if ( docs[i].properties.description ) {
result += sp2 + "<richcontent TYPE='NOTE'><html><head/><body><p align='left'>" + docs[i].properties.description + "</p></body></html></richcontent>" + line;
}
result += sp2 + "</node>" + line;
} else {
result += sp2 + sharp_linear_4 + line + sp2 + "<node BACKGROUND_COLOR='";
result += ( mapProperties["background_color"] ) ? mapProperties["background_color"] : "#33ff66";
result += "' COLOR='";
result += ( mapProperties["color"] ) ? mapProperties["color"] : "#000000";
result += "' TEXT=_dq_" + name;
result += "_dq_ STYLE='";
result += ( mapProperties["style"] ) ? mapProperties["style"] : "bubble";
result += "' FOLDED='";
result += ( mapProperties["folded"] ) ? mapProperties["folded"] : "true";
result += "' POSITION='";
result += ( mapProperties["position"] ) ? mapProperties["position"] : "right";
result += "' HGAP='";
result += ( mapProperties["hgap"] ) ? mapProperties["hgap"] : "50";
result += "' VGAP='";
result += ( mapProperties["vgap"] ) ? mapProperties["vgap"] : "116";
result += "' VSHIFT='";
result += ( mapProperties["vshift"] ) ? mapProperties["vshift"] : "0";
result += "' >" + line;
if ( iconProp != "" ) {
result += sp2 + "<icon BUILTIN='" + iconProp + "'/>" + line;
}
result += sp2 + font1 + line;
result += processNode( folderPath + "/" + name, mapProperties, roleNumber );
if ( docs[i].properties.description ) {
result += sp2 + "<richcontent TYPE='NOTE'><html><head/><body><p align='left'>" + docs[i].properties.description + "</p></body></html></richcontent>" + line;
}
result += sp2 + "</node>" + line;
}
} else if ( numChildren > 0 && childFolder.children[0].type.toString().substr(-6,6) != "folder" ) {
childName = childFolder.children[0].properties["name"];
nodeRefNum = childFolder.children[0].nodeRef;
if ( childName.toString().substr(-3,3)==".mm" ) {
arrayNodeRefNum = nodeRefNum.toString().split("/");
if ( arrayNodeRefNum.length > 1 ) {
nodeRefNum = arrayNodeRefNum[arrayNodeRefNum.length-1];
}
nodeRefNum = "../" + nodeRefNum + "/" + childName;
} else {
nodeRefNum = nodeRefNum.toString().replace(":/", "");
nodeRefNum = prePath + nodeRefNum + "/" + childName;
}
result += sp2 + sharp_linear_4 + line + sp2 + "<node BACKGROUND_COLOR='";
result += ( mapProperties["background_color"] ) ? mapProperties["background_color"] : "#33ff66";
result += "' COLOR='";
result += ( mapProperties["color"] ) ? mapProperties["color"] : "#000000";
result += "' LINK=_dq_" + nodeRefNum + "_dq_ TEXT=_dq_" + name;
result += "_dq_ STYLE='";
result += ( mapProperties["style"] ) ? mapProperties["style"] : "bubble";
result += "' FOLDED='";
result += ( mapProperties["folded"] ) ? mapProperties["folded"] : "true";
result += "' POSITION='";
result += ( mapProperties["position"] ) ? mapProperties["position"] : "right";
result += "' HGAP='";
result += ( mapProperties["hgap"] ) ? mapProperties["hgap"] : "50";
result += "' VGAP='";
result += ( mapProperties["vgap"] ) ? mapProperties["vgap"] : "116";
result += "' VSHIFT='";
result += ( mapProperties["vshift"] ) ? mapProperties["vshift"] : "0";
result += "' >" + line;
if ( iconProp != "" ) {
result += sp2 + "<icon BUILTIN='" + iconProp + "'/>" + line;
}
result += sp2 + font1 + line;
result += processNode( folderPath + "/" + name, mapProperties, roleNumber );
if ( docs[i].properties.description ) {
result += sp2 + "<richcontent TYPE='NOTE'><html><head/><body><p align='left'>" + docs[i].properties.description + "</p></body></html></richcontent>" + line;
}
result += sp2 + "</node>" + line;
} else {
result += sp2 + sharp_linear_4 + line + sp2 + "<node BACKGROUND_COLOR='";
result += ( mapProperties["background_color"] ) ? mapProperties["background_color"] : "#33ff66";
result += "' COLOR='";
result += ( mapProperties["color"] ) ? mapProperties["color"] : "#000000";
result += "' TEXT=_dq_" + name;
result += "_dq_ STYLE='";
result += ( mapProperties["style"] ) ? mapProperties["style"] : "bubble";
result += "' FOLDED='";
result += ( mapProperties["folded"] ) ? mapProperties["folded"] : "true";
result += "' POSITION='";
result += ( mapProperties["position"] ) ? mapProperties["position"] : "right";
result += "' HGAP='";
result += ( mapProperties["hgap"] ) ? mapProperties["hgap"] : "50";
result += "' VGAP='";
result += ( mapProperties["vgap"] ) ? mapProperties["vgap"] : "116";
result += "' VSHIFT='";
result += ( mapProperties["vshift"] ) ? mapProperties["vshift"] : "0";
result += "' >" + line;
if ( iconProp != "" ) {
result += sp2 + "<icon BUILTIN='" + iconProp + "'/>" + line;
}
result += sp2 + font1 + line;
result += processNode( folderPath + "/" + name, mapProperties, roleNumber );
if ( docs[i].properties.description ) {
result += sp2 + "<richcontent TYPE='NOTE'><html><head/><body><p align='left'>" + docs[i].properties.description + "</p></body></html></richcontent>" + line;
}
result += sp2 + "</node>" + line;
}
}
} else if ( name != "Thumbs.db" ) {
nodeRefNum = docs[i].nodeRef;
if ( name.toString().substr(-3,3)==".mm" ) {
arrayNodeRefNum = nodeRefNum.toString().split("/");
if ( arrayNodeRefNum.length > 3 ) {
nodeRefNum = arrayNodeRefNum[3];
}
nodeRefNum = "../" + nodeRefNum + "/" + name;
} else {
nodeRefNum = nodeRefNum.toString().replace(":/", "");
nodeRefNum = "/share/proxy/alfresco/api/node/content/" + nodeRefNum + "/" + name;
}
result += sp2 + sharp_linear_4 + line + sp2 + "<node BACKGROUND_COLOR='";
result += ( mapProperties["background_color"] ) ? mapProperties["background_color"] : "#33ff66";
result += "' COLOR='";
result += ( mapProperties["color"] ) ? mapProperties["color"] : "#000000";
result += "' LINK=_dq_" + nodeRefNum + "_dq_ TEXT=_dq_";
result += ( mapProperties["text"] ) ? mapProperties["text"] : name;
result += "_dq_ STYLE='";
result += ( mapProperties["style"] ) ? mapProperties["style"] : "bubble";
result += "' POSITION='";
result += ( mapProperties["position"] ) ? mapProperties["position"] : "right";
result += "' HGAP='";
result += ( mapProperties["hgap"] ) ? mapProperties["hgap"] : "50";
result += "' VGAP='";
result += ( mapProperties["vgap"] ) ? mapProperties["vgap"] : "15";
result += "' VSHIFT='";
result += ( mapProperties["vshift"] ) ? mapProperties["vshift"] : "0";
result += "' >" + line;
if ( iconProp != null && iconProp != "" ) {
result += sp2 + "<icon BUILTIN='" + iconProp + "'/>" + line;
}
if ( docs[i].properties.description ) {
result += sp2 + "<richcontent TYPE='NOTE'><html><head/><body><p align='left'>" + docs[i].properties.description + "</p></body></html></richcontent>" + line;
}
result += sp4 + sharp_linear_4 + line + sp2 + font1 + line + sp3 + "</node>" + line;
} // eof else
} // eof if exclude == 'true'
} // eof for i
return result;
}
function main()
{
// Get the shortname
var shortName = url.extension;
// Get the site
var site = siteService.getSite(shortName);
if (site != null)
{
// Pass the site to the template
model.site = site;
}
else
{
// Return 404
status.setCode(404, "Site " + shortName + " does not exist");
return;
}
var role = site.getMembersRole(person.properties.userName).toLowerCase();
var roleNumber = siteRoles.indexOf(String(role));
if ( roleNumber > 0 )
return;
var folderPath = "Sites/" + shortName + "/documentLibrary";
var MM = companyhome.childByNamePath(folderPath + "/MM");
var mmProperties = new Array();
mmProperties = getProperties( MM );
var mmFontSize = ( mmProperties["font_size"] ) ? mmProperties["font_size"] : "24";
var mmBackgroundColor = ( mmProperties["background_color"] ) ? mmProperties["background_color"] : "#FFFFFF";
for (var ind = 0; ind < 4; ind++) {
if (ind == 0) {
var sitemap5 = companyhome.childByNamePath("Sites/" + shortName + "/documentLibrary/MM/auto_main.mm");
} else {
var sitemap5 = companyhome.childByNamePath("Sites/" + shortName + "/documentLibrary/MM/auto_main_" + siteRoles[ind] + ".mm");
}
var result="";
var parentProperties = new Array(); // inherited mapProperties
if (sitemap5 == null) {
if (ind == 0) {
var sitemap5 = MM.createFile("auto_main.mm");
} else {
var sitemap5 = MM.createFile("auto_main_" + siteRoles[ind] + ".mm");
}
result = "<map>\r\n <node TEXT=_dq_ " + site.title + " _dq_ BACKGROUND_COLOR='" + mmBackgroundColor + "' STYLE='bubble' VGAP='25'>\r\n";
result += "<edge COLOR='#808080' STYLE='sharp_linear' WIDTH='4'/>";
result += "<font BOLD='true' NAME='Century Schoolbook' SIZE='" + mmFontSize + "'/>";
result += processNode (folderPath, parentProperties, ind);
result += " </node>\r\n</map>";
result = result.replace(/&/g,'&');
sitemap5.content = result.replace(/_dq_/g,'\"');
} else if ( mmProperties["auto"] && mmProperties["auto"] == "true" ) {
result = "<map>\r\n <node TEXT=_dq_ " + site.title + " _dq_ BACKGROUND_COLOR='" + mmBackgroundColor + "' STYLE='bubble' VGAP='25'>\r\n";
result += "<edge COLOR='#808080' STYLE='sharp_linear' WIDTH='4'/>";
result += "<font BOLD='true' NAME='Century Schoolbook' SIZE='" + mmFontSize + "'/>";
result += processNode (folderPath, parentProperties, ind);
result += " </node>\r\n</map>";
result = result.replace(/&/g,'&');
sitemap5.content = result.replace(/_dq_/g,'\"');
}
sitemap5.properties.content.encoding = "UTF-8";
sitemap5.properties.content.mimetype = "text/plain";
sitemap5.properties.title = "freemindmap";
sitemap5.properties.description = "Automatic Map File";
sitemap5.save();
}
return;
}
main();
11-02-2010 08:53 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.