Cheetah
ChWsbTwigPageView.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import ('ChWsbPageView');
9 
14 {
16  var $_oMain;
17  var $_oDb;
18  var $_oConfig;
20 
21  function __construct($sName, &$oMain, &$aDataEntry)
22  {
23  parent::__construct($sName);
24  $this->_oMain = $oMain;
25  $this->_oTemplate = $oMain->_oTemplate;
26  $this->_oDb = $oMain->_oDb;
27  $this->_oConfig = $oMain->_oConfig;
28  $this->aDataEntry = &$aDataEntry;
29  }
30 
32  {
33  if(!$this->_oMain->isAllowedShare($this->aDataEntry))
34  return '';
35 
36  $sUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $this->aDataEntry[$this->_oDb->_sFieldUri];
37  $sTitle = $this->aDataEntry[$this->_oDb->_sFieldTitle];
38 
39  $aCustomParams = false;
40  if ($this->aDataEntry[$this->_oDb->_sFieldThumb]) {
41  $a = array('ID' => $this->aDataEntry[$this->_oDb->_sFieldAuthorId], 'Avatar' => $this->aDataEntry[$this->_oDb->_sFieldThumb]);
42  $aImage = ChWsbService::call('photos', 'get_image', array($a, 'browse'), 'Search');
43  $sImgUrl = $aImage['no_image'] ? '' : $aImage['file'];
44  if ($sImgUrl) {
45  $aCustomParams = array (
46  'img_url' => $sImgUrl,
47  'img_url_encoded' => rawurlencode($sImgUrl),
48  );
49  }
50  }
51 
52  ch_import('ChTemplSocialSharing');
53  $sCode = ChTemplSocialSharing::getInstance()->getCode($sUrl, $sTitle, $aCustomParams);
54  return array($sCode, array(), array(), false);
55  }
56 
58  {
59  if (!$this->_oMain->isAllowedReadForum($this->aDataEntry))
60  return '';
61 
62  $oModuleDb = new ChWsbModuleDb();
63  if (!$oModuleDb->getModuleByUri('forum'))
64  return '';
65 
66  $sRssId = 'forum|' . $this->_oConfig->getUri() . '|' . rawurlencode($this->aDataEntry[$this->_oDb->_sFieldUri]);
67  return '<div class="RSSAggrCont" rssid="' . $sRssId . '" rssnum="8" member="' . getLoggedId() . '">' . $GLOBALS['oFunctions']->loadingBoxInline() . '</div>';
68  }
69 
70  function _blockInfo ($aData, $sFields = '', $sLocation = '')
71  {
72  $aAuthor = getProfileInfo($aData['author_id']);
73 
74  $aVars = array (
75  'date' => getLocaleDate($aData['created'], CH_WSB_LOCALE_DATE_SHORT),
76  'date_ago' => defineTimeInterval($aData['created'], false),
77  'cats' => $this->_oTemplate->parseCategories($aData['categories']),
78  'tags' => $this->_oTemplate->parseTags($aData['tags']),
79  'fields' => $sFields,
80  'author_unit' => $GLOBALS['oFunctions']->getMemberThumbnail($aAuthor['ID'], 'none', true),
81  'location' => $sLocation,
82  );
83  return $this->_oTemplate->parseHtmlByName('entry_view_block_info', $aVars);
84  }
85 
86  function _blockPhoto (&$aReadyMedia, $iAuthorId, $sPrefix = false)
87  {
88  if (!$aReadyMedia)
89  return '';
90 
91  $aImages = array ();
92 
93  foreach ($aReadyMedia as $iMediaId) {
94 
95  $a = array ('ID' => $iAuthorId, 'Avatar' => $iMediaId);
96 
97  $aImageFile = ChWsbService::call('photos', 'get_image', array($a, 'file'), 'Search');
98  if ($aImageFile['no_image'])
99  continue;
100 
101  $aImageIcon = ChWsbService::call('photos', 'get_image', array($a, 'icon'), 'Search');
102  if ($aImageIcon['no_image'])
103  continue;
104 
105  $aImages[] = array (
106  'icon_url' => $aImageIcon['file'],
107  'image_url' => $aImageFile['file'],
108  'title' => $aImageIcon['title'],
109  );
110  }
111 
112  if (!$aImages)
113  return '';
114 
115  return $GLOBALS['oFunctions']->genGalleryImages($aImages);
116  }
117 
118  function _blockVideo ($aReadyMedia, $iAuthorId, $sPrefix = false)
119  {
120  if (!$aReadyMedia)
121  return '';
122 
123  $aVars = array (
124  'title' => false,
125  'prefix' => $sPrefix ? $sPrefix : 'id'.time().'_'.rand(1, 999999),
126  'default_height' => getSettingValue('video', 'player_height'),
127  'ch_repeat:videos' => array (),
128  'ch_repeat:icons' => array (),
129  );
130 
131  foreach ($aReadyMedia as $iMediaId) {
132 
133  $a = ChWsbService::call('videos', 'get_video_array', array($iMediaId), 'Search');
134  $a['ID'] = $iMediaId;
135 
136  $aVars['ch_repeat:videos'][] = array (
137  'style' => false === $aVars['title'] ? '' : 'display:none;',
138  'id' => $iMediaId,
139  'video' => ChWsbService::call('videos', 'get_video_concept', array($a), 'Search'),
140  );
141  $aVars['ch_repeat:icons'][] = array (
142  'id' => $iMediaId,
143  'icon_url' => $a['file'],
144  'title' => $a['title'],
145  );
146  if (false === $aVars['title'])
147  $aVars['title'] = $a['title'];
148  }
149 
150  if (!$aVars['ch_repeat:icons'])
151  return '';
152 
153  return $this->_oTemplate->parseHtmlByName('entry_view_block_videos', $aVars);
154  }
155 
156  function _blockFiles ($aReadyMedia, $iAuthorId = 0)
157  {
158  if (!$aReadyMedia)
159  return '';
160 
161  $aVars = array (
162  'ch_repeat:files' => array (),
163  );
164 
165  foreach ($aReadyMedia as $iMediaId) {
166 
167  $a = ChWsbService::call('files', 'get_file_array', array($iMediaId), 'Search');
168  if (!$a['date'])
169  continue;
170 
171  ch_import('ChTemplFormView');
172  $oForm = new ChTemplFormView(array());
173 
174  $aInputBtnDownload = array (
175  'type' => 'submit',
176  'name' => 'download',
177  'value' => _t ('_download'),
178  'attrs' => array(
179  'class' => 'ch-btn-small',
180  'onclick' => "window.open ('" . CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . "download/".$this->aDataEntry[$this->_oDb->_sFieldId]."/{$iMediaId}','_self');",
181  ),
182  );
183 
184  $aVars['ch_repeat:files'][] = array (
185  'id' => $iMediaId,
186  'title' => $a['title'],
187  'icon' => $a['file'],
188  'date' => defineTimeInterval($a['date']),
189  'btn_download' => $oForm->genInputButton ($aInputBtnDownload),
190  );
191  }
192 
193  if (!$aVars['ch_repeat:files'])
194  return '';
195 
196  return $this->_oTemplate->parseHtmlByName('entry_view_block_files', $aVars);
197  }
198 
199  function _blockSound ($aReadyMedia, $iAuthorId, $sPrefix = false)
200  {
201  if (!$aReadyMedia)
202  return '';
203 
204  $aVars = array (
205  'title' => false,
206  'prefix' => $sPrefix ? $sPrefix : 'id'.time().'_'.rand(1, 999999),
207  'default_height' => 350,
208  'ch_repeat:sounds' => array (),
209  'ch_repeat:icons' => array (),
210  );
211 
212  foreach ($aReadyMedia as $iMediaId) {
213 
214  $a = ChWsbService::call('sounds', 'get_music_array', array($iMediaId, 'browse'), 'Search');
215  $a['ID'] = $iMediaId;
216 
217  $aVars['ch_repeat:sounds'][] = array (
218  'style' => false === $aVars['title'] ? '' : 'display:none;',
219  'id' => $iMediaId,
220  'sound' => ChWsbService::call('sounds', 'get_sound_concept', array($a), 'Search'),
221  );
222  $aVars['ch_repeat:icons'][] = array (
223  'id' => $iMediaId,
224  'icon_url' => $a['file'],
225  'title' => $a['title'],
226  );
227  if (false === $aVars['title'])
228  $aVars['title'] = $a['title'];
229  }
230 
231  if (!$aVars['ch_repeat:icons'])
232  return '';
233 
234  return $this->_oTemplate->parseHtmlByName('entry_view_block_sounds', $aVars);
235  }
236 
237  function _blockFans($iPerPage, $sFuncIsAllowed = 'isAllowedViewFans', $sFuncGetFans = 'getFans')
238  {
239  if (!$this->_oMain->$sFuncIsAllowed($this->aDataEntry))
240  return '';
241 
242  $iPage = (int)$_GET['page'];
243  if( $iPage < 1)
244  $iPage = 1;
245  $iStart = ($iPage - 1) * $iPerPage;
246 
247  $aProfiles = array ();
248  $iNum = $this->_oDb->$sFuncGetFans($aProfiles, $this->aDataEntry[$this->_oDb->_sFieldId], true, $iStart, $iPerPage);
249  if (!$iNum || !$aProfiles)
250  return MsgBox(_t("_Empty"));
251 
252  ch_import('ChTemplSearchProfile');
253  $oChTemplSearchProfile = new ChTemplSearchProfile();
254  $sMainContent = '';
255  foreach ($aProfiles as $aProfile) {
256  $sMainContent .= $oChTemplSearchProfile->displaySearchUnit($aProfile, array ('ext_css_class' => 'ch-def-margin-sec-top-auto'));
257  }
258  $ret .= $sMainContent;
259  $ret .= '<div class="clear_both"></div>';
260 
261  $oPaginate = new ChWsbPaginate(array(
262  'page_url' => 'javascript:void(0);',
263  'count' => $iNum,
264  'per_page' => $iPerPage,
265  'page' => $iPage,
266  'on_change_page' => 'return !loadDynamicBlock({id}, \'' . ch_append_url_params(CH_WSB_URL_ROOT . $this->_oMain->_oConfig->getBaseUri() . "view/" . $this->aDataEntry[$this->_oDb->_sFieldUri], 'page={page}&per_page={per_page}') . '\');',
267  ));
268  $sAjaxPaginate = $oPaginate->getSimplePaginate('', -1, -1, false);
269 
270  return array($ret, array(), $sAjaxPaginate);
271  }
272 
273  function _blockFansUnconfirmed($iFansLimit = 1000)
274  {
275  if (!$this->_oMain->isEntryAdmin($this->aDataEntry))
276  return '';
277 
278  $aProfiles = array ();
279  $iNum = $this->_oDb->getFans($aProfiles, $this->aDataEntry[$this->_oDb->_sFieldId], false, 0, $iFansLimit);
280  if (!$iNum)
281  return MsgBox(_t('_Empty'));
282 
283  $sActionsUrl = ch_append_url_params(CH_WSB_URL_ROOT . $this->_oMain->_oConfig->getBaseUri() . "view/" . $this->aDataEntry[$this->_oDb->_sFieldUri], array('ajax_action' => ''));
284  $aButtons = array (
285  array (
286  'type' => 'submit',
287  'name' => 'fans_reject',
288  'value' => _t('_sys_btn_fans_reject'),
289  'onclick' => "onclick=\"getHtmlData('sys_manage_items_unconfirmed_fans_content', '{$sActionsUrl}reject&ids=' + sys_manage_items_get_unconfirmed_fans_ids(), false, 'post'); return false;\"",
290  ),
291  array (
292  'type' => 'submit',
293  'name' => 'fans_confirm',
294  'value' => _t('_sys_btn_fans_confirm'),
295  'onclick' => "onclick=\"getHtmlData('sys_manage_items_unconfirmed_fans_content', '{$sActionsUrl}confirm&ids=' + sys_manage_items_get_unconfirmed_fans_ids(), false, 'post'); return false;\"",
296  ),
297  );
298  ch_import ('ChTemplSearchResult');
299  $sControl = ChTemplSearchResult::showAdminActionsPanel('sys_manage_items_unconfirmed_fans', $aButtons, 'sys_fan_unit');
300  $aVars = array(
301  'suffix' => 'unconfirmed_fans',
302  'content' => $this->_oMain->_profilesEdit($aProfiles),
303  'control' => $sControl,
304  );
305  return $this->_oMain->_oTemplate->parseHtmlByName('manage_items_form', $aVars);
306  }
307 }
ChWsbSocialSharing\getInstance
static getInstance()
Definition: ChWsbSocialSharing.php:50
ChWsbTwigPageView\_blockInfo
_blockInfo($aData, $sFields='', $sLocation='')
Definition: ChWsbTwigPageView.php:70
ChTemplFormView
Definition: ChTemplFormView.php:11
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChWsbPageView
Definition: ChWsbPageView.php:99
defineTimeInterval
defineTimeInterval($iTime, $bAutoDateConvert=true, $bShort=false)
Definition: utils.inc.php:831
ChTemplSearchProfile
Definition: ChTemplSearchProfile.php:11
name
Core AllowHostnameUnderscore underscores are not permitted in host most browsers do the right thing when faced with an underscore in the host name
Definition: Core.AllowHostnameUnderscore.txt:11
post
post($sTable, $sId, $sAuthor, $sParent, $sMood, $sFileId)
Definition: customFunctions.inc.php:8
$ret
$ret
Definition: index.php:39
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChWsbTwigPageView\$_oMain
$_oMain
Definition: ChWsbTwigPageView.php:16
ChWsbTwigPageView\$_oDb
$_oDb
Definition: ChWsbTwigPageView.php:17
ChWsbTwigPageView
Definition: ChWsbTwigPageView.php:14
ChWsbTwigPageView\$_oTemplate
$_oTemplate
Definition: ChWsbTwigPageView.php:15
$sUrl
$sUrl
Definition: cart.php:15
php
ChWsbModuleDb
Definition: ChWsbModuleDb.php:12
ChWsbTwigPageView\_blockFans
_blockFans($iPerPage, $sFuncIsAllowed='isAllowedViewFans', $sFuncGetFans='getFans')
Definition: ChWsbTwigPageView.php:237
$iPerPage
else $iPerPage
Definition: browse.php:61
ChWsbTwigPageView\getBlockCode_SocialSharing
getBlockCode_SocialSharing()
Definition: ChWsbTwigPageView.php:31
$oForm
$oForm
Definition: host_tools.php:42
ChWsbTwigPageView\_blockSound
_blockSound($aReadyMedia, $iAuthorId, $sPrefix=false)
Definition: ChWsbTwigPageView.php:199
$_GET
$_GET['debug']
Definition: index.php:67
$oModuleDb
$oModuleDb
Definition: classifieds.php:20
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
ChWsbTwigPageView\_blockPhoto
_blockPhoto(&$aReadyMedia, $iAuthorId, $sPrefix=false)
Definition: ChWsbTwigPageView.php:86
$sTitle
$sTitle
Definition: actions.inc.php:13
content
AutoFormat RemoveEmpty HTML Purifier will attempt to remove empty elements that contribute no semantic information to the document The following types of nodes will be and that are not empty and</li >< li > Tags with no content
Definition: AutoFormat.RemoveEmpty.txt:17
$aProfile
$aProfile
Definition: flash.php:14
ChTemplSearchResult
Definition: ChTemplSearchResult.php:11
ch_append_url_params
ch_append_url_params($sUrl, $mixedParams)
Definition: utils.inc.php:1697
type
if(!defined("USER_STATUS_TYPE")) define("USER_STATUS_TYPE" type
Definition: constants.inc.php:13
ChWsbTwigPageView\_blockVideo
_blockVideo($aReadyMedia, $iAuthorId, $sPrefix=false)
Definition: ChWsbTwigPageView.php:118
ChWsbPaginate
Definition: ChWsbPaginate.php:69
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChWsbTwigPageView\$_oConfig
$_oConfig
Definition: ChWsbTwigPageView.php:18
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
value
URI Base such as when URI MakeAbsolute is on You may use a non absolute URI for this value
Definition: URI.Base.txt:11
CH_WSB_LOCALE_DATE_SHORT
const CH_WSB_LOCALE_DATE_SHORT
Definition: utils.inc.php:15
ChWsbTwigPageView\getBlockCode_ForumFeed
getBlockCode_ForumFeed()
Definition: ChWsbTwigPageView.php:57
ChWsbTwigPageView\$aDataEntry
$aDataEntry
Definition: ChWsbTwigPageView.php:19
$aVars
$aVars
Definition: license.php:101
ChWsbTwigPageView\_blockFiles
_blockFiles($aReadyMedia, $iAuthorId=0)
Definition: ChWsbTwigPageView.php:156
$iPage
$iPage
Definition: browse.php:50
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
getSettingValue
getSettingValue($sWidget, $sSettingKey, $sFile="config", $bFullReturn=false, $sFolder="xml")
Definition: apiFunctions.inc.php:82
ChWsbTwigPageView\__construct
__construct($sName, &$oMain, &$aDataEntry)
Definition: ChWsbTwigPageView.php:21
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
getLocaleDate
getLocaleDate($sTimestamp='', $iCode=CH_WSB_LOCALE_DATE_SHORT)
Definition: utils.inc.php:70
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$sName
$sName
Definition: ChWsbAdminTools.php:853
ChWsbPageView\$sCode
$sCode
Definition: ChWsbPageView.php:102
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10