50 $this->aCurrent = array(
51 'ownFields' => array(
'ID',
'Title',
'Uri',
'Date',
'Time',
'Rate',
'RateCount'),
52 'searchFields' => array(
'Title',
'Tags',
'Description',
'Categories'),
56 'table' =>
'Profiles',
57 'mainField' =>
'Owner',
59 'joinFields' => array(
'NickName')
61 'albumsObjects' => array(
63 'table' =>
'sys_albums_objects',
65 'onField' =>
'id_object',
70 'table' =>
'sys_albums',
71 'mainField' =>
'id_album',
73 'joinFields' => array(
'AllowAlbumView'),
74 'mainTable' =>
'sys_albums_objects'
77 'restriction' => array(
78 'activeStatus' => array(
'value'=>
'approved',
'field'=>
'Status',
'operator'=>
'=',
'paramName'=>
'status'),
79 'owner' => array(
'value'=>
'',
'field'=>
'Owner',
'operator'=>
'=',
'paramName'=>
'userID'),
80 'ownerStatus' => array(
'value'=>array(
'Rejected',
'Suspended'),
'operator'=>
'not in',
'paramName'=>
'ownerStatus',
'table'=>
'Profiles',
'field'=>
'Status'),
81 'tag' => array(
'value'=>
'',
'field'=>
'Tags',
'operator'=>
'against',
'paramName'=>
'tag'),
82 'category'=> array(
'value'=>
'',
'field'=>
'Categories',
'operator'=>
'against',
'paramName'=>
'categoryUri'),
83 'id' => array(
'value'=>
'',
'field'=>
'ID',
'operator'=>
'in'),
84 'allow_view' => array(
'value'=>
'',
'field'=>
'AllowAlbumView',
'operator'=>
'in',
'table'=>
'sys_albums'),
85 'not_allow_view' => array(
'value'=>
'',
'field'=>
'AllowAlbumView',
'operator'=>
'not in',
'table'=>
'sys_albums'),
86 'album_status' => array(
'value'=>
'active',
'field'=>
'Status',
'operator'=>
'=',
'table'=>
'sys_albums'),
87 'albumType' => array(
'value'=>
'',
'field'=>
'Type',
'operator'=>
'=',
'paramName'=>
'albumType',
'table'=>
'sys_albums'),
89 'paginate' => array(
'perPage' => 10,
'page' => 1,
'totalNum' => 10,
'totalPages' => 1),
100 'DateTimeUTS' =>
'date',
107 $this->aAddPartsConfig[
'favorite'] = array(
112 'userField' =>
'Profile',
116 parent::__construct();
120 $this->oTemplate =
$GLOBALS[
'oSysTemplate'];
122 $sClassName = $this->oModule->_oConfig->getClassPrefix() .
'Privacy';
123 ch_import(
'Privacy', $this->oModule->_aModule);
124 $this->oPrivacy =
new $sClassName(
'sys_albums',
'ID',
'Owner');
125 $this->sTemplUnit =
'browse_unit';
127 $this->bDynamic = isset($_SERVER[
'HTTP_X_REQUESTED_WITH']) && $_SERVER[
'HTTP_X_REQUESTED_WITH'] ==
'XMLHttpRequest';
132 $sLink = $this->aConstants[
'linksTempl'][
$sType];
133 return CH_WSB_URL_ROOT . $this->oModule->_oConfig->getBaseUri() . str_replace(
'{uri}', $sUri, $sLink);
138 $bFull = isset($this->aCurrent[
'view']) && $this->aCurrent[
'view'] ==
'short' ?
false :
true;
139 if ($this->oModule->isAdmin($this->oModule->_iProfileId) || is_array($this->aCurrent[
'restriction'][
'allow_view'][
'value']))
141 elseif ($this->oPrivacy->check(
'album_view', $aData[
'id_album'], $this->oModule->_iProfileId))
148 'ch_if:show_title' => array(
149 'condition' => $bFull,
150 'content' => array(1)
153 $sCode = $this->oTemplate->parseHtmlByName(
'browse_unit_private.html',
$aUnit);
164 <div class="sys_file_search_unit_short" id="unit_{id}">
168 $aUnit[
'id'] = $aData[
'id'];
169 $sFileLink = $this->
getCurrentUrl(
'file', $aData[
'id'], $aData[
'uri']);
178 $aUnit[
'main_prefix'] = $this->oModule->_oConfig->getMainPrefix();
180 $aUnit[
'id'] = $aData[
'id'];
181 $sFileLink = $this->
getCurrentUrl(
'file', $aData[
'id'], $aData[
'uri']);
186 if (!is_null($this->oRate) && $this->oRate->isEnabled()) {
187 if ($this->sTemplUnit ==
'browse_unit')
188 $aUnit[
'rate'] = $this->oRate->getSmallVoting(0, $aData[
'Rate']);
195 $aUnit[
'size'] = isset($aData[
'size']) ? $this->
getLength($aData[
'size']) :
'';
197 $aUnit[
'titleLink'] = $sFileLink;
198 $aUnit[
'title'] = stripslashes($aData[
'title']);
208 $aUnit[
'view'] = $aData[
'view'];
209 return $this->oTemplate->parseHtmlByName($this->sTemplUnit .
'.html',
$aUnit, array(
'{',
'}'));
214 $this->sCurrentAlbum = strip_tags($sAlbumUri);
219 $iTime = (int)round($iTime/1000);
222 $aLength[0] = $iTime;
223 } elseif ($iTime < 3600) {
224 $aLength[1] = (int)($iTime/60);
225 $aLength[0] = $iTime%60;
227 $aLength[2] = (int)($iTime/3600);
228 $iOther = $iTime - $aLength[2]*3600;
229 $aLength[1] = (int)($iOther/60);
230 $aLength[0] = $iOther%60;
233 for ($i = count($aLength)-1; $i >= 0; $i--) {
234 $sCode .= strlen($aLength[$i]) < 2 ?
'0' . $aLength[$i] : $aLength[$i];
242 $aDBTopMenu = $this->
getTopMenu(array($this->aCurrent[
'name'] .
'_mode'));
244 return array( $aDBTopMenu, $aDBBottomMenu );
250 switch ($this->aCurrent[
'sorting']) {
252 $aSql[
'order'] =
" ORDER BY `{$this->aCurrent['table']}`.`Views` DESC";
255 $aSql[
'order'] =
" ORDER BY `obj_order` ASC, `id_object` DESC";
264 $aDBTopMenu = array();
266 foreach (array(
'last',
'top')
as $sMyMode) {
269 $sModeTitle =
'_Latest';
272 $sModeTitle =
'_Top';
276 if (basename( $_SERVER[
'PHP_SELF'] ) ==
'rewrite_name.php' || basename( $_SERVER[
'PHP_SELF'] ) ==
'profile.php')
277 $sLink = CH_WSB_URL_ROOT .
"profile.php?ID={$this->aCurrent['restriction']['owner']['value']}&";
280 $sLink .= $this->aCurrent[
'name'] .
"_mode=$sMyMode" . $aLinkAddon[
'params'] . $aLinkAddon[
'paginate'] . $aLinkAddon[
'type'];
282 $aDBTopMenu[$sModeTitle] = array(
'href' => $sLink,
'dynamic' =>
true,
'active' => ($sMyMode == $this->aCurrent[
'sorting']));
286 function getBrowseBlock ($aParams, $aCustom = array(), $sMainUrl =
'', $bClearJoins =
true)
288 if(!isset($aCustom[
'sorting']))
289 $aCustom[
'sorting'] =
'album_order';
291 return parent::getBrowseBlock($aParams, $aCustom, $sMainUrl, $bClearJoins);
296 foreach( $this->aCurrent[
'restriction']
as $sKey => $aValue ) {
297 if (isset($aValue[
'value'])) {
301 if ((
int)$aValue[
'value'] != 0)
302 $aWhere[] =
"`{$this->aCurrent['table']}`.`{$aValue['field']}` = '" . (int)$aValue[
'value'] .
"'";
306 if (strlen($aValue[
'value']) > 0)
307 $aWhere[] =
"MATCH(`{$this->aCurrent['table']}`.`{$aValue['field']}`) AGAINST ('" . trim(
process_db_input($aValue[
'value'],
CH_TAGS_STRIP)) .
"')";
310 if (is_array($aValue[
'value'])) {
311 $sqlJoin =
"LEFT JOIN `sys_albums_objects` ON `sys_albums_objects`.`id_object`=`{$this->aCurrent['table']}`.`{$this->aCurrent['ident']}`
312 LEFT JOIN `sys_albums` ON `sys_albums_objects`.`id_album`=`sys_albums`.`ID`
314 $sqlCode =
"`AllowAlbumView` IN(";
315 foreach ($aValue[
'value']
as $sValue)
316 $sqlCode .=
"$sValue, ";
317 $aWhere[] = rtrim($sqlCode,
", ") .
')';
323 $sqlWhere =
"WHERE " . implode(
' AND ', $aWhere ) .
" AND `{$this->aCurrent['table']}`.`Status`= 'approved'";
324 $sqlQuery =
"SELECT `{$this->aCurrent['table']}`.`{$this->aCurrent['ident']}` as `{$this->aCurrent['ident']}` FROM `{$this->aCurrent['table']}` $sqlJoin $sqlWhere ORDER BY `{$this->aCurrent['ident']}` DESC LIMIT 1";
328 $aInfo = $this->oModule->_oDb->getFileInfo(array(
'fileId' =>
$iFileId));
332 'file' => $this->oTemplate->getFileConcept(
$aInfo[
'medID'], array(
'ext'=>
$aInfo[
'medExt'],
'source'=>
$aInfo[
'medSource'])),
334 'title' =>
$aInfo[
'medTitle'],
335 'rate' =>
$oRate->getSmallVoting(0),
341 $this->oTemplate->addCss(
'view.css');
342 $sCode = $this->oTemplate->parseHtmlByName(
'latest_file.html', $aDraw);
349 $sIdent = strlen($sHash) > 0 ? $sHash :
$iId;
351 'imgUrl' => $this->
getImgUrl($sIdent,
'browse'),
352 'imgUrl_2x' => $this->
getImgUrl($sIdent,
'browse2x'),
353 'fileLink' => $sFileLink,
354 'ch_if:admin' => array(
355 'condition' => $this->bAdminMode,
356 'content' => array(
'id' =>
$iId)
359 return $this->oModule->_oTemplate->parseHtmlByName(
'thumb.html',
$aUnit);
364 $sCode =
$GLOBALS[
'oFunctions']->centerContent(
$sCode,
'.sys_file_search_unit') .
'<div class="clear_both"></div>';
366 $sFunc = !$bAdminBox ?
'Content' :
'Admin';
367 $sCode = call_user_func(
'DesignBox' . $sFunc,
$sTitle,
'<div class="searchContentBlock">' .
$sCode .
'</div>' .$sPaginate, 1);
368 if (!isset(
$_GET[
'searchMode']))
369 $sCode =
'<div id="page_block_' . $this->
id .
'">' .
$sCode .
'</div>';
376 $sPostFix = isset($this->aConstants[
'picPostfix'][$sImgType]) ? $this->aConstants[
'picPostfix'][$sImgType] : $this->aConstants[
'picPostfix'][
'browse'];
377 if(!file_exists($this->aConstants[
'filesDir'] .
$iId . $sPostFix))
380 return $this->aConstants[
'filesUrl'] .
$iId . $sPostFix;
386 $this->aCurrent[
'restriction'][
'owner'][
'value'] =
$iId;
387 $this->aCurrent[
'paginate'][
'perPage'] = 1000;
388 $this->aCurrent[
'join'][
'category'] = array(
390 'table' =>
'sys_categories',
391 'mainField' => $this->aCurrent[
'ident'],
393 'joinFields' => array(
'Category')
395 $this->aCurrent[
'restriction'][
'category'] = array(
396 'value' => $sCategory,
397 'field' =>
'Category',
399 'table' =>
'sys_categories'
402 $this->aCurrent[
'restriction'][
'type'] = array(
403 'value' => $this->aCurrent[
'name'],
406 'table' =>
'sys_categories'
417 $iAlbumId = (int)$iAlbumId;
421 $this->aCurrent[
'join'][
'albumsObjects'] = array(
423 'table' =>
'sys_albums_objects',
425 'onField' =>
'id_object',
426 'joinFields' => array(
'obj_order')
428 $this->aCurrent[
'sorting'] =
'album_order';
429 if ($aLimits[
'page'])
430 $this->aCurrent[
'paginate'][
'page'] = (int)$aLimits[
'page'];
431 if (isset($aLimits[
'per_page']) && $aLimits[
'per_page'] !==
false)
432 $this->aCurrent[
'paginate'][
'perPage'] = (
int)$aLimits[
'per_page'];
433 $this->aCurrent[
'restriction'][
'album'] = array(
434 'value'=>$iAlbumId,
'field'=>
'id_album',
'operator'=>
'=',
'paramName'=>
'albumId',
'table'=>
'sys_albums_objects'
444 $this->
clearFilters(array(), array(
'albumsObjects',
'albums'));
445 if ($aLimits[
'page'])
446 $this->aCurrent[
'paginate'][
'page'] = (int)$aLimits[
'page'];
447 if ($aLimits[
'per_page'])
448 $this->aCurrent[
'paginate'][
'perPage'] = $aLimits[
'per_page'];
449 $this->aCurrent[
'restriction'][
'activeStatus'][
'value'] =
'approved';
450 $this->aCurrent[
'restriction'][
'owner'][
'value'] = (int)
$iProfId;
460 if (!$this->bCustomParts) {
461 $this->bCustomParts =
true;
463 $this->oTemplate->addLocation($this->aCurrent[
'name'], CH_DIRECTORY_PATH_MODULES . $sModulePart, CH_WSB_URL_MODULES . $sModulePart);
464 $this->oTemplate->addCss(array(
'search.css'));
472 return 'cheetah/'.$this->aCurrent[
'name'];
477 $sResult = $this->oTemplate->addJs(array(
488 foreach ($this->aCurrent[
'restriction']
as $sKey => $aParam) {
489 if (!
empty($aParam[
'value']))
490 $aData[$sKey] = $aParam[
'value'];
492 $aData = array_merge($aData, $aCond);
493 $iAlbumCount = $oSet->getAlbumCount($aData);
494 $this->aCurrent[
'paginate'][
'totalAlbumNum'] = $iAlbumCount;
495 if ($iAlbumCount > 0) {
498 $bCheckPrivacy = isset($aData[
'allow_view']) ?
false :
true;
499 foreach ($aList
as $aData)
505 return $this->oTemplate->parseHtmlByName(
'album_units.html', array(
'content' =>
$sCode));
508 function getAlbumsBlock ($aSectionParams = array(), $aAlbumParams = array(), $aCustom = array())
510 $aCustomTmpl = array(
511 'caption' =>
_t(
'_' . $this->oModule->_oConfig->getMainPrefix() .
'_albums'),
512 'enable_center' =>
true,
513 'unit_css_class' =>
'.sys_album_unit',
514 'page' => isset(
$_GET[
'page']) ? (
int)
$_GET[
'page'] : 1,
515 'per_page' => isset(
$_GET[
'per_page']) ? (
int)
$_GET[
'per_page']: (
int)$this->oModule->_oConfig->getGlParam(
'number_albums_home'),
516 'simple_paginate' =>
true,
519 'paginate_url' =>
'',
520 'simple_paginate_url' => CH_WSB_URL_ROOT . $this->oModule->_oConfig->getUri() .
'/albums/browse',
521 'simple_paginate_view_all' =>
true
523 $aCustom = array_merge($aCustomTmpl, $aCustom);
524 $this->aCurrent[
'paginate'][
'perPage'] = $aCustom[
'per_page'];
525 $this->aCurrent[
'paginate'][
'page'] = $aCustom[
'page'];
528 $sCode = $this->
getAlbumList($this->aCurrent[
'paginate'][
'page'], $this->aCurrent[
'paginate'][
'perPage'], $aAlbumParams);
529 if ($this->aCurrent[
'paginate'][
'totalAlbumNum'] > 0) {
530 if ($aCustom[
'enable_center'])
532 if (
empty($aCustom[
'menu_bottom'])) {
535 'page_url' => $aCustom[
'paginate_url'],
536 'count' => $this->aCurrent[
'paginate'][
'totalAlbumNum'],
537 'per_page' => $this->aCurrent[
'paginate'][
'perPage'],
538 'page' => $this->aCurrent[
'paginate'][
'page'],
539 'on_change_page' =>
'return !loadDynamicBlock({id}, \'' . $aCustom[
'paginate_url'] . $aLinkAddon[
'params'] .
'&page={page}&per_page={per_page}\');',
541 $aCode[
'menu_bottom'] = $aCustom[
'simple_paginate'] ? $oPaginate->getSimplePaginate($aCustom[
'simple_paginate_url'], -1, -1, $aCustom[
'simple_paginate_view_all']) : $oPaginate->getPaginate();
543 $aCode[
'menu_bottom'] = $aCustom[
'menu_bottom'];
546 $aCode[
'menu_top'] = $aCustom[
'menu_top'];
547 return array($aCode[
'code'], $aCode[
'menu_top'], $aCode[
'menu_bottom'], (!
empty($aCode[
'code']) ?
false :
''));
552 $iAlbumId = (int)$iAlbumId;
553 $iLimit = isset($aParams[
'filesInAlbumCover']) ? (int)$aParams[
'filesInAlbumCover'] :
null;
554 return $this->oModule->oAlbums->getAlbumCoverFiles($iAlbumId, array(
'table'=>$this->aCurrent[
'table'],
'field'=>
'ID'), array(array(
'field'=>
'Status',
'value'=>
'approved')), $iLimit);
559 return $this->
getImgUrl($aIdent[
'id_object'],
'thumb');
564 $bOwner = $this->oModule->_iProfileId == $aData[
'Owner'];
566 if(!$this->bAdminMode && $bCheckPrivacy) {
567 if(!$this->oPrivacy->check(
'album_view', $aData[
'ID'], $this->oModule->_iProfileId)) {
569 'type' => $this->aCurrent[
'name']
571 return $this->oTemplate->parseHtmlByName(
'album_unit_private.html',
$aUnit);
577 'type' => $aData[
'Type'],
578 'ch_if:editMode' => array(
579 'condition' => $this->bAdminMode,
581 'id' => $aData[
'ID'],
582 'checked' => $this->sCurrentAlbum == $aData[
'Uri'] ?
'checked="checked"' :
''
585 'albumUrl' => $sLink,
586 'ch_repeat:units' => array(),
587 'title' => $aData[
'Caption'],
588 'titleLink' => stripcslashes($sLink),
591 'view' => isset($aData[
'ObjCount']) ? $aData[
'ObjCount'] .
' ' .
_t($this->aCurrent[
'title']):
'',
595 $iPics = isset($this->aConstants[
'filesInAlbumCover']) ? (int)$this->aConstants[
'filesInAlbumCover'] : 15;
596 $aPics = $this->
getAlbumCovers($aData[
'ID'], array(
'filesInAlbumCover' => $iPics));
597 $bPics = is_array($aPics) && count($aPics) > 0;
599 if(!$bPics && !$bOwner) {
600 $this->aCurrent[
'paginate'][
'totalAlbumNum']--;
603 else if(!$bPics && $bOwner) {
604 if(isset($this->aConstants[
'filesInEmptyAlbumCover']))
605 $iPics = $this->aConstants[
'filesInEmptyAlbumCover'];
608 $aUnit[
'ch_repeat:units'] = array();
609 for($i = 0; $i < $iPics; $i++)
612 $sResult = $this->oTemplate->parseHtmlByName(
'album_unit.html',
$aUnit, array(
'{',
'}'));
613 if(!
empty($aData[
'show_as_list'])) {
615 $sResult = $this->oTemplate->parseHtmlByName(
'album_units.html', array(
'content' =>
$sResult));
617 if(!
empty($aData[
'enable_center']))
628 $bPicture = isset($aPicture[
'id_object']) && (int)$aPicture[
'id_object'] > 0;
630 'ch_if:exist' => array(
631 'condition' => $bPicture,
637 'ch_if:not-exist' => array(
638 'condition' => !$bPicture,
660 $iViewer = $this->oModule->_iProfileId;
661 return $this->oModule->oAlbumPrivacy->check(
'album_view', (
int)$iAlbumId, $iViewer);
668 $sSimpleUrl = CH_WSB_URL_ROOT . $this->oModule->_oConfig->getBaseUri() .
'albums/browse/owner/' . $sNickName;
670 return $this->
getAlbumsBlock(array(), array(
'owner' =>
$iProfileId,
'hide_default' =>
TRUE), array(
'enable_center' =>
true,
'paginate_url' => $sPaginateUrl,
'simple_paginate_url' => $sSimpleUrl));
676 $sNickKey =
'{nickname}';
678 $sDefAlbumName = $this->oModule->_oConfig->getGlParam(
'profile_album_name');
679 if (strpos($sDefAlbumName, $sNickKey) !==
false)
680 $sCaption = str_replace($sNickKey, $sNickName, $sDefAlbumName);
683 $this->aCurrent[
'restriction'][
'album_owner'] = array(
684 'value'=>
$iProfileId,
'field'=>
'Owner',
'operator'=>
'=',
'paramName'=>
'albumOwner',
'table'=>
'sys_albums'
688 $this->aCurrent[
'sorting'] =
'album_order';
689 $this->aCurrent[
'restriction'][
'album'] = array(
690 'value'=>$sUri,
'field'=>
'Uri',
'operator'=>
'=',
'paramName'=>
'albumUri',
'table'=>
'sys_albums'
693 if (is_array($aFiles)) {
694 foreach ($aFiles
as $iKey => $aData)
695 $aFiles[$iKey][
'file'] = $this->
getImgUrl($aData[
'id'],
'icon');
703 $iFileOwner = (int)$iFileOwner;
705 if ($this->oModule->isAdmin($this->oModule->_iProfileId) || $iFileOwner == $this->oModule->_iProfileId)
return true;
706 $this->oModule->_defineActions();
707 $aCheck =
checkAction($this->oModule->_iProfileId, $this->oModule->_defineActionName(
$sAction));
715 return CH_WSB_URL_ROOT . $this->oModule->_oConfig->getBaseUri() .
'view/' . $a[
'uri'];
723 $iId = (int)$aEvent[
'object_id'];
724 $iOwner = (int)$aEvent[
'owner_id'];
727 $aItem = $this->serviceGetEntry(
$iId,
'browse');
728 if(
empty($aItem) || !is_array($aItem))
729 return array(
'perform_delete' =>
true);
731 $aContent = unserialize($aEvent[
'content']);
732 if(
empty($aContent) || !isset($aContent[
'comment_id']))
735 if(!$this->oPrivacy->check(
'album_view', (
int)$aItem[
'album_id'], $this->oModule->_iProfileId))
740 if(!$oCmts->isEnabled())
743 $aComment = $oCmts->getCommentRow((
int)$aContent[
'comment_id']);
746 $sUri = $this->oModule->_oConfig->getUri();
747 if($aEvent[
'js_mode'])
748 $sCss = $this->oModule->_oTemplate->addCss(
'wall_post.css',
true);
750 $this->oModule->_oTemplate->addCss(
'wall_post.css');
752 $sTextAddedNew =
_t(
'_ch_' . $sUri .
'_wall_added_new_comment');
753 $sTextWallObject =
_t(
'_ch_' . $sUri .
'_wall_object');
755 $sTmplName = isset($aParams[
'templates'][
'main']) ? $aParams[
'templates'][
'main'] :
'modules/cheetah/wall/|timeline_comment.html';
756 $sTmplNameSnippet = isset($aParams[
'templates'][
'snippet']) ? $aParams[
'templates'][
'snippet'] :
'modules/cheetah/wall/|timeline_comment_files.html';
758 'title' => $sOwner .
' ' . $sTextAddedNew .
' ' . $sTextWallObject,
759 'description' => $aComment[
'cmt_text'],
760 'content' => $sCss . $this->oModule->_oTemplate->parseHtmlByName($sTmplName, array(
761 'mod_prefix' =>
'ch_' . $sUri,
762 'cpt_user_name' => $sOwner,
763 'cpt_added_new' => $sTextAddedNew,
764 'cpt_object' => $sTextWallObject,
765 'cpt_item_url' => $aItem[
'url'],
766 'cnt_comment_text' => $aComment[
'cmt_text'],
767 'snippet' => $this->oModule->_oTemplate->parseHtmlByName($sTmplNameSnippet, array(
768 'mod_prefix' =>
'ch_' . $sUri,
769 'cnt_item_page' => $aItem[
'url'],
770 'cnt_item_icon' => $aItem[
'file'],
771 'cnt_item_title' => $aItem[
'title'],
773 'cnt_item_description' => $aItem[
'description'],
774 'post_id' => $aEvent[
'id'],