getData('type') == ListingsMediaService::TYPE_VIDEO) {
$video = $media->getData('value');
$videoId = 'video_' . $media->getData('id');
}
}
else if (is_array($media)) {
if ($media['type'] == ListingsMediaService::TYPE_VIDEO) {
$video = $media['value'];
$videoId = $media['id'];
}
}
else if (is_string($media)) {
$video = $media;
$videoId = 'video_' . md5(uniqid(time()));
}
$video = $this->_decode($video);
$video = $this->getView()->renderHtml($video);
if (strcmp(strip_tags($video), $video) === 0 && !preg_match('#^http(s)?://(.*)+$#i', $video)) {
$baseUrl = Front::getInstance()->getRequest()->getBaseUrl();
/** @var \Cube\View\Helper\Script $scriptHelper */
$scriptHelper = $this->getView()->getHelper('script');
$scriptHelper->addHeaderCode('')
->addBodyCode('');
$baseUrl = Front::getInstance()->getRequest()->getBaseUrl();
$video = $baseUrl . \Ppb\Utility::URI_DELIMITER
. \Ppb\Utility::getFolder('uploads') . \Ppb\Utility::URI_DELIMITER
. $video;
$player = '
';
}
else {
$player = $video;
}
return $player;
}
/**
*
* decode string if encoded
*
* @param $string
*
* @return bool|string
*/
protected function _decode($string)
{
$decoded = base64_decode($string);
return (base64_encode($decoded) === $string) ? $decoded : $string;
}
}