variables.componentName = "catalogPageService";
var retPageCreate = StructNew();
var stdMetadata = StructNew();
var custMetadata = StructNew();
var createResult = StructNew();
var updateContentStruct = StructNew();
var newPageTemplateID = getTemplateIDFromContent(contentType=arguments.contentType,contentData=arguments.contentData);
var newPageSubsiteID = getSubsiteIDFromContent(contentType=arguments.contentType,contentData=arguments.contentData);
var newPageFileName = buildCatalogPageFileName(contentType=arguments.contentType,contentData=arguments.contentData);
var newPageTitle = buildCatalogPageTitle(contentType=arguments.contentType,contentData=arguments.contentData);
var newPageDescription = buildCatalogPageDescription(contentType=arguments.contentType,contentData=arguments.contentData);
// build the data to create the page
stdMetadata.subsiteID = newPageSubsiteID;
stdMetadata.templateID = newPageTemplateID;
stdMetadata.name = newPageFileName;
stdMetadata.title = newPageTitle;
stdMetadata.globalKeywords = "";
stdMetadata.description = newPageDescription;
stdMetadata.caption = "";
stdMetadata.publicationDate = application.ptCourseCatalog.date.csDateFormat(dateInput=Now(),timeInput=Now());
//stdMetadata.publicationDate = DateFormat(Now(), 'yyyy-mm-dd') & " " & TimeFormat(Now(), 'HH:MM:SS');
stdMetadata.categoryID = 1;
//stdMetadata.includeInIndex = 1;
//stdMetadata.confidentiality = 2;
// Get the custom metadata from the template (fix for CS CCAPI custom metadata inheritance issue)
custMetadata = application.ptCourseCatalog.csData.getCustomMetadata(pageid=newPageTemplateID,convertTaxonomyTermsToIDs=1);
// Set Custom Meta Data to bind to the correct page Type
custMetadata = buildCustomMetadataContentPageBinding(contentType=arguments.contentType,custMetadata=custMetadata,contentID=arguments.contentID);
// create the page
if ( newPageSubsiteID GT 0 )
{
createResult = variables.catalogPageDAO.createCatalogPage(stdMetadata, custMetadata);
}
else
{
retPageCreate["msg"] = 'Destination Subsite was invalid';
}
retPageCreate["templateID"] = newPageTemplateID;
retPageCreate["subsiteID"] = newPageSubsiteID;
retPageCreate["pageFileName"] = newPageFileName;
// add the newly created pageID into the simple form
if ( StructKeyExists(createResult,"newPageID") AND IsNumeric(createResult.newPageID) AND createResult.newPageID GT 0 )
{
retPageCreate["newPageID"] = createResult.newPageID;
arguments.contentData["catalogPageID"] = retPageCreate.newPageID;
// Update Element Record with the PageID in the catalogPageID field
updateContentStruct = variables.catalogPageDAO.handleUpdateContentRecord(contentType=arguments.contentType,contentData=arguments.contentData);
retPageCreate["updateStatus"] = updateContentStruct;
retPageCreate["catalogPageID"] = retPageCreate.newPageID;
}
else
{
retPageCreate["error"] = "page-create-error";
retPageCreate["create-result"] = createResult;
doErrorLogging(variables.componentName,"handleCreateCatalogPage",retPageCreate,"Page Create Failed!");
}
// add the newly created pageID into the simple form
/*if ( IsNumeric(createResult.newPageID) AND createResult.newPageID GT 0 ) {
pageCreateRet["msg"] = "The new page was created!" & "
";
pageCreateRet["results"] = createResult;
pageCreateRet["status"] = "page-created";
pageCreateRet["catalogPageID"] = createResult.newPageID;
pageCreateRet["catalogPageName"] = stdMetadata.name;
}
else {
pageCreateRet["msg"] = "A new page was NOT created!" & "
";
pageCreateRet["results"] = StructNew();
pageCreateRet["status"] = "page-create-error";
}*/
return retPageCreate;
var appConfigStruct = getAppConfig();
var pageUpdateRet = StructNew();
var catalogPageUpdate = StructNew();
var retStatus = "";
var retMsg = "";
//var catalogData = StructNew();
var updatePageTitle = buildCatalogPageTitle(contentType=arguments.contentType,contentData=arguments.contentData);
var updatePageName = buildCatalogPageFileName(contentType=arguments.contentType,contentData=arguments.contentData);
var updateDescription = buildCatalogPageDescription(contentType=arguments.contentType,contentData=arguments.contentData);
var updateFileName = "";
var catalogCSPageID = arguments.csPageID;
var updateKeywords = "";
var catalogSubsiteID = application.ptCourseCatalog.csData.getSubsiteIDByPageID(pageid=catalogCSPageID); //Stay in the same subsite the page was created in
var catalogSubsiteURL = application.ptCourseCatalog.csData.getSubsiteURLbySubsiteID(subsiteID=catalogSubsiteID);
var pageNameWordTrimCnt = getPageNameMaxWordCount();
var pageDescrptWordTrimCnt = getPageDescriptionMaxWordCount();
// Init the return struct
pageUpdateRet["msg"] = "";
pageUpdateRet["results"] = "";
pageUpdateRet["status"] = "";
pageUpdateRet["catalogPageID"] = 0;
pageUpdateRet["catalogPageName"] = "";
if ( LEN(TRIM(catalogSubsiteURL)) )
{
if ( arguments.verbose )
application.ADF.utils.dodump(catalogSubsiteURL,"catalogSubsiteURL",1);
if ( catalogCSPageID GT 0 )
{
if ( arguments.verbose )
application.ADF.utils.dodump(catalogCSPageID,"catalogCSPageID",1);
// Make sure pages with other CSPageIDs do not have this FileName or Title
// So build a unique and and CS safe page title, page name and file name
uniquePageInfo = application.ptCourseCatalog.csData.createUniquePageInfofromPageTitle(
csPageTitle = updatePageTitle,
csPageName = updatePageName,
csSubsiteID = catalogSubsiteID,
csPageID = catalogCSPageID,
pageNameWordMax = pageNameWordTrimCnt,
verbose=false
);
if ( arguments.verbose )
application.ADF.utils.doDump(uniquePageInfo,"uniquePageInfo",1);
// Get Unique Page Title
if ( StructKeyExists(uniquePageInfo,"title") )
updatePageTitle = uniquePageInfo.title;
// Get Unique Page Name
if ( StructKeyExists(uniquePageInfo,"name") )
updatePageName = uniquePageInfo.name;
// Get Unique File Name
if ( StructKeyExists(uniquePageInfo,"filenameNoExt") )
updateFileName = uniquePageInfo.filenameNoExt;
// Update the Page Name and the Standard Metadata properties (Using the CSAPI command functions)
catalogPageUpdate = variables.catalogPageDAO.handlePageUpdate(
cspageID=catalogCSPageID
,fileName=updateFileName
,pageTitle=updatePageTitle
,pageName=updatePageName
,pageDesc=updateDescription
,pageKeywords=updateKeywords
);
if ( arguments.verbose )
application.ADF.utils.dodump(catalogPageUpdate,"catalogPageUpdate",0);
if ( structKeyExists(catalogPageUpdate,"rename") AND structKeyExists(catalogPageUpdate.rename,"PAGERENAMED") AND catalogPageUpdate.rename.PAGERENAMED IS true )
{
// Add to Return Message String
retMsg = retMsg & "The page was renamed successfully!" & "
";
retStatus = retStatus & "page-renamed";
}
else
{
// Add to Return Message String
retMsg = retMsg & "The page was NOT renamed!" & "
";
retStatus = retStatus & "page-rename-fail";
// TODO: Log Page Rename Failure
}
if ( structKeyExists(catalogPageUpdate,"update") AND structKeyExists(catalogPageUpdate.update,"PAGEUPDATED") AND catalogPageUpdate.update.PAGEUPDATED IS true )
{
// Add to Return Message String
retMsg = retMsg & "The page properties were updated successfully!" & "
";
retStatus = retStatus & "|" & "metadata-updated";
}
else
{
// Add to Return Message String
retMsg = retMsg & "The page properties were NOT updated!" & "
";
retStatus = retStatus & "|" & "metadata-update-fail";
// TODO: Log Page Update Failure
}
pageUpdateRet["msg"] = retMsg;
pageUpdateRet["results"] = catalogPageUpdate;
pageUpdateRet["status"] = retStatus;
}
else
{
pageUpdateRet["msg"] = "The catalog page id was no longer valid!" & "
";
pageUpdateRet["results"] = StructNew();
pageUpdateRet["status"] = "pageid-zero";
}
}
else
{
pageUpdateRet["msg"] = "The destination subsite was no longer valid!" & "
";
pageUpdateRet["results"] = StructNew();
pageUpdateRet["status"] = "subsiteid-error";
}
// Add the catalogPageUpdate cs pageID to the return structure
pageUpdateRet["catalogPageID"] = catalogCSPageID;
pageUpdateRet["catalogPageName"] = updatePageName;
if ( arguments.verbose )
{
updatedPageInfo = application.ptCourseCatalog.csData.getStandardMetadata(catalogCSPageID);
application.adf.utils.doDump(updatedPageInfo,"updatedPageInfo",1);
}
return pageUpdateRet;
return variables.catalogPageDAO.handlePageDelete(cspageID=arguments.csPageID);
var retValue = "create";
var csPageID = getCSPageIDFromContent(contentData=arguments.contentData);
var catPageRebuildStatus = getRebuildStatusFromContent(contentData=arguments.contentData);
//doErrorLogging(variables.componentName,"getPageActionFromContent",catPageRebuildStatus,"catPageRebuildStatus!");
if ( catPageRebuildStatus AND csPageID GT 0 )
retValue = "rebuild";
else if ( csPageID GT 0 )
retValue = "update";
return retValue;
var retValue = 0;
var contentField = "catalogPageID";
// Check if we have a valid cs pageID stored in the element data
if ( NOT StructIsEmpty(arguments.contentData) AND StructKeyExists(arguments.contentData,contentField) AND IsNumeric(arguments.contentData[contentField]) AND arguments.contentData[contentField] GT 0 )
retValue = arguments.contentData[contentField];
return retValue;
var retValue = 0;
var contentField = "catalogPageRebuild";
//doErrorLogging(variables.componentName,"getRebuildStatusFromContent",arguments.contentData,"content data!");
// Check if we have a catalogpagerebuild flag stored in the element data
if ( NOT StructIsEmpty(arguments.contentData) AND StructKeyExists(arguments.contentData,contentField) AND IsNumeric(arguments.contentData[contentField]) AND arguments.contentData[contentField] GT 0 )
retValue = arguments.contentData[contentField];
return retValue;
var retValue = false;
var pageURL = application.ADF.csData.getCSPageURL(pageID=arguments.csPageID);
// Check if we have a page URL
if ( LEN(TRIM(pageURL)) )
retValue = true;
return retValue;
var retValue = 2; //Base+1
switch(arguments.contentType) {
case "department":
retValue = variables.departmentPageService.getTemplateIDFromContent(contentData=arguments.contentData);
break;
case "program":
retValue = variables.programPageService.getTemplateIDFromContent(contentData=arguments.contentData);
break;
case "course":
retValue = variables.coursePageService.getTemplateIDFromContent(contentData=arguments.contentData);
break;
}
return retValue;
var retValue = 1; // root subsite
switch(arguments.contentType)
{
case "department":
retValue = variables.departmentPageService.getSubsiteIDFromContent(contentData=arguments.contentData);
break;
case "program":
retValue = variables.programPageService.getSubsiteIDFromContent(contentData=arguments.contentData);
break;
case "course":
retValue = variables.coursePageService.getSubsiteIDFromContent(contentData=arguments.contentData);
break;
}
return retValue;
var retValue = "";
var lowerCaseStatus = getForceSubsiteNameLowerCaseStatus();
// Go get the Name we should use to create the department Subsite
retValue = variables.departmentPageService.getDepartmentSubsiteName(contentData=arguments.contentData);
// Make the retValue CommonSpot Safe
retValue = application.ptCourseCatalog.csData.makeCSSafe(stringToFix=retValue,makeLowerCase=lowerCaseStatus);
return retValue;
var retValue = "";
var lowerCaseStatus = getForceSubsiteNameLowerCaseStatus();
switch(arguments.contentType)
{
case "program":
retValue = variables.programPageService.getCatYearSubsiteName(contentData=arguments.contentData);
break;
case "course":
retValue = variables.coursePageService.getCatYearSubsiteName(contentData=arguments.contentData);
break;
}
// Make the retValue CommonSpot Safe
retValue = application.ptCourseCatalog.csData.makeCSSafe(stringToFix=retValue,makeLowerCase=lowerCaseStatus);
return retValue;
var retValue = "";
var lowerCaseStatus = getForceSubsiteNameLowerCaseStatus();
switch(arguments.contentType)
{
case "program":
retValue = variables.programPageService.getTermSubsiteName(contentData=arguments.contentData);
break;
case "course":
retValue = variables.coursePageService.getTermSubsiteName(contentData=arguments.contentData);
break;
}
// Make the retValue CommonSpot Safe
retValue = application.ptCourseCatalog.csData.makeCSSafe(stringToFix=retValue,makeLowerCase=lowerCaseStatus);
return retValue;
var retValue = "";
var lowerCaseStatus = getForceFileNameLowerCaseStatus();
switch(arguments.contentType)
{
case "department":
retValue = variables.departmentPageService.buildDepartmentPageFileName(contentData=arguments.contentData);
break;
case "program":
retValue = variables.programPageService.buildProgramPageFileName(contentData=arguments.contentData);
break;
case "course":
retValue = variables.coursePageService.buildCoursePageFileName(contentData=arguments.contentData);
break;
}
// Make the retValue CommonSpot Safe
retValue = application.ptCourseCatalog.csData.makeCSSafe(stringToFix=retValue,makeLowerCase=lowerCaseStatus);
return retValue;
var retValue = "";
switch(arguments.contentType)
{
case "department":
retValue = variables.departmentPageService.buildDepartmentPageTitle(contentData=arguments.contentData);
break;
case "program":
retValue = variables.programPageService.buildProgramPageTitle(contentData=arguments.contentData);
break;
case "course":
retValue = variables.coursePageService.buildCoursePageTitle(contentData=arguments.contentData);
break;
}
return retValue;
var retValue = "";
var pageDescrptWordTrimCnt = getPageDescriptionMaxWordCount();
switch(arguments.contentType)
{
case "department":
retValue = variables.departmentPageService.buildDepartmentPageDescription(contentData=arguments.contentData);
break;
case "program":
retValue = variables.programPageService.buildProgramPageDescription(contentData=arguments.contentData);
break;
case "course":
retValue = variables.coursePageService.buildCoursePageDescription(contentData=arguments.contentData);
break;
}
// If needed trim the description by the word count limit
if ( pageDescrptWordTrimCnt GT 0 )
retValue = application.ptCourseCatalog.data.trimStringByWordCount(str=retValue,words=pageDescrptWordTrimCnt,useEllipsis=false);
return retValue;
var retData = arguments.custMetadata;
var bindFormName = "CourseCatalog";
var bindFields = StructNew();
var bindCustomMetadata = StructNew();
var bindFieldName = "";
// Set the Metadata binding field in a data struct by Content Type
bindFields["department"] = "deptID";
bindFields["program"] = "programID";
bindFields["course"] = "courseID";
// Set up the Custom Metadata struct from the Binding Form
bindCustomMetadata[bindFormName] = structNew();
// Make sure the Content Type that is passed in is in the Binding Field struct
if ( StructKeyExists(bindFields,arguments.contentType) ) {
bindFieldName = bindFields[arguments.contentType];
// Create the binding data for the content type that is passed in
if ( LEN(TRIM(bindFieldName)) )
bindCustomMetadata[bindFormName][bindFieldName] = arguments.contentID;
}
// Merge the Custom Metadata from the Template with the new metadata for the binding the Page (overwriting and existing binding info)
StructAppend(retData,bindCustomMetadata,true);
return retData;
var retValue = arguments.parentSubsiteID;
var parentSubsiteURL = application.ptCourseCatalog.csData.getSubsiteURLbySubsiteID(subsiteID=retValue);
var childSubsiteName = ""; //getCatYearSubsiteNameFromContent(contentType=arguments.contentType,contentData=arguments.contentData);
var childSubsiteURL = "";
var childSubsiteID = 1;
// - Build a pseudo SUBSITE URL from the parent and the child's (catalog year) subsite name
// -- Get the parent subsiteURL
// -- Get the subsite name to be used for the ContentType's term
// -- Concatinate the Parent Subsite URL and the Term Subsit Name
// - Check to see if a term subsite exists inside of the parent's subsite
// -- If exists
// --- Set the Term Subsite ID as teh retValue
// -- If it does not exist
// --- Create the term subsite
// --- Set the NEW term subsite ID as the retValue
switch(arguments.contentType)
{
/* case "department":
childSubsiteName = getDepartmentSubsiteNameFromContent(contentType=arguments.contentType,contentData=arguments.contentData);
break; */
case "program":
childSubsiteName = getCatYearSubsiteNameFromContent(contentType=arguments.contentType,contentData=arguments.contentData);
break;
case "course":
childSubsiteName = getCatYearSubsiteNameFromContent(contentType=arguments.contentType,contentData=arguments.contentData);
break;
}
// Build the new SubsiteURL from the parentSubsiteURL and the childSubsiteName from the contentData record
if ( LEN(TRIM(childSubsiteName)) )
childSubsiteURL = parentSubsiteURL & childSubsiteName & "/";
else
childSubsiteURL = parentSubsiteURL;
// Now Check to see if the SubsiteURL is valid
childSubsiteID = application.ptCourseCatalog.csData.getSubsiteID(subsiteURL=childSubsiteURL);
// If needed, build the subsite Path for the Child Subsite
if ( childSubsiteID LTE 0 ) {
// Subsite doesn't exist, so build it now
childSubsiteID = application.ptCourseCatalog.CSSubsite.buildSubsitesFromPath(subsitePath=childSubsiteURL);
}
// Pass the Child Subsite URL back as the Return Value
retValue = childSubsiteID;
return retValue;