Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/controller/PhabricatorCalendarEventListController.php
12256 views
1
<?php
2
3
final class PhabricatorCalendarEventListController
4
extends PhabricatorCalendarController {
5
6
private $viewYear;
7
private $viewMonth;
8
private $viewDay;
9
10
public function shouldAllowPublic() {
11
return true;
12
}
13
14
public function isGlobalDragAndDropUploadEnabled() {
15
return true;
16
}
17
18
public function handleRequest(AphrontRequest $request) {
19
$year = $request->getURIData('year');
20
$month = $request->getURIData('month');
21
$day = $request->getURIData('day');
22
23
$this->viewYear = $year;
24
$this->viewMonth = $month;
25
$this->viewDay = $day;
26
27
$engine = new PhabricatorCalendarEventSearchEngine();
28
29
if ($month && $year) {
30
$engine->setCalendarYearAndMonthAndDay($year, $month, $day);
31
}
32
33
$nav_items = $this->buildNavigationItems();
34
35
return $engine
36
->setNavigationItems($nav_items)
37
->setController($this)
38
->buildResponse();
39
}
40
41
protected function buildApplicationCrumbs() {
42
$crumbs = parent::buildApplicationCrumbs();
43
44
$viewer = $this->getViewer();
45
46
$year = $this->viewYear;
47
$month = $this->viewMonth;
48
$day = $this->viewDay;
49
50
$parameters = array();
51
52
// If the viewer clicks "Create Event" while on a particular day view,
53
// default the times to that day.
54
if ($year && $month && $day) {
55
$datetimes = PhabricatorCalendarEvent::newDefaultEventDateTimes(
56
$viewer,
57
PhabricatorTime::getNow());
58
59
foreach ($datetimes as $datetime) {
60
$datetime
61
->setYear($year)
62
->setMonth($month)
63
->setDay($day);
64
}
65
66
list($start, $end) = $datetimes;
67
$parameters['start'] = $start->getEpoch();
68
$parameters['end'] = $end->getEpoch();
69
}
70
71
id(new PhabricatorCalendarEventEditEngine())
72
->setViewer($this->getViewer())
73
->addActionToCrumbs($crumbs, $parameters);
74
75
return $crumbs;
76
}
77
78
protected function buildNavigationItems() {
79
$items = array();
80
81
$items[] = id(new PHUIListItemView())
82
->setType(PHUIListItemView::TYPE_LABEL)
83
->setName(pht('Import/Export'));
84
85
$items[] = id(new PHUIListItemView())
86
->setName('Imports')
87
->setHref('/calendar/import/');
88
89
$items[] = id(new PHUIListItemView())
90
->setName('Exports')
91
->setHref('/calendar/export/');
92
93
return $items;
94
}
95
96
}
97
98