Exemplo n.º 1
0
 /**
  * Method acts as ajax responder. Calls methods using ajax
  * 
  * @return JSON encoded string
  *
  */
 public function getPhotosContent()
 {
     if (empty($_GET['photo_id']) || !$_GET['photo_id']) {
         throw new Redirect404Exception();
         exit;
     }
     $userId = OW::getUser()->getId();
     $photoId = (int) $_GET['photo_id'];
     $photo = $this->photoService->findPhotoById($photoId);
     if (!$photo) {
         exit(json_encode(array('result' => 'error')));
     }
     // is moderator
     $moderatorMode = OW::getUser()->isAuthorized('photo');
     $userId = OW::getUser()->getId();
     $contentOwner = $this->photoService->findPhotoOwner($photoId);
     $ownerMode = $contentOwner == $userId;
     $canView = true;
     $message = '';
     if (!$ownerMode && !OW::getUser()->isAuthorized('photo', 'view')) {
         $canView = false;
         $message = OW::getLanguage()->text('base', 'authorization_failed_feedback');
     }
     $album = $this->photoAlbumService->findAlbumById($photo->albumId);
     $ownerName = BOL_UserService::getInstance()->getUserName($album->userId);
     $photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
     $photos = $this->photoService->getAlbumPhotos($photo->albumId, 1, $photoCount);
     foreach ($photos as $item) {
         $photosList[] = array('photo_id' => $item['id'], 'thumb' => $item['url'], 'src' => $this->photoService->getPhotoUrl($item['id']), 'active' => $item['id'] == $_GET['photo_id'], 'title' => '', 'description' => '');
     }
     //var_dump($photos);die;
     exit(json_encode(array('photos' => $photosList, 'count' => $photoCount, 'album_title' => $album->name, 'album_href' => OW::getRouter()->urlForRoute('photo_user_album', array('user' => $ownerName, 'album' => $photo->albumId)), 'owner_title' => BOL_UserService::getInstance()->getDisplayName($album->userId), 'owner_href' => BOL_UserService::getInstance()->getUserUrl($album->userId), 'authorized' => $ownerMode || $moderatorMode || OW::getUser()->isAuthorized('photo', 'view'), 'message' => $message)));
 }
Exemplo n.º 2
0
 public function view(array $params)
 {
     if (!isset($params['id']) || !($photoId = (int) $params['id'])) {
         throw new Redirect404Exception();
     }
     $lang = OW::getLanguage();
     $photo = $this->photoService->findPhotoById($photoId);
     if (!$photo) {
         throw new Redirect404Exception();
     }
     $album = $this->photoAlbumService->findAlbumById($photo->albumId);
     $this->assign('album', $album);
     $ownerName = BOL_UserService::getInstance()->getUserName($album->userId);
     $albumUrl = OW::getRouter()->urlForRoute('photo_user_album', array('album' => $album->id, 'user' => $ownerName));
     $this->assign('albumUrl', $albumUrl);
     // is owner
     $contentOwner = $this->photoService->findPhotoOwner($photo->id);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     $this->assign('ownerMode', $ownerMode);
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('photo');
     $this->assign('moderatorMode', $modPermissions);
     $this->assign('url', $this->photoService->getPhotoUrl($photo->id, false, $photo->hash));
     if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'view');
         $this->assign('authError', $status['msg']);
         return;
     }
     // permissions check
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => 'photo_view_album', 'ownerId' => $contentOwner, 'viewerId' => $userId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         OW::getEventManager()->trigger($event);
     }
     $photo->description = UTIL_HtmlTag::autoLink($photo->description);
     $this->assign('photo', $photo);
     $fullsizeUrl = (int) OW::getConfig()->getValue('photo', 'store_fullsize') && $photo->hasFullsize ? $this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash) : null;
     $this->assign('fullsizeUrl', $fullsizeUrl);
     $this->assign('nextPhoto', $this->photoService->getNextPhotoId($photo->albumId, $photo->id));
     $this->assign('previousPhoto', $this->photoService->getPreviousPhotoId($photo->albumId, $photo->id));
     $photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
     $this->assign('photoCount', $photoCount);
     $photoIndex = $this->photoService->getPhotoIndex($photo->albumId, $photo->id);
     $this->assign('photoIndex', $photoIndex);
     $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false);
     $this->assign('avatar', $avatar[$contentOwner]);
     $cmtParams = new BASE_CommentsParams('photo', 'photo_comments');
     $cmtParams->setEntityId($photo->id);
     $cmtParams->setOwnerId($contentOwner);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     $photoCmts = new BASE_MCMP_Comments($cmtParams);
     $this->addComponent('comments', $photoCmts);
     OW::getDocument()->setHeading($album->name);
     $description = strip_tags($photo->description);
     $description = mb_strlen($description) ? $description : $photo->id;
     OW::getDocument()->setTitle($lang->text('photo', 'meta_title_photo_view', array('title' => $description)));
 }
