* Layout head-Bereich: canonical-Tag und title-Tag, sowie robots/noindex,nofollow für einige Seiten * Abfahrtsorte in der Suchmaske auf der Startseite angepasst * Traveltainment-Suche: Suchergebnisseite, CMS-Template (mit Suchmaske oben), Sidebar-Widget * Behoben: Vorschaubild von Reiseprogrammen wird nicht mehr angezeigt * Bewertung für google-Ergebniseintrag (In der Sidebar) * E-Mail-Signatur korrigiert * Eltern-Template wird dynamisch bestimmt / Template ohne "Rahmen" wird für AJAX-Anfragen verwendet * Termin-Status in Termintabelle auf Reiseprogrammseiten anzeigen * /create-tree : Reiseführer-Unterseiten mit Reiseführer-Hauptseite verknüpfen * Behoben: Exception bei Öffnen bestimmter Reisetermine; Bei diesen Terminen fehlen die Abfahrtsorte * Behoben: Video klappt erst beim 2. Klick aus git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3299 f459cee4-fb09-11de-96c3-f9c5f16c3c76
113 lines
No EOL
3.1 KiB
PHP
113 lines
No EOL
3.1 KiB
PHP
<?php
|
|
/**
|
|
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
|
|
* @date 02/10/2017
|
|
*/
|
|
|
|
namespace AppBundle\Twig;
|
|
|
|
|
|
use AppBundle\Service\KeywordService;
|
|
use AppBundle\Util;
|
|
use Symfony\Component\HttpFoundation\RequestStack;
|
|
|
|
class AppExtension extends \Twig_Extension
|
|
{
|
|
private $environment;
|
|
private $keywordService;
|
|
private $requestStack;
|
|
private $template;
|
|
|
|
public function __construct(\Twig_Environment $env, KeywordService $keywordService, RequestStack $requestStack)
|
|
{
|
|
$this->environment = $env;
|
|
$this->keywordService = $keywordService;
|
|
$this->requestStack = $requestStack;
|
|
}
|
|
|
|
public function getFilters()
|
|
{
|
|
return [
|
|
'stripslashes' => new \Twig_SimpleFilter('stripslashes', [$this, 'stripslashesFilter'], [
|
|
'is_safe' => ['html']
|
|
]),
|
|
'keywords' => new \Twig_SimpleFilter('keywords', [$this, 'keywordsFilter'], [
|
|
'is_safe' => ['html']
|
|
]),
|
|
];
|
|
}
|
|
|
|
public function getFunctions()
|
|
{
|
|
return [
|
|
'form_field' => new \Twig_SimpleFunction('form_field', [$this, 'formField'], [
|
|
'is_safe' => ['html']
|
|
]),
|
|
'form_field_pho' => new \Twig_SimpleFunction('form_field_pho', [$this, 'formFieldPho'], [
|
|
'is_safe' => ['html']
|
|
]),
|
|
'get_base_template' => new \Twig_SimpleFunction('get_base_template', [$this, 'getBaseTemplate']),
|
|
'get_base_url' => new \Twig_SimpleFunction('get_base_url', [$this, 'getBaseUrl']),
|
|
];
|
|
}
|
|
|
|
public function stripslashesFilter($v)
|
|
{
|
|
return stripslashes($v);
|
|
}
|
|
|
|
public function keywordsFilter($v)
|
|
{
|
|
return $this->keywordService->addKeywordLinksToHtml($v, 'keyword-link');
|
|
}
|
|
|
|
public function getBaseTemplate()
|
|
{
|
|
return ($this->requestStack->getCurrentRequest()->isXmlHttpRequest() ? 'ajax' : 'base') .'.html.twig';
|
|
}
|
|
|
|
public function getBaseUrl()
|
|
{
|
|
return Util::getBaseUrl();
|
|
}
|
|
|
|
public function formField($form, $label = null, $opt = null)
|
|
{
|
|
$this->template = $this->environment->loadTemplate( '::default/form/helpers.html.twig' );
|
|
return $this->template->renderBlock('form_field', [
|
|
'form' => $form,
|
|
'label' => $label,
|
|
'opt' => $opt
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Form field with placeholder only
|
|
*
|
|
* @param $form
|
|
* @param null $label
|
|
* @param null $opt
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function formFieldPho($form, $label = null, $opt = [])
|
|
{
|
|
$this->template = $this->environment->loadTemplate( '::default/form/helpers.html.twig' );
|
|
|
|
return $this->template->renderBlock('form_field_pho', [
|
|
'form' => $form,
|
|
'label' => $label,
|
|
'opt' => $opt
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Returns the name of the extension.
|
|
*
|
|
* @return string The extension name
|
|
*/
|
|
public function getName()
|
|
{
|
|
return 'app_extension';
|
|
}
|
|
} |