11 require_once(
'ChFilesCmts.php');
12 require_once(
'ChFilesSearch.php');
27 parent::__construct(
'ch_files_view');
29 $this->iProfileId = &$oShared->_iProfileId;
31 $this->oModule = $oShared;
32 $this->oTemplate = $oShared->_oTemplate;
33 $this->oConfig = $oShared->_oConfig;
34 $this->oDb = $oShared->_oDb;
36 $this->oTemplate->addCss(
'view.css');
37 new ChWsbViews(
'ch_files', $this->aFileInfo[
'medID']);
43 $sMainPrefix = $this->oConfig->getMainPrefix();
47 $aButton =
$oSubscription->getButton($this->iProfileId, $sMainPrefix,
'', (
int)$this->aFileInfo[
'medID']);
50 $aReplacement = array(
51 'featured' => (
int)$this->aFileInfo[
'Featured'],
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') :
'',
69 if (
isAdmin($this->iProfileId)) {
70 $sMsg = $aReplacement[
'featured'] > 0 ?
'un' :
'';
71 $aReplacement[
'featuredCpt'] =
_t(
'_' . $sMainPrefix .
'_action_' .
$sMsg .
'feature');
73 if ($this->oModule->isAllowedApprove($this->aFileInfo))
77 if ($this->aFileInfo[
'Approved'] ==
'approved')
82 $aReplacement[
'approvedCpt'] =
_t(
'_' . $sMainPrefix .
'_admin_' .
$sMsg .
'activate');
83 $aReplacement[
'approvedAct'] = $iAppr;
86 $aReplacement[
'repostCpt'] = $aReplacement[
'repostScript'] =
'';
90 $aReplacement[
'repostCpt'] =
_t(
'_Repost');
91 $aReplacement[
'repostScript'] =
ChWsbService::call(
'wall',
'get_repost_js_click', array($this->iProfileId, $sMainPrefix,
'add', (
int)$this->aFileInfo[
'medID']));
94 $sActionsList =
$GLOBALS[
'oFunctions']->genObjectsActions($aReplacement, $sMainPrefix);
95 if(is_null($sActionsList))
98 return $sCode . $sActionsList;
103 return $this->oTemplate->getFileInfo($this->aFileInfo);
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));
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']);
121 if (!
empty($sKeywords)) {
122 $this->oSearch->aCurrent[
'restriction'][
'keyword'] = array(
123 'value' => $sKeywords,
125 'operator' =>
'against'
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)),
136 'operator' =>
'against'
141 $this->oSearch->aCurrent[
'join'][
'icon'] = array(
143 'table' =>
'ch_files_types',
144 'mainField' =>
'Type',
146 'joinFields' => array(
'Icon')
148 $this->oSearch->aCurrent[
'restriction'][
'id'] = array(
149 'value' => $this->aFileInfo[
'medID'],
150 'field' => $this->oSearch->aCurrent[
'ident'],
152 'paramName' =>
'fileID'
154 $this->oSearch->aCurrent[
'sorting'] =
'score';
155 $iLimit = (int)$this->oConfig->getGlParam(
'number_related');
156 $iLimit = $iLimit == 0 ? 2 : $iLimit;
158 $this->oSearch->aCurrent[
'paginate'][
'perPage'] = $iLimit;
159 $this->oSearch->aCurrent[
'view'] =
'short';
160 $sCode = $this->oSearch->displayResultBlock();
162 $aBottomMenu = array();
164 $aBottomMenu = $this->oSearch->getBottomMenu(
'category', 0, $this->aFileInfo[
'Categories']);
166 return array(
$sCode, array(), $aBottomMenu,
'');
171 $this->oTemplate->addCss(
'cmts.css');
173 $oCmtsView =
new ChFilesCmts(
'ch_files', $this->aFileInfo[
'medID']);
174 if (!$oCmtsView->isEnabled())
177 return $oCmtsView->getCommentsFirst ();
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'));
188 $sIcon = $this->oDb->getTypeIcon($this->aFileInfo[
'Type']);
190 $sIcon =
'default.png';
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,
205 'linkPrev' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'view/' . $aPrev[
'medUri'],
206 'titlePrev' => $aPrev[
'medTitle'],
207 'percent' => $this->aFileInfo[
'nextItem'] > 0 ? 50 : 100,
210 'ch_if:next' => array(
211 'condition' => $this->aFileInfo[
'nextItem'] > 0,
213 'linkNext' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'view/' . $aNext[
'medUri'],
214 'titleNext' => $aNext[
'medTitle'],
215 'percent' => $this->aFileInfo[
'prevItem'] > 0 ? 50 : 100,
220 $sCode = $this->oTemplate->parseHtmlByName(
'view_unit.html',
$aUnit);
221 return array(
$sCode, array(), array(),
false);
226 return $this->oTemplate->getFileInfoMain($this->aFileInfo);
231 if(!$this->oModule->isAllowedShare($this->aFileInfo))
234 $sUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'view/' . $this->aFileInfo[
'medUri'];
235 $sTitle = $this->aFileInfo[
'medTitle'];
238 return array(
$sCode, array(), array(),
false);