Cheetah
ChSitesPageView.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbTwigPageView');
9 ch_import('ChWsbSubscription');
10 
11 require_once('ChSitesCmts.php');
12 
14 {
15  var $_oSites;
16  var $_aSite;
18  var $_oConfig;
19 
20  function __construct(&$oSites, $aSite)
21  {
22  parent::__construct('ch_sites_view', $oSites, $aSite);
23 
24  $this->_oSites = &$oSites;
25  $this->_aSite = $aSite;
26 
27  $this->_oTemplate = $oSites->_oTemplate;
28  $this->_oConfig = $oSites->_oConfig;
29  }
30 
32  {
34 
35  if ($this->_oSites->iOwnerId || $this->_oSites->isAdmin()) {
36  $sCode = '';
37 
38  $aInfo = array(
39  'iViewer' => $this->_oSites->iOwnerId,
40  'ownerID' => (int)$this->_aSite['ownerid'],
41  'ID' => (int)$this->_aSite['id'],
42  'TitleEdit' => $this->_oSites->isAllowedEdit($this->_aSite) ? _t('_ch_sites_action_title_edit') : '',
43  'TitleDelete' => $this->_oSites->isAllowedDelete($this->_aSite) ? _t('_ch_sites_action_title_delete') : '',
44  'TitleShare' => $this->_oSites->isAllowedShare($this->_aSite) ? _t('_Share') : '',
45  'AddToFeatured' => ($this->_oSites->isAllowedMarkAsFeatured($this->_aSite) && (int)$this->_aSite['allowView'] == CH_WSB_PG_ALL) ?
46  ((int)$this->_aSite['featured'] == 1 ? _t('_ch_sites_action_remove_from_featured') : _t('_ch_sites_action_add_to_featured')) : ''
47  );
48 
50  $aButton = $oSubscription->getButton($this->_oSites->iOwnerId, 'ch_sites', '', $this->_aSite['id']);
51  $sCode .= $oSubscription->getData();
52 
53  $aInfo['sbs_sites_title'] = $aButton['title'];
54  $aInfo['sbs_sites_script'] = $aButton['script'];
55 
56  if (!$aInfo['TitleEdit'] && !$aInfo['TitleDelete'] && !$aInfo['TitleShare'] && !$aInfo['AddToFeatured'] && !$aInfo['sbs_sites_title'])
57  return '';
58 
59  if ($aInfo['TitleShare']) {
60  $sUrlSharePopup = CH_WSB_URL_ROOT . $this->_oSites->_oConfig->getBaseUri() . "share_popup/" . $this->_aSite['id'];
61  $sCode .= <<<EOF
62  <script type="text/javascript">
63  function ch_site_show_share_popup ()
64  {
65  if (!$('#ch_sites_share_popup').length) {
66  $('<div id="ch_sites_share_popup" style="display: none;"></div>').prependTo('body');
67  }
68 
69  $('#ch_sites_share_popup').load(
70  '{$sUrlSharePopup}',
71  function() {
72  $(this).dolPopup();
73  }
74  );
75  }
76  </script>
77 EOF;
78  }
79 
80  $aInfo['repostCpt'] = $aInfo['repostScript'] = '';
81  if(ChWsbRequest::serviceExists('wall', 'get_repost_js_click')) {
82  $sCode .= ChWsbService::call('wall', 'get_repost_js_script');
83 
84  $aInfo['repostCpt'] = _t('_Repost');
85  $aInfo['repostScript'] = ChWsbService::call('wall', 'get_repost_js_click', array($this->_oSites->iOwnerId, 'ch_sites', 'add', (int)$this->_aSite['id']));
86  }
87 
88  $aCodeActions = $oFunctions->genObjectsActions($aInfo, 'ch_sites');
89  if(empty($aCodeActions))
90  return '';
91 
92  return $sCode . $aCodeActions;
93  }
94 
95  return '';
96  }
97 
99  {
100  $sContent = $this->_oTemplate->blockInformation($this->_aSite);
101  return array($sContent, array(), array(), false);
102  }
103 
105  {
106  $sSiteUrl = $this->_aSite['url'];
107 
108  $aFile = ChWsbService::call('photos', 'get_photo_array', array($this->_aSite['photo'], 'file'), 'Search');
109  $sImage = $aFile['no_image'] ? '' : $aFile['file'];
110 
111  // BEGIN STW INTEGRATION
112  if (getParam('ch_sites_account_type') != 'No Automated Screenshots') {
113  if ($sImage == '') {
114  $aSTWOptions = array(
115  );
116 
117  ch_sites_import('STW');
118  $sThumbHTML = getThumbnailHTML($sSiteUrl, $aSTWOptions, false, false);
119  }
120  }
121  // END STW INTEGRATION
122 
123  $sVote = '';
124 
125  if (strncasecmp($sSiteUrl, 'http://', 7) !== 0 && strncasecmp($sSiteUrl, 'https://', 8) !== 0)
126  $sSiteUrl = 'http://' . $sSiteUrl;
127 
128  if ($this->_oConfig->isVotesAllowed() &&
129  $this->_oSites->oPrivacy->check('rate',
130  $this->_aSite['id'], $this->_oSites->iOwnerId))
131  {
132  ch_import('ChTemplVotingView');
133  $oVotingView = new ChTemplVotingView('ch_sites', $this->_aSite['id']);
134 
135  if ($oVotingView->isEnabled())
136  $sVote = $oVotingView->getBigVoting();
137  }
138 
139  $sContent = $this->_oTemplate->parseHtmlByName('view_image.html', array(
140  'title' => $this->_aSite['title'],
141  'site_url' => $sSiteUrl,
142  'site_url_view' => $this->_aSite['url'],
143  // BEGIN STW INTEGRATION
144  'ch_if:is_image' => array(
145  'condition' => $sThumbHTML == false,
146  'content' => array('image' => $sImage ? $sImage : $this->_oTemplate->getImageUrl('no-image-thumb.png'))
147  ),
148  'ch_if:is_thumbhtml' => array(
149  'condition' => $sThumbHTML != '',
150  'content' => array('thumbhtml' => $sThumbHTML)
151  ),
152  // END STW INTEGRATION
153  'vote' => $sVote,
154  'view_count' => $this->_aSite['views']
155  ));
156 
157  return array($sContent, array(), array(), false);
158  }
159 
161  {
162  $sContent = $this->_oTemplate->parseHtmlByName('view_description.html', array(
163  'description' => $this->_aSite['description']
164  ));
165 
166  return array($sContent, array(), array(), false);
167  }
168 
170  {
171  if ($this->_oConfig->isCommentsAllowed() && $this->_oSites->oPrivacy->check('comments', $this->_aSite['id'], $this->_oSites->iOwnerId)) {
172  $o = new ChSitesCmts('ch_sites', $this->_aSite['id']);
173 
174  if ($o->isEnabled())
175  return $o->getCommentsFirst();
176  }
177 
178  return '';
179  }
180 
181 }
ChWsbRequest\serviceExists
static serviceExists($mixedModule, $sMethod, $sClass="Module")
Definition: ChWsbRequest.php:70
ChSitesPageView\getBlockCode_ViewInformation
getBlockCode_ViewInformation()
Definition: ChSitesPageView.php:98
ChWsbPageView\load
load()
Definition: ChWsbPageView.php:146
ChSitesPageView\getBlockCode_ViewActions
getBlockCode_ViewActions()
Definition: ChSitesPageView.php:31
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChWsbTwigPageView
Definition: ChWsbTwigPageView.php:14
php
ChWsbSubscription\getInstance
static getInstance()
Definition: ChWsbSubscription.php:67
ChSitesPageView\getBlockCode_ViewDescription
getBlockCode_ViewDescription()
Definition: ChSitesPageView.php:160
ChSitesPageView\getBlockCode_ViewComments
getBlockCode_ViewComments()
Definition: ChSitesPageView.php:169
ChSitesPageView\$_oConfig
$_oConfig
Definition: ChSitesPageView.php:18
$oFunctions
$oFunctions
Definition: ChTemplFunctions.php:20
$aInfo
$aInfo
Definition: constants.inc.php:21
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
type
if(!defined("USER_STATUS_TYPE")) define("USER_STATUS_TYPE" type
Definition: constants.inc.php:13
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
CH_WSB_PG_ALL
const CH_WSB_PG_ALL
Definition: ChWsbPrivacy.php:12
ChSitesPageView\$_aSite
$_aSite
Definition: ChSitesPageView.php:16
ch_sites_import
ch_sites_import($sClassPostfix, $aModuleOverwright=array())
Definition: ChSitesModule.php:8
ChSitesPageView
Definition: ChSitesPageView.php:14
getThumbnailHTML
getThumbnailHTML($sUrl, $aOptions, $sAttribAlt=false, $sAttribClass=false, $sAttribStyle=false)
Definition: ChSitesSTW.php:34
ChSitesCmts
Definition: ChSitesCmts.php:11
ChSitesPageView\__construct
__construct(&$oSites, $aSite)
Definition: ChSitesPageView.php:20
ChSitesPageView\$_oSites
$_oSites
Definition: ChSitesPageView.php:15
ChSitesPageView\getBlockCode_ViewImage
getBlockCode_ViewImage()
Definition: ChSitesPageView.php:104
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
$o
$o
Definition: cmd.php:193
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
ChSitesPageView\$_oTemplate
$_oTemplate
Definition: ChSitesPageView.php:17
ChTemplVotingView
Definition: ChTemplVotingView.php:14
ChWsbPageView\$sCode
$sCode
Definition: ChWsbPageView.php:102
$oSubscription
$oSubscription
Definition: notifies.php:28