From: Anthony Talarico Date: Tue, 24 May 2016 18:47:23 +0000 (-0400) Subject: added title column to admin videos gallery X-Git-Tag: v1.0.13^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=6d38c57257866c055e696dba98401cb372343e59;p=web%2FSooLocks.git added title column to admin videos gallery --- diff --git a/Toolkit/Videos/AdminEditVideoForm.php b/Toolkit/Videos/AdminEditVideoForm.php index 0977087..905890c 100644 --- a/Toolkit/Videos/AdminEditVideoForm.php +++ b/Toolkit/Videos/AdminEditVideoForm.php @@ -131,6 +131,13 @@ class Toolkit_Videos_AdminEditVideoForm 'name' => 'featured' ); } + $e[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'title', + 'display' => 'Title', + 'opts' => array('class' => 'text','size'=>50) + ); $e[] = array( 'type' => 'text', 'req' => true, @@ -210,18 +217,18 @@ class Toolkit_Videos_AdminEditVideoForm { $r = array(); - $r[] = array( - 'element' => 'video_url', - 'message' => 'ERROR: Invalid URL format (http)', - 'type' => 'checkURI', - 'format' => array( - 'allowed_schemes' => array('http'), - 'strict' => false - ), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); + $r[] = array( + 'element' => 'video_url', + 'message' => 'ERROR: Invalid URL format (http)', + 'type' => 'checkURI', + 'format' => array( + 'allowed_schemes' => array('http', 'https'), + 'strict' => false + ), + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); $this->setupRules($r); @@ -252,6 +259,7 @@ class Toolkit_Videos_AdminEditVideoForm $video = new Toolkit_Videos_Video(); } $video->setVideo_url($values['video_url']) + ->setTitle($values['title']) ->setFeatured($values['featured']) ->setActive($values['active']); diff --git a/Toolkit/Videos/Database/addTitle.sql b/Toolkit/Videos/Database/addTitle.sql new file mode 100644 index 0000000..fe0cbd1 --- /dev/null +++ b/Toolkit/Videos/Database/addTitle.sql @@ -0,0 +1,4 @@ +-- +-- Update the video table +-- +ALTER TABLE videos.videos ADD title TEXT; diff --git a/Toolkit/Videos/Video.php b/Toolkit/Videos/Video.php index 8e5f6e3..85b5987 100644 --- a/Toolkit/Videos/Video.php +++ b/Toolkit/Videos/Video.php @@ -28,6 +28,7 @@ class Toolkit_Videos_Video { protected $id; + protected $title; protected $video_url; protected $pos; protected $featured; @@ -170,6 +171,16 @@ class Toolkit_Videos_Video } return $this; } + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + return $this; + } /** * video_url getter @@ -326,21 +337,26 @@ class Toolkit_Videos_Video */ public function getVideoTitle() { - $url = "http://gdata.youtube.com/feeds/api/videos/". $this->getVideoCode(); - $ch = curl_init(); - $curlOptions = array( + return $this->getTitle(); + $code = $this->getVideoCode(); + if (!$code) { + return false; + } else { + //$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, 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); + parse_str($response, $ytarr); + return $ytarr['title']; + } } } diff --git a/Toolkit/Videos/VideoMapper.php b/Toolkit/Videos/VideoMapper.php index 2a00c87..26a1178 100644 --- a/Toolkit/Videos/VideoMapper.php +++ b/Toolkit/Videos/VideoMapper.php @@ -95,6 +95,7 @@ class Toolkit_Videos_VideoMapper 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']) diff --git a/Toolkit/Videos/VideosDataGrid.php b/Toolkit/Videos/VideosDataGrid.php index f2403e8..c139910 100644 --- a/Toolkit/Videos/VideosDataGrid.php +++ b/Toolkit/Videos/VideosDataGrid.php @@ -112,8 +112,8 @@ class Toolkit_Videos_VideosDataGrid $this->addColumn( new Structures_DataGrid_Column( - 'Video Url', - 'video_url', + 'Title', + 'title', null ) );