More video page fixes
Conflicts: openstack/code/PresentationCategoryPage.php
This commit is contained in:
parent
343420ad15
commit
f9168bdaf2
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2014 Openstack Foundation
|
* Copyright 2014 Openstack Foundation
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -21,8 +22,9 @@ class PresentationCategoryPage extends Page
|
|||||||
'StillUploading' => 'Boolean'
|
'StillUploading' => 'Boolean'
|
||||||
);
|
);
|
||||||
static $has_one = array();
|
static $has_one = array();
|
||||||
|
|
||||||
static $has_many = array(
|
static $has_many = array(
|
||||||
'Presentations' => 'Presentation',
|
'Presentations' => 'Presentation',
|
||||||
'FeaturedVideos' => 'FeaturedVideo'
|
'FeaturedVideos' => 'FeaturedVideo'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -33,18 +35,22 @@ class PresentationCategoryPage extends Page
|
|||||||
function getCMSFields()
|
function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
$presentationsTable = new GridField('Presentations', 'Presentations', $this->Presentations());
|
$presentationsTable = new GridField('Presentations', 'Presentations', $this->Presentations(),GridFieldConfig_RecordEditor::create(10));
|
||||||
$fields->addFieldToTab('Root.Presentations', $presentationsTable);
|
|
||||||
|
$fields->addFieldToTab('Root.Content.Presentations', $presentationsTable);
|
||||||
|
|
||||||
// Summit Videos
|
// Summit Videos
|
||||||
$VideosUploadingField = new OptionSetField('StillUploading', 'Are videos still being uploaded?', array(
|
$VideosUploadingField = new OptionSetField('StillUploading', 'Are videos still being uploaded?', array(
|
||||||
'1' => 'Yes - A message will be displayed.',
|
'1' => 'Yes - A message will be displayed.',
|
||||||
'0' => 'No'
|
'0' => 'No'
|
||||||
));
|
));
|
||||||
|
|
||||||
$fields->addFieldToTab("Root.Content.Main", $VideosUploadingField, 'Content');
|
$fields->addFieldToTab("Root.Content.Main", $VideosUploadingField, 'Content');
|
||||||
$featuredVideos = new DataObjectManager($this, 'FeaturedVideos', 'FeaturedVideo');
|
|
||||||
|
$featuredVideos = new GridField('FeaturedVideos', 'FeaturedVideos', $this->FeaturedVideos(),GridFieldConfig_RecordEditor::create(10));
|
||||||
$fields->addFieldToTab('Root.Content.FeaturedVideos', $featuredVideos);
|
$fields->addFieldToTab('Root.Content.FeaturedVideos', $featuredVideos);
|
||||||
|
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +62,7 @@ class PresentationCategoryPage_Controller extends Page_Controller
|
|||||||
|
|
||||||
static $allowed_actions = array(
|
static $allowed_actions = array(
|
||||||
'presentation',
|
'presentation',
|
||||||
|
'featured',
|
||||||
'updateURLS' => 'admin'
|
'updateURLS' => 'admin'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -100,6 +107,28 @@ class PresentationCategoryPage_Controller extends Page_Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Show the Presentation detail page using the PresentationCategoryPage_presentation.ss template
|
||||||
|
function featured()
|
||||||
|
{
|
||||||
|
if ($Presentation = $this->getPresentationByURLSegment(TRUE)) {
|
||||||
|
$Data = array(
|
||||||
|
'Presentation' => $Presentation
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->Title = $Presentation->Name;
|
||||||
|
$this->Autoplay = Session::get('Autoplay');
|
||||||
|
|
||||||
|
// Clear autoplay so it only happens when you come directly from videos index
|
||||||
|
Session::set('Autoplay', FALSE);
|
||||||
|
|
||||||
|
//return our $Data to use on the page
|
||||||
|
return $this->Customise($Data);
|
||||||
|
} else {
|
||||||
|
//Presentation not found
|
||||||
|
return $this->httpError(404, 'Sorry that presentation could not be found');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function PresentationDayID($PresentationDay)
|
function PresentationDayID($PresentationDay)
|
||||||
{
|
{
|
||||||
return trim($PresentationDay, ' ');
|
return trim($PresentationDay, ' ');
|
||||||
@ -125,15 +154,20 @@ class PresentationCategoryPage_Controller extends Page_Controller
|
|||||||
|
|
||||||
|
|
||||||
//Get the current Presentation from the URL, if any
|
//Get the current Presentation from the URL, if any
|
||||||
public function getPresentationByURLSegment()
|
public function getPresentationByURLSegment($featured = FALSE)
|
||||||
{
|
{
|
||||||
|
|
||||||
$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 ($featured == FALSE && $Params['ID'] && $Presentation = DataObject::get_one('Presentation', "`URLSegment` = '" . $Segment . "' AND `PresentationCategoryPageID` = " . $this->ID)) {
|
||||||
return $Presentation;
|
return $Presentation;
|
||||||
|
} elseif ($featured == TRUE && $Params['ID'] && $FeaturedVideo = DataObject::get_one('FeaturedVideo', "`URLSegment` = '" . $Segment . "'")) {
|
||||||
|
return $FeaturedVideo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function currentDay()
|
function currentDay()
|
||||||
{
|
{
|
||||||
$day = Session::get('Day');
|
$day = Session::get('Day');
|
||||||
@ -144,7 +178,7 @@ class PresentationCategoryPage_Controller extends Page_Controller
|
|||||||
|
|
||||||
function updateURLS()
|
function updateURLS()
|
||||||
{
|
{
|
||||||
$presentations = Presentation::get()->filter('PresentationCategoryPageID', $this->ID)->sort('StartTime', 'ASC');
|
$presentations = dataobject::get('Presentation', 'PresentationCategoryPageID = ' . $this->ID, 'StartTime ASC');
|
||||||
foreach ($presentations as $presentation) {
|
foreach ($presentations as $presentation) {
|
||||||
if ($presentation->URLSegment == NULL) {
|
if ($presentation->URLSegment == NULL) {
|
||||||
$presentation->write();
|
$presentation->write();
|
||||||
|
@ -14,7 +14,50 @@ class FeaturedVideo extends DataObject {
|
|||||||
'PresentationCategoryPage' => 'PresentationCategoryPage'
|
'PresentationCategoryPage' => 'PresentationCategoryPage'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function onBeforeWrite() {
|
||||||
|
parent::onBeforeWrite();
|
||||||
|
|
||||||
|
|
||||||
|
// If there is no URLSegment set, generate one from Title
|
||||||
|
if((!$this->URLSegment || $this->URLSegment == 'new-presentation') && $this->Title != 'New Presentation')
|
||||||
|
{
|
||||||
|
$this->URLSegment = SiteTree::generateURLSegment($this->Title);
|
||||||
|
}
|
||||||
|
else if($this->isChanged('URLSegment'))
|
||||||
|
{
|
||||||
|
// Make sure the URLSegment is valid for use in a URL
|
||||||
|
$segment = preg_replace('/[^A-Za-z0-9]+/','-',$this->URLSegment);
|
||||||
|
$segment = preg_replace('/-+/','-',$segment);
|
||||||
|
|
||||||
|
// If after sanitising there is no URLSegment, give it a reasonable default
|
||||||
|
if(!$segment) {
|
||||||
|
$segment = "presentation-".$this->ID;
|
||||||
|
}
|
||||||
|
$this->URLSegment = $segment;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure that this object has a non-conflicting URLSegment value by appending number if needed
|
||||||
|
$count = 2;
|
||||||
|
while($this->LookForExistingURLSegment($this->URLSegment))
|
||||||
|
{
|
||||||
|
$this->URLSegment = preg_replace('/-[0-9]+$/', null, $this->URLSegment) . '-' . $count;
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Test whether the URLSegment exists already on another Video
|
||||||
|
function LookForExistingURLSegment($URLSegment)
|
||||||
|
{
|
||||||
|
return (DataObject::get_one('Company', "URLSegment = '" . $URLSegment ."' AND ID != " . $this->ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -21,15 +21,17 @@
|
|||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<!-- Start Videos -->
|
<!-- Start Videos -->
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
|
|
||||||
<% control Presentations.GroupedBy(PresentationDay) %>
|
<% control Presentations.GroupedBy(PresentationDay) %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<h2 id="day-{$Pos}">$PresentationDay</h2>
|
<h2 id="day-{$Pos}">$PresentationDay</h2>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
<% control Children %>
|
<% control Children %>
|
||||||
|
|
||||||
<!-- Video Block -->
|
<!-- Video Block -->
|
||||||
<% if YouTubeID %>
|
<% if YouTubeID %>
|
||||||
<div class="col-lg-3 col-md-3 col-sm-3 video-block">
|
<div class="col-lg-3 col-md-3 col-sm-3 video-block">
|
||||||
@ -47,13 +49,18 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
<% if MultipleOf(4) %>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<% end_if %>
|
||||||
|
|
||||||
|
<% if Last %>
|
||||||
|
</div>
|
||||||
|
<% end_if %>
|
||||||
|
|
||||||
<% end_control %>
|
<% end_control %>
|
||||||
</div>
|
|
||||||
<% end_control %>
|
<% end_control %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- End Videos -->
|
<!-- End Videos -->
|
||||||
|
|
||||||
</div>
|
|
||||||
<!-- End Page Content -->
|
|
||||||
|
@ -37,6 +37,26 @@
|
|||||||
<div class="container daily-recap-wrapper">
|
<div class="container daily-recap-wrapper">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<% control FeaturedVideos %>
|
<% control FeaturedVideos %>
|
||||||
|
|
||||||
|
<!-- If there is a YouTube ID -->
|
||||||
|
|
||||||
|
<% if YouTubeID %>
|
||||||
|
|
||||||
|
<div class="col-lg-3 col-md-3 col-sm-3 video-block">
|
||||||
|
<a href="{$Top.Link}featured/{$URLSegment}">
|
||||||
|
<div class="video-thumb">
|
||||||
|
<div class="thumb-play"></div>
|
||||||
|
<img class="video-thumb-img" src="//img.youtube.com/vi/{$YouTubeID}/0.jpg">
|
||||||
|
</div>
|
||||||
|
<p class="video-thumb-title">
|
||||||
|
$Name
|
||||||
|
</p>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% else %>
|
||||||
|
|
||||||
|
|
||||||
<div class="col-lg-3 col-md-3 col-sm-3">
|
<div class="col-lg-3 col-md-3 col-sm-3">
|
||||||
<div class="video-thumb">
|
<div class="video-thumb">
|
||||||
<img class="video-thumb-img" src="/themes/openstack/images/no-video.jpg">
|
<img class="video-thumb-img" src="/themes/openstack/images/no-video.jpg">
|
||||||
@ -45,6 +65,10 @@
|
|||||||
Day {$Pos} - Coming Soon
|
Day {$Pos} - Coming Soon
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% end_if %>
|
||||||
|
|
||||||
|
|
||||||
<% end_control %>
|
<% end_control %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
<% require themedCSS(videos) %>
|
||||||
|
|
||||||
|
<% control Presentation %>
|
||||||
|
|
||||||
|
<div class="main-video-wrapper">
|
||||||
|
<iframe width="853" height="480" src="//www.youtube.com/embed/{$YouTubeID}?rel=0<% if Top.Autoplay %>&autoplay=1<% end_if %>" frameborder="0" allowfullscreen></iframe>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container single-video-details">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-3 col-md-3 col-sm-3 video-share">
|
||||||
|
<a href="https://twitter.com/share" data-related="jasoncosta" data-lang="en" data-size="large" data-count="none"><i class="fa fa-twitter"></i></a>
|
||||||
|
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-9 col-md-9 col-sm-9">
|
||||||
|
<h3>$Name</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<% end_control %>
|
||||||
|
|
||||||
|
|
||||||
|
<% include VideoThumbnails %>
|
Loading…
Reference in New Issue
Block a user