Пример #1
0
 public function getDescription()
 {
     // strip HTML and BBcode
     $content = strip_tags($this->body);
     $content = preg_replace('|[[\\/\\!]*?[^\\[\\]]*?]|si', '', $content);
     return Engine_String::strlen($content) > 255 ? Engine_String::substr($content, 0, 255) . '...' : $content;
 }
Пример #2
0
 public function getDescription()
 {
     $firstPost = $this->getFirstPost();
     $content = '';
     if (null !== $firstPost) {
         $content = $firstPost->body;
         // strip HTML and BBcode
         $content = strip_tags($content);
         $content = preg_replace('|[[\\/\\!]*?[^\\[\\]]*?]|si', '', $content);
         $content = Engine_String::strlen($content) > 255 ? Engine_String::substr($content, 0, 255) . '...' : $content;
     }
     return $content;
 }
Пример #3
0
 public function getRichContent($view = false, $params = array())
 {
     // if video type is youtube
     if ($this->type == 1) {
         $videoEmbedded = $this->compileYouTube($this->code, $view);
     }
     // if video type is vimeo
     if ($this->type == 2) {
         $videoEmbedded = $this->compileVimeo($this->code, $view);
     }
     // if video type is uploaded
     if ($this->type == 3) {
         $video_location = Engine_Api::_()->storage()->get($this->file_id, $this->getType())->getHref();
         $videoEmbedded = $this->compileFlowPlayer($video_location, $view);
     }
     // $view == false means that this rich content is requested from the activity feed
     if ($view == false) {
         // prepare the duration
         //
         $video_duration = "";
         if ($this->duration) {
             if ($this->duration > 360) {
                 $duration = gmdate("H:i:s", $this->duration);
             } else {
                 $duration = gmdate("i:s", $this->duration);
             }
             if ($duration[0] == '0') {
                 $duration = substr($duration, 1);
             }
             $video_duration = "<span class='video_length'>" . $duration . "</span>";
         }
         // prepare the thumbnaile
         $thumb = Zend_Registry::get('Zend_View')->itemPhoto($this, 'thumb.video.activity');
         if ($this->photo_id) {
             $thumb = Zend_Registry::get('Zend_View')->itemPhoto($this, 'thumb.video.activity');
         } else {
             $thumb = '<img alt="" src="application/modules/Video/externals/images/video.png">';
         }
         $thumb = '<a id="video_thumb_' . $this->video_id . '" 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>';
         // prepare title and description
         $title = "<a href='" . $this->getHref($params) . "'>{$this->title}</a>";
         $tmpBody = strip_tags($this->description);
         $description = "<div class='video_desc'>" . (Engine_String::strlen($tmpBody) > 255 ? Engine_String::substr($tmpBody, 0, 255) . '...' : $tmpBody) . "</div>";
         $videoEmbedded = $thumb . '<div id="video_object_' . $this->video_id . '" style="display:none;">' . $videoEmbedded . '</div><div class="video_info">' . $title . $description . '</div>';
     }
     return $videoEmbedded;
 }
Пример #4
0
 public function getRichContent($view = false, $params = array())
 {
     $playlist = $this->getParent();
     $videoEmbedded = '';
     // $view == false means that this rich content is requested from the activity feed
     if ($view == false) {
         $desc = strip_tags($playlist->description);
         $desc = "<div class='music_desc'>" . (Engine_String::strlen($desc) > 255 ? Engine_String::substr($desc, 0, 255) . '...' : $desc) . "</div>";
         $zview = Zend_Registry::get('Zend_View');
         $zview->playlist = $playlist;
         $zview->songs = array($this);
         $zview->short_player = true;
         $videoEmbedded = $desc . $zview->render('application/modules/Music/views/scripts/_Player.tpl');
     }
     return $videoEmbedded;
 }
Пример #5
0
 public function getRichContent($view = false, $params = array())
 {
     $videoEmbedded = '';
     // $view == false means that this rich content is requested from the activity feed
     if ($view == false) {
         $desc = strip_tags($this->description);
         $desc = "<div class='music_desc'>" . (Engine_String::strlen($desc) > 255 ? Engine_String::substr($desc, 0, 255) . '...' : $desc) . "</div>";
         $zview = Zend_Registry::get('Zend_View');
         $zview->playlist = $this;
         $zview->songs = $this->getSongs();
         $zview->short_player = true;
         $videoEmbedded = $desc . $zview->render('application/modules/Music/views/scripts/_Player.tpl');
     }
     // hide playlist if in production mode
     if (!count($zview->songs) && 'production' == APPLICATION_ENV) {
         throw new Exception('Empty playlists show not be shown');
     }
     return $videoEmbedded;
 }
