forked from tanghus/journal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
100 lines (86 loc) · 3.37 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* ownCloud - Journal
*
* @author Thomas Tanghus
* @copyright 2012 Thomas Tanghus <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
OCP\User::checkLoggedIn();
$errors = array();
$categories = array();
$calendars = array();
$singlecalendar = false;
$id = null;
$l = new OC_L10N('journal');
// Version check
list($version,) = \OCP\Util::getVersion();
$required_apps = array(
array('id' => 'tal', 'name' => 'TAL Page Templates'),
array('id' => 'journal', 'name' => 'Journal'),
array('id' => 'calendar', 'name' => 'Calendar'),
);
foreach ($required_apps as $app) {
if(!OCP\App::isEnabled($app['id'])) {
$error = (string)$l->t('The %%s app isn\'t enabled! Please enable it here: <strong><a href="%%s?appid=%%s">Enable %%s app</a></strong>');
$errors[] = sprintf($error, $app['name'],OC_Helper::linkToRoute('settings_apps'), $app['id'], $app['name']);
}
}
if (count($errors) === 0) {
$categories = OCA\Journal\App::getCategories();
$singlecalendar = (bool)OCP\Config::getUserValue(OCP\User::getUser(), 'journal', 'single_calendar', false);
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
if (count($calendars) === 0) {
$error = (string)$l->t('You have no calendars. Please add one at the <strong><a href="%%s">Calendar app</a></strong>');
$errors[] = sprintf($error, OCP\Util::linkTo('calendar', 'index.php'));
}
// Load a specific entry?
$id = isset($_GET['id']) ? $_GET['id'] : null;
OCP\Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addScript('contacts','jquery.multi-autocomplete');
if ($version < 6) {
OCP\Util::addScript('','oc-vcategories');
} else {
OCP\Util::addScript('','tags');
}
OCP\Util::addScript('journal', '3rdparty/Markdown.Converter');
OCP\Util::addScript('journal', '3rdparty/Markdown.Sanitizer');
OCP\Util::addScript('journal', '3rdparty/markdown_dom_parser');
OCP\Util::addScript('journal', '3rdparty/html2markdown');
OCP\Util::addScript('journal', 'jquery.rte');
//OCP\Util::addScript('journal', 'jquery.textchange');
OCP\Util::addScript('journal', 'journal');
OCP\Util::addscript('tal','modernizr');
OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addStyle('journal', 'rte');
OCP\Util::addStyle('journal', 'journal');
if ($version < 6) {
OCP\Util::addStyle('journal', 'icons');
}
OCP\App::setActiveNavigationEntry('journal_index');
}
if ($errors) {
$tmpl = new OCP\Template('journal', 'rtfm', 'user' );
$tmpl->assign('errors',$errors, false);
} else {
$tmpl = new OCA\TAL\Template('journal', 'index', 'user');
$tmpl->assign('categories', $categories);
$tmpl->assign('calendars', $calendars);
$tmpl->assign('singlecalendar', $singlecalendar);
$tmpl->assign('id', $id);
$tmpl->assign('version', $version);
}
$tmpl->printPage();