// Get the values from the Configuration Element
appConfigStruct = application.ptSocialMedia.getAppConfig();
// initialize the uitheme to a known good value
uiTheme = 'redmond';
// Set the UI theme from the Configuration Element
if ( structKeyExists(appConfigStruct,"ui_theme") AND LEN(TRIM(appConfigStruct['ui_theme'])) )
uiTheme = appConfigStruct['ui_theme'];
// Load the JQuery Plugin Headers
application.ptSocialMedia.scripts.loadjQuery();
// load header for jQuery UI
application.ptSocialMedia.scripts.loadJQueryUI(themeName=uiTheme);
// 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();
// 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;
noRenderHTML = false;
showTestPost = false;
CSRF_Token = application.ADF.csSecurity.getCSRF_Token();
// 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 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;
}
// Made it past the initial data check ... turn off the error
showError = false;
outputHTML = true;
//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 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";
// 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
,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);
}
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");