Exemplo n.º 3
0
 private function preparePhotos(array $photos)
 {
     if (!count($photos)) {
         return array();
     }
     $list = array();
     foreach ($photos as $photo) {
         $id = $photo->id;
         $album = $this->albumService->findAlbumById($photo->albumId);
         $list[$id]['albumId'] = $photo->albumId;
         $list[$id]['description'] = $photo->description;
         $list[$id]['userId'] = $album->userId;
         $list[$id]['url'] = OW::getRouter()->urlForRoute('view_photo', array('id' => $id));
         $list[$id]['photoUrl'] = $this->photoService->getPhotoUrl($id);
         $list[$id]['previewUrl'] = $this->photoService->getPhotoUrl($id, true);
     }
     return $list;
 }
Exemplo n.º 4
0
 /**
  * Class constructor
  *
  * @param string $listType
  * @param int $count
  * @param string $tag
  */
 public function __construct(array $params)
 {
     parent::__construct();
     $photoId = $params['photoId'];
     $config = OW::getConfig();
     $lang = OW::getLanguage();
     $this->photoService = PHOTO_BOL_PhotoService::getInstance();
     $this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     $photo = $this->photoService->findPhotoById($photoId);
     $album = $this->photoAlbumService->findAlbumById($photo->albumId);
     $this->assign('album', $album);
     // is owner
     $contentOwner = $this->photoService->findPhotoOwner($photo->id);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     $this->assign('ownerMode', $ownerMode);
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('photo');
     $this->assign('moderatorMode', $modPermissions);
     $canView = true;
     if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) {
         $canView = false;
     }
     $this->assign('canView', $canView);
     $cmtParams = new BASE_CommentsParams('photo', 'photo_comments');
     $cmtParams->setEntityId($photo->id);
     $cmtParams->setOwnerId($contentOwner);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     $photoCmts = new BASE_CMP_Comments($cmtParams);
     $this->addComponent('comments', $photoCmts);
     $photoRates = new BASE_CMP_Rate('photo', 'photo_rates', $photo->id, $contentOwner);
     $this->addComponent('rate', $photoRates);
     $photoTags = new BASE_CMP_EntityTagCloud('photo');
     $photoTags->setEntityId($photo->id);
     $photoTags->setRouteName('view_tagged_photo_list');
     $this->addComponent('tags', $photoTags);
     $description = $photo->description;
     $photo->description = UTIL_HtmlTag::autoLink($photo->description);
     $this->assign('photo', $photo);
     $this->assign('url', $this->photoService->getPhotoUrl($photo->id, false, $photo->hash));
     $this->assign('ownerName', BOL_UserService::getInstance()->getUserName($album->userId));
     $is_featured = PHOTO_BOL_PhotoFeaturedService::getInstance()->isFeatured($photo->id);
     if ((int) $config->getValue('photo', 'store_fullsize') && $photo->hasFullsize) {
         $this->assign('fullsizeUrl', $this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash));
     } else {
         $this->assign('fullsizeUrl', null);
     }
     $action = new BASE_ContextAction();
     $action->setKey('photo-moderate');
     $context = new BASE_CMP_ContextAction();
     $context->addAction($action);
     $contextEvent = new BASE_CLASS_EventCollector('photo.collect_photo_context_actions', array('photoId' => $photoId, 'photoDto' => $photo));
     OW::getEventManager()->trigger($contextEvent);
     foreach ($contextEvent->getData() as $contextAction) {
         $action = new BASE_ContextAction();
         $action->setKey(empty($contextAction['key']) ? uniqid() : $contextAction['key']);
         $action->setParentKey('photo-moderate');
         $action->setLabel($contextAction['label']);
         if (!empty($contextAction['id'])) {
             $action->setId($contextAction['id']);
         }
         if (!empty($contextAction['order'])) {
             $action->setOrder($contextAction['order']);
         }
         if (!empty($contextAction['class'])) {
             $action->setClass($contextAction['class']);
         }
         if (!empty($contextAction['url'])) {
             $action->setUrl($contextAction['url']);
         }
         $attributes = empty($contextAction['attributes']) ? array() : $contextAction['attributes'];
         foreach ($attributes as $key => $value) {
             $action->addAttribute($key, $value);
         }
         $context->addAction($action);
     }
     if ($userId && !$ownerMode) {
         $action = new BASE_ContextAction();
         $action->setKey('flag');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'flag'));
         $action->setId('btn-photo-flag');
         $action->addAttribute('rel', $photoId);
         $action->addAttribute('url', OW::getRouter()->urlForRoute('view_photo', array('id' => $photo->id)));
         $context->addAction($action);
     }
     if ($ownerMode || $modPermissions) {
         $action = new BASE_ContextAction();
         $action->setKey('edit');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'edit'));
         $action->setId('btn-photo-edit');
         $action->addAttribute('rel', $photoId);
         $context->addAction($action);
         $action = new BASE_ContextAction();
         $action->setKey('delete');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'delete'));
         $action->setId('photo-delete');
         $action->addAttribute('rel', $photoId);
         $context->addAction($action);
     }
     if ($modPermissions) {
         if ($is_featured) {
             $action = new BASE_ContextAction();
             $action->setKey('unmark-featured');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'remove_from_featured'));
             $action->setId('photo-mark-featured');
             $action->addAttribute('rel', 'remove_from_featured');
             $action->addAttribute('photo-id', $photoId);
             $context->addAction($action);
         } else {
             $action = new BASE_ContextAction();
             $action->setKey('mark-featured');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'mark_featured'));
             $action->setId('photo-mark-featured');
             $action->addAttribute('rel', 'mark_featured');
             $action->addAttribute('photo-id', $photoId);
             $context->addAction($action);
         }
     }
     $this->addComponent('contextAction', $context);
     $nextPhoto = $this->photoService->getNextPhoto($photo->albumId, $photo->id);
     $this->assign('nextPhoto', $nextPhoto);
     $previousPhoto = $this->photoService->getPreviousPhoto($photo->albumId, $photo->id);
     $this->assign('previousPhoto', $previousPhoto);
     $photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
     $this->assign('photoCount', $photoCount);
     $photoIndex = $this->photoService->getPhotoIndex($photo->albumId, $photo->id);
     $this->assign('photoIndex', $photoIndex);
     $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false);
     $this->assign('avatar', $avatar[$contentOwner]);
 }
