1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* CMS Pico - Integration of Pico within your files to create websites. |
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
|
|
|
namespace OCA\CMSPico\Service; |
28
|
|
|
|
29
|
|
|
use OC\App\AppManager; |
|
|
|
|
30
|
|
|
use OCA\CMSPico\AppInfo\Application; |
31
|
|
|
use OCA\CMSPico\Model\Website; |
32
|
|
|
use Pico; |
33
|
|
|
|
34
|
|
|
class PicoService { |
35
|
|
|
|
36
|
|
|
const DIR_CONFIG = 'Pico/config/'; |
37
|
|
|
const DIR_PLUGINS = 'Pico/plugins/'; |
38
|
|
|
const DIR_THEMES = 'Pico/themes/'; |
39
|
|
|
|
40
|
|
|
private $userId; |
41
|
|
|
|
42
|
|
|
/** @var AppManager */ |
43
|
|
|
private $appManager; |
44
|
|
|
|
45
|
|
|
/** @var MiscService */ |
46
|
|
|
private $miscService; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* PicoService constructor. |
50
|
|
|
* |
51
|
|
|
* @param string $userId |
52
|
|
|
* @param AppManager $appManager |
53
|
|
|
* @param MiscService $miscService |
54
|
|
|
*/ |
55
|
|
|
function __construct($userId, AppManager $appManager, MiscService $miscService) { |
56
|
|
|
$this->userId = $userId; |
57
|
|
|
$this->appManager = $appManager; |
58
|
|
|
$this->miscService = $miscService; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param Website $website |
64
|
|
|
* |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
|
|
public function getContent(Website $website) { |
68
|
|
|
|
69
|
|
|
$appPath = MiscService::endSlash($this->appManager->getAppPath(Application::APP_NAME)); |
|
|
|
|
70
|
|
|
$pico = new Pico( |
71
|
|
|
$website->getAbsolutePath(), self::DIR_CONFIG, |
72
|
|
|
$appPath . self::DIR_PLUGINS, |
73
|
|
|
$appPath . self::DIR_THEMES |
74
|
|
|
); |
75
|
|
|
|
76
|
|
|
$this->generateConfig($pico, $website); |
77
|
|
|
$content = $pico->run(); |
78
|
|
|
|
79
|
|
|
$absolutePath = $this->getAbsolutePathFromPage($pico); |
80
|
|
|
$website->contentMustBeLocal($absolutePath); |
81
|
|
|
$website->viewerMustHaveAccess($absolutePath, $pico->getFileMeta()); |
82
|
|
|
|
83
|
|
|
return $content; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param Pico $pico |
89
|
|
|
* @param Website $website |
90
|
|
|
*/ |
91
|
|
|
private function generateConfig(Pico &$pico, Website $website) { |
92
|
|
|
$pico->setConfig( |
93
|
|
|
[ |
94
|
|
|
'content_dir' => 'content/', |
95
|
|
|
'content_ext' => '.md', |
96
|
|
|
'theme' => $website->getTheme(), |
97
|
|
|
'site_title' => $website->getName(), |
98
|
|
|
'base_url' => \OC::$WEBROOT . $website->getSite() |
99
|
|
|
] |
100
|
|
|
); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param Pico $pico |
106
|
|
|
* |
107
|
|
|
* @return string |
108
|
|
|
*/ |
109
|
|
|
private function getAbsolutePathFromPage(Pico $pico) { |
110
|
|
|
return $pico->getConfig()['content_dir'] . $pico->getCurrentPage()['id'] . ' . md'; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths