Cheetah
ChSoundsSearch.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChTemplSearchResultSharedMedia');
9 
11 {
12  function __construct($sParamName = '', $sParamValue = '', $sParamValue1 = '', $sParamValue2 = '')
13  {
14  parent::__construct('ChSoundsModule');
15  $this->aConstants['linksTempl'] = array(
16  'home' => 'home',
17  'file' => 'view/{uri}',
18  'category' => 'browse/category/{uri}',
19  'browseAll' => 'browse/',
20  'browseUserAll' => 'albums/browse/owner/{uri}',
21  'browseAllTop' => 'browse/top',
22  'tag' => 'browse/tag/{uri}',
23  'album' => 'browse/album/{uri}',
24  'add' => 'browse/my/add'
25  );
26  // main part of aCurrent settings, usual most unique part of every module
27  $aMain = array(
28  'name' => 'ch_sounds',
29  'title' => '_ch_sounds',
30  'table' => 'RayMp3Files'
31  );
32 
33  $this->aCurrent = array_merge($aMain, $this->aCurrent);
34  $this->aCurrent['ownFields'][] = 'Listens';
35  $this->aCurrent['rss']['title'] = _t('_ch_sounds');
36 
37  $this->aAddPartsConfig['favorite']['table'] = 'ch_sounds_favorites';
38  $this->oModule = ChWsbModule::getInstance('ChSoundsModule');
39  $this->oTemplate = &$this->oModule->_oTemplate;
40  $this->aConstants['filesUrl'] = $this->oModule->_oConfig->getFilesUrl();
41  $this->aConstants['filesDir'] = $this->oModule->_oConfig->getFilesPath();
42  $this->aConstants['filesInAlbumCover'] = 12;
43  $this->aConstants['picPostfix'] = $this->oModule->_oConfig->aFilePostfix;
44 
45  $this->aCurrent['restriction']['albumType']['value'] = $this->aCurrent['name'];
46 
47  switch ($sParamName) {
48  case 'calendar':
49  $this->aCurrent['restriction']['calendar-min'] = array('value' => "UNIX_TIMESTAMP('{$sParamValue}-{$sParamValue1}-{$sParamValue2} 00:00:00')", 'field' => 'Date', 'operator' => '>=', 'no_quote_value' => true);
50  $this->aCurrent['restriction']['calendar-max'] = array('value' => "UNIX_TIMESTAMP('{$sParamValue}-{$sParamValue1}-{$sParamValue2} 23:59:59')", 'field' => 'Date', 'operator' => '<=', 'no_quote_value' => true);
51  $this->aCurrent['title'] = _t('_ch_sounds_caption_browse_by_day') . sprintf("%04u-%02u-%02u", $sParamValue, $sParamValue1, $sParamValue2);
52  break;
53  case 'top':
54  $this->aCurrent['sorting'] = 'top';
55  break;
56  case 'popular':
57  $this->aCurrent['sorting'] = 'popular';
58  break;
59  case 'featured':
60  $this->aCurrent['restriction']['featured'] = array(
61  'value'=>'1', 'field'=>'Featured', 'operator'=>'=', 'paramName'=>'ch_sounds_mode'
62  );
63  break;
64  case 'favorited':
65  if (isset($this->aAddPartsConfig['favorite']) && !empty($this->aAddPartsConfig['favorite']) && getLoggedId() != 0) {
66  $this->aCurrent['join']['favorite'] = $this->aAddPartsConfig['favorite'];
67  $this->aCurrent['restriction']['fav'] = array(
68  'value' => getLoggedId(),
69  'field' => $this->aAddPartsConfig['favorite']['userField'],
70  'operator' => '=',
71  'table' => $this->aAddPartsConfig['favorite']['table']
72  );
73  }
74  break;
75  case 'album':
76  $this->aCurrent['sorting'] = 'album_order';
77  $this->aCurrent['restriction']['album'] = array(
78  'value'=>'', 'field'=>'Uri', 'operator'=>'=', 'paramName'=>'albumUri', 'table'=>'sys_albums'
79  );
80  if ($sParamValue1 == 'owner' && strlen($sParamValue2) > 0) {
81  $this->aCurrent['restriction']['owner'] = array(
82  'value'=>$sParamValue2, 'field'=>'NickName', 'operator'=>'=', 'paramName'=>'ownerName', 'table' => 'Profiles'
83  );
84  }
85  break;
86  }
87  }
88 
89  function _getPseud ()
90  {
91  return array(
92  'id' => 'ID',
93  'title' => 'Title',
94  'date' => 'Date',
95  'size' => 'Time',
96  'uri' => 'Uri',
97  'ownerId' => 'Owner',
98  'ownerName' => 'NickName',
99  'view' => 'Listens',
100  'voteTime' => 'gal_date'
101  );
102  }
103 
104  function getImgUrl ($iId, $sImgType = 'browse')
105  {
106  $sImgUrl = parent::getImgUrl($iId, $sImgType);
107  if(empty($sImgUrl))
108  $sImgUrl = $this->aConstants['filesUrl'] . 'default.png';
109 
110  return $sImgUrl;
111  }
112 
113  function getImgPath ($iId, $sType = 'browse')
114  {
115  $iId = (int)$iId;
116  if (!isset($this->aConstants['picPostfix'][$sType]))
117  $sType = 'browse';
118 
119  $s = $this->aConstants['filesDir'] . $iId . $this->aConstants['picPostfix'][$sType];
120  if (!file_exists($s) && isset($this->oModule->_oConfig->aFilePostfix[$sType]['fallback']))
121  $s = $this->aConstants['filesDir'] . $this->oModule->_oConfig->aFilePostfix[$sType]['fallback'];
122 
123  return $s;
124  }
125 
126  function serviceGetFileUrl ($iId, $sImgType = 'browse')
127  {
128  return $this->getImgUrl($iId, $sImgType);
129  }
130 
131  function serviceGetSoundConcept ($aSound)
132  {
133  return $this->oTemplate->getFileConcept($aSound['ID'], $aSound);
134  }
135 
137  {
138  $iId = (int)$iId;
139  $sqlQuery = "SELECT
140  a.`ID` as `id`,
141  a.`Title` as `title`,
142  a.`Description` as `description`,
143  a.`Uri` as `uri`,
144  a.`Owner` as `owner`,
145  a.`Date` as `date`,
146  a.`Rate` AS `rate`,
147  a.`RateCount` AS `rate_count`,
148  a.`CommentsCount` AS `comments_count`,
149  a.`Listens` AS `views_count`,
150  a.`Status` AS `status`,
151  b.`id_album` as `album_id`
152  FROM `RayMp3Files` as a
153  LEFT JOIN `sys_albums_objects` as b ON b.`id_object` = a.`ID`
154  LEFT JOIN `sys_albums` as c ON c.`ID`=b.`id_album`
155  WHERE a.`ID`='$iId' AND c.`Type`='ch_sounds'";
156  $aImageInfo = db_arr($sqlQuery);
157  if(empty($aImageInfo) || !is_array($aImageInfo))
158  return array();
159 
160  $sFileName = $this->getImgUrl($iId, $sType);
161  $sFilePath = $this->getImgPath($iId, $sType);
162  $sUrl = $this->getCurrentUrl('file', $iId, $aImageInfo['uri']);
163  return array(
164  'id' => $aImageInfo['id'],
165  'file' => $sFileName,
166  'file_path' => $sFilePath,
167  'title' => $aImageInfo['title'],
168  'owner' => $aImageInfo['owner'],
169  'description' => $aImageInfo['description'],
170  'width' => (int)$this->oModule->_oConfig->getGlParam($sType . '_width') + 2 * 2,
171  'height' => (int)$this->oModule->_oConfig->getGlParam($sType . '_height') + 2 * 2,
172  'url' => $sUrl,
173  'date' => $aImageInfo['date'],
174  'rate' => $aImageInfo['rate'],
175  'rate_count' => $aImageInfo['rate_count'],
176  'comments_count' => $aImageInfo['comments_count'],
177  'views_count' => $aImageInfo['views_count'],
178  'status' => $aImageInfo['status'],
179  'album_id' => $aImageInfo['album_id']
180  );
181  }
182 
183  function serviceGetItemArray($iId, $sType = 'browse')
184  {
185  return $this->serviceGetEntry($iId, $sType);
186  }
187 
189  {
190  return $this->serviceGetEntry($iId, $sType);
191  }
192 
194  {
195  return $this->serviceGetEntry($iId, $sType);
196  }
197 
198  function serviceGetFilesInCat ($iId, $sCategory = '')
199  {
200  $aFiles = $this->getFilesInCatArray($iId, $sCategory);
201  foreach ($aFiles as $k => $aRow) {
202  $aFiles[$k]['thumb'] = $this->getImgUrl($aRow['id'], 'browse');
203  $aFiles[$k]['file'] = $this->getImgUrl($aRow['id'], 'file');
204  }
205  return $aFiles;
206  }
207 
208  function serviceGetFilesInAlbum ($iAlbumId, $isCheckPrivacy = false, $iViewer = 0, $aLimits = array())
209  {
210  if (!$iViewer)
211  $iViewer = $this->oModule->_iProfileId;
212  if ($isCheckPrivacy && !$this->oModule->oAlbumPrivacy->check('album_view', (int)$iAlbumId, $iViewer))
213  return array();
214  $aFiles = $this->getFilesInAlbumArray($iAlbumId, $aLimits);
215  foreach ($aFiles as $k => $aRow) {
216  $aFiles[$k]['thumb'] = $this->getImgUrl($aRow['id'], 'browse');
217  $aFiles[$k]['file'] = $this->getImgUrl($aRow['id'], 'file');
218  }
219  return $aFiles;
220  }
221 
222  function serviceGetAllProfileSounds ($iProfId, $aLimits = array())
223  {
224  $aFiles = $this->getProfileFiles($iProfId, $aLimits);
225  foreach ($aFiles as $k => $aRow) {
226  $aFiles[$k]['thumb'] = $this->getImgUrl($aRow['id'], 'browse');
227  $aFiles[$k]['file'] = $this->getImgUrl($aRow['id'], 'file');
228  }
229  return $aFiles;
230  }
231 
235  function serviceGetWallPost($aEvent)
236  {
237  return $this->oModule->getWallPost($aEvent, 'music');
238  }
239 
243  function serviceGetWallPostOutline($aEvent)
244  {
245  return $this->oModule->getWallPostOutline($aEvent, 'music');
246  }
247 
249  {
250  if(!$this->checkMemAction($iProfileId, 'view'))
251  return '';
252  $aVars = array (
253  'title' => false,
254  'prefix' => 'id' . time() . '_' . rand(1, 999999),
255  'default_height' => 350,
256  'ch_repeat:sounds' => array (),
257  'ch_repeat:icons' => array (),
258  );
259 
260  $aFiles = $this->serviceGetProfileAlbumFiles($iProfileId);
261  foreach($aFiles as $aFile) {
262  $aVars['ch_repeat:sounds'][] = array (
263  'style' => false === $aVars['title'] ? '' : 'display:none;',
264  'id' => $aFile['id'],
265  'sound' => $this->oTemplate->getFileConcept($aFile['id']),
266  );
267  $aVars['ch_repeat:icons'][] = array (
268  'id' => $aFile['id'],
269  'icon_url' => $aFile['file'],
270  'title' => $aFile['title'],
271  );
272  if (false === $aVars['title'])
273  $aVars['title'] = $aFile['title'];
274  }
275 
276  if (!$aVars['ch_repeat:icons'])
277  return '';
278 
279  $this->oTemplate->addCss('entry_view.css');
280  return $this->oTemplate->parseHtmlByName('entry_view_block_sounds.html', $aVars);
281  }
282 
283  function getAlterOrder()
284  {
285  $aSql = array();
286  switch ($this->aCurrent['sorting']) {
287  case 'popular':
288  $aSql['order'] = " ORDER BY `Listens` DESC";
289  break;
290 
291  case 'album_order':
292  $aSql['order'] = " ORDER BY `obj_order` ASC, `id_object` DESC";
293  break;
294 
295  default:
296  $aSql = parent::getAlterOrder();
297  }
298  return $aSql;
299  }
300 }
ChSoundsSearch\serviceGetFilesInAlbum
serviceGetFilesInAlbum($iAlbumId, $isCheckPrivacy=false, $iViewer=0, $aLimits=array())
Definition: ChSoundsSearch.php:208
ChSoundsSearch\serviceGetAllProfileSounds
serviceGetAllProfileSounds($iProfId, $aLimits=array())
Definition: ChSoundsSearch.php:222
ChBaseSearchResultSharedMedia\getProfileFiles
getProfileFiles($iProfId, $aLimits=array())
Definition: ChBaseSearchResultSharedMedia.php:442
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChSoundsSearch\serviceGetSoundConcept
serviceGetSoundConcept($aSound)
Definition: ChSoundsSearch.php:131
ChSoundsSearch\serviceGetSoundArray
serviceGetSoundArray($iId, $sType)
Definition: ChSoundsSearch.php:188
$sUrl
$sUrl
Definition: cart.php:15
ChSoundsSearch\serviceGetFileUrl
serviceGetFileUrl($iId, $sImgType='browse')
Definition: ChSoundsSearch.php:126
php
ChSoundsSearch\serviceGetFilesInCat
serviceGetFilesInCat($iId, $sCategory='')
Definition: ChSoundsSearch.php:198
$iId
$iId
Definition: license.php:15
$sParamValue
$sParamValue
Definition: actions.inc.php:16
ChSoundsSearch\serviceGetWallPost
serviceGetWallPost($aEvent)
Definition: ChSoundsSearch.php:235
ChSoundsSearch\serviceGetWallPostOutline
serviceGetWallPostOutline($aEvent)
Definition: ChSoundsSearch.php:243
db_arr
db_arr($query, $bindings=[])
Definition: db.inc.php:76
$sType
$sType
Definition: actions.inc.php:11
ChBaseSearchResultSharedMedia\serviceGetProfileAlbumFiles
serviceGetProfileAlbumFiles($iProfileId)
Definition: ChBaseSearchResultSharedMedia.php:673
$sParamName
$sParamName
Definition: actions.inc.php:15
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
ChSoundsSearch\_getPseud
_getPseud()
Definition: ChSoundsSearch.php:89
ChSoundsSearch\getAlterOrder
getAlterOrder()
Definition: ChSoundsSearch.php:283
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
ChSoundsSearch\serviceProfileSoundBlock
serviceProfileSoundBlock($iProfileId)
Definition: ChSoundsSearch.php:248
ChSoundsSearch\serviceGetMusicArray
serviceGetMusicArray($iId, $sType)
Definition: ChSoundsSearch.php:193
ChBaseSearchResultSharedMedia\checkMemAction
checkMemAction($iFileOwner, $sAction='view')
Definition: ChBaseSearchResultSharedMedia.php:701
ChSoundsSearch\__construct
__construct($sParamName='', $sParamValue='', $sParamValue1='', $sParamValue2='')
Definition: ChSoundsSearch.php:12
$aVars
$aVars
Definition: license.php:101
ChSoundsSearch\getImgPath
getImgPath($iId, $sType='browse')
Definition: ChSoundsSearch.php:113
$s
$s
Definition: embed.php:13
ChSoundsSearch\getImgUrl
getImgUrl($iId, $sImgType='browse')
Definition: ChSoundsSearch.php:104
ChSoundsSearch
Definition: ChSoundsSearch.php:11
ChTemplSearchResultSharedMedia
Definition: ChTemplSearchResultSharedMedia.php:11
ChBaseSearchResultSharedMedia\getFilesInCatArray
getFilesInCatArray($iId, $sCategory='')
Definition: ChBaseSearchResultSharedMedia.php:383
$iProfId
$iProfId
Definition: short_profile_info.php:22
ChBaseSearchResultSharedMedia\getFilesInAlbumArray
getFilesInAlbumArray($iAlbumId, $aLimits=array())
Definition: ChBaseSearchResultSharedMedia.php:415
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChSoundsSearch\serviceGetItemArray
serviceGetItemArray($iId, $sType='browse')
Definition: ChSoundsSearch.php:183
ChBaseSearchResultSharedMedia\getCurrentUrl
getCurrentUrl($sType, $iId=0, $sUri='', $aOwner='')
Definition: ChBaseSearchResultSharedMedia.php:130
ChSoundsSearch\serviceGetEntry
serviceGetEntry($iId, $sType)
Definition: ChSoundsSearch.php:136
$iProfileId
if( $sMembersList) $iProfileId
Definition: communicator.php:29