Fixes for page display and featured videos

Conflicts:

	openstack/code/PresentationCategoryPage.php
This commit is contained in:
Todd Morey 2014-11-04 14:20:28 +01:00 committed by Sebastian Marcet
parent caf9f2a016
commit 343420ad15
5 changed files with 113 additions and 102 deletions

View File

@ -11,41 +11,47 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
**/ **/
/** /**
* Defines the JobsHolder page type * Defines the JobsHolder page type
*/ */
class PresentationCategoryPage extends Page { class PresentationCategoryPage extends Page
static $db = array( {
'StillUploading' => 'Boolean' static $db = array(
); 'StillUploading' => 'Boolean'
static $has_one = array( );
); static $has_one = array();
static $has_many = array( static $has_many = array(
'Presentations' => 'Presentation' 'Presentations' => 'Presentation',
); 'FeaturedVideos' => 'FeaturedVideo'
);
static $allowed_children = array('PresentationCategoryPage'); static $allowed_children = array('PresentationCategoryPage');
/** static $icon = "icon/path"; */
function getCMSFields() { /** static $icon = "icon/path"; */
$fields = parent::getCMSFields();
$presentationsTable = new GridField('Presentations', 'Presentations',$this->Presentations());
$fields->addFieldToTab('Root.Presentations',$presentationsTable);
// Summit Videos function getCMSFields()
$VideosUploadingField = new OptionSetField('StillUploading', 'Are videos still being uploaded?', array( {
'1' => 'Yes - A message will be displayed.', $fields = parent::getCMSFields();
'0' => 'No' $presentationsTable = new GridField('Presentations', 'Presentations', $this->Presentations());
)); $fields->addFieldToTab('Root.Presentations', $presentationsTable);
$fields->addFieldToTab("Root.Main", $VideosUploadingField, 'Content'); // Summit Videos
$VideosUploadingField = new OptionSetField('StillUploading', 'Are videos still being uploaded?', array(
'1' => 'Yes - A message will be displayed.',
'0' => 'No'
));
$fields->addFieldToTab("Root.Content.Main", $VideosUploadingField, 'Content');
$featuredVideos = new DataObjectManager($this, 'FeaturedVideos', 'FeaturedVideo');
$fields->addFieldToTab('Root.Content.FeaturedVideos', $featuredVideos);
return $fields; return $fields;
} }
} }
class PresentationCategoryPage_Controller extends Page_Controller { class PresentationCategoryPage_Controller extends Page_Controller
{
static $allowed_actions = array( static $allowed_actions = array(
@ -53,61 +59,62 @@ class PresentationCategoryPage_Controller extends Page_Controller {
'updateURLS' => 'admin' 'updateURLS' => 'admin'
); );
public function Presentations(){ public function Presentations()
$sessions = dataobject::get('Presentation','`YouTubeID` IS NOT NULL AND PresentationCategoryPageID = '.$this->ID,'StartTime DESC'); {
$sessions = dataobject::get('Presentation', '`YouTubeID` IS NOT NULL AND PresentationCategoryPageID = ' . $this->ID, 'StartTime DESC');
return $sessions; return $sessions;
} }
function init() { function init()
{
parent::init(); parent::init();
if(isset($_GET['day'])) { if (isset($_GET['day'])) {
Session::set('Day', $_GET['day']); Session::set('Day', $_GET['day']);
} else { } else {
Session::set('Day', 1); Session::set('Day', 1);
} }
if (Director::urlParam("OtherID") != "presentation") Session::set('Autoplay',TRUE); if (Director::urlParam("OtherID") != "presentation") Session::set('Autoplay', TRUE);
} }
//Show the Presentation detail page using the PresentationCategoryPage_presentation.ss template //Show the Presentation detail page using the PresentationCategoryPage_presentation.ss template
function presentation() function presentation()
{ {
if($Presentation = $this->getPresentationByURLSegment()) if ($Presentation = $this->getPresentationByURLSegment()) {
{
$Data = array( $Data = array(
'Presentation' => $Presentation 'Presentation' => $Presentation
); );
$this->Title = $Presentation->Name; $this->Title = $Presentation->Name;
$this->Autoplay = Session::get('Autoplay'); $this->Autoplay = Session::get('Autoplay');
// Clear autoplay so it only happens when you come directly from videos index // Clear autoplay so it only happens when you come directly from videos index
Session::set('Autoplay',FALSE); Session::set('Autoplay', FALSE);
//return our $Data to use on the page //return our $Data to use on the page
return $this->Customise($Data); return $this->Customise($Data);
} } else {
else
{
//Presentation not found //Presentation not found
return $this->httpError(404, 'Sorry that presentation could not be found'); return $this->httpError(404, 'Sorry that presentation could not be found');
} }
} }
function PresentationDayID($PresentationDay) { function PresentationDayID($PresentationDay)
return trim($PresentationDay,' '); {
} return trim($PresentationDay, ' ');
}
function LatestPresentation() function LatestPresentation()
{ {
if ($this->Presentations()) return $this->Presentations()->first(); if ($this->Presentations()) return $this->Presentations()->first();
} }
// Check to see if the page is being accessed in Chinese // Check to see if the page is being accessed in Chinese
// We use this in the templates to tell Chinese visitors how to obtain the videos on a non-youtube source // We use this in the templates to tell Chinese visitors how to obtain the videos on a non-youtube source
function ChineseLanguage() { function ChineseLanguage()
{
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if ($lang == "zh") { if ($lang == "zh") {
return TRUE; return TRUE;
@ -122,8 +129,7 @@ class PresentationCategoryPage_Controller extends Page_Controller {
{ {
$Params = $this->getURLParams(); $Params = $this->getURLParams();
$Segment = convert::raw2sql($Params['ID']); $Segment = convert::raw2sql($Params['ID']);
if($Params['ID'] && $Presentation = DataObject::get_one('Presentation', "`URLSegment` = '".$Segment."' AND `PresentationCategoryPageID` = ".$this->ID)) if ($Params['ID'] && $Presentation = DataObject::get_one('Presentation', "`URLSegment` = '" . $Segment . "' AND `PresentationCategoryPageID` = " . $this->ID)) {
{
return $Presentation; return $Presentation;
} }
} }
@ -136,10 +142,11 @@ class PresentationCategoryPage_Controller extends Page_Controller {
return (int)$day; return (int)$day;
} }
function updateURLS() { function updateURLS()
$presentations = Presentation::get()->filter('PresentationCategoryPageID', $this->ID)->sort('StartTime','ASC'); {
$presentations = Presentation::get()->filter('PresentationCategoryPageID', $this->ID)->sort('StartTime', 'ASC');
foreach ($presentations as $presentation) { foreach ($presentations as $presentation) {
if($presentation->URLSegment == NULL) { if ($presentation->URLSegment == NULL) {
$presentation->write(); $presentation->write();
} }
} }

View File

@ -0,0 +1,20 @@
<?php
class FeaturedVideo extends DataObject {
static $db = array(
'Name' => 'Text',
'Day' => 'Int',
'YouTubeID' => 'Varchar',
'Description' => 'Text',
'URLSegment' => 'Text'
);
static $has_one = array(
'PresentationCategoryPage' => 'PresentationCategoryPage'
);
}
?>

View File

@ -400,4 +400,8 @@ a.media-btn.left {
margin-right: -2px; margin-right: -2px;
border-right: 1px solid #122231; } border-right: 1px solid #122231; }
.video-thumb-title, .video-thumb-speaker {
min-height: 2em;
}
/*End Video Inner Page*/ /*End Video Inner Page*/

View File

@ -26,26 +26,28 @@
<% control Presentations.GroupedBy(PresentationDay) %> <% control Presentations.GroupedBy(PresentationDay) %>
<div class="row"> <div class="row">
<h2 id="day-{$Pos}">$PresentationDay</h2> <div class="col-lg-12">
<ul> <h2 id="day-{$Pos}">$PresentationDay</h2>
</div>
<% control Children %> <% control Children %>
<!-- Video Block --> <!-- Video Block -->
<div class="col-lg-3 col-md-3 col-sm-3"> <% if YouTubeID %>
<a href="{$Top.Link}presentation/{$URLSegment}"> <div class="col-lg-3 col-md-3 col-sm-3 video-block">
<div class="video-thumb"> <a href="{$Top.Link}presentation/{$URLSegment}">
<div class="thumb-play"></div> <div class="video-thumb">
<img class="video-thumb-img" src="//img.youtube.com/vi/{$YouTubeID}/0.jpg"> <div class="thumb-play"></div>
</div> <img class="video-thumb-img" src="//img.youtube.com/vi/{$YouTubeID}/0.jpg">
<p class="video-thumb-title"> </div>
$Name <p class="video-thumb-title">
</p> $Name
<p class="video-thumb-speaker"> </p>
$Speakers <p class="video-thumb-speaker">
</p> $Speakers
</a> </p>
</div> </a>
</div>
<% end_if %>
<% end_control %> <% end_control %>
</ul>
</div> </div>
<% end_control %> <% end_control %>

View File

@ -36,38 +36,16 @@
</div> </div>
<div class="container daily-recap-wrapper"> <div class="container daily-recap-wrapper">
<div class="row"> <div class="row">
<div class="col-lg-3 col-md-3 col-sm-3"> <% control FeaturedVideos %>
<div class="video-thumb"> <div class="col-lg-3 col-md-3 col-sm-3">
<img class="video-thumb-img" src="/themes/openstack/images/no-video.jpg"> <div class="video-thumb">
<img class="video-thumb-img" src="/themes/openstack/images/no-video.jpg">
</div>
<p class="video-thumb-title">
Day {$Pos} - Coming Soon
</p>
</div> </div>
<p class="video-thumb-title"> <% end_control %>
Day 1 - Coming Soon
</p>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="video-thumb">
<img class="video-thumb-img" src="/themes/openstack/images/no-video.jpg">
</div>
<p class="video-thumb-title">
Day 2 - Coming Soon
</p>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="video-thumb">
<img class="video-thumb-img" src="/themes/openstack/images/no-video.jpg">
</div>
<p class="video-thumb-title">
Day 3 - Coming Soon
</p>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="video-thumb">
<img class="video-thumb-img" src="/themes/openstack/images/no-video.jpg">
</div>
<p class="video-thumb-title">
Day 4 - Coming Soon
</p>
</div>
</div> </div>
</div> </div>