Ejemplo n.º 1
0
	/**
	 * Replaces :EMOTE: with emote icons
	 *
	 * @return string
	 */
	public function emotes()
	{
		$this->parsed	=	strtr( $this->parsed, CBActivity::loadEmoteOptions( true ) );

		return $this->parsed;
	}
Ejemplo n.º 2
0
	/**
	 * @param ActivityTable   $row
	 * @param Activity        $stream
	 * @param int             $output 0: Normal, 1: Raw, 2: Inline, 3: Load, 4: Save
	 * @param UserTable       $user
	 * @param UserTable       $viewer
	 * @param cbPluginHandler $plugin
	 * @return null|string
	 */
	static public function showEdit( $row, $stream, $output, $user, $viewer, $plugin )
	{
		global $_PLUGINS;

		$cbModerator				=	CBActivity::isModerator( (int) $viewer->get( 'id' ) );
		$messageLimit				=	( $cbModerator ? 0 : (int) $stream->get( 'message_limit', 400 ) );
		$showActions				=	(int) $stream->get( 'actions', 1 );
		$actionLimit				=	( $cbModerator ? 0 : (int) $stream->get( 'actions_message_limit', 100 ) );
		$showLocations				=	(int) $stream->get( 'locations', 1 );
		$locationLimit				=	( $cbModerator ? 0 : (int) $stream->get( 'locations_address_limit', 200 ) );
		$showLinks					=	(int) $stream->get( 'links', 1 );
		$linkLimit					=	( $cbModerator ? 0 : (int) $stream->get( 'links_link_limit', 5 ) );
		$showTags					=	(int) $stream->get( 'tags', 1 );

		$actionTooltip				=	cbTooltip( null, CBTxt::T( 'What are you doing or feeling?' ), null, 'auto', null, null, null, 'data-hascbtooltip="true" data-cbtooltip-position-my="bottom center" data-cbtooltip-position-at="top center" data-cbtooltip-classes="qtip-simple"' );
		$locationTooltip			=	cbTooltip( null, CBTxt::T( 'Share your location.' ), null, 'auto', null, null, null, 'data-hascbtooltip="true" data-cbtooltip-position-my="bottom center" data-cbtooltip-position-at="top center" data-cbtooltip-classes="qtip-simple"' );
		$tagTooltip					=	cbTooltip( null, CBTxt::T( 'Are you with anyone?' ), null, 'auto', null, null, null, 'data-hascbtooltip="true" data-cbtooltip-position-my="bottom center" data-cbtooltip-position-at="top center" data-cbtooltip-classes="qtip-simple"' );
		$linkTooltip				=	cbTooltip( null, CBTxt::T( 'Have a link to share?' ), null, 'auto', null, null, null, 'data-hascbtooltip="true" data-cbtooltip-position-my="bottom center" data-cbtooltip-position-at="top center" data-cbtooltip-classes="qtip-simple"' );
		$actionOptions				=	( $showActions ? CBActivity::loadActionOptions() : array() );
		$locationOptions			=	( $showLocations ? CBActivity::loadLocationOptions() : array() );

		$rowId						=	$stream->id() . '_edit_' . (int) $row->get( 'id' );
		$actionId					=	null;
		$locationId					=	null;
		$tags						=	array();
		$links						=	array();

		$editBody					=	null;
		$editFooter					=	null;

		$_PLUGINS->trigger( 'activity_onDisplayActivityEdit', array( &$row, &$editBody, &$editFooter, $stream, $output ) );

		$return						=	'<div class="streamItemEdit activityContainerContentEdit border-default hidden">'
									.		'<form action="' . $stream->endpoint( 'save', array( 'id' => (int) $row->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="' . $rowId . 'Form" id="' . $rowId . 'Form" class="cb_form streamItemForm form">'
									.			'<textarea id="' . $stream->id() . '_message_edit_' . (int) $row->get( 'id' ) . '" name="message" rows="3" class="streamInput streamInputAutosize streamInputMessage form-control no-border" placeholder="' . htmlspecialchars( CBTxt::T( "What's on your mind?" ) ) . '" data-cbactivity-input-size="3"' . ( $messageLimit ? ' data-cbactivity-input-limit="' . (int) $messageLimit . '" maxlength="' . (int) $messageLimit . '"' : null ) . '>' . htmlspecialchars( $row->get( 'message' ) ) . '</textarea>';

		if ( $showLinks ) {
			$links					=	$row->attachments();

			if ( $links ) {
				$return				.=			'<div class="streamPanelBody streamItemInputGroup streamInputAttachmentsContainer panel-body border-default clearfix">'
									.				self::showAttachments( $row, $stream, $output, $user, $viewer, $plugin )
									.			'</div>';
			}

			if ( ( ! $linkLimit ) || ( $linkLimit > 1 ) ) {
				$return				.=			'<div class="streamItemInputGroup streamInputLinkContainer cbRepeat border-default clearfix' . ( ! $links ? ' hidden' : null ) . '" data-cbrepeat-sortable="false"' . ( $linkLimit ? ' data-cbrepeat-max="' . (int) $linkLimit . '"' : null ) . '>';

				if ( $links ) {
					foreach ( $links as $i => $link ) {
						$return		.=				'<div class="streamItemInputGroupRow cbRepeatRow border-default">'
									.					'<span class="streamItemInputGroupLabel form-control">'
									.						'<button type="button" class="cbRepeatRowAdd btn btn-xs btn-success"><span class="fa fa-plus "></span></button>'
									.						'<button type="button" class="cbRepeatRowRemove btn btn-xs btn-danger"><span class="fa fa-minus"></span></button>'
									.					'</span>'
									.					'<div class="streamItemInputGroupInput border-default">'
									.						'<input type="text" id="' . $stream->id() . '_links__' . $i . '__url_edit_' . (int) $row->get( 'id' ) . '" name="links[' . $i . '][url]" value="' . htmlspecialchars( $link['url'] ) . '" class="streamInput streamInputLinkURL form-control no-border" placeholder="' . htmlspecialchars( CBTxt::T( "What link would you like to share?" ) ) . '" />'
									.					'</div>'
									.				'</div>';
					}
				} else {
					$return			.=				'<div class="streamItemInputGroupRow cbRepeatRow border-default">'
									.					'<span class="streamItemInputGroupLabel form-control">'
									.						'<button type="button" class="cbRepeatRowAdd btn btn-xs btn-success"><span class="fa fa-plus "></span></button>'
									.						'<button type="button" class="cbRepeatRowRemove btn btn-xs btn-danger"><span class="fa fa-minus"></span></button>'
									.					'</span>'
									.					'<div class="streamItemInputGroupInput border-default">'
									.						'<input type="text" id="' . $stream->id() . '_links__0__url_edit_' . (int) $row->get( 'id' ) . '" name="links[0][url]" class="streamInput streamInputLinkURL form-control no-border" placeholder="' . htmlspecialchars( CBTxt::T( "What link would you like to share?" ) ) . '" disabled="disabled" />'
									.					'</div>'
									.				'</div>';
				}

				$return				.=			'</div>';
			} else {
				$return				.=			'<div class="streamItemInputGroup streamInputLinkContainer border-default clearfix' . ( ! $links ? ' hidden' : null ) . '">'
									.				'<input type="text" id="' . $stream->id() . '_links__0__url_edit_' . (int) $row->get( 'id' ) . '" name="links[0][url]" value="' . htmlspecialchars( ( $links ? $links[0]['url'] : null ) ) . '" class="streamInput streamInputLinkURL form-control no-border" placeholder="' . htmlspecialchars( CBTxt::T( "What link would you like to share?" ) ) . '"' . ( ! $links ? ' disabled="disabled"' : null ) . ' />'
									.			'</div>';
			}
		}

		if ( $actionOptions ) {
			$action					=	$row->params()->subTree( 'action' );
			$actionId				=	(int) $action->get( 'id' );
			$emoteOptions			=	CBActivity::loadEmoteOptions();

			$return					.=			'<div class="streamItemInputGroup streamInputActionContainer border-default clearfix' . ( ! $actionId ? ' hidden' : null ) . '">'
									.				'<span class="streamItemInputGroupLabel streamInputSelectToggleLabel form-control"></span>'
									.				'<div class="streamItemInputGroupInput border-default">'
									.					'<input type="text" id="' . $stream->id() . '_actions_message_edit_' . (int) $row->get( 'id' ) . '" name="actions[message]" value="' . htmlspecialchars( $action->get( 'message' ) ) . '" class="streamInput streamInputActionMessage streamInputSelectTogglePlaceholder form-control no-border"' . ( $actionLimit ? ' maxlength="' . (int) $actionLimit . '"' : null ) . ( ! $actionId ? ' disabled="disabled"' : null ) . ' />'
									.					( $emoteOptions ? str_replace( 'action__emote', $stream->id() . '_actions_emote_edit_' . (int) $row->get( 'id' ), moscomprofilerHTML::selectList( $emoteOptions, 'actions[emote]', 'class="streamInputSelect streamInputEmote" data-cbselect-width="auto" data-cbselect-height="100%" data-cbselect-dropdown-css-class="streamEmoteOptions"' . ( ! $actionId ? ' disabled="disabled"' : null ), 'value', 'text', $action->get( 'emote' ), 0, false, false, false ) ) : null )
									.				'</div>'
									.			'</div>';
		}

		if ( $locationOptions ) {
			$location				=	$row->params()->subTree( 'location' );
			$locationId				=	(int) $location->get( 'id' );

			$return					.=			'<div class="streamItemInputGroup streamInputLocationContainer border-default clearfix' . ( ! $locationId ? ' hidden' : null ) . '">'
									.				'<span class="streamItemInputGroupLabel streamInputSelectToggleLabel form-control"></span>'
									.				'<div class="streamItemInputGroupInput border-default">'
									.					'<input type="text" id="' . $stream->id() . '_location_place_edit_' . (int) $row->get( 'id' ) . '" name="location[place]" value="' . htmlspecialchars( $location->get( 'place' ) ) . '" class="streamInput streamInputLocationPlace form-control no-border" placeholder="' . CBTxt::T( 'Where are you?' ) . '"' . ( $locationLimit ? ' maxlength="' . (int) $locationLimit . '"' : null ) . ( ! $locationId ? ' disabled="disabled"' : null ) . ' />'
									.					'<input type="text" id="' . $stream->id() . '_location_address_edit_' . (int) $row->get( 'id' ) . '" name="location[address]" value="' . htmlspecialchars( $location->get( 'address' ) ) . '" class="streamInput streamInputLocationAddress form-control no-border" placeholder="' . CBTxt::T( 'Have the address to share?' ) . '"' . ( $locationLimit ? ' maxlength="' . (int) $locationLimit . '"' : null ) . ( ! $locationId ? ' disabled="disabled"' : null ) . ' />'
							.							'<div class="streamFindLocation fa fa-map-marker fa-lg" data-cbactivity-location-target=".streamInputLocationAddress"></div>'
									.				'</div>'
									.			'</div>';
		}

		if ( $showTags ) {
			if ( $row->get( '_tags' ) ) {
				$tagsStream			=	$row->tags( $stream->source() );

				if ( $tagsStream ) {
					foreach ( $tagsStream->data() as $tag ) {
						/** @var TagTable $tag */
						$tags[]		=	(string) $tag->get( 'user' );
					}
				}
			}

			$tagOptions				=	CBActivity::loadTagOptions( (int) $row->get( 'id' ), (int) $row->get( 'user_id' ) );

			$return					.=			'<div class="streamItemInputGroup streamInputTagContainer border-default clearfix' . ( ! $tags ? ' hidden' : null ) . '">'
									.				str_replace( 'tags__', $stream->id() . '_tags_edit_' . (int) $row->get( 'id' ), moscomprofilerHTML::selectList( $tagOptions, 'tags[]', 'multiple="multiple" class="streamInputSelect streamInputTags form-control no-border" data-cbselect-placeholder="' . htmlspecialchars( CBTxt::T( 'Who are you with?' ) ) . '" data-cbselect-tags="true" data-cbselect-width="100%" data-cbselect-height="100%" data-cbselect-dropdown-css-class="streamTagsOptions"' . ( ! $tags ? ' disabled="disabled"' : null ), 'value', 'text', $tags, 0, true, false, false ) )
									.			'</div>';
		}

		$return						.=			$editBody
									.			'<div class="streamPanelFooter activityContainerFooter panel-footer">'
									.				'<div class="activityContainerFooterRow clearfix">'
									.					'<div class="activityContainerFooterRowLeft pull-left">'
									.						( $actionOptions ? str_replace( 'actions__id', $stream->id() . '_actions_id_edit_' . (int) $row->get( 'id' ), moscomprofilerHTML::selectList( $actionOptions, 'actions[id]', 'class="streamInputSelect streamInputSelectToggle streamInputAction btn btn-xs ' . ( $actionId ? 'btn-primary' : 'btn-default' ) . '" data-cbactivity-toggle-target=".streamInputActionContainer" data-cbactivity-toggle-active-classes="btn-primary" data-cbactivity-toggle-inactive-classes="btn-default" data-cbactivity-toggle-icon="fa fa-smile-o" data-cbselect-dropdown-css-class="streamSelectOptions"' . $actionTooltip, 'value', 'text', $actionId, 0, false, false, false ) ) : null )
									.						( $locationOptions ? ( $actionOptions ? ' ' : null ) . str_replace( 'location__id', $stream->id() . '_location_id_edit_' . (int) $row->get( 'id' ), moscomprofilerHTML::selectList( $locationOptions, 'location[id]', 'class="streamInputSelect streamInputSelectToggle streamInputLocation btn btn-xs ' . ( $locationId ? 'btn-primary' : 'btn-default' ) . '" data-cbactivity-toggle-target=".streamInputLocationContainer" data-cbactivity-toggle-active-classes="btn-primary" data-cbactivity-toggle-inactive-classes="btn-default" data-cbactivity-toggle-icon="fa fa-map-marker" data-cbselect-dropdown-css-class="streamSelectOptions"' . $locationTooltip, 'value', 'text', $locationId, 0, false, false, false ) ) : null )
									.						( $showTags ? ( $actionOptions || $locationOptions ? ' ' : null ) . '<button type="button" id="' . $stream->id() . '_tags_edit_' . (int) $row->get( 'id' ) . '" class="streamToggle streamInputTag btn btn-xs' . ( $tags ? ' btn-primary streamToggleOpen' : ' btn-default' ) . '" data-cbactivity-toggle-target=".streamInputTagContainer" data-cbactivity-toggle-active-classes="btn-primary" data-cbactivity-toggle-inactive-classes="btn-default"' . $tagTooltip . '><span class="fa fa-user"></span></button>' : null )
									.						( $showLinks ? ( $actionOptions || $locationOptions || $showTags ? ' ' : null ) . '<button type="button" id="' . $stream->id() . '_links_edit_' . (int) $row->get( 'id' ) . '" class="streamToggle streamInputLink btn btn-xs' . ( $links ? ' btn-primary streamToggleOpen' : ' btn-default' ) . '" data-cbactivity-toggle-target=".streamInputLinkContainer" data-cbactivity-toggle-active-classes="btn-primary" data-cbactivity-toggle-inactive-classes="btn-default"' . $linkTooltip . '><span class="fa fa-link"></span></button>' : null )
									.						$editFooter
									.					'</div>'
									.					'<div class="activityContainerFooterRowRight pull-right text-right">'
									.						'<button type="submit" class="activityButton activityButtonEditSave streamItemEditSave btn btn-primary btn-xs">' . CBTxt::T( 'Done Editing' ) . '</button>'
									.						' <button type="button" class="activityButton activityButtonEditCancel streamItemEditCancel btn btn-default btn-xs">' . CBTxt::T( 'Cancel' ) . '</button>'
									.					'</div>'
									.				'</div>'
									.			'</div>'
									.		'</form>'
									.	'</div>';

		return $return;
	}
Ejemplo n.º 3
0
	/**
	 * @return null|string
	 */
	public function action()
	{
		static $cache						=	array();

		$actions							=	CBActivity::loadActionOptions( true );
		$emotes								=	CBActivity::loadEmoteOptions( false, true );

		$id									=	$this->get( 'id' );

		if ( ! isset( $cache[$id] ) ) {
			$action							=	$this->params()->subTree( 'action' );
			$actionId						=	(int) $action->get( 'id', 0, GetterInterface::INT );
			$actionTitle					=	null;
			$actionMessage					=	null;
			$actionEmote					=	null;
			$return							=	null;

			if ( $actionId && isset( $actions[$actionId] ) ) {
				if ( $actions[$actionId]->get( 'published' ) ) {
					$actionTitle			=	( $actions[$actionId]->get( 'title' ) != '' ? trim( CBTxt::T( $actions[$actionId]->get( 'title' ) ) ) : null );

					$message				=	$action->get( 'message', null, GetterInterface::STRING );

					if ( $message != '' ) {
						$actionMessage		=	'<span class="activityActionMessage">' . trim( htmlspecialchars( $message ) ) . '</span>';
					}

					$emoteId				=	(int) $action->get( 'emote', 0, GetterInterface::INT );

					if ( $emoteId && isset( $emotes[$emoteId] ) && $emotes[$emoteId]->get( 'published' ) ) {
						$actionEmote		=	( $emotes[$emoteId]->icon() ? $emotes[$emoteId]->icon() : null );
					} else {
						$actionEmote		=	( $actions[$actionId]->icon() ? $actions[$actionId]->icon() : null );
					}
				}

				if ( $actionMessage ) {
					$return					=	trim( CBTxt::T( 'ACTIVITY_STATUS_ACTION', '[title] [message] [emote]', array( '[title]' => $actionTitle, '[message]' => $actionMessage, '[emote]' => $actionEmote ) ) );
				}
			}

			$cache[$id]						=	$return;
		}

		return $cache[$id];
	}