10 require_once(
'ChSoundsCmts.php');
11 require_once(
'ChSoundsSearch.php');
26 parent::__construct(
'ch_sounds_view');
28 $this->iProfileId = &$oShared->_iProfileId;
30 $this->oModule = $oShared;
31 $this->oTemplate = $oShared->_oTemplate;
32 $this->oConfig = $oShared->_oConfig;
33 $this->oDb = $oShared->_oDb;
35 $this->oTemplate->addCss(array(
'view.css',
'search.css'));
37 new ChWsbViews(
'ch_' . $this->oConfig->getUri(), $this->aFileInfo[
'medID']);
43 $sMainPrefix = $this->oConfig->getMainPrefix();
47 $aButton =
$oSubscription->getButton($this->iProfileId, $sMainPrefix,
'', (
int)$this->aFileInfo[
'medID']);
50 $aReplacement = array(
51 'favorited' => $this->aFileInfo[
'favorited'] ==
false ?
'' :
'favorited',
52 'featured' => (
int)$this->aFileInfo[
'Featured'],
56 'moduleUrl' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri(),
57 'fileUri' => $this->aFileInfo[
'medUri'],
58 'iViewer' => $this->iProfileId,
59 'ID' => (
int)$this->aFileInfo[
'medID'],
60 'Owner' => (
int)$this->aFileInfo[
'medProfId'],
61 'OwnerName' => $this->aFileInfo[
'NickName'],
62 'AlbumUri' => $this->aFileInfo[
'albumUri'],
63 'sbs_' . $sMainPrefix .
'_title' => $aButton[
'title'],
64 'sbs_' . $sMainPrefix .
'_script' => $aButton[
'script'],
65 'shareCpt' => $this->oModule->isAllowedShare($this->aFileInfo) ?
_t(
'_Share') :
'',
66 'downloadCpt' => $this->oModule->isAllowedDownload($this->aFileInfo) ?
_t(
'_Download') :
'',
68 if (
isAdmin($this->iProfileId)) {
69 $sMsg = $aReplacement[
'featured'] > 0 ?
'un' :
'';
70 $aReplacement[
'featuredCpt'] =
_t(
'_' . $sMainPrefix .
'_action_' .
$sMsg .
'feature');
72 if ($this->oModule->isAllowedApprove($this->aFileInfo))
76 if ($this->aFileInfo[
'Approved'] ==
'approved')
81 $aReplacement[
'approvedCpt'] =
_t(
'_' . $sMainPrefix .
'_admin_' .
$sMsg .
'activate');
82 $aReplacement[
'approvedAct'] = $iAppr;
85 $aReplacement[
'repostCpt'] = $aReplacement[
'repostScript'] =
'';
89 $aReplacement[
'repostCpt'] =
_t(
'_Repost');
90 $aReplacement[
'repostScript'] =
ChWsbService::call(
'wall',
'get_repost_js_click', array($this->iProfileId, $sMainPrefix,
'add', (
int)$this->aFileInfo[
'medID']));
93 $sActionsList =
$GLOBALS[
'oFunctions']->genObjectsActions($aReplacement, $sMainPrefix);
94 if(is_null($sActionsList))
97 return $sCode . $sActionsList;
102 return $this->oTemplate->getFileAuthor($this->aFileInfo);
107 $oAlbum =
new ChWsbAlbums($this->oConfig->getMainPrefix());
108 $aAlbum = $oAlbum->getAlbumInfo(array(
'fileId' => $this->aFileInfo[
'albumId']));
109 return array($this->oSearch->displayAlbumUnit($aAlbum), array(), array(),
false);
114 $this->oSearch->clearFilters(array(
'activeStatus',
'albumType',
'allow_view',
'album_status'), array(
'albumsObjects',
'albums'));
115 $bLike =
getParam(
'useLikeOperator');
116 if ($bLike !=
'on') {
117 $aRel = array($this->aFileInfo[
'medTitle'], $this->aFileInfo[
'medDesc'], $this->aFileInfo[
'medTags'], $this->aFileInfo[
'Categories']);
119 if (!
empty($sKeywords)) {
120 $this->oSearch->aCurrent[
'restriction'][
'keyword'] = array(
121 'value' => $sKeywords,
123 'operator' =>
'against'
127 $sKeywords = $this->aFileInfo[
'medTitle'].
' '.$this->aFileInfo[
'medTags'];
128 $aWords = explode(
' ', $sKeywords);
129 foreach (array_unique($aWords)
as $iKey => $sValue) {
130 if (strlen($sValue) > 2) {
131 $this->oSearch->aCurrent[
'restriction'][
'keyword'.$iKey] = array(
132 'value' => trim(addslashes($sValue)),
134 'operator' =>
'against'
139 $this->oSearch->aCurrent[
'restriction'][
'id'] = array(
140 'value' => $this->aFileInfo[
'medID'],
141 'field' => $this->oSearch->aCurrent[
'ident'],
143 'paramName' =>
'fileID'
145 $this->oSearch->aCurrent[
'sorting'] =
'score';
146 $iLimit = (int)$this->oConfig->getGlParam(
'number_related');
147 $iLimit = $iLimit == 0 ? 2 : $iLimit;
149 $this->oSearch->aCurrent[
'paginate'][
'perPage'] = $iLimit;
150 $sCode = $this->oSearch->displayResultBlock();
151 $aBottomMenu = array();
153 if ($this->oSearch->aCurrent[
'paginate'][
'totalNum'] > 0) {
155 $aBottomMenu = $this->oSearch->getBottomMenu(
'category', 0, $this->aFileInfo[
'Categories']);
158 return array(
$sCode, array(), $aBottomMenu, $bWrap);
163 $this->oTemplate->addCss(
'cmts.css');
165 $oCmtsView =
new ChSoundsCmts(
'ch_' . $this->oConfig->getUri(), $this->aFileInfo[
'medID']);
167 if(!$oCmtsView->isEnabled())
170 return $oCmtsView->getCommentsFirst();
175 $this->aFileInfo[
'favCount'] = $this->oDb->getFavoritesCount($this->aFileInfo[
'medID']);
176 $sCode = $this->oTemplate->getViewFile($this->aFileInfo);
177 return array(
$sCode, array(), array(),
false);
182 return $this->oTemplate->getFileInfoMain($this->aFileInfo);
187 if(!$this->oModule->isAllowedShare($this->aFileInfo))
190 $sUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'view/' . $this->aFileInfo[
'medUri'];
191 $sTitle = $this->aFileInfo[
'medTitle'];
195 return array(
$sCode, array(), array(),
false);