📄 newtempl.ssc
字号:
<!--SCRIPT PSOBJMOD
import( site.GetRootDocument().location + "/ObjMod80.ssc" );
session.active = true;
InitObjects(session);
-->
<!--SCRIPT // {{ SCRIPT()
var webRoot = site.GetRootDocument();
import ( webRoot.location + '/system/utils/strtable.ssc' );
import ( webRoot.location + '/system/utils/wizard.ssc' );
// wizard "next" functions
function docTypeNext() {
if( wiz.doctypepage.value == IntlStr.wizNewTempl.doctypepage.choices[0] ) {
// HTML page
return "formatpage";
} else {
// XML page
// see if there are any saved XML tag sets
if( savedXMLList != null ) {
// ask the user if they want to enter a new tag set or use a saved tag set
return "xmltypepage";
} else {
// skip to entering new XML tags
wiz.xmltypepage.value = IntlStr.wizNewTempl.xmltypepage.choices[0];
return "xmlcustompage";
}
}
}
function xmlTypeNext() {
if( wiz.xmltypepage.value == IntlStr.wizNewTempl.xmltypepage.choices[0] ) {
// custom XML
return "xmlcustompage";
} else {
// predefined XML
return "xmlpredefinedpage";
}
}
// general use functions
function skip_spaces( space_str )
{
start = 0;
// skip leading spaces
while( space_str.charAt(start) == ' ' ) {
start++;
}
// skip trailing spaces
end = space_str.length - 1;
while( space_str.charAt(end) == ' ' ) {
end--;
}
if( start > end ) {
return "";
} else {
return space_str.substring( start, end + 1 );
}
}
// document generation functions
function generateSQLSection() {
if( sqlQuery != null && sqlQuery != '' ) {
text += sqlTag + sqlQuery + '\r\n' + endTag;
// get information about the columns that will result from the query
queryConnection = site.GetConnection( wiz.sqlpage.connectionId );
if( queryConnection.name == IntlStr.inherited ) {
queryConnection = connection;
}
if( queryConnection != null ) {
sqlQueryResult = queryConnection.CreateQuery( sqlQuery );
if( sqlQueryResult != null ) {
columnCount = sqlQueryResult.GetColumnCount();
return true;
}
}
}
return false;
}
function generateHTMLDocument() {
text = '<HTML>\r\n' + templname.tag('TITLE') + '\r\n<BODY>\r\n';
text += '<H1>' + templdesc + '</H1>\r\n';
if( generateSQLSection() ) {
// table format
var templFormat = wiz.formatpage.value;
if( templFormat == IntlStr.wizNewTempl.p4.choices[1]
|| templFormat == IntlStr.wizNewTempl.p4.choices[2] ) {
text += '<TABLE BORDER>\r\n';
if( templFormat == IntlStr.wizNewTempl.p4.choices[2] ) {
text += '<TR>\r\n';
for( i = 1; i <= columnCount; i++ ) {
text += '<TH>' + sqlQueryResult.GetColumnLabel(i) + '</TH>\r\n';
}
text += '</TR>\r\n';
}
text += formatTag + '<TR>\r\n';
for( i = 1; i <= columnCount; i++ ) {
text += '<TD>' + dataTag + '</TD>\r\n';
}
text += '</TR>' + eformatTag + '\r\n';
text += '</TABLE>\r\n';
// detail format
} else if( templFormat == IntlStr.wizNewTempl.p4.choices[3] ) {
text += formatTag + '\r\n';
for( i = 1; i <= columnCount; i++ ) {
text += '<P>\r\n' + sqlQueryResult.GetColumnLabel(i) + ': ' + dataTag;
}
text += eformatTag + '\r\n';
// definition list format
} else if( templFormat == IntlStr.wizNewTempl.p4.choices[4] ) {
text += '<DL>\r\n' + formatTag + '\r\n';
text += '<DT>' + dataTag + '<DD>';
for( i = 2; i <= columnCount; i++ ) {
text += dataTag;
}
text += eformatTag + '</DL>\r\n';
// ordered and unordered list format
} else if( templFormat == IntlStr.wizNewTempl.p4.choices[5]
|| templFormat == IntlStr.wizNewTempl.p4.choices[6] ) {
if( templFormat == IntlStr.wizNewTempl.p4.choices[5] ) {
text += '<UL>\r\n';
} else {
text += '<OL>\r\n';
}
text += formatTag + '<LI>';
for( i = 1; i <= columnCount; i++ ) {
text += dataTag;
}
text += eformatTag;
if( templFormat == IntlStr.wizNewTempl.p4.choices[5] ) {
text += '</UL>\r\n';
} else {
text += '</OL>\r\n';
}
// paragraph format
} else if( templFormat == IntlStr.wizNewTempl.p4.choices[7] ) {
text += formatTag + '<P>';
for( i = 1; i <= columnCount; i++ ) {
text += dataTag;
}
text += eformatTag;
// link format
} else if( templFormat == IntlStr.wizNewTempl.p4.choices[8] ) {
text += '<UL>\r\n' + formatTag + '\r\n<LI><A HREF="' + dataTag + '">';
if( columnCount > 1 ) {
text += dataTag;
}
text += '</A>';
for( i = 3; i <= columnCount; i++ ) {
text += dataTag;
}
text += eformatTag + '</UL>\r\n';
} else {
// default format
text += formatTag + '\r\n' + eformatTag + '\r\n';
}
}
text += '</BODY>\r\n</HTML>';
return true;
}
function generateXMLDocument() {
text = '<?xml version="1.0"?>\r\n';
if( generateSQLSection() ) {
var resultTag;
var rowTag;
var columnTag;
var columnTagList = null;
var columnTagCount = 0;
var useSavedTagSet = false;
if( wiz.xmltypepage.value == IntlStr.wizNewTempl.xmltypepage.choices[1] ) {
useSavedTagSet = true;
}
if( useSavedTagSet ) {
// saved XML tag set
var setDocName = savedXMLFileList[wiz.xmlpredefinedpage.selected];
var setDoc = site.GetDocument( setDocName );
if( setDoc == null ) {
document.writeln( formatString( IntlStr.unableToOpen, setDocName ) );
return false;
}
// parse the file
var start;
var end;
// parse the result set tag
start = setDoc.source.indexOf( '<RESULT>' );
end = setDoc.source.indexOf( '</RESULT>' );
resultTag = setDoc.source.substring( start + 8, end );
start = end + 9;
// parse the row tag
start = setDoc.source.indexOf( '<ROW>', start );
end = setDoc.source.indexOf( '</ROW>', start );
rowTag = setDoc.source.substring( start + 5, end );
start = end + 6;
// parse the column tags
while( start < setDoc.source.length ) {
start = setDoc.source.indexOf( '<COLUMN>', start );
if( start == - 1 ) {
break;
}
end = setDoc.source.indexOf( '</COLUMN>', start );
columnTagList[columnTagCount] = setDoc.source.substring( start + 8, end );
columnTagCount++;
start = end + 9;
}
} else {
// new XML tag set
resultTag = wiz.xmlcustompage.items[0].value;
rowTag = wiz.xmlcustompage.items[1].value;
columnTag = wiz.xmlcustompage.items[2].value;
// if there are multiple column tags, build a list of them
var space;
for(;;) {
columnTag = skip_spaces( columnTag );
space = columnTag.indexOf( ' ' );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -