Cheetah
ChWsbSocialSharing.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbSocialSharingQuery');
9 
33 {
34  var $_aSocialButtons = array (); // active social buttons array
35 
39  protected function __construct()
40  {
41  $oQuery = new ChWsbSocialSharingQuery();
42  $this->_aSocialButtons = $oQuery->getActiveButtons();
43  }
44 
50  static public function getInstance()
51  {
52  if (isset($GLOBALS['chWsbClasses']['ChWsbSocialSharing']))
53  return $GLOBALS['chWsbClasses']['ChWsbSocialSharing'];
54 
55  ch_import('ChTemplSocialSharing');
56  $o = new ChTemplSocialSharing();
57 
58  return ($GLOBALS['chWsbClasses']['ChWsbSocialSharing'] = $o);
59  }
60 
61  public function getCode ($sUrl, $sTitle, $aCustomVars = false)
62  {
63  // overrided in template class
64  }
65 
72  protected function _replaceMarkers ($s, $a)
73  {
74  if (empty($s) || empty($a) || !is_array($a))
75  return $s;
76 
77  foreach ($a as $sKey => $sValue)
78  $s = str_replace('{' . $sKey . '}', $sValue, $s);
79 
80  return $s;
81  }
82 
88  protected function _getLocaleFacebook ($sLocale)
89  {
90  $aLocales = $this->_getLocalesFacebook();
91  if (!isset($aLocales[$sLocale]))
92  return '';
93  return $sLocale;
94  }
95 
100  protected function _getLocalesFacebook ()
101  {
102  $oCache = $GLOBALS['MySQL']->getDbCacheObject();
103  $sCacheKey = $GLOBALS['MySQL']->genDbCacheKey('sys_social_sharing_locales_fb');
104  $aData = $oCache->getData($sCacheKey);
105  if (null === $aData) {
106  $sXML = ch_file_get_contents (CH_WSB_URL_ROOT . 'plugins/facebook-php-sdk/FacebookLocales.xml');
107  if (!$sXML)
108  return false;
109  $xmlLocates = new SimpleXMLElement($sXML);
110  $aData = array ();
111  foreach ($xmlLocates->locale as $xmlLocale) {
112  $sLocale = (string)($xmlLocale->codes->code->standard->representation);
113  $aData[$sLocale] = 1;
114  }
115  $oCache->setData ($sCacheKey, $aData);
116  }
117  return $aData;
118  }
119 }
ChWsbSocialSharing\getInstance
static getInstance()
Definition: ChWsbSocialSharing.php:50
ChWsbSocialSharing\$_aSocialButtons
$_aSocialButtons
Definition: ChWsbSocialSharing.php:34
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChWsbSocialSharing
Definition: ChWsbSocialSharing.php:33
$sUrl
$sUrl
Definition: cart.php:15
php
ChWsbSocialSharing\_getLocalesFacebook
_getLocalesFacebook()
Definition: ChWsbSocialSharing.php:100
$oCache
$oCache
Definition: prof.inc.php:10
ChWsbSocialSharing\getCode
getCode($sUrl, $sTitle, $aCustomVars=false)
Definition: ChWsbSocialSharing.php:61
ChWsbSocialSharing\__construct
__construct()
Definition: ChWsbSocialSharing.php:39
ChWsbSocialSharing\_getLocaleFacebook
_getLocaleFacebook($sLocale)
Definition: ChWsbSocialSharing.php:88
$sTitle
$sTitle
Definition: actions.inc.php:13
ChWsbSocialSharing\_replaceMarkers
_replaceMarkers($s, $a)
Definition: ChWsbSocialSharing.php:72
ch_file_get_contents
ch_file_get_contents($sFileUrl, $aParams=array(), $sMethod='get', $aHeaders=array(), &$sHttpCode=null)
Definition: utils.inc.php:1357
$s
$s
Definition: embed.php:13
ChWsbSocialSharingQuery
Definition: ChWsbSocialSharingQuery.php:14
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
$o
$o
Definition: cmd.php:193
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChTemplSocialSharing
Definition: ChTemplSocialSharing.php:14
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10