Initial commit: apps.supersam24.ru

This commit is contained in:
root committed 2026-10-22 00:04:27 +03:00
commit e955e1da36
6566 files changed
+1271095

No files matched your search

@@ -0,0 +1,48 @@
<?php
/**
* This file is part of TwigView.
*
** (c) 2015 Cees-Jan Kiewiet
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace WyriHaximus\TwigView\Event;
use Cake\Event\Event;
use WyriHaximus\TwigView\View\TwigView;
class ConstructEvent extends Event
{
const EVENT = 'TwigView.TwigView.construct';
/**
* @param TwigView $twigView
* @param \Twig_Environment $twig
* @return static
*/
public static function create(TwigView $twigView, \Twig_Environment $twig)
{
return new static(static::EVENT, $twigView, [
'twigView' => $twigView,
'twig' => $twig,
]);
}
/**
* @return TwigView
*/
public function getTwigView()
{
return $this->getData()['twigView'];
}
/**
* @return \Twig_Environment
*/
public function getTwig()
{
return $this->getData()['twig'];
}
}
@@ -0,0 +1,51 @@
<?php
/**
* This file is part of TwigView.
*
** (c) 2015 Cees-Jan Kiewiet
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace WyriHaximus\TwigView\Event;
use Cake\Event\Event;
class EnvironmentConfigEvent extends Event
{
const EVENT = 'TwigView.TwigView.environment';
/**
* @var array
*/
private $config = [];
/**
* @param array $config
*
* @return static
*/
public static function create(array $config)
{
$event = new static(static::EVENT);
$event->setConfig($config);
return $event;
}
/**
* @return array
*/
public function getConfig()
{
return $this->config;
}
/**
* @param array $config
*/
public function setConfig(array $config)
{
$this->config = array_replace_recursive($this->config, $config);
}
}
@@ -0,0 +1,116 @@
<?php
/**
* This file is part of TwigView.
*
** (c) 2014 Cees-Jan Kiewiet
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace WyriHaximus\TwigView\Event;
use Aptoma\Twig\Extension\MarkdownEngineInterface;
use Aptoma\Twig\Extension\MarkdownExtension;
use Aptoma\Twig\TokenParser\MarkdownTokenParser;
use Ajgl\Twig\Extension\BreakpointExtension;
use Asm89\Twig\CacheExtension\CacheStrategy\LifetimeCacheStrategy;
use Asm89\Twig\CacheExtension\Extension as CacheExtension;
use Cake\Core\Configure;
use Cake\Event\EventListenerInterface;
use Jasny\Twig\ArrayExtension;
use Jasny\Twig\DateExtension;
use Jasny\Twig\PcreExtension;
use Jasny\Twig\TextExtension;
use Umpirsky\Twig\Extension\PhpFunctionExtension;
use WyriHaximus\TwigView\Lib\Cache;
use WyriHaximus\TwigView\Lib\Twig\Extension;
use WyriHaximus\TwigView\Lib\Twig\TokenParser;
/**
* Class ExtensionsListener
* @package WyriHaximus\TwigView\Event
*/
class ExtensionsListener implements EventListenerInterface
{
/**
* Return implemented events.
*
* @return array
*/
public function implementedEvents()
{
return [
ConstructEvent::EVENT => 'construct',
];
}
/**
* Event handler.
*
* @param ConstructEvent $event Event.
*
* @return void
*/
// @codingStandardsIgnoreStart
public function construct(ConstructEvent $event)
{
// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreStart
// Twig core extensions
$event->getTwig()->addExtension(new \Twig_Extension_StringLoader);
$event->getTwig()->addExtension(new \Twig_Extension_Debug);
// CakePHP bridging extensions
$event->getTwig()->addExtension(new Extension\I18n);
$event->getTwig()->addExtension(new Extension\Time);
$event->getTwig()->addExtension(new Extension\Basic);
$event->getTwig()->addExtension(new Extension\Number);
$event->getTwig()->addExtension(new Extension\Utils);
$event->getTwig()->addExtension(new Extension\Arrays);
$event->getTwig()->addExtension(new Extension\Strings);
$event->getTwig()->addExtension(new Extension\Inflector);
if (
!Configure::check('WyriHaximus.TwigView.flags.potentialDangerous') ||
(
Configure::check('WyriHaximus.TwigView.flags.potentialDangerous') &&
Configure::read('WyriHaximus.TwigView.flags.potentialDangerous') === true
)
) {
$event->getTwig()->addExtension(new Extension\PotentialDangerous);
}
// Markdown extension
if (
Configure::check('WyriHaximus.TwigView.markdown.engine') &&
Configure::read('WyriHaximus.TwigView.markdown.engine') instanceof MarkdownEngineInterface
) {
$engine = Configure::read('WyriHaximus.TwigView.markdown.engine');
$event->getTwig()->addExtension(new MarkdownExtension($engine));
$event->getTwig()->addTokenParser(new MarkdownTokenParser($engine));
}
// Third party cache extension
$cacheProvider = new Cache();
$cacheStrategy = new LifetimeCacheStrategy($cacheProvider);
$cacheExtension = new CacheExtension($cacheStrategy);
$event->getTwig()->addExtension($cacheExtension);
// jasny/twig-extensions
$event->getTwig()->addExtension(new DateExtension());
$event->getTwig()->addExtension(new PcreExtension());
$event->getTwig()->addExtension(new TextExtension());
$event->getTwig()->addExtension(new ArrayExtension());
// umpirsky/twig-php-function
$event->getTwig()->addExtension(new PhpFunctionExtension());
// Breakpoint extension
if (Configure::read('debug') === true) {
$event->getTwig()->addExtension(new BreakpointExtension());
}
// @codingStandardsIgnoreEnd
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php
/**
* This file is part of TwigView.
*
** (c) 2015 Cees-Jan Kiewiet
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace WyriHaximus\TwigView\Event;
use Cake\Event\Event;
class LoaderEvent extends Event
{
const EVENT = 'TwigView.TwigView.loader';
/**
* @param \Twig_LoaderInterface $loader
* @return LoaderEvent
*/
public static function create(\Twig_LoaderInterface $loader)
{
return new static(static::EVENT, $loader, [
'loader' => $loader,
]);
}
/**
* @return \Twig_LoaderInterface
*/
public function getLoader()
{
return $this->getSubject();
}
/**
* @return string|Twig_LoaderInterface
*/
public function getResultLoader()
{
if ($this->result instanceof \Twig_LoaderInterface) {
return $this->result;
}
if (is_array($this->result) && $this->result['loader'] instanceof \Twig_LoaderInterface) {
return $this->result['loader'];
}
return $this->getLoader();
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
/**
* This file is part of TwigView.
*
** (c) 2015 Cees-Jan Kiewiet
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace WyriHaximus\TwigView\Event;
use Cake\Event\Event;
class ProfileEvent extends Event
{
const EVENT = 'TwigView.TwigView.profile';
/**
* @param \Twig_Profiler_Profile $profile
* @return static
*/
public static function create(\Twig_Profiler_Profile $profile)
{
return new static(static::EVENT, $profile);
}
/**
* @return \Twig_Profiler_Profile
*/
public function getLoader()
{
return $this->getSubject();
}
}
@@ -0,0 +1,53 @@
<?php
/**
* This file is part of TwigView.
*
** (c) 2014 Cees-Jan Kiewiet
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace WyriHaximus\TwigView\Event;
use Cake\Event\EventListenerInterface;
use Cake\Event\EventManager;
use WyriHaximus\TwigView\Lib\Cache;
use WyriHaximus\TwigView\Lib\Twig\Extension;
use WyriHaximus\TwigView\Lib\Twig\TokenParser;
/**
* Class ExtensionsListener
* @package WyriHaximus\TwigView\Event
*/
class ProfilerListener implements EventListenerInterface
{
/**
* Return implemented events.
*
* @return array
*/
public function implementedEvents()
{
return [
ConstructEvent::EVENT => 'construct',
];
}
/**
* Event handler.
*
* @param ConstructEvent $event Event.
*
* @return void
*/
public function construct(ConstructEvent $event)
{
$profile = new \Twig_Profiler_Profile();
$event->
getTwig()->
addExtension(new Extension\Profiler($profile));
EventManager::instance()->dispatch(ProfileEvent::create($profile));
}
}
@@ -0,0 +1,53 @@
<?php
/**
* This file is part of TwigView.
*
** (c) 2014 Cees-Jan Kiewiet
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace WyriHaximus\TwigView\Event;
use Cake\Event\EventListenerInterface;
use WyriHaximus\TwigView\Lib\Cache;
use WyriHaximus\TwigView\Lib\Twig\Extension;
use WyriHaximus\TwigView\Lib\Twig\TokenParser;
/**
* Class TokenParsersListener
* @package WyriHaximus\TwigView\Event
*/
class TokenParsersListener implements EventListenerInterface
{
/**
* Return implemented events.
*
* @return array
*/
public function implementedEvents()
{
return [
ConstructEvent::EVENT => 'construct',
];
}
/**
* Event handler.
*
* @param ConstructEvent $event Event.
*
* @return void
*/
// @codingStandardsIgnoreStart
public function construct(ConstructEvent $event)
{
// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreStart
// CakePHP specific tags
$event->getTwig()->addTokenParser(new TokenParser\Cell);
$event->getTwig()->addTokenParser(new TokenParser\Element);
// @codingStandardsIgnoreEnd
}
}