Cheetah
ChPhotosSearch.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('ChPhotosModule');
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  'manageProfilePhoto' => 'albums/my/manage_profile_photos/{uri}',
26  );
27  $aMain = array(
28  'name' => 'ch_photos',
29  'title' => '_ch_photos',
30  'table' => 'ch_photos_main'
31  );
32  $this->aCurrent = array_merge($aMain, $this->aCurrent);
33  $this->aCurrent['ownFields'] = array('ID', 'Title', 'Uri', 'Date', 'Size', 'Views', 'Rate', 'RateCount', 'Hash');
34  $this->aCurrent['searchFields'] = array('Title', 'Tags', 'Desc', 'Categories');
35  $this->aCurrent['rss']['title'] = _t('_ch_photos');
36  $this->aCurrent['rss']['fields']['Image'] = 'Hash';
37 
38  // redeclaration some unique fav fields
39  $this->aAddPartsConfig['favorite']['table'] = 'ch_photos_favorites';
40  $this->aAddPartsConfig['favorite']['mainField'] = 'ID';
41 
42  $this->oTemplate = &$this->oModule->_oTemplate;
43  $this->aConstants['filesUrl'] = $this->oModule->_oConfig->getFilesUrl();
44  $this->aConstants['filesDir'] = $this->oModule->_oConfig->getFilesPath();
45  $this->aConstants['filesInAlbumCover'] = 17;
46  $this->aConstants['filesInEmptyAlbumCover'] = 1;
47  $this->aConstants['picPostfix'] = $this->oModule->_oConfig->aFilePostfix;
48 
49  $this->aCurrent['restriction']['albumType']['value'] = $this->aCurrent['name'];
50 
51  switch ($sParamName) {
52  case 'calendar':
53  $this->aCurrent['restriction']['calendar-min'] = array('value' => "UNIX_TIMESTAMP('{$sParamValue}-{$sParamValue1}-{$sParamValue2} 00:00:00')", 'field' => 'Date', 'operator' => '>=', 'no_quote_value' => true);
54  $this->aCurrent['restriction']['calendar-max'] = array('value' => "UNIX_TIMESTAMP('{$sParamValue}-{$sParamValue1}-{$sParamValue2} 23:59:59')", 'field' => 'Date', 'operator' => '<=', 'no_quote_value' => true);
55  $this->aCurrent['title'] = _t('_ch_photos_caption_browse_by_day') . sprintf("%04u-%02u-%02u", $sParamValue, $sParamValue1, $sParamValue2);
56  break;
57  case 'top':
58  $this->aCurrent['sorting'] = 'top';
59  break;
60  case 'popular':
61  $this->aCurrent['sorting'] = 'popular';
62  break;
63  case 'featured':
64  $this->aCurrent['restriction']['featured'] = array(
65  'value'=>'1', 'field'=>'Featured', 'operator'=>'=', 'paramName'=>'ch_photos_mode'
66  );
67  break;
68  case 'favorited':
69  if (isset($this->aAddPartsConfig['favorite']) && !empty($this->aAddPartsConfig['favorite']) && getLoggedId() != 0) {
70  $this->aCurrent['join']['favorite'] = $this->aAddPartsConfig['favorite'];
71  $this->aCurrent['restriction']['fav'] = array(
72  'value' => getLoggedId(),
73  'field' => $this->aAddPartsConfig['favorite']['userField'],
74  'operator' => '=',
75  'table' => $this->aAddPartsConfig['favorite']['table']
76  );
77  }
78  break;
79  case 'album':
80  $this->aCurrent['sorting'] = 'album_order';
81  $this->aCurrent['restriction']['album'] = array(
82  'value'=>'', 'field'=>'Uri', 'operator'=>'=', 'paramName'=>'albumUri', 'table'=>'sys_albums'
83  );
84  $this->aCurrent['restriction']['albumType'] = array(
85  'value'=>$this->aCurrent['name'], 'field'=>'Type', 'operator'=>'=', 'paramName'=>'albumType', 'table'=>'sys_albums'
86  );
87  if ($sParamValue1 == 'owner' && strlen($sParamValue2) > 0) {
88  $this->aCurrent['restriction']['owner'] = array(
89  'value'=>$sParamValue2, 'field'=>'NickName', 'operator'=>'=', 'paramName'=>'ownerName', 'table' => 'Profiles'
90  );
91  }
92  break;
93  }
94  }
95 
96  function addCustomParts ()
97  {
98  if (!$this->bCustomParts) {
99  $this->bCustomParts = true;
100  $this->oModule->_oTemplate->addCss(array('search.css'));
101  return '';
102  }
103  }
104 
105  function addAlbumJsCss($bDynamic = false) {
106  $sResult = parent::addAlbumJsCss($bDynamic);
107  $sResult .= $this->oTemplate->addCss(array(
108  'album.css'
109  ), $bDynamic);
110 
111  return $bDynamic ? $sResult : '';
112  }
113 
114  function getAlbumCovers ($iAlbumId, $aParams = array())
115  {
116  $iAlbumId = (int)$iAlbumId;
117  $iLimit = isset($aParams['filesInAlbumCover']) ? (int)$aParams['filesInAlbumCover'] : null;
118  $aPics = $this->oModule->oAlbums->getAlbumCoverFiles($iAlbumId, array('table'=>$this->aCurrent['table'], 'field'=>'ID', 'fields_list'=>array('Uri', 'Hash')), array(array('field'=>'Status', 'value'=>'approved')), $iLimit);
119  return $aPics;
120  }
121 
122  function getAlbumsBlock ($aSectionParams = array(), $aAlbumParams = array(), $aCustom = array())
123  {
124  $aCustom['unit_css_class'] = '.sys_album_unit_wrp';
125 
126  $aResult = parent::getAlbumsBlock($aSectionParams, $aAlbumParams, $aCustom);
127  if(!empty($aResult[0])) {
128  $aResult[3] = true;
129 
130  $aResult[0] = $this->oTemplate->parseHtmlByName('default_margin_thd.html', array(
131  'content' => $aResult[0]
132  ));
133  }
134 
135  return $aResult;
136  }
137 
138  function getAlbumCoverUrl (&$aIdent)
139  {
140  return $this->getImgUrl($aIdent['Hash'], 'browse');
141  }
142 
143  function displayAlbumUnit ($aData, $bCheckPrivacy = true)
144  {
145  $sContent = parent::displayAlbumUnit($aData, $bCheckPrivacy);
146  return $this->oTemplate->parseHtmlByContent($sContent, array(
147  'ch_if:show_activation' => array(
148  'condition' => (int)$aData['ObjCount'] > 1,
149  'content' => array()
150  )
151  ));
152  }
153 
154  function _getAlbumUnitItem($iIndex, $aPicture, $aParams = array())
155  {
156  $aResult = parent::_getAlbumUnitItem($iIndex, $aPicture, $aParams);
157  $aResult['ch_if:exist']['content']['url'] = '';
158 
159  $sClass = '';
160  if(empty($aPicture)){
161  if($iIndex == 0) {
162  $aResult['ch_if:not-exist']['condition'] = true;
163  $aResult['ch_if:not-exist']['content']['class'] = ' sys-ai-empty';
164  }
165  else
166  $aResult['ch_if:not-exist']['condition'] = false;
167  }
168  else {
169  switch($iIndex) {
170  case 0:
171  $sClass = 'sys-ai-front';
172  break;
173  case 1:
174  $sClass = 'sys-ai-middle';
175  break;
176  case 2:
177  $sClass = 'sys-ai-back';
178  break;
179  default:
180  $sClass = 'sys-ai-out';
181  }
182  $aResult['ch_if:exist']['content']['class'] = ' ' . $sClass;
183 
184  if(!empty($aPicture['Uri']))
185  $aResult['ch_if:exist']['content']['url'] = $this->getCurrentUrl('file', $aPicture['id_object'], $aPicture['Uri']);
186  if(empty($aResult['ch_if:exist']['content']['url']) && !empty($aParams['album_url']))
187  $aResult['ch_if:exist']['content']['url'] = $aParams['album_url'];
188  }
189 
190  return $aResult;
191  }
192 
193  function getImgUrl ($sHash, $sImgType = 'browse')
194  {
195  return CH_WSB_URL_ROOT . $this->oModule->_oConfig->getBaseUri() . 'get_image/' . $sImgType .'/' . $sHash . '.jpg';
196  }
197 
198  function getLength ($sSize)
199  {
200  return $sSize;
201  }
202 
203  function getLatestFile ()
204  {
205  $aParams['DisplayPagination'] = 0;
206  $aParams['DisplayWhenAgo'] = 1;
207  $aParams['DisplayViews'] = 0;
208  $aParams['DisplayLink'] = 1;
209  $aParams['DisplayProfile'] = 1;
210 
211  if (isset($this->aCurrent['restriction']['owner']['value']) && (int)$this->aCurrent['restriction']['owner']['value'] != 0)
212  $aParams['PID'] = $this->aCurrent['restriction']['owner']['value'];
213 
214  if (isset($this->aCurrent['restriction']['category']['value']) && strlen($this->aCurrent['restriction']['category']['value']) > 0)
215  $aParams['Category'] = $this->aCurrent['restriction']['category']['value'];
216 
217  if (isset($this->aCurrent['restriction']['tag']['value']) && strlen($this->aCurrent['restriction']['tag']['value']) > 0)
218  $aParams['Tag'] = $this->aCurrent['restriction']['tag']['value'];
219 
220  return '<div class="latestFile">'.$this->servicePhotoBlock($aParams).'</div>';
221  }
222 
229  function serviceGetImage ($aImageInfo, $sImgType = 'thumb')
230  {
231  $iPicID = (int)$aImageInfo['Avatar'];
232  $aImg = $this->_getImageFullInfo($iPicID, $sImgType);
233  if (strlen($aImg['file']) > 0) {
234  $sFileName = $aImg['file'];
235  $isNoImage = false;
236  }
237  return array('file' => $sFileName, 'title' => $aImg['title'], 'width' => $aImg['width'], 'height' => $aImg['height'], 'no_image'=>$isNoImage);
238  }
239 
240  function serviceGetEntry($iId, $sType = 'thumb')
241  {
242  $aImageInfo = $this->_getImageFullInfo($iId, $sType);
243  return empty($aImageInfo['file']) ? array() : $aImageInfo;
244  }
245 
246  function serviceGetItemArray($iId, $sType = 'browse')
247  {
248  return $this->serviceGetEntry($iId, $sType);
249  }
250 
251  function serviceGetPhotoArray($iId, $sType = 'thumb')
252  {
253  return $this->serviceGetEntry($iId, $sType);
254  }
255 
256  function _getImageFullInfo($iId, $sType = 'thumb')
257  {
258  $aImageInfo = $this->_getImageDbInfo($iId);
259 
260  $iWidth = (int)$this->oModule->_oConfig->getGlParam($sType . '_width');
261  $iHeight = (int)$this->oModule->_oConfig->getGlParam($sType . '_height');
262 
263  $iWidth = $iWidth == 0 ? $this->oModule->_oConfig->aFilesConfig[$sType]['size_def'] : $iWidth;
264  $iHeight = $iHeight == 0 ? $this->oModule->_oConfig->aFilesConfig[$sType]['size_def'] : $iHeight;
265 
266  $sImagePath = $sImageUrl = $sBrowseUrl = '';
267  if(is_array($aImageInfo) && !empty($aImageInfo)) {
268  $sImageUrl = $this->_getImageFullUrl($aImageInfo, $sType);
269  $sImagePath = $this->oModule->_oConfig->getFilesPath() . $aImageInfo['id'] . $this->aConstants['picPostfix'][$sType];
270  $sBrowseUrl = !empty($aImageInfo['uri']) ? $this->getCurrentUrl('file', $iId, $aImageInfo['uri']) : '';
271  }
272  return array(
273  'id' => $iId,
274  'file' => $sImageUrl,
275  'file_path' => $sImagePath,
276  'path' => $sImagePath,
277  'title' => $aImageInfo['title'],
278  'owner' => $aImageInfo['owner'],
279  'description' => $aImageInfo['description'],
280  'width' => $iWidth + 2 * 2,
281  'height' => $iHeight + 2 * 2,
282  'url' => $sBrowseUrl,
283  'date' => $aImageInfo['date'],
284  'rate' => $aImageInfo['rate'],
285  'rate_count' => $aImageInfo['rate_count'],
286  'comments_count' => $aImageInfo['comments_count'],
287  'views_count' => $aImageInfo['views_count'],
288  'status' => $aImageInfo['status'],
289  'album_id' => $aImageInfo['album_id']
290  );
291  }
292 
294  {
295  $iId = (int)$iId;
296  $sqlQuery = "SELECT a.`ID` as `id`,
297  a.`Ext` as `ext`,
298  a.`Title` as `title`,
299  a.`Desc` as `description`,
300  a.`Uri` as `uri`,
301  a.`Owner` as `owner`,
302  a.`Date` as `date`,
303  a.`Rate` as `rate`,
304  a.`RateCount` as `rate_count`,
305  a.`CommentsCount` as `comments_count`,
306  a.`Views` as `views_count`,
307  a.`Hash`,
308  a.`Status` AS `status`,
309  b.`id_album` as `album_id`
310  FROM `ch_photos_main` as a
311  LEFT JOIN `sys_albums_objects` as b ON b.`id_object` = a.`ID`
312  LEFT JOIN `sys_albums` as c ON c.`ID`=b.`id_album`
313  WHERE a.`ID`='" . $iId . "' AND c.`Type`='ch_photos'";
314  $aImageInfo = ($iId) ? db_arr($sqlQuery) : null;
315  return $aImageInfo;
316  }
317 
318  // get image source url
319  function _getImageFullUrl ($aImageInfo, $sType = 'thumb')
320  {
321  $sName = $aImageInfo['id'] . $this->aConstants['picPostfix'][$sType];
322  $sName = str_replace('{ext}', $aImageInfo['ext'], $sName);
323  $sImageUrl = !empty($aImageInfo['id']) && extFileExists($this->oModule->_oConfig->getFilesPath() . $sName) ? $this->getImgUrl($aImageInfo['Hash'], $sType) : '';
324  return $sImageUrl;
325  }
326 
327  function _getPseud ()
328  {
329  return array(
330  'id' => 'ID',
331  'title' => 'Title',
332  'date' => 'Date',
333  'size' => 'Size',
334  'uri' => 'Uri',
335  'view' => 'Views',
336  'ownerId' => 'Owner',
337  'ownerName' => 'NickName',
338  'voteTime' => 'gal_date'
339  );
340  }
341 
342  function serviceGetProfileAlbumBlock($iProfileId, $sSpecUrl = '')
343  {
344  $sCaption = str_replace('{nickname}', getUsername($iProfileId), $this->oModule->_oConfig->getGlParam('profile_album_name'));
345  $sUri = uriFilter($sCaption);
346 
347  $oAlbum = new ChWsbAlbums('ch_photos');
348  $aAlbum = $oAlbum->getAlbumInfo(array('fileUri' => $sUri, 'owner' => $iProfileId));
349  if((int)$aAlbum['ObjCount'] <= 0)
350  return '';
351 
352  $aAlbum['show_as_list'] = true;
353  $aAlbum['enable_center'] = true;
354  return array($this->displayAlbumUnit($aAlbum), array(), array(), false);
355  }
356 
357  function servicePhotoBlock ($aParams)
358  {
359  return $this->getPhotoBlock($aParams);
360  }
361 
362  function serviceProfilePhotoBlock ($aParams)
363  {
364  if(!isset($aParams['PID']) || empty($aParams['PID']))
365  return '';
366 
367  $sOwner = getUsername($aParams['PID']);
368  $sCaption = str_replace('{nickname}', $sOwner, $this->oModule->_oConfig->getGlParam('profile_album_name'));
369 
370  if((int)$aParams['PID'] == getLoggedId())
371  $aParams['LinkUnitTo'] = $this->getCurrentUrl('manageProfilePhoto', 0, uriFilter($sCaption)) . '/owner/' . $sOwner;
372 
373  $aParams['DisplayRate'] = 0;
374  $aParams['DisplayPagination'] = 0;
375  $aParams['DisplayLink'] = 0;
376  $aParams['Limit'] = 1;
377 
378  return $this->getProfilePhotoBlock($aParams);
379  }
380 
381  function serviceProfilePhoto ($iProfileId, $sType = 'icon', $sReturnType = 'link')
382  {
383  return $this->getProfilePhoto(array(
384  'profile_id' => $iProfileId,
385  'album' => 'profile_album_name',
386  'type' => $sType,
387  'return_type' => $sReturnType
388  ));
389  }
390 
391  function serviceProfileCover ($iProfileId, $sType = 'file', $sReturnType = 'link')
392  {
393  return $this->getProfilePhoto(array(
394  'profile_id' => $iProfileId,
395  'album' => 'profile_cover_album_name',
396  'type' => $sType,
397  'return_type' => $sReturnType
398  ));
399  }
400 
402  {
403  if(!isset($aParams['PID']) || empty($aParams['PID']))
404  return '';
405 
406  $aParams['DisplayScroller'] = 1;
407  $aParams['DisplayPagination'] = 1;
408  $aParams['DisplayLink'] = 1;
409 
410  return $this->getProfilePhotoBlock($aParams);
411  }
412 
413  function serviceGetFilesInCat ($iId, $sCategory = '')
414  {
415  $aFiles = $this->getFilesInCatArray($iId, $sCategory);
416  foreach ($aFiles as $k => $aRow) {
417  $aFiles[$k]['icon'] = $this->getImgUrl($aRow['Hash'], 'icon');
418  $aFiles[$k]['thumb'] = $this->getImgUrl($aRow['Hash'], 'thumb');
419  $aFiles[$k]['file'] = $this->getImgUrl($aRow['Hash'], 'file');
420  }
421  return $aFiles;
422  }
423 
424  function serviceGetFilesInAlbum ($iAlbumId, $isCheckPrivacy = false, $iViewer = 0, $aLimits = array())
425  {
426  if (!$iViewer)
427  $iViewer = $this->oModule->_iProfileId;
428  if ($isCheckPrivacy && !$this->oModule->oAlbumPrivacy->check('album_view', (int)$iAlbumId, $iViewer))
429  return array();
430  $aFiles = $this->getFilesInAlbumArray($iAlbumId, $aLimits);
431  foreach ($aFiles as $k => $aRow) {
432  $aFiles[$k]['icon'] = $this->getImgUrl($aRow['Hash'], 'icon');
433  $aFiles[$k]['thumb'] = $this->getImgUrl($aRow['Hash'], 'thumb');
434  $aFiles[$k]['file'] = $this->getImgUrl($aRow['Hash'], 'file');
435  }
436  return $aFiles;
437  }
438 
439  function serviceGetAllProfilePhotos ($iProfId, $aLimits = array())
440  {
441  $aFiles = $this->getProfileFiles($iProfId, $aLimits);
442  foreach ($aFiles as $k => $aRow) {
443  foreach ($this->oModule->_oConfig->aFilesConfig as $sType => $aFileConfig) {
444  if (isset($aFileConfig['size_def']))
445  $aFiles[$k][$sType] = $this->getImgUrl($aRow['Hash'], $sType);
446  }
447  }
448  return $aFiles;
449  }
450 
454  function serviceGetWallPost($aEvent)
455  {
456  return $this->oModule->getWallPost($aEvent, 'picture-o');
457  }
458 
462  function serviceGetWallPostOutline($aEvent)
463  {
464  return $this->oModule->getWallPostOutline($aEvent, 'picture-o');
465  }
466 
467  function getProfilePhotoBlock($aParams)
468  {
469  $sCaption = str_replace('{nickname}', getUsername($aParams['PID']), $this->oModule->_oConfig->getGlParam('profile_album_name'));
470  $sUri = uriFilter($sCaption);
471  $oAlbum = new ChWsbAlbums('ch_photos');
472  $aAlbumInfo = $oAlbum->getAlbumInfo(array('fileUri' => $sUri, 'owner' => $aParams['PID']), array('ID'));
473  if(empty($aAlbumInfo) && $this->oModule->_iProfileId == (int)$aParams['PID']) {
474  $aData = array(
475  'caption' => $sCaption,
476  'owner' => $this->oModule->_iProfileId,
477  'AllowAlbumView' => $this->oModule->oAlbumPrivacy->_oDb->getDefaultValueModule('photos', 'album_view'),
478  );
479  $aAlbumInfo['ID'] = $oAlbum->addAlbum($aData, false);
480  }
481 
482  if(!$this->oModule->oAlbumPrivacy->check('album_view', $aAlbumInfo['ID'], $this->oModule->_iProfileId))
483  return '';
484 
485  $this->aCurrent['sorting'] = 'album_order';
486  $this->aCurrent['restriction']['album'] = array(
487  'value' => $sUri, 'field' => 'Uri', 'operator' => '=', 'paramName' => 'albumUri', 'table' => 'sys_albums'
488  );
489 
490  return $this->getPhotoBlock($aParams);
491  }
492 
493  function getProfilePhoto($aParams)
494  {
495  $iProfileId = !empty($aParams['profile_id']) ? (int)$aParams['profile_id'] : 0;
496  $sAlbum = !empty($aParams['album']) ? $aParams['album'] : 'profile_album_name';
497  $sType = !empty($aParams['type']) ? $aParams['type'] : 'icon';
498  $sReturnType = !empty($aParams['return_type']) ? $aParams['return_type'] : 'link';
499 
500  $aDefaultAlbums = $this->oModule->_oConfig->getDefaultAlbums();
501  if(!empty($sAlbum) && in_array($sAlbum, $aDefaultAlbums)) {
502  ch_import('ChWsbAlbums');
503  $sAlbum = ChWsbAlbums::getAbumUri($this->oModule->_oConfig->getGlParam($sAlbum), $iProfileId);
504  }
505 
506  $oAlbum = new ChWsbAlbums('ch_photos');
507  $aAlbumInfo = $oAlbum->getAlbumInfo(array('fileUri' => $sAlbum, 'owner' => $iProfileId), array('ID'));
508  if (!$this->oModule->oAlbumPrivacy->check('album_view', $aAlbumInfo['ID'], getLoggedId()))
509  return '';
510 
511  $sKeywordGet = $sKeywordPost = null;
512 
513  if (isset($_GET['keyword']))
514  {
515  $sKeywordGet = $_GET['keyword'];
516  unset($_GET['keyword']);
517  }
518  elseif(isset($_POST['keyword']))
519  {
520  $sKeywordPost = $_POST['keyword'];
521  unset($_POST['keyword']);
522  }
523 
524  $aSavePaginate = array();
525  if(isset($_GET['page'], $_GET['per_page']))
526  $aSavePaginate = array($_GET['page'], $_GET['per_page']);
527 
528  unset($_GET['page']);
529  unset($_GET['per_page']);
530 
531  $this->aCurrent['paginate']['perPage'] = 1;
532  $this->aCurrent['paginate']['page'] = 1;
533  $this->aCurrent['restriction']['owner']['value'] = $iProfileId;
534  $this->aCurrent['sorting'] = 'album_order';
535  $this->aCurrent['restriction']['album'] = array(
536  'value' => $sAlbum, 'field' => 'Uri', 'operator' => '=', 'paramName' => 'albumUri', 'table' => 'sys_albums'
537  );
538 
539  $aFilesList = $this->getSearchData();
540 
541  if(!empty($aSavePaginate))
542  list($_GET['page'], $_GET['per_page']) = $aSavePaginate;
543 
544  if (!is_null($sKeywordGet))
545  $_GET['keyword'] = clear_xss($sKeywordGet);
546  elseif(!is_null($sKeywordPost))
547  $_POST['keyword'] = clear_xss($sKeywordPost);
548 
549  if (!$this->aCurrent['paginate']['totalNum'])
550  return '';
551 
552  $aFile = array_pop($aFilesList);
553  $aFile['file_url'] = $this->getImgUrl($aFile['Hash'], $sType);
554  $aFile['view_url'] = CH_WSB_URL_ROOT . $this->oModule->_oConfig->getBaseUri() . 'view/' . $aFile['uri'];
555 
556  if($sReturnType == 'full')
557  return $aFile;
558 
559  return $aFile['file_url'];
560  }
561 
562  function getPhotoBlock ($aParams = array())
563  {
564  $this->aCurrent['paginate']['perPage'] = 20;
565  $aShowParams = array('showScroller' => 0, 'showRate' => 1, 'showPaginate' => 0, 'showViews' => 0, 'showDate' => 0, 'showLink' => 0, 'showFrom' => 0);
566 
567  if(count($aParams) > 0) {
568  foreach( $aParams as $sKeyName => $sKeyValue ) {
569  switch ($sKeyName) {
570  case 'PID':
571  $this->aCurrent['restriction']['owner']['value'] = (int)$sKeyValue;
572  break;
573  case 'Category':
574  $this->aCurrent['restriction']['category']['value'] = strip_tags($sKeyValue);
575  break;
576  case 'Tag':
577  $this->aCurrent['restriction']['tag']['value'] = strip_tags($sKeyValue);
578  break;
579  case 'Limit':
580  $this->aCurrent['paginate']['perPage'] = (int)$sKeyValue;
581  break;
582  case 'DisplayScroller':
583  $aShowParams['showScroller'] = $sKeyValue == 1 ? 1 : 0;
584  break;
585  case 'DisplayRate':
586  $aShowParams['showRate'] = $sKeyValue == 1 ? 1 : 0;
587  break;
588  case 'DisplayPagination':
589  $aShowParams['showPaginate'] = $sKeyValue == 1 ? 1 : 0;
590  break;
591  case 'DisplayViews':
592  $aShowParams['showViews'] = $sKeyValue == 1 ? 1 : 0;
593  break;
594  case 'DisplayWhenAgo':
595  $aShowParams['showDate'] = $sKeyValue == 1 ? 1 : 0;
596  break;
597  case 'DisplayLink':
598  $aShowParams['showLink'] = $sKeyValue == 1 ? 1 : 0;
599  break;
600  case 'DisplayProfile':
601  $aShowParams['showFrom'] = $sKeyValue == 1 ? 1 : 0;
602  break;
603  case 'LinkUnitTo':
604  $aShowParams['linkUnitTo'] = $sKeyValue;
605  break;
606  }
607  }
608  }
609 
610  $aFilesList = $this->getSearchData();
611  $iCnt = $this->aCurrent['paginate']['totalNum'];
612 
613  if($iCnt) {
614  $aUnit = array();
615  $aUnits = array();
616  if (defined('CH_PROFILE_PAGE') || defined('CH_MEMBER_PAGE')) {
617  $iPhotoWidth = 259;
618  $sImgWidth = 'style="width:' . $iPhotoWidth . 'px;"';
619  } else {
620  $iPhotoWidth = (int)$this->oModule->_oConfig->getGlParam('file_width');
621  $iPhotoWidth = ($iPhotoWidth > 1) ? $iPhotoWidth : 600;
622  $sImgWidth = '';
623  }
624 
625  foreach ($aFilesList as $iKey => $aData) {
626  $sPicUrl = $this->getImgUrl($aData['Hash'], 'icon');
627  $aUnits[] = array(
628  'imageId' => $iKey + 1,
629  'picUrl' => $sPicUrl
630  );
631  $sPicLinkElements .= 'aPicLink['.($iKey + 1).'] = '.$aData['id'].';';
632  if ($iKey == 0) {
633  $aAdd = array('switchWidth' => ($iPhotoWidth + 2), 'imgWidth' => $sImgWidth);
634  $aUnit['switcherUnit'] = $this->getSwitcherUnit($aData, $aShowParams, $aAdd);
635  }
636  }
637 
638  $aUnit['moduleUrl'] = CH_WSB_URL_ROOT . $this->oModule->_oConfig->getBaseUri();
639  $aUnit['count'] = $iCnt;
640  $aUnit['picWidth'] = $iPhotoWidth;
641  $aUnit['picBoxWidth'] = $aUnit['switchWidth'] = $iPhotoWidth + 2;
642  $aUnit['switchWidthOut'] = $aUnit['switchWidth'] + 2;
643  $aUnit['ch_if:show_scroller'] = array(
644  'condition' => false,
645  'content' => array()
646  );
647 
648  if((int)$aShowParams['showScroller'] == 1) {
649  $bScroller = false;
650  $iContainerWidth = $iContentWidth = $iCnt * 40;
651  if($iContentWidth > $aUnit['picWidth']) {
652  $bScroller = true;
653  $iContainerWidth = $aUnit['picBoxWidth'] - 72;
654  }
655 
656  $aUnit['ch_if:show_scroller'] = array(
657  'condition' => true,
658  'content' => array(
659  'switchWidthOut' => $aUnit['switchWidthOut'],
660  'containerWidth' => $iContainerWidth,
661  'contWidth' => $iContentWidth,
662  'ch_if:scrollerBack' => array(
663  'condition' => $bScroller,
664  'content' => array(1)
665  ),
666  'ch_repeat:iconBlock' => $aUnits,
667  'ch_if:scrollerNext' => array(
668  'condition' => $bScroller,
669  'content' => array(1),
670  )
671  )
672  );
673  }
674 
675  $aUnit['picLinkElements'] = $sPicLinkElements;
676  if ($aShowParams['showPaginate'] == 1) {
677  $aLinkAddon = $this->getLinkAddByPrams();
678  $oPaginate = new ChWsbPaginate(array(
679  'page_url' => $aUnit['changeUrl'],
680  'count' => $iCnt,
681  'info' => false,
682  'per_page' => 1,
683  'page' => $this->aCurrent['paginate']['page'],
684  'on_change_page' => 'getCurrentImage({page})',
685  ));
686  $aUnit['paginate'] = $oPaginate->getPaginate();
687  } else
688  $aUnit['paginate'] = '';
689 
690  $this->oTemplate->addCss('search.css');
691  return $this->oTemplate->parseHtmlByName('photo_switcher.html', $aUnit);
692  } elseif ($this->oModule->_iProfileId != 0 && $this->oModule->_iProfileId == (int)$this->aCurrent['restriction']['owner']['value']) {
693  ob_start();
694  ?>
695  <div class="paginate ch-def-padding-sec-left ch-def-padding-sec-right">
696  <div class="view_all">
697  <a href="__lnk_url__" title="__lnk_title__">__lnk_content__</a>
698  </div>
699  </div>
700  <?php
701  $sCode = ob_get_clean();
702 
703  ch_import('ChWsbAlbums');
704  $sCaption = ChWsbAlbums::getAbumUri($this->oModule->_oConfig->getGlParam('profile_album_name'), $this->oModule->_iProfileId);
705 
706  $sLinkTitle = _t('_ch_photos_add');
707  return MsgBox(_t('_Empty')) . $this->oTemplate->parseHtmlByContent($sCode, array(
708  'lnk_url' => $this->oModule->_oConfig->getBaseUri() . 'albums/my/add_objects/' . $sCaption . '/owner/' . getUsername($this->oModule->_iProfileId),
709  'lnk_title' => $sLinkTitle,
710  'lnk_content' => $sLinkTitle
711  ));
712  }
713  return MsgBox(_t('_Empty'));
714  }
715 
716  function getSwitcherUnit (&$aData, $aShowParams = array(), $aAddElems = array())
717  {
718  if (!is_array($aData))
719  return;
720 
721  $iPhotoWidth = (int)$this->oModule->_oConfig->getGlParam('file_width') ? (int)$this->oModule->_oConfig->getGlParam('file_width') : 602;
722  $iWidth = (int)$aAddElems['switchWidth'] > 0 ? (int)$aAddElems['switchWidth'] : $iPhotoWidth;
723  $sImgUrl = $this->getCurrentUrl('file', $aData['id'], $aData['uri']);
724  $aUnit = array(
725  'switchWidth' => $iWidth,
726  'imgWidth' => !empty($aAddElems['imgWidth']) ? $aAddElems['imgWidth']: '',
727  'picUrl' => $this->getImgUrl($aData['Hash'], 'file'),
728  'href' => isset($aShowParams['linkUnitTo']) && !empty($aShowParams['linkUnitTo']) ? $aShowParams['linkUnitTo'] : $sImgUrl,
729  'ch_if:href' => array(
730  'condition' => (int)$aShowParams['showLink'] != 0,
731  'content' => array(
732  'href' => $sImgUrl,
733  'title' => $aData['title']
734  )
735  ),
736  'ch_if:rate' => array(
737  'condition' => (int)$aShowParams['showRate'] != 0,
738  'content' => array(
739  'rate' => $this->oRate && $this->oRate->isEnabled() ? $this->oRate->getJustVotingElement(1, $aData['id'], $aData['Rate']) : $this->oRate->getJustVotingElement(0, 0, $aData['Rate'])
740  )
741  ),
742  'ch_if:date' => array(
743  'condition' => (int)$aShowParams['showDate'] != 0,
744  'content' => array(
745  'date' => defineTimeInterval($aData['date'])
746  )
747  ),
748  'ch_if:from' => array(
749  'condition' => (int)$aShowParams['showFrom'] != 0,
750  'content' => array(
751  'profileUrl' => getProfileLink($aData['ownerId']),
752  'nick' => getNickName($aData['ownerId'])
753  )
754  )
755  );
756  return $this->oTemplate->parseHtmlByName('switcher_unit.html', $aUnit);
757  }
758 
759  function getModuleFolder ()
760  {
761  return 'cheetah/photos';
762  }
763 
764  function getRssUnitImage (&$a, $sField)
765  {
766  return $this->getImgUrl($a[$sField]);
767  }
768 }
ChPhotosSearch
Definition: ChPhotosSearch.php:11
ChPhotosSearch\addAlbumJsCss
addAlbumJsCss($bDynamic=false)
Definition: ChPhotosSearch.php:105
ChPhotosSearch\serviceProfilePhotoBlock
serviceProfilePhotoBlock($aParams)
Definition: ChPhotosSearch.php:362
ChPhotosSearch\getProfilePhoto
getProfilePhoto($aParams)
Definition: ChPhotosSearch.php:493
ChPhotosSearch\displayAlbumUnit
displayAlbumUnit($aData, $bCheckPrivacy=true)
Definition: ChPhotosSearch.php:143
ChBaseSearchResult\getLinkAddByPrams
getLinkAddByPrams($aExclude=array())
Definition: ChBaseSearchResult.php:186
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChPhotosSearch\getLatestFile
getLatestFile()
Definition: ChPhotosSearch.php:203
ChBaseSearchResultSharedMedia\getProfileFiles
getProfileFiles($iProfId, $aLimits=array())
Definition: ChBaseSearchResultSharedMedia.php:442
ChPhotosSearch\getAlbumCoverUrl
getAlbumCoverUrl(&$aIdent)
Definition: ChPhotosSearch.php:138
ChPhotosSearch\_getImageDbInfo
_getImageDbInfo($iId)
Definition: ChPhotosSearch.php:293
defineTimeInterval
defineTimeInterval($iTime, $bAutoDateConvert=true, $bShort=false)
Definition: utils.inc.php:831
ChPhotosSearch\getSwitcherUnit
getSwitcherUnit(&$aData, $aShowParams=array(), $aAddElems=array())
Definition: ChPhotosSearch.php:716
$aUnit
$aUnit
Definition: short_profile_info.php:31
$sCode
$sCode
Definition: explanation.php:19
$sResult
$sResult
Definition: advanced_settings.php:26
ChPhotosSearch\getImgUrl
getImgUrl($sHash, $sImgType='browse')
Definition: ChPhotosSearch.php:193
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$aResult
$aResult
Definition: index.php:19
ChPhotosSearch\_getPseud
_getPseud()
Definition: ChPhotosSearch.php:327
ChPhotosSearch\_getAlbumUnitItem
_getAlbumUnitItem($iIndex, $aPicture, $aParams=array())
Definition: ChPhotosSearch.php:154
ChPhotosSearch\serviceGetItemArray
serviceGetItemArray($iId, $sType='browse')
Definition: ChPhotosSearch.php:246
ChPhotosSearch\getRssUnitImage
getRssUnitImage(&$a, $sField)
Definition: ChPhotosSearch.php:764
ChBaseSearchResultSharedMedia\$bDynamic
$bDynamic
Definition: ChBaseSearchResultSharedMedia.php:14
php
ChPhotosSearch\serviceGetPhotoArray
serviceGetPhotoArray($iId, $sType='thumb')
Definition: ChPhotosSearch.php:251
$iId
$iId
Definition: license.php:15
ChPhotosSearch\_getImageFullInfo
_getImageFullInfo($iId, $sType='thumb')
Definition: ChPhotosSearch.php:256
$sParamValue
$sParamValue
Definition: actions.inc.php:16
ChPhotosSearch\serviceProfilePhoto
serviceProfilePhoto($iProfileId, $sType='icon', $sReturnType='link')
Definition: ChPhotosSearch.php:381
ChPhotosSearch\serviceGetFilesInCat
serviceGetFilesInCat($iId, $sCategory='')
Definition: ChPhotosSearch.php:413
ChPhotosSearch\serviceGetAllProfilePhotos
serviceGetAllProfilePhotos($iProfId, $aLimits=array())
Definition: ChPhotosSearch.php:439
a
Filter ExtractStyleBlocks Scope FilterParam ExtractStyleBlocksScope DESCRIPTION< p > If you would like users to be able to define external but only allow them to specify CSS declarations for a specific node and prevent them from fiddling with other use this directive It accepts any valid CSS and will prepend this to any CSS declaration extracted from the document For if this directive is set to< code > selector< code > a
Definition: Filter.ExtractStyleBlocks.Scope.txt:15
ChPhotosSearch\getLength
getLength($sSize)
Definition: ChPhotosSearch.php:198
db_arr
db_arr($query, $bindings=[])
Definition: db.inc.php:76
$sType
$sType
Definition: actions.inc.php:11
$_GET
$_GET['debug']
Definition: index.php:67
$iIndex
$iIndex
Definition: bottom_menu_compose.php:142
ChPhotosSearch\getModuleFolder
getModuleFolder()
Definition: ChPhotosSearch.php:759
ChPhotosSearch\serviceGetProfileAlbumBlock
serviceGetProfileAlbumBlock($iProfileId, $sSpecUrl='')
Definition: ChPhotosSearch.php:342
$sParamName
$sParamName
Definition: actions.inc.php:15
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
ChPhotosSearch\serviceProfileCover
serviceProfileCover($iProfileId, $sType='file', $sReturnType='link')
Definition: ChPhotosSearch.php:391
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
ChPhotosSearch\getAlbumsBlock
getAlbumsBlock($aSectionParams=array(), $aAlbumParams=array(), $aCustom=array())
Definition: ChPhotosSearch.php:122
ChWsbAlbums
Definition: ChWsbAlbums.php:9
ChPhotosSearch\getProfilePhotoBlock
getProfilePhotoBlock($aParams)
Definition: ChPhotosSearch.php:467
ChPhotosSearch\getPhotoBlock
getPhotoBlock($aParams=array())
Definition: ChPhotosSearch.php:562
ChPhotosSearch\serviceGetWallPost
serviceGetWallPost($aEvent)
Definition: ChPhotosSearch.php:454
uriFilter
uriFilter($s)
Definition: utils.inc.php:931
getUsername
getUsername( $ID='')
Definition: profiles.inc.php:443
ChWsbSearchResult\getSearchData
getSearchData()
Definition: ChWsbSearch.php:376
ChWsbPaginate
Definition: ChWsbPaginate.php:69
extFileExists
extFileExists($sFileSrc)
Definition: utils.inc.php:638
ChPhotosSearch\serviceGetFilesInAlbum
serviceGetFilesInAlbum($iAlbumId, $isCheckPrivacy=false, $iViewer=0, $aLimits=array())
Definition: ChPhotosSearch.php:424
ChPhotosSearch\servicePhotoBlock
servicePhotoBlock($aParams)
Definition: ChPhotosSearch.php:357
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChPhotosSearch\serviceProfilePhotoSwitcherBlock
serviceProfilePhotoSwitcherBlock($aParams)
Definition: ChPhotosSearch.php:401
ChPhotosSearch\getAlbumCovers
getAlbumCovers($iAlbumId, $aParams=array())
Definition: ChPhotosSearch.php:114
getProfileLink
getProfileLink( $iID, $sLinkAdd='')
Definition: profiles.inc.php:484
ChPhotosSearch\__construct
__construct($sParamName='', $sParamValue='', $sParamValue1='', $sParamValue2='')
Definition: ChPhotosSearch.php:12
ChPhotosSearch\serviceGetEntry
serviceGetEntry($iId, $sType='thumb')
Definition: ChPhotosSearch.php:240
ChTemplSearchResultSharedMedia
Definition: ChTemplSearchResultSharedMedia.php:11
ChBaseSearchResultSharedMedia\getFilesInCatArray
getFilesInCatArray($iId, $sCategory='')
Definition: ChBaseSearchResultSharedMedia.php:383
ChPhotosSearch\serviceGetWallPostOutline
serviceGetWallPostOutline($aEvent)
Definition: ChPhotosSearch.php:462
$sCaption
$sCaption
Definition: tellfriend.php:39
$iProfId
$iProfId
Definition: short_profile_info.php:22
ChPhotosSearch\serviceGetImage
serviceGetImage($aImageInfo, $sImgType='thumb')
Definition: ChPhotosSearch.php:229
ChPhotosSearch\addCustomParts
addCustomParts()
Definition: ChPhotosSearch.php:96
ChBaseSearchResultSharedMedia\getFilesInAlbumArray
getFilesInAlbumArray($iAlbumId, $aLimits=array())
Definition: ChBaseSearchResultSharedMedia.php:415
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
ChPhotosSearch\_getImageFullUrl
_getImageFullUrl($aImageInfo, $sType='thumb')
Definition: ChPhotosSearch.php:319
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChBaseSearchResultSharedMedia\getCurrentUrl
getCurrentUrl($sType, $iId=0, $sUri='', $aOwner='')
Definition: ChBaseSearchResultSharedMedia.php:130
$sName
$sName
Definition: ChWsbAdminTools.php:853
$iProfileId
if( $sMembersList) $iProfileId
Definition: communicator.php:29
ChWsbAlbums\getAbumUri
static getAbumUri($sName, $iUserId)
Definition: ChWsbAlbums.php:50
clear_xss
clear_xss($val)
Definition: utils.inc.php:700