nxs_snapClassTR

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

Defined (1)

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

/inc-cl/tr.php  
  1. if (!class_exists("nxs_snapClassTR")) { class nxs_snapClassTR { var $ntInfo = array('code'=>'TR', 'lcode'=>'tr', 'name'=>'Tumblr', 'defNName'=>'', 'tstReq' => true); 
  2. //#### Show Common Settings  
  3. function showGenNTSettings($ntOpts) { global $nxs_snapSetPgURL, $nxs_plurl, $nxs_gOptions; $ntInfo = $this->ntInfo;  
  4. if ( isset($_GET['auth']) && $_GET['auth']=='tr') { require_once('apis/trOAuth.php'); $options = $ntOpts[$_GET['acc']]; 
  5. $consumer_key = $options['trConsKey']; $consumer_secret = $options['trConsSec']; 
  6. $callback_url = $nxs_snapSetPgURL."&auth=tra&acc=".$_GET['acc']; 
  7. $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret);prr($tum_oauth ); 
  8. $request_token = $tum_oauth->getRequestToken($callback_url); echo "####"; prr($request_token); 
  9. $options['trOAuthToken'] = $request_token['oauth_token']; 
  10. $options['trOAuthTokenSecret'] = $request_token['oauth_token_secret'];// prr($tum_oauth ); die(); 
  11. switch ($tum_oauth->http_code) { case 200: $url = $tum_oauth->getAuthorizeURL($options['trOAuthToken']);  
  12. if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['tr'][$_GET['acc']] = $options; nxs_settings_save($nxs_gOptions); } 
  13. echo '<script type="text/javascript">window.location = "'.$url.'"</script>'; break;  
  14. default: echo '<br/><b style="color:red">Could not connect to Tumblr. Refresh the page or try again later.</b>'; die(); 
  15. die(); 
  16. if ( isset($_GET['auth']) && $_GET['auth']=='tra') { require_once('apis/trOAuth.php'); $options = $ntOpts[$_GET['acc']]; prr($options); 
  17.  
  18. $consumer_key = $options['trConsKey']; $consumer_secret = $options['trConsSec'];  
  19. $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trOAuthToken'], $options['trOAuthTokenSecret']); 
  20. $options['trAccessTocken'] = $tum_oauth->getAccessToken($_REQUEST['oauth_verifier']); // prr($_GET); prr($_REQUEST); prr($options['trAccessTocken']);  
  21. $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trAccessTocken']['oauth_token'], $options['trAccessTocken']['oauth_token_secret']);  
  22. if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['tr'][$_GET['acc']] = $options; nxs_settings_save($nxs_gOptions); } 
  23. $userinfo = $tum_oauth->get('http://api.tumblr.com/v2/user/info'); prr($userinfo); prr($tum_oauth);// prr($url); die(); 
  24. if (is_array($userinfo->response->user->blogs)) { 
  25. foreach ($userinfo->response->user->blogs as $blog) { 
  26. if (stripos($blog->url, $options['trPgID'])!==false) {  
  27. $gGet = $_GET; unset($gGet['auth']); unset($gGet['acc']); unset($gGet['oauth_token']); unset($gGet['oauth_verifier']); unset($gGet['post_type']); 
  28. $sturl = explode('?', $nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):'');  
  29. echo '<script type="text/javascript">window.location = "'.$nxs_snapSetPgURL.'"</script>'; die(); 
  30. } prr($userinfo); 
  31. die("<span style='color:red;'>ERROR: Authorized USER don't have access to the specified blog: <span style='color:darkred; font-weight: bold;'>".$options['trPgID']."</span></span>"); 
  32. ?>  
  33. <div class="nxs_box"> 
  34. <div class="nxs_box_header">  
  35. <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?> 
  36. <?php $cbo = count($ntOpts); ?>  
  37. <?php if ($cbo>1) { ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?> 
  38. </div> 
  39. </div> 
  40. <div class="nxs_box_inside"> 
  41. <?php foreach ($ntOpts as $indx=>$pbo) { if (trim($pbo['nName']=='')) $pbo['nName'] = str_ireplace('https://', '', str_ireplace('http://', '', $pbo['trURL']));  
  42. if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['trOAuthTokenSecret']) && $pbo['trOAuthTokenSecret']!='')?'1':''; ?> 
  43. <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' /> 
  44. <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />  
  45. <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>  
  46. <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> /> 
  47. <?php } ?> 
  48. <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ", ")+1)."]*" ?></span><?php } ?> 
  49. <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?> 
  50. <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong> 
  51.   <?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')) { ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==></b><?php } ?><a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>   
  52. <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a> 
  53. </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);  
  54. }?> 
  55. </div> 
  56. </div> <?php  
  57. }  
  58. //#### Show NEW Settings Page 
  59. function showNewNTSettings($bo) { $po = array('nName'=>'', 'doTR'=>'1', 'trURL'=>'', 'trPgID'=>'', 'trConsKey'=>'', 'trInclTags'=>'1', 'fillSrcURL'=>'1', 'useOrDate'=>'1', 'trInclCats'=>'0', 'cImgURL'=>'R', 'trConsSec'=>'', 'trPostType'=>'T', 'trDefImg'=>'', 'trOAuthTokenSecret'=>'', 'trAccessTocken'=>'', 'trMsgFormat'=>'<p>New Post has been published on %URL%</p><blockquote><p><strong>%TITLE%</strong></p><p><img src=\'%IMG%\'/></p><p>%FULLTEXT%</p></blockquote>', 'trMsgTFormat'=>'New Post has been published on %SITENAME%' ); 
  60. $po['ntInfo']= array('lcode'=>'tr'); $this->showNTSettings($bo, $po, true);} 
  61. //#### Show Unit Settings 
  62. function showNTSettings($ii, $options, $isNew=false) { global $nxs_plurl, $nxs_snapSetPgURL; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt);  
  63. 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'] = ''; if (!isset($options['fillSrcURL'])) $options['fillSrcURL'] = '0'; if (!isset($options['useOrDate'])) $options['useOrDate'] = '1'; 
  64. if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['trMsgTFormat'])) $options['trMsgTFormat'] = ''; //prr($options); ?> 
  65. <div id="doTR<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>" style="background-image: url(<?php echo $nxs_plurl; ?>img/tr-bg.png); background-position:90% 10%;"> <input type="hidden" name="apDoSTR<?php echo $ii; ?>" value="0" id="apDoSTR<?php echo $ii; ?>" />  
  66. <?php if ($isNew) { ?> <input type="hidden" name="tr[<?php echo $ii; ?>][apDoTR]" value="1" id="apDoNewTR<?php echo $ii; ?>" /> <?php } ?> 
  67.  
  68. <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/tr16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-tumblr-social-networks-auto-poster-wordpress/"><?php $nType="Tumblr"; printf( __( 'Detailed %s Installation/Configuration Instructions' , 'social-networks-auto-poster-facebook-twitter-g'), $nType); ?></a></div> 
  69.  
  70. <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="tr[<?php echo $ii; ?>][nName]" id="trnName<?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/> 
  71. <?php echo nxs_addQTranslSel('tr', $ii, $options['qTLng']); ?> 
  72.  
  73. <br/> 
  74. <ul class="nsx_tabs"> 
  75. <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>  
  76. <?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 } ?> 
  77. </ul> 
  78. <div class="nsx_tab_container"><?php /** ######################## Account Tab ####################### */ ?> 
  79. <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%;"> 
  80.  
  81.  
  82.  
  83. <div style="width:100%;"><strong>Tumblr URL:</strong> <i>It should be your public URL. (i.e. like <b>http://nextscripts.tumblr.com/</b>, not http://www.tumblr.com/blog/nextscripts</i> </div><input onchange="nxsTRURLVal(<?php echo $ii; ?>);" name="tr[<?php echo $ii; ?>][apTRURL]" id="apTRURL<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trURL'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><span style="color: #F00000;" id="apTRURLerr<?php echo $ii; ?>"></span> 
  84. <div style="width:100%;"><strong>Tumblr OAuth Consumer Key:</strong> </div><input name="tr[<?php echo $ii; ?>][apTRConsKey]" id="apTRConsKey" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trConsKey'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />  
  85. <div style="width:100%;"><strong>Tumblr Secret Key:</strong> </div><input name="tr[<?php echo $ii; ?>][apTRConsSec]" id="apTRConsSec" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trConsSec'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  86. <br/> 
  87.  
  88. <div style="width:100%;"><strong id="altFormatText">Default Post Type:</strong></div>  
  89. <div style="margin-left: 10px;"> 
  90.  
  91. <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="T" <?php if ($options['trPostType'] != 'I') echo 'checked="checked"'; ?> onchange="nxs_TRSetEnable('T', '<?php echo $ii; ?>');" /> Text Post<br/>  
  92.  
  93. <div style="width:100%; margin-left: 15px;"><strong id="altFormatText"><?php _e('Post Title Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="apTRTMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apTRTMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) </div><div onblur="jQuery('#apTRMsgFrmt<?php echo $ii; ?>Hint').hide();"> 
  94. <input name="tr[<?php echo $ii; ?>][apTRMsgTFrmt]" id="apTRMsgTFrmt<?php echo $ii; ?>" style="margin-left: 15px; width: 50%;" value="<?php if ($options['trMsgTFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['trMsgTFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); else echo "New Post has been published on %SITENAME%"; ?>" onfocus="jQuery('#apTRTMsgFrmt<?php echo $ii; ?>Hint').show();" <?php if ($options['trPostType'] == 'I') echo 'disabled="disabled"'; ?> /><br/> 
  95. <?php nxs_doShowHint("apTRTMsgFrmt".$ii); ?> 
  96. </div> 
  97.  
  98. <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="I" <?php if ($options['trPostType'] == 'I') echo 'checked="checked"'; ?> onchange="nxs_TRSetEnable('I', '<?php echo $ii; ?>');"/> Image Post 
  99. <i>Don't forget to change default "Post Text Format" to prevent duplicate images.</i><br/> 
  100.  
  101. <div style="width:100%; margin-left: 15px;"> 
  102.  
  103. <strong>Clickthrough URL:</strong>  
  104. <p style="margin-bottom: 20px;margin-top: 5px;"> 
  105. <input type="radio" name="tr[<?php echo $ii; ?>][cImgURL]" value="R" <?php if ( !isset($options['cImgURL']) || $options['cImgURL'] == '' || $options['cImgURL'] == 'R') echo 'checked="checked"'; ?> /> Regular Post URL   
  106. <input type="radio" name="tr[<?php echo $ii; ?>][cImgURL]" value="S" <?php if ($options['cImgURL'] == 'S') echo 'checked="checked"'; ?> /> Shortened Post URL   
  107. <input type="radio" name="tr[<?php echo $ii; ?>][cImgURL]" value="N" <?php if ($options['cImgURL'] == 'N') echo 'checked="checked"'; ?> /> No Clickthrough URL   
  108. </p><strong>Defailt Image to Post:</strong>  
  109. <p style="font-size: 11px; margin: 0px;">If your post is missing "Featured Image" and doesn't have any images in the text body this will be used instead.</p> 
  110. </div><input name="tr[<?php echo $ii; ?>][apTRDefImg]" id="apTRDefImg<?php echo $ii; ?>" style=" margin-left: 15px; width: 30%;" <?php if ($options['trPostType'] != 'I') echo 'disabled="disabled"'; ?> value="<?php _e(apply_filters('format_to_edit', htmlentities($options['trDefImg'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />  
  111. <br/>  
  112. <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="U" <?php if ($options['trPostType'] == 'U') echo 'checked="checked"'; ?> /> Audio Post<br/> 
  113. <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="V" <?php if ($options['trPostType'] == 'V') echo 'checked="checked"'; ?> /> Video Post<br/>  
  114. <i style="">Tip: Your post must contain link to Audio or Video file if you select "Audio Post" or "Video Post" , otherwise it will reverted to the "Text Post"</i> 
  115. <br/><br/> 
  116.  
  117. </div>  
  118.  
  119. <div style="width:100%;"><strong id="altFormatText"><?php _e('Post Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> (<a href="#" id="apTRMsgFrmt<?php echo $ii; ?>HintInfo" onclick="mxs_showHideFrmtInfo('apTRMsgFrmt<?php echo $ii; ?>'); return false;"><?php _e('Show format info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>) </div> 
  120.  
  121.  
  122. <textarea cols="150" rows="3" id="tr<?php echo $ii; ?>SNAPformat" name="tr[<?php echo $ii; ?>][apTRMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#tr<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apTRMsgFrmt<?php echo $ii; ?>');"><?php if ($options['trMsgFormat']!='') _e(apply_filters('format_to_edit', htmlentities($options['trMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); else echo htmlentities("<p>New Post has been published on %URL%</p>\r\n<blockquote><p><strong>%TITLE%</strong></p>\r\n<p><img src=\"%IMG%\"/></p><p>%FULLTEXT%</p></blockquote>"); ?></textarea> 
  123.  
  124. <br/> 
  125. <?php nxs_doShowHint("apTRMsgFrmt".$ii); ?> 
  126.  
  127.  
  128. <p style="margin-bottom: 20px;margin-top: 5px;">  
  129.  
  130. <input value="1" type="checkbox" name="tr[<?php echo $ii; ?>][fillSrcURL]" <?php if ((int)$options['fillSrcURL'] == 1) echo "checked"; ?> />  
  131. <strong>Fill "Source URL"</strong> Will fill Tumblr's "Source URL" with post URL or defined URL. 
  132.  
  133. <br/><input value="1" type="checkbox" name="tr[<?php echo $ii; ?>][useOrDate]" <?php if ((int)$options['useOrDate'] == 1) echo "checked"; ?> />  
  134. <strong>Keep Original Post Date</strong> Will post to Tumblr with original date of the post  
  135.  
  136. <br/><input value="1" type="checkbox" name="tr[<?php echo $ii; ?>][trInclTags]" <?php if ((int)$options['trInclTags'] == 1) echo "checked"; ?> />  
  137. <strong>Post with tags.</strong> Tags from the blogpost will be auto posted to Tumblr  
  138.  
  139. <br/><input value="1" type="checkbox" name="tr[<?php echo $ii; ?>][trInclCats]" <?php if ((int)$options['trInclCats'] == 1) echo "checked"; ?> />  
  140. <strong>Post categories as tags.</strong> Categories from the blogpost will be auto posted to Tumblr as tags  
  141. </p> 
  142.  
  143. <?php  
  144. if($options['trConsSec']=='') { ?> 
  145. <b>Authorize Your Tumblr Account</b>. Please save your settings and come back here to Authorize your account. 
  146. <?php } else { if(isset($options['trAccessTocken']) && isset($options['trAccessTocken']['oauth_token_secret']) && $options['trAccessTocken']['oauth_token_secret']!=='') { ?> 
  147. Your Tumblr Account has been authorized. Blog ID: <?php _e(apply_filters('format_to_edit', htmlentities($options['trPgID'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>.  
  148. You can Re- <?php } ?>  
  149. <a href="<?php echo $nxs_snapSetPgURL.(stripos($nxs_snapSetPgURL, '?')!==false?'&':'?');?>auth=tr&acc=<?php echo $ii; ?>">Authorize Your Tumblr Account</a>  
  150. <?php if (!isset($options['trOAuthTokenSecret']) || $options['trOAuthTokenSecret']=='') { ?> <div class="blnkg"><=== Authorize your account ===</div> <?php } ?>  
  151. <?php } ?>  
  152.  
  153.  
  154. <?php if( isset($options['trOAuthTokenSecret']) && $options['trOAuthTokenSecret']!='') { ?> 
  155.  
  156. <br/><br/><b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>    <a href="#" class="NXSButton" onclick="testPost('TR', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s' , 'social-networks-auto-poster-facebook-twitter-g'), $nType); ?></a> <br/><br/> 
  157. <?php }?> 
  158.  
  159. </div> 
  160. <?php /** ######################## Advanced Tab ####################### */ ?> 
  161. <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content"> 
  162.  
  163. <?php nxs_showCatTagsCTFilters($nt, $ii, $options);  
  164. nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);  
  165. nxs_showRepostSettings($nt, $ii, $options); ?> 
  166.  
  167.  
  168. </div> <?php } ?> <?php /** #### End of Tab #### */ ?> 
  169. </div><br/> <?php /** #### End of Tabs #### */ ?> 
  170.  
  171. <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div> 
  172.  
  173. </div> 
  174. <?php 
  175.  
  176.  
  177. //#### Set Unit Settings from POST 
  178. function setNTSettings($post, $options) { $code = $this->ntInfo['code']; 
  179. foreach ($post as $ii => $pval) { 
  180. if (isset($pval['apTRConsKey']) && $pval['apTRConsSec']!='') { if (!isset($options[$ii])) $options[$ii] = array(); 
  181.  
  182. if (isset($pval['apTRURL'])) { $options[$ii]['trURL'] = trim($pval['apTRURL']); if ( substr($options[$ii]['trURL'], 0, 4)!='http' ) $options[$ii]['trURL'] = 'http://'.$options[$ii]['trURL']; 
  183. $trPgID = $options[$ii]['trURL']; if (substr($trPgID, -1)=='/') $trPgID = substr($trPgID, 0, -1); $trPgID = substr(strrchr($trPgID, "/"), 1); 
  184. $options[$ii]['trPgID'] = $trPgID; //echo $fbPgID; 
  185. if (substr($options[$ii]['trURL'], -1)!='/') $options[$ii]['trURL'] .= '/';; 
  186. if (isset($pval['apDoTR'])) $options[$ii]['doTR'] = $pval['apDoTR']; else $options[$ii]['doTR'] = 0; 
  187. if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']); 
  188. if (isset($pval['apTRConsKey'])) $options[$ii]['trConsKey'] = trim($pval['apTRConsKey']); 
  189. if (isset($pval['apTRConsSec'])) $options[$ii]['trConsSec'] = trim($pval['apTRConsSec']);  
  190. if (isset($pval['apTRMsgFrmt'])) $options[$ii]['trMsgFormat'] = trim($pval['apTRMsgFrmt']);  
  191. if (isset($pval['apTRMsgTFrmt'])) $options[$ii]['trMsgTFormat'] = trim($pval['apTRMsgTFrmt']);  
  192. if (isset($pval['trInclTags'])) $options[$ii]['trInclTags'] = $pval['trInclTags']; else $options[$ii]['trInclTags'] = 0; 
  193. if (isset($pval['fillSrcURL'])) $options[$ii]['fillSrcURL'] = $pval['fillSrcURL']; else $options[$ii]['fillSrcURL'] = 0;  
  194. if (isset($pval['useOrDate'])) $options[$ii]['useOrDate'] = $pval['useOrDate']; else $options[$ii]['useOrDate'] = 0;  
  195.  
  196. if (isset($pval['trInclCats'])) $options[$ii]['trInclCats'] = $pval['trInclCats']; else $options[$ii]['trInclCats'] = 0; 
  197. if (isset($pval['apTRPostType'])) $options[$ii]['trPostType'] = trim($pval['apTRPostType']);  
  198. if (isset($pval['cImgURL'])) $options[$ii]['cImgURL'] = trim($pval['cImgURL']);  
  199.  
  200. if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0; 
  201. if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = '';  
  202.  
  203. if (isset($pval['apTRDefImg'])) $options[$ii]['trDefImg'] = trim($pval['apTRDefImg']);  
  204.  
  205. $options[$ii] = nxs_adjRpst($options[$ii], $pval);  
  206.  
  207. if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']); 
  208. if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);  
  209. if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);  
  210. } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;  
  211. } return $options; 
  212. }  
  213. //#### Show Post->Edit Meta Box Settings 
  214. function showEdPostNTSettings($ntOpts, $post) { global $nxs_plurl; $post_id = $post->ID; $nt = 'tr'; $ntU = 'TR'; 
  215. foreach($ntOpts as $ii=>$ntOpt) {$pMeta = maybe_unserialize(get_post_meta($post_id, 'snapTR', true)); // prr($ntOpts); echo "~~~~~~~~~~~~~~~~"; prr($pMeta); echo "#######"; 
  216. if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]); 
  217. if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; if (empty($ntOpt['trMsgTFormat'])) $ntOpt['trMsgTFormat'] = ''; 
  218. $doTR = $ntOpt['doTR'] && (is_array($pMeta) || (is_array($pMeta) || $ntOpt['catSel']!='1')); $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];  
  219. $isAvailTR = isset($ntOpt['trAccessTocken']) && isset($ntOpt['trAccessTocken']['oauth_token_secret']) && $ntOpt['trAccessTocken']['oauth_token_secret']!=='';  
  220. $trMsgFormat = htmlentities($ntOpt['trMsgFormat'], ENT_COMPAT, "UTF-8"); $trMsgTFormat = htmlentities($ntOpt['trMsgTFormat'], ENT_COMPAT, "UTF-8"); 
  221. ?>  
  222.  
  223. <tr><th style="text-align:left;" colspan="2"> 
  224. <?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 } ?> 
  225. <?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 } ?> 
  226. <?php if ($isAvailTR) { ?><input class="nxsGrpDoChb" value="1" id="doTR<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="tr[<?php echo $ii; ?>][doTR]" <?php if ((int)$doTR == 1) echo 'checked="checked" title="def"'; ?> />  
  227. <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="tr[<?php echo $ii; ?>][doTR]" value="<?php echo $doTR;?>"> <?php } ?> <?php } ?> 
  228. <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/tr16.png);">Tumblr - <?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" 
  229. if ($post->post_status == "publish" && $isAvailTR) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;"Z type="button" class="button" name="rePostToTR_repostButton" id="rePostToTR_button" value="<?php _e('Repost to Tumblr', 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  230. <?php } ?> 
  231.  
  232. <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) {  
  233. ?> <span id="pstdTR<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;"> 
  234. <a style="font-size: 10px;" href="<?php echo $ntOpt['trURL']; ?>post/<?php echo $pMeta[$ii]['pgID']; ?>" target="_blank"><?php $nType="Tumblr"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a> 
  235. </span><?php } ?> 
  236.  
  237. </td></tr> 
  238. <?php if (!$isAvailTR) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup and authorize your Tumblr Account to AutoPost to Tumblr</b> 
  239. <?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); } ?> 
  240.  
  241. <?php if ($ntOpt['rpstOn']=='1') { ?>  
  242.  
  243. <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow"> 
  244. <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>tr" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> /> 
  245. </th> 
  246. <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>  
  247. </td></tr> <?php } ?> 
  248.  
  249. <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"> 
  250. <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="T" <?php if ($ntOpt['trPostType'] != 'I') echo 'checked="checked"'; ?> /> <br/>  
  251. </th> 
  252. <td><b><?php _e('Text Post. Title Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></b> <input value="<?php echo $trMsgTFormat ?>" type="text" name="tr[<?php echo $ii; ?>][SNAPTformat]" style="width:270px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTRTMsgFrmt<?php echo $ii; ?>');"/> 
  253. <?php nxs_doShowHint("apTRTMsgFrmt".$ii); ?> </td></tr> 
  254.  
  255. <tr id="altFormat1" style=""><th scope="row" style="text-align:right; width:60px; padding-right:10px;"> 
  256. <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="I" <?php if ($ntOpt['trPostType'] == 'I') echo 'checked="checked"'; ?> /> <br/>  
  257. </th> 
  258. <td><b>Image Post</b>     
  259. <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="V" <?php if ($ntOpt['trPostType'] == 'V') echo 'checked="checked"'; ?> /> <b>Video Post</b> <?php nxs_doShowHint("apTRTMsgFrmt".$ii); ?>      
  260. <input type="radio" name="tr[<?php echo $ii; ?>][apTRPostType]" value="U" <?php if ($ntOpt['trPostType'] == 'U') echo 'checked="checked"'; ?> /> <b>Audio Post</b> <?php nxs_doShowHint("apTRTMsgFrmt".$ii); ?>  
  261. </td></tr> 
  262.  
  263. <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow"><?php _e('Text Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th> 
  264. <td>  
  265. <textarea cols="150" rows="1" id="tr<?php echo $ii; ?>SNAPformat" name="tr[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#tr<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apTRMsgFrmt<?php echo $ii; ?>');"><?php echo $trMsgFormat; ?></textarea> 
  266. <?php nxs_doShowHint("apTRMsgFrmt".$ii); ?></td></tr> 
  267.  
  268. <?php /** ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?>  
  269.  
  270. <?php }  
  271.  
  272.  
  273.  
  274. function adjMetaOpt($optMt, $pMeta) { if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = ''; 
  275. if (isset($pMeta['SNAPformat'])) $optMt['trMsgFormat'] = $pMeta['SNAPformat']; if (isset($pMeta['SNAPTformat'])) $optMt['trMsgTFormat'] = $pMeta['SNAPTformat'];  
  276. if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];  
  277. if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];  
  278. if (isset($pMeta['apTRPostType'])) $optMt['trPostType'] = $pMeta['apTRPostType'];  
  279. if (isset($pMeta['AttachPost'])) $optMt['trAttch'] = $pMeta['AttachPost'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['trAttch'] = 0; } 
  280. if (isset($pMeta['doTR'])) $optMt['doTR'] = $pMeta['doTR'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doTR'] = 0; } 
  281. if (isset($pMeta['SNAPincludeTR']) && $pMeta['SNAPincludeTR'] == '1' ) $optMt['doTR'] = 1;  
  282. return $optMt; 
  283. }}