Пример #6
0
 public function viewMore($string, $moreLength = null, $maxLength = null)
 {
     if (!is_numeric($moreLength) || $moreLength <= 0) {
         $moreLength = $this->_moreLength;
     }
     if (!is_numeric($maxLength) || $maxLength <= 0) {
         $maxLength = $this->_maxLength;
     }
     if (Engine_String::strlen($string) <= $moreLength + $this->_fudgesicles) {
         return $string;
     }
     if (Engine_String::strlen($string) >= $maxLength) {
         $string = Engine_String::substr($string, 0, $maxLength) . $this->view->translate('... &nbsp;');
     }
     //$id = $this->_prefix . '_' . self::$_index++;
     //$class = $this->_prefix;
     $content = '';
     $content .= '<' . $this->_tag . ' class="view_more"' . '>' . Engine_String::substr($string, 0, $moreLength) . $this->view->translate('... &nbsp;') . '<a class="view_more_link" href="javascript:void(0);" onclick="$(this).getParent().getNext().style.display=\'\';$(this).getParent().style.display=\'none\';">' . $this->view->translate('more') . '</a>' . '</' . $this->_tag . '>' . '<' . $this->_tag . ' class="view_more"' . ' style="display:none;"' . '>' . $string . ' &nbsp;' . '<a class="view_less_link" href="javascript:void(0);" onclick="$(this).getParent().getPrevious().style.display=\'\';$(this).getParent().style.display=\'none\';">' . $this->view->translate('less') . '</a>' . '</' . $this->_tag . '>';
     return $content;
 }
Пример #7
0
    public function viewMore($string, $moreLength = null, $maxLength = null, $lessLength = null, $nl2br = true)
    {
        if (!is_numeric($moreLength) || $moreLength <= 0) {
            $moreLength = $this->_moreLength;
        }
        if (!is_numeric($maxLength) || $maxLength <= 0) {
            $maxLength = $this->_maxLength;
        }
        if (!is_numeric($lessLength) || $lessLength <= 0) {
            $lessLength = $this->_lessLength;
        }
        // If using line breaks, ensure that there are not too many line breaks
        if ($nl2br) {
            $string = trim(preg_replace('/(\\r\\n|\\n\\r|\\r|\\n)/', "\n", $string));
            if (($c = substr_count($string, "\n")) > $this->_maxLineBreaks) {
                $pos = 0;
                for ($i = 0; $i < $this->_maxLineBreaks; $i++) {
                    $pos = strpos($string, "\n", $pos + 1);
                }
                if ($pos <= 0 || !is_int($pos)) {
                    $pos = null;
                }
                if ($pos && $pos < $moreLength) {
                    $moreLength = $pos;
                }
            }
        }
        // If length is less than max len, just return
        $strLen = Engine_String::strlen($string);
        if ($strLen <= $moreLength + $this->_fudgesicles) {
            if ($nl2br) {
                return nl2br($string);
            } else {
                return $string;
            }
        }
        // Otherwise truncate
        if ($strLen >= $maxLength) {
            $strLen = $maxLength;
            $string = Engine_String::substr($string, 0, $maxLength) . $this->view->translate('... &nbsp;');
        }
        $shortText = Engine_String::substr($string, 0, $moreLength);
        $fullText = $string;
        // Do nl2br
        if ($nl2br) {
            $shortText = nl2br($shortText);
            $fullText = nl2br($fullText);
        }
        $onclick = <<<EOF
var me = \$(this).getParent(), other = \$(this).getParent().getNext(), fn = function() {
  me.style.display = 'none';
  other.style.display = '';
};
fn();
setTimeout(fn, 0);
EOF;
        $content = '<' . $this->_tag . ' class="view_more"' . '>' . $shortText . $this->view->translate('... &nbsp;') . '<a class="view_more_link" href="javascript:void(0);" onclick="' . htmlspecialchars($onclick) . '">' . $this->view->translate('more') . '</a>' . '</' . $this->_tag . '>' . '<' . $this->_tag . ' class="view_more"' . ' style="display:none;"' . '>' . $fullText . ' &nbsp;';
        if ($strLen >= $lessLength) {
            $onclick = <<<EOF
var me = \$(this).getParent(), other = \$(this).getParent().getPrevious(), fn = function() {
  me.style.display = 'none';
  other.style.display = '';
};
fn();
setTimeout(fn, 0);
EOF;
            $content .= '<a class="view_less_link" href="javascript:void(0);" onclick="' . htmlspecialchars($onclick) . '">' . $this->view->translate('less') . '</a>';
        }
        $content .= '</' . $this->_tag . '>';
        return $content;
    }
