first
This commit is contained in:
39
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Laravel/SlugifyFacade.php
vendored
Normal file
39
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Laravel/SlugifyFacade.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of cocur/slugify.
|
||||
*
|
||||
* (c) Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Cocur\Slugify\Bridge\Laravel;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* SlugifyFacade
|
||||
*
|
||||
* @package cocur/slugify
|
||||
* @subpackage bridge
|
||||
* @author Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
* @author Colin Viebrock
|
||||
* @copyright 2012-2014 Florian Eckerstorfer
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class SlugifyFacade extends Facade
|
||||
{
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'slugify';
|
||||
}
|
||||
}
|
57
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Laravel/SlugifyServiceProvider.php
vendored
Normal file
57
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Laravel/SlugifyServiceProvider.php
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of cocur/slugify.
|
||||
*
|
||||
* (c) Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Cocur\Slugify\Bridge\Laravel;
|
||||
|
||||
use Cocur\Slugify\Slugify;
|
||||
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
|
||||
|
||||
/**
|
||||
* SlugifyServiceProvider
|
||||
*
|
||||
* @package cocur/slugify
|
||||
* @subpackage bridge
|
||||
* @author Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
* @author Colin Viebrock
|
||||
* @copyright 2012-2014 Florian Eckerstorfer
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class SlugifyServiceProvider extends LaravelServiceProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = true;
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('slugify', function () {
|
||||
return new Slugify();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return ['slugify'];
|
||||
}
|
||||
}
|
38
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Latte/SlugifyHelper.php
vendored
Normal file
38
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Latte/SlugifyHelper.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Cocur\Slugify\Bridge\Latte;
|
||||
|
||||
use Cocur\Slugify\SlugifyInterface;
|
||||
|
||||
/**
|
||||
* SlugifyHelper
|
||||
*
|
||||
* @package cocur/slugify
|
||||
* @subpackage bridge
|
||||
* @author Lukáš Unger <looky.msc@gmail.com>
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class SlugifyHelper
|
||||
{
|
||||
/** @var SlugifyInterface */
|
||||
private $slugify;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __construct(SlugifyInterface $slugify)
|
||||
{
|
||||
$this->slugify = $slugify;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @param string|null $separator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function slugify($string, $separator = null)
|
||||
{
|
||||
return $this->slugify->slugify($string, $separator);
|
||||
}
|
||||
}
|
37
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/League/SlugifyServiceProvider.php
vendored
Normal file
37
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/League/SlugifyServiceProvider.php
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Cocur\Slugify\Bridge\League;
|
||||
|
||||
use Cocur\Slugify\RuleProvider\DefaultRuleProvider;
|
||||
use Cocur\Slugify\RuleProvider\RuleProviderInterface;
|
||||
use Cocur\Slugify\Slugify;
|
||||
use Cocur\Slugify\SlugifyInterface;
|
||||
use League\Container\ServiceProvider\AbstractServiceProvider;
|
||||
|
||||
class SlugifyServiceProvider extends AbstractServiceProvider
|
||||
{
|
||||
protected $provides = [
|
||||
SlugifyInterface::class,
|
||||
];
|
||||
|
||||
public function register(): void
|
||||
{
|
||||
$this->container->share(SlugifyInterface::class, function () {
|
||||
$options = [];
|
||||
if ($this->container->has('config.slugify.options')) {
|
||||
$options = $this->container->get('config.slugify.options');
|
||||
}
|
||||
|
||||
$provider = null;
|
||||
if ($this->container->has(RuleProviderInterface::class)) {
|
||||
/* @var RuleProviderInterface $provider */
|
||||
$provider = $this->container->get(RuleProviderInterface::class);
|
||||
}
|
||||
|
||||
return new Slugify(
|
||||
$options,
|
||||
$provider
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
49
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Nette/SlugifyExtension.php
vendored
Normal file
49
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Nette/SlugifyExtension.php
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Cocur\Slugify\Bridge\Nette;
|
||||
|
||||
use Nette\DI\CompilerExtension;
|
||||
use Nette\DI\ServiceDefinition;
|
||||
|
||||
/**
|
||||
* SlugifyExtension
|
||||
*
|
||||
* @package cocur/slugify
|
||||
* @subpackage bridge
|
||||
* @author Lukáš Unger <looky.msc@gmail.com>
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class SlugifyExtension extends CompilerExtension
|
||||
{
|
||||
public function loadConfiguration(): void
|
||||
{
|
||||
$builder = $this->getContainerBuilder();
|
||||
|
||||
$builder->addDefinition($this->prefix('slugify'))
|
||||
->setClass('Cocur\Slugify\SlugifyInterface')
|
||||
->setFactory('Cocur\Slugify\Slugify');
|
||||
|
||||
$builder->addDefinition($this->prefix('helper'))
|
||||
->setClass('Cocur\Slugify\Bridge\Latte\SlugifyHelper')
|
||||
->setAutowired(false);
|
||||
}
|
||||
|
||||
public function beforeCompile(): void
|
||||
{
|
||||
$builder = $this->getContainerBuilder();
|
||||
|
||||
$self = $this;
|
||||
$registerToLatte = function (ServiceDefinition $def) use ($self) {
|
||||
$def->addSetup('addFilter', ['slugify', [$self->prefix('@helper'), 'slugify']]);
|
||||
};
|
||||
|
||||
$latteFactory = $builder->getByType('Nette\Bridges\ApplicationLatte\ILatteFactory') ?: 'nette.latteFactory';
|
||||
if ($builder->hasDefinition($latteFactory)) {
|
||||
$registerToLatte($builder->getDefinition($latteFactory));
|
||||
}
|
||||
|
||||
if ($builder->hasDefinition('nette.latte')) {
|
||||
$registerToLatte($builder->getDefinition('nette.latte'));
|
||||
}
|
||||
}
|
||||
}
|
50
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Plum/SlugifyConverter.php
vendored
Normal file
50
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Plum/SlugifyConverter.php
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of cocur/slugify.
|
||||
*
|
||||
* (c) Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Cocur\Slugify\Bridge\Plum;
|
||||
|
||||
use Plum\Plum\Converter\ConverterInterface;
|
||||
use Cocur\Slugify\Slugify;
|
||||
use Cocur\Slugify\SlugifyInterface;
|
||||
|
||||
/**
|
||||
* SlugifyConverter
|
||||
*
|
||||
* @package Cocur\Slugify\Bridge\Plum
|
||||
* @author Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
* @copyright 2015 Florian Eckerstorfer
|
||||
*/
|
||||
class SlugifyConverter implements ConverterInterface
|
||||
{
|
||||
/** @var Slugify */
|
||||
private $slugify;
|
||||
|
||||
/**
|
||||
* @param SlugifyInterface|null $slugify
|
||||
*/
|
||||
public function __construct(SlugifyInterface $slugify = null)
|
||||
{
|
||||
if ($slugify === null) {
|
||||
$slugify = new Slugify();
|
||||
}
|
||||
$this->slugify = $slugify;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $item
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function convert($item)
|
||||
{
|
||||
return $this->slugify->slugify($item);
|
||||
}
|
||||
}
|
32
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Symfony/CocurSlugifyBundle.php
vendored
Normal file
32
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Symfony/CocurSlugifyBundle.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of cocur/slugify.
|
||||
*
|
||||
* (c) Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Cocur\Slugify\Bridge\Symfony;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
/**
|
||||
* CocurSlugifyBundle
|
||||
*
|
||||
* @package cocur/slugify
|
||||
* @subpackage bridge
|
||||
* @author Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
* @copyright 2012-2014 Florian Eckerstorfer
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class CocurSlugifyBundle extends Bundle
|
||||
{
|
||||
public function getContainerExtension(): ExtensionInterface
|
||||
{
|
||||
return new CocurSlugifyExtension();
|
||||
}
|
||||
}
|
65
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Symfony/CocurSlugifyExtension.php
vendored
Normal file
65
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Symfony/CocurSlugifyExtension.php
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of cocur/slugify.
|
||||
*
|
||||
* (c) Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Cocur\Slugify\Bridge\Symfony;
|
||||
|
||||
use Cocur\Slugify\Bridge\Twig\SlugifyExtension;
|
||||
use Cocur\Slugify\Slugify;
|
||||
use Cocur\Slugify\SlugifyInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
|
||||
/**
|
||||
* CocurSlugifyExtension
|
||||
*
|
||||
* @package cocur/slugify
|
||||
* @subpackage bridge
|
||||
* @author Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
* @copyright 2012-2014 Florian Eckerstorfer
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class CocurSlugifyExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param mixed[] $configs
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container): void
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
if (empty($config['rulesets'])) {
|
||||
unset($config['rulesets']);
|
||||
}
|
||||
|
||||
// Extract slugify arguments from config
|
||||
$slugifyArguments = array_intersect_key($config, array_flip(['lowercase', 'trim', 'strip_tags', 'separator', 'regexp', 'rulesets']));
|
||||
|
||||
$container->setDefinition('cocur_slugify', new Definition(Slugify::class, [$slugifyArguments]));
|
||||
$container
|
||||
->setDefinition(
|
||||
'cocur_slugify.twig.slugify',
|
||||
new Definition(
|
||||
SlugifyExtension::class,
|
||||
[new Reference('cocur_slugify')]
|
||||
)
|
||||
)
|
||||
->addTag('twig.extension')
|
||||
->setPublic(false);
|
||||
$container->setAlias('slugify', 'cocur_slugify');
|
||||
$container->setAlias(SlugifyInterface::class, 'cocur_slugify');
|
||||
}
|
||||
}
|
46
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Symfony/Configuration.php
vendored
Normal file
46
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Symfony/Configuration.php
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the cocur/slugify package.
|
||||
*
|
||||
* (c) Enrico Stahn <enrico.stahn@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Cocur\Slugify\Bridge\Symfony;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder(): TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('cocur_slugify');
|
||||
|
||||
// Keep compatibility with symfony/config < 4.2
|
||||
if (\method_exists($treeBuilder, 'getRootNode')) {
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
} else {
|
||||
$rootNode = $treeBuilder->root('cocur_slugify');
|
||||
}
|
||||
|
||||
$rootNode
|
||||
->children()
|
||||
->booleanNode('lowercase')->end()
|
||||
->booleanNode('lowercase_after_regexp')->end()
|
||||
->booleanNode('trim')->end()
|
||||
->booleanNode('strip_tags')->end()
|
||||
->scalarNode('separator')->end()
|
||||
->scalarNode('regexp')->end()
|
||||
->arrayNode('rulesets')->prototype('scalar')->end()
|
||||
->end();
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
80
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Twig/SlugifyExtension.php
vendored
Normal file
80
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/Twig/SlugifyExtension.php
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of cocur/slugify.
|
||||
*
|
||||
* (c) Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Cocur\Slugify\Bridge\Twig;
|
||||
|
||||
use Cocur\Slugify\SlugifyInterface;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
|
||||
/**
|
||||
* SlugifyExtension
|
||||
*
|
||||
* @package cocur/slugify
|
||||
* @subpackage bridge
|
||||
* @author Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
* @copyright 2012-2015 Florian Eckerstorfer
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class SlugifyExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* @var SlugifyInterface
|
||||
*/
|
||||
private $slugify;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param SlugifyInterface $slugify
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __construct(SlugifyInterface $slugify)
|
||||
{
|
||||
$this->slugify = $slugify;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Twig functions of this extension.
|
||||
*
|
||||
* @return TwigFilter[]
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
new TwigFilter('slugify', [$this, 'slugifyFilter']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Slugify filter.
|
||||
*
|
||||
* @param string $string
|
||||
* @param string|null $separator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function slugifyFilter($string, $separator = null)
|
||||
{
|
||||
return $this->slugify->slugify($string, $separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return "SlugifyExtension";
|
||||
}
|
||||
}
|
50
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/ZF2/Module.php
vendored
Normal file
50
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/ZF2/Module.php
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Cocur\Slugify\Bridge\ZF2;
|
||||
|
||||
use Zend\ModuleManager\Feature\ServiceProviderInterface;
|
||||
use Zend\ModuleManager\Feature\ViewHelperProviderInterface;
|
||||
|
||||
/**
|
||||
* Class Module
|
||||
* @package cocur/slugify
|
||||
* @subpackage bridge
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class Module implements ServiceProviderInterface, ViewHelperProviderInterface
|
||||
{
|
||||
const CONFIG_KEY = 'cocur_slugify';
|
||||
|
||||
/**
|
||||
* Expected to return \Zend\ServiceManager\Config object or array to
|
||||
* seed such an object.
|
||||
*
|
||||
* @return array<string,array<string,string>>
|
||||
*/
|
||||
public function getServiceConfig()
|
||||
{
|
||||
return [
|
||||
'factories' => [
|
||||
'Cocur\Slugify\Slugify' => 'Cocur\Slugify\Bridge\ZF2\SlugifyService'
|
||||
],
|
||||
'aliases' => [
|
||||
'slugify' => 'Cocur\Slugify\Slugify'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Expected to return \Zend\ServiceManager\Config object or array to
|
||||
* seed such an object.
|
||||
*
|
||||
* @return array<string,array<string,string>>|\Zend\ServiceManager\Config
|
||||
*/
|
||||
public function getViewHelperConfig()
|
||||
{
|
||||
return [
|
||||
'factories' => [
|
||||
'slugify' => 'Cocur\Slugify\Bridge\ZF2\SlugifyViewHelperFactory'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
30
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/ZF2/SlugifyService.php
vendored
Normal file
30
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/ZF2/SlugifyService.php
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Cocur\Slugify\Bridge\ZF2;
|
||||
|
||||
use Cocur\Slugify\Slugify;
|
||||
use Zend\ServiceManager\ServiceManager;
|
||||
|
||||
/**
|
||||
* Class SlugifyService
|
||||
* @package cocur/slugify
|
||||
* @subpackage bridge
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class SlugifyService
|
||||
{
|
||||
/**
|
||||
* @param ServiceManager $sm
|
||||
*
|
||||
* @return Slugify
|
||||
*/
|
||||
public function __invoke($sm)
|
||||
{
|
||||
$config = $sm->get('Config');
|
||||
|
||||
$options = isset($config[Module::CONFIG_KEY]['options']) ? $config[Module::CONFIG_KEY]['options'] : [];
|
||||
$provider = isset($config[Module::CONFIG_KEY]['provider']) ? $config[Module::CONFIG_KEY]['provider'] : null;
|
||||
|
||||
return new Slugify($options, $provider);
|
||||
}
|
||||
}
|
41
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/ZF2/SlugifyViewHelper.php
vendored
Normal file
41
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/ZF2/SlugifyViewHelper.php
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Cocur\Slugify\Bridge\ZF2;
|
||||
|
||||
use Cocur\Slugify\SlugifyInterface;
|
||||
use Zend\View\Helper\AbstractHelper;
|
||||
|
||||
/**
|
||||
* Class SlugifyViewHelper
|
||||
* @package cocur/slugify
|
||||
* @subpackage bridge
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class SlugifyViewHelper extends AbstractHelper
|
||||
{
|
||||
/**
|
||||
* @var SlugifyInterface
|
||||
*/
|
||||
protected $slugify;
|
||||
|
||||
/**
|
||||
* @param SlugifyInterface $slugify
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __construct(SlugifyInterface $slugify)
|
||||
{
|
||||
$this->slugify = $slugify;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @param string|null $separator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __invoke($string, $separator = null)
|
||||
{
|
||||
return $this->slugify->slugify($string, $separator);
|
||||
}
|
||||
}
|
28
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/ZF2/SlugifyViewHelperFactory.php
vendored
Normal file
28
wp-content/plugins/visual-portfolio/vendors/slugify/Bridge/ZF2/SlugifyViewHelperFactory.php
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Cocur\Slugify\Bridge\ZF2;
|
||||
|
||||
use Cocur\Slugify\Slugify;
|
||||
use Zend\View\HelperPluginManager;
|
||||
|
||||
/**
|
||||
* Class SlugifyViewHelperFactory
|
||||
* @package cocur/slugify
|
||||
* @subpackage bridge
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class SlugifyViewHelperFactory
|
||||
{
|
||||
/**
|
||||
* @param HelperPluginManager $vhm
|
||||
*
|
||||
* @return SlugifyViewHelper
|
||||
*/
|
||||
public function __invoke($vhm)
|
||||
{
|
||||
/** @var Slugify $slugify */
|
||||
$slugify = $vhm->getServiceLocator()->get('Cocur\Slugify\Slugify');
|
||||
|
||||
return new SlugifyViewHelper($slugify);
|
||||
}
|
||||
}
|
8613
wp-content/plugins/visual-portfolio/vendors/slugify/RuleProvider/DefaultRuleProvider.php
vendored
Normal file
8613
wp-content/plugins/visual-portfolio/vendors/slugify/RuleProvider/DefaultRuleProvider.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
47
wp-content/plugins/visual-portfolio/vendors/slugify/RuleProvider/FileRuleProvider.php
vendored
Normal file
47
wp-content/plugins/visual-portfolio/vendors/slugify/RuleProvider/FileRuleProvider.php
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of cocur/slugify.
|
||||
*
|
||||
* (c) Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Cocur\Slugify\RuleProvider;
|
||||
|
||||
/**
|
||||
* FileRuleProvider
|
||||
*
|
||||
* @package Cocur\Slugify\RuleProvider
|
||||
* @author Florian Eckerstorfer
|
||||
* @copyright 2015 Florian Eckerstorfer
|
||||
*/
|
||||
class FileRuleProvider implements RuleProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $directoryName;
|
||||
|
||||
/**
|
||||
* @param string $directoryName
|
||||
*/
|
||||
public function __construct($directoryName)
|
||||
{
|
||||
$this->directoryName = $directoryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $ruleset
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRules($ruleset)
|
||||
{
|
||||
$fileName = $this->directoryName.DIRECTORY_SEPARATOR.$ruleset.'.json';
|
||||
|
||||
return json_decode(file_get_contents($fileName), true);
|
||||
}
|
||||
}
|
29
wp-content/plugins/visual-portfolio/vendors/slugify/RuleProvider/RuleProviderInterface.php
vendored
Normal file
29
wp-content/plugins/visual-portfolio/vendors/slugify/RuleProvider/RuleProviderInterface.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of cocur/slugify.
|
||||
*
|
||||
* (c) Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Cocur\Slugify\RuleProvider;
|
||||
|
||||
/**
|
||||
* RuleProviderInterface
|
||||
*
|
||||
* @package Cocur\Slugify\RuleProvider
|
||||
* @author Florian Eckerstorfer
|
||||
* @copyright 2015 Florian Eckerstorfer
|
||||
*/
|
||||
interface RuleProviderInterface
|
||||
{
|
||||
/**
|
||||
* @param $ruleset
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRules($ruleset);
|
||||
}
|
199
wp-content/plugins/visual-portfolio/vendors/slugify/Slugify.php
vendored
Normal file
199
wp-content/plugins/visual-portfolio/vendors/slugify/Slugify.php
vendored
Normal file
@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of cocur/slugify.
|
||||
*
|
||||
* (c) Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* CHANGED by nK:
|
||||
* - added check for `mb_strtolower` existence and use `strtolower` if mb is not available
|
||||
*/
|
||||
|
||||
namespace Cocur\Slugify;
|
||||
|
||||
use Cocur\Slugify\RuleProvider\DefaultRuleProvider;
|
||||
use Cocur\Slugify\RuleProvider\RuleProviderInterface;
|
||||
|
||||
/**
|
||||
* Slugify
|
||||
*
|
||||
* @package Cocur\Slugify
|
||||
* @author Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
* @author Ivo Bathke <ivo.bathke@gmail.com>
|
||||
* @author Marchenko Alexandr
|
||||
* @copyright 2012-2015 Florian Eckerstorfer
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
class Slugify implements SlugifyInterface
|
||||
{
|
||||
const LOWERCASE_NUMBERS_DASHES = '/[^A-Za-z0-9]+/';
|
||||
|
||||
/**
|
||||
* @var array<string,string>
|
||||
*/
|
||||
protected $rules = [];
|
||||
|
||||
/**
|
||||
* @var RuleProviderInterface
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var array<string,mixed>
|
||||
*/
|
||||
protected $options = [
|
||||
'regexp' => self::LOWERCASE_NUMBERS_DASHES,
|
||||
'separator' => '-',
|
||||
'lowercase' => true,
|
||||
'lowercase_after_regexp' => false,
|
||||
'trim' => true,
|
||||
'strip_tags' => false,
|
||||
'rulesets' => [
|
||||
'default',
|
||||
// Languages are preferred if they appear later, list is ordered by number of
|
||||
// websites in that language
|
||||
// https://en.wikipedia.org/wiki/Languages_used_on_the_Internet#Content_languages_for_websites
|
||||
'armenian',
|
||||
'azerbaijani',
|
||||
'burmese',
|
||||
'hindi',
|
||||
'georgian',
|
||||
'norwegian',
|
||||
'vietnamese',
|
||||
'ukrainian',
|
||||
'latvian',
|
||||
'finnish',
|
||||
'greek',
|
||||
'czech',
|
||||
'arabic',
|
||||
'slovak',
|
||||
'turkish',
|
||||
'polish',
|
||||
'german',
|
||||
'russian',
|
||||
'romanian'
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
* @param RuleProviderInterface $provider
|
||||
*/
|
||||
public function __construct(array $options = [], RuleProviderInterface $provider = null)
|
||||
{
|
||||
$this->options = array_merge($this->options, $options);
|
||||
$this->provider = $provider ? $provider : new DefaultRuleProvider();
|
||||
|
||||
foreach ($this->options['rulesets'] as $ruleSet) {
|
||||
$this->activateRuleSet($ruleSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the slug-version of the string.
|
||||
*
|
||||
* @param string $string String to slugify
|
||||
* @param string|array|null $options Options
|
||||
*
|
||||
* @return string Slugified version of the string
|
||||
*/
|
||||
public function slugify($string, $options = null)
|
||||
{
|
||||
// BC: the second argument used to be the separator
|
||||
if (is_string($options)) {
|
||||
$separator = $options;
|
||||
$options = [];
|
||||
$options['separator'] = $separator;
|
||||
}
|
||||
|
||||
$options = array_merge($this->options, (array) $options);
|
||||
|
||||
// Add a custom ruleset without touching the default rules
|
||||
if (isset($options['ruleset'])) {
|
||||
$rules = array_merge($this->rules, $this->provider->getRules($options['ruleset']));
|
||||
} else {
|
||||
$rules = $this->rules;
|
||||
}
|
||||
|
||||
$string = ($options['strip_tags'])
|
||||
? strip_tags($string)
|
||||
: $string;
|
||||
|
||||
$string = strtr($string, $rules);
|
||||
unset($rules);
|
||||
|
||||
if ($options['lowercase'] && !$options['lowercase_after_regexp']) {
|
||||
// CHANGED: nK
|
||||
// added check for mb_strtolower existence.
|
||||
$string = function_exists('mb_strtolower') ? mb_strtolower($string) : strtolower($string);
|
||||
}
|
||||
|
||||
$string = preg_replace($options['regexp'], $options['separator'], $string);
|
||||
|
||||
if ($options['lowercase'] && $options['lowercase_after_regexp']) {
|
||||
// CHANGED: nK
|
||||
// added check for mb_strtolower existence.
|
||||
$string = function_exists('mb_strtolower') ? mb_strtolower($string) : strtolower($string);
|
||||
}
|
||||
|
||||
return ($options['trim'])
|
||||
? trim($string, $options['separator'])
|
||||
: $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom rule to Slugify.
|
||||
*
|
||||
* @param string $character Character
|
||||
* @param string $replacement Replacement character
|
||||
*
|
||||
* @return Slugify
|
||||
*/
|
||||
public function addRule($character, $replacement)
|
||||
{
|
||||
$this->rules[$character] = $replacement;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple rules to Slugify.
|
||||
*
|
||||
* @param array <string,string> $rules
|
||||
*
|
||||
* @return Slugify
|
||||
*/
|
||||
public function addRules(array $rules)
|
||||
{
|
||||
foreach ($rules as $character => $replacement) {
|
||||
$this->addRule($character, $replacement);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $ruleSet
|
||||
*
|
||||
* @return Slugify
|
||||
*/
|
||||
public function activateRuleSet($ruleSet)
|
||||
{
|
||||
return $this->addRules($this->provider->getRules($ruleSet));
|
||||
}
|
||||
|
||||
/**
|
||||
* Static method to create new instance of {@see Slugify}.
|
||||
*
|
||||
* @param array <string,mixed> $options
|
||||
*
|
||||
* @return Slugify
|
||||
*/
|
||||
public static function create(array $options = [])
|
||||
{
|
||||
return new static($options);
|
||||
}
|
||||
}
|
36
wp-content/plugins/visual-portfolio/vendors/slugify/SlugifyInterface.php
vendored
Normal file
36
wp-content/plugins/visual-portfolio/vendors/slugify/SlugifyInterface.php
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of cocur/slugify.
|
||||
*
|
||||
* (c) Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Cocur\Slugify;
|
||||
|
||||
/**
|
||||
* SlugifyInterface
|
||||
*
|
||||
* @package org.cocur.slugify
|
||||
* @author Florian Eckerstorfer <florian@eckerstorfer.co>
|
||||
* @author Marchenko Alexandr
|
||||
* @copyright 2012-2014 Florian Eckerstorfer
|
||||
* @license http://www.opensource.org/licenses/MIT The MIT License
|
||||
*/
|
||||
interface SlugifyInterface
|
||||
{
|
||||
/**
|
||||
* Return a URL safe version of a string.
|
||||
*
|
||||
* @param string $string
|
||||
* @param string|array|null $options
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function slugify($string, $options = null);
|
||||
}
|
Reference in New Issue
Block a user