/**
	 * returns a cached photo object or adds existing photos to the cache
	 *
	 * @param int|PhotoTable[] $id
	 * @return PhotoTable|null
	 */
	static public function getPhoto( $id )
	{
		static $cache			=	array();

		if ( is_array( $id ) ) {
			foreach ( $id as $row ) {
				/** @var PhotoTable $row */
				$rowId			=	(int) $row->get( 'id' );

				if ( ! $rowId ) {
					continue;
				}

				$cache[$rowId]	=	$row;
			}

			return null;
		} elseif ( ! $id ) {
			return new PhotoTable();
		} elseif ( ! isset( $cache[$id] ) ) {
			$row				=	new PhotoTable();

			$row->load( (int) $id );

			$cache[$id]			=	$row;
		}

		return $cache[$id];
	}
示例#2
0
	/**
	 * render frontend event activity
	 *
	 * @param CB\Plugin\Activity\Table\ActivityTable $row
	 * @param string                                 $title
	 * @param string                                 $message
	 * @param CB\Plugin\Activity\Activity            $stream
	 * @param PhotoTable                             $photo
	 * @param cbgjPhotoPlugin                        $plugin
	 * @return string
	 */
	static function showPhotoActivity( $row, &$title, &$message, $stream, $photo, $plugin )
	{
		global $_CB_framework;

		$title				=	CBTxt::T( 'GROUP_PHOTO_ACTIVITY_TITLE', 'uploaded a photo in [group]', array( '[group]' => '<strong><a href="' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $photo->group()->get( 'id' ) ) ) . '">' . htmlspecialchars( CBTxt::T( $photo->group()->get( 'name' ) ) ) . '</a></strong>' ) );

		$name				=	( $photo->get( 'title' ) ? htmlspecialchars( $photo->get( 'title' ) ) : $photo->name() );
		$item				=	$name;
		$logo				=	null;

		if ( $photo->exists() ) {
			$showPath		=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'photo', 'func' => 'show', 'id' => (int) $photo->get( 'id' ) ), 'raw', 0, true );

			$image			=	'<div class="gjGroupPhotoImageContainer">'
							.		'<div style="background-image: url(' . $showPath . ')" class="gjGroupPhotoImage"></div>'
							.		'<div class="gjGroupPhotoImageInfo">'
							.			'<div class="gjGroupPhotoImageInfoRow">'
							.				'<div class="gjGroupPhotoImageInfoTitle col-sm-8 text-left"><strong>' . $name . '</strong></div>'
							.				'<div class="gjGroupPhotoImageInfoOriginal col-sm-4 text-right">'
							.					'<a href="' . $showPath . '" target="_blank">'
							.						CBTxt::T( 'Original' )
							.					'</a>'
							.				'</div>'
							.			'</div>';

			if ( $photo->get( 'description' ) ) {
				$image		.=			'<div class="gjGroupPhotoImageInfoRow">'
							.				'<div class="gjGroupPhotoImageInfoDescription col-sm-8 text-left">' . htmlspecialchars( $photo->get( 'description' ) ) . '</div>'
							.				'<div class="gjGroupPhotoImageInfoDownload col-sm-4 text-right">'
							.				'</div>'
							.			'</div>';
			}

			$image			.=		'</div>'
							.	'</div>';

			$item			=	cbTooltip( 1, $image, null, array( '80%', '80%' ), null, $item, 'javascript: void(0);', 'class="gjGroupPhotoItem" data-cbtooltip-modal="true" data-cbtooltip-open-solo="document" data-cbtooltip-classes="gjGroupPhotoImageModal"' );
			$logo			=	cbTooltip( 1, $image, null, array( '80%', '80%' ), null, '<img src="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'photo', 'func' => 'preview', 'id' => (int) $photo->get( 'id' ) ), 'raw', 0, true ) . '" class="gjGroupPhotoLogo" />', 'javascript: void(0);', 'class="gjGroupPhotoLogo" data-cbtooltip-modal="true" data-cbtooltip-open-solo="document" data-cbtooltip-classes="gjGroupPhotoImageModal"' );
		}

		$return				=	'<div class="gjPhotoActivity text-center">'
							.		'<div class="gjGroupPhotoRow gjContainerBox img-thumbnail">'
							.			'<div class="gjContainerBoxHeader">'
							.				'<div class="gjContainerBoxCanvas">'
							.					$logo
							.				'</div>'
							.			'</div>'
							.			'<div class="gjContainerBoxBody text-left border-default">'
							.				'<div class="gjContainerBoxTitle">'
							.					'<strong>'
							.						$item
							.					'</strong>'
							.				'</div>';

		if ( $photo->get( 'description' ) ) {
			$return			.=				'<div class="gjContainerBoxContent cbMoreLess">'
							.					'<div class="cbMoreLessContent">'
							.						htmlspecialchars( $photo->get( 'description' ) )
							.					'</div>'
							.					'<div class="cbMoreLessOpen fade-edge hidden">'
							.						'<a href="javascript: void(0);" class="cbMoreLessButton">' . CBTxt::T( 'See More' ) . '</a>'
							.					'</div>'
							.				'</div>';
		}

		$return				.=			'</div>'
							.		'</div>'
							.	'</div>';

		return $return;
	}
