PageRenderTime 47ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/libraries/sourcecoast/easyTags.php

https://bitbucket.org/pastor399/newcastleunifc
PHP | 1409 lines | 1239 code | 159 blank | 11 comment | 322 complexity | 9dd52143631c2b0cb877172d66107b71 MD5 | raw file
  1. <?php
  2. /**
  3. * @package SourceCoast Extensions (JFBConnect, JLinked)
  4. * @copyright (C) 2009-2013 by Source Coast - All rights reserved
  5. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
  6. */
  7. // Check to ensure this file is included in Joomla!
  8. defined('_JEXEC') or die('Restricted access');
  9. jimport('sourcecoast.utilities');
  10. class SCEasyTags
  11. {
  12. /*
  13. * Determines if the Easy-Tag can be rendered. If it can, then remove the render key
  14. */
  15. static function cannotRenderEasyTag(&$easyTag, $renderKey)
  16. {
  17. $key1 = 'key=' . $renderKey . ' ';
  18. $key2 = 'key=' . $renderKey;
  19. $renderKeyCheck = strtolower($easyTag);
  20. $containsKey = strpos($renderKeyCheck, 'key=') !== false;
  21. $missingKey1 = strpos($renderKeyCheck, $key1) === false;
  22. $missingKey2 = SCStringUtilities::endswith($renderKeyCheck, $key2) == false;
  23. $cannotRender = ($renderKey != '' && $missingKey1 && $missingKey2) ||
  24. ($renderKey == '' && $containsKey && $missingKey1 && $missingKey2);
  25. if (!$cannotRender && $renderKey != '')
  26. {
  27. $easyTag = str_replace($key1, '', $easyTag);
  28. $easyTag = str_replace($key2, '', $easyTag);
  29. $easyTag = SCStringUtilities::trimNBSP($easyTag);
  30. }
  31. return $cannotRender;
  32. }
  33. static function _splitIntoTagParameters($paramList)
  34. {
  35. $params = explode(' ', $paramList);
  36. $count = count($params);
  37. for ($i = 0; $i < $count; $i++)
  38. {
  39. $params[$i] = str_replace('"', '', $params[$i]);
  40. if (strpos($params[$i], '=') === false && $i > 0)
  41. {
  42. $previousIndex = SCEasyTags::_findPreviousParameter($params, $i - 1);
  43. //Combine this with previous entry and space
  44. $combinedParamValue = $params[$previousIndex] . ' ' . $params[$i];
  45. $params[$previousIndex] = $combinedParamValue;
  46. unset($params[$i]);
  47. }
  48. }
  49. return $params;
  50. }
  51. static function _findPreviousParameter($params, $i)
  52. {
  53. for ($index = $i; $index >= 0; $index--)
  54. {
  55. if (isset($params[$index]))
  56. return $index;
  57. }
  58. return 0;
  59. }
  60. static $jLinkedLoginCSSIncluded = false;
  61. static function getJLinkedLogin($paramList)
  62. {
  63. $buttonHtml = '';
  64. $showLogoutButton = '';
  65. $buttonSize = '';
  66. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  67. foreach ($params as $param)
  68. {
  69. if ($param != null)
  70. {
  71. $paramValues = explode('=', $param, 2);
  72. if (count($paramValues) == 2) //[0] name [1] value
  73. {
  74. $paramValues[0] = strtolower(trim($paramValues[0]));
  75. $paramValues[1] = trim($paramValues[1]);
  76. $paramValues[1] = trim($paramValues[1], ' '); //trim email address was not working
  77. switch ($paramValues[0])
  78. {
  79. case 'logout':
  80. $showLogoutButton = $paramValues[1];
  81. break;
  82. case 'size':
  83. $buttonSize = ' ' . $paramValues[1];
  84. break;
  85. }
  86. }
  87. }
  88. }
  89. $jLinkedLibrary = JLinkedApiLibrary::getInstance();
  90. $user = JFactory::getUser();
  91. if ($user->guest) // Only show login button if user isn't logged in (no remapping for now)
  92. {
  93. $lang = JFactory::getLanguage();
  94. $lang->load('com_jlinked');
  95. $loginText = JText::_('COM_JLINKED_LOGIN_USING_LINKEDIN');
  96. if (!self::$jLinkedLoginCSSIncluded)
  97. {
  98. self::$jLinkedLoginCSSIncluded = true;
  99. $buttonHtml .= '<link rel="stylesheet" href="' . JURI::base() . 'components/com_jlinked/assets/jlinked.css" type="text/css" />';
  100. }
  101. $buttonHtml .= '<div class="jLinkedLogin"><a href="javascript:void(0)" onclick="jlinked.login.login();"><span class="jlinkedButton' . $buttonSize . '"></span><span class="jlinkedLoginButton' . $buttonSize . '">' . $loginText . '</span></a></div>';
  102. } else
  103. {
  104. if ($showLogoutButton == '1' || $showLogoutButton == 'true')
  105. {
  106. $buttonHtml .= $jLinkedLibrary->getLogoutButton();
  107. }
  108. }
  109. return $buttonHtml;
  110. }
  111. static function getJLinkedApply($paramList)
  112. {
  113. $companyId = ''; //ID or Name required
  114. $companyName = ''; //ID or Name required
  115. $recipientEmail = ''; //required
  116. $jobTitle = ''; //required
  117. $jobLocation = '';
  118. $companyLogo = '';
  119. $themeColor = '';
  120. $requirePhoneNumber = '';
  121. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  122. foreach ($params as $param)
  123. {
  124. if ($param != null)
  125. {
  126. $paramValues = explode('=', $param, 2);
  127. if (count($paramValues) == 2) //[0] name [1] value
  128. {
  129. $paramValues[0] = strtolower(trim($paramValues[0]));
  130. $paramValues[1] = trim($paramValues[1]);
  131. $paramValues[1] = trim($paramValues[1], ' '); //trim email address was not working
  132. switch ($paramValues[0])
  133. {
  134. case 'companyid':
  135. $companyId = $paramValues[1];
  136. break;
  137. case 'companyname':
  138. $companyName = $paramValues[1];
  139. break;
  140. case 'email':
  141. $recipientEmail = $paramValues[1];
  142. break;
  143. case 'jobtitle':
  144. $jobTitle = $paramValues[1];
  145. break;
  146. case 'joblocation':
  147. $jobLocation = $paramValues[1];
  148. break;
  149. case 'logo':
  150. $companyLogo = $paramValues[1];
  151. break;
  152. case 'themecolor':
  153. $themeColor = $paramValues[1];
  154. break;
  155. case 'phone':
  156. $requirePhoneNumber = strtolower($paramValues[1]);
  157. break;
  158. }
  159. }
  160. }
  161. }
  162. $tagButtonText = '<div class="jlinkedApply">';
  163. $tagButtonText .= '<script type="IN/Apply"';
  164. if ($companyId)
  165. $tagButtonText .= ' data-companyid="' . $companyId . '"';
  166. if ($companyName)
  167. $tagButtonText .= ' data-companyname="' . $companyName . '"';
  168. if ($recipientEmail)
  169. $tagButtonText .= ' data-email="' . $recipientEmail . '"';
  170. if ($jobTitle)
  171. $tagButtonText .= ' data-jobtitle="' . $jobTitle . '"';
  172. if ($jobLocation)
  173. $tagButtonText .= ' data-joblocation="' . $jobLocation . '"';
  174. if ($companyLogo)
  175. $tagButtonText .= ' data-logo="' . $companyLogo . '"';
  176. if ($themeColor)
  177. $tagButtonText .= ' data-themecolor="' . $themeColor . '"';
  178. if ($requirePhoneNumber == 'true' || $requirePhoneNumber == '1')
  179. $tagButtonText .= ' data-phone="required"';
  180. $tagButtonText .= '></script></div>';
  181. return $tagButtonText;
  182. }
  183. static function getJLinkedShare($paramList)
  184. {
  185. $url = '';
  186. $countMode = '';
  187. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  188. foreach ($params as $param)
  189. {
  190. if ($param != null)
  191. {
  192. $paramValues = explode('=', $param, 2);
  193. if (count($paramValues) == 2) //[0] name [1] value
  194. {
  195. $paramValues[0] = strtolower(trim($paramValues[0]));
  196. $paramValues[1] = trim($paramValues[1]);
  197. switch ($paramValues[0])
  198. {
  199. case 'href':
  200. case 'url': //DEPRECATED 3/6/12
  201. $url = $paramValues[1];
  202. break;
  203. case 'counter':
  204. $countMode = $paramValues[1];
  205. break;
  206. }
  207. }
  208. }
  209. }
  210. if (!$url)
  211. $url = SCSocialUtilities::getStrippedUrl();
  212. $tagButtonText = '<div class="jlinkedShare">';
  213. $tagButtonText .= '<script type="IN/Share"';
  214. if ($url)
  215. $tagButtonText .= ' data-url="' . $url . '"';
  216. if ($countMode && ($countMode == 'top' || $countMode == 'right'))
  217. $tagButtonText .= ' data-counter="' . $countMode . '"';
  218. $tagButtonText .= '></script></div>';
  219. return $tagButtonText;
  220. }
  221. static function getJLinkedMember($paramList)
  222. {
  223. $url = '';
  224. $displayMode = '';
  225. $displayBehavior = '';
  226. $displayText = '';
  227. $showConnections = '';
  228. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  229. foreach ($params as $param)
  230. {
  231. if ($param != null)
  232. {
  233. $paramValues = explode('=', $param, 2);
  234. if (count($paramValues) == 2) //[0] name [1] value
  235. {
  236. $paramValues[0] = strtolower(trim($paramValues[0]));
  237. $paramValues[1] = trim($paramValues[1]);
  238. switch ($paramValues[0])
  239. {
  240. case 'href':
  241. case 'url': //DEPRECATED 3/6/12
  242. $url = $paramValues[1];
  243. break;
  244. case 'display_mode':
  245. $displayMode = $paramValues[1];
  246. break;
  247. case 'display_behavior':
  248. $displayBehavior = $paramValues[1];
  249. break;
  250. case 'display_text':
  251. $displayText = $paramValues[1];
  252. break;
  253. case 'related':
  254. $showConnections = strtolower(($paramValues[1]));
  255. break;
  256. }
  257. }
  258. }
  259. }
  260. $tagButtonText = '<div class="jlinkedMember"><style type="text/css">.IN-canvas-member iframe{left:20px !important; top:135px !important;}</style>';
  261. $tagButtonText .= '<span class="IN-canvas-member"><script type="IN/MemberProfile"';
  262. if ($url)
  263. $tagButtonText .= ' data-id="' . $url . '"';
  264. if ($showConnections == 'false' || $showConnections == '0')
  265. $tagButtonText .= ' data-related="false"';
  266. if ($displayMode == 'inline')
  267. $tagButtonText .= ' data-format="inline"';
  268. else if ($displayMode == 'icon_name')
  269. {
  270. $tagButtonText .= ' data-format="' . $displayBehavior . '"';
  271. $tagButtonText .= ' data-text="' . $displayText . '"';
  272. } else if ($displayMode == 'icon')
  273. {
  274. $tagButtonText .= ' data-format="' . $displayBehavior . '"';
  275. }
  276. $tagButtonText .= '></script></span></div>';
  277. return $tagButtonText;
  278. }
  279. static function getJLinkedCompanyInsider($paramList)
  280. {
  281. $companyId = '';
  282. $showInNetwork = '';
  283. $showNewHires = '';
  284. $showPromotions = '';
  285. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  286. foreach ($params as $param)
  287. {
  288. if ($param != null)
  289. {
  290. $paramValues = explode('=', $param, 2);
  291. if (count($paramValues) == 2) //[0] name [1] value
  292. {
  293. $paramValues[0] = strtolower(trim($paramValues[0]));
  294. $paramValues[1] = trim($paramValues[1]);
  295. switch ($paramValues[0])
  296. {
  297. case 'companyid':
  298. $companyId = $paramValues[1];
  299. break;
  300. case 'in_network':
  301. $showInNetwork = strtolower($paramValues[1]);
  302. break;
  303. case 'new_hires':
  304. $showNewHires = strtolower($paramValues[1]);
  305. break;
  306. case 'promotions_changes':
  307. $showPromotions = strtolower($paramValues[1]);
  308. break;
  309. }
  310. }
  311. }
  312. }
  313. $tagButtonText = '<div class="jlinkedCompanyInsider">';
  314. $tagButtonText .= '<script type="IN/CompanyInsider"';
  315. if ($companyId)
  316. $tagButtonText .= ' data-id="' . $companyId . '"';
  317. $modules = array();
  318. if ($showInNetwork == '1' || $showInNetwork == 'true')
  319. $modules[] = 'innetwork';
  320. if ($showNewHires == '1' || $showNewHires == 'true')
  321. $modules[] = 'newhires';
  322. if ($showPromotions == '1' || $showPromotions == 'true')
  323. $modules[] = 'jobchanges';
  324. if (count($modules) > 0)
  325. $tagButtonText .= ' data-modules="' . implode(',', $modules) . '"';
  326. $tagButtonText .= '></script></div>';
  327. return $tagButtonText;
  328. }
  329. static function getJLinkedCompanyProfile($paramList)
  330. {
  331. $companyId = '';
  332. $displayMode = '';
  333. $displayBehavior = '';
  334. $displayText = '';
  335. $showConnections = '';
  336. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  337. foreach ($params as $param)
  338. {
  339. if ($param != null)
  340. {
  341. $paramValues = explode('=', $param, 2);
  342. if (count($paramValues) == 2) //[0] name [1] value
  343. {
  344. $paramValues[0] = strtolower(trim($paramValues[0]));
  345. $paramValues[1] = trim($paramValues[1]);
  346. switch ($paramValues[0])
  347. {
  348. case 'companyid':
  349. $companyId = $paramValues[1];
  350. break;
  351. case 'display_mode':
  352. $displayMode = $paramValues[1];
  353. break;
  354. case 'display_behavior':
  355. $displayBehavior = $paramValues[1];
  356. break;
  357. case 'display_text':
  358. $displayText = $paramValues[1];
  359. break;
  360. case 'related':
  361. $showConnections = strtolower(($paramValues[1]));
  362. break;
  363. }
  364. }
  365. }
  366. }
  367. $tagButtonText = '<div class="jlinkedCompanyProfile"><style type="text/css">.IN-canvas-company iframe{left:20px !important; top:135px !important;}</style>';
  368. $tagButtonText .= '<span class="IN-canvas-company"><script type="IN/CompanyProfile"';
  369. if ($companyId)
  370. $tagButtonText .= ' data-id="' . $companyId . '"';
  371. if ($showConnections == 'false' || $showConnections == '0')
  372. $tagButtonText .= ' data-related="false"';
  373. if ($displayMode == 'inline')
  374. $tagButtonText .= ' data-format="inline"';
  375. else if ($displayMode == 'icon_name')
  376. {
  377. $tagButtonText .= ' data-format="' . $displayBehavior . '"';
  378. $tagButtonText .= ' data-text="' . $displayText . '"';
  379. } else if ($displayMode == 'icon')
  380. {
  381. $tagButtonText .= ' data-format="' . $displayBehavior . '"';
  382. }
  383. $tagButtonText .= '></script></span></div>';
  384. return $tagButtonText;
  385. }
  386. static function getJLinkedRecommend($paramList)
  387. {
  388. $companyId = '';
  389. $productId = '';
  390. $countMode = '';
  391. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  392. foreach ($params as $param)
  393. {
  394. if ($param != null)
  395. {
  396. $paramValues = explode('=', $param, 2);
  397. if (count($paramValues) == 2) //[0] name [1] value
  398. {
  399. $paramValues[0] = strtolower(trim($paramValues[0]));
  400. $paramValues[1] = trim($paramValues[1]);
  401. switch ($paramValues[0])
  402. {
  403. case 'companyid':
  404. $companyId = $paramValues[1];
  405. break;
  406. case 'productid':
  407. $productId = $paramValues[1];
  408. break;
  409. case 'counter':
  410. $countMode = $paramValues[1];
  411. break;
  412. }
  413. }
  414. }
  415. }
  416. $tagButtonText = '<div class="jlinkedRecommend">';
  417. $tagButtonText .= '<script type="IN/RecommendProduct"';
  418. if ($companyId)
  419. $tagButtonText .= ' data-company="' . $companyId . '"';
  420. if ($productId)
  421. $tagButtonText .= ' data-product="' . $productId . '"';
  422. if ($countMode && ($countMode == 'top' || $countMode == 'right'))
  423. $tagButtonText .= ' data-counter="' . $countMode . '"';
  424. $tagButtonText .= '></script></div>';
  425. return $tagButtonText;
  426. }
  427. static function getJLinkedJobs($paramList)
  428. {
  429. $companyId = ''; //optional
  430. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  431. foreach ($params as $param)
  432. {
  433. if ($param != null)
  434. {
  435. $paramValues = explode('=', $param, 2);
  436. if (count($paramValues) == 2) //[0] name [1] value
  437. {
  438. $paramValues[0] = strtolower(trim($paramValues[0]));
  439. $paramValues[1] = trim($paramValues[1]);
  440. $paramValues[1] = trim($paramValues[1], ' '); //trim email address was not working
  441. switch ($paramValues[0])
  442. {
  443. case 'companyid':
  444. $companyId = $paramValues[1];
  445. break;
  446. }
  447. }
  448. }
  449. }
  450. $tagButtonText = '<div class="jlinkedJobs">';
  451. $tagButtonText .= '<script type="IN/JYMBII"';
  452. if ($companyId)
  453. $tagButtonText .= ' data-companyid="' . $companyId . '"';
  454. $tagButtonText .= ' data-format="inline"';
  455. $tagButtonText .= '></script></div>';
  456. return $tagButtonText;
  457. }
  458. static function getJLinkedFollowCompany($paramList)
  459. {
  460. $companyId = '';
  461. $countMode = '';
  462. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  463. foreach ($params as $param)
  464. {
  465. if ($param != null)
  466. {
  467. $paramValues = explode('=', $param, 2);
  468. if (count($paramValues) == 2) //[0] name [1] value
  469. {
  470. $paramValues[0] = strtolower(trim($paramValues[0]));
  471. $paramValues[1] = trim($paramValues[1]);
  472. switch ($paramValues[0])
  473. {
  474. case 'companyid':
  475. $companyId = $paramValues[1];
  476. break;
  477. case 'counter':
  478. $countMode = $paramValues[1];
  479. break;
  480. }
  481. }
  482. }
  483. }
  484. $tagButtonText = '<div class="jlinkedFollowCompany">';
  485. $tagButtonText .= '<script type="IN/FollowCompany"';
  486. if ($companyId)
  487. $tagButtonText .= ' data-id="' . $companyId . '"';
  488. if ($countMode && ($countMode == 'top' || $countMode == 'right' || $countMode == 'none'))
  489. $tagButtonText .= ' data-counter="' . $countMode . '"';
  490. else
  491. $tagButtonText .= ' data-counter="none"';
  492. $tagButtonText .= '></script></div>';
  493. return $tagButtonText;
  494. }
  495. static function getSCTwitterShare($paramList)
  496. {
  497. $url = '';
  498. $dataCount = '';
  499. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  500. foreach ($params as $param)
  501. {
  502. if ($param != null)
  503. {
  504. $paramValues = explode('=', $param, 2);
  505. if (count($paramValues) == 2) //[0] name [1] value
  506. {
  507. $paramValues[0] = strtolower(trim($paramValues[0]));
  508. $paramValues[1] = trim($paramValues[1]);
  509. switch ($paramValues[0])
  510. {
  511. case 'href':
  512. case 'url': //DEPRECATED 3/6/12
  513. $url = $paramValues[1];
  514. break;
  515. case 'data_count':
  516. $dataCount = $paramValues[1];
  517. break;
  518. }
  519. }
  520. }
  521. }
  522. if (!$url)
  523. $url = SCSocialUtilities::getStrippedUrl();
  524. $tagButtonText = '<div class="sc_twittershare">';
  525. $tagButtonText .= '<a href="http://twitter.com/share" class="twitter-share-button" ';
  526. if ($url)
  527. $tagButtonText .= 'data-url="' . $url . '"';
  528. if ($dataCount == 'horizontal' || $dataCount == 'vertical' || $dataCount == 'none')
  529. $tagButtonText .= ' data-count="' . $dataCount . '"';
  530. $tagButtonText .= '>Tweet</a></div>';
  531. return $tagButtonText;
  532. }
  533. static function getSCGPlusOne($paramList)
  534. {
  535. $url = '';
  536. $annotation = '';
  537. $size = '';
  538. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  539. foreach ($params as $param)
  540. {
  541. if ($param != null)
  542. {
  543. $paramValues = explode('=', $param, 2);
  544. if (count($paramValues) == 2) //[0] name [1] value
  545. {
  546. $paramValues[0] = strtolower(trim($paramValues[0]));
  547. $paramValues[1] = trim($paramValues[1]);
  548. switch ($paramValues[0])
  549. {
  550. case 'href':
  551. case 'url': //DEPRECATED 3/6/12
  552. $url = $paramValues[1];
  553. break;
  554. case 'annotation':
  555. $annotation = $paramValues[1];
  556. break;
  557. case 'size':
  558. $size = $paramValues[1];
  559. break;
  560. }
  561. }
  562. }
  563. }
  564. if (!$url)
  565. $url = SCSocialUtilities::getStrippedUrl();
  566. $tagButtonText = '<div class="sc_gplusone"><g:plusone';
  567. if ($size)
  568. $tagButtonText .= ' size="' . $size . '"';
  569. if ($annotation)
  570. $tagButtonText .= ' annotation="' . $annotation . '"';
  571. if ($url)
  572. $tagButtonText .= ' href="' . $url . '"';
  573. $tagButtonText .= '></g:plusone></div>';
  574. return $tagButtonText;
  575. }
  576. static function getJFBCLike($paramList)
  577. {
  578. $url = '';
  579. $buttonStyle = '';
  580. $showFaces = '';
  581. $showSendButton = '';
  582. $width = '';
  583. $verbToDisplay = '';
  584. $font = '';
  585. $colorScheme = '';
  586. $ref = '';
  587. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  588. foreach ($params as $param)
  589. {
  590. if ($param != null)
  591. {
  592. $paramValues = explode('=', $param, 2);
  593. if (count($paramValues) == 2) //[0] name [1] value
  594. {
  595. $paramValues[0] = strtolower(trim($paramValues[0]));
  596. $paramValues[1] = trim($paramValues[1]);
  597. switch ($paramValues[0])
  598. {
  599. case 'href':
  600. case 'url': //DEPRECATED 3/6/12
  601. $url = $paramValues[1];
  602. break;
  603. case 'layout':
  604. $buttonStyle = $paramValues[1];
  605. break;
  606. case 'show_faces':
  607. $showFaces = strtolower($paramValues[1]);
  608. break;
  609. case 'show_send_button':
  610. $showSendButton = strtolower($paramValues[1]);
  611. break;
  612. case 'width':
  613. $width = $paramValues[1];
  614. break;
  615. case 'action':
  616. $verbToDisplay = $paramValues[1];
  617. break;
  618. case 'font':
  619. $font = $paramValues[1];
  620. break;
  621. case 'colorscheme':
  622. $colorScheme = $paramValues[1];
  623. break;
  624. case 'ref':
  625. $ref = $paramValues[1];
  626. break;
  627. }
  628. }
  629. }
  630. }
  631. if (!$url)
  632. $url = SCSocialUtilities::getStrippedUrl();
  633. $likeButtonText = '<div class="jfbclike"><div class="fb-like" data-href="' . $url . '"';
  634. if ($showFaces == "false" || $showFaces == "0")
  635. $likeButtonText .= ' data-show-faces="false"';
  636. else
  637. $likeButtonText .= ' data-show-faces="true"';
  638. if ($showSendButton == "false" || $showSendButton == "0")
  639. $likeButtonText .= ' data-send="false"';
  640. else
  641. $likeButtonText .= ' data-send="true"';
  642. if ($buttonStyle)
  643. $likeButtonText .= ' data-layout="' . $buttonStyle . '"';
  644. if ($width)
  645. $likeButtonText .= ' data-width="' . $width . '"';
  646. if ($verbToDisplay)
  647. $likeButtonText .= ' data-action="' . $verbToDisplay . '"';
  648. if ($font)
  649. $likeButtonText .= ' data-font="' . $font . '"';
  650. if ($colorScheme)
  651. $likeButtonText .= ' data-colorscheme="' . $colorScheme . '"';
  652. if ($ref)
  653. $likeButtonText .= ' data-ref="' . $ref .'"';
  654. $likeButtonText .= '></div></div>';
  655. return $likeButtonText;
  656. }
  657. static function getJFBCLogin($paramList)
  658. {
  659. $buttonSize = 'medium';
  660. $showFaces = '';
  661. $showLogoutButton = '';
  662. $maxRows = '';
  663. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  664. foreach ($params as $param)
  665. {
  666. if ($param != null)
  667. {
  668. $paramValues = explode('=', $param, 2);
  669. if (count($paramValues) == 2) //[0] name [1] value
  670. {
  671. $paramValues[0] = strtolower(trim($paramValues[0]));
  672. $paramValues[1] = trim($paramValues[1]);
  673. switch ($paramValues[0])
  674. {
  675. case 'size':
  676. $buttonSize = $paramValues[1];
  677. break;
  678. case 'logout':
  679. $showLogoutButton = $paramValues[1];
  680. break;
  681. case 'show_faces':
  682. $showFaces = $paramValues[1];
  683. break;
  684. case 'max_rows':
  685. $maxRows = $paramValues[1];
  686. break;
  687. }
  688. }
  689. }
  690. }
  691. $jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
  692. $user = JFactory::getUser();
  693. if ($user->guest) // Only show login button if user isn't logged in (no remapping for now)
  694. $fbLogin = $jfbcLibrary->getLoginButton($buttonSize, $showFaces, $maxRows);
  695. else
  696. {
  697. $fbLogin = ""; // return blank for registered users
  698. if ($showLogoutButton == '1' || $showLogoutButton == 'true')
  699. $fbLogin = $jfbcLibrary->getLogoutButton();
  700. }
  701. return '<div class="jfbclogin">' . $fbLogin . '</div>';
  702. }
  703. static function getJFBCSend($paramList)
  704. {
  705. $url = '';
  706. $font = '';
  707. $colorScheme = '';
  708. $ref = '';
  709. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  710. foreach ($params as $param)
  711. {
  712. if ($param != null)
  713. {
  714. $paramValues = explode('=', $param, 2);
  715. if (count($paramValues) == 2) //[0] name [1] value
  716. {
  717. $paramValues[0] = strtolower(trim($paramValues[0]));
  718. $paramValues[1] = trim($paramValues[1]);
  719. switch ($paramValues[0])
  720. {
  721. case 'href':
  722. case 'url': //DEPRECATED 3/6/12
  723. $url = $paramValues[1];
  724. break;
  725. case 'font':
  726. $font = $paramValues[1];
  727. break;
  728. case 'colorscheme':
  729. $colorScheme = $paramValues[1];
  730. break;
  731. case 'ref' :
  732. $ref = $paramValues[1];
  733. break;
  734. }
  735. }
  736. }
  737. }
  738. if (!$url)
  739. $url = SCSocialUtilities::getStrippedUrl();
  740. $sendButtonText = '<div class="jfbcsend"><div class="fb-send" data-href="' . $url . '"';
  741. if ($font)
  742. $sendButtonText .= ' data-font="' . $font . '"';
  743. if ($colorScheme)
  744. $sendButtonText .= ' data-colorscheme="' . $colorScheme . '"';
  745. if ($ref)
  746. $sendButtonText .= ' data-ref="' . $ref . '"';
  747. $sendButtonText .= '></div></div>';
  748. return $sendButtonText;
  749. }
  750. static function getJFBCComments($paramList)
  751. {
  752. $href = '';
  753. $width = '';
  754. $numComments = '';
  755. $colorscheme = '';
  756. $mobile = '';
  757. $orderBy = '';
  758. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  759. foreach ($params as $param)
  760. {
  761. if ($param != null)
  762. {
  763. $paramValues = explode('=', $param, 2);
  764. if (count($paramValues) == 2) //[0] name [1] value
  765. {
  766. $paramValues[0] = strtolower(trim($paramValues[0]));
  767. $paramValues[1] = trim($paramValues[1]);
  768. switch ($paramValues[0])
  769. {
  770. case 'href':
  771. $href = $paramValues[1];
  772. break;
  773. case 'width':
  774. $width = $paramValues[1];
  775. break;
  776. case 'num_posts':
  777. $numComments = $paramValues[1];
  778. break;
  779. case 'colorscheme':
  780. $colorscheme = $paramValues[1];
  781. break;
  782. case 'mobile':
  783. $mobile = $paramValues[1];
  784. break;
  785. case 'order_by':
  786. $orderBy = $paramValues[1];
  787. break;
  788. }
  789. }
  790. }
  791. }
  792. $commentString = '<div class="jfbccomments"><div class="fb-comments"';
  793. if ($href)
  794. $commentString .= ' data-href="' . $href . '"';
  795. else
  796. {
  797. $url = SCSocialUtilities::getStrippedUrl();
  798. $commentString .= ' data-href="' . $url . '"';
  799. }
  800. if ($width)
  801. $commentString .= ' data-width="' . $width . '"';
  802. if ($numComments || $numComments == "0")
  803. $commentString .= ' data-num-posts="' . $numComments . '"';
  804. if ($colorscheme)
  805. $commentString .= ' data-colorscheme="' . $colorscheme . '"';
  806. if ($mobile == "false" || $mobile == "0")
  807. $commentString .= ' data-mobile="false"';
  808. if ($orderBy == 'social' || $orderBy == 'reverse_time' || $orderBy == 'time')
  809. $commentString .= ' data-order-by="' . $orderBy . '"';
  810. $commentString .= '></div></div>';
  811. return $commentString;
  812. }
  813. static function getJFBCCommentsCount($paramList)
  814. {
  815. $href = '';
  816. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  817. foreach ($params as $param)
  818. {
  819. if ($param != null)
  820. {
  821. $paramValues = explode('=', $param, 2);
  822. if (count($paramValues) == 2) //[0] name [1] value
  823. {
  824. $paramValues[0] = strtolower(trim($paramValues[0]));
  825. $paramValues[1] = trim($paramValues[1]);
  826. switch ($paramValues[0])
  827. {
  828. case 'href':
  829. $href = $paramValues[1];
  830. break;
  831. }
  832. }
  833. }
  834. }
  835. //Get the Comments Count string
  836. $tagString = '<div class="fb-comments-count"';
  837. if ($href)
  838. $tagString .= ' data-href="' . $href . '"';
  839. else
  840. {
  841. $url = SCSocialUtilities::getStrippedUrl();
  842. $tagString .= ' data-href="' . $url . '"';
  843. }
  844. $tagString .= '></div>';
  845. $lang = JFactory::getLanguage();
  846. $lang->load('com_jfbconnect');
  847. $commentString = '<div class="jfbccomments_count">';
  848. $commentString .= JText::sprintf('COM_JFBCONNECT_COMMENTS_COUNT', $tagString);
  849. $commentString .= '</div>';
  850. return $commentString;
  851. }
  852. static function getJFBCFan($paramList)
  853. {
  854. $height = '';
  855. $width = '';
  856. $colorScheme = '';
  857. $href = '';
  858. $showFaces = '';
  859. $stream = '';
  860. $header = '';
  861. $borderColor = '';
  862. $forceWall = '';
  863. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  864. foreach ($params as $param)
  865. {
  866. if ($param != null)
  867. {
  868. $paramValues = explode('=', $param, 2);
  869. if (count($paramValues) == 2) //[0] name [1] value
  870. {
  871. $paramValues[0] = strtolower(trim($paramValues[0]));
  872. $paramValues[1] = trim($paramValues[1]);
  873. switch ($paramValues[0])
  874. {
  875. case 'height': //Not shown - http://developers.facebook.com/docs/reference/plugins/like-box/
  876. $height = $paramValues[1];
  877. break;
  878. case 'width':
  879. $width = $paramValues[1];
  880. break;
  881. case 'colorscheme':
  882. $colorScheme = $paramValues[1];
  883. break;
  884. case 'href':
  885. $href = $paramValues[1];
  886. break;
  887. case 'show_faces':
  888. $showFaces = $paramValues[1];
  889. break;
  890. case 'stream':
  891. $stream = $paramValues[1];
  892. break;
  893. case 'header':
  894. $header = $paramValues[1];
  895. break;
  896. case 'border_color':
  897. $borderColor = $paramValues[1];
  898. break;
  899. case 'force_wall':
  900. $forceWall = $paramValues[1];
  901. break;
  902. }
  903. }
  904. }
  905. }
  906. $fanString = '<div class="jfbcfan"><div class="fb-like-box"';
  907. if ($showFaces == "false" || $showFaces == "0")
  908. $fanString .= ' data-show-faces="false"';
  909. else
  910. $fanString .= ' data-show-faces="true"';
  911. if ($header == "false" || $header == "0")
  912. $fanString .= ' data-header="false"';
  913. else
  914. $fanString .= ' data-header="true"';
  915. if ($stream == "false" || $stream == "0")
  916. $fanString .= ' data-stream="false"';
  917. else
  918. $fanString .= ' data-stream="true"';
  919. if ($forceWall == "false" || $forceWall == "0")
  920. $fanString .= ' data-force-wall="false"';
  921. else
  922. $fanString .= ' data-force-wall="true"';
  923. if ($width)
  924. $fanString .= ' data-width="' . $width . '"';
  925. if ($height)
  926. $fanString .= ' data-height="' . $height . '"';
  927. if ($href)
  928. $fanString .= ' data-href="' . $href . '"';
  929. if ($colorScheme)
  930. $fanString .= ' data-colorscheme="' . $colorScheme . '"';
  931. if ($borderColor)
  932. $fanString .= ' data-border-color="' . $borderColor . '"';
  933. $fanString .= '></div></div>';
  934. return $fanString;
  935. }
  936. static function getJFBCFeed($paramList)
  937. {
  938. $site = '';
  939. $height = '';
  940. $width = '';
  941. $colorScheme = '';
  942. $font = '';
  943. $recommendations = '';
  944. $header = '';
  945. $linkTarget = '';
  946. $filter = '';
  947. $action = '';
  948. $ref = '';
  949. $max_age = '';
  950. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  951. foreach ($params as $param)
  952. {
  953. if ($param != null)
  954. {
  955. $paramValues = explode('=', $param, 2);
  956. if (count($paramValues) == 2) //[0] name [1] value
  957. {
  958. $paramValues[0] = strtolower(trim($paramValues[0]));
  959. $paramValues[1] = trim($paramValues[1]);
  960. switch ($paramValues[0])
  961. {
  962. case 'site':
  963. $site = $paramValues[1];
  964. break;
  965. case 'height':
  966. $height = $paramValues[1];
  967. break;
  968. case 'width':
  969. $width = $paramValues[1];
  970. break;
  971. case 'colorscheme':
  972. $colorScheme = $paramValues[1];
  973. break;
  974. case 'font':
  975. $font = $paramValues[1];
  976. break;
  977. case 'recommendations':
  978. $recommendations = $paramValues[1];
  979. break;
  980. case 'header':
  981. $header = $paramValues[1];
  982. break;
  983. case 'link_target':
  984. $linkTarget = $paramValues[1];
  985. break;
  986. case 'action':
  987. $action = $paramValues[1];
  988. break;
  989. case 'filter':
  990. $filter = $paramValues[1];
  991. break;
  992. case 'ref':
  993. $ref = $paramValues[1];
  994. break;
  995. case 'max_age':
  996. $max_age = $paramValues[1];
  997. break;
  998. }
  999. }
  1000. }
  1001. }
  1002. $feedString = '<div class="jfbcfeed"><div class="fb-activity"';
  1003. if ($recommendations == "false" || $recommendations == "0")
  1004. $feedString .= ' data-recommendations="false"';
  1005. else
  1006. $feedString .= ' data-recommendations="true"';
  1007. if ($header == "false" || $header == "0")
  1008. $feedString .= ' data-header="false"';
  1009. else
  1010. $feedString .= ' data-header="true"';
  1011. if ($width)
  1012. $feedString .= ' data-width="' . $width . '"';
  1013. if ($height)
  1014. $feedString .= ' data-height="' . $height . '"';
  1015. if ($site)
  1016. $feedString .= ' data-site="' . $site . '"';
  1017. if ($colorScheme)
  1018. $feedString .= ' data-colorscheme="' . $colorScheme . '"';
  1019. if ($font)
  1020. $feedString .= ' data-font="' . $font . '"';
  1021. if ($linkTarget)
  1022. $feedString .= ' data-linktarget="' . $linkTarget . '"';
  1023. if ($action)
  1024. $feedString .= ' data-action="' . $action . '"';
  1025. if ($filter)
  1026. $feedString .= ' data-filter="' . $filter . '"';
  1027. if ($ref)
  1028. $feedString .= ' data-ref="' . $ref . '"';
  1029. if ($max_age)
  1030. $feedString .= ' data-max-age="' . $max_age . '"';
  1031. $feedString .= '></div></div>';
  1032. return $feedString;
  1033. }
  1034. static function getJFBCFriends($paramList)
  1035. {
  1036. $href = '';
  1037. $width = '';
  1038. $maxRows = '';
  1039. $colorScheme = '';
  1040. $size = '';
  1041. $action = '';
  1042. $showCount = '';
  1043. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  1044. foreach ($params as $param)
  1045. {
  1046. if ($param != null)
  1047. {
  1048. $paramValues = explode('=', $param, 2);
  1049. if (count($paramValues) == 2) //[0] name [1] value
  1050. {
  1051. $paramValues[0] = strtolower(trim($paramValues[0]));
  1052. $paramValues[1] = trim($paramValues[1]);
  1053. switch ($paramValues[0])
  1054. {
  1055. case 'href':
  1056. $href = $paramValues[1];
  1057. break;
  1058. case 'width':
  1059. $width = $paramValues[1];
  1060. break;
  1061. case 'max_rows':
  1062. $maxRows = $paramValues[1];
  1063. break;
  1064. case 'colorscheme':
  1065. $colorScheme = $paramValues[1];
  1066. break;
  1067. case 'size':
  1068. $size = $paramValues[1];
  1069. break;
  1070. case 'action':
  1071. $action = $paramValues[1];
  1072. break;
  1073. case 'show_count':
  1074. $showCount = $paramValues[1];
  1075. break;
  1076. }
  1077. }
  1078. }
  1079. }
  1080. $friendsString = '<div class="jfbcfriends"><div class="fb-facepile"';
  1081. if ($href)
  1082. $friendsString .= ' data-href="' . $href . '"';
  1083. if ($width)
  1084. $friendsString .= ' data-width="' . $width . '"';
  1085. if ($maxRows)
  1086. $friendsString .= ' data-max-rows="' . $maxRows . '"';
  1087. if ($colorScheme)
  1088. $friendsString .= ' data-colorscheme="' . $colorScheme . '"';
  1089. if ($size)
  1090. $friendsString .= ' data-size="' . $size . '"';
  1091. if ($showCount == '0' || $showCount == 'false')
  1092. $friendsString .= ' data-show-count="false"';
  1093. else
  1094. $friendsString .= ' data-show-count="true"';
  1095. if ($action)
  1096. $friendsString .= ' data-action="' . $action .'"';
  1097. $friendsString .= '></div></div>';
  1098. return $friendsString;
  1099. }
  1100. static function getJFBCRecommendationsBar($paramList)
  1101. {
  1102. $href = '';
  1103. $trigger = '';
  1104. $readTime = '';
  1105. $action = '';
  1106. $side = '';
  1107. $site = '';
  1108. $ref = '';
  1109. $numRecommendations = '';
  1110. $maxAge = '';
  1111. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  1112. foreach ($params as $param)
  1113. {
  1114. if ($param != null)
  1115. {
  1116. $paramValues = explode('=', $param, 2);
  1117. if (count($paramValues) == 2) //[0] name [1] value
  1118. {
  1119. $paramValues[0] = strtolower(trim($paramValues[0]));
  1120. $paramValues[1] = trim($paramValues[1]);
  1121. switch ($paramValues[0])
  1122. {
  1123. case 'href':
  1124. $href = $paramValues[1];
  1125. break;
  1126. case 'trigger':
  1127. $trigger = $paramValues[1];
  1128. break;
  1129. case 'read_time':
  1130. $readTime = $paramValues[1];
  1131. break;
  1132. case 'action' :
  1133. $action = $paramValues[1];
  1134. break;
  1135. case 'side' :
  1136. $side = $paramValues[1];
  1137. break;
  1138. case 'site':
  1139. $site = $paramValues[1];
  1140. break;
  1141. case 'ref':
  1142. $ref = $paramValues[1];
  1143. break;
  1144. case 'num_recommendations':
  1145. $numRecommendations = $paramValues[1];
  1146. break;
  1147. case 'max_age':
  1148. $maxAge = $paramValues[1];
  1149. break;
  1150. }
  1151. }
  1152. }
  1153. }
  1154. if (!$href)
  1155. $href = SCSocialUtilities::getStrippedUrl();
  1156. $tagString = '<div class="jfbcrecommendationsbar"><div class="fb-recommendations-bar"';
  1157. $tagString .= ' data-href="' . $href . '"';
  1158. if ($trigger)
  1159. $tagString .= ' data-trigger="' . $trigger . '"';
  1160. if ($readTime)
  1161. $tagString .= ' data-read-time="' . $readTime . '"';
  1162. if ($action)
  1163. $tagString .= ' data-action="' . $action . '"';
  1164. if ($side)
  1165. $tagString .= ' data-side="' . $side . '"';
  1166. if ($site)
  1167. $tagString .= ' data-site="' . $site . '"';
  1168. if ($ref)
  1169. $tagString .= ' data-ref="' . $ref . '"';
  1170. if ($numRecommendations)
  1171. $tagString .= ' data-num-recommendations="' . $numRecommendations . '"';
  1172. if ($maxAge)
  1173. $tagString .= ' data-max-age="' . $maxAge . '"';
  1174. $tagString .= '></div></div>';
  1175. return $tagString;
  1176. }
  1177. static function getJFBCRecommendations($paramList)
  1178. {
  1179. $site = '';
  1180. $width = '';
  1181. $height = '';
  1182. $header = '';
  1183. $colorScheme = '';
  1184. $font = '';
  1185. $linkTarget = '';
  1186. $action = '';
  1187. $ref = '';
  1188. $max_age = '';
  1189. $params = SCEasyTags::_splitIntoTagParameters($paramList);
  1190. foreach ($params as $param)
  1191. {
  1192. if ($param != null)
  1193. {
  1194. $paramValues = explode('=', $param, 2);
  1195. if (count($paramValues) == 2) //[0] name [1] value
  1196. {
  1197. $paramValues[0] = strtolower(trim($paramValues[0]));
  1198. $paramValues[1] = trim($paramValues[1]);
  1199. switch ($paramValues[0])
  1200. {
  1201. case 'site':
  1202. $site = $paramValues[1];
  1203. break;
  1204. case 'width':
  1205. $width = $paramValues[1];
  1206. break;
  1207. case 'height':
  1208. $height = $paramValues[1];
  1209. break;
  1210. case 'colorscheme' :
  1211. $colorScheme = $paramValues[1];
  1212. break;
  1213. case 'header' :
  1214. $header = $paramValues[1];
  1215. break;
  1216. case 'font':
  1217. $font = $paramValues[1];
  1218. break;
  1219. case 'link_target':
  1220. $linkTarget = $paramValues[1];
  1221. break;
  1222. case 'action':
  1223. $action = $paramValues[1];
  1224. break;
  1225. case 'ref':
  1226. $ref = $paramValues[1];
  1227. break;
  1228. case 'max_age':
  1229. $max_age = $paramValues[1];
  1230. break;
  1231. }
  1232. }
  1233. }
  1234. }
  1235. $recString = '<div class="jfbcrecommendations"><div class="fb-recommendations"';
  1236. if ($header == "false" || $header == "0")
  1237. $recString .= ' data-header="false"';
  1238. else
  1239. $recString .= ' data-header="true"';
  1240. if ($site)
  1241. $recString .= ' data-site="' . $site . '"';
  1242. if ($width)
  1243. $recString .= ' data-width="' . $width . '"';
  1244. if ($height)
  1245. $recString .= ' data-height="' . $height . '"';
  1246. if ($colorScheme)
  1247. $recString .= ' data-colorscheme="' . $colorScheme . '"';
  1248. if ($font)
  1249. $recString .= ' data-font="' . $font . '"';
  1250. if ($linkTarget)