Exemplo n.º 5
0
 public function backgroundLoadPhoto(OW_Event $event)
 {
     $params = $event->getParams();
     if (empty($params['photoIdList'])) {
         return;
     }
     $photoList = PHOTO_BOL_PhotoDao::getInstance()->findByIdList($params['photoIdList']);
     $js = '$(window).load(function(){';
     foreach ($photoList as $photo) {
         if ($photo->hasFullsize) {
             $js .= ';new Image().src = ' . json_encode($this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash));
         } else {
             $js .= ';new Image().src = ' . json_encode($this->photoService->getPhotoUrl($photo->id, FALSE, $photo->hash));
         }
     }
     $js .= '});';
     OW::getDocument()->addScriptDeclaration($js);
 }
Exemplo n.º 6
0
 /**
  * View photo action
  *
  * @param array $params
  * @throws Redirect404Exception
  */
 public function view(array $params)
 {
     if (!isset($params['id']) || !($photoId = (int) $params['id'])) {
         throw new Redirect404Exception();
     }
     $photo = $this->photoService->findPhotoById($photoId);
     if (!$photo) {
         throw new Redirect404Exception();
     }
     $album = $this->photoAlbumService->findAlbumById($photo->albumId);
     $this->assign('album', $album);
     $language = OW::getLanguage();
     // is owner
     $contentOwner = $this->photoService->findPhotoOwner($photo->id);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     $this->assign('ownerMode', $ownerMode);
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('photo');
     $this->assign('moderatorMode', $modPermissions);
     if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     // permissions check
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => 'photo_view_album', 'ownerId' => $contentOwner, 'viewerId' => $userId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         OW::getEventManager()->trigger($event);
     }
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.bbq.min.js');
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('photo')->getStaticJsUrl() . 'photo.js');
     OW::getLanguage()->addKeyForJs('photo', 'tb_edit_photo');
     OW::getLanguage()->addKeyForJs('photo', 'confirm_delete');
     OW::getLanguage()->addKeyForJs('photo', 'mark_featured');
     OW::getLanguage()->addKeyForJs('photo', 'remove_from_featured');
     $objParams = array('ajaxResponder' => OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxResponder'), 'fbResponder' => OW::getRouter()->urlForRoute('photo.floatbox'), 'layout' => 'page');
     $script = 'if ( !window.photoViewObj ) {
         window.photoViewObj = new photoView(' . json_encode($objParams) . ');
     }
     
     window.photoViewObj.showPhotoCmp(' . $photo->id . ');
     
     $(window).bind( "hashchange", function(e) {
         var photo_id = $.bbq.getState("view-photo");
         if ( photo_id != undefined )
         {
             if ( window.photoFBLoading ) { return; }
             window.photoViewObj.showPhotoCmp(photo_id);
         }
     });';
     OW::getDocument()->addOnloadScript($script);
     OW::getDocument()->setHeading($album->name);
     OW::getDocument()->setHeadingIconClass('ow_ic_picture');
     $imageUrl = $this->photoService->getPhotoUrl($photo->id);
     OW::getDocument()->addMetaInfo('image', $imageUrl, 'itemprop');
     OW::getDocument()->addMetaInfo('og:image', $imageUrl, 'property');
     $description = strip_tags($photo->description);
     $description = mb_strlen($description) ? $description : $photo->id;
     OW::getDocument()->setTitle($language->text('photo', 'meta_title_photo_view', array('title' => $description)));
     $tagsArr = BOL_TagService::getInstance()->findEntityTags($photo->id, 'photo');
     $labels = array();
     foreach ($tagsArr as $t) {
         $labels[] = $t->label;
     }
     $tagStr = $tagsArr ? implode(', ', $labels) : '';
     OW::getDocument()->setDescription($language->text('photo', 'meta_description_photo_view', array('title' => $description, 'tags' => $tagStr)));
 }
