// Get the values from the Configuration Element
appConfigStruct = application.ptSocialMedia.getAppConfig();
/*writeDump(var=appConfigStruct,expand=0,label="appConfigStruct");*/
// filtertype = included -> BlockedListing
// excluded -> AllowedListing
// init the filter type
filterType = 'included';
filterPostClass = '';
if ( structKeyExists(appConfigStruct,"filterType") AND LEN(TRIM(appConfigStruct['filterType'])) )
filterType = appConfigStruct['filterType'];
// Load the JQuery Plugin Headers
application.ptSocialMedia.scripts.loadjQuery();
// load header for jQuery UI
application.ptSocialMedia.scripts.loadJQueryUI();
// Load the JQuery TimeAgo Plugin Headers
application.ptSocialMedia.scripts.loadjQueryTimeAgo();
// Load the JQuery CFJS Plugin Headers
application.ptSocialMedia.scripts.loadCFJS();
// Load the Social Media App JS Headers
application.ptSocialMedia.socialMediaService.loadSocialMediaJS();
// Add social media style sheet files
if ( NOT StructKeyExists(request,'loadSocialMediaCssStyles') )
{
smBaseCssFile = '/ADF/pt_social_media/style/socialmedia.css';
application.ptSocialMedia.scripts.loadUnregisteredResource(URL=smBaseCssFile,resourceType='StyleSheet',location='head',resourceGroup='tertiary',canCombine=0,canMinify=0);
// If exists, load CSS override file
smOverrideCssFile = '/_cs_apps/pt_social_media/style/socialmedia.css';
If ( FileExists(ExpandPath(smOverrideCssFile)) )
application.ptSocialMedia.scripts.loadUnregisteredResource(URL=smOverrideCssFile,resourceType='StyleSheet',location='head',resourceGroup='tertiary',canCombine=0,canMinify=0);
request.loadSocialMediaCssStyles = 1;
}
// Get the state of the App Level Feed Cache
useFeedCache = application.ptSocialMedia.getFeedCacheState();
// Check for CS Author Mode
csMode = "";
if ( StructKeyExists(request,"renderstate") AND StructKeyExists(request.renderstate,"rendermode") )
csMode = request.renderstate.rendermode;
// Check status of socialMediaDebugToolsMode variable
if ( !StructKeyExists(request,"ptSocialMedia") )
request.ptSocialMedia = StructNew();
if ( !StructKeyExists(request.ptSocialMedia,"socialMediaDebugToolsMode") )
request.ptSocialMedia.socialMediaDebugToolsMode = false;
/*
// --- cacheValidUntil Sample code block--
// Cache for a set amount of time then refresh the cache
// - Set the number of minutes to cache
minsToCache = 5;
// - Set the rebuild Date/Time using the minutes to cache from above
rebuildDate = dateAdd("n", minsToCache, now());
// - Tell the element to cache until the rebuild date
request.element.cacheValidUntil = Mid(CreateODBCDateTime(rebuildDate),6,19);
// - Make sure that the element is static
request.element.isStatic = 1;
// --- if using cacheValidUntil comment out the 'isStatic = 0' line below
*/
request.element.isStatic = 0;
// Set the Default for the Show Error flag
showError = true;
showModerateTools = false;
showSocialMediaToolsBtn = false;
socialMediaToolsBtnShowText = "Show Moderation Bars";
socialMediaToolsBtnHideText = "Hide Moderation Bars";
showElementDump = false;
showDataDump = false;
showFeedDump = false;
showSourceDataDump = false;
useCacheOverride = false; // Set to True to not use the FeedCache
noRenderHTML = false;
showTestPost = false;
// If debug tools are available allow url variables to control debug output
if ( request.ptSocialMedia.socialMediaDebugToolsMode )
{
request.element.isStatic = 0; // for debug mode make sure element is not Cached by CS
if ( StructKeyExists(request.params,"showElement") AND IsBoolean(request.params.showElement) )
showElementDump = request.params.showElement;
if ( StructKeyExists(request.params,"showData") AND IsBoolean(request.params.showData) )
showDataDump = request.params.showData;
if ( StructKeyExists(request.params,"showFeed") AND IsBoolean(request.params.showFeed) )
showFeedDump = request.params.showFeed;
if ( StructKeyExists(request.params,"showSourceData") AND IsBoolean(request.params.showSourceData) )
showSourceDataDump = request.params.showSourceData;
if ( StructKeyExists(request.params,"disableFeedCache") AND IsBoolean(request.params.disableFeedCache) )
useCacheOverride = request.params.disableFeedCache;
if ( StructKeyExists(request.params,"noHTML") AND IsBoolean(request.params.noHTML) )
noRenderHTML = request.params.noHTML;
if ( StructKeyExists(request.params,"showTestPost") AND IsBoolean(request.params.showTestPost) )
showTestPost = request.params.showTestPost;
}
// Set variables 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;
currService = "";
//Set Ajax Proxy Path
AjaxPath = application.ADF.ajaxProxy;
//Set the Controller Bean and the Filter Method
ControllerBean = "feedController";
filterMethod = "removePost";
filterVerb = "remove";
if (filterType EQ "excluded") {
filterMethod = "displayPost";
filterVerb = "display";
}
//application.ptSocialMedia.scripts.setDebugMode(debugMode=true);
// Get the data items in the RH
selectedFeeds = attributes.elementInfo.elementData.propertyValues;
//writeDump(var=selectedFeeds[1],label="selectedFeeds");
// 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 AND StructKeyExists(selectedFeedStruct,"values") )
application.ptSocialMedia.utils.doDump(selectedFeedStruct.values,"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;
// 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";
// 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";
// Disable Cache when NOT in READ mode
if ( ListFindNoCase("author,edit",csMode) )
useCacheOverride = true;
// Get Feed Data from the selected Feeds and combine it into one feed
items = application.ptSocialMedia.feedController.buildCombinedFeedItems(
selectedFeeds=selectedFeedStruct
,sortOrder="desc"
,sortField="PublishedDate"
,addTestData=showTestPost
,showFeedDump=showFeedDump
,useCacheOverride=useCacheOverride
);
/*
// DEBUG DUMPS
writeDump(var=selectedFeeds,label="selectedFeeds",expand="no");
writeoutput("showtestpost: #showtestpost# ");
writeoutput("showfeeddump: #showfeeddump# ");
writeoutput("useCacheOverride: #useCacheOverride# ");
*/
// TODO: Add admin/contributor rights check around this DUMP
if ( showDataDump )
application.ptSocialMedia.utils.doDump(items,"items",0);
// Set the Max Number of Result to display
if ( ArrayLen(items) LT maxRenderLimit )
maxRenderLimit = ArrayLen(items);
// Get Feed Source 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.ptSocialMedia.scripts.addFooterJS(socialMediaStreamJS,"tertiary");