Skip to content

Commit fa269f0

Browse files
author
Jan Staněk
authored
Merge pull request #357 from jan-stanek/upravy
obsah s poradatelem
2 parents 09a8918 + fea64df commit fa269f0

14 files changed

+162
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\WebModule\Components;
4+
5+
6+
/**
7+
* Factory komponenty s informací o pořadateli.
8+
*
9+
* @author Jan Staněk <[email protected]>
10+
*/
11+
interface IOrganizerContentControlFactory
12+
{
13+
/**
14+
* @return OrganizerContentControl
15+
*/
16+
public function create();
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\WebModule\Components;
4+
5+
use Nette\Application\UI\Control;
6+
7+
8+
/**
9+
* Komponenta s informací o pořadateli.
10+
*
11+
* @author Jan Staněk <[email protected]>
12+
*/
13+
class OrganizerContentControl extends Control
14+
{
15+
/**
16+
* @param $content
17+
*/
18+
public function render($content)
19+
{
20+
$template = $this->template;
21+
$template->setFile(__DIR__ . '/templates/organizer_content.latte');
22+
23+
$template->heading = $content->getHeading();
24+
$template->organizer = $content->getOrganizer();
25+
26+
$template->render();
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="row" n:ifcontent>
2+
<div class="col-sm-12" n:ifcontent>
3+
<h3 n:ifcontent>{$heading}</h3>
4+
</div>
5+
</div>
6+
{$organizer|noescape}
7+
<img src="img/logo.png" width="100%"/>

app/WebModule/presenters/PagePresenter.php

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use App\WebModule\Components\IImageContentControlFactory;
1212
use App\WebModule\Components\ILectorsContentControlFactory;
1313
use App\WebModule\Components\INewsContentControlFactory;
14+
use App\WebModule\Components\IOrganizerContentControlFactory;
1415
use App\WebModule\Components\IPlaceContentControlFactory;
1516
use App\WebModule\Components\IProgramsContentControlFactory;
1617
use App\WebModule\Components\ITextContentControlFactory;
@@ -104,6 +105,12 @@ class PagePresenter extends WebBasePresenter
104105
*/
105106
public $lectorsContentControlFactory;
106107

108+
/**
109+
* @var IOrganizerContentControlFactory
110+
* @inject
111+
*/
112+
public $organizerContentControlFactory;
113+
107114

108115
public function renderDefault($slug)
109116
{
@@ -191,4 +198,9 @@ protected function createComponentLectorsContent()
191198
{
192199
return $this->lectorsContentControlFactory->create();
193200
}
201+
202+
protected function createComponentOrganizerContent()
203+
{
204+
return $this->organizerContentControlFactory->create();
205+
}
194206
}

app/config/config.neon

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ services:
181181
- App\WebModule\Components\IUsersContentControlFactory
182182
- App\WebModule\Components\ILectorsContentControlFactory
183183
- App\WebModule\Components\IApplicationsGridControlFactory
184+
- App\WebModule\Components\IOrganizerContentControlFactory
184185

185186
- App\WebModule\Forms\BaseForm
186187
- App\WebModule\Forms\AdditionalInformationForm

app/lang/admin.cs_CZ.neon

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ cms:
8989
pages_content_news_count_note: "Pokud necháte počet prázdný, zobrazí se všechny aktuality."
9090
pages_content_text: "Text"
9191
pages_content_users_roles: "Zobrazované role"
92+
pages_content_organizer: "Pořadatel"
9293

9394
news_heading: "Aktuality"
9495
news_published: "Zveřejnit"

app/lang/common.cs_CZ.neon

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ content:
4949
lectors: "Přehled lektorů"
5050
blocks: "Program semináře"
5151
capacities: "Kapacita semináře"
52+
organizer: "Pořadatel"
5253

5354
default_heading:
5455
text: ""
@@ -64,6 +65,7 @@ content:
6465
lectors: "Přehled lektorů"
6566
blocks: "Program semináře"
6667
capacities: "Kapacita semináře"
68+
organizer: "Pořadatel"
6769

6870
area:
6971
main: "Hlavní oblast"

app/model/CMS/Content/Content.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
* "users_content" = "UsersContent",
3131
* "lectors_content" = "LectorsContent",
3232
* "blocks_content" = "BlocksContent",
33-
* "capacities_content" = "CapacitiesContent"
33+
* "capacities_content" = "CapacitiesContent",
34+
* "organizer_content" = "OrganizerContent"
3435
* })
3536
*/
3637
abstract class Content implements IContent
@@ -100,6 +101,11 @@ abstract class Content implements IContent
100101
*/
101102
const CAPACITIES = 'capacities';
102103

104+
/**
105+
* OrganizerContent
106+
*/
107+
const ORGANIZER = 'organizer';
108+
103109

104110
/**
105111
* Hlavní oblast stránky.
@@ -111,6 +117,7 @@ abstract class Content implements IContent
111117
*/
112118
const SIDEBAR = 'sidebar';
113119

120+
114121
public static $types = [
115122
self::TEXT,
116123
self::IMAGE,
@@ -124,7 +131,8 @@ abstract class Content implements IContent
124131
self::USERS,
125132
self::LECTORS,
126133
self::BLOCKS,
127-
self::CAPACITIES
134+
self::CAPACITIES,
135+
self::ORGANIZER
128136
];
129137

130138
public static $areas = [
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
namespace App\Model\CMS\Content;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
use Nette\Application\UI\Form;
7+
8+
9+
/**
10+
* Entita obsahu s informací o pořadateli.
11+
*
12+
* @author Jan Staněk <[email protected]>
13+
* @ORM\Entity
14+
* @ORM\Table(name="organizer_content")
15+
*/
16+
class OrganizerContent extends Content implements IContent
17+
{
18+
protected $type = Content::ORGANIZER;
19+
20+
/**
21+
* Pořadatel.
22+
* @ORM\Column(type="string", nullable=true)
23+
* @var string
24+
*/
25+
protected $organizer;
26+
27+
28+
/**
29+
* @return string
30+
*/
31+
public function getOrganizer()
32+
{
33+
return $this->organizer;
34+
}
35+
36+
/**
37+
* @param string $organizer
38+
*/
39+
public function setOrganizer($organizer)
40+
{
41+
$this->organizer = $organizer;
42+
}
43+
44+
/**
45+
* Přidá do formuláře pro editaci stránky formulář pro úpravu obsahu.
46+
* @param Form $form
47+
* @return Form
48+
*/
49+
public function addContentForm(Form $form)
50+
{
51+
parent::addContentForm($form);
52+
53+
$formContainer = $form[$this->getContentFormName()];
54+
55+
$formContainer->addText('organizer', 'admin.cms.pages_content_organizer')
56+
->setDefaultValue($this->organizer);
57+
58+
return $form;
59+
}
60+
61+
/**
62+
* Zpracuje při uložení stránky část formuláře týkající se obsahu.
63+
* @param Form $form
64+
* @param \stdClass $values
65+
*/
66+
public function contentFormSucceeded(Form $form, \stdClass $values)
67+
{
68+
parent::contentFormSucceeded($form, $values);
69+
$values = $values[$this->getContentFormName()];
70+
$this->organizer = $values['organizer'];
71+
}
72+
}

app/model/User/CustomInputValue/CustomSelectValue.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CustomSelectValue extends CustomInputValue implements ICustomInputValue
1616
{
1717
/**
1818
* Vybraná položka výběrového pole přihlášky.
19-
* @ORM\Column(type="integer")
19+
* @ORM\Column(type="integer", nullable=true)
2020
* @var int
2121
*/
2222
protected $value;

migrations/initial_data.sql

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
55

66
INSERT INTO `content` (`id`, `page_id`, `heading`, `area`, `position`, `type`) VALUES
77
(1, 1, 'Úspěšně jste nainstalovali SRS. Gratulujeme!', 'main', 1, 'text_content'),
8-
(2, 1, 'Pořadatel', 'sidebar', 1, 'text_content'),
9-
(3, 1, '', 'sidebar', 2, 'image_content');
8+
(2, 1, 'Pořadatel', 'sidebar', 1, 'organizer_content');
109

11-
INSERT INTO `image_content` (`id`, `image`, `align`, `width`, `height`) VALUES
12-
(3, '/logo/skaut.png', 'center', 120, 150);
10+
INSERT INTO `organizer_content` (`id`, `organizer`) VALUES
11+
(2, 'Junák - český skaut, z. s.');
1312

1413
INSERT INTO `page` (`id`, `name`, `slug`, `position`, `public`) VALUES
1514
(1, 'Homepage', '/', 1, 1);
@@ -119,5 +118,4 @@ INSERT INTO `settings` (`item`, `value`) VALUES
119118
('variable_symbol_code', '');
120119

121120
INSERT INTO `text_content` (`id`, `text`) VALUES
122-
(1, '<p>Obsah této stránky můžete změnit v administraci v sekci Web.</p>'),
123-
(2, '<p>Junák – český skaut</p>');
121+
(1, '<p>Obsah této stránky můžete změnit v administraci v sekci Web.</p>');

migrations/initial_schema.sql

+7
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ CREATE TABLE `news_content` (
242242
CONSTRAINT `FK_A9212C4FBF396750` FOREIGN KEY (`id`) REFERENCES `content` (`id`) ON DELETE CASCADE
243243
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
244244

245+
CREATE TABLE `organizer_content` (
246+
`id` int(11) NOT NULL,
247+
`organizer` VARCHAR(255) DEFAULT NULL,
248+
PRIMARY KEY (`id`),
249+
CONSTRAINT `FK_B7F48760BF396750` FOREIGN KEY (`id`) REFERENCES `content` (`id`) ON DELETE CASCADE
250+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
251+
245252
CREATE TABLE `page` (
246253
`id` int(11) NOT NULL AUTO_INCREMENT,
247254
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,

www/files/logo/skaut.png

-50.5 KB
Binary file not shown.

www/img/logo.png

68.4 KB
Loading

0 commit comments

Comments
 (0)