Exemplo n.º 7
0
    /**
     * Controller action for user album
     *
     * @param array $params
     */
    public function userAlbum(array $params)
    {
        if (!isset($params['user']) || !strlen($user = trim($params['user']))) {
            throw new Redirect404Exception();
        }
        if (!isset($params['album']) || !($albumId = (int) $params['album'])) {
            throw new Redirect404Exception();
        }
        // is owner
        $userDto = BOL_UserService::getInstance()->findByUsername($user);
        if ($userDto) {
            $ownerMode = $userDto->id == OW::getUser()->getId();
        } else {
            $ownerMode = false;
        }
        // is moderator
        $modPermissions = OW::getUser()->isAuthorized('photo');
        if (!OW::getUser()->isAuthorized('photo', 'view') && !$modPermissions && !$ownerMode) {
            $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
            return;
        }
        $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
        $config = OW::getConfig();
        $photoPerPage = $config->getValue('photo', 'photos_per_page');
        $album = $this->photoAlbumService->findAlbumById($albumId);
        if (!$album) {
            throw new Redirect404Exception();
            return;
        }
        $this->assign('album', $album);
        // permissions check
        if (!$ownerMode && !$modPermissions) {
            $privacyParams = array('action' => 'photo_view_album', 'ownerId' => $album->userId, 'viewerId' => OW::getUser()->getId());
            $event = new OW_Event('privacy_check_permission', $privacyParams);
            OW::getEventManager()->trigger($event);
        }
        $this->assign('userName', BOL_UserService::getInstance()->getUserName($album->userId));
        $displayName = BOL_UserService::getInstance()->getDisplayName($album->userId);
        $this->assign('displayName', $displayName);
        $photos = $this->photoService->getAlbumPhotos($albumId, $page, $photoPerPage);
        $aPhotos = array();
        if ($photos) {
            $userIds = array();
            foreach ($photos as $photo) {
                $photo['fullurl'] = $this->photoService->getPhotoUrl($photo['id']);
                $photo['comments_count'] = BOL_CommentService::getInstance()->findCommentCount('photo_comments', $photo['id']);
                $aPhotos[] = $photo;
            }
        }
        $this->assign('photos', $aPhotos);
        $total = $this->photoAlbumService->countAlbumPhotos($albumId);
        $this->assign('total', $total);
        $lastUpdated = $this->photoAlbumService->getAlbumUpdateTime($albumId);
        $this->assign('lastUpdate', $lastUpdated);
        $this->assign('widthConfig', $config->getValue('photo', 'preview_image_width'));
        $this->assign('heightConfig', $config->getValue('photo', 'preview_image_height'));
        // Paging
        $pages = (int) ceil($total / $photoPerPage);
        $paging = new BASE_CMP_Paging($page, $pages, $photoPerPage);
        $this->assign('paging', $paging->render());
        OW::getDocument()->setHeading($album->name . ' <span class="ow_small">' . OW::getLanguage()->text('photo', 'photos_in_album', array('total' => $total)) . '</span>');
        OW::getDocument()->setHeadingIconClass('ow_ic_picture');
        // check permissions
        $canEdit = OW::getUser()->isAuthorized('photo', 'upload', $album->userId);
        $canModerate = OW::getUser()->isAuthorized('photo');
        $authorized = $canEdit || $canModerate;
        $this->assign('authorized', $canEdit || $canModerate);
        $this->assign('canUpload', $canEdit);
        $lang = OW::getLanguage();
        if ($authorized) {
            $albumEditForm = new albumEditForm();
            $albumEditForm->getElement('albumName')->setValue($album->name);
            $albumEditForm->getElement('category')->setValue($album->category_id);
            $albumEditForm->getElement('id')->setValue($album->id);
            $this->addForm($albumEditForm);
            OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('photo')->getStaticJsUrl() . 'album.js');
            if (OW::getRequest()->isPost() && $albumEditForm->isValid($_POST)) {
                $res = $albumEditForm->process();
                if ($res['result']) {
                    OW::getFeedback()->info($lang->text('photo', 'photo_album_updated'));
                    $this->redirect();
                }
            }
            $lang->addKeyForJs('photo', 'confirm_delete_album');
            $lang->addKeyForJs('photo', 'edit_album');
            $objParams = array('ajaxResponder' => OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxResponder'), 'albumId' => $albumId, 'uploadUrl' => OW::getRouter()->urlForRoute('photo_upload_album', array('album' => $album->id)));
            $script = "\$(document).ready(function(){\n                    var album = new photoAlbum( " . json_encode($objParams) . ");\n                }); ";
            OW::getDocument()->addOnloadScript($script);
        }
        OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('advancedphoto')->getStaticJsUrl() . 'hap.min.js');
        $script = '
			//var hap = new hap();
			hap.initialize({request_url: "", max_width: 220});			  
		';
        OW::getDocument()->addOnloadScript($script);
        OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.bbq.min.js');
        OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('photo')->getStaticJsUrl() . 'photo.js');
        OW::getLanguage()->addKeyForJs('photo', 'tb_edit_photo');
        OW::getLanguage()->addKeyForJs('photo', 'confirm_delete');
        OW::getLanguage()->addKeyForJs('photo', 'mark_featured');
        OW::getLanguage()->addKeyForJs('photo', 'remove_from_featured');
        $objParams = array('ajaxResponder' => OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxResponder'), 'fbResponder' => OW::getRouter()->urlForRoute('photo.floatbox'));
        $script = '$("div.photo a").on("click", function(e){
			e.preventDefault();
			var photo_id = $(this).attr("rel");

			if ( !window.photoViewObj ) {
				window.photoViewObj = new photoView(' . json_encode($objParams) . ');
			}
			
			window.photoViewObj.setId(photo_id);
		}); 
        
        $(window).bind( "hashchange", function(e) {
            var photo_id = $.bbq.getState("view-photo");
            if ( photo_id != undefined )
            {
                if ( window.photoFBLoading ) { return; }
                window.photoViewObj.showPhotoCmp(photo_id);
            }
        });';
        OW::getDocument()->addOnloadScript($script);
        OW::getDocument()->setTitle($lang->text('photo', 'meta_title_photo_useralbum', array('displayName' => $displayName, 'albumName' => $album->name)));
        OW::getDocument()->setDescription($lang->text('photo', 'meta_description_photo_useralbum', array('displayName' => $displayName, 'number' => $total)));
    }
