// Get the values from the Configuration Element
uiTheme = application.ptSocialMedia.getUItheme();
// TODO - Figure out why are these commented out
// Load the Facebook Graph API JS Headers Headers
//application.ptSocialMedia.socialMediaService.loadFacebookJS();
// Load the Twitter @Anywhere and Widgets JS Headers Headers
//application.ptSocialMedia.socialMediaService.loadTwitterAnywhereJS();
//application.ptSocialMedia.socialMediaService.loadTwitterWidgetsJS();
// Load the JQuery Plugin Headers
application.ptSocialMedia.scripts.loadjQuery(noconflict=1);
// load header for jQuery UI
application.ptSocialMedia.scripts.loadJQueryUI(themeName=uiTheme);
// Load the JQuery TimeAgo Plugin Headers
application.ptSocialMedia.scripts.loadjQueryTimeAgo();
// Load the JQuery TimeAgo Plugin Headers
application.ptSocialMedia.scripts.loadCFJS();
// Load the Social Media App JS Headers
application.ptSocialMedia.socialMediaService.loadSocialMediaJS();
// if on Authoring DO NOT Cache
if ( server.commonspot.udf.security.authorok() == 1 )
{
request.element.isStatic = 0;
// request.element.hasdata=1;
}
else
{
// Cache for a set amount of time then refresh the cache
// Get today's last X minute(s)
minsToCache = 10;
rebuildDate = dateAdd("n", minsToCache, now());
// tells the element to cache until the end of today
request.element.cacheValidUntil = Mid(CreateODBCDateTime(rebuildDate),6,19);
// makes sure that the element is static
request.element.isStatic = 1;
}
csMode = "";
if ( StructKeyExists(request,"renderstate") AND StructKeyExists(request.renderstate,"rendermode") )
csMode = request.renderstate.rendermode;
// Set the Default for the Show Error flag
showError = true;
showModerateTools = false;
showSocialMediaToolsBtn = false;
socialMediaToolsBtnShowText = "Show Moderation Bars";
socialMediaToolsBtnHideText = "Hide Moderation Bars";
showElementDump = false;
if ( StructKeyExists(request.params,"showElement") AND IsBoolean(request.params.showElement) )
showElementDump = request.params.showElement;
showDataDump = false;
if ( StructKeyExists(request.params,"showData") AND IsBoolean(request.params.showData) )
showDataDump = request.params.showData;
showFeedDump = false;
if ( StructKeyExists(request.params,"showFeed") AND IsBoolean(request.params.showFeed) )
showFeedDump = request.params.showFeed;
showSourceDataDump = false;
if ( StructKeyExists(request.params,"showSourceData") AND IsBoolean(request.params.showSourceData) )
showSourceDataDump = request.params.showSourceData;
noRenderHTML = false;
if ( StructKeyExists(request.params,"noHTML") AND IsBoolean(request.params.noHTML) )
noRenderHTML = request.params.noHTML;
showTestPost = false;
if ( StructKeyExists(request.params,"showTestPost") AND IsBoolean(request.params.showTestPost) )
showTestPost = request.params.showTestPost;
// Set variabless for items that should only be show in author mode and with the correct user rights
if ( ListFindNoCase("author,edit",csMode) ) {
showSocialMediaToolsBtn = true;
showModerateTools = true;
}
CSRF_Token = application.ADF.csSecurity.getCSRF_Token();
// Made it past the initial data check ... turn off the error
showError = false;
outputHTML = true;
// Get the values from the Configuration Element
appConfigStruct = application.ptSocialMedia.getAppConfig();
//application.ptSocialMedia.utils.doDump(appConfigStruct,"appConfigStruct",0);
// Set the UI theme from the Configuration Element
uiTheme = 'redmond';
if ( structKeyExists(appConfigStruct,"ui_theme") AND LEN(TRIM(appConfigStruct['ui_theme'])) )
uiTheme = appConfigStruct['ui_theme'];
//Set Ajax Proxy Path
AjaxPath = application.ADF.ajaxProxy;
//Set the Controller Bean and the RomoveMethod
ControllerBean = "feedController";
RemoveMethod = "removePost";
//application.ptSocialMedia.scripts.setDebugMode(debugMode=true);
// Get the data items in the RH
selectedFeeds = attributes.elementInfo.elementData.propertyValues;
// Since we are only worried about what is in the first array item grab that one
selectedFeedStruct = StructNew();
if ( ArrayLen(selectedFeeds) )
selectedFeedStruct = selectedFeeds[1];
// TODO: Add admin/contributor rights check around this DUMP
if ( showElementDump )
application.ptSocialMedia.utils.doDump(selectedFeedStruct,"selectedFeedStruct",0);
items = ArrayNew(1);
maxRenderLimit = 10;
facebookLikeButtonStyle = "Button Count"; //Standard
likeStyle = "button_count";
likeWidth = 200;
twitterTweetButtonStyle = "No Count";
tweetStyle = "none";
showSourceLinks = "No Display";
sourceLinksPosition = "";
youTubeThumbImageHTML = "";
openYouTubePlayersInLB = "No";
lbYouTubePlayerWidth = "480"; //Default: 480x270 aspect ratio 16:9
lbYouTubePlayerHeight = "270";
// Make sure Feed Selector Element Returns selected feed records
if ( StructKeyExists(selectedFeedStruct,"values") ) {
// Get the RenderLimit from the selected feed meta data
if ( StructKeyExists(selectedFeedStruct.values,"renderLimit") )
maxRenderLimit = selectedFeedStruct.values.renderLimit;
// Get the fbLikeButtonStyle from the selected feed meta data
if ( StructKeyExists(selectedFeedStruct.values,"fbLikeButtonStyle") )
facebookLikeButtonStyle = selectedFeedStruct.values.fbLikeButtonStyle;
// 2025-02-12 - Removed Twitter Posts logic
// Get the tweetButtonStyle from the selected feed meta data
//if ( StructKeyExists(selectedFeedStruct.values,"tweetButtonStyle") )
//twitterTweetButtonStyle = selectedFeedStruct.values.tweetButtonStyle;
// Get the tweetButtonStyle from the selected feed meta data
if ( StructKeyExists(selectedFeedStruct.values,"displaySourcesLinks") )
showSourceLinks = selectedFeedStruct.values.displaySourcesLinks;
// Get the youtubePlayersInLB from the selected feed meta data
if ( StructKeyExists(selectedFeedStruct.values,"youtubePlayersInLB") )
openYouTubePlayersInLB = selectedFeedStruct.values.youtubePlayersInLB;
// Get the youtubePlayerSizeInLB from the selected feed meta data
// - Convert the value to a width and a height
if ( StructKeyExists(selectedFeedStruct.values,"youtubePlayerSizeInLB") AND LEN(TRIM(selectedFeedStruct.values.youtubePlayerSizeInLB)) ) {
youtubePlayerSizeInLB = selectedFeedStruct.values.youtubePlayerSizeInLB ;
if ( IsNumeric(ListFirst(youtubePlayerSizeInLB,"x")) )
lbYouTubePlayerWidth = ListFirst(youtubePlayerSizeInLB,"x");
if ( IsNumeric(ListLast(youtubePlayerSizeInLB,"x")) )
lbYouTubePlayerHeight = ListLast(youtubePlayerSizeInLB,"x");
}
// Facebook Button CE Options: No Button, Standard, Button Count, Box Count
// FB Parameter Values: standard, button_count, box_count
if ( facebookLikeButtonStyle EQ "Button Count" )
likeStyle = "button_count";
else if ( facebookLikeButtonStyle EQ "Box Count" )
likeStyle = "box_count";
else if ( facebookLikeButtonStyle EQ "Standard" )
likeStyle = "standard";
// 2025-02-12 - Removed Twitter Posts logic
// Twitter Button CE Options: No Button, No Count, Vertical Count, Horizontal Count
// Twitter Parameter Values: none, horizontal, vertical
/* if ( twitterTweetButtonStyle EQ "Vertical Count" )
tweetStyle = "vertical";
else if ( twitterTweetButtonStyle EQ "Horizontal Count" )
tweetStyle = "horizontal";
else if ( twitterTweetButtonStyle EQ "No Count" )
tweetStyle = "none";*/
// Set the source link display position
if ( showSourceLinks EQ "Links on Top" )
sourceLinksPosition = "top";
else if ( showSourceLinks EQ "Links on Bottom" )
sourceLinksPosition = "bottom";
// Get Feed Data from the Combined from the selected Feeds
items = application.ptSocialMedia.feedController.buildCombinedFeedItems(
selectedFeeds=selectedFeedStruct
,sortOrder="desc"
,sortField="PublishedDate"
,addTestData=showTestPost
,showFeedDump=showFeedDump
);
// TODO: Add admin/contributor rights check around this DUMP
if ( showDataDump )
application.ADF.utils.doDump(items,"items",0);
// Set the Max Number of Result to display
if ( ArrayLen(items) LT maxRenderLimit )
maxRenderLimit = ArrayLen(items);
// Get Feed Souce Link data for the selected Feeds
if ( LEN(TRIM(showSourceLinks)) ) {
sourceItems = application.ptSocialMedia.feedController.buildFeedSourceData(
feedItems=items,
renderedItemCount=maxRenderLimit
);
// TODO: Add admin/contributor rights check around this DUMP
if ( showSourceDataDump )
application.ptSocialMedia.utils.doDump(sourceItems,"sourceItems",0);
}
}
if ( ArrayLen(items) EQ 0 )
showError = true;
if ( noRenderHTML )
outputHTML = false;
// Do not Show Moderation Tools if there are no items returned (or if there was an error)
//if ( showError ) {
//showSocialMediaToolsBtn = false;
//showModerateTools = false;
//}
application.ADF.scripts.addFooterJS(moderationFooterJS,"TERTIARY");