Пример #8
0
 public function getDescription()
 {
     // @todo decide how we want to handle multibyte string functions
     $tmpBody = strip_tags($this->description);
     return Engine_String::strlen($tmpBody) > 255 ? Engine_String::substr($tmpBody, 0, 255) . '...' : $tmpBody;
 }
Пример #9
0
 public function truncate($string, $length = 300, $chopString = null)
 {
     if (Engine_String::strlen($string) <= $length) {
         return $string;
     }
     if (null === $chopString) {
         $chopString = '...';
     }
     $chopString = $this->view->translate($chopString);
     return Engine_String::substr($string, 0, $length) . $chopString;
 }
Пример #10
0
 protected function _insertSearch($resourceType, $resourceId, $searchData = array())
 {
     $defaultData = array('type' => $resourceType, 'id' => $resourceId, 'title' => '', 'description' => '', 'keywords' => '', 'hidden' => '');
     $searchData = array_merge($defaultData, array_filter($searchData));
     if ($searchData['description']) {
         $description = strip_tags($searchData['description']);
         $searchData['description'] = Engine_String::strlen($description) > 255 ? Engine_String::substr($description, 0, 252) . '...' : $description;
     }
     try {
         $this->getToDb()->insert('engine4_core_search', $searchData);
     } catch (Exception $e) {
         // ignore exception
     }
 }
Пример #11
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;
	}
Пример #12
0
 public function whisperAction()
 {
     $userTable = Engine_Api::_()->getDbtable('users', 'chat');
     // Check viewer
     $viewer = Engine_Api::_()->user()->getViewer();
     if (!$viewer->getIdentity()) {
         $this->view->status = false;
         $this->view->error = true;
         $this->view->message = 'AUTH_FAIL';
         return;
     }
     // Check for chat user
     $userTable->check($viewer);
     // Check for target user
     $targetUserId = (int) $this->_getParam('user_id');
     $targetUser = $userTable->find($targetUserId)->current();
     if (null === $targetUser) {
         $this->view->status = false;
         $this->view->error = true;
         $this->view->message = 'NOT_ONLINE';
         return;
     }
     // Rate limiting
     $session = $this->getSession();
     // Clear out old
     if (!isset($session->whisperRate) || !is_array($session->whisperRate)) {
         $session->whisperRate = array();
     }
     foreach ($session->whisperRate as $index => $time) {
         if (time() > $time + 5) {
             unset($session->whisperRate[$index]);
         }
     }
     // Check count
     $rate = count($session->whisperRate);
     if ($rate > 10) {
         $this->view->status = false;
         $this->view->error = true;
         $this->view->message = 'RATE_LIMIT_EXCEEDED';
         return;
     }
     // Do it!
     $censor = new Engine_Filter_Censor();
     $message = $censor->filter($this->_getParam('message'));
     $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
     $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
     $message = htmlspecialchars($message, ENT_NOQUOTES, 'UTF-8');
     if (Engine_String::strlen($message) > 1023) {
         $message = Engine_String::substr($message, 0, 1023);
     }
     // Start transaction
     $db = $userTable->getAdapter();
     $db->beginTransaction();
     try {
         // Send message
         $whisperObject = $targetUser->whisper($viewer, $message);
         $session->whisperRate[] = time();
         $db->commit();
         $this->view->status = true;
         $this->view->error = false;
         $this->view->whisper_id = $whisperObject->whisper_id;
     } catch (Exception $e) {
         $db->rollBack();
         $this->view->status = false;
         $this->view->error = true;
         $this->view->message = 'ERROR';
         if (APPLICATION_ENV === 'development') {
             $this->view->error_message = $e->__toString();
         }
     }
 }