Cheetah
shared_sites.inc.php
Go to the documentation of this file.
1 <?php
2 
8 require_once(CH_DIRECTORY_PATH_INC . 'db.inc.php');
9 
10 define('SHARED_SITES_TABLE', 'sys_shared_sites');
11 
12 function ch_pre_rawurlencode($sURL) {
13  $sEncoded = '';
14  $iLength = mb_strlen($sURL);
15  for ($i = 0 ; $i < $iLength ; $i++) {
16  $c = mb_substr($sURL, $i, 1);
17  if (ord($c[0]) >= 0 && ord($c[0]) <= 127)
18  $sEncoded .= $c;
19  else
20  $sEncoded .= rawurlencode(mb_substr($sURL, $i, 1));
21  }
22  return $sEncoded;
23 }
24 
25 function getSitesArray ($sLink)
26 {
27  $aSites = $GLOBALS['MySQL']->fromCache ('sys_shared_sites', 'getAllWithKey', "SELECT `ID` as `id`, `URL` as `url`, `Icon` as `icon`, `Name` FROM `" . SHARED_SITES_TABLE . "`", 'Name');
28 
29  $sLink = rawurlencode(ch_pre_rawurlencode($sLink));
30 
31  foreach ($aSites as $sKey => $aValue)
32  $aSites[$sKey]['url'] .= $sLink;
33 
34  return $aSites;
35 }
36 
37 function getSitesHtml ($sLink, $sTitle = false)
38 {
39  if (!$sTitle)
40  $sTitle = _t('_Share');
41  $aSitesPrepare = getSitesArray ($sLink);
42  $sIconsUrl = getTemplateIcon('digg.png');
43  $sIconsUrl = str_replace('digg.png', '', $sIconsUrl);
44  $aSites = array ();
45  foreach ($aSitesPrepare as $k => $r) {
46  $aSites[] = array (
47  'icon' => $sIconsUrl . $r['icon'],
48  'name' => $k,
49  'url' => $r['url'],
50  );
51  }
52 
53  $aVarsContent = array (
54  'ch_repeat:sites' => $aSites,
55  );
56  $aVarsPopup = array (
57  'title' => $sTitle,
58  'content' => $GLOBALS['oSysTemplate']->parseHtmlByName('popup_share.html', $aVarsContent),
59  );
60  return $GLOBALS['oFunctions']->transBox($GLOBALS['oSysTemplate']->parseHtmlByName('popup.html', $aVarsPopup), true);
61 }
php
SHARED_SITES_TABLE
const SHARED_SITES_TABLE
Definition: shared_sites.inc.php:10
getSitesArray
getSitesArray($sLink)
Definition: shared_sites.inc.php:25
getSitesHtml
getSitesHtml($sLink, $sTitle=false)
Definition: shared_sites.inc.php:37
$sTitle
$sTitle
Definition: actions.inc.php:13
getTemplateIcon
getTemplateIcon($sFileName)
Definition: design.inc.php:193
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ch_pre_rawurlencode
ch_pre_rawurlencode($sURL)
Definition: shared_sites.inc.php:12
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10