Revize a80fe7b2
Přidáno uživatelem Jan Šedivý před téměř 6 roky(ů)
app/AdminModule/component/Settings/HomepageEditForm.latte | ||
---|---|---|
1 |
{control form} |
app/AdminModule/component/Settings/HomepageEditForm.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
namespace App\AdminModule\Components; |
|
4 |
|
|
5 |
use App\Enum\EFlashMessage; |
|
6 |
use App\Model\Repository\SettingsRepository; |
|
7 |
use App\Utils\Form; |
|
8 |
use Nette\Application\UI\Control; |
|
9 |
|
|
10 |
class HomepageEditForm extends Control |
|
11 |
{ |
|
12 |
/** |
|
13 |
* @var \App\Model\Repository\SettingsRepository |
|
14 |
*/ |
|
15 |
private $settingsRepository; |
|
16 |
|
|
17 |
public function __construct(\App\Model\Repository\SettingsRepository $settingsRepository) |
|
18 |
{ |
|
19 |
$this->settingsRepository = $settingsRepository; |
|
20 |
parent::__construct(); |
|
21 |
} |
|
22 |
|
|
23 |
public function render() |
|
24 |
{ |
|
25 |
$this->template->setFile(__DIR__ . '/HomepageEditForm.latte'); |
|
26 |
$this->template->render(); |
|
27 |
} |
|
28 |
|
|
29 |
public function createComponentForm() |
|
30 |
{ |
|
31 |
$form = new Form(); |
|
32 |
|
|
33 |
$form->addText(\App\Model\Repository\SettingsRepository::KEY_HOMEPAGE_HEADER, 'Page Header') |
|
34 |
->addRule(Form::REQUIRED, 'Field %label is required.'); |
|
35 |
|
|
36 |
$form->addText(\App\Model\Repository\SettingsRepository::KEY_HOMEPAGE_MOTTO, 'Motto'); |
|
37 |
|
|
38 |
$form->addCheckbox(\App\Model\Repository\SettingsRepository::KEY_HOMEPAGE_SHOW_SIGNS_FORM, "Show Borger's number search form"); |
|
39 |
|
|
40 |
$form->addTextArea(\App\Model\Repository\SettingsRepository::KEY_HOMEPAGE_CONTENT, 'Page content', 10, 15) |
|
41 |
->setAttribute('class', 'mceEditor'); |
|
42 |
|
|
43 |
$form->addSubmit('submit', 'Save'); |
|
44 |
|
|
45 |
$form->onSuccess[] = [$this, 'formSuccess']; |
|
46 |
$form->getElementPrototype()->onsubmit('tinyMCE.triggerSave()'); |
|
47 |
|
|
48 |
$form->setDefaults($this->settingsRepository->getHomepageSettings()); |
|
49 |
|
|
50 |
return $form; |
|
51 |
} |
|
52 |
|
|
53 |
public function formSuccess(Form $form) |
|
54 |
{ |
|
55 |
$values = $form->getValues(); |
|
56 |
|
|
57 |
$result = TRUE; |
|
58 |
foreach ($values as $key => $value) |
|
59 |
{ |
|
60 |
$row = $this->settingsRepository->findBy([SettingsRepository::COLUMN_KEY => $key]); |
|
61 |
if(!$row) |
|
62 |
{ |
|
63 |
$result = FALSE; |
|
64 |
continue; |
|
65 |
} |
|
66 |
$row->update([SettingsRepository::COLUMN_VALUE => $value]); |
|
67 |
} |
|
68 |
|
|
69 |
if($result) |
|
70 |
{ |
|
71 |
$this->presenter->flashMessage('Settings were successfully changed', EFlashMessage::SUCCESS); |
|
72 |
} |
|
73 |
else |
|
74 |
{ |
|
75 |
$this->presenter->flashMessage('Settings could not be saved', EFlashMessage::ERROR); |
|
76 |
} |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 |
interface IHomepageEditFormFactory |
|
81 |
{ |
|
82 |
/** @return HomepageEditForm */ |
|
83 |
public function create(); |
|
84 |
} |
app/AdminModule/presenters/SettingsPresenter.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
namespace App\AdminModule\Presenters; |
|
4 |
|
|
5 |
|
|
6 |
use App\AdminModule\Components\IHomepageEditFormFactory; |
|
7 |
|
|
8 |
class SettingsPresenter extends BaseUserPresenter |
|
9 |
{ |
|
10 |
/** |
|
11 |
* @var IHomepageEditFormFactory |
|
12 |
*/ |
|
13 |
private $homepageEditFormFactory; |
|
14 |
|
|
15 |
public function __construct(IHomepageEditFormFactory $homepageEditFormFactory) |
|
16 |
{ |
|
17 |
$this->homepageEditFormFactory = $homepageEditFormFactory; |
|
18 |
parent::__construct(); |
|
19 |
} |
|
20 |
|
|
21 |
public function actionDefault() |
|
22 |
{ |
|
23 |
} |
|
24 |
|
|
25 |
public function createComponentHomepageEditForm() |
|
26 |
{ |
|
27 |
return $this->homepageEditFormFactory->create(); |
|
28 |
} |
|
29 |
|
|
30 |
} |
app/AdminModule/templates/@adminMenu.latte | ||
---|---|---|
19 | 19 |
Origin </a></li> |
20 | 20 |
<li class="nav-item"><a n:href="Transport:default" n:class="nav-link, $presenter->isLinkCurrent('Transport:*') ? active" title="Transport"> |
21 | 21 |
Import texts </a></li> |
22 |
<li class="nav-item"><a n:href="Settings:default" n:class="nav-link, $presenter->isLinkCurrent('Settings:*') ? active" title="Settings"> |
|
23 |
Settings </a></li> |
|
24 |
|
|
22 | 25 |
</ul> |
app/AdminModule/templates/Settings/default.latte | ||
---|---|---|
1 |
{block content} |
|
2 |
|
|
3 |
{control homepageEditForm} |
|
4 |
|
|
5 |
{block scripts} |
|
6 |
<script src="https://cdn.tiny.cloud/1/yum19i37uf1ffh15ll7d2u8jaxq0jwbbp4tzjwytli8mdg8h/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script> |
|
7 |
|
|
8 |
<script> |
|
9 |
tinyMCE.init({ |
|
10 |
mode: "specific_textareas", |
|
11 |
plugins: "link", |
|
12 |
editor_selector: "mceEditor" |
|
13 |
}); |
|
14 |
</script> |
|
15 |
{/block} |
app/FrontModule/presenters/HomepagePresenter.php | ||
---|---|---|
5 | 5 |
use App\FrontModule\Components\IUserSettingsFormFactory; |
6 | 6 |
use App\FrontModule\Components\ILoginFormFactory; |
7 | 7 |
use App\Enum\EFlashMessage; |
8 |
use App\Model\Repository\SettingsRepository; |
|
8 | 9 |
use Nette; |
9 | 10 |
|
10 | 11 |
|
... | ... | |
15 | 16 |
|
16 | 17 |
/** @var IUserSettingsFormFactory */ |
17 | 18 |
private $userSettingsFormFactory; |
19 |
/** |
|
20 |
* @var SettingsRepository |
|
21 |
*/ |
|
22 |
private $settingsRepository; |
|
18 | 23 |
|
19 | 24 |
public function __construct(ILoginFormFactory $loginFormFactory, |
20 |
IUserSettingsFormFactory $userSettingsFormFactory |
|
25 |
IUserSettingsFormFactory $userSettingsFormFactory, |
|
26 |
SettingsRepository $settingsRepository |
|
21 | 27 |
) |
22 | 28 |
{ |
23 | 29 |
parent::__construct(); |
24 | 30 |
|
25 | 31 |
$this->loginFormFactory = $loginFormFactory; |
26 | 32 |
$this->userSettingsFormFactory = $userSettingsFormFactory; |
33 |
$this->settingsRepository = $settingsRepository; |
|
27 | 34 |
} |
28 | 35 |
|
29 | 36 |
public function actionDefault() |
30 | 37 |
{ |
31 |
|
|
38 |
$settings = $this->settingsRepository->getHomepageSettings(); |
|
39 |
$this->template->settings = $settings; |
|
32 | 40 |
} |
33 | 41 |
|
34 | 42 |
public function actionUserSettings() |
app/FrontModule/templates/Homepage/default.latte | ||
---|---|---|
1 | 1 |
{block content} |
2 |
<div class="display-5">Old Babylonian Text Corpus by Cuneiform Circle</div>
|
|
2 |
<div class="display-5">{$settings[\App\Model\Repository\SettingsRepository::KEY_HOMEPAGE_HEADER]}</div>
|
|
3 | 3 |
<hr> |
4 | 4 |
|
5 | 5 |
<div class="row"> |
6 | 6 |
<div class="col"> |
7 |
{if !empty($settings[\App\Model\Repository\SettingsRepository::KEY_HOMEPAGE_MOTTO])} |
|
7 | 8 |
<dl class="row"> |
8 | 9 |
<dt class="col-sm-3">OB motto</dt> |
9 |
<dd class="col-sm-9">a-na D:na-bi-um-ma-lik a-wi-lim dam-qí-im ša D:AMAR.UTU ù D:na-bi-um GI.DUB.BA-šu |
|
10 |
ú-še-še-ru (AbB 3,33,1-4) |
|
10 |
<dd class="col-sm-9">{$settings[\App\Model\Repository\SettingsRepository::KEY_HOMEPAGE_MOTTO]} |
|
11 | 11 |
</dd> |
12 | 12 |
</dl> |
13 |
{/if} |
|
13 | 14 |
|
14 | 15 |
<div class="alert alert-primary"> |
15 | 16 |
If you have interest in Old Babylonian Akkadian Texts, don't hesitate to join us! You are welcome! |
16 | 17 |
</div> |
17 | 18 |
</div> |
19 |
{if $settings[\App\Model\Repository\SettingsRepository::KEY_HOMEPAGE_SHOW_SIGNS_FORM]} |
|
18 | 20 |
<div class="col"> |
19 | 21 |
<form method="get" action="/utf/show2borger.php"> |
20 | 22 |
<p class="blue"> |
... | ... | |
36 | 38 |
</p> |
37 | 39 |
</form> |
38 | 40 |
</div> |
41 |
{/if} |
|
39 | 42 |
</div> |
40 | 43 |
|
41 | 44 |
<hr> |
42 | 45 |
|
43 |
<p>Cuneiform Circle is a community of scholars engaged in the study of the Old Babylonian Akkadian. Our main goal is |
|
44 |
to create an Old Babylonian Text Corpus, an Old Babylonian Dictionary, and a List of Old Babylonian Cuneiform |
|
45 |
Signs.</p> |
|
46 |
|
|
47 |
<p>The Old Babylonian Text Corpus (OBTC) comprises a large text database of the Old Babylonian Akkadian Language |
|
48 |
(currently 144097 text lines, letters, documents, legal texts, royal inscriptions, omina, mathematical texts |
|
49 |
etc.).</p> |
|
50 |
|
|
51 |
<p><strong>All texts are available for search according to sign-chains (transliteration). The search engine in Old |
|
52 |
Babylonian Text Corpus verse 1 is available for everybody but the search is restricted to the following |
|
53 |
texts: Codex Hammurapi and AbB 5. The search in all 144097 lines of OBTC verse 2 is available for members |
|
54 |
only (<a n:href="Contact:howToBecomeAMember">see how to become a member</a>) .</strong></p> |
|
55 |
|
|
56 |
<p><strong>Our service includes unique searchable lists of Old Babylonian Signs Variants as appearing in the hand |
|
57 |
copies selected for the graphemic analysis.</strong></p> |
|
58 |
|
|
59 |
<p>The work on the project is in progress. We have started in 1988-89 and have accomplished significant advances |
|
60 |
since. We are currently working towards improving the quality and scope of our databases. The full access to all |
|
61 |
materials and sources is given to active members only (<a n:href="Contact:howToBecomeAMember">see our policy</a>).</p> |
|
46 |
{$settings[\App\Model\Repository\SettingsRepository::KEY_HOMEPAGE_CONTENT]|noescape} |
|
62 | 47 |
{/block} |
63 | 48 |
|
64 | 49 |
{block scripts} |
app/config/components.neon | ||
---|---|---|
25 | 25 |
- App\AdminModule\Components\ITransliterationNewFormFactory |
26 | 26 |
- App\FrontModule\Components\ICatalogueSearchFormFactory |
27 | 27 |
- App\FrontModule\Components\IUserSettingsFormFactory |
28 |
- App\AdminModule\Components\IHomepageEditFormFactory |
|
28 | 29 |
|
29 | 30 |
- App\FrontModule\Components\IKeyboard |
30 | 31 |
- App\FrontModule\Components\ITransliterationSearchResultListFactory |
app/config/model.neon | ||
---|---|---|
16 | 16 |
- App\Model\Repository\UserLogRepository |
17 | 17 |
- App\Model\Repository\UserRepository |
18 | 18 |
- App\Model\Repository\UserRoleRepository |
19 |
- App\Model\Repository\SettingsRepository |
|
19 | 20 |
|
20 | 21 |
#Facade |
21 | 22 |
- App\Model\Facade\UserFacade |
app/model/repository/SettingsRepository.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
namespace App\Model\Repository; |
|
4 |
|
|
5 |
|
|
6 |
class SettingsRepository extends Repository |
|
7 |
{ |
|
8 |
const TABLE_NAME = 'settings'; |
|
9 |
protected $tableName = self::TABLE_NAME; |
|
10 |
|
|
11 |
/** Sloupečky tabulky */ |
|
12 |
const COLUMN_KEY = 'key'; |
|
13 |
const COLUMN_VALUE = 'value'; |
|
14 |
|
|
15 |
/** Setting keys */ |
|
16 |
const KEY_HOMEPAGE_HEADER = 'homepage_header'; |
|
17 |
const KEY_HOMEPAGE_MOTTO = 'homepage_motto'; |
|
18 |
const KEY_HOMEPAGE_CONTENT = 'homepage_content'; |
|
19 |
const KEY_HOMEPAGE_SHOW_SIGNS_FORM = 'homepage_show_signs_form'; |
|
20 |
|
|
21 |
private $homepageSettings = |
|
22 |
[ |
|
23 |
self::KEY_HOMEPAGE_HEADER, |
|
24 |
self::KEY_HOMEPAGE_MOTTO, |
|
25 |
self::KEY_HOMEPAGE_CONTENT, |
|
26 |
self::KEY_HOMEPAGE_SHOW_SIGNS_FORM |
|
27 |
]; |
|
28 |
|
|
29 |
public function getHomepageSettings() |
|
30 |
{ |
|
31 |
return $this->findBy([self::COLUMN_KEY => $this->homepageSettings])->fetchPairs(self::COLUMN_KEY, self::COLUMN_VALUE); |
|
32 |
} |
|
33 |
} |
Také k dispozici: Unified diff
Re #7608 Editor pro domovskou stránku