Cheetah
ChWsbFilesPageAlbumsOwner.php
Go to the documentation of this file.
1 <?php
2 
8 require_once(CH_DIRECTORY_PATH_CLASSES . 'ChWsbPageView.php');
9 require_once(CH_DIRECTORY_PATH_CLASSES . 'ChWsbAlbums.php');
10 
12 {
13  var $oAlbum;
14  var $oModule;
16  var $oConfig;
17  var $oDb;
18  var $iOwnerId;
20 
21  function __construct($sPageName, &$oShared, $aParams = array())
22  {
23  parent::__construct($sPageName);
24  $this->oModule = $oShared;
25  $this->oTemplate = $oShared->_oTemplate;
26  $this->oConfig = $oShared->_oConfig;
27  $this->oDb = $oShared->_oDb;
28 
29  $this->aAddParams = $aParams;
30  list($sParamName, $sParamValue, $sParamValue1, $sParamValue2, $sParamValue3) = $this->aAddParams;
31 
32  $this->iOwnerId = getID($sParamValue1);
33  $this->oAlbum = new ChWsbAlbums($this->oConfig->getMainPrefix(), $this->iOwnerId);
34  }
35 
36  function getBlockCode_Browse($iBlockId)
37  {
38  foreach ($this->aAddParams as $sValue) {
39  if (strlen($sValue) > 0) {
40  $sArg .= '/' . rawurlencode($sValue);
41  } else {
42  break;
43  }
44  }
45  $aCustom['simple_paginate_url'] = $aCustom['paginate_url'] = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'albums' . $sArg;
46  $aCustom['simple_paginate_view_all'] = false;
47 
48  $oSearch = $this->getSearchObject();
49  $aCode = $oSearch->getAlbumsBlock(array(), array('hide_default' => true), $aCustom);
50  if (!$oSearch->aCurrent['paginate']['totalAlbumNum']) {
51  return MsgBox(_t('_Empty'));
52  }
53 
54  return $aCode;
55  }
56 
57  function getBlockCode_Favorited($aParams = array())
58  {
59  $sEmpty = MsgBox(_t('_Empty'));
60 
61  if ($this->iOwnerId == 0) {
62  return $sEmpty;
63  }
64 
65  $sUnitCssClass = isset($aParams['unit_css_class']) ? $aParams['unit_css_class'] : '.sys_file_search_unit';
66 
67  $oSearch = $this->getSearchObject();
68  $oSearch->clearFilters(array('activeStatus', 'allow_view', 'album_status', 'albumType', 'ownerStatus'),
69  array('albumsObjects', 'albums', 'icon'));
70  if (isset($oSearch->aAddPartsConfig['favorite']) && !empty($oSearch->aAddPartsConfig['favorite'])) {
71  $oSearch->aCurrent['join']['favorite'] = $oSearch->aAddPartsConfig['favorite'];
72  $oSearch->aCurrent['restriction']['fav'] = array(
73  'value' => $this->iOwnerId,
74  'field' => $oSearch->aAddPartsConfig['favorite']['userField'],
75  'operator' => '=',
76  'table' => $oSearch->aAddPartsConfig['favorite']['table']
77  );
78  }
79  $oSearch->aCurrent['paginate']['perPage'] = (int)$this->oConfig->getGlParam('number_top');
80 
81  $sCode = $oSearch->displayResultBlock();
82  if(!empty($sUnitCssClass))
83  $sCode = $GLOBALS['oFunctions']->centerContent($sCode, $sUnitCssClass);
84 
85  if($oSearch->aCurrent['paginate']['totalNum'] > 0) {
86  $oSearch->aConstants['linksTempl']['favorited'] = 'browse/favorited';
87 
88  $aBottomMenu = $oSearch->getBottomMenu('favorited', 0, '');
89 
90  return array($sCode, array(), $aBottomMenu, false);
91  } else {
92  return array($sEmpty, array(), array(), '');
93  }
94  }
95 
96  function getSearchObject()
97  {
98  list($sParamName, $sParamValue, $sParamValue1, $sParamValue2, $sParamValue3) = $this->aAddParams;
99 
100  ch_import('Search', $this->oModule->_aModule);
101  $sClassName = $this->oConfig->getClassPrefix() . 'Search';
102  $oSearch = new $sClassName($sParamValue, $sParamValue1, $sParamValue2, $sParamValue3);
103 
104  if (!empty($sParamValue) && !empty($sParamValue1) && isset($oSearch->aCurrent['restriction'][$sParamValue])) {
105  $oSearch->aCurrent['restriction'][$sParamValue]['value'] = 'owner' == $sParamValue ? getID($sParamValue1) : $sParamValue1;
106  }
107 
108  return $oSearch;
109  }
110 }
ChWsbFilesPageAlbumsOwner\$oModule
$oModule
Definition: ChWsbFilesPageAlbumsOwner.php:14
ChWsbFilesPageAlbumsOwner\$iOwnerId
$iOwnerId
Definition: ChWsbFilesPageAlbumsOwner.php:18
ChWsbFilesPageAlbumsOwner\$oConfig
$oConfig
Definition: ChWsbFilesPageAlbumsOwner.php:16
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChWsbPageView
Definition: ChWsbPageView.php:99
ChWsbFilesPageAlbumsOwner\$oDb
$oDb
Definition: ChWsbFilesPageAlbumsOwner.php:17
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
php
$sParamValue
$sParamValue
Definition: actions.inc.php:16
ChWsbFilesPageAlbumsOwner\getBlockCode_Favorited
getBlockCode_Favorited($aParams=array())
Definition: ChWsbFilesPageAlbumsOwner.php:57
$sParamName
$sParamName
Definition: actions.inc.php:15
ChWsbFilesPageAlbumsOwner\__construct
__construct($sPageName, &$oShared, $aParams=array())
Definition: ChWsbFilesPageAlbumsOwner.php:21
ChWsbFilesPageAlbumsOwner
Definition: ChWsbFilesPageAlbumsOwner.php:12
ChWsbAlbums
Definition: ChWsbAlbums.php:9
ChWsbFilesPageAlbumsOwner\getBlockCode_Browse
getBlockCode_Browse($iBlockId)
Definition: ChWsbFilesPageAlbumsOwner.php:36
ChWsbFilesPageAlbumsOwner\getSearchObject
getSearchObject()
Definition: ChWsbFilesPageAlbumsOwner.php:96
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChWsbPageView\$sPageName
$sPageName
Definition: ChWsbPageView.php:100
ChWsbFilesPageAlbumsOwner\$oAlbum
$oAlbum
Definition: ChWsbFilesPageAlbumsOwner.php:13
getID
getID( $str, $with_email=1)
Definition: admin.inc.php:139
ChWsbFilesPageAlbumsOwner\$oTemplate
$oTemplate
Definition: ChWsbFilesPageAlbumsOwner.php:15
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChWsbPageView\$sCode
$sCode
Definition: ChWsbPageView.php:102
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
ChWsbFilesPageAlbumsOwner\$aAddParams
$aAddParams
Definition: ChWsbFilesPageAlbumsOwner.php:19