/** * @param string $type * @param TabTable $tab * @param UserTable $user * @param UserTable $viewer * @return null|string */ private function getGallery( $type, $tab, $user, $viewer ) { list( $folders, $foldersPageNav, $foldersSearching, $foldersInput ) = $this->getFolders( $type, $tab, $user, $viewer ); list( $items, $itemsPageNav, $itemsSearching, $itemsInput ) = $this->getItems( $type, $tab, $user, $viewer ); $input = array_merge( $foldersInput, $itemsInput ); $showEmpty = (int) ( isset( $ueConfig['showEmptyTabs'] ) ? $ueConfig['showEmptyTabs'] : 1 ); cbgalleryClass::getTemplate( array( 'items', 'folder', 'folders', $type ) ); if ( ( ! $showEmpty ) && ( ! ( $folders || cbgalleryClass::canUserCreate( $viewer, $type, true ) ) ) && ( ! ( $items || cbgalleryClass::canUserCreate( $viewer, $type, false ) ) ) ) { return null; } return HTML_cbgalleryItems::showItems( $folders, $foldersPageNav, $foldersSearching, $items, $itemsPageNav, $itemsSearching, $type, $input, $viewer, $user, $tab, $this ); }
/** * Displays folder create/edit page * * @param int $id * @param string $type * @param TabTable $tab * @param UserTable $user * @param UserTable $viewer * @param null|string $message * @param null|string $messageType */ public function showFolderEdit( $id, $type, $tab, $user, $viewer, $message = null, $messageType = 'error' ) { global $_CB_framework; $row = new cbgalleryFolderTable(); $row->load( (int) $id ); $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); $canAccess = false; if ( ! $row->get( 'id' ) ) { if ( ( $user->get( 'id' ) != $viewer->get( 'id' ) ) && ( ! $cbModerator ) ) { $user = $viewer; } $canAccess = cbgalleryClass::canUserCreate( $viewer, $type, true ); } elseif ( ( $row->get( 'type' ) == $type ) && ( $cbModerator || ( $viewer->get( 'id' ) == $row->get( 'user_id' ) ) ) ) { $canAccess = true; } if ( $this->input( 'folder', false, GetterInterface::BOOLEAN ) ) { $returnUrl = $_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ); } else { $returnUrl = $_CB_framework->userProfileUrl( (int) $row->get( 'user_id', $user->get( 'id' ) ), false, $tab->get( 'tabid' ) ); } if ( ! $canAccess ) { cbRedirect( $returnUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } switch( $type ) { case 'photos': case 'videos': case 'music': $typeTranslated = CBTxt::T( 'Album' ); break; default: $typeTranslated = CBTxt::T( 'Folder' ); break; } cbgalleryClass::getTemplate( 'folder_edit' ); $input = array(); $publishedTooltip = cbTooltip( null, CBTxt::T( 'FOLDER_PUBLISHED_DESCRIPTION', 'Select publish status of the [type]. If unpublished the [type] will not be visible to the public.', array( '[type]' => $typeTranslated ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['published'] = moscomprofilerHTML::yesnoSelectList( 'published', 'class="form-control"' . ( $publishedTooltip ? ' ' . $publishedTooltip : null ), (int) $this->input( 'post/published', $row->get( 'published', 1 ), GetterInterface::INT ) ); $titleTooltip = cbTooltip( null, CBTxt::T( 'FOLDER_TITLE_DESCRIPTION', 'Optionally input a title. If no title is provided the date will be displayed as the title.', array( '[type]' => $typeTranslated ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['title'] = '<input type="title" id="title" name="title" value="' . htmlspecialchars( $this->input( 'post/title', $row->get( 'title' ), GetterInterface::STRING ) ) . '" class="form-control" size="25"' . ( $titleTooltip ? ' ' . $titleTooltip : null ) . ' />'; $descriptionTooltip = cbTooltip( null, CBTxt::T( 'FOLDER_DESCRIPTION_DESCRIPTION', 'Optionally input a description.', array( '[type]' => $typeTranslated ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['description'] = '<textarea id="description" name="description" class="form-control" cols="40" rows="5"' . ( $descriptionTooltip ? ' ' . $descriptionTooltip : null ) . '>' . htmlspecialchars( $this->input( 'post/description', $row->get( 'description' ), GetterInterface::STRING ) ) . '</textarea>'; $ownerTooltip = cbTooltip( null, CBTxt::T( 'FOLDER_OWNER_DESCRIPTION', 'Input owner as single integer user_id.', array( '[type]' => $typeTranslated ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['user_id'] = '<input type="text" id="user_id" name="user_id" value="' . (int) $this->input( 'post/user_id', $row->get( 'user_id', $user->get( 'id' ) ), GetterInterface::INT ) . '" class="digits required form-control" size="6"' . ( $ownerTooltip ? ' ' . $ownerTooltip : null ) . ' />'; if ( $message ) { $_CB_framework->enqueueMessage( $message, $messageType ); } HTML_cbgalleryFolderEdit::showFolderEdit( $row, $input, $type, $tab, $user, $viewer, $this ); }