10 require_once(
'ChPhotosCmts.php');
 
   11 require_once(
'ChPhotosSearch.php');
 
   26         parent::__construct($sPage);
 
   28         $this->iProfileId = &$oShared->_iProfileId;
 
   30         $this->oModule = $oShared;
 
   31         $this->oTemplate = $oShared->_oTemplate;
 
   32         $this->oConfig = $oShared->_oConfig;
 
   33         $this->oDb = $oShared->_oDb;
 
   35         $this->oTemplate->addCss(
'view.css');
 
   37         new ChWsbViews($this->oConfig->getMainPrefix(), $this->aFileInfo[
'medID']);
 
   43         $sMainPrefix = $this->oConfig->getMainPrefix();
 
   47         $aButton = 
$oSubscription->getButton($this->iProfileId, $sMainPrefix, 
'', (
int)$this->aFileInfo[
'medID']);
 
   51         $sProfileAlbumUri = 
ChWsbAlbums::getAbumUri($this->oConfig->getGlParam(
'profile_album_name'), $this->iProfileId);
 
   53         $aReplacement = array(
 
   54             'favorited' => $this->aFileInfo[
'favorited'] == 
false ? 
'' : 
'favorited',
 
   55             'featured' => (
int)$this->aFileInfo[
'Featured'],
 
   59             'moduleUrl' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri(),
 
   60             'fileUri' => $this->aFileInfo[
'medUri'],
 
   61             'fileKey' => $this->aFileInfo[
'Hash'],
 
   62             'fileExt' => $this->aFileInfo[
'medExt'],
 
   63             'iViewer' => $this->iProfileId,
 
   64             'ID' => (
int)$this->aFileInfo[
'medID'],
 
   65             'Owner' => (
int)$this->aFileInfo[
'medProfId'],
 
   66             'OwnerName' => $this->aFileInfo[
'NickName'],
 
   67             'AlbumUri' => $this->aFileInfo[
'albumUri'],
 
   69             'TitleAvatar' => $this->aFileInfo[
'medProfId'] == $this->iProfileId && 
'sys_avatar' == 
getParam(
'sys_member_info_thumb') ? 
_t(
'_' . $sMainPrefix . 
'_set_as_avatar') : 
'',
 
   70             'SetAvatarCpt' => $this->aFileInfo[
'medProfId'] == $this->iProfileId && $sProfileAlbumUri == $this->aFileInfo[
'albumUri'] && 
'ch_photos_thumb' == 
getParam(
'sys_member_info_thumb') ? 
_t(
'_' . $sMainPrefix . 
'_set_as_avatar') : 
'',
 
   71             'sbs_' . $sMainPrefix . 
'_title' => $aButton[
'title'],
 
   72             'sbs_' . $sMainPrefix . 
'_script' => $aButton[
'script'],
 
   73             'shareCpt' => $this->oModule->isAllowedShare($this->aFileInfo) ? 
_t(
'_Share') : 
'',
 
   74             'cropCpt' => $this->oModule->isAllowedEdit($this->aFileInfo) && $this->aFileInfo[
'medProfId'] == $this->iProfileId ? 
_t(
'_ch_photos_crop_action') : 
'',
 
   76         if (
isAdmin($this->iProfileId)) {
 
   77             $sMsg = $aReplacement[
'featured'] > 0 ? 
'un' : 
'';
 
   78             $aReplacement[
'featuredCpt'] = 
_t(
'_' . $sMainPrefix . 
'_action_' . 
$sMsg . 
'feature');
 
   80         if ($this->oModule->isAllowedApprove($this->aFileInfo)) {
 
   83             if ($this->aFileInfo[
'Approved'] == 
'approved')
 
   88             $aReplacement[
'approvedCpt'] = 
_t(
'_' . $sMainPrefix . 
'_admin_' . 
$sMsg . 
'activate');
 
   89             $aReplacement[
'approvedAct'] = $iAppr;
 
   92         $aReplacement[
'repostCpt'] = $aReplacement[
'repostScript'] = 
'';
 
   96             $aReplacement[
'repostCpt'] = 
_t(
'_Repost');
 
   97             $aReplacement[
'repostScript'] = 
ChWsbService::call(
'wall', 
'get_repost_js_click', array($this->iProfileId, $sMainPrefix, 
'add', (
int)$this->aFileInfo[
'medID']));
 
  100         $sActionsList = 
$GLOBALS[
'oFunctions']->genObjectsActions($aReplacement, $sMainPrefix);
 
  101         if(is_null($sActionsList))
 
  104         return $sCode . $sActionsList;
 
  109         return $this->oTemplate->getFileAuthor($this->aFileInfo);
 
  114         $oAlbum = 
new ChWsbAlbums($this->oConfig->getMainPrefix());
 
  115         $aAlbum = $oAlbum->getAlbumInfo(array(
'fileId' => $this->aFileInfo[
'albumId']));
 
  116         $aAlbum[
'show_as_list'] = 
true;
 
  118         return array($this->oSearch->displayAlbumUnit($aAlbum), array(), array(), 
false);
 
  123         $this->oSearch->clearFilters(array(
'activeStatus', 
'albumType', 
'allow_view', 
'album_status'), array(
'albumsObjects', 
'albums'));
 
  124         $bLike = 
getParam(
'useLikeOperator');
 
  125         if ($bLike != 
'on') {
 
  126             $aRel = array($this->aFileInfo[
'medTitle'], $this->aFileInfo[
'medDesc'], $this->aFileInfo[
'medTags'], $this->aFileInfo[
'Categories']);
 
  128             if (!
empty($sKeywords)) {
 
  129                 $this->oSearch->aCurrent[
'restriction'][
'keyword'] = array(
 
  130                     'value' => $sKeywords,
 
  132                     'operator' => 
'against' 
  136             $sKeywords = $this->aFileInfo[
'medTitle'].
' '.$this->aFileInfo[
'medTags'];
 
  137             $aWords = explode(
' ', $sKeywords);
 
  138             foreach (array_unique($aWords) 
as $iKey => $sValue) {
 
  139                 if (strlen($sValue) > 2) {
 
  140                     $this->oSearch->aCurrent[
'restriction'][
'keyword'.$iKey] = array(
 
  141                         'value' => trim(addslashes($sValue)),
 
  143                         'operator' => 
'against' 
  148         $this->oSearch->aCurrent[
'restriction'][
'id'] = array(
 
  149             'value' => $this->aFileInfo[
'medID'],
 
  150             'field' => $this->oSearch->aCurrent[
'ident'],
 
  152             'paramName' => 
'fileID' 
  154         $this->oSearch->aCurrent[
'sorting'] = 
'score';
 
  155         $iLimit = (int)$this->oConfig->getGlParam(
'number_related');
 
  156         $iLimit = $iLimit == 0 ? 2 : $iLimit;
 
  158         $this->oSearch->aCurrent[
'paginate'][
'perPage'] = $iLimit;
 
  159         $sCode = $this->oSearch->displayResultBlock();
 
  160         $aBottomMenu = array();
 
  162         if ($this->oSearch->aCurrent[
'paginate'][
'totalNum'] > 0) {
 
  164             $aBottomMenu = $this->oSearch->getBottomMenu(
'category', 0, $this->aFileInfo[
'Categories']);
 
  167         return array(
$sCode, array(), $aBottomMenu, $bWrap);
 
  172         $this->oTemplate->addCss(
'cmts.css');
 
  174         $oCmtsView = 
new ChPhotosCmts($this->oConfig->getMainPrefix(), $this->aFileInfo[
'medID']);
 
  175         if (!$oCmtsView->isEnabled())
 
  178         return $oCmtsView->getCommentsFirst();
 
  183         $oVotingView = 
new ChTemplVotingView($this->oConfig->getMainPrefix(), $this->aFileInfo[
'medID']);
 
  184         $iWidth = (int)$this->oConfig->getGlParam(
'file_width');
 
  185         if ($this->aFileInfo[
'prevItem'] > 0)
 
  186             $aPrev = $this->oDb->getFileInfo(array(
'fileId'=>$this->aFileInfo[
'prevItem']), 
true, array(
'medUri', 
'medTitle'));
 
  187         if ($this->aFileInfo[
'nextItem'] > 0)
 
  188             $aNext = $this->oDb->getFileInfo(array(
'fileId'=>$this->aFileInfo[
'nextItem']), 
true, array(
'medUri', 
'medTitle'));
 
  190             'pic' => $this->oSearch->getImgUrl($this->aFileInfo[
'Hash'], 
'file'),
 
  192             'fileTitle' => $this->aFileInfo[
'medTitle'],
 
  193             'fileDescription' => nl2br($this->aFileInfo[
'medDesc']),
 
  194             'rate' => $oVotingView->isEnabled() ? $oVotingView->getBigVoting(1, $this->aFileInfo[
'Rate']): 
'',
 
  195             'favInfo' => $this->oDb->getFavoritesCount($this->aFileInfo[
'medID']),
 
  196             'viewInfo' => $this->aFileInfo[
'medViews'],
 
  197             'albumUri' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 
'browse/album/' . $this->aFileInfo[
'albumUri'] . 
'/owner/' . $this->aFileInfo[
'NickName'],
 
  198             'albumCaption' => $this->aFileInfo[
'albumCaption'],
 
  199             'ch_if:prev' => array(
 
  200                 'condition' => $this->aFileInfo[
'prevItem'] > 0,
 
  202                     'linkPrev'  => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 
'view/' . $aPrev[
'medUri'],
 
  203                     'titlePrev' => $aPrev[
'medTitle'],
 
  204                     'percent' => $this->aFileInfo[
'nextItem'] > 0 ? 50 : 100,
 
  207             'ch_if:next' => array(
 
  208                 'condition' => $this->aFileInfo[
'nextItem'] > 0,
 
  210                     'linkNext'  => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 
'view/' . $aNext[
'medUri'],
 
  211                     'titleNext' => $aNext[
'medTitle'],
 
  212                     'percent' => $this->aFileInfo[
'prevItem'] > 0 ? 50 : 100,
 
  217         $sCode = $this->oTemplate->parseHtmlByName(
'view_unit.html', 
$aUnit);
 
  218         return array(
$sCode, array(), array(), 
false);
 
  223         return $this->oTemplate->getFileInfoMain($this->aFileInfo);
 
  228         if(!$this->oModule->isAllowedShare($this->aFileInfo))
 
  231         $sUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 
'view/' . $this->aFileInfo[
'medUri'];
 
  232         $sTitle = $this->aFileInfo[
'medTitle'];
 
  233         $sImgUrl = $this->oSearch->getImgUrl($this->aFileInfo[
'Hash'], 
'file');
 
  237             'img_url' => $sImgUrl,
 
  238             'img_url_encoded' => rawurlencode($sImgUrl),
 
  240         return array(
$sCode, array(), array(), 
false);
 
  245         $this->oTemplate->addCss(array(
 
  247             'plugins/croppic/css/|croppic.css',
 
  250         $this->oTemplate->addJs(array(
 
  251             'croppic/js/croppic.min.js',
 
  255             'crop_url' =>  CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 
'crop_perform/' . $this->aFileInfo[
'medID'],
 
  256             'preload_image' => $this->oSearch->getImgUrl($this->aFileInfo[
'Hash'], 
'original'),
 
  257             'url' => CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 
'view/' . $this->aFileInfo[
'medUri'],
 
  258             'title' => $this->aFileInfo[
'medTitle'],
 
  260         $sCode = $this->oTemplate->parseHtmlByName(
'crop.html', 
$aVars);