1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Mood |
4
|
|
|
* |
5
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
6
|
|
|
* later. See the COPYING file. |
7
|
|
|
* |
8
|
|
|
* @author Maxence Lange <[email protected]> |
9
|
|
|
* @copyright 2017 |
10
|
|
|
* @license GNU AGPL version 3 or any later version |
11
|
|
|
* |
12
|
|
|
* This program is free software: you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU Affero General Public License as |
14
|
|
|
* published by the Free Software Foundation, either version 3 of the |
15
|
|
|
* License, or (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* This program is distributed in the hope that it will be useful, |
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20
|
|
|
* GNU Affero General Public License for more details. |
21
|
|
|
* |
22
|
|
|
* You should have received a copy of the GNU Affero General Public License |
23
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
24
|
|
|
* |
25
|
|
|
* |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
namespace OCA\Mood\AppInfo; |
29
|
|
|
|
30
|
|
|
use OCA\Mood\Controller\MoodController; |
31
|
|
|
use OCA\Mood\Controller\ToolsController; |
32
|
|
|
use OCA\Mood\Service\HttpService; |
33
|
|
|
use OCP\AppFramework\App; |
34
|
|
|
use OCP\AppFramework\IAppContainer; |
35
|
|
|
use OCP\Notification\IApp; |
36
|
|
|
use OCP\Util; |
37
|
|
|
|
38
|
|
|
class Application extends App { |
39
|
|
|
|
40
|
|
|
/** @var string */ |
41
|
|
|
private $appName; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param array $params |
45
|
|
|
*/ |
46
|
|
|
public function __construct(array $params = array()) { |
47
|
|
|
parent::__construct('mood', $params); |
48
|
|
|
|
49
|
|
|
$container = $this->getContainer(); |
50
|
|
|
$this->appName = $container->query('AppName'); |
51
|
|
|
|
52
|
|
|
$this->registerCore($container); |
53
|
|
|
$this->registerServices($container); |
54
|
|
|
$this->registerControllers($container); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param IAppContainer $container |
60
|
|
|
*/ |
61
|
|
|
public function registerServices(IAppContainer $container) { |
62
|
|
|
|
63
|
|
|
$container->registerService( |
64
|
|
|
'HttpService', function() { |
65
|
|
|
return new HttpService(); |
66
|
|
|
} |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param IAppContainer $container |
73
|
|
|
*/ |
74
|
|
|
public function registerControllers(IAppContainer $container) { |
75
|
|
|
|
76
|
|
|
$container->registerService( |
77
|
|
|
'MoodController', function(IAppContainer $c) { |
78
|
|
|
return new MoodController($c->query('AppName'), $c->query('Request')); |
79
|
|
|
} |
80
|
|
|
); |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
$container->registerService( |
84
|
|
|
'ToolsController', function(IAppContainer $c) { |
85
|
|
|
return new ToolsController( |
86
|
|
|
$c->query('AppName'), $c->query('Request'), $c->query('HttpService') |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
); |
90
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param IAppContainer $container |
96
|
|
|
*/ |
97
|
|
|
public function registerCore(IAppContainer $container) { |
98
|
|
|
|
99
|
|
|
$container->registerService( |
100
|
|
|
'L10N', function(IAppContainer $c) { |
101
|
|
|
return $c->query('ServerContainer') |
102
|
|
|
->getL10N($c->query('AppName')); |
103
|
|
|
} |
104
|
|
|
); |
105
|
|
|
|
106
|
|
|
$container->registerService( |
107
|
|
|
'ActivityManager', function(IAppContainer $c) { |
108
|
|
|
return $c->query('ServerContainer') |
109
|
|
|
->getActivityManager(); |
110
|
|
|
} |
111
|
|
|
); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* |
117
|
|
|
*/ |
118
|
|
|
public function registerToActivity() { |
119
|
|
|
if (!\OCP\App::isEnabled('circles')) { |
120
|
|
|
\OC::$server->getLogger() |
121
|
|
|
->log(2, 'mood needs circles'); |
122
|
|
|
|
123
|
|
|
return; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
\OC::$server->getEventDispatcher() |
127
|
|
|
->addListener( |
128
|
|
|
'OCA\Activity::loadAdditionalScripts', function() { |
129
|
|
|
Util::addScript('circles', 'circles.v1'); |
130
|
|
|
Util::addScript('mood', 'mood'); |
131
|
|
|
Util::addScript('mood', 'mood.app'); |
132
|
|
|
Util::addScript('mood', 'mood.app.elements'); |
133
|
|
|
Util::addScript('mood', 'mood.app.actions'); |
134
|
|
|
Util::addScript('mood', 'mood.app.navigation'); |
135
|
|
|
|
136
|
|
|
Util::addStyle('mood', 'navigate'); |
137
|
|
|
} |
138
|
|
|
); |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
|