17 parent::__construct();
19 $this->aCurrent = array(
21 'title' =>
'_ch_files',
22 'table' =>
'ch_files_main',
23 'ownFields' => array(
'ID',
'Title',
'Uri',
'Desc',
'Date',
'Size',
'Ext',
'Views',
'Rate',
'RateCount',
'Type'),
24 'searchFields' => array(
'Title',
'Tags',
'Desc',
'Categories'),
28 'table' =>
'Profiles',
29 'mainField' =>
'Owner',
31 'joinFields' => array(
'NickName')
35 'table' =>
'ch_files_types',
36 'mainField' =>
'Type',
38 'joinFields' => array(
'Icon')
40 'albumsObjects' => array(
42 'table' =>
'sys_albums_objects',
44 'onField' =>
'id_object',
49 'table' =>
'sys_albums',
50 'mainField' =>
'id_album',
52 'joinFields' => array(
'AllowAlbumView'),
53 'mainTable' =>
'sys_albums_objects'
56 'restriction' => array(
57 'activeStatus' => array(
'value'=>
'approved',
'field'=>
'Status',
'operator'=>
'=',
'paramName' =>
'status'),
58 'owner' => array(
'value'=>
'',
'field'=>
'NickName',
'operator'=>
'=',
'paramName'=>
'ownerName',
'table'=>
'Profiles'),
59 'ownerStatus' => array(
'value'=>array(
'Rejected',
'Suspended'),
'operator'=>
'not in',
'paramName'=>
'ownerStatus',
'table'=>
'Profiles',
'field'=>
'Status'),
60 'tag' => array(
'value'=>
'',
'field'=>
'Tags',
'operator'=>
'against',
'paramName'=>
'tag'),
61 'category' => array(
'value'=>
'',
'field'=>
'Categories',
'operator'=>
'against',
'paramName'=>
'categoryUri'),
62 'id' => array(
'value' =>
'',
'field' =>
'ID',
'operator' =>
'in'),
63 'allow_view' => array(
'value'=>
'',
'field'=>
'AllowAlbumView',
'operator'=>
'in',
'table'=>
'sys_albums'),
64 'not_allow_view' => array(
'value'=>
'',
'field'=>
'AllowAlbumView',
'operator'=>
'not in',
'table'=>
'sys_albums'),
65 'album_status' => array(
'value'=>
'active',
'field'=>
'Status',
'operator'=>
'=',
'table'=>
'sys_albums'),
66 'albumType' => array(
'value'=>
'',
'field'=>
'Type',
'operator'=>
'=',
'paramName'=>
'albumType',
'table'=>
'sys_albums'),
68 'paginate' => array(
'perPage' => 10,
'page' => 1,
'totalNum' => 10,
'totalPages' => 1),
73 'title' =>
_t(
'_ch_files'),
80 'DateTimeUTS' =>
'date',
88 $this->aAddPartsConfig[
'favorite'] = array(
90 'table' =>
'ch_files_favorites',
93 'userField' =>
'Profile',
98 $this->oTemplate = $this->oModule->_oTemplate;
99 $this->oModule->_oTemplate->addCss(
'search.css');
100 $this->aConstants[
'filesUrl'] = $this->oModule->_oConfig->getFilesUrl();
101 $this->aConstants[
'filesDir'] = $this->oModule->_oConfig->getFilesPath();
102 $this->aConstants[
'filesInAlbumCover'] = 32;
103 $this->aConstants[
'picPostfix'] = $this->oModule->_oConfig->aFilePostfix;
106 $this->aConstants[
'linksTempl'] = array(
108 'file' =>
'view/{uri}',
109 'category' =>
'browse/category/{uri}',
110 'browseAll' =>
'browse/',
111 'browseUserAll' =>
'albums/browse/owner/{uri}',
112 'browseAllTop' =>
'browse/top',
113 'tag' =>
'browse/tag/{uri}',
114 'album' =>
'browse/album/{uri}',
115 'add' =>
'browse/my/add'
118 $this->aCurrent[
'restriction'][
'albumType'][
'value'] = $this->aCurrent[
'name'];
123 $this->aCurrent[
'restriction'][
'calendar-min'] = array(
'value' =>
"UNIX_TIMESTAMP('{$sParamValue}-{$sParamValue1}-{$sParamValue2} 00:00:00')",
'field' =>
'Date',
'operator' =>
'>=',
'no_quote_value' =>
true);
124 $this->aCurrent[
'restriction'][
'calendar-max'] = array(
'value' =>
"UNIX_TIMESTAMP('{$sParamValue}-{$sParamValue1}-{$sParamValue2} 23:59:59')",
'field' =>
'Date',
'operator' =>
'<=',
'no_quote_value' =>
true);
127 $this->aCurrent[
'sorting'] =
'top';
130 $this->aCurrent[
'sorting'] =
'popular';
133 $this->aCurrent[
'restriction'][
'featured'] = array(
134 'value'=>
'1',
'field'=>
'Featured',
'operator'=>
'=',
'paramName'=>
'ch_files_mode'
138 if (isset($this->aAddPartsConfig[
'favorite']) && !
empty($this->aAddPartsConfig[
'favorite']) &&
getLoggedId() != 0) {
139 $this->aCurrent[
'join'][
'favorite'] = $this->aAddPartsConfig[
'favorite'];
140 $this->aCurrent[
'restriction'][
'fav'] = array(
142 'field' => $this->aAddPartsConfig[
'favorite'][
'userField'],
144 'table' => $this->aAddPartsConfig[
'favorite'][
'table']
149 $this->aCurrent[
'sorting'] =
'album_order';
150 $this->aCurrent[
'restriction'][
'album'] = array(
151 'value'=>
'',
'field'=>
'Uri',
'operator'=>
'=',
'paramName'=>
'albumUri',
'table'=>
'sys_albums'
153 if ($sParamValue1 ==
'owner' && strlen($sParamValue2) > 0)
154 $this->aCurrent[
'restriction'][
'owner'][
'value'] = $sParamValue2;
168 'ownerId' =>
'Owner',
169 'ownerName' =>
'NickName',
177 switch ($this->aCurrent[
'sorting']) {
179 $aSql[
'order'] =
" ORDER BY `DownloadsCount` DESC";
183 $aSql[
'order'] =
" ORDER BY `obj_order` ASC, `id_object` DESC";
192 $bShort = isset($this->aCurrent[
'view']) && $this->aCurrent[
'view'] ==
'short' ?
true :
false;
193 if ($this->oModule->isAdmin($this->oModule->_iProfileId) || is_array($this->aCurrent[
'restriction'][
'allow_view'][
'value']))
195 elseif ($this->oModule->oAlbumPrivacy->check(
'album_view', $aData[
'id_album'], $this->oModule->_iProfileId))
202 'ch_if:show_title' => array(
203 'condition' => !$bShort,
204 'content' => array(1)
207 $sCode = $this->oTemplate->parseHtmlByName(
'browse_unit_private.html',
$aUnit);
215 $sCode = parent::displayResultBlock();
216 return !
empty(
$sCode) ? $this->oTemplate->parseHtmlByName(
'default_margin.html', array(
'content' =>
$sCode)) :
$sCode;
221 $aUnit[
'unitClass'] = $this->aCurrent[
'name'];
222 $aUnit[
'ch_if:admin'] = array(
223 'condition' => $this->bAdminMode,
224 'content' => array(
'id' => $aData[
'id'])
227 $sPicName =
empty($aData[
'Icon']) ?
'default.png': $aData[
'Icon'];
228 $aUnit[
'pic'] = $this->oModule->_oTemplate->getIconUrl($sPicName);
229 $aUnit[
'spacer'] = $this->oModule->_oTemplate->getIconUrl(
'spacer.gif');
231 if (!is_null($this->oRate) && $this->oRate->isEnabled())
232 $aUnit[
'rate'] = $this->oRate->getJustVotingElement(0, 0, $aData[
'Rate']);
236 $aUnit[
'title'] = stripslashes($aData[
'title']);
243 $aUnit[
'ext'] = $aData[
'Ext'];
251 $aUnit[
'view'] = $aData[
'view'];
253 $aUnit[
'desc'] = stripslashes($aData[
'desc']);
255 $aUnit[
'id'] = $aData[
'id'];
256 return $this->oModule->_oTemplate->parseHtmlByName(
'browse_unit.html',
$aUnit, array(
'{',
'}'));
263 $aUnit[
'unitClass'] = $this->aCurrent[
'name'];
267 $aUnit[
'title'] = $aData[
'title'];
274 $aUnit[
'ext'] = $aData[
'Ext'];
283 $sPicName = is_null($aData[
'Icon']) ?
'default.png': $aData[
'Icon'];
284 $aUnit[
'pic'] = $this->oModule->_oTemplate->getIconUrl($sPicName);
286 $aUnit[
'id'] = $aData[
'id'];
287 return $this->oModule->_oTemplate->parseHtmlByName(
'browse_unit_short.html',
$aUnit, array(
'{',
'}'));
292 $this->aCurrent[
'sorting'] = isset(
$_GET[$this->aCurrent[
'name'].
'_mode']) ?
$_GET[$this->aCurrent[
'name'].
'_mode'] : $this->aCurrent[
'sorting'];
297 $aDBTopMenu = array();
299 foreach (array(
'last',
'top')
as $sMyMode) {
302 $sModeTitle =
'_Latest';
305 $sModeTitle =
'_Top';
309 if(basename( $_SERVER[
'PHP_SELF'] ) ==
'rewrite_name.php' || basename( $_SERVER[
'PHP_SELF'] ) ==
'profile.php')
310 $sLink = CH_WSB_URL_ROOT .
"profile.php?ID={$this->aCurrent['restriction']['owner']['value']}&";
313 $sLink .= $this->aCurrent[
'name'] .
"_mode=$sMyMode" . $aLinkAddon[
'params'] . $aLinkAddon[
'paginate'] . $aLinkAddon[
'type'];
315 $aDBTopMenu[$sModeTitle] = array(
'href' => $sLink,
'dynamic' =>
true,
'active' => ($sMyMode == $this->aCurrent[
'sorting']));
322 $sLink = $this->aConstants[
'linksTempl'][
$sType];
323 return CH_WSB_URL_ROOT . $this->oModule->_oConfig->getBaseUri() . str_replace(
'{uri}', $sUri, $sLink);
329 foreach ($this->aCurrent[
'restriction']
as $sKey => $aParam)
330 $aData[$sKey] = $aParam[
'value'];
331 $aData = array_merge($aData, $aCond);
332 $iAlbumCount = $oSet->getAlbumCount($aData);
333 if ($iAlbumCount > 0) {
334 $this->aCurrent[
'paginate'][
'totalAlbumNum'] = $iAlbumCount;
337 foreach ($aList
as $iKey => $aData)
346 if (!$this->bAdminMode && $bCheckPrivacy) {
347 if (!$this->oModule->oAlbumPrivacy->check(
'album_view', $aData[
'ID'], $this->oModule->_iProfileId)) {
349 'img_url' => $this->oTemplate->getIconUrl(
'lock.png'),
351 return $this->oTemplate->parseHtmlByName(
'album_unit_private.html',
$aUnit);
354 $aUnit[
'type'] = $this->oModule->_oConfig->getMainPrefix();
355 $aUnit[
'ch_if:editMode'] = array(
356 'condition' => $this->bAdminMode,
358 'id' => $aData[
'ID'],
359 'checked' => $this->sCurrentAlbum == $aData[
'Uri'] ?
'checked="checked"' :
''
370 $aUnit[
'spacer'] = $this->oTemplate->getIconUrl(
'spacer.gif');
373 $iItems = isset($this->aConstants[
'filesInAlbumCover']) ? (int)$this->aConstants[
'filesInAlbumCover'] : 15;
374 $aItems = $this->
getAlbumCovers($aData[
'ID'], array(
'filesInAlbumCover' => $iItems));
375 if((!is_array($aItems) || count($aItems) == 0) && $this->oModule->_iProfileId != $aData[
'Owner']) {
376 $this->aCurrent[
'paginate'][
'totalAlbumNum']--;
381 for($i = 0; $i < $iItems; $i++) {
382 $aItem = array_shift($aItems);
383 $bItem = isset($aItem[
'id_object']) && (int)$aItem[
'id_object'] > 0;
386 'ch_if:exist' => array(
387 'condition' => $bItem,
392 'ch_if:not-exist' => array(
393 'condition' => !$bItem,
398 $aUnit[
'ch_repeat:units'] = $aUnits;
402 $aUnit[
'title'] = $aData[
'Caption'];
408 $aUnit[
'view'] = isset($aData[
'ObjCount']) ? $aData[
'ObjCount'] .
' ' .
_t($this->aCurrent[
'title']):
'';
409 return $this->oTemplate->parseHtmlByName(
'album_unit.html',
$aUnit, array(
'{',
'}'));
414 $iAlbumId = (int)$iAlbumId;
415 $iLimit = isset($aParams[
'filesInAlbumCover']) ? (int)$aParams[
'filesInAlbumCover'] :
null;
416 return $this->oModule->oAlbums->getAlbumCoverFiles($iAlbumId, array(
'table' => $this->aCurrent[
'table'],
'field' =>
'ID',
'fields_list' => array(
'Type')), array(array(
'field'=>
'Status',
'value'=>
'approved')), $iLimit);
421 $sIcon = $this->oModule->_oConfig->getMimeTypeIcon($aIdent[
'Type']);
422 return $this->oTemplate->getIconUrl($sIcon);
428 $sPostFix = isset($this->aConstants[
'picPostfix'][$sImgType]) ? $this->aConstants[
'picPostfix'][$sImgType] : $this->aConstants[
'picPostfix'][
'browse'];
429 return $this->aConstants[
'filesUrl'] .
$iId . $sPostFix;
432 function getAlbumsBlock ($aSectionParams = array(), $aAlbumParams = array(), $aCustom = array())
434 $aCustomTmpl = array(
435 'caption' =>
_t(
'_' . $this->oModule->_oConfig->getMainPrefix() .
'_albums'),
436 'enable_center' =>
true,
437 'unit_css_class' =>
'.sys_album_unit',
438 'page' => isset(
$_GET[
'page']) ? (
int)
$_GET[
'page'] : 1,
439 'per_page' => isset(
$_GET[
'per_page']) ? (
int)
$_GET[
'per_page']: (
int)$this->oModule->_oConfig->getGlParam(
'number_albums_home'),
440 'simple_paginate' =>
true,
443 'paginate_url' =>
'',
444 'simple_paginate_url' => CH_WSB_URL_ROOT . $this->oModule->_oConfig->getUri() .
'/albums/browse'
446 $aCustom = array_merge($aCustomTmpl, $aCustom);
447 $this->aCurrent[
'paginate'][
'perPage'] = $aCustom[
'per_page'];
448 $this->aCurrent[
'paginate'][
'page'] = $aCustom[
'page'];
451 $sCode = $this->
getAlbumList($this->aCurrent[
'paginate'][
'page'], $this->aCurrent[
'paginate'][
'perPage'], $aAlbumParams);
452 if ($this->aCurrent[
'paginate'][
'totalAlbumNum'] > 0) {
453 if ($aCustom[
'enable_center'])
455 if (
empty($aCustom[
'menu_bottom'])) {
458 'page_url' => $aCustom[
'paginate_url'],
459 'count' => $this->aCurrent[
'paginate'][
'totalAlbumNum'],
460 'per_page' => $this->aCurrent[
'paginate'][
'perPage'],
461 'page' => $this->aCurrent[
'paginate'][
'page'],
462 'on_change_page' =>
'return !loadDynamicBlock({id}, \'' . $aCustom[
'paginate_url'] . $aLinkAddon[
'params'] .
'&page={page}&per_page={per_page}\');',
464 $aCode[
'menu_bottom'] = $aCustom[
'simple_paginate'] ? $oPaginate->getSimplePaginate($aCustom[
'simple_paginate_url']) : $oPaginate->getPaginate();
467 $aCode[
'menu_bottom'] = $aCustom[
'menu_bottom'];
469 $aCode[
'menu_top'] = $aCustom[
'menu_top'];
470 return array($aCode[
'code'], $aCode[
'menu_top'], $aCode[
'menu_bottom'], (!
empty($aCode[
'code']) ?
false :
''));
476 $this->aCurrent[
'paginate'][
'perPage'] = 1000;
477 $this->aCurrent[
'join'][
'category'] = array(
479 'table' =>
'sys_categories',
482 'joinFields' => array(
'Category')
485 $this->aCurrent[
'restriction'][
'ownerId'] = array(
491 $this->aCurrent[
'restriction'][
'category'] = array(
492 'value' => $sCategory,
493 'field' =>
'Category',
495 'table' =>
'sys_categories'
498 $this->aCurrent[
'restriction'][
'type'] = array(
499 'value' => $this->aCurrent[
'name'],
502 'table' =>
'sys_categories'
508 foreach ($aFiles
as $k => $aRow) {
509 $sIcon = !
empty($aRow[
'Icon']) ? $aRow[
'Icon'] :
'default.png';
510 $aFiles[$k][
'icon'] = $this->oModule->_oTemplate->getIconUrl($sIcon);
511 $aFiles[$k][
'url'] = $this->
getCurrentUrl(
'file', $aRow[
'ID'], $aRow[
'uri']);
519 $iViewer = $this->oModule->_iProfileId;
520 return $this->oModule->oAlbumPrivacy->check(
'album_view', (
int)$iAlbumId, $iViewer);
525 $iAlbumId = (int)$iAlbumId;
529 $iViewer = $this->oModule->_iProfileId;
530 if ($isCheckPrivacy && !$this->oModule->oAlbumPrivacy->check(
'album_view', (
int)$iAlbumId, $iViewer))
533 $this->aCurrent[
'paginate'][
'perPage'] = 1000;
534 $this->aCurrent[
'join'][
'albumsObjects'] = array(
536 'table' =>
'sys_albums_objects',
538 'onField' =>
'id_object',
539 'joinFields' => array(
'obj_order')
541 $this->aCurrent[
'sorting'] =
'album_order';
542 $this->aCurrent[
'restriction'][
'album'] = array(
543 'value'=>$iAlbumId,
'field'=>
'id_album',
'operator'=>
'=',
'paramName'=>
'albumId',
'table'=>
'sys_albums_objects'
548 foreach ($aFiles
as $k => $aRow) {
549 $sIcon = !
empty($aRow[
'Icon']) ? $aRow[
'Icon'] :
'default.png';
550 $aFiles[$k][
'icon'] = $this->oModule->_oTemplate->getIconUrl($sIcon);
551 $aFiles[$k][
'url'] = $this->
getCurrentUrl(
'file', $aRow[
'ID'], $aRow[
'uri']);
552 $aFiles[$k][
'mime_type'] = $aRow[
'Type'];
553 $aFiles[$k][
'path'] = $this->aConstants[
'filesDir'] . $aRow[
'ID'] .
'_' . sha1($aRow[
'Date']);
571 $sqlQuery =
"SELECT a.`ID` as `id`,
572 a.`Title` as `title`,
575 a.`Owner` as `owner`,
580 a.`Status` as `status`,
583 FROM `{$this->aCurrent['table']}` as a
584 LEFT JOIN `sys_albums_objects` as b ON b.`id_object` = a.`ID`
585 LEFT JOIN `sys_albums` as c ON c.`ID` = b.`id_album`
586 LEFT JOIN `ch_files_types` as d ON d.`Type` = a.`Type`
587 WHERE a.`ID`='$iId' AND c.`Type`='{$this->aCurrent['name']}'";
588 $aData =
db_arr($sqlQuery);
592 $iSize = (int)$this->oModule->_oConfig->getGlParam(
'browse_width');
593 $sIcon = !
empty($aData[
'Icon']) ? $aData[
'Icon'] :
'default.png';
595 if (strlen($aData[
'Ext']) > 0)
596 $sFile .=
'_' . sha1($aData[
'date']);
598 'file' => $this->oModule->_oTemplate->getIconUrl($sIcon),
599 'file_path' => $this->oModule->_oTemplate->getIconPath($sIcon),
600 'width' => $iSize + 4,
601 'height' => $iSize + 4,
602 'title' => $aData[
'title'],
603 'owner' => $aData[
'owner'],
604 'description' => $aData[
'desc'],
605 'url' => $this->getCurrentUrl(
'file',
$iId, $aData[
'uri']),
606 'date' => $aData[
'date'],
607 'rate' => $aData[
'Rate'],
608 'path' => $this->aConstants[
'filesDir'] .
$sFile,
609 'extension' => $aData[
'Ext'],
610 'mime_type' => $aData[
'Type'],
611 'status' => $aData[
'status'],
612 'album_id' => $aData[
'id_album']
619 $aCode = $this->
getBrowseBlock($aParams, $aCustom, $sLink,
false);
620 if ($this->aCurrent[
'paginate'][
'totalNum'] > 0)
621 return array($aCode[
'code'], $aCode[
'menu_top'], $aCode[
'menu_bottom'], $aCode[
'wrapper']);
626 $iFile = (int)$iFile;
627 $aInfo = $this->oModule->_oDb->getFileInfo(array(
'fileId'=>$iFile),
true, array(
'medID',
'medExt'));
628 return $this->aConstants[
'filesDir'] .
$aInfo[
'medID'] .
'.' .
$aInfo[
'medExt'];
635 $sSimpleUrl = CH_WSB_URL_ROOT . $this->oModule->_oConfig->getBaseUri() .
'albums/browse/owner/' . $sNickName;
637 return $this->
getAlbumsBlock(array(
'owner' =>
$iProfileId), array(
'hide_default' =>
TRUE), array(
'enable_center' =>
false,
'paginate_url' => $sPaginateUrl,
'simple_paginate_url' => $sSimpleUrl));
645 return $this->oModule->serviceGetWallPost($aEvent);
653 return $this->oModule->serviceGetWallPostOutline($aEvent);
661 $iId = (int)$aEvent[
'object_id'];
662 $iOwner = (int)$aEvent[
'owner_id'];
666 if(
empty($aItem) || !is_array($aItem))
667 return array(
'perform_delete' =>
true);
669 $aContent = unserialize($aEvent[
'content']);
670 if(
empty($aContent) || !isset($aContent[
'comment_id']))
675 if(!$oCmts->isEnabled())
678 $aComment = $oCmts->getCommentRow((
int)$aContent[
'comment_id']);
681 if($aEvent[
'js_mode'])
682 $sCss = $this->oModule->_oTemplate->addCss(
'wall_post.css',
true);
684 $this->oModule->_oTemplate->addCss(
'wall_post.css');
686 $sTextWallObject =
_t(
'_ch_files_wall_object');
688 'title' =>
_t(
'_ch_files_wall_added_new_comment_title', $sOwner, $sTextWallObject),
689 'description' => $aComment[
'cmt_text'],
690 'content' => $sCss . $this->oModule->_oTemplate->parseHtmlByName(
'modules/cheetah/wall/|timeline_comment.html', array(
691 'mod_prefix' =>
'ch_files',
692 'cpt_user_name' => $sOwner,
693 'cpt_added_new' =>
_t(
'_ch_files_wall_added_new_comment'),
694 'cpt_object' => $sTextWallObject,
695 'cpt_item_url' => $aItem[
'url'],
696 'cnt_comment_text' => $aComment[
'cmt_text'],
697 'snippet' => $this->oModule->_oTemplate->parseHtmlByName(
'wall_post_comment.html', array(
698 'cnt_item_page' => $aItem[
'url'],
699 'cnt_item_width' => $aItem[
'width'],
700 'cnt_item_height' => $aItem[
'height'],
701 'cnt_item_icon' => $aItem[
'file'],
702 'cnt_item_title' => $aItem[
'title'],
703 'cnt_item_description' => $aItem[
'description'],
711 return CH_WSB_URL_ROOT . $this->oModule->_oConfig->getBaseUri() .
'view/' . $a[
'uri'];