Changeset 15122 for extensions/TweetThis/main.inc.php
- Timestamp:
- May 19, 2012, 1:12:51 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/TweetThis/main.inc.php
r12388 r15122 20 20 function tweet_add_button() 21 21 { 22 global $conf, $template; 23 $conf['TweetThis'] = explode(',', $conf['TweetThis']); 22 global $conf, $template, $user; 23 24 $conf['TweetThis'] = unserialize($conf['TweetThis']); 25 $conf['TweetThis']['lang'] = array( 26 'no','de','zh-cn','en','pl','sv','zh-tw','tr','es','th','fa','hu','pt','it','ar','he', 27 'ko','id','ru','ja','da','fi','hi','ur','fr','nl', 28 ); 29 30 $template->assign(array( 31 'TWEET_SIZE' => $conf['TweetThis']['size'], 32 'TWEET_COUNT' => $conf['TweetThis']['count'], 33 'TWEET_VIA' => $conf['TweetThis']['via'], 34 )); 24 35 25 36 if (script_basename() == 'picture') 26 37 { 27 $template->assign(array( 28 'TWEET_IMAGE' => $conf['TweetThis'][0], 29 'TWEET_POSITON' => $conf['TweetThis'][1], 30 )); 31 38 $template->assign('TWEET_POSITON', $conf['TweetThis']['position']); 32 39 $template->set_prefilter('picture', 'tweet_add_button_prefilter'); 33 40 } 34 41 else if (script_basename() == 'index') 35 42 { 36 $template->assign(array( 37 'TWEET_IMAGE' => $conf['TweetThis'][0], 38 'TWEET_POSITON' => 'index', 39 )); 40 43 $template->assign('TWEET_POSITON', 'index'); 41 44 $template->set_prefilter('index', 'tweet_add_button_prefilter'); 42 45 } 43 46 44 // html change a bit if we use custom button, or official with counter45 if ( in_array( $conf['TweetThis'][0], array('none','horizontal','vertical')) )47 // button language 48 if ( in_array(str_replace('_','-',strtolower($user['language'])), $conf['TweetThis']['lang']) ) 46 49 { 47 $template->assign(array( 48 'TWEET_IFRAME' => true, 49 'TWEET_COUNTER' => $conf['TweetThis'][0], 50 )); 50 $template->assign('TWEET_LANG', str_replace('_','-',strtolower($user['language']))); 51 } 52 if ( in_array(substr($user['language'],0,2), $conf['TweetThis']['lang']) ) 53 { 54 $template->assign('TWEET_LANG', substr($user['language'],0,2)); 51 55 } 52 56 else 53 57 { 54 $template->assign(array( 55 'TWEET_IFRAME' => false, 56 'TWEET_COUNTER' => 'none', 57 )); 58 } 59 60 // if the link is in the toolbar, we must use smallier buttons 61 if ( script_basename() == 'index' OR $conf['TweetThis'][1] == 'toolbar') 62 { 63 switch ($conf['TweetThis'][0]) 64 { 65 case 'vertical': 66 $template->assign('TWEET_COUNTER', 'horizontal'); break; 67 case 't_logo-a': 68 $template->assign('TWEET_IMAGE', 't_small-a'); break; 69 case 't_logo-b': 70 $template->assign('TWEET_IMAGE', 't_small-b'); break; 71 case 't_logo-c': 72 $template->assign('TWEET_IMAGE', 't_small-c'); break; 73 } 58 $template->assign('TWEET_LANG', 'en'); 74 59 } 75 60 } … … 79 64 global $template; 80 65 66 $replace = '{combine_script id=\'twitter_widgets\' path=\'http://platform.twitter.com/widgets.js} 67 <a href="https://twitter.com/share" class="twitter-share-button" data-lang="{$TWEET_LANG}" {if not empty($TWEET_VIA)}data-via="{$TWEET_VIA}"{/if} {if $TWEET_SIZE=="large"}data-size="large"{/if} {if not $TWEET_COUNT}data-count="none"{/if}>Tweet</a>'; 68 81 69 switch ($template->get_template_vars('TWEET_POSITON')) 82 70 { 83 71 case 'top': 84 72 $search = '<div id="theImage">'; 85 $replace = ' 86 <div><a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')" 87 class="{if $TWEET_IFRAME}twitter-share-button{/if}" title="{\'Share on Twitter\'|@translate}"> 88 {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if} 89 </a></div> 90 '; 73 $replace = '<div>'.$replace.'</div>'; 91 74 break; 92 75 93 76 case 'bottom': 94 77 $search = '{$ELEMENT_CONTENT}'; 95 $replace = '96 <a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')"97 class="{if $TWEET_IFRAME}twitter-share-button{/if}" title="{\'Share on Twitter\'|@translate}">98 {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if}99 </a>100 ';101 78 break; 102 79 103 80 case 'toolbar': 104 $search = '{*caddie management END*}'; 105 $replace = ' 106 <a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')" 107 class="{if $TWEET_IFRAME}twitter-share-button{/if} pwg-button" title="{\'Share on Twitter\'|@translate}"> 108 {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if} 109 </a> 110 '; 81 $search = '<div class="actionButtons">'; 111 82 break; 112 83 113 84 case 'index': 114 85 $search = '<ul class="categoryActions">'; 115 $replace = ' 116 {combine_script id=\'scripts\' path=\'themes/default/js/scripts.js\'} 117 <li><a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')" 118 class="{if $TWEET_IFRAME}twitter-share-button{/if} pwg-button" title="{\'Share on Twitter\'|@translate}"> 119 {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if} 120 </a></li> 121 '; 86 $replace = '<li>'.$replace.'</li>'; 122 87 break; 123 88 } 124 89 125 $replace = $search . $replace . '{if $TWEET_IFRAME}{combine_script id=\'twitter_widgets\' path=\'http://platform.twitter.com/widgets.js}{/if}'; 126 127 return str_replace($search, $replace, $content); 90 return str_replace($search, $search.$replace, $content); 128 91 } 129 92 … … 135 98 function tweet_plugin_admin_menu($menu) 136 99 { 137 array_push( 138 $menu, 139 array( 140 'NAME' => 'TweetThis', 141 'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)) 142 ) 143 ); 144 100 array_push($menu, array( 101 'NAME' => 'TweetThis', 102 'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)) 103 )); 145 104 return $menu; 146 105 }
Note: See TracChangeset
for help on using the changeset viewer.