nxs_snapClassFB

The NextScripts: Social Networks Auto-Poster nxs snapClassFB class.

Defined (1)

The class is defined in the following location(s).

/inc-cl/fb.php  
  1. if (!class_exists("nxs_snapClassFB")) { class nxs_snapClassFB { 
  2. //#### Show Common Settings  
  3. function showGenNTSettings($ntOpts) { global $nxs_snapSetPgURL, $nxs_plurl, $nxs_gOptions; $ntInfo = array('code'=>'FB', 'lcode'=>'fb', 'name'=>'Facebook', 'defNName'=>'dlUName', 'tstReq' => true); 
  4. if ( isset($_GET['code']) && $_GET['code']!='' && isset($_GET['state']) && substr($_GET['state'], 0, 7) == 'nxs-fb-') { $at = $_GET['code']; $ii = str_replace('nxs-fb-', '', $_GET['state']); 
  5. echo '-= This is normal technical authorization info that will dissapear. (Unless you get some errors. If you do get errors please check them at the <a target="_blank" href="http://www.nextscripts.com/support-faq/">FAQ Page</a>) =- <br/><br/><br/>'; $gGet = array();  
  6. if (!empty($_SERVER['QUERY_STRING'])) parse_str($_SERVER['QUERY_STRING'], $gGet); elseif (!empty($_SERVER['argv'][0])) parse_str($_SERVER['argv'][0], $gGet);  
  7. else { $gGet = $_GET; prr($_GET); unset($gGet['post_type']);} prr($gGet); unset($gGet['code']); unset($gGet['state']); prr($gGet); 
  8. $sturl = explode('?', $nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):''); $fbo = $ntOpts[$ii]; $wprg = array('sslverify'=>false, 'timeout' => 30);  
  9. if (isset($fbo['fbPgID'])) { echo "-="; prr($fbo);// die(); 
  10. $tknURL = 'https://graph.facebook.com/v2.3/oauth/access_token?client_id='.$fbo['fbAppID'].'&state=nxs-fb-'.$ii.'&redirect_uri='.urlencode($nxs_snapSetPgURL).'&client_secret='.$fbo['fbAppSec'].'&code='.$at;  
  11. $response = wp_remote_get($tknURL, $wprg); echo "<br/>TKN URL: "; prr($tknURL);  
  12. if ( (is_object($response) && (isset($response->errors))) || (is_array($response) && stripos($response['body'], '"error":')!==false )) { prr($response); die(); }  
  13. if (substr($response['body'], 0, 1)=='{') $params = json_decode($response['body'], true); else parse_str($response['body'], $params);  
  14. $at = $params['access_token']; echo "<br/>TKN PARAMS: "; prr($params); echo "<br/>TKN RESP: "; prr($response);  
  15. $response = wp_remote_get('https://graph.facebook.com/v2.3/oauth/access_token?client_secret='.$fbo['fbAppSec'].'&client_id='.$fbo['fbAppID'].'&grant_type=fb_exchange_token&fb_exchange_token='.$at, $wprg);  
  16. if ((is_object($response) && isset($response->errors))) { prr($response); die();} 
  17. if (substr($response['body'], 0, 1)=='{') $params = json_decode($response['body'], true); else parse_str($response['body'], $params); $at = $params['access_token']; $fbo['fbAppAuthToken'] = $at;  
  18. $appsecret_proof = hash_hmac('sha256', $fbo['fbAppAuthToken'], $fbo['fbAppSec']);  
  19. $aacct = array('access_token'=>$fbo['fbAppAuthToken'], 'appsecret_proof'=>$appsecret_proof, 'method'=>'get');  
  20. $uurl = "https://graph.facebook.com/v2.3/me?".http_build_query($aacct, null, '&'); prr($uurl); $res = wp_remote_get( $uurl, $wprg);  
  21. if (is_wp_error($res) || empty($res['body'])) { echo "Can't get Facebook User."; prr($res); die();} else { 
  22. $user = json_decode($res['body'], true); if (empty($user)) {echo "Can't get Facebook User. JSON Error. "; prr($res); die();} else { 
  23. if (!empty($user['id'])) { echo "-= Got user: "; prr($user);  
  24. if (stripos($fbo['fbURL'], '/groups/')!==false) { $fbo['destType'] = 'gr'; $fbo['fbAppPageAuthToken'] = $fbo['fbAppAuthToken']; } else {  
  25. $page_id = $fbo['fbPgID']; echo "-= Authorizing Page =-<br/>";  
  26. $aacct = array('access_token'=>$fbo['fbAppAuthToken'], 'appsecret_proof'=>$appsecret_proof, 'method'=>'get'); $fbo['destType'] = '';  
  27. echo "-= Getting List of Pages =-<br/>";  
  28. $resP = wp_remote_get('https://graph.facebook.com/v2.3/'.$user['id'].'/accounts?'.http_build_query($aacct, null, '&'), $wprg); prr($resP); $pages = json_decode($resP['body'], true); prr($pages); 
  29. echo "-= Getting Page Token =-<br/>";  
  30. echo "https://graph.facebook.com/v2.3/$page_id?fields=access_token&".http_build_query($aacct, null, '&'); 
  31. $res = wp_remote_get( "https://graph.facebook.com/v2.3/$page_id?fields=access_token&".http_build_query($aacct, null, '&'), $wprg); prr($res); 
  32. if (is_wp_error($res) || empty($res['body'])) { echo "Can't get Page Token."; prr($res); die();} else { 
  33. $token = json_decode($res['body'], true); if (empty($token)) {echo "Can't get Page Token. JSON Error. "; prr($res); die();} else { 
  34. if (!empty($token['error'])) if (!empty($token['error']['message'])) { $errMsg = $token['error']['message']; 
  35. if ( stripos($errMsg, 'Unknown fields: access_token')!==false || stripos($errMsg, 'Cannot query users by their username')!==false || stripos($errMsg, 'node type (User)')!==false) { 
  36. $token['access_token'] = $fbo['fbAppAuthToken']; $fbo['destType'] = (stripos($fbo['fbURL'], '/groups/')!=false)?'gr':'pr'; } else {  
  37. if (stripos($errMsg, 'Unsupported get request')!==false) echo "<b style='color:red;'>Error </b>: Your Facebook URL ( <i>".$fbo['fbURL']."</i> ) is either incorrect or authorzing user don't have rights to post there.<br/>"; 
  38. echo '<br/>Reported Error: ', $errMsg, "\n"; die();  
  39. }  
  40. }  
  41. if (!empty($token['access_token'])) { $fbo['fbAppPageAuthToken'] = $token['access_token']; } else { echo "Can't get Page Token. NO TOKEN RETURNED. Are you sure that user you are trying to authorize is an admin of the page? This message means user was authorized as profile, but page refused to return authorization token. This usually happens when user has <b>no rights</b> to post to that page. "; prr($res); die(); } 
  42. }  
  43. } else {echo "Can't get User. NO USER RETURNED. "; prr($res); die();} 
  44.  
  45. if (!empty($user['id'])) { $fbo['fbAppAuthUser'] = $user['id']; $fbo['fbAppAuthUserName'] = $user['name'].(!empty($user['username'])?" (".$user['username'].")":'');  
  46. if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['fb'][$ii] = $fbo; nxs_settings_save($nxs_gOptions); } 
  47. ?><script type="text/javascript">window.location = "<?php echo $nxs_snapSetPgURL; ?>"</script>  
  48. <?php } die(); } 
  49. }  
  50. $ntParams = array('ntInfo'=>$ntInfo, 'nxs_plurl'=>$nxs_plurl, 'ntOpts'=>$ntOpts, 'chkField'=>'fbAppAuthUser'); nxs_showListRow($ntParams);  
  51. }  
  52. //#### Show NEW Settings Page 
  53. function showNewNTSettings($mfbo) { $fbo = array('nName'=>'', 'doFB'=>'1', 'fbURL'=>'', 'atpKey'=>'', 'uName'=>'', 'uPass'=>'', 'fbAppID'=>'', 'imgUpl'=>'1', 'postType'=>'A', 'fbMsgAFormat'=>'', 'fbAppSec'=>'', 'fbAttch'=>'2', 'fbPgID'=>'', 'fbAppAuthUser'=>'', 'fbMsgFormat'=>__('New post (%TITLE%) has been published on %SITENAME%', 'social-networks-auto-poster-facebook-twitter-g') ); $fbo['ntInfo']= array('lcode'=>'fb'); $this->showNTSettings($mfbo, $fbo, true);} 
  54. //#### Show Unit Settings 
  55. function showNTSettings($ii, $options, $isNew=false) { global $nxs_plurl, $nxs_snapSetPgURL, $plgn_NS_SNAutoPoster; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt); $tmzFrmt = _x('Y-m-d G:i:s', 'timezone date format');  
  56. if (empty($options['postType']) && !empty($options['fbPostType'])) { $options['postType'] = $options['fbPostType']; unset($options['fbPostType']); } //## Compatibility with V <3.2 
  57. if (empty($options['postType']) && !empty($options['PostType'])) { $pt = $options['PostType']; unset($options['PostType']); $options['postType'] = $pt; } //## Compatibility with V <3.2 
  58. if ((int)$options['fbAttch']==0 && empty($options['postType'])) $options['postType'] = 'T';  
  59. if (!isset($plgn_NS_SNAutoPoster)) $gOptions = array(); else $gOptions = $plgn_NS_SNAutoPoster->nxs_options;  
  60. if (!isset($options['nHrs'])) $options['nHrs'] = 0; if (!isset($options['nMin'])) $options['nMin'] = 0; if (!isset($options['catSel'])) $options['catSel'] = 0; if (!isset($options['catSelEd'])) $options['catSelEd'] = '';  
  61. if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['msgDAFrmt'])) $options['msgDAFrmt'] = '';  
  62. if (!isset($options['msgTAFrmt'])) $options['msgTAFrmt'] = ''; if (!isset($options['riComments'])) $options['riComments'] = ''; if (!isset($options['riCommentsAA'])) $options['riCommentsAA'] = '';  
  63.  
  64. ?>  
  65. <div id="doFB<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSFB<?php echo $ii; ?>" value="0" id="apDoSFB<?php echo $ii; ?>" />  
  66. <?php if ($isNew) { ?> <input type="hidden" name="fb[<?php echo $ii; ?>][apDoFB]" value="1" id="apDoNewFB<?php echo $ii; ?>" /> <?php } ?> 
  67.  
  68. <div class="nsx_iconedTitle" style="float: right; max-width: 342px; text-align: right; background-image: url(<?php echo $nxs_plurl; ?>img/fb16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/instructions/facebook-social-networks-auto-poster-setup-installation"><?php $nType="Facebook"; printf( __( 'Detailed %s Installation/Configuration Instructions', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a><br/> 
  69. <span style="font-size: 10px;"><?php _e('Please use in your Facebook App:', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/> URL: <em style="font-size: 10px; color:#CB4B16;"><?php echo !empty($_SERVER["REQUEST_SCHEME"])?$_SERVER["REQUEST_SCHEME"]:'http'; ?>://<?php echo $_SERVER["SERVER_NAME"] ?></em> <br/>Domain: <em style="font-size: 10px; color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"] ?></em> </span> 
  70.  
  71. </div> 
  72.  
  73. <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="fb[<?php echo $ii; ?>][nName]" id="fbnName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/> 
  74. <?php echo nxs_addQTranslSel('fb', $ii, $options['qTLng']); ?> 
  75.  
  76.  
  77. <ul class="nsx_tabs"> 
  78. <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>  
  79. <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?>  
  80.  
  81. </ul> 
  82. <div class="nsx_tab_container"><?php /** ######################## Account Tab ####################### */ ?> 
  83. <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;"> 
  84.  
  85. <div style="width:100%;"><strong>Facebook URL:</strong> </div> 
  86. <p style="font-size: 11px; margin: 0px;"><?php _e('Could be your Facebook Profile, Facebook Page, Facebook Group', 'social-networks-auto-poster-facebook-twitter-g'); ?></p> 
  87. <input name="fb[<?php echo $ii; ?>][apFBURL]" id="apFBURL" style="width: 50%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['fbURL'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />  
  88. <br/><br/> <?php /**  
  89. <?php if ($isNew) { ?><b>Choose How to connect to Facebook:</b> <- <a target="_blank" href="http://www.nextscripts.com/connect-facebook/">What is it?</a> <br/>  
  90.  
  91. <select onchange="nxs_showHideBlock('fbChooseSRVB'+this.value, 'fbChooseSRVC');" id="fbChooseSRV<?php echo $ii; ?>"><option value="0">Your own app</option><option value="1">Autopost.to Service</option><option value="2">Username/password (Pro Only)</option></select> <br/> <br/>  
  92.  
  93. <?php } */ ?> 
  94. <div id="fbChooseSRVB0" class="fbChooseSRVC" style="padding-left:15px; display: <?php if ($isNew || !empty($options['fbAppID'])) echo 'block'; else echo 'none'; ?>;">  
  95. <div style="width:100%;"><strong>Facebook App ID:</strong> </div><input name="fb[<?php echo $ii; ?>][apFBAppID]" id="apFBAppID" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['fbAppID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />  
  96. <div style="width:100%;"><strong>Facebook App Secret:</strong> </div><input name="fb[<?php echo $ii; ?>][apFBAppSec]" id="apFBAppSec" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['fbAppSec'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  97. </div>  
  98. <br/><br/> 
  99. <div id="altFormat"> 
  100. <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="apFBMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</div> 
  101.  
  102. <textarea cols="150" rows="3" id="fb<?php echo $ii; ?>SNAPformat" name="fb[<?php echo $ii; ?>][apFBMsgFrmt]" style="width:51%;max-width: 610px;" onfocus="jQuery('#fb<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apFBMsgFrmt<?php echo $ii; ?>');"><?php _e(apply_filters('format_to_edit', htmlentities($options['fbMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?></textarea> <?php nxs_doShowHint("apFBMsgFrmt".$ii); ?>  
  103. <br/> 
  104. </div><br/> 
  105. <div style="width:100%;"><strong style="font-size: 16px;" id="altFormatText">Post Type:</strong><-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>X');" onmouseover="showPopShAtt('<?php echo $ii; ?>X', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) </div>  
  106. <div style="margin-left: 10px;"> 
  107.  
  108. <input type="radio" name="fb[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> onchange="if (jQuery(this).is(':checked')) jQuery('.nxsDivFBPostTypeOpts<?php echo $ii; ?>').hide();"/> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>  
  109.  
  110. <input type="radio" name="fb[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('.nxsDivFBPostTypeOpts<?php echo $ii; ?>').hide(); jQuery('#nxsDivFBImgUplOpts<?php echo $ii; ?>').show();}"/> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/> 
  111. <div style="width:100%; margin-left: 15px;<?php if (empty($options['postType']) || $options['postType'] != 'I') echo "display:none;"; ?>" id="nxsDivFBImgUplOpts<?php echo $ii; ?>" class="nxsDivFBPostTypeOpts<?php echo $ii; ?>" ><strong><?php _e('Upload Images to', 'social-networks-auto-poster-facebook-twitter-g'); ?>: </strong>  
  112. <input value="2" id="apFBImgUplAPP<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBImgUpl]" <?php if ((int)$options['imgUpl'] == 2) echo "checked"; ?> /> <?php _e('App Album', 'social-networks-auto-poster-facebook-twitter-g'); ?>  
  113. <input value="1" id="apFBImgUplTML<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBImgUpl]" <?php if ((int)$options['imgUpl'] != 2) echo "checked"; ?> />  
  114. <?php _e('Timeline', 'social-networks-auto-poster-facebook-twitter-g'); ?> <-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>I');" onmouseover="showPopShAtt('<?php echo $ii; ?>I', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)  
  115. </div>  
  116.  
  117. <input type="radio" name="fb[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('.nxsDivFBPostTypeOpts<?php echo $ii; ?>').hide(); jQuery('#nxsDivFBAttchLinkOpts<?php echo $ii; ?>').show();}" /> <?php _e('Text Post with "attached" link', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/> 
  118.  
  119. <div id="nxsDivFBAttchLinkOpts<?php echo $ii; ?>" class="nxsDivFBPostTypeOpts<?php echo $ii; ?>" style="width:100%; margin-left: 15px; line-height: 22px;<?php if (!empty($options['postType']) && $options['postType'] != 'A') echo "display:none;"; ?>"> 
  120. <?php //prr($options); 
  121. if (empty($options['atchUse'])) $options['atchUse'] = 'F';  
  122. if (!empty($options['useFBGURLInfo']) && $options['useFBGURLInfo']=='1') $options['atchUse'] = 'F';  
  123. if (isset($options['useFBGURLInfo']) && $options['useFBGURLInfo']=='0') $options['atchUse'] = 'A';  
  124. if (!empty($options['fbMsgAFrmt']) && empty($options['msgDAFrmt'])) { $options['msgDAFrmt'] = $options['fbMsgAFrmt']; $options['msgTAFrmt'] = '%TITLE%'; } 
  125. if (!empty($options['fbMsgAFrmt'])) $options['atchUse'] = 'M';  
  126. if (isset($options['fbAttchAsVid']) && $options['fbAttchAsVid'] == '1') $options['fbAttchAsVid'] = 'A';  
  127. if (empty($options['fbAttchAsVid'])) $options['fbAttchAsVid'] = 'N';  
  128.  
  129. ?> 
  130. <strong><?php _e('Link attachment type', 'social-networks-auto-poster-facebook-twitter-g'); ?>: </strong> <input value="2" id="apFBAttchShare<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBAttch]" <?php if ((int)$options['fbAttch'] == 2) echo "checked"; ?> /><?php _e('Share a link to your blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?>    
  131. <input value="1" id="apFBAttch<?php echo $ii; ?>" type="radio" name="fb[<?php echo $ii; ?>][apFBAttch]" <?php if ((int)$options['fbAttch'] == 1) echo "checked"; ?> />  
  132. <?php _e('Attach your blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?>   
  133. <-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>');" onmouseover="showPopShAtt('<?php echo $ii; ?>', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) 
  134. <br/> 
  135. <strong><?php _e('What should fill attachment info:', 'social-networks-auto-poster-facebook-twitter-g'); ?> </strong>  
  136. <input value="F" type="radio" name="fb[<?php echo $ii; ?>][atchUse]" <?php if ($options['atchUse'] == 'F') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apFBMsgAFrmtDiv<?php echo $ii; ?>').hide(); jQuery('#nxsRBVidThumb<?php echo $ii; ?>').prop('disabled', true); }"/><?php _e('Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?>    
  137. <input value="A" type="radio" name="fb[<?php echo $ii; ?>][atchUse]" <?php if ($options['atchUse'] == 'A') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apFBMsgAFrmtDiv<?php echo $ii; ?>').hide(); jQuery('#nxsRBVidThumb<?php echo $ii; ?>').prop('disabled', false);}"/><?php _e('Plugin/API', 'social-networks-auto-poster-facebook-twitter-g'); ?>    
  138. <input value="M" type="radio" name="fb[<?php echo $ii; ?>][atchUse]" <?php if ($options['atchUse'] == 'M') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apFBMsgAFrmtDiv<?php echo $ii; ?>').show(); jQuery('#nxsRBVidThumb<?php echo $ii; ?>').prop('disabled', false);}"/><?php _e('Set your own', 'social-networks-auto-poster-facebook-twitter-g'); ?>   
  139. <-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>Fill');" onmouseover="showPopShAtt('<?php echo $ii; ?>Fill', event);" onclick="return false;" class="underdash" href="#"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)<br/> 
  140.  
  141. <div id="apFBMsgAFrmtDiv<?php echo $ii; ?>" style="<?php if ($options['atchUse'] != 'M') echo "display:none;"; ?>" > 
  142.     <?php _e('Attachment Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:<input name="fb[<?php echo $ii; ?>][msgTAFrmt]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['msgTAFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/> 
  143.     <?php _e('Attachment Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:<input name="fb[<?php echo $ii; ?>][msgDAFrmt]" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['msgDAFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  144. </div>  
  145.  
  146. <strong><?php _e('If post has a video:', 'social-networks-auto-poster-facebook-twitter-g'); ?> </strong>  
  147. <input value="N" type="radio" name="fb[<?php echo $ii; ?>][fbAttchAsVid]" <?php if ($options['fbAttchAsVid'] == 'N') echo 'checked="checked"'; ?> /><?php _e('Do nothing', 'social-networks-auto-poster-facebook-twitter-g'); ?>    
  148. <input value="A" id="nxsRBVidThumb<?php echo $ii; ?>" <?php if ($options['atchUse'] == 'F') echo "disabled"; ?> type="radio" name="fb[<?php echo $ii; ?>][fbAttchAsVid]" <?php if ($options['fbAttchAsVid'] == 'A') echo 'checked="checked"'; ?> /><?php _e('Use as thumbnail', 'social-networks-auto-poster-facebook-twitter-g'); ?>    
  149. <input value="V" type="radio" name="fb[<?php echo $ii; ?>][fbAttchAsVid]" <?php if ($options['fbAttchAsVid'] == 'V') echo 'checked="checked"'; ?> />  
  150. <?php _e('Attach Video(!)', 'social-networks-auto-poster-facebook-twitter-g'); ?>   
  151. <-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>Video');" onmouseover="showPopShAtt('<?php echo $ii; ?>Video', event);" onclick="return false;" class="underdash" href="#"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) 
  152. <br/>  
  153.  
  154.  
  155. </div><br/></div> 
  156.  
  157. <div class="popShAtt" style="z-index: 9999; width: 350px;" id="popShAtt<?php echo $ii; ?>I"><h3><?php _e('Where to upload Images', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3> <b><?php _e('(App Album)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Facebook automatically creates an album for your app. Images will be grouped there as in any regular album.', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/><br/><b><?php _e('(Timeline)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Images will be posted to the special "Wall/Timeline" album and won\'t be grouped. "Wall/Timeline" album must exist. It\'s created when first image posted to timeline manually.', 'social-networks-auto-poster-facebook-twitter-g'); ?></div>  
  158. <div class="popShAtt" style="z-index: 9999" id="popShAtt<?php echo $ii; ?>"><h3><?php _e('Two ways of attaching post on Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fb2wops.png" width="600" height="257" alt="<?php _e('Two ways of attaching post on Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div> 
  159. <div class="popShAtt" style="z-index: 9999" id="popShAtt<?php echo $ii; ?>X"><h3><?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="<?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div> 
  160.  
  161. <div class="popShAtt" style="z-index: 9999; width: 350px;" id="popShAtt<?php echo $ii; ?>Fill"><h3><?php _e('What should fill attachment info', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3> <b><?php _e('(Facebook)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Recommended. Facebook will automatically take attached/shared link info from OG: tags or other sources.', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/><br/><b><?php _e('(Pluign/API)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Plugin will generate attachment title and description using info from SEO Plugins, then post excerpt, then post text and title.', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/><br/><b><?php _e('(Set your own)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Set the format by yourself using message formatting tags', 'social-networks-auto-poster-facebook-twitter-g'); ?></div>  
  162. <div class="popShAtt" style="z-index: 9999; width: 350px;" id="popShAtt<?php echo $ii; ?>Video"><h3><?php _e('If post has a video', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3> <b><?php _e('(Do Nothing)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Plugin is not going to do anything specific about video', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/><br/><b><?php _e('(Use as thumbnail)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Video thumbnail will be used as attachment image. Please note - <b>it won\'t be playable.</b> This option is not compatible with "What should fill attachment info: Facebook"', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/><br/><b><?php _e('(Attach video page to the Facebook post)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('If you choose this, YouTube or Vimeo page will be attached to the Facebook post as <b>playable thumbnail</b>. Please note! <b>There will be no link to your site.</b> Please use %URL% in the message format if you need a backlink', 'social-networks-auto-poster-facebook-twitter-g'); ?></div>  
  163.  
  164.  
  165.  
  166.  
  167. <?php if ($options['fbPgID']!='') {?><div style="width:100%;"><strong>Facebook Page ID:</strong> <?php if (!empty($options['destType']) && $options['destType'] == 'pr') _e('Profile', 'social-networks-auto-poster-facebook-twitter-g');  
  168. if (!empty($options['destType']) && $options['destType'] == 'gr') _e('Group', 'social-networks-auto-poster-facebook-twitter-g');  
  169. if (empty($options['destType']) || (!empty($options['destType']) && $options['destType'] == 'pg')) _e('Page', 'social-networks-auto-poster-facebook-twitter-g'); ?> -  
  170. <?php _e(apply_filters('format_to_edit', htmlentities($options['fbPgID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?> 
  171. </div><?php } ?> 
  172. <?php  
  173. if (!empty($options['fbAppID'])) { 
  174. if($options['fbAppSec']=='') { ?> 
  175. <b><?php _e('Authorize Your Facebook Account', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php _e('Please click "Update Settings" to be able to Authorize your account.', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  176. <?php } else { if(isset($options['fbAppAuthUser']) && $options['fbAppAuthUser']>0) { ?> 
  177. <?php _e('Your Facebook Account has been authorized.', 'social-networks-auto-poster-facebook-twitter-g'); ?> User ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['fbAppAuthUser'].(!empty($options['fbAppAuthUserName'])?" - ".$options['fbAppAuthUserName']:''), ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>. 
  178. <br/><?php _e('You can', 'social-networks-auto-poster-facebook-twitter-g'); ?> Re- <?php } ?>  
  179. <a href="https://www.facebook.com/dialog/oauth?client_id=<?php echo trim($options['fbAppID']);?>&scope=publish_actions, manage_pages, publish_pages, user_managed_groups, user_posts, user_photos&state=<?php echo 'nxs-fb-'.$ii; ?>&redirect_uri=<?php echo trim(urlencode($nxs_snapSetPgURL));?>">Authorize Your Facebook Account</a>  
  180. <?php if (!isset($options['fbAppAuthUser']) || $options['fbAppAuthUser']<1) { ?> <div class="blnkg"><=== <?php _e('Authorize your account', 'social-networks-auto-poster-facebook-twitter-g'); ?> ===</div>  
  181. <br/><br/><i> <?php _e('If you get Facebook message:', 'social-networks-auto-poster-facebook-twitter-g'); ?> <b>"Error. An error occurred. Please try again later."</b> or <b>"Error 191"</b> <?php _e('please make sure that domain name in your Facebook App matches your website domain exactly. Please note that www. and non www. versions are different domains.', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> <?php }?> 
  182. <?php } } ?> 
  183.  
  184. <?php if((isset($options['fbAppAuthUser']) && $options['fbAppAuthUser']>0) || !empty($options['atpKey']) || !empty($options['uName']) ) { ?> 
  185.  
  186. <br/><br/><b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>    <a href="#" class="NXSButton" onclick="testPost('FB', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a>  
  187. <?php }?> 
  188.  
  189. </div> 
  190. <?php /** ######################## Tools Tab ####################### */ ?> 
  191. <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content"> 
  192.  
  193. <?php nxs_showCatTagsCTFilters($nt, $ii, $options);  
  194. nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']); ?>  
  195.  
  196. <div style="width:100%;"><strong style="font-size: 16px;"><?php _e('Facebook Comments:', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> </div> 
  197. <div style="margin-bottom: 5px; margin-left: 10px; "> 
  198. <p style="font-size: 11px; margin: 0px;"><?php _e('Plugin could grab comments from Facebook and import them as Wordpress Comments', 'social-networks-auto-poster-facebook-twitter-g'); ?></p> 
  199.  
  200. <?php if ( !empty($gOptions['riActive']) && $gOptions['riActive'] == '1' ) { ?> 
  201. <input value="1" id="apFBMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($options['riComments'])=='1') echo "checked"; ?> type="checkbox" name="fb[<?php echo $ii; ?>][riComments]"/> <strong><?php _e('Import Facebook Comments', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> 
  202. <br/> 
  203. <div style="margin-bottom: 5px; margin-left: 10px; "> 
  204. <input value="1" id="apFBMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($options['riCommentsAA'])=='1') echo "checked"; ?> type="checkbox" name="fb[<?php echo $ii; ?>][riCommentsAA]"/> <strong><?php _e('Auto-approve imported comments', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong></div> 
  205.  
  206. <?php } else { echo "<br/>"; _e('Please activate the "Comments Import" from SNAP Settings Tab', 'social-networks-auto-poster-facebook-twitter-g'); } ?> 
  207.  
  208. </div> 
  209.  
  210. <?php nxs_showRepostSettings($nt, $ii, $options); ?>  
  211.  
  212.  
  213. </div> <?php } ?> <?php /** #### End of Tab #### */ ?> 
  214. </div><br/> <?php /** #### End of Tabs #### */ ?> 
  215.  
  216. <div class="submitX nxclear" style="padding-bottom: 0px;">  
  217. <input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  218. <?php /** ?> 
  219. <input type="button" id="svBtn<?php echo $nt.$ii ?>" onclick="nxs_svSet('<?php echo $nt; ?>', '<?php echo $ii; ?>')" class="button-primary" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  220. <div id="nxsSaveLoadingImg<?php echo $nt.$ii; ?>" class="doneMsg">Saving.....</div> <div id="doneMsg<?php echo $nt.$ii; ?>" class="doneMsg">Done</div> 
  221. <?php */ ?> 
  222. </div> 
  223.  
  224. </div>  
  225. <?php 
  226.  
  227. //#### Set Unit Settings from POST 
  228. function setNTSettings($post, $options) { $code = 'FB'; $lcode = 'fb'; 
  229. foreach ($post as $ii => $pval) {  
  230. if (!empty($pval['apFBAppID']) || !empty($pval['atpKey']) || !empty($pval['uName'])) { if (!isset($options[$ii])) $options[$ii] = array(); 
  231.  
  232. if (isset($pval['atpKey'])) $options[$ii]['atpKey'] = trim($pval['atpKey']); 
  233. if (isset($pval['uName'])) $options[$ii]['uName'] = trim($pval['uName']); 
  234. if (isset($pval['uPass'])) $options[$ii]['uPass'] = trim($pval['uPass']);  
  235.  
  236. if (isset($pval['apDoFB'])) $options[$ii]['doFB'] = $pval['apDoFB']; else $options[$ii]['doFB'] = 0; 
  237. if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']); 
  238. if (isset($pval['apFBAppID'])) $options[$ii]['fbAppID'] = trim($pval['apFBAppID']);  
  239. if (isset($pval['apFBAppSec'])) $options[$ii]['fbAppSec'] = trim($pval['apFBAppSec']);  
  240.  
  241. if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0; 
  242. if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = ''; 
  243.  
  244. if (isset($pval['postType'])) $options[$ii]['postType'] = trim($pval['postType']); 
  245. if (isset($pval['apFBAttch'])) $options[$ii]['fbAttch'] = $pval['apFBAttch']; else $options[$ii]['fbAttch'] = 0; 
  246. if (isset($pval['fbAttchAsVid'])) $options[$ii]['fbAttchAsVid'] = $pval['fbAttchAsVid']; else $options[$ii]['fbAttchAsVid'] = 0; 
  247. if (isset($pval['atchUse'])) $options[$ii]['atchUse'] = trim($pval['atchUse']); 
  248.  
  249. if ($options[$ii]['atchUse']=='F' && $options[$ii]['fbAttchAsVid'] = 'A') $options[$ii]['fbAttchAsVid'] = 'N'; 
  250.  
  251. if (isset($pval['apFBImgUpl'])) $options[$ii]['imgUpl'] = $pval['apFBImgUpl']; else $options[$ii]['imgUpl'] = 0; 
  252.  
  253. if (isset($pval['apFBMsgFrmt'])) $options[$ii]['fbMsgFormat'] = trim($pval['apFBMsgFrmt']);  
  254.  
  255.  
  256. if (isset($pval['msgTAFrmt'])) $options[$ii]['msgTAFrmt'] = trim($pval['msgTAFrmt']);  
  257. if (isset($pval['msgDAFrmt'])) $options[$ii]['msgDAFrmt'] = trim($pval['msgDAFrmt']);  
  258.  
  259. if (isset($options[$ii]['useFBGURLInfo'])) unset($options[$ii]['useFBGURLInfo']); 
  260. if (isset($options[$ii]['fbMsgAFrmt'])) unset($options[$ii]['fbMsgAFrmt']); 
  261.  
  262. if (isset($pval['riComments'])) $options[$ii]['riComments'] = $pval['riComments']; else $options[$ii]['riComments'] = 0; 
  263. if (isset($pval['riCommentsAA'])) $options[$ii]['riCommentsAA'] = $pval['riCommentsAA']; else $options[$ii]['riCommentsAA'] = 0; 
  264.  
  265. $options[$ii] = nxs_adjRpst($options[$ii], $pval);  
  266.  
  267. if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']); 
  268. if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);  
  269.  
  270. if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);  
  271.  
  272. if (isset($pval['apFBURL'])) { $options[$ii]['fbURL'] = trim($pval['apFBURL']); if ( substr($options[$ii]['fbURL'], 0, 4)!='http' ) $options[$ii]['fbURL'] = 'http://'.$options[$ii]['fbURL']; 
  273. $fbPgID = $options[$ii]['fbURL']; if (substr($fbPgID, -1)=='/') $fbPgID = substr($fbPgID, 0, -1); $fbPgID = substr(strrchr($fbPgID, "/"), 1);  
  274. if (strpos($fbPgID, '?')!==false) $fbPgID = substr($fbPgID, 0, strpos($fbPgID, '?'));  
  275. if (strpos($fbPgID, '-')!==false) { $possID = substr(strrchr($fbPgID, "-"), 1); $fbPgID = (strlen($possID)>10 && is_numeric($possID))?$possID:$fbPgID; } //prr($fbPgID); die();  
  276. $options[$ii]['fbPgID'] = $fbPgID; //echo $fbPgID; 
  277. if (strpos($options[$ii]['fbURL'], '?')!==false) $options[$ii]['fbURL'] = substr($options[$ii]['fbURL'], 0, strpos($options[$ii]['fbURL'], '?'));// prr($pval); prr($options[$ii]); // die(); 
  278. }  
  279. //## Compatibility with ver <3.2 
  280. if (empty($options[$ii]['postType']) && !empty($options[$ii]['fbPostType'])) { $options[$ii]['postType'] = $options[$ii]['fbPostType']; unset($options[$ii]['fbPostType']); } 
  281. if (empty($options[$ii]['postType']) && !empty($options[$ii]['PostType'])) { $pt = $options[$ii]['PostType']; unset($options[$ii]['PostType']); $options[$ii]['postType'] = $pt; } 
  282.  
  283. } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;  
  284. } return $options; 
  285. }  
  286. //#### Show Post->Edit Meta Box Settings 
  287. function showEdPostNTSettings($ntOpts, $post) { global $nxs_plurl; $post_id = $post->ID; $nt = 'fb'; $ntU = 'FB';  
  288. foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapFB', true)); if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);  
  289. if (empty($ntOpt['postType']) && !empty($ntOpt['fbPostType'])) { $ntOpt['postType'] = $ntOpt['fbPostType']; unset($ntOpt['fbPostType']); } //## Compatibility with ver <3.2  
  290. if (empty($ntOpt['postType']) && !empty($ntOpt['PostType'])) { $pt = $ntOpt['PostType']; unset($ntOpt['PostType']); $ntOpt['postType'] = $pt; } //## Compatibility with ver <3.2  
  291. if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; 
  292. $doFB = $ntOpt['doFB'] && (is_array($pMeta) || $ntOpt['catSel']!='1');  
  293. $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];  
  294. $isAvailFB = $ntOpt['fbURL']!='' && $ntOpt['fbAppID']!='' && $ntOpt['fbAppSec']!=''; $isAttachFB = $ntOpt['fbAttch']; $fbMsgFormat = htmlentities($ntOpt['fbMsgFormat'], ENT_COMPAT, "UTF-8"); $fbPostType = $ntOpt['postType']; 
  295. ?>  
  296.  
  297. <tr><th style="text-align:left;" colspan="2">  
  298. <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?> 
  299. <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?> 
  300.  
  301. <?php if ($isAvailFB) { ?><input class="nxsGrpDoChb" value="1" id="doFB<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="fb[<?php echo $ii; ?>][doFB]" <?php if ((int)$doFB == 1) echo 'checked="checked" title="def"'; ?> />  
  302. <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="fb[<?php echo $ii; ?>][doFB]" value="<?php echo $doFB;?>"> <?php } ?> <?php } ?> 
  303.  
  304. <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/fb16.png);">Facebook - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published" 
  305. if ($post->post_status == "publish" && $isAvailFB) { ?> 
  306.  
  307. <input alt="<?php echo $ii; ?>" style="float: right;margin-left: 10px" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToFB_repostButton" id="rePostToFB_button" value="<?php _e('Repost to Facebook', 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  308. <?php if ($ntOpt['riComments']=='1' && (is_array($pMeta) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) && strpos($pMeta[$ii]['pgID'], '_')!==false ) ) { ?> 
  309. <input alt="<?php echo $ii; ?>" style="float: right; " onclick="return false;" type="button" class="button" name="riToFB_repostButton" id="riToFB_button" value="<?php _e('Import Comments from Facebook', 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  310. <?php } ?> 
  311.  
  312. <?php } ?> 
  313.  
  314. <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) && strpos($pMeta[$ii]['pgID'], '_')!==false ) { $pid = explode('_', $pMeta[$ii]['pgID']); 
  315.  
  316. ?> <span id="pstdFB<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;"> 
  317. <a style="font-size: 10px;" href="http://www.facebook.com/permalink.php?story_fbid=<?php echo $pid[1].'&id='.$pid[0]; ?>" target="_blank"><?php $nType="Facebook"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a> 
  318. </span><?php } ?> 
  319.  
  320. </td></tr> 
  321. <?php if (!$isAvailFB) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and Authorize your Facebook Account to AutoPost to Facebook</b> 
  322. <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?> 
  323.  
  324. <?php if ($ntOpt['rpstOn']=='1') { ?>  
  325.  
  326. <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow"> 
  327. <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>fb" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> />  
  328. </th> 
  329. <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>  
  330. </td></tr> <?php } ?> 
  331.  
  332. <tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"> 
  333.  
  334. <b></b> 
  335. </th> 
  336. <td></td> 
  337. </tr> 
  338.  
  339. <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g'); ?> <br/> 
  340. (<a id="showShAtt" style="font-weight: normal" onmouseout="hidePopShAtt('<?php echo $ii; ?>X');" onmouseover="showPopShAtt('<?php echo $ii; ?>X', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>)</th><td>  
  341.  
  342. <input class="nxs_postEditCtrl" type="radio" name="fb[<?php echo $ii; ?>][postType]" value="T" <?php if ($fbPostType == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>  
  343. <input class="nxs_postEditCtrl" type="radio" name="fb[<?php echo $ii; ?>][postType]" value="I" <?php if ($fbPostType == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>  
  344. <input class="nxs_postEditCtrl" type="radio" name="fb[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($fbPostType) || $fbPostType == '' || $fbPostType == 'A') echo 'checked="checked"'; ?> /> <?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?> <-- (<a id="showShAtt" onmouseout="hidePopShAtt('<?php echo $ii; ?>');" onmouseover="showPopShAtt('<?php echo $ii; ?>', event);" onclick="return false;" class="underdash" href="http://www.nextscripts.com/blog/"><?php _e('What\'s the difference?', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) <br/> 
  345.  
  346. <div style="width:100%; margin-left: 25px;"><strong><?php _e('Link attachment type:', 'social-networks-auto-poster-facebook-twitter-g'); ?> </strong> <input value="2" id="apFBAttchShare<?php echo $ii; ?>" onchange="doSwitchShAtt(0, <?php echo $ii; ?>);" type="radio" name="fb[<?php echo $ii; ?>][AttachPost]" <?php if ((int)$isAttachFB == 2) echo "checked"; ?> />  
  347. <?php _e('Share a link to your blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?> .. <?php _e('or', 'social-networks-auto-poster-facebook-twitter-g'); ?> ..  
  348. <input class="nxs_postEditCtrl" value="1" id="apFBAttch<?php echo $ii; ?>" onchange="doSwitchShAtt(1, <?php echo $ii; ?>);" type="radio" name="fb[<?php echo $ii; ?>][AttachPost]" <?php if ((int)$isAttachFB == 1) echo "checked"; ?> />  
  349. <?php _e('Attach your blogpost', 'social-networks-auto-poster-facebook-twitter-g'); ?>  
  350. </div>  
  351. <div class="popShAtt" id="popShAtt<?php echo $ii; ?>"><h3><?php _e('Two ways of attaching post on Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3> <img src="<?php echo $nxs_plurl; ?>img/fb2wops.png" width="600" height="257" alt="<?php _e('Two ways of attaching post on Facebook', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div> 
  352. <div class="popShAtt" id="popShAtt<?php echo $ii; ?>X"><h3><?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?></h3><img src="<?php echo $nxs_plurl; ?>img/fbPostTypesDiff6.png" width="600" height="398" alt="<?php _e('Facebook Post Types', 'social-networks-auto-poster-facebook-twitter-g'); ?>"/></div> 
  353. </td></tr> 
  354.  
  355.  
  356. <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th> 
  357. <td> 
  358. <?php if (1==1) { ?> 
  359. <textarea class="nxs_postEditCtrl" cols="150" rows="2" id="fb<?php echo $ii; ?>SNAPformat" name="fb[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#fb<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFBTMsgFrmt<?php echo $ii; ?>');"><?php echo $fbMsgFormat ?></textarea> 
  360. <?php } else { ?> 
  361. <input class="nxs_postEditCtrl" value="<?php echo $fbMsgFormat ?>" type="text" name="fb[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apFBTMsgFrmt<?php echo $ii; ?>');"/><?php nxs_doShowHint("apFBTMsgFrmt".$ii, '', '58'); ?> 
  362. <?php } ?> 
  363. </td></tr> 
  364. <?php /** ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); 
  365. }  
  366.  
  367.  
  368. function adjMetaOpt($optMt, $pMeta) { if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = ''; 
  369. if (isset($pMeta['SNAPformat'])) $optMt['fbMsgFormat'] = $pMeta['SNAPformat'];  
  370. if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];  
  371. if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];  
  372. if (isset($pMeta['AttachPost'])) $optMt['fbAttch'] = ($pMeta['AttachPost'] != '')?$pMeta['AttachPost']:0; else { if (isset($pMeta['SNAPformat'])) $optMt['fbAttch'] = 0; }  
  373. if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType']; 
  374. if (isset($pMeta['doFB'])) $optMt['doFB'] = $pMeta['doFB'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doFB'] = 0; }  
  375. if (isset($pMeta['SNAPincludeFB']) && $pMeta['SNAPincludeFB'] == '1' ) $optMt['doFB'] = 1; // <2.6 Compatibility fix  
  376. return $optMt; 
  377. }}