Cheetah
ChVideosSearch.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('ChVideosModule');
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  );
26  // main part of aCurrent settings, usual most unique part of every module
27  $aMain = array(
28  'name' => 'ch_videos',
29  'title' => '_ch_videos',
30  'table' => 'RayVideoFiles'
31  );
32  $this->aCurrent = array_merge($aMain, $this->aCurrent);
33  $this->aCurrent['ownFields'] = array_merge($this->aCurrent['ownFields'], array('Views', 'Source', 'Video'));
34  $this->aCurrent['rss']['title'] = _t('_ch_videos');
35 
36  $this->aAddPartsConfig['favorite']['table'] = 'ch_videos_favorites';
37  $this->oModule = ChWsbModule::getInstance('ChVideosModule');
38  $this->oTemplate = &$this->oModule->_oTemplate;
39  $this->aConstants['filesUrl'] = $this->oModule->_oConfig->getFilesUrl();
40  $this->aConstants['filesDir'] = $this->oModule->_oConfig->getFilesPath();
41  $this->aConstants['filesInAlbumCover'] = 12;
42  $this->aConstants['picPostfix'] = $this->oModule->_oConfig->aFilePostfix;
43 
44  $this->aCurrent['restriction']['albumType']['value'] = $this->aCurrent['name'];
45 
46  switch ($sParamName) {
47  case 'calendar':
48  $this->aCurrent['restriction']['calendar-min'] = array('value' => "UNIX_TIMESTAMP('{$sParamValue}-{$sParamValue1}-{$sParamValue2} 00:00:00')", 'field' => 'Date', 'operator' => '>=', 'no_quote_value' => true);
49  $this->aCurrent['restriction']['calendar-max'] = array('value' => "UNIX_TIMESTAMP('{$sParamValue}-{$sParamValue1}-{$sParamValue2} 23:59:59')", 'field' => 'Date', 'operator' => '<=', 'no_quote_value' => true);
50  $this->aCurrent['title'] = _t('_ch_videos_caption_browse_by_day') . sprintf("%04u-%02u-%02u", $sParamValue, $sParamValue1, $sParamValue2);
51  break;
52  case 'top':
53  $this->aCurrent['sorting'] = 'top';
54  break;
55  case 'popular':
56  $this->aCurrent['sorting'] = 'popular';
57  break;
58  case 'featured':
59  $this->aCurrent['restriction']['featured'] = array(
60  'value'=>'1', 'field'=>'Featured', 'operator'=>'=', 'paramName'=>'ch_videos_mode'
61  );
62  break;
63  case 'favorited':
64  if (isset($this->aAddPartsConfig['favorite']) && !empty($this->aAddPartsConfig['favorite']) && getLoggedId() != 0) {
65  $this->aCurrent['join']['favorite'] = $this->aAddPartsConfig['favorite'];
66  $this->aCurrent['restriction']['fav'] = array(
67  'value' => getLoggedId(),
68  'field' => $this->aAddPartsConfig['favorite']['userField'],
69  'operator' => '=',
70  'table' => $this->aAddPartsConfig['favorite']['table']
71  );
72  }
73  break;
74  case 'album':
75  $this->aCurrent['sorting'] = 'album_order';
76  $this->aCurrent['restriction']['album'] = array(
77  'value'=>'', 'field'=>'Uri', 'operator'=>'=', 'paramName'=>'albumUri', 'table'=>'sys_albums'
78  );
79  if ($sParamValue1 == 'owner' && strlen($sParamValue2) > 0) {
80  $this->aCurrent['restriction']['owner'] = array(
81  'value'=>$sParamValue2, 'field'=>'NickName', 'operator'=>'=', 'paramName'=>'ownerName', 'table' => 'Profiles'
82  );
83  }
84  break;
85  }
86  }
87 
88  function serviceGetFileUrl ($iId, $sImgType = 'browse')
89  {
90  return $this->getImgUrl($iId, $sImgType);
91  }
92 
93  function serviceGetVideoConcept ($aVideo)
94  {
95  return $this->oTemplate->getFileConcept($aVideo['ID'], array('ext'=>$aVideo['video'], 'source'=>$aVideo['source']));
96  }
97 
98  function serviceGetEntry($iId, $sType = 'browse')
99  {
100  $iId = (int)$iId;
101  $sqlQuery = "SELECT a.`ID` as `id`,
102  a.`Title` as `title`,
103  a.`Description` as `description`,
104  a.`Uri` as `uri`,
105  a.`Owner` as `owner`,
106  a.`Date` as `date`,
107  a.`Video`,
108  a.`Source`,
109  a.`Time`,
110  a.`Rate` AS `rate`,
111  a.`RateCount` AS `rate_count`,
112  a.`CommentsCount` AS `comments_count`,
113  a.`Views` AS `views_count`,
114  a.`Status` AS `status`,
115  b.`id_album` as `album_id`
116  FROM `RayVideoFiles` as a
117  LEFT JOIN `sys_albums_objects` as b ON b.`id_object` = a.`ID`
118  LEFT JOIN `sys_albums` as c ON c.`ID`=b.`id_album`
119  WHERE a.`ID`='$iId' AND c.`Type`='ch_videos'";
120  $aImageInfo = db_arr($sqlQuery);
121 
122  if(empty($aImageInfo) || !is_array($aImageInfo))
123  return array();
124 
125  $sFileName = $sFilePath = '';
126  $sImg = $aImageInfo['id'] . $this->aConstants['picPostfix'][$sType];
127  if($sImg != '' && extFileExists($this->aConstants['filesDir'] . $sImg)) {
128  $sFileName = $this->aConstants['filesUrl'] . $sImg;
129  $sFilePath = $this->aConstants['filesDir'] . $sImg;
130  }
131 
132  return array(
133  'id' => $aImageInfo['id'],
134  'file' => $sFileName,
135  'file_path' => $sFilePath,
136  'title' => $aImageInfo['title'],
137  'owner' => $aImageInfo['owner'],
138  'description' => $aImageInfo['description'],
139  'width' => (int)$this->oModule->_oConfig->aFilesConfig['browse']['w'] + 2 * 2,
140  'height' => (int)$this->oModule->_oConfig->aFilesConfig['browse']['h'] + 2 * 2,
141  'url' => $this->getCurrentUrl('file', $iId, $aImageInfo['uri']),
142  'video' => $aImageInfo['Video'],
143  'source' => $aImageInfo['Source'],
144  'duration' => $aImageInfo['Time'],
145  'duration_f' => _format_time(round(($aImageInfo['Time'])/1000)),
146  'date' => $aImageInfo['date'],
147  'rate' => $aImageInfo['rate'],
148  'rate_count' => $aImageInfo['rate_count'],
149  'comments_count' => $aImageInfo['comments_count'],
150  'views_count' => $aImageInfo['views_count'],
151  'status' => $aImageInfo['status'],
152  'album_id' => $aImageInfo['album_id']
153  );
154  }
155 
156  function serviceGetItemArray($iId, $sType = 'browse')
157  {
158  return $this->serviceGetEntry($iId, $sType);
159  }
160 
161  function serviceGetVideoArray ($iId, $sType = 'browse')
162  {
163  return $this->serviceGetEntry($iId, $sType);
164  }
165 
166  function serviceGetFilesInCat ($iId, $sCategory = '')
167  {
168  $aFiles = $this->getFilesInCatArray($iId, $sCategory);
169  foreach ($aFiles as $k => $aRow) {
170  $aFiles[$k]['thumb'] = $this->getImgUrl($aRow['id'], 'browse');
171  $aFiles[$k]['file'] = $this->getImgUrl($aRow['id'], 'file');
172  }
173  return $aFiles;
174  }
175 
176  function serviceGetFilesInAlbum ($iAlbumId, $isCheckPrivacy = false, $iViewer = 0, $aLimits = array())
177  {
178  if (!$iViewer)
179  $iViewer = $this->oModule->_iProfileId;
180  if ($isCheckPrivacy && !$this->oModule->oAlbumPrivacy->check('album_view', (int)$iAlbumId, $iViewer))
181  return array();
182 
183  $this->aCurrent['ownFields'][] = 'Video';
184  $this->aCurrent['ownFields'][] = 'Source';
185  $aFiles = $this->getFilesInAlbumArray($iAlbumId, $aLimits);
186  foreach ($aFiles as $k => $aRow) {
187  $aFiles[$k]['thumb'] = $this->getImgUrl($aRow['id'], 'browse');
188  $aFiles[$k]['file'] = $this->getImgUrl($aRow['id'], 'file');
189  $aFiles[$k]['main'] = $this->getImgUrl($aRow['id'], 'main');
190  $aFiles[$k]['video'] = $aFiles[$k]['Video'];
191  $aFiles[$k]['source'] = $aFiles[$k]['Source'];
192  }
193  return $aFiles;
194  }
195 
196  function serviceGetAllProfileVideos ($iProfId, $aLimits = array())
197  {
198  $aFiles = $this->getProfileFiles($iProfId, $aLimits);
199  foreach ($aFiles as $k => $aRow) {
200  $aFiles[$k]['thumb'] = $this->getImgUrl($aRow['id'], 'browse');
201  $aFiles[$k]['file'] = $this->getImgUrl($aRow['id'], 'file');
202  $aFiles[$k]['main'] = $this->getImgUrl($aRow['id'], 'main');
203  $aFiles[$k]['video'] = $aFiles[$k]['Video'];
204  $aFiles[$k]['source'] = $aFiles[$k]['Source'];
205  }
206  return $aFiles;
207  }
208 
212  function serviceGetWallPost($aEvent)
213  {
214  return $this->oModule->getWallPost($aEvent, 'film');
215  }
216 
220  function serviceGetWallPostOutline($aEvent)
221  {
222  return $this->oModule->getWallPostOutline($aEvent, 'film');
223  }
224 
226  {
227  if(!$this->checkMemAction($iProfileId, 'view'))
228  return '';
229  $aVars = array (
230  'title' => false,
231  'prefix' => 'id' . time() . '_' . rand(1, 999999),
232  'default_height' => getSettingValue('video', 'player_height'),
233  'ch_repeat:videos' => array (),
234  'ch_repeat:icons' => array (),
235  );
236 
237  $aFiles = $this->serviceGetProfileAlbumFiles($iProfileId);
238  foreach($aFiles as $aFile) {
239  $aVars['ch_repeat:videos'][] = array (
240  'style' => false === $aVars['title'] ? '' : 'display:none;',
241  'id' => $aFile['id'],
242  'video' => $this->oTemplate->getFileConcept($aFile['id'], ($aFile['source'] == 'youtube' ? array('ext' => $aFile['video']) : array())),
243  );
244  $aVars['ch_repeat:icons'][] = array (
245  'id' => $aFile['id'],
246  'icon_url' => $aFile['file'],
247  'title' => $aFile['title'],
248  );
249  if (false === $aVars['title'])
250  $aVars['title'] = $aFile['title'];
251  }
252 
253  if (!$aVars['ch_repeat:icons'])
254  return '';
255 
256  $this->oTemplate->addCss('entry_view.css');
257  return $this->oTemplate->parseHtmlByName('entry_view_block_videos.html', $aVars);
258  }
259  function getSearchUnitShort($aData)
260  {
261  $sContent = parent::getSearchUnitShort($aData);
262  return $this->oTemplate->parseHtmlByContent($sContent, array(
263  'size' => _format_time($aData['size'] / 1000)
264  ));
265  }
266  function getSearchUnit($aData)
267  {
268  $sContent = parent::getSearchUnit($aData);
269  return $this->oTemplate->parseHtmlByContent($sContent, array(
270  'size' => _format_time($aData['size'] / 1000)
271  ));
272  }
273  function _getPseud ()
274  {
275  return array(
276  'id' => 'ID',
277  'title' => 'Title',
278  'date' => 'Date',
279  'size' => 'Time',
280  'uri' => 'Uri',
281  'ownerId' => 'Owner',
282  'ownerName' => 'NickName',
283  'view' => 'Views',
284  'voteTime' => 'gal_date',
285  'source' => 'Source',
286  'video' => 'Video'
287  );
288  }
289 }
ChVideosSearch\serviceGetItemArray
serviceGetItemArray($iId, $sType='browse')
Definition: ChVideosSearch.php:156
ChVideosSearch\_getPseud
_getPseud()
Definition: ChVideosSearch.php:273
ChVideosSearch\serviceGetEntry
serviceGetEntry($iId, $sType='browse')
Definition: ChVideosSearch.php:98
ChBaseSearchResultSharedMedia\getProfileFiles
getProfileFiles($iProfId, $aLimits=array())
Definition: ChBaseSearchResultSharedMedia.php:442
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
_format_time
_format_time($iSec, $aParams=array())
Definition: utils.inc.php:813
ChVideosSearch\__construct
__construct($sParamName='', $sParamValue='', $sParamValue1='', $sParamValue2='')
Definition: ChVideosSearch.php:12
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChVideosSearch\serviceGetFilesInAlbum
serviceGetFilesInAlbum($iAlbumId, $isCheckPrivacy=false, $iViewer=0, $aLimits=array())
Definition: ChVideosSearch.php:176
php
$iId
$iId
Definition: license.php:15
$sParamValue
$sParamValue
Definition: actions.inc.php:16
ChVideosSearch\serviceGetVideoConcept
serviceGetVideoConcept($aVideo)
Definition: ChVideosSearch.php:93
ChVideosSearch\serviceGetFileUrl
serviceGetFileUrl($iId, $sImgType='browse')
Definition: ChVideosSearch.php:88
db_arr
db_arr($query, $bindings=[])
Definition: db.inc.php:76
$sType
$sType
Definition: actions.inc.php:11
ChBaseSearchResultSharedMedia\serviceGetProfileAlbumFiles
serviceGetProfileAlbumFiles($iProfileId)
Definition: ChBaseSearchResultSharedMedia.php:673
$sParamName
$sParamName
Definition: actions.inc.php:15
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
ChVideosSearch\serviceGetVideoArray
serviceGetVideoArray($iId, $sType='browse')
Definition: ChVideosSearch.php:161
extFileExists
extFileExists($sFileSrc)
Definition: utils.inc.php:638
ChVideosSearch\serviceGetAllProfileVideos
serviceGetAllProfileVideos($iProfId, $aLimits=array())
Definition: ChVideosSearch.php:196
ChVideosSearch\serviceGetFilesInCat
serviceGetFilesInCat($iId, $sCategory='')
Definition: ChVideosSearch.php:166
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
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
ChVideosSearch
Definition: ChVideosSearch.php:11
ChBaseSearchResultSharedMedia\checkMemAction
checkMemAction($iFileOwner, $sAction='view')
Definition: ChBaseSearchResultSharedMedia.php:701
ChVideosSearch\serviceGetWallPostOutline
serviceGetWallPostOutline($aEvent)
Definition: ChVideosSearch.php:220
ChVideosSearch\serviceGetWallPost
serviceGetWallPost($aEvent)
Definition: ChVideosSearch.php:212
$aVars
$aVars
Definition: license.php:101
ChVideosSearch\getSearchUnitShort
getSearchUnitShort($aData)
Definition: ChVideosSearch.php:259
ChTemplSearchResultSharedMedia
Definition: ChTemplSearchResultSharedMedia.php:11
ChBaseSearchResultSharedMedia\getFilesInCatArray
getFilesInCatArray($iId, $sCategory='')
Definition: ChBaseSearchResultSharedMedia.php:383
getSettingValue
getSettingValue($sWidget, $sSettingKey, $sFile="config", $bFullReturn=false, $sFolder="xml")
Definition: apiFunctions.inc.php:82
$iProfId
$iProfId
Definition: short_profile_info.php:22
ChBaseSearchResultSharedMedia\getImgUrl
getImgUrl($iId, $sImgType='browse')
Definition: ChBaseSearchResultSharedMedia.php:373
ChVideosSearch\serviceProfileVideoBlock
serviceProfileVideoBlock($iProfileId)
Definition: ChVideosSearch.php:225
ChBaseSearchResultSharedMedia\getFilesInAlbumArray
getFilesInAlbumArray($iAlbumId, $aLimits=array())
Definition: ChBaseSearchResultSharedMedia.php:415
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChVideosSearch\getSearchUnit
getSearchUnit($aData)
Definition: ChVideosSearch.php:266
$iProfileId
if( $sMembersList) $iProfileId
Definition: communicator.php:29