Пример #1
0
	public function popupViewAction()
	{
		$video_id = $this -> _getParam('video_id');
		$video = Engine_Api::_() -> getItem('video', $video_id);
		if ($video)
		{
			Engine_Api::_() -> core() -> setSubject($video);
		}
		if (!$this -> _helper -> requireSubject() -> isValid())
		{
			return;
		}
		$type = $video -> getType();

		$video = Engine_Api::_() -> core() -> getSubject('video');
		$viewer = Engine_Api::_() -> user() -> getViewer();

		//Get Photo Url
		$photoUrl = $video -> getPhotoUrl('thumb.normal');
		$pos = strpos($photoUrl, "http");
		if ($pos === false)
		{
			$photoUrl = rtrim((constant('_ENGINE_SSL') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'], '/') . $photoUrl;
		}

		//Get Video Url
		$videoUrl = $video -> getHref();
		$pos = strpos($videoUrl, "http");
		if ($pos === false)
		{
			$videoUrl = rtrim((constant('_ENGINE_SSL') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'], '/') . $videoUrl;
		}

		$watchLaterTbl = Engine_Api::_() -> getDbTable('watchlaters', 'ynvideo');
		$watchLaterTbl -> update(array(
			'watched' => '1',
			'watched_date' => date('Y-m-d H:i:s')
		), array(
			"video_id = {$video->getIdentity()}",
			"user_id = {$viewer->getIdentity()}"
		));

		// Check if edit/delete is allowed
		$this -> view -> can_edit = $can_edit = $this -> _helper -> requireAuth() -> setAuthParams($video, null, 'edit') -> checkRequire();
		$this -> view -> can_delete = $can_delete = $this -> _helper -> requireAuth() -> setAuthParams($video, null, 'delete') -> checkRequire();
		$embedded = "";
		// increment count
		if ($video -> status == 1)
		{
			if (!$video -> isOwner($viewer))
			{
				$video -> view_count++;
				$video -> save();
				Engine_Api::_()->getDbTable('views', 'ynvideo')->addView($video);
			}
            $embedded = $video -> getRichContent(true);
		}

		if ($video -> type == Ynvideo_Plugin_Factory::getUploadedType() && $video -> status == 1)
		{
			$session = new Zend_Session_Namespace('mobile');
			$responsive_mobile = FALSE;
			if (defined('YNRESPONSIVE'))
			{
				$responsive_mobile = Engine_Api::_()-> ynresponsive1() -> isMobile();
			}
			if (!empty($video -> file1_id))
			{
				$storage_file = Engine_Api::_() -> getItem('storage_file', $video -> file_id);
				if ($session -> mobile || $responsive_mobile)
				{
					$storage_file = Engine_Api::_() -> getItem('storage_file', $video -> file1_id);
				}
				if ($storage_file)
				{
					$this -> view -> video_location1 = $storage_file -> map();
					$this -> view -> video_location = '';
				}
			}
			else 
			{
				$storage_file = Engine_Api::_() -> getItem('storage_file', $video -> file_id);
				if ($storage_file)
				{
					$this -> view -> video_location = $storage_file -> map();
					$this -> view -> video_location1 = '';
				}
			}
		}
		else
		if ($video -> type == Ynvideo_Plugin_Factory::getVideoURLType())
		{
			$this -> view -> video_location = $video -> code;
		}

		$settings = Engine_Api::_() -> getApi('settings', 'core');
		$this -> view -> numberOfEmail = $settings -> getSetting('ynvideo.friend.emails', 5);
		$this -> view -> viewer_id = $viewer -> getIdentity();
		$this -> view -> rating_count = Engine_Api::_() -> ynvideo() -> ratingCount($video -> getIdentity());
		$this -> view -> video = $video;
		$this -> view -> rated = Engine_Api::_() -> ynvideo() -> checkRated($video -> getIdentity(), $viewer -> getIdentity());
		$this -> view -> videoEmbedded = $embedded;
	}
Пример #2
0
	public function getRichContent($view = false, $params = array())
	{
		$session = new Zend_Session_Namespace('mobile');
		$mobile = $session -> mobile;
		$count_video = 0;
		if (isset($session -> count))
			$count_video = ++$session -> count;
		$paramsForCompile = array_merge(array(
			'video_id' => $this -> video_id,
			'code' => $this -> code,
			'view' => $view,
			'mobile' => $mobile,
			'duration' => $this -> duration,
			'count_video' => $count_video
		), $params);
		if ($this -> type == Ynvideo_Plugin_Factory::getUploadedType())
		{
			$responsive_mobile = FALSE;
			if (defined('YNRESPONSIVE'))
			{
				$responsive_mobile = Engine_Api::_() -> ynresponsive1() -> isMobile();
			}
			if (!empty($this -> file1_id))
			{
				$storage_file = Engine_Api::_() -> getItem('storage_file', $this -> file_id);
				if ($session -> mobile || $responsive_mobile)
				{
					$storage_file = Engine_Api::_() -> getItem('storage_file', $this -> file1_id);
				}
				if ($storage_file)
				{
					$paramsForCompile['location1'] = $storage_file -> getHref();
					$paramsForCompile['location'] = '';
				}
			}
			else 
			{
				$storage_file = Engine_Api::_() -> getItem('storage_file', $this -> file_id);
				if ($storage_file)
				{
					$paramsForCompile['location'] = $storage_file -> getHref();
					$paramsForCompile['location1'] = '';
				}
			}
		}
		else
		if ($this -> type == Ynvideo_Plugin_Factory::getVideoURLType())
		{
			$paramsForCompile['location'] = $this -> code;
		}
        $videoEmbedded = Ynvideo_Plugin_Factory::getPlugin((int)$this -> type) -> compileVideo($paramsForCompile);

		// $view == false means that this rich content is requested from the activity feed
		if ($view == false)
		{
			$video_duration = "";
			if ($this -> duration)
			{
				if ($this -> duration >= 3600)
				{
					$duration = gmdate("H:i:s", $this -> duration);
				}
				else
				{
					$duration = gmdate("i:s", $this -> duration);
				}
				$video_duration = "<span class='video_length'>" . $duration . "</span>";
			}

			// prepare the thumbnail
			$thumb = Zend_Registry::get('Zend_View') -> itemPhoto($this, 'thumb.large');
			if ($this -> photo_id)
			{
				$thumb = Zend_Registry::get('Zend_View') -> itemPhoto($this, 'thumb.large');
			}
			else
			{
				$thumb = '<img alt="" src="' . Zend_Registry::get('StaticBaseUrl') . 'application/modules/Video/externals/images/video.png">';
			}

			if (!$mobile)
			{
				$thumb = '<a id="video_thumb_' . $this -> video_id . $count_video . '" style="" href="javascript:void(0);" onclick="javascript:var myElement = $(this);myElement.style.display=\'none\';var next = myElement.getNext(); next.style.display=\'block\';">
                  <div class="video_thumb_wrapper">' . $video_duration . $thumb . '</div>
                  </a>';
			}
			else
			{
				$thumb = '<a id="video_thumb_' . $this -> video_id . $count_video . '" class="video_thumb" href="javascript:void(0);">
                  <div class="video_thumb_wrapper">' . $video_duration . $thumb . '</div>
                  </a>';
			}

			// prepare title and description
			$title = "<a class='smoothbox' href='" . $this -> getPopupHref($params) . "'>". $this-> getTitle()."</a>";
			$tmpBody = strip_tags($this -> description);
			$description = "<div class='video_desc'>" . (Engine_String::strlen($tmpBody) > 255 ? Engine_String::substr($tmpBody, 0, 255) . '...' : $tmpBody) . "</div>";

			$class_html5 = "";
			if ($this -> type == Ynvideo_Plugin_Factory::getVideoURLType() || $this -> type == Ynvideo_Plugin_Factory::getUploadedType())
			{
				$class_html5 = 'html5_player';
			}
			$totalLike = Engine_Api::_() -> getDbtable('likes', 'yncomment') -> likes($this) -> getLikeCount();
          	$totalDislike = Engine_Api::_() -> getDbtable('dislikes', 'yncomment') -> getDislikeCount($this);
			
			$videoEmbedded = '<div class="video_info">' .$title . $description . '</div>'.$thumb . '<div id="video_object_' . $this -> video_id . '" class="video_object ' . $class_html5 . '">' . $videoEmbedded . '</div>';
			
			$view = Zend_Registry::get('Zend_View');  
			$videoEmbedded .= '<div class="tfvideo_statistics">
          	<span>'. $view->translate(array('%s like', '%s likes', $totalLike), $totalLike). '</span>
          	<span>'. $view->translate(array('%s dislike', '%s dislikes', $totalDislike), $totalDislike). '</span>
          	<span>'. $view->translate(array('%s comment', '%s comments', $this -> comment_count), $this -> comment_count).'</span>
      		</div>';
		}

		return $videoEmbedded;
	}