75 lines
2.3 KiB
PHP
75 lines
2.3 KiB
PHP
<?php
|
|
/*************************************************************************************/
|
|
/* Copyright (c) Open Studio */
|
|
/* web : https://open.studio */
|
|
/* */
|
|
/* For the full copyright and license information, please view the LICENSE */
|
|
/* file that was distributed with this source code. */
|
|
/*************************************************************************************/
|
|
|
|
/**
|
|
* Created by Franck Allimant, OpenStudio <fallimant@openstudio.fr>
|
|
* Date: 02/01/2021 18:46
|
|
*/
|
|
namespace Agenda\Hook;
|
|
|
|
use Agenda\Agenda;
|
|
use Agenda\Model\AgendaContentDateQuery;
|
|
use Thelia\Core\Event\Hook\HookRenderEvent;
|
|
use Thelia\Core\Hook\BaseHook;
|
|
use Thelia\Model\ContentQuery;
|
|
|
|
class HookManager extends BaseHook
|
|
{
|
|
/**
|
|
* @param HookRenderEvent $event
|
|
* @throws \Propel\Runtime\Exception\PropelException
|
|
*/
|
|
public function onContentEditRightColumnBottom(HookRenderEvent $event)
|
|
{
|
|
$content = ContentQuery::create()->findPk((int) $event->getArgument('content_id'));
|
|
|
|
if (! Agenda::estContenuAgenda($content)) {
|
|
return;
|
|
}
|
|
|
|
$date_debut = $date_fin = $heure = '';
|
|
|
|
if (null !== $agenda = AgendaContentDateQuery::create()->findOneByContentId($content->getId())) {
|
|
$dateFormat = $this->getSession()->getLang()->getDateFormat();
|
|
|
|
$date_debut = $agenda->getDateDebut()->format($dateFormat);
|
|
$date_fin = $agenda->getDateFin()->format($dateFormat);
|
|
$heure = $agenda->getHeure();
|
|
}
|
|
|
|
$event->add(
|
|
$this->render(
|
|
"agenda.html",
|
|
[
|
|
'agenda_date_debut' => $date_debut,
|
|
'agenda_date_fin' => $date_fin,
|
|
'agenda_heure' => $heure,
|
|
]
|
|
)
|
|
);
|
|
}
|
|
|
|
public function onContentEditJs(HookRenderEvent $event)
|
|
{
|
|
$event->add(
|
|
$this->render(
|
|
"agenda-js.html"
|
|
)
|
|
);
|
|
}
|
|
public function onMainHeadCss(HookRenderEvent $event)
|
|
{
|
|
$event->add(
|
|
$this->render(
|
|
"agenda-css.html"
|
|
)
|
|
);
|
|
}
|
|
}
|