示例#3
0
	/**
	 * render frontend photo edit
	 *
	 * @param PhotoTable              $row
	 * @param array                   $input
	 * @param GroupTable              $group
	 * @param UserTable               $user
	 * @param CBplug_cbgroupjivephoto $plugin
	 * @return string
	 */
	static function showPhotoEdit( $row, $input, $group, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$pageTitle					=	( $row->get( 'id' ) ? CBTxt::T( 'Edit Photo' ) : CBTxt::T( 'New Photo' ) );

		$_CB_framework->setPageTitle( $pageTitle );

		cbValidator::loadValidation();
		initToolTip();

		$isModerator				=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$canModerate				=	( CBGroupJive::getGroupStatus( $user, $group ) >= 2 );
		$return						=	null;

		$_PLUGINS->trigger( 'gj_onBeforeDisplayPhotoEdit', array( &$return, &$row, &$input, $group, $user ) );

		$return						.=	'<div class="gjPhotoEdit">'
									.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'photo', 'func' => 'save', 'id' => (int) $row->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="gjPhotoEditForm" id="gjPhotoEditForm" class="cb_form gjPhotoEditForm form-auto cbValidation">'
									.			( $pageTitle ? '<div class="gjPhotoEditTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null );

		if ( $isModerator || $canModerate || ( $row->get( 'id' ) && ( $row->get( 'published' ) != -1 ) ) || ( $group->params()->get( 'photo', 1 ) != 2 ) ) {
			$return					.=			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="published" class="col-sm-3 control-label">' . CBTxt::T( 'Published' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['published']
									.					getFieldIcons( null, 0, null, CBTxt::T( 'Select publish state of this photo. Unpublished photos will not be visible to the public.' ) )
									.				'</div>'
									.			'</div>';
		}

		$return						.=			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
									.				'<label for="title" class="col-sm-3 control-label">' . CBTxt::T( 'Title' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['title']
									.					getFieldIcons( null, 0, null, CBTxt::T( 'Optionally input a photo title to display instead of filename.' ) )
									.				'</div>'
									.			'</div>';

		if ( $row->get( 'id' ) && $row->exists() ) {
			$return					.=			'<div class="cbft_delimiter form-group cb_form_line clearfix">'
									.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
									.					'<a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'photo', 'func' => 'download', 'id' => (int) $row->get( 'id' ) ), 'raw', 0, true ) . '" target="_blank">'
									.						$row->name()
									.					'</a>'
									.					' (' . $row->size() . ')'
									.				'</div>'
									.			'</div>'
									.			'<div class="cbft_delimiter form-group cb_form_line clearfix">'
									.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
									.					'<img src="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'photo', 'func' => 'preview', 'id' => (int) $row->get( 'id' ) ), 'raw', 0, true ) . '" class="gjPhotoPreview img-responsive" />'
									.				'</div>'
									.			'</div>';
		}

		$return						.=			'<div class="cbft_file cbtt_input form-group cb_form_line clearfix">'
									.				'<label for="image" class="col-sm-3 control-label">' . CBTxt::T( 'Photo' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['image']
									.					getFieldIcons( null, ( ! $row->get( 'id' ) ? 1 : 0 ), null, CBTxt::T( 'Select the photo to upload.' ) )
									.					( $input['image_limits'] ? '<div class="help-block">' . implode( ' ', $input['image_limits'] ) . '</div>' : null )
									.				'</div>'
									.			'</div>'
									.			'<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">'
									.				'<label for="description" class="col-sm-3 control-label">' . CBTxt::T( 'Description' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['description']
									.					getFieldIcons( null, 0, null, CBTxt::T( 'Optionally input a photo description.' ) )
									.				'</div>'
									.			'</div>';

		if ( $isModerator ) {
			$return					.=			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
									.				'<label for="user_id" class="col-sm-3 control-label">' . CBTxt::T( 'Owner' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['user_id']
									.					getFieldIcons( null, 1, null, CBTxt::T( 'Input the photo owner id. Photo owner determines the creator of the photo specified as User ID.' ) )
									.				'</div>'
									.			'</div>';
		}

		if ( ( ! $isModerator ) && $plugin->params->get( 'groups_photo_captcha', 0 ) ) {
			$_PLUGINS->loadPluginGroup( 'user' );

			$captcha				=	$_PLUGINS->trigger( 'onGetCaptchaHtmlElements', array( false ) );

			if ( ! empty( $captcha ) ) {
				$captcha			=	$captcha[0];

				$return				.=			'<div class="form-group cb_form_line clearfix">'
									.				'<label class="col-sm-3 control-label">' . CBTxt::T( 'Captcha' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					( isset( $captcha[0] ) ? $captcha[0] : null )
									.				'</div>'
									.			'</div>'
									.			'<div class="form-group cb_form_line clearfix">'
									.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
									.					str_replace( 'inputbox', 'form-control', ( isset( $captcha[1] ) ? $captcha[1] : null ) )
									.					getFieldIcons( null, 1, null )
									.				'</div>'
									.			'</div>';
			}
		}

		$return						.=			'<div class="form-group cb_form_line clearfix cbtwolines">'
									.				'<div class="col-sm-offset-3 col-sm-9">'
									.					'<input type="submit" value="' . htmlspecialchars( ( $row->get( 'id' ) ? CBTxt::T( 'Update Photo' ) : CBTxt::T( 'Upload Photo' ) ) ) . '" class="gjButton gjButtonSubmit btn btn-primary" ' . cbValidator::getSubmitBtnHtmlAttributes() . ' />'
									.					' <input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="gjButton gjButtonCancel btn btn-default" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '\'; })" />'
									.				'</div>'
									.			'</div>'
									.			( ! $row->get( 'id' ) ? '<input type="hidden" id="group" name="group" value="' . (int) $group->get( 'id' ) . '" />' : null )
									.			cbGetSpoofInputTag( 'plugin' )
									.		'</form>'
									.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayPhotoEdit', array( &$return, $row, $input, $group, $user ) );

		$_CB_framework->setMenuMeta();

		echo $return;
	}