- Use symfony twig to render tpls - Remove double codepull/2715/head
parent
5bf2ee33b7
commit
87bc659c2a
@ -1,16 +0,0 @@ |
||||
<div class="page-header"> |
||||
<h4>{{ "SystemAnnouncements" | get_lang }}</h4> |
||||
</div> |
||||
|
||||
{% if not announcement is empty %} |
||||
<article id="announcement-{{ announcement.id }}}"> |
||||
<div class="page-header"> |
||||
<h3>{{ announcement.title }}</h3> |
||||
{{ announcement.content }} |
||||
</div> |
||||
</article> |
||||
{% else %} |
||||
<div class="alert alert-danger" role="alert"> |
||||
{{ "NoResults" | get_lang }} |
||||
</div> |
||||
{% endif %} |
@ -1,31 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
require_once 'main/inc/global.inc.php'; |
||||
|
||||
$tool_name = get_lang('SystemAnnouncements'); |
||||
$visibility = SystemAnnouncementManager::getCurrentUserVisibility(); |
||||
$id = isset($_GET['id']) ? $_GET['id'] : 0; |
||||
|
||||
if (empty($id)) { |
||||
$content = SystemAnnouncementManager::displayAnnouncementsSlider($visibility); |
||||
} else { |
||||
$content = SystemAnnouncementManager::displayAnnouncement($id, $visibility); |
||||
} |
||||
|
||||
$tpl = new Template($tool_name); |
||||
|
||||
if (api_is_platform_admin()) { |
||||
$actionEdit = Display::url( |
||||
Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), [], ICON_SIZE_MEDIUM), |
||||
api_get_path(WEB_PATH).'main/admin/system_announcements.php' |
||||
); |
||||
|
||||
$tpl->assign( |
||||
'actions', |
||||
Display::toolbarAction('toolbar', [$actionEdit]) |
||||
); |
||||
} |
||||
|
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
@ -0,0 +1,81 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\Controller; |
||||
|
||||
use Chamilo\CoreBundle\Framework\PageController; |
||||
use Chamilo\PageBundle\Entity\Block; |
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; |
||||
use Symfony\Component\HttpFoundation\Request; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use Symfony\Component\Routing\Annotation\Route; |
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; |
||||
|
||||
/** |
||||
* Class IndexController |
||||
* author Julio Montoya <gugli100@gmail.com>. |
||||
* @Route("/news") |
||||
* |
||||
* @package Chamilo\CoreBundle\Controller |
||||
*/ |
||||
class NewsController extends BaseController |
||||
{ |
||||
/** |
||||
* The Chamilo index home page. |
||||
* |
||||
* @Route("/", name="news_index", methods={"GET", "POST"}, options={"expose"=true}) |
||||
* |
||||
* @return Response |
||||
*/ |
||||
public function indexAction(Request $request): Response |
||||
{ |
||||
$toolBar = ''; |
||||
if ($this->isGranted('ROLE_ADMIN')) { |
||||
$actionEdit = \Display::url( |
||||
\Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), [], ICON_SIZE_MEDIUM), |
||||
api_get_path(WEB_PATH).'main/admin/system_announcements.php' |
||||
); |
||||
$toolBar = \Display::toolbarAction('toolbar', [$actionEdit]); |
||||
} |
||||
|
||||
return $this->render( |
||||
'@ChamiloCore/News/index.html.twig', |
||||
[ |
||||
'toolbar' => $toolBar |
||||
] |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* The Chamilo index home page. |
||||
* |
||||
* @Route("/{id}", name="news", methods={"GET", "POST"}, options={"expose"=true}) |
||||
* |
||||
* @return Response |
||||
*/ |
||||
public function newsAction($id = null) |
||||
{ |
||||
$visibility = \SystemAnnouncementManager::getCurrentUserVisibility(); |
||||
|
||||
$toolBar = ''; |
||||
if (empty($id)) { |
||||
$content = \SystemAnnouncementManager::getAnnouncements($visibility); |
||||
|
||||
return $this->render( |
||||
'@ChamiloCore/News/slider.html.twig', |
||||
[ |
||||
'announcements' => $content |
||||
] |
||||
); |
||||
} else { |
||||
$content = \SystemAnnouncementManager::getAnnouncement($id, $visibility); |
||||
|
||||
return $this->render( |
||||
'@ChamiloCore/News/view.html.twig', |
||||
[ |
||||
'announcement' => $content |
||||
] |
||||
); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,8 @@ |
||||
{% extends "@ChamiloTheme/Layout/layout_one_col.html.twig" %} |
||||
|
||||
{% block content %} |
||||
{% autoescape false %} |
||||
{{ toolbar }} |
||||
{{ render(controller('ChamiloCoreBundle:News:news')) }} |
||||
{% endautoescape %} |
||||
{% endblock %} |
@ -0,0 +1,24 @@ |
||||
{% extends "@ChamiloTheme/Layout/layout_one_col.html.twig" %} |
||||
|
||||
{% block content %} |
||||
{% autoescape false %} |
||||
<div class="page-header"> |
||||
<h4>{{ "SystemAnnouncements" | get_lang }}</h4> |
||||
</div> |
||||
|
||||
{% if not announcement is empty %} |
||||
<article id="announcement-{{ announcement.id }}}"> |
||||
<div class="page-header"> |
||||
<h3>{{ announcement.title }}</h3> |
||||
{{ announcement.content }} |
||||
</div> |
||||
</article> |
||||
{% else %} |
||||
<div class="alert alert-danger" role="alert"> |
||||
{{ "NoResults" | get_lang }} |
||||
</div> |
||||
{% endif %} |
||||
{% endautoescape %} |
||||
{% endblock %} |
||||
|
||||
|
Loading…
Reference in new issue