var status = ""; // Get the Post Data var postData = application.ptBlog2.postDAO.getPost(postID=arguments.postID); // Check if the Blog Post has a page, and the page exists if ( isNumeric(postData.postPageID) AND postData.postPageID GT 0 AND (LEN(application.ptBlog2.csData.getCSPageURL(postData.postPageID))) ) { // Update the existing page metadata saveInfoPostPage(postID=arguments.postID); // Rename the post page renamePostPage(postID=arguments.postID); } else { // Create the blog post page postData = createPostPage(blogID=arguments.BlogID,postID=arguments.postID); } /* 2011-10-28 - MFC - Added Feature - PT tags integration into the blog post. Check if the PT Tags apps is integrated 2012-09-11 - MFC - Commented out b/c the tags are set when the form is saved.*/ /* if ( application.ptBlog2.appConfig.tagsIntegrated ) { updatedPostData = setTags(dataValues=updatedPostData); } */ // Update the blog post data status = application.ptBlog2.postDAO.updatePost(dataValues=postData); // Send notifications status = postNotification(postDataValues=postData); var pageMetadata = StructNew(); var stdMetadata = structNew(); var custMetadata = structNew(); // get configuration for this blog (gives the template and subsite data) var blogConfig = application.ptBlog2.blogDAO.getBlog(blogID=arguments.BlogID); var postData = application.ptBlog2.postDAO.getPost(postID=arguments.postID); var postSubsiteID = 0; var postSubsitePath = ""; var result = ""; // TODO error check that we got a valid config back for this blog if( structKeyExists(blogConfig, "subsiteURL") ) { // Build the post page metadata pageMetadata = buildPageMetadata(blogPostData=postData); // Check if the subsite URL text is a valid subsite postSubsiteID = application.ptBlog2.blogService.getBlogSubsiteID(blogID=arguments.blogID, postID=arguments.postID); // Add in the subsite and template pageMetadata.standard.subsiteID = postSubsiteID; pageMetadata.standard.templateID = blogConfig.blogTemplate; // create the page result = application.ptBlog2.PostDAO.createPost(pageMetadata.standard, pageMetadata.custom); // add the newly created pageID into the simple form if ( (isNumeric(result.newPageID)) AND (result.newPageID GT 0) ) { postData.postPageID = result.newPageID; } } // Get the blog data var postData = application.ptBlog2.postDAO.getPost(postID=arguments.postID); var result = ""; // Build the post page metadata var pageMetadata = buildPageMetadata(blogPostData=postData); // Add the current page ID pageMetadata.standard.id = postData.postPageID; // create the page result = application.ptBlog2.PostDAO.saveInfoPost(pageMetadata.standard, pageMetadata.custom); // Get the blog data var postData = application.ptBlog2.postDAO.getPost(postID=arguments.postID); var result = ""; // Build the post page metadata var pageMetadata = buildPageMetadata(blogPostData=postData); var currPageInfo = application.ptBlog2.apiPage.getInfo(csPageID=postData.postPageID); // Add the current page ID pageMetadata.standard.id = postData.postPageID; // Check if we need to rename the page if ( StructKeyExists(currPageInfo, "CMDRESULTS") AND StructKeyExists(currPageInfo.CMDRESULTS, "name") AND ( currPageInfo.CMDRESULTS.name NEQ pageMetadata.standard.name ) ) { // Rename the page result = application.ptBlog2.PostDAO.renamePost(pageMetadata.standard, pageMetadata.custom); } var pageMetadata = structNew(); // get configuration for this blog (gives the template and subsite data) var blogConfig = application.ptBlog2.blogDAO.getBlog(blogID=arguments.blogPostData.blogID); pageMetadata.standard = structNew(); pageMetadata.custom = structNew(); pageMetadata.standard.name = application.ptBlog2.CSData.makeCSSafe(arguments.blogPostData.title); pageMetadata.standard.title = arguments.blogPostData.title; pageMetadata.standard.globalKeywords = buildPageKeywords(arguments.blogPostData.tags); // Make sure the description field is distinct to avoid any potential // Standard Metadata errors if ( pageMetadata.standard.title NEQ arguments.blogPostData.slug ) pageMetadata.standard.description = arguments.blogPostData.slug; else pageMetadata.standard.description = "Blog post " & blogPostData.slug; pageMetadata.standard.caption = arguments.blogPostData.title; pageMetadata.standard.publicationDate = DateFormat(arguments.blogPostData.datePosted, 'yyyy-mm-dd') & " " & TimeFormat(arguments.blogPostData.datePosted, 'HH:MM:SS'); pageMetadata.standard.categoryID = 1; // 2013-12-17 - Added so pages are pageindex-able pageMetadata.standard.audiencecategory = 1; // Get the custom metadata from the template (fix for CS CCAPI custom metadata inheritance issue) pageMetadata.custom = application.ptBlog2.csData.getCustomMetadata(pageid=blogConfig.blogTemplate, convertTaxonomyTermsToIDs=1); pageMetadata.custom["Blogs2"] = structNew(); pageMetadata.custom["Blogs2"]["blogID"] = arguments.blogPostData.blogID; pageMetadata.custom["Blogs2"]["postID"] = arguments.blogPostData.postID; return pageMetadata; var retKeywords = ""; // Check if we have the PT Tags Integrated if ( application.ptBlog2.appConfig.tagsIntegrated AND ListFindNoCase(application.ADF.siteAppList, "ptTags") ) { // Call the PT Tags app to return the string of keywords retKeywords = application.ptTags.tagsService.tagNameListByIDs(tagIDList=arguments.tagFieldData, delim=","); } else { // Return the tags b/c they are the text keywords retKeywords = arguments.tagFieldData; } return retKeywords; // Call the PT Tags to add the text tags and return the UUID list if ( ListFindNoCase(application.ADF.siteAppList, "ptTags") ) arguments.dataValues.tags = application.ptTags.tagsService.handleTagAdd(tags=arguments.dataValues.tags, contentID=arguments.dataValues.blogID, parentContentID=0); return arguments.dataValues; var currPost = ""; var retPostData = ArrayNew(1); var itmCntr = 0; // Config Values // - Set the Link, Page and Subsite Defualts var baseLinkURL = ""; // Link to the Display page for the RSS feed Data var rootSiteURL = "http://" & CGI.HTTP_HOST; // Get the feed Page ID from the current page var feedPageID = request.page.ID; var feedPageURL = Application.PTBlog2.csData.getCSPageURL(feedPageID); // Set the base Page and Subsite defaults... to handle it if nothing is passed in var basePageURL = ""; var baseSubsiteID = request.subsite.id; var baseSubsiteURL = request.subsiteCache[request.subsite.id].url; var recentPostDaysFilter = 90; var recentPostDescriptionWordsLimit = 25; var showRSSdata = false; var rssStruct = StructNew(); var blogData = ""; var FormattedPostURL = ""; var postPageID = ""; var FormattedDatePosted = ""; var FormattedTitle = ""; var FormattedDesciption = ""; var tagNameList = ""; // Build the site URL is the server is secure if ( CGI.SERVER_PORT IS "443" ) rootSiteURL = "https://" & CGI.HTTP_HOST; if ( structKeyExists(request.params,"pgid") AND IsNumeric(request.params.pgid) ) { basePageURL = Application.Blog2.csData.getCSPageURL(request.params.pgid); } else if ( structKeyExists(request.params,"ssid") AND IsNumeric(request.params.ssid) ) { // If a pageID is not passed in, use the index page of the current subsite (set above) or a subsite ID that is passed in // If a Subsite ID is passed in, use this for the subsite id baseSubsiteID = request.params.ssid; baseSubsiteURL = request.subsiteCache[baseSubsiteID].url; } // TODO: Add this to the CS Filter recentPostDaysFilter = 90; if (structKeyExists(request.params,"days") AND IsNumeric(request.params.days) AND request.params.days NEQ 0 ) recentPostDaysFilter = request.params.days; recentPostDescriptionWordsLimit = 25; if (structKeyExists(request.params,"words") AND IsNumeric(request.params.words) AND request.params.words NEQ 0 ) recentPostDescriptionWordsLimit = request.params.words; showRSSdata = false; if (structKeyExists(request.params,"rssdata") AND IsBoolean(request.params.rssdata) ) showRSSdata = request.params.rssdata; // Create the LinkURL fromt the basePageURL if ( LEN(TRIM(basePageURL)) ) baseLinkURL = rootSiteURL & basePageURL; else baseLinkURL = rootSiteURL & baseSubsiteURL; // use the index page as the URL the base subsite // Build the RSS feed struct rssStruct = StructNew(); // The "link" is URL page the RSS feed references, not the URL of the FEED itself // - This URL was built from location of the CS Page using this RH or from the subsite or pageID that was passed in rssStruct.link = baseLinkURL; rssStruct.title = "Recent Blog Posts"; // TODO: Add to configuration render handler Meta data rssStruct.description = "RSS Feed for Recent Blog Posts"; // TODO: Add to configuration render handler Meta data rssStruct.pubDate = Now(); rssStruct.version = "rss_2.0"; rssStruct.item = ArrayNew(1); // Loop of Posts2 element data for (itm=1;itm LTE ArrayLen(arguments.blogDataArray); itm=itm+1) { //Application.ptBlog2.utils.doDump(arguments.blogDataArray[itm].values.blogID,"blogID",0); // Get the meta data about the BLOG that this Blog Post is coming from blogData = Application.ptBlog2.blogDAO.getBlog(arguments.blogDataArray[itm].values.blogID); //Application.ptBlog2.utils.doDump(blogData,"blogData",0); // Make sure the Blog is ACTIVE if ( IsStruct(blogData) AND StructKeyExists(blogData,"active") AND blogData.active EQ true ) { // Set 'baseLinkURL' adn the Default URL for each item FormattedPostURL = baseLinkURL; // Set the PageID for the Blog Post postPageID = arguments.blogDataArray[itm].values.postPageID; // If a PostPageID is available for the Post, get the Page URL from the pageid if ( LEN(TRIM(postPageID)) AND IsNumeric(postPageID) ) FormattedPostURL = rootSiteURL & application.ptBlog2.CSData.getCSPageURL(pageID=arguments.blogDataArray[itm].values.postPageID); // Formatted RSS Post Date FormattedDatePosted = createDate(year(arguments.blogDataArray[itm].values.datePosted), month(arguments.blogDataArray[itm].values.datePosted), day(arguments.blogDataArray[itm].values.datePosted)); // Filter By Recent Posts if ( DateCompare(FormattedDatePosted,DateAdd("d",-(recentPostDaysFilter),Now())) EQ 1) { itmCntr = itmCntr + 1; // Formatted RSS Title FormattedTitle = XMLFormat(Trim(arguments.blogDataArray[itm].values.title)); // Format RSS Description FormattedDesciption = arguments.blogDataArray[itm].values.slug; FormattedDesciption = XMLFormat(FormattedDesciption); // 2013-02-12 - Removed the description to default to the content if not defined. /* if ( LEN(TRIM(FormattedDesciption)) EQ 0 ) FormattedDesciption = arguments.blogDataArray[itm].values.content; // Strip out Images from inside the blog post content block FormattedDesciption = REReplace(FormattedDesciption,"]*>","","All"); // Strip HTML FormattedDesciption = ReReplace(FormattedDesciption, "<[^>]*>", "", "all"); // Trim the number of words FormattedDesciption = application.ptBlog2.data.trimStringByWordCount(FormattedDesciption,recentPostDescriptionWordsLimit,0); // Make XML Safe (converts some characters to HTML entities ) // TODO: DO NOT USE... this logic needs some work before using this function FormattedDesciption = XMLFormat(FormattedDesciption); */ // Build Feed ITEM substruct rssStruct.item[itmCntr] = StructNew(); rssStruct.item[itmCntr].title = xmlFormat(FormattedTitle); // "2" rssStruct.item[itmCntr].pubDate = FormattedDatePosted; rssStruct.item[itmCntr].description = StructNew(); rssStruct.item[itmCntr].description.value = FormattedDesciption; rssStruct.item[itmCntr].guid.isPermaLink = "YES"; rssStruct.item[itmCntr].guid.value = TRIM(FormattedPostURL); rssStruct.item[itmCntr].link = TRIM(FormattedPostURL); rssStruct.item[itmCntr].category = ArrayNew(1); // extract the tags from the a comma-delimited list and assign to RSS categories if ( structKeyExists(arguments.blogDataArray[itm].values, "tags") ) { tagNameList = arguments.blogDataArray[itm].values.tags; for (c=1;c LTE ListLen(tagNameList,","); c=c+1) { rssStruct.item[itmCntr].category[c] = StructNew(); rssStruct.item[itmCntr].category[c].value = Trim(ListGetAt(tagNameList,c,",")); } } // retrieve the tag names for the tags // IMPORTANT: This Requires ptTags App /* if (structKeyExists(arguments.blogDataArray[itm].values, "tags") and LEN(TRIM(arguments.blogDataArray[itm].values.tags)) ) { tagNameList = application.ptTags.tagsService.tagNameListByIDs(arguments.blogDataArray[itm].values.tags); //Build Category Sub-Substruct for TAGS for (cat=1;cat LTE ListLen(tagNameList,"^"); cat=cat+1) { rssStruct.item[itmCntr].category[cat] = StructNew(); rssStruct.item[itmCntr].category[cat].value = ListGetAt(tagNameList,cat,"^"); } } */ } } } if ( showRSSdata ) Application.ptBlog2.utils.doDump(rssStruct,"rssStruct",0); return rssStruct; // Get the blog information var blogData = application.ptBlog2.blogDAO.getBlog(blogID=arguments.postDataValues.blogID); var notificationEmails = application.ptBlog2.blogService.getNotificationEmails(blogID=arguments.postDataValues.blogID); var fromEmailAddress = notificationEmails.from; var toEmailAddress = notificationEmails.to; var msgBody = buildNotificationMessage(postDataValues=arguments.postDataValues, blogDataValues=blogData); var emailSent = false; // Initialize the variables var msgBody = "";

Blog:
#arguments.blogDataValues.name#

Post:
#arguments.postDataValues.title#

Abstract:
#arguments.postDataValues.slug#