Cheetah
ChFilesPageView.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbPageView');
9 ch_import('ChWsbViews');
10 
11 require_once('ChFilesCmts.php');
12 require_once('ChFilesSearch.php');
13 
15 {
18 
19  var $oModule;
21  var $oConfig;
22  var $oDb;
23  var $oSearch;
24 
25  function __construct (&$oShared, &$aFileInfo)
26  {
27  parent::__construct('ch_files_view');
28  $this->aFileInfo = $aFileInfo;
29  $this->iProfileId = &$oShared->_iProfileId;
30 
31  $this->oModule = $oShared;
32  $this->oTemplate = $oShared->_oTemplate;
33  $this->oConfig = $oShared->_oConfig;
34  $this->oDb = $oShared->_oDb;
35  $this->oSearch = new ChFilesSearch();
36  $this->oTemplate->addCss('view.css');
37  new ChWsbViews('ch_files', $this->aFileInfo['medID']);
38  }
39 
41  {
42  $sCode = null;
43  $sMainPrefix = $this->oConfig->getMainPrefix();
44 
45  ch_import('ChWsbSubscription');
47  $aButton = $oSubscription->getButton($this->iProfileId, $sMainPrefix, '', (int)$this->aFileInfo['medID']);
48  $sCode .= $oSubscription->getData();
49 
50  $aReplacement = array(
51  'featured' => (int)$this->aFileInfo['Featured'],
52  'featuredCpt' => '',
53  'approvedCpt' => '',
54  'approvedAct' => '',
55  'moduleUrl' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri(),
56  'fileUri' => $this->aFileInfo['medUri'],
57  'extension' => !empty($this->aFileInfo['medExt']) ? '.' . $this->aFileInfo['medExt'] : '',
58  'iViewer' => $this->iProfileId,
59  'favorited' => $this->aFileInfo['favorited'] == false ? '' : 'favorited',
60  'ID' => (int)$this->aFileInfo['medID'],
61  'Owner' => (int)$this->aFileInfo['medProfId'],
62  'OwnerName' => $this->aFileInfo['NickName'],
63  'AlbumUri' => $this->aFileInfo['albumUri'],
64  'sbs_' . $sMainPrefix . '_title' => $aButton['title'],
65  'sbs_' . $sMainPrefix . '_script' => $aButton['script'],
66  'shareCpt' => $this->oModule->isAllowedShare($this->aFileInfo) ? _t('_Share') : '',
67  'downloadCpt' => $this->oModule->isAllowedDownload($this->aFileInfo) ? _t('_Download') : '',
68  );
69  if (isAdmin($this->iProfileId)) {
70  $sMsg = $aReplacement['featured'] > 0 ? 'un' : '';
71  $aReplacement['featuredCpt'] = _t('_' . $sMainPrefix . '_action_' . $sMsg . 'feature');
72  }
73  if ($this->oModule->isAllowedApprove($this->aFileInfo))
74  {
75  $sMsg = '';
76  $iAppr = 1;
77  if ($this->aFileInfo['Approved'] == 'approved')
78  {
79  $sMsg = 'de';
80  $iAppr = 0;
81  }
82  $aReplacement['approvedCpt'] = _t('_' . $sMainPrefix . '_admin_' . $sMsg . 'activate');
83  $aReplacement['approvedAct'] = $iAppr;
84  }
85 
86  $aReplacement['repostCpt'] = $aReplacement['repostScript'] = '';
87  if(ChWsbRequest::serviceExists('wall', 'get_repost_js_click')) {
88  $sCode .= ChWsbService::call('wall', 'get_repost_js_script');
89 
90  $aReplacement['repostCpt'] = _t('_Repost');
91  $aReplacement['repostScript'] = ChWsbService::call('wall', 'get_repost_js_click', array($this->iProfileId, $sMainPrefix, 'add', (int)$this->aFileInfo['medID']));
92  }
93 
94  $sActionsList = $GLOBALS['oFunctions']->genObjectsActions($aReplacement, $sMainPrefix);
95  if(is_null($sActionsList))
96  return '';
97 
98  return $sCode . $sActionsList;
99  }
100 
102  {
103  return $this->oTemplate->getFileInfo($this->aFileInfo);
104  }
105 
107  {
108  $sPref = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri();
109  $sSimpleUrl = $sPref . 'albums/browse/owner/' . $this->aFileInfo['NickName'];
110  $sPaginateUrl = $sPref . 'view/' . $this->aFileInfo['medUri'];
111  return $this->oSearch->getAlbumsBlock(array('owner' => $this->aFileInfo['medProfId']), array(), array('paginate_url' => $sPaginateUrl, 'simple_paginate_url' => $sSimpleUrl));
112  }
113 
115  {
116  $this->oSearch->clearFilters(array('activeStatus', 'albumType', 'allow_view', 'album_status'), array('albumsObjects', 'albums'));
117  $bLike = getParam('useLikeOperator');
118  if ($bLike != 'on') {
119  $aRel = array($this->aFileInfo['medTitle'], $this->aFileInfo['medDesc'], $this->aFileInfo['medTags'], $this->aFileInfo['Categories']);
120  $sKeywords = getRelatedWords($aRel);
121  if (!empty($sKeywords)) {
122  $this->oSearch->aCurrent['restriction']['keyword'] = array(
123  'value' => $sKeywords,
124  'field' => '',
125  'operator' => 'against'
126  );
127  }
128  } else {
129  $sKeywords = $this->aFileInfo['medTitle'].' '.$this->aFileInfo['medTags'];
130  $aWords = explode(' ', $sKeywords);
131  foreach (array_unique($aWords) as $iKey => $sValue) {
132  if (strlen($sValue) > 2) {
133  $this->oSearch->aCurrent['restriction']['keyword'.$iKey] = array(
134  'value' => trim(addslashes($sValue)),
135  'field' => '',
136  'operator' => 'against'
137  );
138  }
139  }
140  }
141  $this->oSearch->aCurrent['join']['icon'] = array(
142  'type' => 'left',
143  'table' => 'ch_files_types',
144  'mainField' => 'Type',
145  'onField' => 'Type',
146  'joinFields' => array('Icon')
147  );
148  $this->oSearch->aCurrent['restriction']['id'] = array(
149  'value' => $this->aFileInfo['medID'],
150  'field' => $this->oSearch->aCurrent['ident'],
151  'operator' => '<>',
152  'paramName' => 'fileID'
153  );
154  $this->oSearch->aCurrent['sorting'] = 'score';
155  $iLimit = (int)$this->oConfig->getGlParam('number_related');
156  $iLimit = $iLimit == 0 ? 2 : $iLimit;
157 
158  $this->oSearch->aCurrent['paginate']['perPage'] = $iLimit;
159  $this->oSearch->aCurrent['view'] = 'short';
160  $sCode = $this->oSearch->displayResultBlock();
161 
162  $aBottomMenu = array();
163  if(strlen($sCode) > 0)
164  $aBottomMenu = $this->oSearch->getBottomMenu('category', 0, $this->aFileInfo['Categories']);
165 
166  return array($sCode, array(), $aBottomMenu, '');
167  }
168 
170  {
171  $this->oTemplate->addCss('cmts.css');
172 
173  $oCmtsView = new ChFilesCmts('ch_files', $this->aFileInfo['medID']);
174  if (!$oCmtsView->isEnabled())
175  return '';
176 
177  return $oCmtsView->getCommentsFirst ();
178  }
179 
181  {
182  $oVotingView = new ChTemplVotingView('ch_files', $this->aFileInfo['medID']);
183  if ($this->aFileInfo['prevItem'] > 0)
184  $aPrev = $this->oDb->getFileInfo(array('fileId'=>$this->aFileInfo['prevItem']), true, array('medUri', 'medTitle'));
185  if ($this->aFileInfo['nextItem'] > 0)
186  $aNext = $this->oDb->getFileInfo(array('fileId'=>$this->aFileInfo['nextItem']), true, array('medUri', 'medTitle'));
187  //icon
188  $sIcon = $this->oDb->getTypeIcon($this->aFileInfo['Type']);
189  if (!$sIcon)
190  $sIcon = 'default.png';
191  $aUnit = array(
192  'pic' => $this->oTemplate->getIconUrl($sIcon),
193  'fileTitle' => $this->aFileInfo['medTitle'],
194  'fileSize' => (int)$this->aFileInfo['medSize'] > 0 ? _t_format_size((int)$this->aFileInfo['medSize']) : 0,
195  'fileExt' => $this->aFileInfo['medExt'],
196  'fileDescription' => nl2br($this->aFileInfo['medDesc']),
197  'rate' => $oVotingView->isEnabled() ? $oVotingView->getBigVoting(1, $this->aFileInfo['Rate']): '',
198  'favInfo' => $this->oDb->getFavoritesCount($this->aFileInfo['medID']),
199  'viewInfo' => $this->aFileInfo['medViews'],
200  'albumUri' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'browse/album/' . $this->aFileInfo['albumUri'] . '/owner/' . $this->aFileInfo['NickName'],
201  'albumCaption' => $this->aFileInfo['albumCaption'],
202  'ch_if:prev' => array(
203  'condition' => $this->aFileInfo['prevItem'] > 0,
204  'content' => array(
205  'linkPrev' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'view/' . $aPrev['medUri'],
206  'titlePrev' => $aPrev['medTitle'],
207  'percent' => $this->aFileInfo['nextItem'] > 0 ? 50 : 100,
208  )
209  ),
210  'ch_if:next' => array(
211  'condition' => $this->aFileInfo['nextItem'] > 0,
212  'content' => array(
213  'linkNext' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'view/' . $aNext['medUri'],
214  'titleNext' => $aNext['medTitle'],
215  'percent' => $this->aFileInfo['prevItem'] > 0 ? 50 : 100,
216  )
217  ),
218  );
219 
220  $sCode = $this->oTemplate->parseHtmlByName('view_unit.html', $aUnit);
221  return array($sCode, array(), array(), false);
222  }
223 
225  {
226  return $this->oTemplate->getFileInfoMain($this->aFileInfo);
227  }
228 
230  {
231  if(!$this->oModule->isAllowedShare($this->aFileInfo))
232  return '';
233 
234  $sUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'view/' . $this->aFileInfo['medUri'];
235  $sTitle = $this->aFileInfo['medTitle'];
236  ch_import('ChTemplSocialSharing');
238  return array($sCode, array(), array(), false);
239  }
240 }
ChFilesPageView\getBlockCode_ActionList
getBlockCode_ActionList()
Definition: ChFilesPageView.php:40
ChWsbSocialSharing\getInstance
static getInstance()
Definition: ChWsbSocialSharing.php:50
ChFilesSearch
Definition: ChFilesSearch.php:11
ChWsbPageView
Definition: ChWsbPageView.php:99
ChWsbRequest\serviceExists
static serviceExists($mixedModule, $sMethod, $sClass="Module")
Definition: ChWsbRequest.php:70
$aUnit
$aUnit
Definition: short_profile_info.php:31
ChFilesCmts
Definition: ChFilesCmts.php:11
ChFilesPageView\$oSearch
$oSearch
Definition: ChFilesPageView.php:23
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$sUrl
$sUrl
Definition: cart.php:15
php
$sMsg
$sMsg
Definition: actions.inc.php:22
ChWsbSubscription\getInstance
static getInstance()
Definition: ChWsbSubscription.php:67
ChFilesPageView\getBlockCode_FileInfo
getBlockCode_FileInfo()
Definition: ChFilesPageView.php:101
_t_format_size
_t_format_size($iBytes, $iPrecision=2)
Definition: languages.inc.php:545
isAdmin
isAdmin()
Definition: index.php:649
ChFilesPageView\getBlockCode_RelatedFiles
getBlockCode_RelatedFiles()
Definition: ChFilesPageView.php:114
ChFilesPageView\getBlockCode_ViewComments
getBlockCode_ViewComments()
Definition: ChFilesPageView.php:169
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
$sTitle
$sTitle
Definition: actions.inc.php:13
ChFilesPageView\getBlockCode_ViewFile
getBlockCode_ViewFile()
Definition: ChFilesPageView.php:180
ChFilesPageView\$oModule
$oModule
Definition: ChFilesPageView.php:19
ChWsbViews
Definition: ChWsbViews.php:38
ChFilesPageView\$oConfig
$oConfig
Definition: ChFilesPageView.php:21
ChFilesPageView\getBlockCode_SocialSharing
getBlockCode_SocialSharing()
Definition: ChFilesPageView.php:229
ChFilesPageView\getBlockCode_LastAlbums
getBlockCode_LastAlbums()
Definition: ChFilesPageView.php:106
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChFilesPageView\$oDb
$oDb
Definition: ChFilesPageView.php:22
ChFilesPageView
Definition: ChFilesPageView.php:15
ChFilesPageView\__construct
__construct(&$oShared, &$aFileInfo)
Definition: ChFilesPageView.php:25
ChFilesPageView\getBlockCode_MainFileInfo
getBlockCode_MainFileInfo()
Definition: ChFilesPageView.php:224
getRelatedWords
getRelatedWords(&$aInfo)
Definition: utils.inc.php:1451
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
ChFilesPageView\$iProfileId
$iProfileId
Definition: ChFilesPageView.php:16
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChFilesPageView\$aFileInfo
$aFileInfo
Definition: ChFilesPageView.php:17
ChFilesPageView\$oTemplate
$oTemplate
Definition: ChFilesPageView.php:20
ChTemplVotingView
Definition: ChTemplVotingView.php:14
ChWsbPageView\$sCode
$sCode
Definition: ChWsbPageView.php:102
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
$oSubscription
$oSubscription
Definition: notifies.php:28