Exemplo n.º 8
0
    /**
     * Class constructor
     *
     * @param string $listType
     * @param int $count
     * @param string $tag
     */
    public function __construct(array $params)
    {
        parent::__construct();
        $listType = $params['listType'];
        $this->assign('listType', $listType);
        $this->assign('idPrefix', $params['idPrefix']);
        $this->assign('format', isset($params['format']) ? $params['format'] : '');
        $this->photoService = PHOTO_BOL_PhotoService::getInstance();
        $this->advancePhotoService = ADVANCEDPHOTO_BOL_PhotoService::getInstance();
        $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
        $config = OW::getConfig();
        $photosPerPage = $config->getValue('photo', 'photos_per_page');
        $result = array();
        $photos = array();
        if (isset($params['tag']) && strlen($tag = $params['tag'])) {
            $photos = $this->photoService->findTaggedPhotos($tag, $page, $photosPerPage);
            $records = $this->photoService->countTaggedPhotos($tag);
        } else {
            if (is_numeric($listType)) {
                $checkPrivacy = !OW::getUser()->isAuthorized('photo');
                $photos = $this->advancePhotoService->getPhotoListCategory($listType, $page, $photosPerPage, $checkPrivacy);
                $records = $this->advancePhotoService->countPhotoListCategory($listType, $checkPrivacy);
            } else {
                if ($listType == 'featured') {
                    $checkPrivacy = false;
                    $photosPerPage = OW::getConfig()->getValue('advancedphoto', 'photofeature_per_page');
                    $photos = $this->advancePhotoService->findPhotoList($listType, $page, $photosPerPage, $checkPrivacy);
                    $records = $this->advancePhotoService->countPhotosFeature($listType, $checkPrivacy);
                } else {
                    //echo $listType;die;
                    $checkPrivacy = $listType == 'latest' && !OW::getUser()->isAuthorized('photo');
                    $photos = $this->photoService->findPhotoList($listType, $page, $photosPerPage, $checkPrivacy);
                    $records = $this->photoService->countPhotos($listType, $checkPrivacy);
                }
            }
        }
        $aPhotos = array();
        if ($photos) {
            $userIds = array();
            foreach ($photos as $photo) {
                if (!in_array($photo['userId'], $userIds)) {
                    array_push($userIds, $photo['userId']);
                }
                $photo['url'] = $this->photoService->getPhotoUrl($photo['id']);
                $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($photo['albumId']);
                $ownerName = BOL_UserService::getInstance()->getUserName($album->userId);
                $photo['album_title'] = $album->name;
                $photo['album_href'] = OW::getRouter()->urlForRoute('photo_user_album', array('user' => $ownerName, 'album' => $album->id));
                $aPhotos[] = $photo;
            }
            $names = BOL_UserService::getInstance()->getDisplayNamesForList($userIds);
            $this->assign('names', $names);
            $usernames = BOL_UserService::getInstance()->getUserNamesForList($userIds);
            $this->assign('usernames', $usernames);
            // Paging
            $pages = (int) ceil($records / $photosPerPage);
            ADVANCEDPHOTO_CTRL_Photo::$isNext = $result['isNext'] = $isNext = $pages > $page ? true : false;
            ADVANCEDPHOTO_CTRL_Photo::$item_count = $result['item_count'] = count($aPhotos);
            $this->assign('photos', $aPhotos);
            $this->assign('no_content', false);
        } else {
            $this->assign('no_content', true);
        }
        if (OW::getPluginManager()->isPluginActive('gphotoviewer')) {
            $script = "PhotoViewer.bindPhotoViewer();";
            OW::getDocument()->addOnloadScript($script);
        } else {
            $objParams = array('ajaxResponder' => OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxResponder'), 'fbResponder' => OW::getRouter()->urlForRoute('photo.floatbox'));
            OW::getLanguage()->addKeyForJs('photo', 'tb_edit_photo');
            OW::getLanguage()->addKeyForJs('photo', 'confirm_delete');
            OW::getLanguage()->addKeyForJs('photo', 'mark_featured');
            OW::getLanguage()->addKeyForJs('photo', 'remove_from_featured');
            $script = '$("div.photo a").on("click", function(e){
				e.preventDefault();
				var photo_id = $(this).attr("rel");
				if ( !window.photoViewObj ) {
					window.photoViewObj = new photoView(' . json_encode($objParams) . ');
				}
				window.photoViewObj.setId(photo_id);
			}); ';
            OW::getDocument()->addOnloadScript($script);
        }
    }