/
image_editor.php
40 lines (31 loc) · 1.22 KB
/
image_editor.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
<?php
namespace Concrete\Controller\SinglePage\Dashboard\System\Files;
use Concrete\Core\Entity\File\Image\Editor;
use Concrete\Core\ImageEditor\ImageEditorService;
use Concrete\Core\Page\Controller\DashboardPageController;
class ImageEditor extends DashboardPageController
{
/** @var ImageEditorService */
protected $editorService;
public function on_start()
{
parent::on_start();
$this->editorService = $this->app->make(ImageEditorService::class);
}
public function view()
{
if ($this->request->getMethod() === "POST") {
if ($this->token->validate("save_editor_settings")) {
$editor = $this->editorService->getEditorByHandle($this->request->request->get("activeEditor"));
if ($editor instanceof Editor) {
$this->editorService->setActiveEditor($editor);
}
$this->set('success', t("The default editor has been successfully changed."));
} else {
$this->error->add("Invalid Token.");
}
}
$this->set('editorList', $this->editorService->getEditorList());
$this->set('activeEditor', $this->editorService->getActiveEditor());
}
}