Server IP : 213.176.29.180 / Your IP : 52.14.125.137 Web Server : Apache System : Linux 213.176.29.180.hostiran.name 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64 User : webtaragh ( 1001) PHP Version : 8.3.14 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0750) : /home/webtaragh/public_html/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
PK ��$Z~D�9] ] knp-menu/README.markdownnu �[��� KnpMenu ======= The KnpMenu library provides object oriented menus for PHP 7. It is used by the [KnpMenuBundle](https://github.com/KnpLabs/KnpMenuBundle) for Symfony but can now be used stand-alone. [![Build Status](https://secure.travis-ci.org/KnpLabs/KnpMenu.svg)](http://travis-ci.org/KnpLabs/KnpMenu) [![Latest Stable Version](https://poser.pugx.org/knplabs/knp-menu/v/stable.svg)](https://packagist.org/packages/knplabs/knp-menu) [![Latest Unstable Version](https://poser.pugx.org/knplabs/knp-menu/v/unstable.svg)](https://packagist.org/packages/knplabs/knp-menu) [![Gitter chat](https://badges.gitter.im/KnpLabs/KnpMenu.svg)](https://gitter.im/KnpLabs/KnpMenu) ## Installation KnpMenu uses Composer, please checkout the [composer website](http://getcomposer.org) for more information. The simple following command will install `knp-menu` into your project. It also add a new entry in your `composer.json` and update the `composer.lock` as well. ```bash $ composer require knplabs/knp-menu ``` > KnpMenu follows the PSR-4 convention names for its classes, which means you can easily integrate `knp-menu` classes loading in your own autoloader. ## Getting Started ```php <?php // Include dependencies installed with composer require 'vendor/autoload.php'; use Knp\Menu\MenuFactory; use Knp\Menu\Renderer\ListRenderer; $factory = new MenuFactory(); $menu = $factory->createItem('My menu'); $menu->addChild('Home', ['uri' => '/']); $menu->addChild('Comments', ['uri' => '#comments']); $menu->addChild('Symfony', ['uri' => 'http://symfony.com/']); $menu->addChild('Happy Awesome Developers'); $renderer = new ListRenderer(new \Knp\Menu\Matcher\Matcher()); echo $renderer->render($menu); ``` The above menu would render the following HTML: ```html <ul> <li class="first"> <a href="/">Home</a> </li> <li class="current"> <a href="#comments">Comments</a> </li> <li> <a href="http://symfony.com/">Symfony</a> </li> <li class="last"> <span>Happy Awesome Developers</span> </li> </ul> ``` This way you can finally avoid writing an ugly template to show the selected item, the first and last items, submenus, ... > The bulk of the documentation can be found in the `doc` directory. ## What now? Follow the tutorial in [`doc/01-Basic-Menus.md`][0] and [`doc/02-Twig-Integration.md`][1] to discover how KnpMenu will rock your world! Find all available documentation at [`doc/`][2]. ## Maintainers This library is maintained by the following people (alphabetically sorted) : - @derrabus - @garak - @stof ## Credits This bundle was originally ported from [ioMenuPlugin](http://github.com/weaverryan/ioMenuPlugin), a menu plugin for symfony1. It has since been developed by [KnpLabs](http://www.knplabs.com) and the [Symfony community](https://github.com/KnpLabs/KnpMenu/graphs/contributors). [0]: doc/01-Basic-Menus.md [1]: doc/02-Twig-Integration.md [2]: doc/ PK ��$Z Gj�� � knp-menu/CODE_OF_CONDUCT.mdnu �[��� # Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org ## Contact If you have any questions or feedback, [please ping us](https://twitter.com/KNPLabs) ! PK ��$Z�ÒT ) knp-menu/src/Knp/Menu/Matcher/Matcher.phpnu �[��� <?php namespace Knp\Menu\Matcher; use Knp\Menu\ItemInterface; use Knp\Menu\Matcher\Voter\VoterInterface; /** * A MatcherInterface implementation using a voter system */ class Matcher implements MatcherInterface { private $cache; private $voters; /** * @param VoterInterface[]|iterable $voters */ public function __construct($voters = []) { $this->voters = $voters; $this->cache = new \SplObjectStorage(); } public function isCurrent(ItemInterface $item): bool { $current = $item->isCurrent(); if (null !== $current) { return $current; } if ($this->cache->contains($item)) { return $this->cache[$item]; } foreach ($this->voters as $voter) { $current = $voter->matchItem($item); if (null !== $current) { break; } } $current = (bool) $current; $this->cache[$item] = $current; return $current; } public function isAncestor(ItemInterface $item, ?int $depth = null): bool { if (0 === $depth) { return false; } $childDepth = null === $depth ? null : $depth - 1; foreach ($item->getChildren() as $child) { if ($this->isCurrent($child) || $this->isAncestor($child, $childDepth)) { return true; } } return false; } public function clear(): void { $this->cache = new \SplObjectStorage(); } } PK ��$Z�*��� � 2 knp-menu/src/Knp/Menu/Matcher/MatcherInterface.phpnu �[��� <?php namespace Knp\Menu\Matcher; use Knp\Menu\ItemInterface; /** * Interface implemented by the item matcher */ interface MatcherInterface { /** * Checks whether an item is current. * * @param ItemInterface $item * * @return bool */ public function isCurrent(ItemInterface $item): bool; /** * Checks whether an item is the ancestor of a current item. * * @param ItemInterface $item * @param int|null $depth The max depth to look for the item * * @return bool */ public function isAncestor(ItemInterface $item, ?int $depth = null): bool; /** * Clears the state of the matcher. */ public function clear(): void; } PK ��$Z�3�(! ! 2 knp-menu/src/Knp/Menu/Matcher/Voter/RegexVoter.phpnu �[��� <?php namespace Knp\Menu\Matcher\Voter; use Knp\Menu\ItemInterface; /** * Implements the VoterInterface which can be used as voter for "current" class * `matchItem` will return true if the pattern you're searching for is found in the URI of the item */ class RegexVoter implements VoterInterface { /** * @var string|null */ private $regexp; /** * @param string|null $regexp */ public function __construct(?string $regexp) { $this->regexp = $regexp; } public function matchItem(ItemInterface $item): ?bool { if (null === $this->regexp || null === $item->getUri()) { return null; } if (\preg_match($this->regexp, $item->getUri())) { return true; } return null; } } PK ��$Z��צ � 2 knp-menu/src/Knp/Menu/Matcher/Voter/RouteVoter.phpnu �[��� <?php namespace Knp\Menu\Matcher\Voter; use Knp\Menu\ItemInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; /** * Voter based on the route */ class RouteVoter implements VoterInterface { /** * @var RequestStack */ private $requestStack; /** * @var Request|null */ private $request; public function __construct(RequestStack $requestStack) { $this->requestStack = $requestStack; } public function matchItem(ItemInterface $item): ?bool { $request = $this->requestStack->getMasterRequest(); if (null === $request) { return null; } $route = $request->attributes->get('_route'); if (null === $route) { return null; } $routes = (array) $item->getExtra('routes', []); foreach ($routes as $testedRoute) { if (\is_string($testedRoute)) { $testedRoute = ['route' => $testedRoute]; } if (!\is_array($testedRoute)) { throw new \InvalidArgumentException('Routes extra items must be strings or arrays.'); } if ($this->isMatchingRoute($request, $testedRoute)) { return true; } } return null; } private function isMatchingRoute(Request $request, array $testedRoute): bool { $route = $request->attributes->get('_route'); if (isset($testedRoute['route'])) { if ($route !== $testedRoute['route']) { return false; } } elseif (!empty($testedRoute['pattern'])) { if (!\preg_match($testedRoute['pattern'], $route)) { return false; } } else { throw new \InvalidArgumentException('Routes extra items must have a "route" or "pattern" key.'); } if (!isset($testedRoute['parameters'])) { return true; } $routeParameters = $request->attributes->get('_route_params', []); foreach ($testedRoute['parameters'] as $name => $value) { // cast both to string so that we handle integer and other non-string parameters, but don't stumble on 0 == 'abc'. if (!isset($routeParameters[$name]) || (string) $routeParameters[$name] !== (string) $value) { return false; } } return true; } } PK ��$Z�0� 0 knp-menu/src/Knp/Menu/Matcher/Voter/UriVoter.phpnu �[��� <?php namespace Knp\Menu\Matcher\Voter; use Knp\Menu\ItemInterface; /** * Voter based on the uri */ class UriVoter implements VoterInterface { private $uri; public function __construct(?string $uri = null) { $this->uri = $uri; } public function matchItem(ItemInterface $item): ?bool { if (null === $this->uri || null === $item->getUri()) { return null; } if ($item->getUri() === $this->uri) { return true; } return null; } } PK ��$Z c�� � 6 knp-menu/src/Knp/Menu/Matcher/Voter/VoterInterface.phpnu �[��� <?php namespace Knp\Menu\Matcher\Voter; use Knp\Menu\ItemInterface; /** * Interface implemented by the matching voters */ interface VoterInterface { /** * Checks whether an item is current. * * If the voter is not able to determine a result, * it should return null to let other voters do the job. * * @param ItemInterface $item * * @return bool|null */ public function matchItem(ItemInterface $item): ?bool; } PK ��$Z�LP+8 8 4 knp-menu/src/Knp/Menu/Factory/ExtensionInterface.phpnu �[��� <?php namespace Knp\Menu\Factory; use Knp\Menu\ItemInterface; interface ExtensionInterface { /** * Builds the full option array used to configure the item. * * @param array $options The options processed by the previous extensions * * @return array */ public function buildOptions(array $options): array; /** * Configures the item with the passed options * * @param ItemInterface $item * @param array $options */ public function buildItem(ItemInterface $item, array $options): void; } PK ��$ZJ�@W W / knp-menu/src/Knp/Menu/Factory/CoreExtension.phpnu �[��� <?php namespace Knp\Menu\Factory; use Knp\Menu\ItemInterface; /** * core factory extension with the main logic */ class CoreExtension implements ExtensionInterface { /** * Builds the full option array used to configure the item. * * @param array $options * * @return array */ public function buildOptions(array $options): array { return \array_merge( [ 'uri' => null, 'label' => null, 'attributes' => [], 'linkAttributes' => [], 'childrenAttributes' => [], 'labelAttributes' => [], 'extras' => [], 'current' => null, 'display' => true, 'displayChildren' => true, ], $options ); } /** * Configures the newly created item with the passed options * * @param ItemInterface $item * @param array $options */ public function buildItem(ItemInterface $item, array $options): void { $item ->setUri($options['uri']) ->setLabel($options['label']) ->setAttributes($options['attributes']) ->setLinkAttributes($options['linkAttributes']) ->setChildrenAttributes($options['childrenAttributes']) ->setLabelAttributes($options['labelAttributes']) ->setCurrent($options['current']) ->setDisplay($options['display']) ->setDisplayChildren($options['displayChildren']) ; $this->buildExtras($item, $options); } /** * Configures the newly created item's extras * Extras are processed one by one in order not to reset values set by other extensions * * @param ItemInterface $item * @param array $options */ private function buildExtras(ItemInterface $item, array $options): void { if (!empty($options['extras'])) { foreach ($options['extras'] as $key => $value) { $item->setExtra($key, $value); } } } } PK ��$Z�.�� � <