Cheetah
ChVideosPageView.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbPageView');
9 
10 require_once('ChVideosCmts.php');
11 require_once('ChVideosSearch.php');
12 
14 {
17 
18  var $oModule;
20  var $oConfig;
21  var $oDb;
22  var $oSearch;
23 
24  function __construct (&$oShared, &$aFileInfo)
25  {
26  parent::__construct('ch_videos_view');
27  $this->aFileInfo = $aFileInfo;
28  $this->iProfileId = &$oShared->_iProfileId;
29 
30  $this->oModule = $oShared;
31  $this->oTemplate = $oShared->_oTemplate;
32  $this->oConfig = $oShared->_oConfig;
33  $this->oDb = $oShared->_oDb;
34  $this->oSearch = new ChVideosSearch();
35  $this->oTemplate->addCss(array('view.css', 'search.css'));
36  ch_import ('ChWsbViews');
37  new ChWsbViews('ch_' . $this->oConfig->getUri(), $this->aFileInfo['medID']);
38  }
39 
41  {
42  $sCode = null;
43  $sMainPrefix = $this->oConfig->getMainPrefix();
44 
45  ch_import('ChWsbSubscription');
47  $aButton = $oSubscription->getButton($this->iProfileId, $sMainPrefix, '', (int)$this->aFileInfo['medID']);
48  $sCode .= $oSubscription->getData();
49 
50  $aReplacement = array(
51  'favorited' => $this->aFileInfo['favorited'] == false ? '' : 'favorited',
52  'featured' => (int)$this->aFileInfo['Featured'],
53  'featuredCpt' => '',
54  'approvedCpt' => '',
55  'approvedAct' => '',
56  'moduleUrl' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri(),
57  'fileUri' => $this->aFileInfo['medUri'],
58  'iViewer' => $this->iProfileId,
59  'ID' => (int)$this->aFileInfo['medID'],
60  'Owner' => (int)$this->aFileInfo['medProfId'],
61  'OwnerName' => $this->aFileInfo['NickName'],
62  'AlbumUri' => $this->aFileInfo['albumUri'],
63  'sbs_' . $sMainPrefix . '_title' => $aButton['title'],
64  'sbs_' . $sMainPrefix . '_script' => $aButton['script'],
65  'shareCpt' => $this->oModule->isAllowedShare($this->aFileInfo) ? _t('_Share') : '',
66  'downloadCpt' => $this->oModule->isAllowedDownload($this->aFileInfo) && empty($this->aFileInfo['medSource']) ? _t('_Download') : '',
67  );
68  if (isAdmin($this->iProfileId)) {
69  $sMsg = $aReplacement['featured'] > 0 ? 'un' : '';
70  $aReplacement['featuredCpt'] = _t('_' . $sMainPrefix . '_action_' . $sMsg . 'feature');
71  }
72  if ($this->oModule->isAllowedApprove($this->aFileInfo)) {
73  $sMsg = '';
74  $iAppr = 1;
75  if ($this->aFileInfo['Approved'] == 'approved')
76  {
77  $sMsg = 'de';
78  $iAppr = 0;
79  }
80  $aReplacement['approvedCpt'] = _t('_' . $sMainPrefix . '_admin_' . $sMsg . 'activate');
81  $aReplacement['approvedAct'] = $iAppr;
82  }
83 
84  $aReplacement['repostCpt'] = $aReplacement['repostScript'] = '';
85  if(ChWsbRequest::serviceExists('wall', 'get_repost_js_click')) {
86  $sCode .= ChWsbService::call('wall', 'get_repost_js_script');
87 
88  $aReplacement['repostCpt'] = _t('_Repost');
89  $aReplacement['repostScript'] = ChWsbService::call('wall', 'get_repost_js_click', array($this->iProfileId, $sMainPrefix, 'add', (int)$this->aFileInfo['medID']));
90  }
91 
92  $sActionsList = $GLOBALS['oFunctions']->genObjectsActions($aReplacement, $sMainPrefix);
93  if(is_null($sActionsList))
94  return '';
95 
96  return $sCode . $sActionsList;
97  }
98 
100  {
101  return $this->oTemplate->getFileAuthor($this->aFileInfo);
102  }
103 
105  {
106  $oAlbum = new ChWsbAlbums($this->oConfig->getMainPrefix());
107  $aAlbum = $oAlbum->getAlbumInfo(array('fileId' => $this->aFileInfo['albumId']));
108  return array($this->oSearch->displayAlbumUnit($aAlbum), array(), array(), false);
109  }
110 
112  {
113  $this->oSearch->clearFilters(array('activeStatus', 'albumType', 'allow_view', 'album_status'), array('albumsObjects', 'albums'));
114  $bLike = getParam('useLikeOperator');
115  if ($bLike != 'on') {
116  $aRel = array($this->aFileInfo['medTitle'], $this->aFileInfo['medDesc'], $this->aFileInfo['medTags'], $this->aFileInfo['Categories']);
117  $sKeywords = getRelatedWords($aRel);
118  if (!empty($sKeywords)) {
119  $this->oSearch->aCurrent['restriction']['keyword'] = array(
120  'value' => $sKeywords,
121  'field' => '',
122  'operator' => 'against'
123  );
124  }
125  } else {
126  $sKeywords = $this->aFileInfo['medTitle'].' '.$this->aFileInfo['medTags'];
127  $aWords = explode(' ', $sKeywords);
128  foreach (array_unique($aWords) as $iKey => $sValue) {
129  if (strlen($sValue) > 2) {
130  $this->oSearch->aCurrent['restriction']['keyword'.$iKey] = array(
131  'value' => trim(addslashes($sValue)),
132  'field' => '',
133  'operator' => 'against'
134  );
135  }
136  }
137  }
138  $this->oSearch->aCurrent['restriction']['id'] = array(
139  'value' => $this->aFileInfo['medID'],
140  'field' => $this->oSearch->aCurrent['ident'],
141  'operator' => '<>',
142  'paramName' => 'fileID'
143  );
144  $this->oSearch->aCurrent['sorting'] = 'score';
145  $iLimit = (int)$this->oConfig->getGlParam('number_related');
146  $iLimit = $iLimit == 0 ? 2 : $iLimit;
147 
148  $this->oSearch->aCurrent['paginate']['perPage'] = $iLimit;
149  $sCode = $this->oSearch->displayResultBlock();
150  $aBottomMenu = array();
151  $bWrap = true;
152  if ($this->oSearch->aCurrent['paginate']['totalNum'] > 0) {
153  $sCode = $GLOBALS['oFunctions']->centerContent($sCode, '.sys_file_search_unit');
154  $aBottomMenu = $this->oSearch->getBottomMenu('category', 0, $this->aFileInfo['Categories']);
155  $bWrap = '';
156  }
157  return array($sCode, array(), $aBottomMenu, $bWrap);
158  }
159 
161  {
162  $this->oTemplate->addCss('cmts.css');
163 
164  $oCmtsView = new ChVideosCmts('ch_' . $this->oConfig->getUri(), $this->aFileInfo['medID']);
165  if(!$oCmtsView->isEnabled())
166  return '';
167 
168  return $oCmtsView->getCommentsFirst();
169  }
170 
172  {
173  $this->aFileInfo['favCount'] = $this->oDb->getFavoritesCount($this->aFileInfo['medID']);
174  $sCode = $this->oTemplate->getViewFile($this->aFileInfo);
175  return array($sCode, array(), array(), false);
176  }
177 
179  {
180  return $this->oTemplate->getFileInfoMain($this->aFileInfo);
181  }
182 
184  {
185  if(!$this->oModule->isAllowedShare($this->aFileInfo))
186  return '';
187 
188  $sUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'view/' . $this->aFileInfo['medUri'];
189  $sTitle = $this->aFileInfo['medTitle'];
190  $aFile = $this->oSearch->serviceGetEntry($this->aFileInfo['medID'], 'poster');
191 
192  ch_import('ChTemplSocialSharing');
194  'img_url' => $aFile['file'],
195  'img_url_encoded' => rawurlencode($aFile['file']),
196  ));
197 
198  return array($sCode, array(), array(), false);
199  }
200 }
ChWsbSocialSharing\getInstance
static getInstance()
Definition: ChWsbSocialSharing.php:50
ChWsbPageView
Definition: ChWsbPageView.php:99
ChWsbRequest\serviceExists
static serviceExists($mixedModule, $sMethod, $sClass="Module")
Definition: ChWsbRequest.php:70
ChVideosPageView\$oDb
$oDb
Definition: ChVideosPageView.php:21
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChVideosPageView\getBlockCode_ViewFile
getBlockCode_ViewFile()
Definition: ChVideosPageView.php:171
$sUrl
$sUrl
Definition: cart.php:15
php
$sMsg
$sMsg
Definition: actions.inc.php:22
ChVideosPageView\getBlockCode_SocialSharing
getBlockCode_SocialSharing()
Definition: ChVideosPageView.php:183
ChWsbSubscription\getInstance
static getInstance()
Definition: ChWsbSubscription.php:67
isAdmin
isAdmin()
Definition: index.php:649
ChVideosPageView\$iProfileId
$iProfileId
Definition: ChVideosPageView.php:15
ChVideosPageView\getBlockCode_MainFileInfo
getBlockCode_MainFileInfo()
Definition: ChVideosPageView.php:178
ChVideosPageView\getBlockCode_ActionList
getBlockCode_ActionList()
Definition: ChVideosPageView.php:40
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
$sTitle
$sTitle
Definition: actions.inc.php:13
ChWsbAlbums
Definition: ChWsbAlbums.php:9
ChVideosPageView\$oSearch
$oSearch
Definition: ChVideosPageView.php:22
ChVideosPageView\$oModule
$oModule
Definition: ChVideosPageView.php:18
ChWsbViews
Definition: ChWsbViews.php:38
ChVideosPageView\getBlockCode_FileAuthor
getBlockCode_FileAuthor()
Definition: ChVideosPageView.php:99
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChVideosPageView\$aFileInfo
$aFileInfo
Definition: ChVideosPageView.php:16
ChVideosSearch
Definition: ChVideosSearch.php:11
ChVideosPageView\getBlockCode_ViewAlbum
getBlockCode_ViewAlbum()
Definition: ChVideosPageView.php:104
ChVideosPageView\$oTemplate
$oTemplate
Definition: ChVideosPageView.php:19
ChVideosPageView\getBlockCode_ViewComments
getBlockCode_ViewComments()
Definition: ChVideosPageView.php:160
getRelatedWords
getRelatedWords(&$aInfo)
Definition: utils.inc.php:1451
ChVideosCmts
Definition: ChVideosCmts.php:11
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
ChVideosPageView\$oConfig
$oConfig
Definition: ChVideosPageView.php:20
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChVideosPageView\__construct
__construct(&$oShared, &$aFileInfo)
Definition: ChVideosPageView.php:24
ChVideosPageView\getBlockCode_RelatedFiles
getBlockCode_RelatedFiles()
Definition: ChVideosPageView.php:111
ChWsbPageView\$sCode
$sCode
Definition: ChWsbPageView.php:102
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
ChVideosPageView
Definition: ChVideosPageView.php:14
$oSubscription
$oSubscription
Definition: notifies.php:28