'message' => 'ERROR: Invalid URL format (http)',
'type' => 'checkURI',
'format' => array(
- 'allowed_schemes' => array('http'),
+ 'allowed_schemes' => array('http', 'https'),
'strict' => false
),
'validation' => $this->validationType,
*/
public function getVideoCode()
{
- $pattern = '/v=(.*)$/';
- $pattern2 = '/youtu.be\/(.*)/';
+ $youTubeUrl = 'http://www.youtube.com/embed/%s?rel=0&hd=1';
+ $pattern = '/v=(.*)$/';
+ $pattern2 = '/youtu.be\/(.*)/';
+ $pattern3 = ';vimeo.com/([0-9]*);';
+ $pattern3 = ';vimeo.com/([0-9]*);';
$vidUrl = $this->getVideo_url();
if (preg_match($pattern, $vidUrl, $match)) {
return $match[1];
} else if (preg_match($pattern2, $vidUrl, $match)) {
return $match[1];
+ } else if (preg_match($pattern3, $vidUrl, $match)) {
+ return $match[1];
} else {
return false;
}
}
+ public function getVideoUrl()
+ {
+ $youTubeUrl = 'http://www.youtube.com/embed/%s?rel=0&hd=1';
+ $vimeoUrl = 'https://player.vimeo.com/video/%d';
+ $pattern = '/v=(.*)$/';
+ $pattern2 = '/youtu.be\/(.*)/';
+ $pattern3 = ';vimeo.com/([0-9]*);';
+ $vidUrl = $this->getVideo_url();
+ if (preg_match($pattern, $vidUrl, $match)) {
+ return sprintf($youTubeUrl, $match[1]);
+ } else if (preg_match($pattern2, $vidUrl, $match)) {
+ return sprintf($youTubeUrl, $match[1]);
+ } else if (preg_match($pattern3, $vidUrl, $match)) {
+ return sprintf($vimeoUrl, $match[1]);
+ } else {
+ return false;
+ }
+ }
+
+
+ public function getVimeoThumbnail($videoId)
+ {
+ $url = "http://vimeo.com/api/v2/video/$videoId.php";
+ $ch = curl_init();
+ $curlOptions = array(
+ CURLOPT_URL => $url,
+ CURLOPT_HEADER => 0,
+ CURLOPT_RETURNTRANSFER => 1
+ );
+ curl_setopt_array($ch, $curlOptions);
+
+ $response = curl_exec($ch);
+ curl_close($ch);
+ $data = unserialize($response);
+ return ($data) ? $data[0] : false;
+ }
+
/**
* Using the youtube API get the video title for the embed url
*
*/
public function getVideoTitle()
{
- $url = "http://gdata.youtube.com/feeds/api/videos/". $this->getVideoCode();
- $ch = curl_init();
- $curlOptions = array(
+ $code = $this->getVideoCode();
+ if (!$code) {
+ return false;
+ } else {
+ $url = "http://gdata.youtube.com/feeds/api/videos/". $this->getVideoCode();
+ $ch = curl_init();
+ $curlOptions = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => 1
- );
- curl_setopt_array($ch, $curlOptions);
+ );
+ curl_setopt_array($ch, $curlOptions);
- $response = curl_exec($ch);
- curl_close($ch);
- $doc = new DOMDocument;
- $doc->loadXML($response);
- $title = $doc->getElementsByTagName("title")->item(0)->nodeValue;
- return $title;
+ $response = curl_exec($ch);
+ curl_close($ch);
+ $doc = new DOMDocument;
+ $doc->loadXML($response);
+ $title = $doc->getElementsByTagName("title")->item(0)->nodeValue;
+ return $title;
+ }
}
}
Toolkit_Common::handleError($e);
}
}
-
+
}
*/
public function renderThumbNail($data)
{
+ $isVimeo = false;
extract($data['record']);
$pattern = '/v=(.*)/';
$pattern2 = '/youtu.be\/(.*)/';
+ $pattern3 = ';vimeo.com/([0-9]*);';
if (preg_match($pattern, $video_url, $match)) {
$vidCode = $match[1];
} else if (preg_match($pattern2, $video_url, $match)) {
$vidCode = $match[1];
+ } else if (preg_match($pattern3, $video_url, $match)) {
+ $vidCode = $match[1];
+ $isVimeo = true;
+ }
+ if ($isVimeo) {
+ //$vimeoData = Toolkit_Videos_Video::getVimeoThumbnail($vidCode);
+ $vimeoData = Toolkit_Videos_Video::getVimeoThumbnail($vidCode);
+ $thumb = ($vidCode)
+ ? '<a href="https://player.vimeo.com/vidio/'.$vidCode.'?rel=0" class="various fancybox.iframe vidimg"><img src="'.$vimeoData['thumbnail_small'].'"></a>'
+ : '';
+ } else {
+ $thumb = ($vidCode)
+ ? '<a href="http://www.youtube.com/embed/'.$vidCode.'?rel=0" class="various fancybox.iframe vidimg"><img src="http://img.youtube.com/vi/'.$vidCode.'/default.jpg"></a>'
+ : '';
}
- $thumb = ($vidCode)
- ? '<a href="http://www.youtube.com/embed/'.$vidCode.'?rel=0" class="various fancybox.iframe vidimg"><img src="http://img.youtube.com/vi/'.$vidCode.'/default.jpg"></a>'
- : '';
return $thumb;
}
= new Toolkit_Videos_VideoMapper($dbh);
$video = $videoMapper->getVideoById($row['id'], false);
if ($video) {
- $page->videos[] = array(
- 'title' => $video->getVideoTitle(),
- 'code' => $video->getVideoCode()
- );
+ if (filter_var($video->getVideoCode(), FILTER_VALIDATE_INT)) {
+ $vimeoData = $video->getVimeoThumbnail($video->getVideoCode());
+ $page->videos[] = array(
+ 'title' => $vimeoData['title'],
+ 'url' => $video->getVideoUrl(),
+ 'img' => $vimeoData['thumbnail_medium'],
+ 'code' => $video->getVideoCode()
+ );
+ } else {
+ $page->videos[] = array(
+ 'title' => $video->getVideoTitle(),
+ 'url' => $video->getVideoUrl(),
+ 'img' => "http://img.youtube.com/vi/{$video->getVideoCode()}/default.jpg",
+ 'code' => $video->getVideoCode()
+ );
+ }
}
}
$count = 1;
{foreach:videos,v}
<li class="vThumb">
<div class="imgBorderMe">
- <a href="http://www.youtube.com/embed/{v[code]}?rel=0&hd=1" class="various fancybox.iframe vidimg">
- <img src="http://img.youtube.com/vi/{v[code]}/default.jpg">
+ <a href="{v[url]}" class="various fancybox.iframe vidimg">
+ <img src="{v[img]}">
<span class="vTitle">{v[title]:h}<span class="play"></span></span>
</a>
</div>
</li>
{end:}
-</ul>
\ No newline at end of file
+</ul>
; development site configuration data inherits from production and
; overrides values as necessary
[development : production]
-site_url = "http://dev53.gaslightmedia.com/www.keweenaw.info/"
+site_url = "http://localhost:8080/www.keweenaw.info/"
mobile.link =
mobile.hostname = Off
google.search.key = "ABQIAAAANX0yQZ2OteLu_zqbwdfUuRTeX7yNUukyMrmY8FsCXcCA9axlYBTyhehgzuXOUfNI0E5UYHCLponA0A"
google.maps.key = "ABQIAAAANX0yQZ2OteLu_zqbwdfUuRQsHGkczIjpqPY1-dTKNoaiGtfPJBTloI-YH7fzUV-bsMLwcy2Yjyti7A"
-app.base_url = "http://dev53.gaslightmedia.com/app.gaslightmedia.com/"
-app.base_secure_url = "https://dev53.gaslightmedia.com/app.gaslightmedia.com/"
+app.base_url = "http://app.gaslightmedia.com/"
+app.base_secure_url = "https://app.gaslightmedia.com/"
error.reporting[] = E_ALL
error.reporting[] = E_NOTICE