Cheetah
ChWsbFilesPageHome.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbPageView');
9 ch_import('ChWsbPrivacy');
10 
12 {
13  var $oModule;
14  var $oDb;
15  var $oConfig;
17  var $oSearch;
18 
19  var $aVisible = array();
20 
21  function __construct (&$oShared)
22  {
23  parent::__construct($oShared->_oConfig->getMainPrefix() . '_home');
24  $this->oModule = $oShared;
25  $this->oDb = $oShared->_oDb;
26  $this->oConfig = $oShared->_oConfig;
27  $this->oTemplate = $oShared->_oTemplate;
28  ch_import('Search', $this->oModule->_aModule);
29  $sClassSearch = $this->oConfig->getClassPrefix() . 'Search';
30  $this->oSearch = new $sClassSearch();
31  $this->aVisible[] = CH_WSB_PG_ALL;
32  if ($this->iMemberID)
33  $this->aVisible[] = CH_WSB_PG_MEMBERS;
34  $this->oSearch->aCurrent['restriction']['allow_view']['value'] = $this->aVisible;
35  $this->oSearch->aCurrent['restriction']['activeStatus']['value'] = 'approved';
36  $this->oSearch->aCurrent['restriction']['album_status']['value'] = 'active';
37  }
38 
39  function getBlockCode_All ($id)
40  {
41  $this->oSearch->clearFilters(array('activeStatus', 'allow_view', 'album_status', 'albumType', 'ownerStatus'), array('albumsObjects', 'albums'));
42  $this->oSearch->aCurrent['paginate']['perPage'] = (int)$this->oConfig->getGlParam('number_home');
43  $this->oSearch->aCurrent['view'] = 'full';
44  if (isset($this->oSearch->aCurrent['rss']))
45  $this->oSearch->aCurrent['rss']['link'] = $this->oSearch->getCurrentUrl('browseAll', 0, '');
46 
47  $sCode = $this->oSearch->displayResultBlock();
48  if ($this->oSearch->aCurrent['paginate']['totalNum'] > 0) {
49  $sCode = $this->wrapUnits($sCode);
50 
51  $aExclude = array('r');
52  $sMode = isset($_GET[$this->oConfig->getMainPrefix() . '_mode']) ? '&_' . $this->oConfig->getMainPrefix() . '_mode=' . rawurlencode($_GET['ch_' . $this->oConfig->getUri() . '_mode']) : '';
53  $sLink = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'home/';
54  $aLinkAddon = $this->oSearch->getLinkAddByPrams($aExclude);
55  $oPaginate = new ChWsbPaginate(array(
56  'page_url' => $sLink,
57  'count' => $this->oSearch->aCurrent['paginate']['totalNum'],
58  'per_page' => $this->oSearch->aCurrent['paginate']['perPage'],
59  'page' => $this->oSearch->aCurrent['paginate']['page'],
60  'on_change_page' => 'return !loadDynamicBlock(' . $id . ', \'' . $sLink . $sMode . $aLinkAddon['params'] . '&page={page}&per_page={per_page}\');',
61  'on_change_per_page' => 'return !loadDynamicBlock(' . $id . ', \'' . $sLink . $sMode . $aLinkAddon['params'] . '&page=1&per_page=\' + this.value);'
62  ));
63  $aTopMenu = $this->oSearch->getTopMenu(array($this->oConfig->getMainPrefix() . '_mode'));
64  $sPaginate = $oPaginate->getPaginate();
65  } else {
66  $sCode = MsgBox(_t("_Empty"));
67  $aTopMenu = array();
68  $sPaginate = '';
69  }
70  return array($sCode, $aTopMenu, $sPaginate, true);
71  }
72 
73  function getBlockCode_Albums ()
74  {
75  $this->oSearch->clearFilters(array('activeStatus', 'allow_view', 'album_status', 'albumType', 'ownerStatus'), array('albumsObjects', 'albums'));
76  $aAlbumParams = array(
77  'allow_view' => $this->aVisible,
78  'obj_count' => array('min' => (int)$this->oConfig->getGlParam('number_albums_public_objects') - 1)
79  );
80  $aCustom = array(
81  'paginate_url' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'home',
82  'simple_paginate_url' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'albums/browse/all',
83  );
84  $aCode = $this->oSearch->getAlbumsBlock(array(), $aAlbumParams, $aCustom);
85  if ($this->oSearch->aCurrent['paginate']['totalAlbumNum'] > 0)
86  return $aCode;
87  else
88  return MsgBox(_t('_Empty'));
89  }
90 
92  {
93  $this->oSearch->aCurrent['restriction']['featured'] = array(
94  'field' => 'Featured',
95  'value' => '',
96  'operator' => '=',
97  'paramName' => 'featured'
98  );
99  $this->oSearch->aConstants['linksTempl']['featured'] = 'browse/featured';
100  $aCustom = array(
101  'per_page' => (int)$this->oConfig->getGlParam('number_top'),
102  'menu_bottom_type' => 'featured',
103  'wrapper_class' => 'result_block'
104  );
105  $aCode = $this->oSearch->getBrowseBlock(array('featured' => 1, 'allow_view' => $this->aVisible), $aCustom, CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'home');
106  if ($this->oSearch->aCurrent['paginate']['totalNum'] > 0)
107  return array($aCode['code'], $aCode['menu_top'], $aCode['menu_bottom'], '');
108  }
109 
111  {
112  $this->oSearch->clearFilters(array('activeStatus', 'allow_view', 'album_status', 'albumType', 'ownerStatus'), array('albumsObjects', 'albums'));
113  $this->oSearch->aCurrent['restriction']['featured'] = array(
114  'field' => 'Featured',
115  'value' => '1',
116  'operator' => '=',
117  'param' => 'featured'
118  );
119  $sContent = $this->oSearch->getLatestFile();
120  return !empty($sContent) ? $sContent : '';
121  }
122 
123  function getBlockCode_Tags($iBlockId)
124  {
125  ch_import('ChTemplTags');
126  $oTags = new ChTemplTags();
127  $oTags->getTagObjectConfig();
128 
129  return $oTags->display(
130  array(
131  'type' => $this->oConfig->getMainPrefix(),
132  'orderby' => 'popular',
133  'limit' => getParam('tags_show_limit'),
134  ),
135  $iBlockId, '', CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'tags'
136  );
137  }
138 
139  function getBlockCode_Calendar($iBlockId)
140  {
141  $sClassName = $this->oConfig->getClassPrefix() . 'Calendar';
142  ch_import('Calendar', $this->oSearch->oModule->_aModule);
143  $sDate = ch_get('date');
144  if (!$sDate)
145  $sDate = date("Y-m");
146 
147  list($iYear, $iMonth) = explode('/', $sDate);
148 
149  $oCalendar = new $sClassName($iYear, $iMonth, $this->oDb, $this->oTemplate, $this->oConfig);
150  $oCalendar->setBlockId($iBlockId);
151  $oCalendar->setDynamicUrl(CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'home/');
152  return $oCalendar->display(true);
153  }
154 
155  function wrapUnits($sCode, $bCenter = true, $bIndent = true, $sIndent = 'default_padding_thd.html')
156  {
157  if($bCenter)
158  $sCode = $GLOBALS['oFunctions']->centerContent($sCode, '.sys_file_search_unit');
159 
160  if($bIndent && $sIndent != '')
161  $sCode = $this->oTemplate->parseHtmlByName($sIndent, array('content' => $sCode));
162 
163  return $sCode;
164  }
165 }
ChWsbFilesPageHome\$oModule
$oModule
Definition: ChWsbFilesPageHome.php:13
$sMode
else $sMode
Definition: antispam.php:362
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChWsbPageView
Definition: ChWsbPageView.php:99
ChWsbFilesPageHome
Definition: ChWsbFilesPageHome.php:12
ChWsbFilesPageHome\__construct
__construct(&$oShared)
Definition: ChWsbFilesPageHome.php:21
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ch_get
ch_get($sName)
Definition: utils.inc.php:1664
php
ChWsbFilesPageHome\getBlockCode_Calendar
getBlockCode_Calendar($iBlockId)
Definition: ChWsbFilesPageHome.php:139
ChWsbFilesPageHome\getBlockCode_Special
getBlockCode_Special()
Definition: ChWsbFilesPageHome.php:91
ChWsbFilesPageHome\$oConfig
$oConfig
Definition: ChWsbFilesPageHome.php:15
$_GET
$_GET['debug']
Definition: index.php:67
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
ChWsbFilesPageHome\getBlockCode_LatestFile
getBlockCode_LatestFile()
Definition: ChWsbFilesPageHome.php:110
ChWsbFilesPageHome\wrapUnits
wrapUnits($sCode, $bCenter=true, $bIndent=true, $sIndent='default_padding_thd.html')
Definition: ChWsbFilesPageHome.php:155
ChTemplTags
Definition: ChTemplTags.php:11
ChWsbPaginate
Definition: ChWsbPaginate.php:69
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChWsbFilesPageHome\getBlockCode_Tags
getBlockCode_Tags($iBlockId)
Definition: ChWsbFilesPageHome.php:123
CH_WSB_PG_ALL
const CH_WSB_PG_ALL
Definition: ChWsbPrivacy.php:12
ChWsbFilesPageHome\$aVisible
$aVisible
Definition: ChWsbFilesPageHome.php:19
ChWsbFilesPageHome\getBlockCode_All
getBlockCode_All($id)
Definition: ChWsbFilesPageHome.php:39
ChWsbFilesPageHome\$oTemplate
$oTemplate
Definition: ChWsbFilesPageHome.php:16
CH_WSB_PG_MEMBERS
const CH_WSB_PG_MEMBERS
Definition: ChWsbPrivacy.php:13
ChWsbFilesPageHome\$oSearch
$oSearch
Definition: ChWsbFilesPageHome.php:17
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
ChWsbFilesPageHome\getBlockCode_Albums
getBlockCode_Albums()
Definition: ChWsbFilesPageHome.php:73
ChWsbPageView\$sCode
$sCode
Definition: ChWsbPageView.php:102
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
ChWsbFilesPageHome\$oDb
$oDb
Definition: ChWsbFilesPageHome.php:14