'name' => 'featured'
);
}
+ $e[] = array(
+ 'type' => 'text',
+ 'req' => false,
+ 'name' => 'title',
+ 'display' => 'Title',
+ 'opts' => array('class' => 'text','size'=>50)
+ );
$e[] = array(
'type' => 'text',
'req' => true,
$video = new Toolkit_Videos_Video();
}
$video->setVideo_url($values['video_url'])
+ ->setTitle($values['title'])
->setFeatured($values['featured'])
->setActive($values['active']);
--- /dev/null
+--
+-- Update the video table
+--
+ALTER TABLE videos.videos ADD title TEXT;
{
protected $id;
+ protected $title;
protected $video_url;
protected $pos;
protected $featured;
}
return $this;
}
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ public function setTitle($title)
+ {
+ $this->title = $title;
+ return $this;
+ }
/**
* video_url getter
*/
public function getVideoTitle()
{
+ return $this->getTitle();
$code = $this->getVideoCode();
if (!$code) {
return false;
} else {
- $url = "http://gdata.youtube.com/feeds/api/videos/". $this->getVideoCode();
+ //$url = "http://gdata.youtube.com/feeds/api/videos/". $this->getVideoCode();
+ $url = "http://www.youtube.com/get_video_info?video_id=".$this->getVideoCode();
$ch = curl_init();
$curlOptions = array(
CURLOPT_URL => $url,
$response = curl_exec($ch);
curl_close($ch);
- $doc = new DOMDocument;
- $doc->loadXML($response);
- $title = $doc->getElementsByTagName("title")->item(0)->nodeValue;
- return $title;
+ parse_str($response, $ytarr);
+ return $ytarr['title'];
}
}
if ($res) {
$video = new Toolkit_Videos_Video();
$video->setId($res['id'])
+ ->setTitle($res['title'])
->setVideo_url($res['video_url'])
->setActive($res['active'])
->setfeatured($res['featured'])
if (filter_var($video->getVideoCode(), FILTER_VALIDATE_INT)) {
$vimeoData = $video->getVimeoThumbnail($video->getVideoCode());
$page->videos[] = array(
- 'title' => $vimeoData['title'],
+ 'title' => $video->getVideoTitle(),
'url' => $video->getVideoUrl(),
'img' => $vimeoData['thumbnail_medium'],
'code' => $video->getVideoCode()
--- /dev/null
+<?php
+require_once '../../setup.phtml';
+$dbh = Toolkit_Database::getInstance();
+$sql = "
+SELECT id
+ FROM videos";
+try {
+ $videoMapper = new Toolkit_Videos_VideoMapper($dbh);
+ $stmt = $dbh->query($sql);
+ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $video = $videoMapper->getVideoById($row['id'], false);
+ //echo '<pre>' . print_r($video, true) . ' </pre>';
+ $title = $video->getVideoTitle();
+ if ($title) {
+ var_dump($title);
+ $video->setTitle($title);
+ $video->save($dbh);
+ echo '<pre>' . print_r($video, true) . ' </pre>';
+ }
+ }
+} catch (PDOException $e) {
+ echo '<pre>'.print_r($e, true).'</pre>';
+ exit;
+}