Cheetah
ChSoundsPageView.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbPageView');
9 
10 require_once('ChSoundsCmts.php');
11 require_once('ChSoundsSearch.php');
12 
14 {
17 
18  var $oModule;
20  var $oConfig;
21  var $oDb;
22  var $oSearch;
23 
24  function __construct (&$oShared, &$aFileInfo)
25  {
26  parent::__construct('ch_sounds_view');
27  $this->aFileInfo = $aFileInfo;
28  $this->iProfileId = &$oShared->_iProfileId;
29 
30  $this->oModule = $oShared;
31  $this->oTemplate = $oShared->_oTemplate;
32  $this->oConfig = $oShared->_oConfig;
33  $this->oDb = $oShared->_oDb;
34  $this->oSearch = new ChSoundsSearch();
35  $this->oTemplate->addCss(array('view.css', 'search.css'));
36  ch_import ('ChWsbViews');
37  new ChWsbViews('ch_' . $this->oConfig->getUri(), $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  'favorited' => $this->aFileInfo['favorited'] == false ? '' : 'favorited',
52  'featured' => (int)$this->aFileInfo['Featured'],
53  'featuredCpt' => '',
54  'approvedCpt' => '',
55  'approvedAct' => '',
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') : '',
67  );
68  if (isAdmin($this->iProfileId)) {
69  $sMsg = $aReplacement['featured'] > 0 ? 'un' : '';
70  $aReplacement['featuredCpt'] = _t('_' . $sMainPrefix . '_action_' . $sMsg . 'feature');
71  }
72  if ($this->oModule->isAllowedApprove($this->aFileInfo))
73  {
74  $sMsg = '';
75  $iAppr = 1;
76  if ($this->aFileInfo['Approved'] == 'approved')
77  {
78  $sMsg = 'de';
79  $iAppr = 0;
80  }
81  $aReplacement['approvedCpt'] = _t('_' . $sMainPrefix . '_admin_' . $sMsg . 'activate');
82  $aReplacement['approvedAct'] = $iAppr;
83  }
84 
85  $aReplacement['repostCpt'] = $aReplacement['repostScript'] = '';
86  if(ChWsbRequest::serviceExists('wall', 'get_repost_js_click')) {
87  $sCode .= ChWsbService::call('wall', 'get_repost_js_script');
88 
89  $aReplacement['repostCpt'] = _t('_Repost');
90  $aReplacement['repostScript'] = ChWsbService::call('wall', 'get_repost_js_click', array($this->iProfileId, $sMainPrefix, 'add', (int)$this->aFileInfo['medID']));
91  }
92 
93  $sActionsList = $GLOBALS['oFunctions']->genObjectsActions($aReplacement, $sMainPrefix);
94  if(is_null($sActionsList))
95  return '';
96 
97  return $sCode . $sActionsList;
98  }
99 
101  {
102  return $this->oTemplate->getFileAuthor($this->aFileInfo);
103  }
104 
106  {
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);
110  }
111 
113  {
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']);
118  $sKeywords = getRelatedWords($aRel);
119  if (!empty($sKeywords)) {
120  $this->oSearch->aCurrent['restriction']['keyword'] = array(
121  'value' => $sKeywords,
122  'field' => '',
123  'operator' => 'against'
124  );
125  }
126  } else {
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)),
133  'field' => '',
134  'operator' => 'against'
135  );
136  }
137  }
138  }
139  $this->oSearch->aCurrent['restriction']['id'] = array(
140  'value' => $this->aFileInfo['medID'],
141  'field' => $this->oSearch->aCurrent['ident'],
142  'operator' => '<>',
143  'paramName' => 'fileID'
144  );
145  $this->oSearch->aCurrent['sorting'] = 'score';
146  $iLimit = (int)$this->oConfig->getGlParam('number_related');
147  $iLimit = $iLimit == 0 ? 2 : $iLimit;
148 
149  $this->oSearch->aCurrent['paginate']['perPage'] = $iLimit;
150  $sCode = $this->oSearch->displayResultBlock();
151  $aBottomMenu = array();
152  $bWrap = true;
153  if ($this->oSearch->aCurrent['paginate']['totalNum'] > 0) {
154  $sCode = $GLOBALS['oFunctions']->centerContent($sCode, '.sys_file_search_unit');
155  $aBottomMenu = $this->oSearch->getBottomMenu('category', 0, $this->aFileInfo['Categories']);
156  $bWrap = '';
157  }
158  return array($sCode, array(), $aBottomMenu, $bWrap);
159  }
160 
162  {
163  $this->oTemplate->addCss('cmts.css');
164 
165  $oCmtsView = new ChSoundsCmts('ch_' . $this->oConfig->getUri(), $this->aFileInfo['medID']);
166 
167  if(!$oCmtsView->isEnabled())
168  return '';
169 
170  return $oCmtsView->getCommentsFirst();
171  }
172 
174  {
175  $this->aFileInfo['favCount'] = $this->oDb->getFavoritesCount($this->aFileInfo['medID']);
176  $sCode = $this->oTemplate->getViewFile($this->aFileInfo);
177  return array($sCode, array(), array(), false);
178  }
179 
181  {
182  return $this->oTemplate->getFileInfoMain($this->aFileInfo);
183  }
184 
186  {
187  if(!$this->oModule->isAllowedShare($this->aFileInfo))
188  return '';
189 
190  $sUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'view/' . $this->aFileInfo['medUri'];
191  $sTitle = $this->aFileInfo['medTitle'];
192 
193  ch_import('ChTemplSocialSharing');
195  return array($sCode, array(), array(), false);
196  }
197 }
ChSoundsPageView\$oModule
$oModule
Definition: ChSoundsPageView.php:18
ChWsbSocialSharing\getInstance
static getInstance()
Definition: ChWsbSocialSharing.php:50
ChSoundsPageView\__construct
__construct(&$oShared, &$aFileInfo)
Definition: ChSoundsPageView.php:24
ChSoundsPageView\getBlockCode_ViewAlbum
getBlockCode_ViewAlbum()
Definition: ChSoundsPageView.php:105
ChWsbPageView
Definition: ChWsbPageView.php:99
ChWsbRequest\serviceExists
static serviceExists($mixedModule, $sMethod, $sClass="Module")
Definition: ChWsbRequest.php:70
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChSoundsPageView\$oConfig
$oConfig
Definition: ChSoundsPageView.php:20
ChSoundsPageView\$oDb
$oDb
Definition: ChSoundsPageView.php:21
$sUrl
$sUrl
Definition: cart.php:15
php
$sMsg
$sMsg
Definition: actions.inc.php:22
ChWsbSubscription\getInstance
static getInstance()
Definition: ChWsbSubscription.php:67
ChSoundsCmts
Definition: ChSoundsCmts.php:11
isAdmin
isAdmin()
Definition: index.php:649
ChSoundsPageView\$oSearch
$oSearch
Definition: ChSoundsPageView.php:22
ChSoundsPageView\getBlockCode_ActionList
getBlockCode_ActionList()
Definition: ChSoundsPageView.php:40
ChSoundsPageView\getBlockCode_MainFileInfo
getBlockCode_MainFileInfo()
Definition: ChSoundsPageView.php:180
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
$sTitle
$sTitle
Definition: actions.inc.php:13
ChWsbAlbums
Definition: ChWsbAlbums.php:9
ChWsbViews
Definition: ChWsbViews.php:38
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChSoundsPageView\getBlockCode_ViewComments
getBlockCode_ViewComments()
Definition: ChSoundsPageView.php:161
ChSoundsPageView\getBlockCode_SocialSharing
getBlockCode_SocialSharing()
Definition: ChSoundsPageView.php:185
ChSoundsPageView\$oTemplate
$oTemplate
Definition: ChSoundsPageView.php:19
ChSoundsPageView\getBlockCode_RelatedFiles
getBlockCode_RelatedFiles()
Definition: ChSoundsPageView.php:112
ChSoundsSearch
Definition: ChSoundsSearch.php:11
ChSoundsPageView\getBlockCode_ViewFile
getBlockCode_ViewFile()
Definition: ChSoundsPageView.php:173
ChSoundsPageView
Definition: ChSoundsPageView.php:14
getRelatedWords
getRelatedWords(&$aInfo)
Definition: utils.inc.php:1451
ChSoundsPageView\getBlockCode_FileAuthor
getBlockCode_FileAuthor()
Definition: ChSoundsPageView.php:100
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
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChSoundsPageView\$aFileInfo
$aFileInfo
Definition: ChSoundsPageView.php:16
ChSoundsPageView\$iProfileId
$iProfileId
Definition: ChSoundsPageView.php:15
ChWsbPageView\$sCode
$sCode
Definition: ChWsbPageView.php:102
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
$oSubscription
$oSubscription
Definition: notifies.php:28