diff --git a/plugins/breadcrumbs/CHANGELOG.md b/plugins/breadcrumbs/CHANGELOG.md new file mode 100644 index 0000000..6080f6c --- /dev/null +++ b/plugins/breadcrumbs/CHANGELOG.md @@ -0,0 +1,67 @@ +# v1.6.1 +## 12/02/2020 + +1. [](#improved) + * Minor default template improvements + +# v1.6.0 +## 04/22/2020 + +1. [](#new) + * Added `schema.org/BreadcrumbList` [#29] + * Added per-page option to control breadcrumbs [#20] + * Added various translations [#17][#18][#19] + * Pass phpstan level 1 tests + * Require Grav v1.6 + +# v1.5.1 +## 10/24/2017 + +1. [](#improved) + * Add option to ignore current page [#11] + * Removed Grav trait in favor of `Grav::instance()` + +# v1.5.0 +## 07/14/2016 + +1. [](#improved) + * non-routable pages are not linked + +# v1.4.0 +## 08/25/2015 + +1. [](#improved) + * Added blueprints for Grav Admin plugin + +# v1.3.0 +## 03/06/2015 + +1. [](#new) + * Added toggle for showing home item + * Added configurable home icon + * Added configurable divider icon + * Added toggle to link trailing item + +# v1.2.3 +## 02/05/2015 + +2. [](#improved) + * Added support for HHVM + +# v1.2.2 +## 01/23/2015 + +2. [](#improved) + * Added microdata information + +# v1.2.1 +## 01/09/2015 + +2. [](#improved) + * NOTE: BREAKING CHANGE: Moved templates into `partials/` subfolder for consistency. + +# v1.2.0 +## 11/30/2014 + +1. [](#new) + * ChangeLog started... diff --git a/plugins/breadcrumbs/LICENSE b/plugins/breadcrumbs/LICENSE new file mode 100644 index 0000000..484793a --- /dev/null +++ b/plugins/breadcrumbs/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Grav + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/plugins/breadcrumbs/README.md b/plugins/breadcrumbs/README.md new file mode 100644 index 0000000..5f8d424 --- /dev/null +++ b/plugins/breadcrumbs/README.md @@ -0,0 +1,101 @@ +# Grav Breadcrumbs Plugin + +![Breadcrumbs](assets/readme_1.png) + +`Breadcrumbs` is a [Grav](http://github.com/getgrav/grav) plugin that adds links to the previous pages (following the hierarchical structure). +It is particularly useful if you are using Grav to run a blog. + +# Installation + +Installing the Breadcrumbs plugin can be done in one of two ways. Our GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file. + +## GPM Installation (Preferred) + +The simplest way to install this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm) through your system's Terminal (also called the command line). From the root of your Grav install type: + + bin/gpm install breadcrumbs + +This will install the Breadcrumbs plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/breadcrumbs`. + +## Manual Installation + +To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `breadcrumbs`. You can find these files either on [GitHub](https://github.com/getgrav/grav-plugin-breadcrumbs) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras). + +You should now have all the plugin files under + + /your/site/grav/user/plugins/breadcrumbs + +>> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav), the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) plugins, and a theme to be installed in order to operate. + +# Usage + +The `breadcrumbs` plugin doesn't require any configuration. The moment you install it, it is ready to use. + +Something you might want to do is to override the look and feel of the breadcrumbs, and with Grav it is super easy. + +Copy the template file [breadcrumbs.html.twig](templates/partials/breadcrumbs.html.twig) into the `templates` folder of your custom theme, and that is it. + +``` +/your/site/grav/user/themes/custom-theme/templates/partials/breadcrumbs.html.twig +``` + +You can now edit the override and tweak it however you prefer. + +## Per-page Settings + +The following options are available for use in a page's YAML frontmatter, placed within the `breadcrumbs` mapping: + +| Option | Default | Values | Description | +|-------------|---------|-------------------|--------------------------------------------------------------------------------------| +| `max_depth` | `true` | `true` or `false` | Determines whether breadcrumbs for pages beneath the current page will be generated. | + +### Example Per-page Settings + +```yaml +--- +title: Some page you wrote +breadcrumbs: + may_descend: false # Breadcrumbs will not be generated for pages underneath this one. +--- +``` + +# Updating + +As development for the Breadcrumbs plugin continues, new versions may become available that add additional features and functionality, improve compatibility with newer Grav releases, and generally provide a better user experience. Updating Breadcrumbs is easy, and can be done through Grav's GPM system, as well as manually. + +## GPM Update (Preferred) + +The simplest way to update this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm). You can do this with this by navigating to the root directory of your Grav install using your system's Terminal (also called command line) and typing the following: + + bin/gpm update breadcrumbs + +This command will check your Grav install to see if your Breadcrumbs plugin is due for an update. If a newer release is found, you will be asked whether or not you wish to update. To continue, type `y` and hit enter. The plugin will automatically update and clear Grav's cache. + +## Manual Update + +Manually updating Breadcrumbs is pretty simple. Here is what you will need to do to get this done: + +* Delete the `your/site/user/plugins/breadcrumbs` directory. +* Download the new version of the Breadcrumbs plugin from either [GitHub](https://github.com/getgrav/grav-plugin-breadcrumbs) or [GetGrav.org](http://getgrav.org/downloads/plugins#extras). +* Unzip the zip file in `your/site/user/plugins` and rename the resulting folder to `breadcrumbs`. +* Clear the Grav cache. The simplest way to do this is by going to the root Grav directory in terminal and typing `bin/grav clear-cache`. + +> Note: Any changes you have made to any of the files listed under this directory will also be removed and replaced by the new set. Any files located elsewhere (for example a YAML settings file placed in `user/config/plugins`) will remain intact. + +## Configuration + +Simply copy the `user/plugins/breadcrumbs/breadcrumbs.yaml` into `user/config/plugins/breadcrumbs.yaml` and make your modifications. + +``` +enabled: true +show_all: true +built_in_css: true +include_home: true +include_current: true +icon_home: '' +icon_divider_classes: 'fa fa-angle-right' +link_trailing: false +``` + +Options are pretty self explanatory. + diff --git a/plugins/breadcrumbs/assets/readme_1.png b/plugins/breadcrumbs/assets/readme_1.png new file mode 100644 index 0000000..7837412 Binary files /dev/null and b/plugins/breadcrumbs/assets/readme_1.png differ diff --git a/plugins/breadcrumbs/blueprints.yaml b/plugins/breadcrumbs/blueprints.yaml new file mode 100644 index 0000000..f9f8f39 --- /dev/null +++ b/plugins/breadcrumbs/blueprints.yaml @@ -0,0 +1,99 @@ +name: Breadcrumbs +type: plugin +slug: breadcrumbs +version: 1.6.1 +description: The **Breadcrumbs** plugin provides a simple method to display the depth of your content/navigation structure. +icon: caret-square-o-right +author: + name: Team Grav + email: devs@getgrav.org + url: http://getgrav.org +homepage: https://github.com/getgrav/grav-plugin-breadcrumbs +demo: http://demo.getgrav.org/blog-skeleton +keywords: breadcrumbs, plugin, navigation, depth +bugs: https://github.com/getgrav/grav-plugin-breadcrumbs/issues +license: MIT +dependencies: + - { name: grav, version: '>=1.6.0' } + +form: + validation: strict + fields: + enabled: + type: toggle + label: PLUGIN_ADMIN.PLUGIN_STATUS + highlight: 1 + default: 1 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + + show_all: + type: toggle + label: PLUGIN_BREADCRUMBS.SHOW_WITH_ONE_ITEM + highlight: 1 + default: 1 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + + built_in_css: + type: toggle + label: PLUGIN_BREADCRUMBS.BUILTIN_CSS + highlight: 1 + default: 1 + help: PLUGIN_BREADCRUMBS.BUILTIN_CSS_HELP + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + + include_home: + type: toggle + label: PLUGIN_BREADCRUMBS.INCLUDE_HOME + highlight: 1 + default: 1 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + + include_current: + type: toggle + label: PLUGIN_BREADCRUMBS.INCLUDE_CURRENT_PAGE + highlight: 1 + default: 1 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + + icon_home: + type: text + size: medium + label: PLUGIN_BREADCRUMBS.ICON_HOME + default: '' + + icon_divider_classes: + type: text + size: medium + label: PLUGIN_BREADCRUMBS.ICON_DIVIDER_CLASSES + default: 'fa fa-angle-right' + + link_trailing: + type: toggle + label: PLUGIN_BREADCRUMBS.LINK_TRAILING + highlight: 1 + default: 0 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool diff --git a/plugins/breadcrumbs/breadcrumbs.php b/plugins/breadcrumbs/breadcrumbs.php new file mode 100644 index 0000000..7c58ee4 --- /dev/null +++ b/plugins/breadcrumbs/breadcrumbs.php @@ -0,0 +1,70 @@ + [ + ['autoload', 100001], + ['onPluginsInitialized', 0] + ] + ]; + } + + /** + * [onPluginsInitialized:100000] Composer autoload. + * + * @return ClassLoader + */ + public function autoload() + { + return require __DIR__ . '/vendor/autoload.php'; + } + + /** + * Initialize configuration + */ + public function onPluginsInitialized() + { + if ($this->isAdmin()) { + $this->active = false; + return; + } + + class_alias(Breadcrumbs::class, 'Grav\\Plugin\\Breadcrumbs'); + + $this->enable([ + 'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0], + 'onTwigSiteVariables' => ['onTwigSiteVariables', 0] + ]); + } + + /** + * Add current directory to twig lookup paths. + */ + public function onTwigTemplatePaths() + { + $this->grav['twig']->twig_paths[] = __DIR__ . '/templates'; + } + + /** + * Set needed variables to display breadcrumbs. + */ + public function onTwigSiteVariables() + { + $this->grav['twig']->twig_vars['breadcrumbs'] = new Breadcrumbs($this->config->get('plugins.breadcrumbs')); + + if ($this->config->get('plugins.breadcrumbs.built_in_css')) { + $this->grav['assets']->add('plugin://breadcrumbs/css/breadcrumbs.css'); + } + } +} diff --git a/plugins/breadcrumbs/breadcrumbs.yaml b/plugins/breadcrumbs/breadcrumbs.yaml new file mode 100644 index 0000000..5364d9d --- /dev/null +++ b/plugins/breadcrumbs/breadcrumbs.yaml @@ -0,0 +1,8 @@ +enabled: true +show_all: true +built_in_css: true +include_home: true +include_current: true +icon_home: '' +icon_divider_classes: 'fa fa-angle-right' +link_trailing: false diff --git a/plugins/breadcrumbs/classes/plugin/Breadcrumbs.php b/plugins/breadcrumbs/classes/plugin/Breadcrumbs.php new file mode 100644 index 0000000..4e3aef1 --- /dev/null +++ b/plugins/breadcrumbs/classes/plugin/Breadcrumbs.php @@ -0,0 +1,123 @@ +config = $config; + } + + /** + * Return an array of breadcrumbs for the current page. + * + * @return array An array of breadcrumbs. + */ + public function get() + { + // If the breadcrumbs have not yet been generated... + if (!$this->breadcrumbs) { + // Generate them now. + $this->build(); + } + + return $this->breadcrumbs; + } + + /** + * Build the array of breadcrumbs. + * + * The array is generated by starting at the current page and then climbing + * the hierarchy until the root is reached. The resulting crumbs are then + * stored in the $breadcrumbs instance variable. + * + * @internal + */ + protected function build() + { + // Used to hold the breadcrumbs as they are being generated. + $hierarchy = array(); + + $grav = Grav::instance(); + $current = $grav['page']; + + // If the page is not routable... + if (!$current) { + // Set up an empty array of crumbs. + $this->breadcrumbs = array(); + return; + } + + // If we are not at the root page... + if (!$current->root()) { + + // If we are configured to include the current page... + if ($this->config['include_current']) { + // Place the current page in the hierarchy. + $hierarchy[$current->url()] = $current; + } + + $current = $current->parent(); + + // As long as $current does not contain the root page... + while ($current && !$current->root()) { + // Get the frontmatter of the page. + $header = $current->header(); + + // Assume we may descend unless otherwise told. + $may_descend = true; + + // If the frontmatter contains a value for $may_descend... + if(isset( + $header->breadcrumbs, + $header->breadcrumbs['may_descend'] + )) { + // Get that value. + $may_descend = $header->breadcrumbs['may_descend']; + } + + // Then, if breadcrumbs should stop at this page... + if ($may_descend === false) { + // Empty the $hierarchy. + $hierarchy = []; + } + + // Place the current page in the hierarchy. + $hierarchy[$current->url()] = $current; + + // Get the parent of the current page. + $current = $current->parent(); + } + } + + // If we are configured to include the home page... + if ($this->config['include_home']) { + // Get the home page. + $home = $grav['pages']->dispatch('/'); + + // If the home page isn't already in the hierarchy... + if ($home && !array_key_exists($home->url(), $hierarchy)) { + // Place the home page in the hierarchy. + $hierarchy[] = $home; + } + } + + // Reverse the array of breadcrumbs, so that they are in descending + // order. + $this->breadcrumbs = array_reverse($hierarchy); + } +} diff --git a/plugins/breadcrumbs/composer.json b/plugins/breadcrumbs/composer.json new file mode 100644 index 0000000..21f1979 --- /dev/null +++ b/plugins/breadcrumbs/composer.json @@ -0,0 +1,32 @@ +{ + "name": "grav-plugin-breadcrumbs", + "type": "grav-plugin", + "description": "Breadcrumbs plugin for Grav CMS", + "keywords": ["breadcrumbs"], + "homepage": "https://github.com/getgrav/grav-plugin-breadcrumbs/", + "license": "MIT", + "authors": [ + { + "name": "Team Grav", + "email": "devs@getgrav.org", + "homepage": "http://getgrav.org", + "role": "Developer" + } + ], + "require": { + "php": ">=7.1.3", + "ext-json": "*", + "ext-mbstring": "*" + }, + "autoload": { + "psr-4": { + "Grav\\Plugin\\Breadcrumbs\\": "classes/plugin" + }, + "classmap": ["breadcrumbs.php"] + }, + "config": { + "platform": { + "php": "7.1.3" + } + } +} diff --git a/plugins/breadcrumbs/composer.lock b/plugins/breadcrumbs/composer.lock new file mode 100644 index 0000000..87e59c5 --- /dev/null +++ b/plugins/breadcrumbs/composer.lock @@ -0,0 +1,24 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "df6ebb29e1322fb9746644198a99943b", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.1.3", + "ext-json": "*", + "ext-mbstring": "*" + }, + "platform-dev": [], + "platform-overrides": { + "php": "7.1.3" + } +} diff --git a/plugins/breadcrumbs/css/breadcrumbs.css b/plugins/breadcrumbs/css/breadcrumbs.css new file mode 100644 index 0000000..90a9df6 --- /dev/null +++ b/plugins/breadcrumbs/css/breadcrumbs.css @@ -0,0 +1,18 @@ +#breadcrumbs { + height: 3rem; + line-height: 3rem; + padding-left: 3rem; +} +#breadcrumbs span { + display: inline-block; + padding: 0 1rem; +} +#breadcrumbs span:first-child { + padding-left: 0; +} +#breadcrumbs i { + display: inline-block; + width: 20px; + text-align: center; +} + diff --git a/plugins/breadcrumbs/hebe.json b/plugins/breadcrumbs/hebe.json new file mode 100644 index 0000000..4550344 --- /dev/null +++ b/plugins/breadcrumbs/hebe.json @@ -0,0 +1,15 @@ +{ + "project":"grav-plugin-breadcrumbs", + "platforms":{ + "grav":{ + "nodes":{ + "plugin":[ + { + "source":"/", + "destination":"/user/plugins/breadcrumbs" + } + ] + } + } + } +} diff --git a/plugins/breadcrumbs/languages.yaml b/plugins/breadcrumbs/languages.yaml new file mode 100644 index 0000000..8f20b37 --- /dev/null +++ b/plugins/breadcrumbs/languages.yaml @@ -0,0 +1,32 @@ +en: + PLUGIN_BREADCRUMBS: + SHOW_WITH_ONE_ITEM: 'Show even with one item' + BUILTIN_CSS: 'Use built in CSS' + BUILTIN_CSS_HELP: 'Include the CSS provided by the plugin' + INCLUDE_HOME: 'Include Home' + INCLUDE_CURRENT_PAGE: 'Include Current Page' + ICON_HOME: 'Icon home' + ICON_DIVIDER_CLASSES: 'Icon Divider Classes' + LINK_TRAILING: 'Link Trailing' + +uk: + PLUGIN_BREADCRUMBS: + SHOW_WITH_ONE_ITEM: 'Показувати навіть з одним елементом' + BUILTIN_CSS: 'Використовувати вбудований CSS' + BUILTIN_CSS_HELP: 'Включити CSS, що надається плагіном' + INCLUDE_HOME: 'Включити головну сторінку' + INCLUDE_CURRENT_PAGE: 'Включати активну сторінку' + ICON_HOME: 'Іконка головної сторінки' + ICON_DIVIDER_CLASSES: 'Клас іконки розділювача' + LINK_TRAILING: 'Трейлінг посилання' + +ru: + PLUGIN_BREADCRUMBS: + SHOW_WITH_ONE_ITEM: 'Показывать даже с одним элементом' + BUILTIN_CSS: 'Использовать встроенный CSS' + BUILTIN_CSS_HELP: 'Включить CSS, предоставляемый плагином' + INCLUDE_HOME: 'Включить главную страницу' + INCLUDE_CURRENT_PAGE: 'Включать текущую страницу' + ICON_HOME: 'Иконка главной страницы' + ICON_DIVIDER_CLASSES: 'Класс иконки разделителя' + LINK_TRAILING: 'Трейлинг ссылки' diff --git a/plugins/breadcrumbs/templates/partials/breadcrumbs.html.twig b/plugins/breadcrumbs/templates/partials/breadcrumbs.html.twig new file mode 100644 index 0000000..fcb255a --- /dev/null +++ b/plugins/breadcrumbs/templates/partials/breadcrumbs.html.twig @@ -0,0 +1,38 @@ +{% set crumbs = breadcrumbs.get() %} +{% set breadcrumbs_config = config.plugins.breadcrumbs %} +{% set divider = breadcrumbs_config.icon_divider_classes %} + +{% if crumbs|length > 1 or breadcrumbs_config.show_all %} + +{% endif %} diff --git a/plugins/breadcrumbs/vendor/autoload.php b/plugins/breadcrumbs/vendor/autoload.php new file mode 100644 index 0000000..e0bc823 --- /dev/null +++ b/plugins/breadcrumbs/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + private $classMapAuthoritative = false; + private $missingClasses = array(); + private $apcuPrefix; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath.'\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/plugins/breadcrumbs/vendor/composer/LICENSE b/plugins/breadcrumbs/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/plugins/breadcrumbs/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/plugins/breadcrumbs/vendor/composer/autoload_classmap.php b/plugins/breadcrumbs/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..1e48ed9 --- /dev/null +++ b/plugins/breadcrumbs/vendor/composer/autoload_classmap.php @@ -0,0 +1,10 @@ + $baseDir . '/breadcrumbs.php', +); diff --git a/plugins/breadcrumbs/vendor/composer/autoload_namespaces.php b/plugins/breadcrumbs/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..b7fc012 --- /dev/null +++ b/plugins/breadcrumbs/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($baseDir . '/classes/plugin'), +); diff --git a/plugins/breadcrumbs/vendor/composer/autoload_real.php b/plugins/breadcrumbs/vendor/composer/autoload_real.php new file mode 100644 index 0000000..c1891fd --- /dev/null +++ b/plugins/breadcrumbs/vendor/composer/autoload_real.php @@ -0,0 +1,52 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require_once __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInit3ccdcd6f1ac1044c32372e7c5a66846a::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + return $loader; + } +} diff --git a/plugins/breadcrumbs/vendor/composer/autoload_static.php b/plugins/breadcrumbs/vendor/composer/autoload_static.php new file mode 100644 index 0000000..6dbff43 --- /dev/null +++ b/plugins/breadcrumbs/vendor/composer/autoload_static.php @@ -0,0 +1,36 @@ + + array ( + 'Grav\\Plugin\\Breadcrumbs\\' => 24, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'Grav\\Plugin\\Breadcrumbs\\' => + array ( + 0 => __DIR__ . '/../..' . '/classes/plugin', + ), + ); + + public static $classMap = array ( + 'Grav\\Plugin\\BreadcrumbsPlugin' => __DIR__ . '/../..' . '/breadcrumbs.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInit3ccdcd6f1ac1044c32372e7c5a66846a::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit3ccdcd6f1ac1044c32372e7c5a66846a::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit3ccdcd6f1ac1044c32372e7c5a66846a::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/plugins/breadcrumbs/vendor/composer/installed.json b/plugins/breadcrumbs/vendor/composer/installed.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/plugins/breadcrumbs/vendor/composer/installed.json @@ -0,0 +1 @@ +[]