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,23 +11,27 @@
* 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( static $db = array(
'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'
); );
static $allowed_children = array('PresentationCategoryPage'); static $allowed_children = array('PresentationCategoryPage');
/** static $icon = "icon/path"; */ /** static $icon = "icon/path"; */
function getCMSFields() { function getCMSFields()
{
$fields = parent::getCMSFields(); $fields = parent::getCMSFields();
$presentationsTable = new GridField('Presentations', 'Presentations', $this->Presentations()); $presentationsTable = new GridField('Presentations', 'Presentations', $this->Presentations());
$fields->addFieldToTab('Root.Presentations', $presentationsTable); $fields->addFieldToTab('Root.Presentations', $presentationsTable);
@ -37,15 +41,17 @@ class PresentationCategoryPage extends Page {
'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.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,12 +59,14 @@ 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'])) {
@ -73,8 +81,7 @@ class PresentationCategoryPage_Controller extends Page_Controller {
//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
); );
@ -87,15 +94,14 @@ class PresentationCategoryPage_Controller extends Page_Controller {
//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, ' ');
} }
@ -107,7 +113,8 @@ class PresentationCategoryPage_Controller extends Page_Controller {
// 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,7 +142,8 @@ 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) {

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,11 +26,13 @@
<% control Presentations.GroupedBy(PresentationDay) %> <% control Presentations.GroupedBy(PresentationDay) %>
<div class="row"> <div class="row">
<div class="col-lg-12">
<h2 id="day-{$Pos}">$PresentationDay</h2> <h2 id="day-{$Pos}">$PresentationDay</h2>
<ul> </div>
<% control Children %> <% control Children %>
<!-- Video Block --> <!-- Video Block -->
<div class="col-lg-3 col-md-3 col-sm-3"> <% if YouTubeID %>
<div class="col-lg-3 col-md-3 col-sm-3 video-block">
<a href="{$Top.Link}presentation/{$URLSegment}"> <a href="{$Top.Link}presentation/{$URLSegment}">
<div class="video-thumb"> <div class="video-thumb">
<div class="thumb-play"></div> <div class="thumb-play"></div>
@ -44,8 +46,8 @@
</p> </p>
</a> </a>
</div> </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">
<% control FeaturedVideos %>
<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">
</div> </div>
<p class="video-thumb-title"> <p class="video-thumb-title">
Day 1 - Coming Soon Day {$Pos} - 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> </p>
</div> </div>
<% end_control %>
</div> </div>
</div> </div>