PageRenderTime 82ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/content/fb_tw_plus1/fb_tw_plus1.php

https://bitbucket.org/biojazzard/joomla-eboracast
PHP | 1577 lines | 1479 code | 64 blank | 34 comment | 458 complexity | 8ae82c7d4e8b8d0874a1d2236dce105e MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, MIT, BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * @version 2.7
  4. * @Project Facebook Like, Twitter and google +1 buttons
  5. * @author Compago TLC
  6. * @package
  7. * @copyright Copyright (C) 2013 Compago TLC. All rights reserved.
  8. * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 2
  9. */
  10. // Check to ensure this file is included in Joomla!
  11. defined( '_JEXEC' ) or die( 'Restricted access' );
  12. if(!defined('DS')) {
  13. define( 'DS', DIRECTORY_SEPARATOR );
  14. }
  15. $document = JFactory::getDocument();
  16. $docType = $document->getType();
  17. // only in html
  18. if ($docType != 'html'){
  19. return;
  20. }
  21. require_once( JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php' );
  22. if(!function_exists('json_decode')) {
  23. function json_decode($json) {
  24. $comment = false;
  25. $out = '$x=';
  26. for ($i=0; $i<strlen($json); $i++) {
  27. if (!$comment) {
  28. if (($json[$i] == '{') || ($json[$i] == '['))
  29. $out .= ' array(';
  30. else if (($json[$i] == '}') || ($json[$i] == ']'))
  31. $out .= ')';
  32. else if ($json[$i] == ':')
  33. $out .= '=>';
  34. else
  35. $out .= $json[$i];
  36. } else
  37. $out .= $json[$i];
  38. if ($json[$i] == '"' && $json[($i-1)]!="\\")
  39. $comment = !$comment;
  40. }
  41. eval($out . ';');
  42. return $x;
  43. }
  44. }
  45. if(!function_exists('json_encode')){
  46. function json_encode($a=false) {
  47. // Some basic debugging to ensure we have something returned
  48. if (is_null($a)) return 'null';
  49. if ($a === false) return 'false';
  50. if ($a === true) return 'true';
  51. if (is_scalar($a)) {
  52. if (is_float($a)) {
  53. // Always use '.' for floats.
  54. return floatval(str_replace(',', '.', strval($a)));
  55. }
  56. if (is_string($a)) {
  57. static $jsonReplaces = array(array('\\', '/', "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
  58. return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
  59. }
  60. else
  61. return $a;
  62. }
  63. $isList = true;
  64. for ($i = 0, reset($a); true; $i++) {
  65. if (key($a) !== $i) {
  66. $isList = false;
  67. break;
  68. }
  69. }
  70. $result = array();
  71. if ($isList) {
  72. foreach ($a as $v) $result[] = json_encode($v);
  73. return '[' . join(',', $result) . ']';
  74. } else {
  75. foreach ($a as $k => $v) $result[] = json_encode($k).':'.json_encode($v);
  76. return '{' . join(',', $result) . '}';
  77. }
  78. }
  79. }
  80. jimport('joomla.plugin.plugin');
  81. jimport('joomla.environment.browser');
  82. class plgContentfb_tw_plus1 extends JPlugin {
  83. var $_fb = 0;
  84. var $_google = 0;
  85. var $_tw = 0;
  86. var $_in = 0;
  87. var $_pint = 0;
  88. function plgContentfb_tw_plus1( &$subject,$params ) {
  89. parent::__construct( $subject,$params );
  90. }
  91. function onContentPrepare($context, &$article, &$params, $page=0){
  92. if ($context == 'com_media.file') return;
  93. $ignore_pagination = $this->params->get( 'ignore_pagination');
  94. $view = JRequest::getCmd('view');
  95. if ((($view == 'article')||($view == 'productdetails'))&&($ignore_pagination==1)) {
  96. $this->InjectCode($article, $params ,0,$view);
  97. }
  98. }
  99. function onContentBeforeDisplay($context,&$article,&$params,$page=0){
  100. if ($context == 'com_media.file') return;
  101. $ignore_pagination = $this->params->get( 'ignore_pagination');
  102. $view = JRequest::getCmd('view');
  103. if (($view != 'article')||((($view == 'article')||($view == 'productdetails'))&&($ignore_pagination==0))) {
  104. $this->InjectCode($article, $params ,1,$view);
  105. }
  106. }
  107. function onBeforeCompileHead(){
  108. $view = JRequest::getCmd('view');
  109. $this->InjectHeadCode($view);
  110. }
  111. public function onContentAfterSave($context, &$article, $isNew) {
  112. if ($_REQUEST[jform][state]!='1') return;
  113. if ($_REQUEST[jform][access]!='1') return;
  114. if ($context == 'com_media.file') return;
  115. //enabled "com_content.article" (backend) and "com_content.form" (frontend)
  116. $enable_fb_autopublish = $this->params->get( 'enable_fb_autopublish');
  117. $enable_twitter_autopublish = $this->params->get( 'enable_twitter_autopublish');
  118. //Enable autopublish only on the articles or categories where are rendered the share buttons
  119. $category_tobe_excluded = $this->params->get('category_tobe_excluded_buttons', '' );
  120. $content_tobe_excluded = $this->params->get('content_tobe_excluded_buttons', '' );
  121. $excludedContentList = @explode ( ",", $content_tobe_excluded );
  122. if ($article->id!=null) {
  123. if ( in_array ( $article->id, $excludedContentList )) {
  124. return;
  125. }
  126. if (is_array($category_tobe_excluded ) && in_array ( $article->catid, $category_tobe_excluded )) {
  127. return;
  128. }
  129. } else {
  130. if (is_array($category_tobe_excluded ) && in_array ( JRequest::getCmd('id'), $category_tobe_excluded )) return;
  131. }
  132. //Enable autopublish only on "apply" action
  133. if ($_REQUEST['task']!='apply') {
  134. return true;
  135. }
  136. if (($enable_fb_autopublish||$enable_twitter_autopublish)&&(!extension_loaded('curl'))) {
  137. JFactory::getApplication()->enqueueMessage( JText::_('Facebook or Twitter Autopublish is not possible because CURL extension is not loaded.'), 'error' );
  138. return true;
  139. }
  140. //Facebook autopublish
  141. if (($context == "com_content.article")&&($enable_fb_autopublish)) {
  142. if (!class_exists('Facebook', false)) {
  143. require_once('facebook'.DS.'facebook.php');
  144. }
  145. $app_id = $this->params->get('app_id');
  146. $fb_secret_key = $this->params->get('fb_secret_key');
  147. $fb_extra_params = $this->params->get('fb_extra_params');
  148. $fb_ids = $fb_extra_params->fb_ids;
  149. $token = $fb_extra_params->fb_token;
  150. //if the configuration is complete proceeed with the post on FB walls
  151. if (($app_id!='')&&($fb_secret_key!='')&&(count($fb_ids)>0)&&($token!='')) {
  152. $title = $this->getTitle($article);
  153. $caption = '';
  154. $url = JUri::root().ContentHelperRoute::getArticleRoute($article->id.':'.$article->alias, $article->catid);
  155. $router = JSite::getInstance('site')->getRouter('site');
  156. $url = $router->build($url);
  157. $url = str_replace('administrator/', '', $url);
  158. $description = $this->getDescription($article,'article');
  159. if ($this->params->get('fb_autopublish_image','1')=='1') {
  160. $images = $this->getPicture($article,'article');
  161. if (count($images)>0) {
  162. $pic = $images[0];
  163. } else {
  164. $pic = '';
  165. }
  166. } else {
  167. $pic = '';
  168. }
  169. if ($isNew) {
  170. $msg = $this->params->get('fb_text_new','');
  171. } else {
  172. $msg = $this->params->get('fb_text_old','Update');
  173. }
  174. $facebook = new Facebook(array(
  175. 'appId' => $app_id,
  176. 'secret' => $fb_secret_key,
  177. 'cookie' => true
  178. ));
  179. $ok = true;
  180. try {
  181. $info_accounts=$facebook->api('/me/accounts',array('access_token' => $token ));
  182. $info_groups=$facebook->api('/me/groups',array('access_token' => $token ));
  183. } catch(FacebookApiException $e) {
  184. JError::raiseWarning('1', 'Facebook error: ' . $e->getMessage());
  185. $ok = false;
  186. }
  187. if ($ok) {
  188. $accounts=$info_accounts['data'];
  189. foreach ($accounts as $account) {
  190. if (in_array($account['id'],$fb_ids)) {
  191. $ok = true;
  192. try {
  193. $token = $account['access_token'];
  194. $facebook->api('/'.$account['id'].'/feed','post',
  195. array('access_token' => $token,
  196. 'message' => $msg,
  197. 'link' => $url,
  198. 'picture' => $pic,
  199. 'name' => $title,
  200. 'caption' => $caption,
  201. 'description' => $description,
  202. )
  203. );
  204. } catch(FacebookApiException $e) {
  205. JError::raiseWarning('1', 'Facebook error: ' . $e->getMessage());
  206. $ok = false;
  207. }
  208. if ($ok) {
  209. $info=$facebook->api('/'.$account['id'].'/',array('access_token' => $token ));
  210. JFactory::getApplication()->enqueueMessage( JText::_('Content published on Facebook: ')."<a href='".$info['link']."'>".$info['name']."</a>", 'message' );
  211. }
  212. }
  213. }
  214. }
  215. } else {
  216. if ($app_id==''){JFactory::getApplication()->enqueueMessage( JText::_('App ID is missing'), 'error' ); }
  217. if ($fb_secret_key==''){JFactory::getApplication()->enqueueMessage( JText::_('App secret key is missing'), 'error' ); }
  218. if (count($fb_ids)==0){JFactory::getApplication()->enqueueMessage( JText::_('Must be specified on at least one Facebook account ID where to publish the article'), 'error' ); }
  219. if ($token==''){JFactory::getApplication()->enqueueMessage( JText::_('Valid access token missing'), 'error' ); }
  220. }
  221. }
  222. //Twitter autopublish
  223. if (($context == "com_content.article")&&($enable_twitter_autopublish)) {
  224. if (!class_exists('TwitterOAuth', false)) {
  225. require_once('twitteroauth'.DS.'twitteroauth.php');
  226. }
  227. $consumer_key = $this->params->get( 'twitter_consumer_key','');
  228. $consumer_secret = $this->params->get( 'twitter_consumer_secret','');
  229. $oauth_token = $this->params->get( 'twitter_oauth_token','');
  230. $oauth_token_secret = $this->params->get( 'twitter_oauth_token_secret','');
  231. $use_tinyurl = $this->params->get( 'twitter_use_tinyurl',0);
  232. if (($consumer_key!='')&&($consumer_secret!='')&&
  233. ($oauth_token!='')&&($oauth_token_secret!='')) {
  234. $conn = new TwitterOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
  235. if (!$conn) {
  236. JFactory::getApplication()->enqueueMessage( JText::_('Connection error occurred'), 'error' );
  237. die();
  238. }
  239. $title = $this->getTitle($article);
  240. $url = JURI::root().ContentHelperRoute::getArticleRoute($article->id, $article->catid);
  241. if ($use_tinyurl) {
  242. $url = $this->getTinyurl($url);
  243. }
  244. if ($isNew) {
  245. $msg = (substr($title, 0, 100)." ".$url);
  246. } else {
  247. $msg = ("Update : " . substr($title, 0, 100)." ".$url);
  248. }
  249. $status = $conn->post('statuses/update', array('status' => $msg));
  250. if (!isset($status->error)) {
  251. JFactory::getApplication()->enqueueMessage( JText::_('Content published on Twitter'), 'message' );
  252. } else {
  253. JFactory::getApplication()->enqueueMessage( JText::_('Content published on Twitter: '.$status->error), 'error' );
  254. }
  255. } else {
  256. if ($consumer_key==''){JFactory::getApplication()->enqueueMessage( JText::_('Consumer key is missing'), 'error' ); }
  257. if ($consumer_secret==''){JFactory::getApplication()->enqueueMessage( JText::_('Consumer secret key is missing'), 'error' ); }
  258. if ($oauth_token==''){JFactory::getApplication()->enqueueMessage( JText::_('Oauth token is missing'), 'error' ); }
  259. if ($oauth_token_secret==''){JFactory::getApplication()->enqueueMessage( JText::_('Oauth token secret key is missing'), 'error' ); }
  260. }
  261. }
  262. return true;
  263. }
  264. private function getTinyurl($url) {
  265. $data = (trim($this->get_url_contents('http://tinyurl.com/api-create.php?url=' . $url)));
  266. if (!$data)
  267. return $url;
  268. return $data;
  269. }
  270. private function getProtocol() {
  271. if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1)
  272. || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'
  273. ) {
  274. $protocol = 'https://';
  275. }
  276. else {
  277. $protocol = 'http://';
  278. }
  279. return $protocol;
  280. }
  281. private function getCurrentUrl($mode=0) {
  282. $protocol = $this->getProtocol();
  283. $currentUrl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  284. $parts = parse_url($currentUrl);
  285. $query = '';
  286. if (!empty($parts['query'])) {
  287. // drop known fb params
  288. $params = explode('&', $parts['query']);
  289. $retained_params = array();
  290. foreach ($params as $param) {
  291. $retained_params[] = $param;
  292. }
  293. unset($retained_params['state']);
  294. unset($retained_params['code']);
  295. if($mode==1){
  296. if ($_REQUEST['task']=='apply') {
  297. $retained_params[] = 'view=article';
  298. } elseif ($_REQUEST['task']=='save2new') {
  299. unset($retained_params['id']);
  300. }
  301. } else {
  302. $retained_params[] = 'view=article';
  303. }
  304. if (!empty($retained_params)) {
  305. $query = '?'.implode($retained_params, '&');
  306. }
  307. }
  308. // use port if non default
  309. $port =
  310. isset($parts['port']) &&
  311. (($protocol === 'http://' && $parts['port'] !== 80) ||
  312. ($protocol === 'https://' && $parts['port'] !== 443))
  313. ? ':' . $parts['port'] : '';
  314. // rebuild
  315. return $protocol . $parts['host'] . $port . $parts['path'] . $query;
  316. }
  317. private function SetParams($key,$value) {
  318. $db=& JFactory::getDBO();
  319. $db->setQuery("SELECT `params` FROM `#__extensions` WHERE `name`= 'Content - Facebook-Twitter-Google+1';");
  320. $contents = $db->loadObject();
  321. $params = json_decode($contents->params);
  322. $params->{$key}=$value;
  323. $params = json_encode($params);
  324. $db->setQuery("UPDATE `#__extensions` SET ".$db->nameQuote('params')."= '".$db->getEscaped($params)."' WHERE `name`= 'Content - Facebook-Twitter-Google+1';");
  325. $result = $db->query();
  326. $db->freeResult($result);
  327. }
  328. private function InjectHeadCode($view){
  329. $document = & JFactory::getDocument();
  330. $enable_like = $this->params->get( 'enable_like');
  331. $enable_share = $this->params->get( 'enable_share');
  332. $enable_comments = $this->params->get( 'enable_comments');
  333. if (($enable_share==1)||($enable_like==1)||($enable_comments==1)) {
  334. $config =& JFactory::getConfig();
  335. if (method_exists($config,'getValue')) {
  336. $site_name = $config->getValue('config.sitename');
  337. } else {
  338. $site_name = $config->get('config.sitename');
  339. }
  340. $description = $this->params->get('description');
  341. $enable_admin = $this->params->get('enable_admin','0');
  342. $enable_app = $this->params->get('enable_app','0');
  343. $admin_id = $this->params->get('admin_id');
  344. $app_id = $this->params->get('app_id');
  345. if ($this->params->get('auto_language')) {
  346. $language_fb = str_replace('-', '_', JFactory::getLanguage()->getTag());
  347. } else {
  348. $language_fb = $this->params->get('language_fb');
  349. }
  350. $meta = "";
  351. $head_data = array();
  352. foreach( $document->getHeadData() as $tmpkey=>$tmpval ){
  353. if(!is_array($tmpval)){
  354. $head_data[] = $tmpval;
  355. } else {
  356. foreach( $tmpval as $tmpval2 ){
  357. if(!is_array($tmpval2)){
  358. $head_data[] = $tmpval2;
  359. }
  360. }
  361. }
  362. }
  363. $head = implode(',',$head_data);
  364. if (($description==0)&&(preg_match('/<meta property="og:description"/i',$head)==0)&&($view!='productdetails')){
  365. $description = $document->getMetaData("description");
  366. $meta .= "<meta property=\"og:description\" content=\"$description\"/>".PHP_EOL;
  367. }
  368. if ($enable_admin==0) { $admin_id=""; }
  369. else {
  370. if (preg_match('/<meta property="fb:admins"/i',$head)==0){
  371. $meta .= "<meta property=\"fb:admins\" content=\"$admin_id\"/>".PHP_EOL;
  372. }
  373. }
  374. if ($enable_app==0) { $app_id=""; }
  375. else {
  376. if (preg_match('/<meta property="fb:app_id"/i',$head)==0){
  377. $meta .= "<meta property=\"fb:app_id\" content=\"$app_id\"/>".PHP_EOL;
  378. }
  379. }
  380. if (preg_match('/<meta property="og:locale"/i',$head)==0){
  381. $meta .= "<meta property=\"og:locale\" content=\"".$language_fb."\"/>".PHP_EOL;
  382. }
  383. if (preg_match('/<meta property="og:site_name"/i',$head)==0){
  384. $meta .= "<meta property=\"og:site_name\" content=\"$site_name\"/>".PHP_EOL;
  385. }
  386. $document->addCustomTag( PHP_EOL.$meta.PHP_EOL);
  387. }
  388. }
  389. private function InjectCode(&$article, &$params, $mode,$view){
  390. $format=JRequest::getCMD('format');
  391. if (($format=='pdf')||($format=='feed')) return;
  392. $document = & JFactory::getDocument();
  393. $position = $this->params->get( 'position', '' );
  394. $enable_like = $this->params->get( 'enable_like');
  395. $enable_share = $this->params->get( 'enable_share');
  396. $enable_comments = $this->params->get( 'enable_comments');
  397. $enable_twitter = $this->params->get( 'enable_twitter');
  398. $enable_google = $this->params->get( 'enable_google');
  399. $enable_in = $this->params->get( 'enable_in');
  400. $enable_pint = $this->params->get( 'enable_pint');
  401. $enable_fb_photo = $this->params->get( 'enable_fb_photo');
  402. $view_article_buttons = $this->params->get( 'view_article_buttons');
  403. $view_frontpage_buttons = $this->params->get( 'view_frontpage_buttons');
  404. $view_category_buttons = $this->params->get( 'view_category_buttons');
  405. $view_article_comments = $this->params->get( 'view_article_comments');
  406. $view_frontpage_comments = $this->params->get( 'view_frontpage_comments');
  407. $view_category_comments = $this->params->get( 'view_category_comments');
  408. $asynchronous_fb = $this->params->get( 'asynchronous_fb',0);
  409. $asynchronous_twitter = $this->params->get( 'asynchronous_twitter',0);
  410. $asynchronous_in = $this->params->get( 'asynchronous_in',0);
  411. $asynchronous_pint = $this->params->get( 'asynchronous_pint',0);
  412. $enable_view_comments = 0;
  413. $enable_view_buttons = 0;
  414. $enable_app = $this->params->get('enable_app');
  415. $app_id = $this->params->get('app_id');
  416. if ($app_id == '') { $enable_fb_photo = '0'; }
  417. $type = $this->params->get('type');
  418. $directyoutube = $this->params->get('directyoutube',0);
  419. $meta = "";
  420. $title = $this->getTitle($article);
  421. $url = $this->getPageUrl($article);
  422. $basetitle= $document->getTitle();
  423. if ($view=='category'){
  424. $baseurl = $this->getCatUrl($article);
  425. } else {
  426. $baseurl = $document->getBase();
  427. }
  428. if (($enable_share==1)||($enable_like==1)||($enable_fb_photo==1)||($enable_comments==1)||($enable_google==1)||($enable_twitter==1)||($enable_in==1)||($enable_pint==1)) {
  429. $head_data = array();
  430. foreach( $document->getHeadData() as $tmpkey=>$tmpval ){
  431. if(!is_array($tmpval)){
  432. $head_data[] = $tmpval;
  433. } else {
  434. foreach( $tmpval as $tmpval2 ){
  435. if(!is_array($tmpval2)){
  436. $head_data[] = $tmpval2;
  437. }
  438. }
  439. }
  440. }
  441. $head = implode(',',$head_data);
  442. if (($enable_share==1)||($enable_like==1)||($enable_comments==1)) {
  443. if ((preg_match('/<meta property="og:video"/i',$head)==0)){
  444. if (isset($article->text)) {
  445. $text=$article->text;
  446. } else {
  447. $text=$article->introtext;
  448. }
  449. if ($view == 'article'){
  450. if (preg_match('%<object.*(?:data|value)=[\\\\"\'](.*?\.(?:flv|swf))["\'].*?</object>%si', $text,$regsu)) {
  451. if ((preg_match('%<object.*width=["\'](.*?)["\'].*</object>%si', $text,$regsw))&&
  452. (preg_match('%<object.*height=["\'](.*?)["\'].*</object>%si', $text,$regsh))) {
  453. if (preg_match('/^http/i',$regsu[1])) {
  454. $video = $regsu[1];
  455. } else {
  456. $video = JURI::root().preg_replace('#^/#','',$regsu[1]);
  457. }
  458. $type = "video";
  459. }
  460. } elseif (preg_match('%<iframe.*src=["\'](.*?(?:www\.(?:youtube|youtube-nocookie)\.com|vimeo.com)/(?:embed|v)/(?!videoseries).*?)["\'].*?</iframe>%si', $text,$regsu)) {
  461. if ((preg_match('%<iframe.*width=["\'](.*?)["\'].*</iframe>%si', $text,$regsw))&&
  462. (preg_match('%<iframe.*height=["\'](.*?)["\'].*</iframe>%si', $text,$regsh))) {
  463. if ($directyoutube==0) {
  464. $video = $regsu[1];
  465. } else {
  466. $video = preg_replace('%embed/(?!videoseries)%i','v/',$regsu[1]);
  467. }
  468. $type = "video";
  469. }
  470. }
  471. if ($type == "video") {
  472. $meta .= "<meta property=\"og:video\" content=\"$video\"/>".PHP_EOL;
  473. $meta .= "<meta property=\"og:video:type\" content=\"application/x-shockwave-flash\"/>".PHP_EOL;
  474. $meta .= "<meta property=\"og:video:width\" content=\"$regsw[1]\">".PHP_EOL;
  475. $meta .= "<meta property=\"og:video:height\" content=\"$regsh[1]\">".PHP_EOL;
  476. }
  477. }
  478. }
  479. if ((preg_match('/<meta property="og:type"/i',$head)==0)&&($enable_app==1)&&($app_id!="")) {
  480. if (($view == 'article')||($view == 'productdetails')) {
  481. $meta .= "<meta property=\"og:type\" content=\"$type\"/>".PHP_EOL;
  482. } else {
  483. $meta .= "<meta property=\"og:type\" content=\"website\"/>".PHP_EOL;
  484. }
  485. }
  486. $description = $this->params->get('description');
  487. if (preg_match('/<meta property="og:description"/i',$head)==0){
  488. if ($view == 'productdetails') {
  489. if (isset($article->product_s_desc)) {
  490. $og_description=htmlentities(strip_tags($article->product_s_desc),ENT_QUOTES, "UTF-8");
  491. } else {
  492. $og_description=htmlentities(strip_tags($article->product_desc),ENT_QUOTES, "UTF-8");
  493. }
  494. } elseif ($view == 'article') {
  495. if ($description==3) {
  496. $og_description=htmlentities(strip_tags($article->introtext),ENT_QUOTES, "UTF-8");
  497. } elseif ($description==2) { //first 255 chars
  498. $og_description = htmlentities(mb_substr(strip_tags($article->text), 0, 251)."... ",ENT_QUOTES, "UTF-8");
  499. } elseif ($description==1) { //first paragraph
  500. $content = htmlentities(strip_tags($article->text),ENT_QUOTES, "UTF-8");
  501. $pos = strpos($content, '.');
  502. if ($pos === false) {
  503. $og_description = $content;
  504. } else {
  505. $og_description = substr($content, 0, $pos+1);
  506. }
  507. } elseif ($description==0) { //meta description
  508. $og_description = htmlentities(strip_tags($article->metadesc),ENT_QUOTES, "UTF-8");
  509. }
  510. } else {
  511. $og_description = htmlentities(strip_tags($document->getMetaData("description")),ENT_QUOTES, "UTF-8");
  512. }
  513. $meta .= "<meta property=\"og:description\" content=\"".$og_description."\"/>".PHP_EOL;
  514. }
  515. if (preg_match('/<meta property="og:image"/i',$head)==0){
  516. $images = $this->getPicture($article,$view);
  517. if (count($images) != 0) {
  518. foreach ($images as $value) {
  519. $meta .= "<meta property=\"og:image\" content=\"$value\"/>".PHP_EOL;
  520. }
  521. }
  522. }
  523. if (preg_match('/<meta property="og:url"/i',$head)==0) {
  524. if (($view == 'article')||($view == 'productdetails')) {
  525. $meta .= "<meta property=\"og:url\" content=\"$url\"/>".PHP_EOL;
  526. } else {
  527. $meta .= "<meta property=\"og:url\" content=\"$baseurl\"/>".PHP_EOL;
  528. }
  529. }
  530. if (preg_match('/<meta property="og:title"/i',$head)==0) {
  531. if (($view == 'article')||($view == 'productdetails')) {
  532. $meta .= "<meta property=\"og:title\" content=\"$title\"/>".PHP_EOL;
  533. } else {
  534. $meta .= "<meta property=\"og:title\" content=\"$basetitle\"/>".PHP_EOL;
  535. }
  536. }
  537. if (preg_match('/<meta name="my:fb"/i',$head)==0){
  538. $meta .= "<meta name=\"my:fb\" content=\"on\"/>".PHP_EOL;
  539. $this->_fb = 1;
  540. } else {
  541. $this->_fb = 2;
  542. }
  543. }
  544. if ($enable_google==1) {
  545. if (preg_match('/<meta name="my:google"/i',$head)==0){
  546. $meta .= "<meta name=\"my:google\" content=\"on\"/>".PHP_EOL;
  547. $this->_google = 1;
  548. } else {
  549. $this->_google = 2;
  550. }
  551. }
  552. if ($enable_twitter==1) {
  553. if (preg_match('/<meta name="my:tw"/i',$head)==0){
  554. $meta .= "<meta name=\"my:tw\" content=\"on\"/>".PHP_EOL;
  555. $this->_tw = 1;
  556. } else {
  557. $this->_tw = 2;
  558. }
  559. }
  560. if ($enable_in==1) {
  561. if (preg_match('/<meta name="my:in"/i',$head)==0){
  562. $meta .= "<meta name=\"my:in\" content=\"on\"/>".PHP_EOL;
  563. $this->_in = 1;
  564. } else {
  565. $this->_in = 2;
  566. }
  567. }
  568. if ($enable_pint==1) {
  569. if (preg_match('/<meta name="my:pint"/i',$head)==0){
  570. $meta .= "<meta name=\"my:pint\" content=\"on\"/>".PHP_EOL;
  571. $this->_pint = 1;
  572. } else {
  573. $this->_pint = 2;
  574. }
  575. }
  576. if ($meta!="") {
  577. $document->addCustomTag( PHP_EOL.$meta.PHP_EOL);
  578. }
  579. }
  580. if ((($view == 'article')||($view == 'productdetails'))&&($view_article_buttons)||
  581. ($view == 'featured')&&($view_frontpage_buttons)||
  582. ($view == 'category')&&($view_category_buttons)) {
  583. $enable_view_buttons = 1;
  584. }
  585. if ((($view == 'article')||($view == 'productdetails'))&&($view_article_comments)||
  586. ($view == 'featured')&&($view_frontpage_comments)||
  587. ($view == 'category')&&($view_category_comments)) {
  588. $enable_view_comments = 1;
  589. }
  590. $category_tobe_excluded_buttons = $this->params->get('category_tobe_excluded_buttons', '' );
  591. $content_tobe_excluded_buttons = $this->params->get('content_tobe_excluded_buttons', '' );
  592. $excludedContentList_buttons = @explode ( ",", $content_tobe_excluded_buttons );
  593. if ($article->id!=null) {
  594. if ( in_array ( $article->id, $excludedContentList_buttons )) $enable_view_buttons = 0;
  595. if (is_array($category_tobe_excluded_buttons ) && in_array ( $article->catid, $category_tobe_excluded_buttons )) $enable_view_buttons = 0;
  596. } else {
  597. if (is_array($category_tobe_excluded_buttons ) && in_array ( JRequest::getCmd('id'), $category_tobe_excluded_buttons )) $enable_view_buttons = 0;
  598. }
  599. $category_tobe_excluded_comments = $this->params->get('category_tobe_excluded_comments', '' );
  600. $content_tobe_excluded_comments = $this->params->get('content_tobe_excluded_comments', '' );
  601. $excludedContentList_comments = @explode ( ",", $content_tobe_excluded_comments );
  602. if ($article->id!=null) {
  603. if ( in_array ( $article->id, $excludedContentList_comments )) $enable_view_comments = 0;
  604. if (is_array($category_tobe_excluded_comments ) && in_array ( $article->catid, $category_tobe_excluded_comments )) $enable_view_comments = 0;
  605. } else {
  606. if (is_array($category_tobe_excluded_comments ) && in_array ( JRequest::getCmd('id'), $category_tobe_excluded_comments )) $enable_view_comments = 0;
  607. }
  608. if (JRequest::getCMD('print')==1) {
  609. $enable_view_buttons = 0;
  610. if ($this->params->get('enable_comments_print','0')==0) $enable_view_comments = 0;
  611. }
  612. if (($enable_view_buttons != 1)&&($enable_view_comments != 1)) return;
  613. if ((($enable_like==1)||($enable_share==1)||($enable_comments==1)||($enable_fb_photo==1))&&(($enable_view_buttons == 1)||($enable_view_comments == 1))) {
  614. if ($this->_fb==1) {
  615. if ($this->params->get('auto_language')) {
  616. $language_fb = str_replace('-', '_', JFactory::getLanguage()->getTag());
  617. } else {
  618. $language_fb = $this->params->get('language_fb');
  619. }
  620. if ($asynchronous_fb) {
  621. $FbCode = "
  622. function AddFbScript(){
  623. var js,fjs=document.getElementsByTagName('script')[0];
  624. if (!document.getElementById('facebook-jssdk')) {
  625. js = document.createElement('script');
  626. js.id = 'facebook-jssdk';
  627. js.setAttribute('async', 'true');
  628. ";
  629. if ($app_id!='') {
  630. $FbCode .= "
  631. js.src = '//connect.facebook.net/".$language_fb."/all.js#xfbml=1&appId=".$app_id."';";
  632. } else {
  633. $FbCode .= "
  634. js.src = '//connect.facebook.net/".$language_fb."/all.js';";
  635. }
  636. $FbCode .= "
  637. fjs.parentNode.insertBefore(js, fjs);
  638. }
  639. }
  640. window.addEvent('load', function() { AddFbScript() });
  641. ";
  642. $document->addScriptDeclaration($FbCode);
  643. } else {
  644. if ($app_id!='') {
  645. $document->addScript("//connect.facebook.net/".$language_fb."/all.js#xfbml=1&appId=".$app_id);
  646. } else {
  647. $document->addScript("//connect.facebook.net/".$language_fb."/all.js");
  648. }
  649. }
  650. if ($enable_fb_photo) {
  651. $FbPhotoCode = "
  652. function fb_click_photo(imgURL,msg){
  653. FB.getLoginStatus(function(response) {
  654. if (response.status === 'connected') {
  655. var uid = response.authResponse.userID;
  656. var accessToken = response.authResponse.accessToken;
  657. fb_upload_photo(uid,imgURL,msg);
  658. } else {
  659. FB.login(function(response) {
  660. if (response.authResponse) {
  661. var uid = response.authResponse.userID;
  662. fb_upload_photo(uid,imgURL,msg);
  663. }
  664. }, {scope: 'user_photos,publish_stream'});
  665. }
  666. });
  667. }
  668. function fb_upload_photo(id,imgURL,msg){
  669. FB.api('/'+id+'/photos', 'post', {
  670. message:msg,
  671. url:imgURL,
  672. // privacy: {value: \"CUSTOM\", friends: \"SELF\"}
  673. }, function(response){
  674. if (!response || response.error) {
  675. alert('Error occured uploading the photo to your profile: '+response.error);
  676. } else {
  677. alert('The photo has been successfully uploaded.' );
  678. }
  679. });
  680. }
  681. ";
  682. $document->addScriptDeclaration($FbPhotoCode);
  683. $FbPhotoCss = "
  684. .cmp_fbp_button {
  685. display: inline;
  686. position: absolute;
  687. -moz-opacity:.50;
  688. filter:alpha(opacity=50);
  689. opacity:.50;
  690. z-index: 20;
  691. }
  692. .cmp_fbp_button:hover {
  693. -moz-opacity:1;
  694. filter:alpha(opacity=100);
  695. opacity:1;
  696. }
  697. ";
  698. $document->addStyleDeclaration($FbPhotoCss);
  699. }
  700. }
  701. }
  702. if (($enable_twitter==1)&&($enable_view_buttons == 1)) {
  703. if ($this->_tw==1){
  704. if ($asynchronous_twitter) {
  705. $TwCode = "
  706. function AddTwitterScript(){
  707. var js,fjs=document.getElementsByTagName('script')[0];
  708. if(!document.getElementById('twitter-wjs')){
  709. js=document.createElement('script');
  710. js.id='twitter-wjs';
  711. js.setAttribute('async', 'true');
  712. js.src=\"//platform.twitter.com/widgets.js\";
  713. fjs.parentNode.insertBefore(js,fjs);
  714. }
  715. }
  716. window.addEvent('load', function() { AddTwitterScript() });
  717. ";
  718. $document->addScriptDeclaration($TwCode);
  719. } else {
  720. $document->addScript("//platform.twitter.com/widgets.js");
  721. }
  722. }
  723. }
  724. if (($enable_google==1)&&($enable_view_buttons == 1)) {
  725. if ($this->_google==1) {
  726. if ($this->params->get('auto_language')) {
  727. $language_google = JFactory::getLanguage()->getTag();
  728. } else {
  729. $language_google = $this->params->get('language_google','en-US');
  730. }
  731. $GoogleCode = "
  732. function AddGoogleScript(){
  733. var js,fjs=document.getElementsByTagName('script')[0];
  734. if(!document.getElementById('google-wjs')){
  735. js=document.createElement('script');
  736. js.id='google-wjs';
  737. js.setAttribute('async', 'true');
  738. js.src=\"//apis.google.com/js/plusone.js\";
  739. js.text=\"{lang: '".$language_google."'}\";
  740. fjs.parentNode.insertBefore(js,fjs);
  741. }
  742. }
  743. window.addEvent('load', function() { AddGoogleScript() });
  744. ";
  745. $document->addScriptDeclaration($GoogleCode);
  746. }
  747. }
  748. if (($enable_in==1)&&($enable_view_buttons == 1)) {
  749. if ($this->_in==1) {
  750. $InCode = "
  751. function AddInScript(){
  752. var js,fjs=document.getElementsByTagName('script')[0];
  753. if(!document.getElementById('linkedin-js')){
  754. js=document.createElement('script');
  755. js.id='linkedin-js';
  756. js.setAttribute('async', 'true');
  757. js.src=\"//platform.linkedin.com/in.js\";
  758. fjs.parentNode.insertBefore(js,fjs);
  759. }
  760. }
  761. window.addEvent('load', function() { AddInScript() });
  762. ";
  763. $document->addScriptDeclaration($InCode);
  764. }
  765. }
  766. if (($enable_pint==1)&&($enable_view_buttons == 1)) {
  767. $selection_pint = $this->params->get( 'selection_pint','0');
  768. if (($this->_pint==1)&&($selection_pint=='1')) { //not user select
  769. $PintCode = "
  770. function AddPintScript(){
  771. var js,fjs=document.getElementsByTagName('script')[0];
  772. if(!document.getElementById('pinterest-js')){
  773. js=document.createElement('script');
  774. js.id='pinterest-js';
  775. js.setAttribute('async', 'true');
  776. js.src=\"//assets.pinterest.com/js/pinit.js\";
  777. fjs.parentNode.insertBefore(js,fjs);
  778. }
  779. }
  780. window.addEvent('load', function() { AddPintScript() });
  781. ";
  782. $document->addScriptDeclaration($PintCode);
  783. $PintCss = "
  784. .cmp_pint_button {
  785. display: inline;
  786. position: absolute;
  787. -moz-opacity:.50;
  788. filter:alpha(opacity=50);
  789. opacity:.50;
  790. z-index: 20;
  791. }
  792. .cmp_pint_button:hover {
  793. -moz-opacity:1;
  794. filter:alpha(opacity=100);
  795. opacity:1;
  796. }
  797. ";
  798. $document->addStyleDeclaration($PintCss);
  799. }
  800. }
  801. if (($view=='article')||($view=='productdetails')){
  802. $tmp=$article->text;
  803. } else {
  804. $tmp=$article->introtext;
  805. }
  806. if ((($enable_like==1)||($enable_share==1)||($enable_twitter==1)||($enable_google==1)||($enable_in==1)||($enable_pint==1))&&($enable_view_buttons==1)) {
  807. $htmlcode=$this->getPlugInButtonsHTML($params, $article, $url, $title, $view, $tmp);
  808. if ($position == '1'){
  809. $tmp = $htmlcode . $tmp;
  810. }
  811. if ($position == '2'){
  812. $tmp = $tmp . $htmlcode;
  813. }
  814. if ($position == '3'){
  815. $tmp = $htmlcode . $tmp . $htmlcode;
  816. }
  817. }
  818. if (($enable_comments==1)&&($enable_view_comments==1)) {
  819. $tmp = $tmp . $this->getPlugInCommentsHTML($params, $article, $url, $title);
  820. }
  821. if (($view=='article')||($view=='productdetails')){
  822. $article->text=$tmp;
  823. } else {
  824. $article->introtext=$tmp;
  825. }
  826. }
  827. private function getPlugInCommentsHTML($params, $article, $url, $title) {
  828. $idrnd = 'fbcom'.rand();
  829. $document = & JFactory::getDocument();
  830. $category_tobe_excluded = $this->params->get('category_tobe_excluded_comments');
  831. $content_tobe_excluded = $this->params->get('content_tobe_excluded_comments', '' );
  832. $excludedContentList = @explode ( ",", $content_tobe_excluded );
  833. if ($article->id!=null) {
  834. if ( in_array ( $article->id, $excludedContentList )) {
  835. return;
  836. }
  837. if (is_array($category_tobe_excluded ) && in_array ( $article->catid, $category_tobe_excluded )) {
  838. return;
  839. }
  840. } else {
  841. if (is_array($category_tobe_excluded ) && in_array ( JRequest::getCmd('id'), $category_tobe_excluded )) return;
  842. }
  843. $htmlCode = "";
  844. $number_comments = $this->params->get('number_comments');
  845. $width = $this->params->get('width_comments');
  846. $box_color = $this->params->get('box_color');
  847. $container_comments = $this->params->get('container_comments','1');
  848. $css_comments = $this->params->get('css_comments','border-top-style:solid;border-top-width:1px;padding:10px;text-align:center;');
  849. if ($css_comments!="") { $css_comments="style=\"$css_comments\""; }
  850. $enable_comments_count = $this->params->get('enable_comments_count');
  851. $container_comments_count = $this->params->get('container_comments_count','1');
  852. $css_comments_count = $this->params->get('css_comments_count');
  853. $asynchronous_fb = $this->params->get('asynchronous_fb',0);
  854. $autofit = $this->params->get('autofit_comments',0);
  855. $htmlCode = "";
  856. if ($css_comments_count!="") { $css_comments_count="style=\"$css_comments_count\""; }
  857. if ($container_comments==1){
  858. $htmlCode .="<div id=\"".$idrnd."\" class=\"cmp_comments_container\" $css_comments>";
  859. } elseif ($container_comments==2) {
  860. $htmlCode .="<p id=\"".$idrnd."\" class=\"cmp_comments_container\" $css_comments>";
  861. }
  862. if ($enable_comments_count==1){
  863. if ($container_comments_count==1){
  864. $htmlCode .="<div $css_comments_count>";
  865. } elseif ($container_comments_count==2) {
  866. $htmlCode .="<p $css_comments_count>";
  867. }
  868. $htmlCode .= "<fb:comments-count href=\"$url\"></fb:comments-count> comments";
  869. if ($container_comments==1){
  870. $htmlCode .="</div>";
  871. } elseif ($container_comments==2) {
  872. $htmlCode .="</p>";
  873. }
  874. }
  875. if ($asynchronous_fb) {
  876. $tmp = "<script type=\"text/javascript\">".PHP_EOL."//<![CDATA[".PHP_EOL;
  877. if ($autofit){
  878. $tmp.= "function getwfbcom() {".PHP_EOL;
  879. $tmp.= "var efbcom = document.getElementById('".$idrnd."');".PHP_EOL;
  880. $tmp.= "if (efbcom.currentStyle){".PHP_EOL;
  881. $tmp.= " var pl=efbcom.currentStyle['paddingLeft'].replace(/px/,'');".PHP_EOL;
  882. $tmp.= " var pr=efbcom.currentStyle['paddingRight'].replace(/px/,'');".PHP_EOL;
  883. $tmp.= " return efbcom.offsetWidth-pl-pr;".PHP_EOL;
  884. $tmp.= "} else {".PHP_EOL;
  885. $tmp.= " var pl=window.getComputedStyle(efbcom,null).getPropertyValue('padding-left' ).replace(/px/,'');".PHP_EOL;
  886. $tmp.= " var pr=window.getComputedStyle(efbcom,null).getPropertyValue('padding-right').replace(/px/,'');".PHP_EOL;
  887. $tmp.= " return efbcom.offsetWidth-pl-pr;";
  888. $tmp.= "}}".PHP_EOL;
  889. $tmp.= "var tagfbcom = '<fb:comments href=\"$url\" num_posts=\"$number_comments\" width=\"'+getwfbcom()+'\" colorscheme=\"$box_color\"></fb:comments>';";
  890. } else {
  891. $tmp.= "var tagfbcom = '<fb:comments href=\"$url\" num_posts=\"$number_comments\" width=\"$width\" colorscheme=\"$box_color\"></fb:comments>';";
  892. }
  893. $tmp.= "document.write(tagfbcom); ".PHP_EOL."//]]> ".PHP_EOL."</script>";
  894. } else {
  895. $tmp = "<fb:comments href=\"$url\" num_posts=\"$number_comments\" width=\"$width\" colorscheme=\"$box_color\"></fb:comments>";
  896. if ($autofit){
  897. $tmps= "function autofitfbcom() {";
  898. $tmps.= "var efbcom = document.getElementById('".$idrnd."');";
  899. $tmps.= "if (efbcom.currentStyle){";
  900. $tmps.= "var pl=efbcom.currentStyle['paddingLeft'].replace(/px/,'');";
  901. $tmps.= "var pr=efbcom.currentStyle['paddingRight'].replace(/px/,'');";
  902. $tmps.= "var wfbcom=efbcom.offsetWidth-pl-pr;";
  903. $tmps.= "try {efbcom.firstChild.setAttribute('width',wfbcom);}";
  904. $tmps.= "catch(e) {efbcom.firstChild.width=wfbcom+'px';}";
  905. $tmps.= "} else {";
  906. $tmps.= "var pl=window.getComputedStyle(efbcom,null).getPropertyValue('padding-left' ).replace(/px/,'');";
  907. $tmps.= "var pr=window.getComputedStyle(efbcom,null).getPropertyValue('padding-right').replace(/px/,'');";
  908. $tmps.= "efbcom.childNodes[0].setAttribute('width',efbcom.offsetWidth-pl-pr);".PHP_EOL;
  909. $tmps.= "}}";
  910. $tmps.= "autofitfbcom();";
  911. $tmp .= "<script type=\"text/javascript\">".PHP_EOL."//<![CDATA[".PHP_EOL.$tmps.PHP_EOL."//]]> ".PHP_EOL."</script>".PHP_EOL;
  912. }
  913. }
  914. $htmlCode .= $tmp;
  915. if ($container_comments==1){
  916. $htmlCode .="</div>";
  917. } elseif ($container_comments==2) {
  918. $htmlCode .="</p>";
  919. }
  920. return $htmlCode;
  921. }
  922. private function getPlugInButtonsHTML($params, $article, $url, $title, $view, &$text) {
  923. $idrnd = rand();
  924. $document = & JFactory::getDocument();
  925. $category_tobe_excluded = $this->params->get('category_tobe_excluded_buttons', '' );
  926. $content_tobe_excluded = $this->params->get('content_tobe_excluded_buttons', '' );
  927. $excludedContentList = @explode ( ",", $content_tobe_excluded );
  928. if ($article->id!=null) {
  929. if ( in_array ( $article->id, $excludedContentList )) {
  930. return;
  931. }
  932. if (is_array($category_tobe_excluded ) && in_array ( $article->catid, $category_tobe_excluded )) {
  933. return;
  934. }
  935. } else {
  936. if (is_array($category_tobe_excluded ) && in_array ( JRequest::getCmd('id'), $category_tobe_excluded )) return;
  937. }
  938. $enable_like = $this->params->get( 'enable_like');
  939. $enable_share = $this->params->get( 'enable_share');
  940. $enable_twitter = $this->params->get( 'enable_twitter');
  941. $enable_google = $this->params->get( 'enable_google');
  942. $enable_in = $this->params->get( 'enable_in');
  943. $enable_pint = $this->params->get( 'enable_pint');
  944. $enable_fb_photo = $this->params->get( 'enable_fb_photo');
  945. $asynchronous_fb = $this->params->get( 'asynchronous_fb',0);
  946. $weight = array(
  947. 'like' => $this->params->get( 'weight_like'),
  948. 'share' => $this->params->get( 'weight_share'),
  949. 'twitter' => $this->params->get( 'weight_twitter'),
  950. 'google' => $this->params->get( 'weight_google'),
  951. 'in' => $this->params->get( 'weight_in'),
  952. 'pint' => $this->params->get( 'weight_pint')
  953. );
  954. asort($weight);
  955. $container_buttons = $this->params->get( 'container_buttons','1');
  956. $css_buttons = $this->params->get( 'css_buttons','height:auto;margi-top:4px;');
  957. if ($css_buttons!="") { $css_buttons="style=\"$css_buttons\""; }
  958. $htmlCode = '';
  959. $code_like = '';
  960. $code_share = '';
  961. $code_twitter = '';
  962. $code_google = '';
  963. $code_in = '';
  964. $code_pint = '';
  965. $code_fb_photo= '';
  966. if ($container_buttons==1){
  967. $htmlCode ="<div class=\"cmp_buttons_container\" $css_buttons>";
  968. } elseif ($container_buttons==2) {
  969. $htmlCode ="<p class=\"cmp_buttons_container\" $css_buttons>";
  970. }
  971. //FB like button
  972. if ($enable_like == 1) {
  973. $layout_style = $this->params->get( 'layout_style','button_count');
  974. $show_faces = $this->params->get('show_faces');
  975. if ($show_faces == 1) {
  976. $show_faces = "true";
  977. } else {
  978. $show_faces = "false";
  979. }
  980. $width_like = $this->params->get( 'width_like');
  981. $css_like = $this->params->get( 'css_like','float:left;margin:10px;');
  982. if ($css_like!="") { $css_like="style=\"$css_like\""; }
  983. $container_like = $this->params->get( 'container_like','1');
  984. $send = $this->params->get( 'send','1');
  985. if ($send == 2) {
  986. $standalone=1;
  987. } else {
  988. $standalone=0;
  989. if ($send == 1) {
  990. $send = "true";
  991. } else {
  992. $send = "false";
  993. }
  994. }
  995. $verb_to_display = $this->params->get( 'verb_to_display','1');
  996. if ($verb_to_display == 1) {
  997. $verb_to_display = "like";
  998. } else {
  999. $verb_to_display = "recommend";
  1000. }
  1001. $font = $this->params->get( 'font');
  1002. $color_scheme = $this->params->get( 'color_scheme','light');
  1003. if ($this->_fb == 1) {
  1004. $code_like .= "<div id=\"fb-root\"></div>";
  1005. }
  1006. if ($standalone==1){
  1007. $tmp = "<fb:send href=\"$url\" font=\"$font\" colorscheme=\"$color_scheme\"></fb:send>";
  1008. if ($container_like==1){
  1009. $code_like .="<div class=\"cmp_send_container\" $css_like>$tmp</div>";
  1010. } elseif ($container_like==2) {
  1011. $code_like .="<p class=\"cmp_send_container\" $css_like>$tmp</p>";
  1012. } else {
  1013. $code_like .=$tmp;
  1014. }
  1015. }
  1016. $tmp = "<fb:like href=\"$url\" layout=\"$layout_style\" show_faces=\"$show_faces\" send=\"$send\" width=\"$width_like\" action=\"$verb_to_display\" font=\"$font\" colorscheme=\"$color_scheme\"></fb:like>";
  1017. if ($asynchronous_fb) {
  1018. $tmp = "<script type=\"text/javascript\">".PHP_EOL."//<![CDATA[".PHP_EOL."document.write('".$tmp."'); ".PHP_EOL."//]]> ".PHP_EOL."</script>";
  1019. } else {
  1020. $tmp = $tmp.PHP_EOL;
  1021. }
  1022. if ($container_like==1){
  1023. $code_like .="<div class=\"cmp_like_container\" $css_like>$tmp</div>";
  1024. } elseif ($container_like==2) {
  1025. $code_like .="<p class=\"cmp_like_container\" $css_like>$tmp</p>";
  1026. } else {
  1027. $code_like .=$tmp;
  1028. }
  1029. }
  1030. //Twitter button
  1031. if ($enable_twitter == 1) {
  1032. if ($this->params->get('auto_language')) {
  1033. $language_twitter = substr(JFactory::getLanguage()->getTag(), 0, 2);
  1034. } else {
  1035. $language_twitter = $this->params->get('language_twitter','en');
  1036. }
  1037. $data_via_twitter = $this->params->get( 'data_via_twitter');
  1038. $data_related_twitter= $this->params->get( 'data_related_twitter');
  1039. $show_count_twitter = $this->params->get( 'show_count_twitter','horizontal');
  1040. $hashtags_twitter = $this->params->get( 'hashtags_twitter','');
  1041. $asynchronous_twitter= $this->params->get( 'asynchronous_twitter','0');
  1042. $datasize_twitter = $this->params->get( 'datasize_twitter','medium');
  1043. $container_twitter = $this->params->get( 'container_twitter','1');
  1044. $css_twitter = $this->params->get( 'css_twitter','float:right;margin:10px;');
  1045. $asynchronous_twitter= $this->params->get( 'asynchronous_twitter',0);
  1046. if ($language_twitter!="en"){$language_twitter="data-lang=\"$language_twitter\"";} else {$language_twitter='';}
  1047. if ($data_via_twitter!=""){$data_via_twitter="data-via=\"$data_via_twitter\"";} else {$data_via_twitter='';}
  1048. if ($data_related_twitter!=""){$data_related_twitter="data-related=\"$data_related_twitter\"";} else {$data_related_twitter='';}
  1049. if ($hashtags_twitter!="") { $hashtags_twitter="data-hashtags=\"$hashtags_twitter\""; }
  1050. if ($datasize_twitter!="") { $datasize_twitter="data-size=\"$datasize_twitter\""; }
  1051. if ($css_twitter!="") { $css_twitter="style=\"$css_twitter\""; }
  1052. $tmp = "<a href=\"//twitter.com/share\" class=\"twitter-share-button\" ";
  1053. $tmp.= "$language_twitter $data_via_twitter $hashtags_twitter $data_related_twitter ";
  1054. $tmp.= "data-url=\"$url\" ";
  1055. $tmp.= "data-text=\"$title\" ";
  1056. $tmp.= "data-count=\"$show_count_twitter\">Tweet</a>";
  1057. if ($asynchronous_twitter) {
  1058. $tmp = "<script type=\"text/javascript\">".PHP_EOL."//<![CDATA[".PHP_EOL."document.write('".$tmp."'); ".PHP_EOL."//]]> ".PHP_EOL."</script>";
  1059. } else {
  1060. $tmp = $tmp.PHP_EOL;
  1061. }
  1062. if ($container_twitter==1){
  1063. $code_twitter .="<div class=\"cmp_twitter_container\" $css_twitter>$tmp</div>";
  1064. } elseif

Large files files are truncated, but you can click here to view the full file