-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbe9799
commit 8b0373e
Showing
3 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{extends "designs/site.tpl"} | ||
|
||
{block title}{_ 'Event'} — {$dwoo.parent}{/block} | ||
|
||
{block content} | ||
{$Event = $data} | ||
|
||
<header class="page-header"> | ||
<div class="btn-toolbar pull-right"> | ||
{if $.User} | ||
<form action="{$Event->getUrl(edit)}"> | ||
<button class="btn btn-success" type="submit">{glyph "pencil"} {_ "Edit Event…"}</button> | ||
</form> | ||
{/if} | ||
</div> | ||
<h1><a href="/events">{_ "Events"}</a> » <a href="{$Event->getUrl()}">{$Event->Title|escape}</a></h1> | ||
</header> | ||
|
||
<article class="post panel panel-default"> | ||
<div class="panel-body"> | ||
<dl class="dl-horizontal"> | ||
{if $Event->Status != 'published'} | ||
<dt>Status</dt> | ||
<dd><strong>{$Event->Status}</strong></dd> | ||
{/if} | ||
|
||
<dt>Start time</dt> | ||
<dd>{timestamp $Event->StartTime time=yes}</dd> | ||
|
||
{if $Event->EndTime} | ||
<dt>End time</dt> | ||
<dd>{timestamp $Event->EndTime time=yes}</dd> | ||
{/if} | ||
|
||
{if $Event->Location} | ||
<dt>Location</dt> | ||
<dd><a href="https://www.google.com/maps?q={$Event->Location|escape:url}">{$Event->Location|escape}</a></dd> | ||
{/if} | ||
|
||
{if $Event->Description} | ||
<dt>Description</dt> | ||
<dd class="well"> | ||
<div class="markdown event-description">{$Event->Description|truncate:600|escape|markdown}</div> | ||
</dd> | ||
{/if} | ||
|
||
{if $Event->Segments} | ||
<dt>Segments</dt> | ||
<dd> | ||
<dl class="dl-horizontal"> | ||
{$lastDate = null} | ||
{foreach item=Segment from=$Event->Segments} | ||
{$thisDate = date("l<\\b\\r>F jS", $Segment->StartTime)} | ||
{if $lastDate != $thisDate} | ||
{if $lastDate} | ||
</dl> | ||
</dd> | ||
{/if} | ||
<dt>{$thisDate}</dt> | ||
<dd> | ||
<dl class="dl-horizontal"> | ||
{$lastDate = $thisDate} | ||
{/if} | ||
<dt>{time_range $Segment->StartTime $Segment->EndTime}</dt> | ||
<dd> | ||
<a href="{$Event->getUrl("segments/$Segment->Handle")}">{$Segment->Title|escape}</a> | ||
{if $Segment->LocationName || $Segment->LocationAddress} | ||
<p> | ||
<strong>Location</strong> | ||
<a target="_blank" href="https://maps.google.com?q={implode(', ', array_filter(array($Segment->LocationName, $Segment->LocationAddress)))|escape:url}"> | ||
{if $Segment->LocationName && $Segment->LocationAddress} | ||
{$Segment->LocationName|escape} ({$Segment->LocationAddress|escape}) | ||
{else} | ||
{$Segment->LocationName|default:$Segment->LocationAddress|escape} | ||
{/if} | ||
</a> | ||
</p> | ||
{/if} | ||
{$Segment->Description|escape|markdown} | ||
</dd> | ||
|
||
{/foreach} | ||
</dl></dd> | ||
</dl> | ||
</dd> | ||
{/if} | ||
</dl> | ||
</div> | ||
</article> | ||
{/block} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
namespace Emergence\Events; | ||
|
||
use HandleBehavior; | ||
|
||
|
||
class EventSegment extends \VersionedRecord | ||
{ | ||
// ActiveRecord configuration | ||
public static $tableName = 'event_segments'; // the name of this model's table | ||
public static $collectionRoute = '/event-segments'; | ||
|
||
// controllers will use these values to figure out what templates to use | ||
public static $singularNoun = 'event segment'; // a singular noun for this model's object | ||
public static $pluralNoun = 'event segments'; // a plural noun for this model's object | ||
|
||
public static $fields = [ | ||
'EventID' => 'uint', | ||
'Title', | ||
'Handle', | ||
'StartTime' => [ | ||
'type' => 'timestamp' | ||
], | ||
'EndTime' => [ | ||
'type' => 'timestamp' | ||
], | ||
'LocationName' => [ | ||
'type' => 'string', | ||
'default' => null | ||
], | ||
'LocationAddress' => [ | ||
'type' => 'string', | ||
'default' => null | ||
], | ||
'Description' => [ | ||
'type' => 'clob', | ||
'default' => null | ||
] | ||
]; | ||
|
||
public static $indexes = [ | ||
'EventHandle' => [ | ||
'fields' => ['EventID', 'Handle'], | ||
'unique' => true | ||
] | ||
]; | ||
|
||
public static $relationships = [ | ||
'Event' => [ | ||
'type' => 'one-many', | ||
'class' => Event::class | ||
] | ||
]; | ||
|
||
public static $dynamicFields = [ | ||
'Event' | ||
]; | ||
|
||
public static $validators = [ | ||
'Event' => 'require-relationship', | ||
'StartTime' => [ | ||
'validator' => 'datetime', | ||
'errorMessage' => 'Event start time is required' | ||
] | ||
// TODO: validate that EndTime > StartTime if set | ||
]; | ||
|
||
public function validate($deep = true) | ||
{ | ||
// call parent | ||
parent::validate(); | ||
|
||
HandleBehavior::onValidate($this, $this->_validator); | ||
|
||
// save results | ||
return $this->finishValidation(); | ||
} | ||
|
||
public function save($deep = true) | ||
{ | ||
HandleBehavior::onSave($this); | ||
|
||
// call parent | ||
parent::save(); | ||
} | ||
} |