本文整理汇总了PHP中PHOTO_BOL_PhotoAlbumService::countUserAlbums方法的典型用法代码示例。如果您正苦于以下问题:PHP PHOTO_BOL_PhotoAlbumService::countUserAlbums方法的具体用法?PHP PHOTO_BOL_PhotoAlbumService::countUserAlbums怎么用?PHP PHOTO_BOL_PhotoAlbumService::countUserAlbums使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHOTO_BOL_PhotoAlbumService
的用法示例。
在下文中一共展示了PHOTO_BOL_PhotoAlbumService::countUserAlbums方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collectAlbumsForAvatar
public function collectAlbumsForAvatar(BASE_CLASS_EventCollector $e)
{
if (!OW::getUser()->isAuthenticated()) {
return;
}
$params = $e->getParams();
$userId = OW::getUser()->getId();
$total = $this->albumService->countUserAlbums($userId);
$albums = $this->albumService->findUserAlbums($userId, 0, $total);
if (!$albums) {
return;
}
foreach ($albums as $album) {
$photoCount = $this->photoService->countAlbumPhotos($album->id, array());
if (!$photoCount) {
continue;
}
$photos = $this->photoService->getAlbumPhotos($album->id, 1, $params['limit']);
$list = array();
foreach ($photos as $photo) {
$list[] = array('id' => $photo['id'], 'entityId' => $album->id, 'entityType' => 'photo_album', 'url' => $photo['url'], 'bigUrl' => $this->photoService->getPhotoUrlByType($photo['id'], PHOTO_BOL_PhotoService::TYPE_MAIN, $photo['dto']->hash, $photo['dto']->dimension));
}
$section = array('entityId' => $album->id, 'entityType' => 'photo_album', 'label' => $album->name, 'count' => $photoCount, 'list' => $list);
$e->add($section);
}
}
示例2: albums
public function albums(array $params)
{
if (empty($params['user']) || !mb_strlen($username = trim($params['user']))) {
throw new Redirect404Exception();
}
$user = BOL_UserService::getInstance()->findByUsername($username);
if (!$user) {
throw new Redirect404Exception();
}
$ownerMode = $user->id == OW::getUser()->getId();
// is moderator
$modPermissions = OW::getUser()->isAuthorized('photo');
if (!OW::getUser()->isAuthorized('photo', 'view') && !$modPermissions && !$ownerMode) {
$status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'view');
$this->assign('authError', $status['msg']);
return;
}
$lang = OW::getLanguage();
$limit = 6;
$initialCmp = new PHOTO_MCMP_AlbumList($user->id, $limit, array());
$this->addComponent('albums', $initialCmp);
$total = $this->photoAlbumService->countUserAlbums($user->id);
$this->assign('loadMore', $total > $limit);
if (OW::getUser()->isAuthenticated() && !OW::getUser()->isAuthorized('photo', 'upload')) {
$id = uniqid('photo_add');
$status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'upload');
OW::getDocument()->addScriptDeclaration(UTIL_JsGenerator::composeJsString(';$("#" + {$btn}).on("click", function()
{
OWM.authorizationLimitedFloatbox({$msg});
});', array('btn' => $id, 'msg' => $status['msg'])));
$this->assign('id', $id);
} else {
$this->assign('uploadUrl', OW::getRouter()->urlForRoute('photo_upload'));
}
$script = '
OWM.bind("photo.hide_load_more", function(){
$("#btn-photo-load-more").hide();
});
$("#btn-photo-load-more").click(function(){
var node = $(this);
node.addClass("owm_preloader");
var exclude = $("li.owm_photo_album_list_item").map(function(){ return $(this).data("ref"); }).get();
OWM.loadComponent(
"PHOTO_MCMP_AlbumList",
{userId: "' . $user->id . '", count:' . $limit . ', exclude: exclude},
{
onReady: function(html){
$("#album-list-cont").append(html);
node.removeClass("owm_preloader");
}
}
);
});';
OW::getDocument()->addOnloadScript($script);
$displayName = BOL_UserService::getInstance()->getDisplayName($user->id);
OW::getDocument()->setHeading($lang->text('photo', 'page_title_user_albums', array('user' => $displayName)));
OW::getDocument()->setTitle($lang->text('photo', 'meta_title_photo_useralbums', array('displayName' => $displayName)));
}
示例3: __construct
public function __construct($userId, $limit, $exclude)
{
parent::__construct();
$this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
$user = BOL_UserService::getInstance()->findUserById($userId);
$this->assign('username', $user->getUsername());
$albums = $this->photoAlbumService->findUserAlbumList($user->id, 1, $limit, $exclude, true);
$this->assign('albums', $albums);
foreach ($albums as $album) {
array_push($exclude, $album['dto']->id);
}
$loadMore = $this->photoAlbumService->countUserAlbums($userId, $exclude);
if (!$loadMore) {
$script = "OWM.trigger('photo.hide_load_more', {});";
OW::getDocument()->addOnloadScript($script);
}
}
示例4: userAlbums
/**
* Controller action for user albums list
*
* @param array $params
* @throws Redirect404Exception
*/
public function userAlbums(array $params)
{
if (empty($params['user']) || !mb_strlen($username = trim($params['user']))) {
throw new Redirect404Exception();
}
$user = BOL_UserService::getInstance()->findByUsername($username);
if (!$user) {
throw new Redirect404Exception();
}
$userId = $user->id;
$ownerMode = $userId == OW::getUser()->getId();
// 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;
}
// permissions check
if (!$ownerMode && !$modPermissions) {
$privacyParams = array('action' => 'photo_view_album', 'ownerId' => $userId, 'viewerId' => OW::getUser()->getId());
$event = new OW_Event('privacy_check_permission', $privacyParams);
OW::getEventManager()->trigger($event);
}
$this->assign('username', $username);
$displayName = BOL_UserService::getInstance()->getDisplayName($userId);
$this->assign('displayName', $displayName);
$total = $this->photoAlbumService->countUserAlbums($userId);
$page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
$config = OW::getConfig();
$albumPerPage = $config->getValue('photo', 'photos_per_page');
$albums = $this->photoAlbumService->findUserAlbumList($userId, $page, $albumPerPage);
$this->assign('albums', $albums);
$this->assign('total', $total);
$this->assign('userId', $userId);
// Paging
$pages = (int) ceil($total / $albumPerPage);
$paging = new BASE_CMP_Paging($page, $pages, $albumPerPage);
$this->assign('paging', $paging->render());
$this->assign('widthConfig', $config->getValue('photo', 'preview_image_width'));
$this->assign('heightConfig', $config->getValue('photo', 'preview_image_height'));
OW::getDocument()->setHeading(OW::getLanguage()->text('photo', 'page_title_user_albums', array('user' => $displayName)));
OW::getDocument()->setHeadingIconClass('ow_ic_picture');
OW::getDocument()->setTitle(OW::getLanguage()->text('photo', 'meta_title_photo_useralbums', array('displayName' => $displayName)));
if ($albums) {
$albumTitles = array();
$i = 0;
foreach ($albums as $album) {
$albumTitles[] = $album['dto']->name;
if ($i == 10) {
break;
}
$i++;
}
$albumTitles = implode(', ', $albumTitles);
OW::getDocument()->setDescription(OW::getLanguage()->text('photo', 'meta_description_photo_useralbums', array('displayName' => $displayName, 'albums' => $albumTitles)));
}
}
示例5: albums
public function albums(array $params)
{
if (empty($params['user']) || !mb_strlen($username = trim($params['user']))) {
throw new Redirect404Exception();
}
$user = BOL_UserService::getInstance()->findByUsername($username);
if (!$user) {
throw new Redirect404Exception();
}
$lang = OW::getLanguage();
$limit = 6;
$initialCmp = new PHOTO_MCMP_AlbumList($user->id, $limit, array());
$this->addComponent('albums', $initialCmp);
$total = $this->photoAlbumService->countUserAlbums($user->id);
$this->assign('loadMore', $total > $limit);
$this->assign('uploadUrl', OW::getRouter()->urlForRoute('photo_upload'));
$script = '
OWM.bind("photo.hide_load_more", function(){
$("#btn-photo-load-more").hide();
});
$("#btn-photo-load-more").click(function(){
var node = $(this);
node.addClass("owm_preloader");
var exclude = $("li.owm_photo_album_list_item").map(function(){ return $(this).data("ref"); }).get();
OWM.loadComponent(
"PHOTO_MCMP_AlbumList",
{userId: "' . $user->id . '", count:' . $limit . ', exclude: exclude},
{
onReady: function(html){
$("#album-list-cont").append(html);
node.removeClass("owm_preloader");
}
}
);
});';
OW::getDocument()->addOnloadScript($script);
$displayName = BOL_UserService::getInstance()->getDisplayName($user->id);
OW::getDocument()->setHeading($lang->text('photo', 'page_title_user_albums', array('user' => $displayName)));
OW::getDocument()->setTitle($lang->text('photo', 'meta_title_photo_useralbums', array('displayName' => $displayName)));
}