Skip to content

Commit

Permalink
přehled lektorů
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-stanek committed Aug 23, 2017
1 parent 70fd479 commit 05400f6
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<ul class="list-group">
{foreach $editedTemplate->getVariables() as $variable}
<li class="list-group-item">
<b>%{$translator->translate('common.mailing.variable_name.' . $variable->getName())}%</b>
<strong>%{$translator->translate('common.mailing.variable_name.' . $variable->getName())}%</strong>
-
{$translator->translate('common.mailing.variable_description.' . $variable->getName())}
</li>
Expand Down
17 changes: 17 additions & 0 deletions app/WebModule/components/ILectorsContentControlFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\WebModule\Components;


/**
* Factory komponenty s přehledem lektorů.
*
* @author Jan Staněk <[email protected]>
*/
interface ILectorsContentControlFactory
{
/**
* @return LectorsContentControl
*/
public function create();
}
51 changes: 51 additions & 0 deletions app/WebModule/components/LectorsContentControl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace App\WebModule\Components;

use App\Model\ACL\Role;
use App\Model\ACL\RoleRepository;
use App\Model\User\UserRepository;
use Nette\Application\UI\Control;


/**
* Komponenta s přehledem lektorů.
*
* @author Jan Staněk <[email protected]>
*/
class LectorsContentControl extends Control
{
/** @var UserRepository */
private $userRepository;

/** @var RoleRepository */
private $roleRepository;


/**
* UsersContentControl constructor.
* @param UserRepository $userRepository
* @param RoleRepository $roleRepository
*/
public function __construct(UserRepository $userRepository, RoleRepository $roleRepository)
{
parent::__construct();

$this->userRepository = $userRepository;
$this->roleRepository = $roleRepository;
}

/**
* @param $content
*/
public function render($content)
{
$template = $this->template;
$template->setFile(__DIR__ . '/templates/lectors_content.latte');

$template->heading = $content->getHeading();
$template->lectors = $this->userRepository->findAllInRole($this->roleRepository->findBySystemName(Role::LECTOR));

$template->render();
}
}
58 changes: 58 additions & 0 deletions app/WebModule/components/templates/lectors_content.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<div class="lectors-content">
<div class="row">
<div class="col-sm-12">
<h3 n:ifcontent>{$heading}</h3>
</div>
</div>

<div class="row">
<div class="col-sm-12">
{foreach $lectors as $lector}
<h4>{$lector->getDisplayName()}</h4>
<div class="well">
<table class="table table-form">
<tr>
<td>
{if $lector->getPhoto()}
<img src="{$basePath}/files/user_photos/{$lector->getPhoto()}"/>
{/if}
</td>
<td>
<table class="table table-form" style="background-color: transparent">
<col class="col-sm-3 col-xs-3">
<col class="col-sm-9 col-xs-9">

{if $lector->getAbout()}
<tr>
<th >{_web.lectors_content.about_me}</th>
<td>{$lector->getAbout()}</td>
</tr>
{/if}

{if $lector->getLecturersBlocks()->count() > 0}
<tr>
<th>{_web.lectors_content.blocks}</th>
<td>
<ul class="no-bullets no-margin">
{foreach $lector->getLecturersBlocks() as $block}
<li>
<strong>{$block->getName()}</strong>
{if $block->getPerex()}
-
{$block->getPerex()}
{/if}
</li>
{/foreach}
</ul>
</td>
</tr>
{/if}
</table>
</td>
</tr>
</table>
</div>
{/foreach}
</div>
</div>
</div>
12 changes: 12 additions & 0 deletions app/WebModule/presenters/PagePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\WebModule\Components\IFaqContentControlFactory;
use App\WebModule\Components\IHtmlContentControlFactory;
use App\WebModule\Components\IImageContentControlFactory;
use App\WebModule\Components\ILectorsContentControlFactory;
use App\WebModule\Components\INewsContentControlFactory;
use App\WebModule\Components\IPlaceContentControlFactory;
use App\WebModule\Components\IProgramsContentControlFactory;
Expand Down Expand Up @@ -97,6 +98,12 @@ class PagePresenter extends WebBasePresenter
*/
public $usersContentControlFactory;

/**
* @var ILectorsContentControlFactory
* @inject
*/
public $lectorsContentControlFactory;


public function renderDefault($slug)
{
Expand Down Expand Up @@ -179,4 +186,9 @@ protected function createComponentUsersContent()
{
return $this->usersContentControlFactory->create();
}

protected function createComponentLectorsContent()
{
return $this->lectorsContentControlFactory->create();
}
}
1 change: 1 addition & 0 deletions app/config/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ services:
- App\WebModule\Components\IProgramsContentControlFactory
- App\WebModule\Components\ITextContentControlFactory
- App\WebModule\Components\IUsersContentControlFactory
- App\WebModule\Components\ILectorsContentControlFactory
- App\WebModule\Forms\BaseForm
- App\WebModule\Forms\AdditionalInformationForm
- App\WebModule\Forms\ApplicationForm
Expand Down
2 changes: 2 additions & 0 deletions app/lang/common.cs_CZ.neon
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ content:
place: "Místo"
programs: "Výběr programů"
users: "Přehled uživatelů"
lectors: "Přehled lektorů"
blocks: "Program semináře"
capacities: "Kapacita semináře"

Expand All @@ -60,6 +61,7 @@ content:
place: "Místo"
programs: "Výběr programů"
users: "Přehled uživatelů"
lectors: "Přehled lektorů"
blocks: "Program semináře"
capacities: "Kapacita semináře"

Expand Down
7 changes: 5 additions & 2 deletions app/lang/web.cs_CZ.neon
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ programs_content:
help_legend_optional: "Programy, na které se lze přihlásit."
help_legend_mandatory: "Programy, které jsou povinné."


users_content:
list_empty: "Žádný uživatel k zobrazení."
list_empty: "Žádný uživatel k zobrazení."

lectors_content:
about_me: "O mně"
blocks: "Programové bloky"
7 changes: 7 additions & 0 deletions app/model/CMS/Content/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* "programs_content" = "ProgramsContent",
* "image_content" = "ImageContent",
* "users_content" = "UsersContent",
* "lectors_content" = "LectorsContent",
* "blocks_content" = "BlocksContent",
* "capacities_content" = "CapacitiesContent"
* })
Expand Down Expand Up @@ -84,6 +85,11 @@ abstract class Content implements IContent
*/
const USERS = 'users';

/**
* LectorsContent.
*/
const LECTORS = 'lectors';

/**
* BlocksContent.
*/
Expand Down Expand Up @@ -116,6 +122,7 @@ abstract class Content implements IContent
self::PLACE,
self::PROGRAMS,
self::USERS,
self::LECTORS,
self::BLOCKS,
self::CAPACITIES
];
Expand Down
18 changes: 18 additions & 0 deletions app/model/CMS/Content/LectorsContent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Model\CMS\Content;

use Doctrine\ORM\Mapping as ORM;


/**
* Entita obsahu se seznamem lektorů.
*
* @author Jan Staněk <[email protected]>
* @ORM\Entity
* @ORM\Table(name="lectors_content")
*/
class LectorsContent extends Content implements IContent
{
protected $type = Content::LECTORS;
}
30 changes: 30 additions & 0 deletions migrations/Version20170823205705.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20170823205705 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('CREATE TABLE lectors_content (id INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE lectors_content ADD CONSTRAINT FK_5B02C449BF396750 FOREIGN KEY (id) REFERENCES content (id) ON DELETE CASCADE');
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

0 comments on commit 05400f6

Please sign in to comment.