var rtnStruct = structNew();
// TODO the element names should all be constants
var blogArray = application.ptBlog2.ceData.getCEData("Blog2", "blogID", arguments.blogID);
if( arrayLen(blogArray) )
{
rtnStruct = blogArray[1].values;
rtnStruct.dataPageID = blogArray[1].pageID;
}
var rtnStruct = structNew();
// TODO the element names should all be constants
var blogArray = application.ptBlog2.ceData.getCEData("Blog2", "Name", arguments.blogName);
if( arrayLen(blogArray) )
{
rtnStruct = blogArray[1].values;
rtnStruct.dataPageID = blogArray[1].pageID;
}
// Return the CCAPI status struct
var contentResult = application.ptBlog2.CSContent.populateContent("Blog", arguments.dataStruct);
var blogData = getBlogByName(blogName=arguments.blogName);
var status = StructNew();
// Check that we have a dataset
if ( structKeyExists(blogData, "name") )
{
// Update the Active field to "No"
blogData["active"] = "No";
// Pass the data back to update the element
status = createBlog(dataStruct=blogData);
}
var pageCreationResults = "";
var blog = getBlog(arguments.blogID);
var stdMetadata = StructNew();
var custMetadata = StructNew();
var blogRootSubsiteID = 0;
var subsiteParentsList = "";
var hasValidSubsiteID = true;
var subsiteErrorMsg = '';
// Set the landing page name
var landingPageName = application.ptBlog2.csData.buildCSPageName(contentTitle=blog.landingPageName);
var landingCSPageID = 0;
var childLandingCSPageID = 0;
var pageData = StructNew();
var retData = StructNew();
retData.errorFlag = false;
retData.errorMsg = "";
retData.csPageID = 0;
// Get the CS Page ID for the Landing Page
if ( !IsNumeric(arguments.subsiteID) )
landingCSPageID = application.ptBlog2.blogService.getFeatureCSPageID(blogID=arguments.blogID, featureType="landingPage");
// Check if the page doesn't exist and we want to build the blog landing page.
if ( landingCSPageID LTE 0
AND application.ptBlog2.appConfig.blogIndexTemplate
AND blog.autoLandingPage )
{
blogRootSubsiteID = application.ptBlog2.blogService.getBlogSubsiteID(blogID=arguments.blogID);
if ( IsNumeric(blogRootSubsiteID) AND blogRootSubsiteID GT 0 )
{
// Set the subsite for the page creation
stdMetadata.subsiteID = blogRootSubsiteID;
if ( IsNumeric(arguments.subsiteID) AND arguments.subsiteID GT 0 )
{
if ( StructKeyExists(request.subsiteCache,arguments.subsiteID) )
{
subsiteParentsList = request.subsiteCache[arguments.subsiteID].SubsiteInheritance;
if ( ListFind(subsiteParentsList,blogRootSubsiteID) )
{
// TODO: Add one more check to see if a child subsite has a landing page
// before attempting to create the page.
//childLandingCSPageID = application.ptBlog2.blogService.getFeatureCSPageID(blogID=arguments.blogID, featureType="landingPage",subsiteID=arguments.subsiteID);
//if ( childLandingCSPageID GT 0 )
//{
// if a valid child blog subsite was added, use it to set the subsite for the page creation
stdMetadata.subsiteID = arguments.subsiteID;
//}
}
else
{
hasValidSubsiteID = false;
subsiteErrorMsg = "The provided blog child subsite was not found under the root blog subsite!";
}
}
else
{
hasValidSubsiteID = false;
subsiteErrorMsg = "A valid blog child subsite was not provided!";
}
}
}
else
{
hasValidSubsiteID = false;
subsiteErrorMsg = "A valid blog root was not provided!";
}
if ( hasValidSubsiteID )
{
stdMetadata.name = landingPageName;
stdMetadata.title = blog.name;
stdMetadata.templateID = application.ptBlog2.appConfig.blogIndexTemplate;
stdMetadata.caption = stdMetadata.title;
stdMetadata.description = stdMetadata.title;
stdMetadata.publicationDate = DateFormat(now(), 'yyyy-mm-dd') & " " & TimeFormat(now(), 'HH:MM:SS');
stdMetadata.categoryID = 1;
//custMetadata = StructNew();
//custMetadata.Blogs2.blogID = arguments.blogID;
// Get the custom metadata from the template (fix for CS CCAPI custom metadata inheritance issue)
custMetadata = application.ptBlog2.csData.getCustomMetadata(pageid=stdMetadata.templateID,convertTaxonomyTermsToIDs=1);
custMetadata["Blogs2"] = structNew();
custMetadata["Blogs2"]["blogID"] = arguments.blogID;
custMetadata["Blogs2"]["postID"] = "";
pageData = stdMetadata;
// Convert the metadata structure to an array of MetadataValue structures for the API
pageData['metadata'] = application.ptBlog2.csData.metadataStructToArray(metadata=custMetadata);
// Ues the Create Remote incase Blog contributor doesn't have page rights
pageCreationResults = application.ptBlog2.apiPage.createRemote(pageData=pageData,
activatePage=true);
if ( StructKeyExists(pageCreationResults, "CMDSTATUS")
AND pageCreationResults.CMDSTATUS EQ true
AND StructKeyExists(pageCreationResults, "CMDRESULTS") )
{
retData.csPageID = pageCreationResults.CMDRESULTS;
}
else
{
retData.errorFlag = true;
if ( StructKeyExists(pageCreationResults, "CMDRESULTS") )
retData.errorMsg = pageCreationResults.CMDRESULTS;
else
retData.errorMsg = "Error";
}
}
else
{
retData.errorFlag = true;
retData.errorMsg = "Error: " & subsiteErrorMsg;
}
}
else
{
// Set the landing page CS page ID to send back
retData.csPageID = landingCSPageID;
}
return retData;
// Validate the postID passed into the function
var postData = getPost(arguments.postID);
var sparams = StructNew();
var csPage = "";
/*
// Check that we have values
if ( StructKeyExists(postData, "postPageID") AND LEN(postData.postPageID) AND isNumeric(postData.postPageID) ){
// Load the sparams
sparams.pageid = postData.postPageID;
// Call CSData to get the subsiteID for the pageID
sparams.subsiteid = application.ptBlog2.csdata.getSubsiteIDByPageID(postData.postPageID);
// create the page CFC
csPage = server.ADF.objectFactory.getBean("CSPage_1_0");
// delete the page
csPage.deletePage(sparams);
} */
return true;
var rtnArray = ArrayNew(1);
return rtnArray;
var rtnString = "";
var pageCreationResults = "";
var blog = getBlog(arguments.blogID);
var stdMetadata = StructNew();
var custMetadata = StructNew();
var pageTitle = blog.name & " Tags";
// Set the landing page name
var tagsPageName = application.ptBlog2.csData.buildCSPageName(contentTitle=blog.tagsPageName);
// Get the CS Page ID for the Landing Page
var landingCSPageID = application.ptBlog2.blogService.getFeatureCSPageID(blogID=arguments.blogID,
featureType="tagsListing");
var pageData = StructNew();
var retData = StructNew();
retData.errorFlag = false;
retData.errorMsg = "";
retData.csPageID = 0;
// Check if the page doesn't exist
// AND we want to build the tags listing page
// AND the PT Tags is integrated is enabled
if( (landingCSPageID LTE 0)
AND Len(application.ptBlog2.appConfig.tagsPageTemplate)
AND (blog.autoTagsPage)
AND application.ptBlog2.appConfig.tagsIntegrated ){
stdMetadata.subsiteID = application.ptBlog2.blogService.getBlogSubsiteID(blogID=arguments.blogID);
stdMetadata.name = tagsPageName;
stdMetadata.title = pageTitle;
stdMetadata.templateID = application.ptBlog2.appConfig.tagsPageTemplate;
stdMetadata.caption = stdMetadata.title;
stdMetadata.description = stdMetadata.title;
stdMetadata.publicationDate = DateFormat(now(), 'yyyy-mm-dd') & " " & TimeFormat(now(), 'HH:MM:SS');
stdMetadata.categoryID = 1;
custMetadata = StructNew();
custMetadata.Blogs2.blogID = arguments.blogID;
pageData = stdMetadata;
// Convert the metadata structure to an array of MetadataValue structures for the API
pageData['metadata'] = application.ptBlog2.csData.metadataStructToArray(metadata=custMetadata);
/*pageCreationResults = application.ptBlog2.apiPage.create(pageData=pageData,
activatePage=true);*/
pageCreationResults = application.ptBlog2.apiPage.createRemote(pageData=pageData,
activatePage=true);
if ( StructKeyExists(pageCreationResults, "CMDSTATUS")
AND pageCreationResults.CMDSTATUS EQ true
AND StructKeyExists(pageCreationResults, "CMDRESULTS") ) {
retData.csPageID = pageCreationResults.CMDRESULTS;
}
else {
retData.errorFlag = true;
if ( StructKeyExists(pageCreationResults, "CMDRESULTS") )
retData.errorMsg = pageCreationResults.CMDRESULTS;
else
retData.errorMsg = "Error";
}
}
else {
// Set the landing page CS page ID to send back
retData.csPageID = landingCSPageID;
}
return retData;
// Return the CCAPI status struct
var contentResult = application.ptBlog2.CSContent.populateContent("BlogFeatureData", arguments.dataStruct);
return contentResult;
var rtnStruct = structNew();
// Get the data for the Blog Feature Data
var featureDataArray = arrayNew(1);
// Get based on Blog ID, Feature Type, and Feature CS Page ID
if ( LEN(arguments.blogID) AND LEN(arguments.featureType) AND (arguments.featureCSPageID GT 0) ) {
featureDataArray = application.ptBlog2.ceData.getCEData(customElementName="Blog2 Feature Data",
searchFields="blogID,featureType,featureCSPageID",
searchValues="#arguments.blogID#,#arguments.featureType#,#arguments.featureCSPageID#",
queryType="multi");
}
// Get based on Blog ID and Feature Type
else if ( LEN(arguments.blogID) AND LEN(arguments.featureType) ) {
featureDataArray = application.ptBlog2.ceData.getCEData(customElementName="Blog2 Feature Data",
searchFields="blogID,featureType",
searchValues="#arguments.blogID#,#arguments.featureType#",
queryType="multi");
}
else if ( LEN(arguments.blogID) ) {
featureDataArray = application.ptBlog2.ceData.getCEData(customElementName="Blog2 Feature Data",
customElementFieldName="blogID",
item=arguments.blogID,
queryType="selected");
}
return featureDataArray;