From e64b18b9a9a345a8c5148523ce90cf6faa67e8e5 Mon Sep 17 00:00:00 2001
From: ouidade
Date: Tue, 20 Oct 2020 09:32:09 +0200
Subject: [PATCH] first commit
---
.github/FUNDING.yml | 8 +
.htaccess | 75 +
CHANGELOG.md | 2708 +++
CODE_OF_CONDUCT.md | 46 +
CONTRIBUTING.md | 138 +
LICENSE.txt | 21 +
README.md | 134 +
assets/.gitkeep | 0
backup/.gitkeep | 0
bin/composer.phar | Bin 0 -> 1909682 bytes
bin/gpm | 79 +
bin/grav | 74 +
bin/plugin | 152 +
cache/.gitkeep | 0
composer.json | 111 +
composer.lock | 5872 +++++++
images/.gitkeep | 0
index.php | 61 +
logs/.gitkeep | 0
now.json | 4 +
robots.txt | 13 +
system/aliases.php | 5 +
system/assets/debugger.css | 70 +
system/assets/grav.png | Bin 0 -> 4166 bytes
system/assets/jquery/jquery-2.1.4.min.js | 4 +
system/assets/jquery/jquery-2.x.min.js | 4 +
system/assets/jquery/jquery-3.x.min.js | 2 +
system/assets/responsive-overlays/1x.png | Bin 0 -> 3238 bytes
system/assets/responsive-overlays/2x.png | Bin 0 -> 7593 bytes
system/assets/responsive-overlays/3x.png | Bin 0 -> 13002 bytes
system/assets/responsive-overlays/4x.png | Bin 0 -> 15545 bytes
system/assets/responsive-overlays/unknown.png | Bin 0 -> 5241 bytes
system/assets/whoops.css | 19 +
system/blueprints/config/backups.yaml | 125 +
system/blueprints/config/media.yaml | 5 +
system/blueprints/config/scheduler.yaml | 76 +
system/blueprints/config/security.yaml | 107 +
system/blueprints/config/site.yaml | 124 +
system/blueprints/config/streams.yaml | 8 +
system/blueprints/config/system.yaml | 1467 ++
system/blueprints/pages/default.yaml | 369 +
system/blueprints/pages/external.yaml | 52 +
system/blueprints/pages/modular.yaml | 38 +
system/blueprints/user/account.yaml | 127 +
system/blueprints/user/account_new.yaml | 18 +
system/blueprints/user/accounts.yaml | 39 +
system/blueprints/user/group.yaml | 37 +
system/blueprints/user/group_new.yaml | 16 +
system/config/backups.yaml | 15 +
system/config/media.yaml | 210 +
system/config/security.yaml | 38 +
system/config/site.yaml | 35 +
system/config/streams.yaml | 16 +
system/config/system.yaml | 180 +
system/defines.php | 53 +
system/images/media/thumb-3dm.png | Bin 0 -> 3013 bytes
system/images/media/thumb-3ds.png | Bin 0 -> 3116 bytes
system/images/media/thumb-3g2.png | Bin 0 -> 3006 bytes
system/images/media/thumb-3gp.png | Bin 0 -> 2853 bytes
system/images/media/thumb-7z.png | Bin 0 -> 1648 bytes
system/images/media/thumb-aac.png | Bin 0 -> 3218 bytes
system/images/media/thumb-ai.png | Bin 0 -> 1595 bytes
system/images/media/thumb-aif.png | Bin 0 -> 1691 bytes
system/images/media/thumb-apk.png | Bin 0 -> 2557 bytes
system/images/media/thumb-app.png | Bin 0 -> 2360 bytes
system/images/media/thumb-asf.png | Bin 0 -> 2635 bytes
system/images/media/thumb-asp.png | Bin 0 -> 2913 bytes
system/images/media/thumb-aspx.png | Bin 0 -> 3726 bytes
system/images/media/thumb-asx.png | Bin 0 -> 3287 bytes
system/images/media/thumb-avi.png | Bin 0 -> 2448 bytes
system/images/media/thumb-bak.png | Bin 0 -> 2814 bytes
system/images/media/thumb-bat.png | Bin 0 -> 2182 bytes
system/images/media/thumb-bin.png | Bin 0 -> 1841 bytes
system/images/media/thumb-bmp.png | Bin 0 -> 2573 bytes
system/images/media/thumb-cab.png | Bin 0 -> 3056 bytes
system/images/media/thumb-cad.png | Bin 0 -> 3021 bytes
system/images/media/thumb-cdr.png | Bin 0 -> 2713 bytes
system/images/media/thumb-cer.png | Bin 0 -> 2367 bytes
system/images/media/thumb-cfg.png | Bin 0 -> 2764 bytes
system/images/media/thumb-cfm.png | Bin 0 -> 2589 bytes
system/images/media/thumb-cgi.png | Bin 0 -> 2626 bytes
system/images/media/thumb-com.png | Bin 0 -> 3292 bytes
system/images/media/thumb-cpl.png | Bin 0 -> 2174 bytes
system/images/media/thumb-cpp.png | Bin 0 -> 2425 bytes
system/images/media/thumb-crx.png | Bin 0 -> 2965 bytes
system/images/media/thumb-csr.png | Bin 0 -> 3158 bytes
system/images/media/thumb-css.png | Bin 0 -> 3235 bytes
system/images/media/thumb-csv.png | Bin 0 -> 3317 bytes
system/images/media/thumb-cue.png | Bin 0 -> 2271 bytes
system/images/media/thumb-cur.png | Bin 0 -> 2716 bytes
system/images/media/thumb-dat.png | Bin 0 -> 2188 bytes
system/images/media/thumb-db.png | Bin 0 -> 1964 bytes
system/images/media/thumb-dbf.png | Bin 0 -> 1947 bytes
system/images/media/thumb-dds.png | Bin 0 -> 2815 bytes
system/images/media/thumb-dem.png | Bin 0 -> 2215 bytes
system/images/media/thumb-dll.png | Bin 0 -> 1352 bytes
system/images/media/thumb-dmg.png | Bin 0 -> 3064 bytes
system/images/media/thumb-dmp.png | Bin 0 -> 2527 bytes
system/images/media/thumb-doc.png | Bin 0 -> 3051 bytes
system/images/media/thumb-docx.png | Bin 0 -> 3865 bytes
system/images/media/thumb-drv.png | Bin 0 -> 2728 bytes
system/images/media/thumb-dtd.png | Bin 0 -> 1949 bytes
system/images/media/thumb-dwg.png | Bin 0 -> 3530 bytes
system/images/media/thumb-dxf.png | Bin 0 -> 2392 bytes
system/images/media/thumb-elf.png | Bin 0 -> 663 bytes
system/images/media/thumb-eot.png | Bin 0 -> 2002 bytes
system/images/media/thumb-eps.png | Bin 0 -> 2276 bytes
system/images/media/thumb-exe.png | Bin 0 -> 1813 bytes
system/images/media/thumb-fla.png | Bin 0 -> 1724 bytes
system/images/media/thumb-flv.png | Bin 0 -> 1720 bytes
system/images/media/thumb-fnt.png | Bin 0 -> 1254 bytes
system/images/media/thumb-fon.png | Bin 0 -> 2402 bytes
system/images/media/thumb-gam.png | Bin 0 -> 3203 bytes
system/images/media/thumb-gbr.png | Bin 0 -> 2849 bytes
system/images/media/thumb-ged.png | Bin 0 -> 2269 bytes
system/images/media/thumb-gif.png | Bin 0 -> 1751 bytes
system/images/media/thumb-gpx.png | Bin 0 -> 2972 bytes
system/images/media/thumb-gz.png | Bin 0 -> 2134 bytes
system/images/media/thumb-gzip.png | Bin 0 -> 2451 bytes
system/images/media/thumb-hqz.png | Bin 0 -> 2604 bytes
system/images/media/thumb-html.png | Bin 0 -> 1740 bytes
system/images/media/thumb-icns.png | Bin 0 -> 3212 bytes
system/images/media/thumb-ico.png | Bin 0 -> 2769 bytes
system/images/media/thumb-ics.png | Bin 0 -> 2787 bytes
system/images/media/thumb-iff.png | Bin 0 -> 601 bytes
system/images/media/thumb-indd.png | Bin 0 -> 2475 bytes
system/images/media/thumb-iso.png | Bin 0 -> 2864 bytes
system/images/media/thumb-jar.png | Bin 0 -> 2583 bytes
system/images/media/thumb-jpg.png | Bin 0 -> 2435 bytes
system/images/media/thumb-js.png | Bin 0 -> 2046 bytes
system/images/media/thumb-json.png | Bin 0 -> 7818 bytes
system/images/media/thumb-jsp.png | Bin 0 -> 2498 bytes
system/images/media/thumb-key.png | Bin 0 -> 2130 bytes
system/images/media/thumb-kml.png | Bin 0 -> 2346 bytes
system/images/media/thumb-kmz.png | Bin 0 -> 2701 bytes
system/images/media/thumb-lnk.png | Bin 0 -> 1971 bytes
system/images/media/thumb-log.png | Bin 0 -> 2762 bytes
system/images/media/thumb-lua.png | Bin 0 -> 2117 bytes
system/images/media/thumb-m3u.png | Bin 0 -> 2909 bytes
system/images/media/thumb-m4a.png | Bin 0 -> 2754 bytes
system/images/media/thumb-m4v.png | Bin 0 -> 2738 bytes
system/images/media/thumb-max.png | Bin 0 -> 3213 bytes
system/images/media/thumb-mdb.png | Bin 0 -> 2691 bytes
system/images/media/thumb-mdf.png | Bin 0 -> 2243 bytes
system/images/media/thumb-mid.png | Bin 0 -> 2199 bytes
system/images/media/thumb-mim.png | Bin 0 -> 2284 bytes
system/images/media/thumb-mov.png | Bin 0 -> 3221 bytes
system/images/media/thumb-mp3.png | Bin 0 -> 2801 bytes
system/images/media/thumb-mp4.png | Bin 0 -> 2221 bytes
system/images/media/thumb-mpa.png | Bin 0 -> 2734 bytes
system/images/media/thumb-mpe.png | Bin 0 -> 1971 bytes
system/images/media/thumb-mpg.png | Bin 0 -> 2811 bytes
system/images/media/thumb-msg.png | Bin 0 -> 3319 bytes
system/images/media/thumb-msi.png | Bin 0 -> 2594 bytes
system/images/media/thumb-nes.png | Bin 0 -> 2320 bytes
system/images/media/thumb-obj.png | Bin 0 -> 2716 bytes
system/images/media/thumb-odb.png | Bin 0 -> 2912 bytes
system/images/media/thumb-odc.png | Bin 0 -> 3239 bytes
system/images/media/thumb-odf.png | Bin 0 -> 2496 bytes
system/images/media/thumb-odg.png | Bin 0 -> 3069 bytes
system/images/media/thumb-odi.png | Bin 0 -> 2453 bytes
system/images/media/thumb-odp.png | Bin 0 -> 2871 bytes
system/images/media/thumb-ods.png | Bin 0 -> 3257 bytes
system/images/media/thumb-odt.png | Bin 0 -> 2414 bytes
system/images/media/thumb-odx.png | Bin 0 -> 3133 bytes
system/images/media/thumb-ogg.png | Bin 0 -> 3577 bytes
system/images/media/thumb-pct.png | Bin 0 -> 2248 bytes
system/images/media/thumb-pdb.png | Bin 0 -> 2354 bytes
system/images/media/thumb-pdf.png | Bin 0 -> 1823 bytes
system/images/media/thumb-pif.png | Bin 0 -> 1103 bytes
system/images/media/thumb-pkg.png | Bin 0 -> 2660 bytes
system/images/media/thumb-pl.png | Bin 0 -> 1066 bytes
system/images/media/thumb-png.png | Bin 0 -> 2530 bytes
system/images/media/thumb-pps.png | Bin 0 -> 2497 bytes
system/images/media/thumb-ppt.png | Bin 0 -> 1573 bytes
system/images/media/thumb-pptx.png | Bin 0 -> 2560 bytes
system/images/media/thumb-ps.png | Bin 0 -> 2285 bytes
system/images/media/thumb-psd.png | Bin 0 -> 2613 bytes
system/images/media/thumb-pub.png | Bin 0 -> 2137 bytes
system/images/media/thumb-py.png | Bin 0 -> 1776 bytes
system/images/media/thumb-ra.png | Bin 0 -> 2223 bytes
system/images/media/thumb-rar.png | Bin 0 -> 2695 bytes
system/images/media/thumb-raw.png | Bin 0 -> 3433 bytes
system/images/media/thumb-rm.png | Bin 0 -> 2181 bytes
system/images/media/thumb-rom.png | Bin 0 -> 3088 bytes
system/images/media/thumb-rpm.png | Bin 0 -> 2566 bytes
system/images/media/thumb-rss.png | Bin 0 -> 3091 bytes
system/images/media/thumb-rtf.png | Bin 0 -> 1364 bytes
system/images/media/thumb-sav.png | Bin 0 -> 3204 bytes
system/images/media/thumb-sdf.png | Bin 0 -> 2444 bytes
system/images/media/thumb-sql.png | Bin 0 -> 2929 bytes
system/images/media/thumb-srt.png | Bin 0 -> 2366 bytes
system/images/media/thumb-svg.png | Bin 0 -> 3359 bytes
system/images/media/thumb-swf.png | Bin 0 -> 3181 bytes
system/images/media/thumb-sys.png | Bin 0 -> 3128 bytes
system/images/media/thumb-tar.png | Bin 0 -> 2165 bytes
system/images/media/thumb-tex.png | Bin 0 -> 1716 bytes
system/images/media/thumb-tga.png | Bin 0 -> 2655 bytes
system/images/media/thumb-thm.png | Bin 0 -> 1666 bytes
system/images/media/thumb-tiff.png | Bin 0 -> 690 bytes
system/images/media/thumb-tmp.png | Bin 0 -> 2040 bytes
system/images/media/thumb-ttf.png | Bin 0 -> 615 bytes
system/images/media/thumb-txt.png | Bin 0 -> 1853 bytes
system/images/media/thumb-uue.png | Bin 0 -> 1632 bytes
system/images/media/thumb-vb.png | Bin 0 -> 2074 bytes
system/images/media/thumb-vcd.png | Bin 0 -> 3040 bytes
system/images/media/thumb-vcf.png | Bin 0 -> 2581 bytes
system/images/media/thumb-wav.png | Bin 0 -> 3601 bytes
system/images/media/thumb-webm.png | Bin 0 -> 3843 bytes
system/images/media/thumb-wma.png | Bin 0 -> 3552 bytes
system/images/media/thumb-wmv.png | Bin 0 -> 3789 bytes
system/images/media/thumb-woff.png | Bin 0 -> 3421 bytes
system/images/media/thumb-woff2.png | Bin 0 -> 3927 bytes
system/images/media/thumb-wpd.png | Bin 0 -> 3127 bytes
system/images/media/thumb-wps.png | Bin 0 -> 3368 bytes
system/images/media/thumb-wsf.png | Bin 0 -> 3028 bytes
system/images/media/thumb-xls.png | Bin 0 -> 2562 bytes
system/images/media/thumb-xlsx.png | Bin 0 -> 3481 bytes
system/images/media/thumb-xml.png | Bin 0 -> 2557 bytes
system/images/media/thumb-yuv.png | Bin 0 -> 2741 bytes
system/images/media/thumb-zip.png | Bin 0 -> 1628 bytes
system/images/media/thumb.png | Bin 0 -> 1200 bytes
system/install.php | 17 +
system/languages/ar.yaml | 63 +
system/languages/bg.yaml | 62 +
system/languages/ca.yaml | 62 +
system/languages/cs.yaml | 144 +
system/languages/da.yaml | 62 +
system/languages/de.yaml | 144 +
system/languages/el.yaml | 63 +
system/languages/en.yaml | 120 +
system/languages/es.yaml | 95 +
system/languages/et.yaml | 85 +
system/languages/eu.yaml | 62 +
system/languages/fa.yaml | 62 +
system/languages/fi.yaml | 134 +
system/languages/fr.yaml | 123 +
system/languages/he.yaml | 63 +
system/languages/hr.yaml | 76 +
system/languages/hu.yaml | 97 +
system/languages/id.yaml | 95 +
system/languages/is.yaml | 80 +
system/languages/it.yaml | 101 +
system/languages/ja.yaml | 66 +
system/languages/ko.yaml | 63 +
system/languages/lt.yaml | 78 +
system/languages/nb.yaml | 4 +
system/languages/nl.yaml | 144 +
system/languages/no.yaml | 77 +
system/languages/pl.yaml | 62 +
system/languages/pt.yaml | 46 +
system/languages/ro.yaml | 96 +
system/languages/ru.yaml | 101 +
system/languages/sk.yaml | 144 +
system/languages/sl.yaml | 62 +
system/languages/sv.yaml | 72 +
system/languages/th.yaml | 56 +
system/languages/tr.yaml | 63 +
system/languages/uk.yaml | 63 +
system/languages/vi.yaml | 63 +
system/languages/zh-tw.yaml | 62 +
system/languages/zh.yaml | 144 +
system/pages/notfound.md | 6 +
system/router.php | 37 +
system/src/Grav/Common/Assets.php | 375 +
system/src/Grav/Common/Assets/BaseAsset.php | 198 +
system/src/Grav/Common/Assets/Css.php | 40 +
system/src/Grav/Common/Assets/InlineCss.php | 32 +
system/src/Grav/Common/Assets/InlineJs.php | 32 +
system/src/Grav/Common/Assets/Js.php | 36 +
system/src/Grav/Common/Assets/Pipeline.php | 273 +
.../Common/Assets/Traits/AssetUtilsTrait.php | 182 +
.../Assets/Traits/LegacyAssetsTrait.php | 129 +
.../Assets/Traits/TestingAssetsTrait.php | 343 +
system/src/Grav/Common/Backup/Backups.php | 261 +
system/src/Grav/Common/Browser.php | 151 +
system/src/Grav/Common/Cache.php | 656 +
system/src/Grav/Common/Composer.php | 61 +
.../src/Grav/Common/Config/CompiledBase.php | 263 +
.../Grav/Common/Config/CompiledBlueprints.php | 119 +
.../src/Grav/Common/Config/CompiledConfig.php | 101 +
.../Grav/Common/Config/CompiledLanguages.php | 67 +
system/src/Grav/Common/Config/Config.php | 126 +
.../Grav/Common/Config/ConfigFileFinder.php | 263 +
system/src/Grav/Common/Config/Languages.php | 83 +
system/src/Grav/Common/Config/Setup.php | 321 +
system/src/Grav/Common/Data/Blueprint.php | 428 +
.../src/Grav/Common/Data/BlueprintSchema.php | 330 +
system/src/Grav/Common/Data/Blueprints.php | 114 +
system/src/Grav/Common/Data/Data.php | 327 +
system/src/Grav/Common/Data/DataInterface.php | 70 +
system/src/Grav/Common/Data/Validation.php | 813 +
.../Grav/Common/Data/ValidationException.php | 38 +
system/src/Grav/Common/Debugger.php | 606 +
system/src/Grav/Common/Errors/BareHandler.php | 32 +
system/src/Grav/Common/Errors/Errors.php | 73 +
.../Grav/Common/Errors/Resources/error.css | 52 +
.../Common/Errors/Resources/layout.html.php | 30 +
.../Grav/Common/Errors/SimplePageHandler.php | 108 +
.../src/Grav/Common/Errors/SystemFacade.php | 40 +
system/src/Grav/Common/File/CompiledFile.php | 110 +
.../src/Grav/Common/File/CompiledJsonFile.php | 29 +
.../Grav/Common/File/CompiledMarkdownFile.php | 17 +
.../src/Grav/Common/File/CompiledYamlFile.php | 17 +
.../src/Grav/Common/Filesystem/Archiver.php | 66 +
system/src/Grav/Common/Filesystem/Folder.php | 526 +
.../RecursiveDirectoryFilterIterator.php | 67 +
.../RecursiveFolderFilterIterator.php | 47 +
.../Grav/Common/Filesystem/ZipArchiver.php | 111 +
system/src/Grav/Common/Form/FormFlash.php | 101 +
.../Grav/Common/GPM/AbstractCollection.php | 31 +
.../GPM/Common/AbstractPackageCollection.php | 39 +
.../Common/GPM/Common/CachedCollection.php | 33 +
system/src/Grav/Common/GPM/Common/Package.php | 70 +
system/src/Grav/Common/GPM/GPM.php | 1160 ++
system/src/Grav/Common/GPM/Installer.php | 543 +
system/src/Grav/Common/GPM/Licenses.php | 123 +
.../GPM/Local/AbstractPackageCollection.php | 25 +
system/src/Grav/Common/GPM/Local/Package.php | 41 +
system/src/Grav/Common/GPM/Local/Packages.php | 25 +
system/src/Grav/Common/GPM/Local/Plugins.php | 31 +
system/src/Grav/Common/GPM/Local/Themes.php | 28 +
.../GPM/Remote/AbstractPackageCollection.php | 77 +
.../src/Grav/Common/GPM/Remote/GravCore.php | 141 +
system/src/Grav/Common/GPM/Remote/Package.php | 27 +
.../src/Grav/Common/GPM/Remote/Packages.php | 25 +
system/src/Grav/Common/GPM/Remote/Plugins.php | 30 +
system/src/Grav/Common/GPM/Remote/Themes.php | 30 +
system/src/Grav/Common/GPM/Response.php | 436 +
system/src/Grav/Common/GPM/Upgrader.php | 142 +
system/src/Grav/Common/Getters.php | 161 +
system/src/Grav/Common/Grav.php | 618 +
system/src/Grav/Common/GravTrait.php | 33 +
system/src/Grav/Common/Helpers/Base32.php | 129 +
system/src/Grav/Common/Helpers/Excerpts.php | 183 +
system/src/Grav/Common/Helpers/Exif.php | 41 +
system/src/Grav/Common/Helpers/LogViewer.php | 149 +
system/src/Grav/Common/Helpers/Truncator.php | 335 +
system/src/Grav/Common/Helpers/YamlLinter.php | 89 +
system/src/Grav/Common/Inflector.php | 330 +
system/src/Grav/Common/Iterator.php | 265 +
system/src/Grav/Common/Language/Language.php | 537 +
.../Grav/Common/Language/LanguageCodes.php | 205 +
system/src/Grav/Common/Markdown/Parsedown.php | 40 +
.../Grav/Common/Markdown/ParsedownExtra.php | 42 +
.../Common/Markdown/ParsedownGravTrait.php | 277 +
.../Interfaces/MediaCollectionInterface.php | 23 +
.../Media/Interfaces/MediaInterface.php | 17 +
.../Media/Interfaces/MediaObjectInterface.php | 17 +
.../Grav/Common/Media/Traits/MediaTrait.php | 129 +
system/src/Grav/Common/Page/Collection.php | 630 +
system/src/Grav/Common/Page/Header.php | 18 +
.../Page/Interfaces/PageContentInterface.php | 267 +
.../Common/Page/Interfaces/PageInterface.php | 19 +
.../Page/Interfaces/PageLegacyInterface.php | 496 +
.../Page/Interfaces/PageRoutableInterface.php | 188 +
.../Interfaces/PageTranslateInterface.php | 32 +
.../Grav/Common/Page/Markdown/Excerpts.php | 330 +
system/src/Grav/Common/Page/Media.php | 222 +
.../Grav/Common/Page/Medium/AbstractMedia.php | 244 +
.../Grav/Common/Page/Medium/AudioMedium.php | 148 +
.../Grav/Common/Page/Medium/GlobalMedia.php | 128 +
.../src/Grav/Common/Page/Medium/ImageFile.php | 145 +
.../Grav/Common/Page/Medium/ImageMedium.php | 668 +
system/src/Grav/Common/Page/Medium/Link.php | 71 +
system/src/Grav/Common/Page/Medium/Medium.php | 679 +
.../Grav/Common/Page/Medium/MediumFactory.php | 192 +
.../Common/Page/Medium/ParsedownHtmlTrait.php | 42 +
.../Page/Medium/RenderableInterface.php | 36 +
.../Common/Page/Medium/StaticImageMedium.php | 29 +
.../Common/Page/Medium/StaticResizeTrait.php | 28 +
.../Page/Medium/ThumbnailImageMedium.php | 132 +
.../Grav/Common/Page/Medium/VideoMedium.php | 162 +
system/src/Grav/Common/Page/Page.php | 3183 ++++
system/src/Grav/Common/Page/Pages.php | 1443 ++
system/src/Grav/Common/Page/Types.php | 141 +
system/src/Grav/Common/Plugin.php | 390 +
system/src/Grav/Common/Plugins.php | 228 +
.../Common/Processors/AssetsProcessor.php | 30 +
.../Common/Processors/BackupsProcessor.php | 30 +
.../Processors/ConfigurationProcessor.php | 30 +
.../Processors/DebuggerAssetsProcessor.php | 31 +
.../Common/Processors/DebuggerProcessor.php | 29 +
.../Common/Processors/ErrorsProcessor.php | 29 +
.../Processors/Events/RequestHandlerEvent.php | 78 +
.../Common/Processors/InitializeProcessor.php | 128 +
.../Common/Processors/LoggerProcessor.php | 50 +
.../Grav/Common/Processors/PagesProcessor.php | 71 +
.../Common/Processors/PluginsProcessor.php | 32 +
.../Grav/Common/Processors/ProcessorBase.php | 48 +
.../Common/Processors/ProcessorInterface.php | 16 +
.../Common/Processors/RenderProcessor.php | 55 +
.../Common/Processors/RequestProcessor.php | 54 +
.../Common/Processors/SchedulerProcessor.php | 31 +
.../Grav/Common/Processors/TasksProcessor.php | 61 +
.../Common/Processors/ThemesProcessor.php | 29 +
.../Grav/Common/Processors/TwigProcessor.php | 29 +
system/src/Grav/Common/Scheduler/Cron.php | 595 +
.../Grav/Common/Scheduler/IntervalTrait.php | 399 +
system/src/Grav/Common/Scheduler/Job.php | 522 +
.../src/Grav/Common/Scheduler/Scheduler.php | 361 +
system/src/Grav/Common/Security.php | 165 +
.../Service/AccountsServiceProvider.php | 129 +
.../Common/Service/AssetsServiceProvider.php | 24 +
.../Common/Service/BackupsServiceProvider.php | 27 +
.../Common/Service/ConfigServiceProvider.php | 172 +
.../Common/Service/ErrorServiceProvider.php | 22 +
.../Service/FilesystemServiceProvider.php | 24 +
.../Service/InflectorServiceProvider.php | 24 +
.../Common/Service/LoggerServiceProvider.php | 34 +
.../Common/Service/OutputServiceProvider.php | 31 +
.../Common/Service/PagesServiceProvider.php | 117 +
.../Common/Service/RequestServiceProvider.php | 38 +
.../Service/SchedulerServiceProvider.php | 24 +
.../Common/Service/SessionServiceProvider.php | 119 +
.../Common/Service/StreamsServiceProvider.php | 48 +
.../Common/Service/TaskServiceProvider.php | 38 +
system/src/Grav/Common/Session.php | 166 +
system/src/Grav/Common/Taxonomy.php | 144 +
system/src/Grav/Common/Theme.php | 96 +
system/src/Grav/Common/Themes.php | 371 +
.../Grav/Common/Twig/Node/TwigNodeCache.php | 56 +
.../Common/Twig/Node/TwigNodeMarkdown.php | 46 +
.../Grav/Common/Twig/Node/TwigNodeRender.php | 78 +
.../Grav/Common/Twig/Node/TwigNodeScript.php | 101 +
.../Grav/Common/Twig/Node/TwigNodeStyle.php | 101 +
.../Grav/Common/Twig/Node/TwigNodeSwitch.php | 85 +
.../Grav/Common/Twig/Node/TwigNodeThrow.php | 51 +
.../Common/Twig/Node/TwigNodeTryCatch.php | 68 +
.../Twig/TokenParser/TwigTokenParserCache.php | 68 +
.../TokenParser/TwigTokenParserMarkdown.php | 56 +
.../TokenParser/TwigTokenParserRender.php | 75 +
.../TokenParser/TwigTokenParserScript.php | 104 +
.../Twig/TokenParser/TwigTokenParserStyle.php | 103 +
.../TokenParser/TwigTokenParserSwitch.php | 130 +
.../Twig/TokenParser/TwigTokenParserThrow.php | 54 +
.../TokenParser/TwigTokenParserTryCatch.php | 72 +
system/src/Grav/Common/Twig/Twig.php | 454 +
.../src/Grav/Common/Twig/TwigEnvironment.php | 15 +
system/src/Grav/Common/Twig/TwigExtension.php | 1499 ++
.../Grav/Common/Twig/WriteCacheFileTrait.php | 49 +
system/src/Grav/Common/Uri.php | 1435 ++
.../src/Grav/Common/User/Authentication.php | 55 +
system/src/Grav/Common/User/DataUser/User.php | 272 +
.../Common/User/DataUser/UserCollection.php | 130 +
.../User/FlexUser/Storage/UserFileStorage.php | 16 +
.../FlexUser/Storage/UserFolderStorage.php | 16 +
system/src/Grav/Common/User/FlexUser/User.php | 710 +
.../Common/User/FlexUser/UserCollection.php | 100 +
.../Grav/Common/User/FlexUser/UserIndex.php | 133 +
system/src/Grav/Common/User/Group.php | 155 +
.../Interfaces/UserCollectionInterface.php | 40 +
.../Common/User/Interfaces/UserInterface.php | 198 +
.../src/Grav/Common/User/Traits/UserTrait.php | 171 +
system/src/Grav/Common/User/User.php | 146 +
system/src/Grav/Common/Utils.php | 1641 ++
system/src/Grav/Common/Yaml.php | 48 +
system/src/Grav/Console/Cli/BackupCommand.php | 120 +
system/src/Grav/Console/Cli/CleanCommand.php | 323 +
.../Grav/Console/Cli/ClearCacheCommand.php | 80 +
.../src/Grav/Console/Cli/ComposerCommand.php | 50 +
.../src/Grav/Console/Cli/InstallCommand.php | 176 +
.../src/Grav/Console/Cli/LogViewerCommand.php | 85 +
.../Grav/Console/Cli/NewProjectCommand.php | 59 +
.../src/Grav/Console/Cli/SandboxCommand.php | 270 +
.../src/Grav/Console/Cli/SchedulerCommand.php | 179 +
.../src/Grav/Console/Cli/SecurityCommand.php | 106 +
.../Grav/Console/Cli/YamlLinterCommand.php | 82 +
system/src/Grav/Console/ConsoleCommand.php | 186 +
system/src/Grav/Console/ConsoleTrait.php | 139 +
.../Grav/Console/Gpm/DirectInstallCommand.php | 309 +
system/src/Grav/Console/Gpm/IndexCommand.php | 265 +
system/src/Grav/Console/Gpm/InfoCommand.php | 180 +
.../src/Grav/Console/Gpm/InstallCommand.php | 691 +
.../Grav/Console/Gpm/SelfupgradeCommand.php | 297 +
.../src/Grav/Console/Gpm/UninstallCommand.php | 295 +
system/src/Grav/Console/Gpm/UpdateCommand.php | 268 +
.../src/Grav/Console/Gpm/VersionCommand.php | 112 +
.../Grav/Console/TerminalObjects/Table.php | 30 +
.../Grav/Framework/Cache/AbstractCache.php | 31 +
.../Framework/Cache/Adapter/ChainCache.php | 198 +
.../Framework/Cache/Adapter/DoctrineCache.php | 116 +
.../Framework/Cache/Adapter/FileCache.php | 233 +
.../Framework/Cache/Adapter/MemoryCache.php | 62 +
.../Framework/Cache/Adapter/SessionCache.php | 79 +
.../Grav/Framework/Cache/CacheInterface.php | 28 +
.../src/Grav/Framework/Cache/CacheTrait.php | 351 +
.../Cache/Exception/CacheException.php | 20 +
.../Exception/InvalidArgumentException.php | 20 +
.../Collection/AbstractFileCollection.php | 228 +
.../Collection/AbstractIndexCollection.php | 510 +
.../Collection/AbstractLazyCollection.php | 81 +
.../Framework/Collection/ArrayCollection.php | 95 +
.../Collection/CollectionInterface.php | 60 +
.../Framework/Collection/FileCollection.php | 94 +
.../Collection/FileCollectionInterface.php | 29 +
.../Framework/ContentBlock/ContentBlock.php | 288 +
.../ContentBlock/ContentBlockInterface.php | 87 +
.../Grav/Framework/ContentBlock/HtmlBlock.php | 387 +
.../ContentBlock/HtmlBlockInterface.php | 95 +
system/src/Grav/Framework/DI/Container.php | 27 +
.../src/Grav/Framework/File/AbstractFile.php | 425 +
system/src/Grav/Framework/File/CsvFile.php | 31 +
system/src/Grav/Framework/File/DataFile.php | 69 +
system/src/Grav/Framework/File/File.php | 37 +
.../File/Formatter/AbstractFormatter.php | 119 +
.../Framework/File/Formatter/CsvFormatter.php | 127 +
.../File/Formatter/FormatterInterface.php | 10 +
.../Framework/File/Formatter/IniFormatter.php | 63 +
.../File/Formatter/JsonFormatter.php | 100 +
.../File/Formatter/MarkdownFormatter.php | 138 +
.../File/Formatter/SerializeFormatter.php | 89 +
.../File/Formatter/YamlFormatter.php | 114 +
system/src/Grav/Framework/File/IniFile.php | 31 +
.../Interfaces/FileFormatterInterface.php | 66 +
.../File/Interfaces/FileInterface.php | 177 +
system/src/Grav/Framework/File/JsonFile.php | 31 +
.../src/Grav/Framework/File/MarkdownFile.php | 31 +
system/src/Grav/Framework/File/YamlFile.php | 31 +
.../Grav/Framework/Filesystem/Filesystem.php | 293 +
.../Interfaces/FilesystemInterface.php | 75 +
system/src/Grav/Framework/Flex/Flex.php | 311 +
.../Grav/Framework/Flex/FlexCollection.php | 525 +
.../src/Grav/Framework/Flex/FlexDirectory.php | 669 +
system/src/Grav/Framework/Flex/FlexForm.php | 344 +
system/src/Grav/Framework/Flex/FlexIndex.php | 704 +
system/src/Grav/Framework/Flex/FlexObject.php | 877 +
.../Interfaces/FlexAuthorizeInterface.php | 32 +
.../Interfaces/FlexCollectionInterface.php | 124 +
.../Flex/Interfaces/FlexCommonInterface.php | 64 +
.../Flex/Interfaces/FlexFormInterface.php | 54 +
.../Flex/Interfaces/FlexIndexInterface.php | 64 +
.../Flex/Interfaces/FlexObjectInterface.php | 208 +
.../Flex/Interfaces/FlexStorageInterface.php | 134 +
.../Storage/AbstractFilesystemStorage.php | 154 +
.../Framework/Flex/Storage/FileStorage.php | 82 +
.../Framework/Flex/Storage/FolderStorage.php | 470 +
.../Framework/Flex/Storage/SimpleStorage.php | 323 +
.../Flex/Traits/FlexAuthorizeTrait.php | 60 +
.../Framework/Flex/Traits/FlexMediaTrait.php | 346 +
system/src/Grav/Framework/Form/FormFlash.php | 519 +
.../src/Grav/Framework/Form/FormFlashFile.php | 159 +
.../Form/Interfaces/FormFactoryInterface.php | 38 +
.../Form/Interfaces/FormFlashInterface.php | 165 +
.../Form/Interfaces/FormInterface.php | 178 +
.../Grav/Framework/Form/Traits/FormTrait.php | 692 +
.../Framework/Interfaces/RenderInterface.php | 38 +
.../Interfaces/MediaCollectionInterface.php | 17 +
.../Media/Interfaces/MediaInterface.php | 37 +
.../Interfaces/MediaManipulationInterface.php | 32 +
.../Media/Interfaces/MediaObjectInterface.php | 17 +
.../Object/Access/ArrayAccessTrait.php | 65 +
.../Object/Access/NestedArrayAccessTrait.php | 65 +
.../Access/NestedPropertyCollectionTrait.php | 125 +
.../Object/Access/NestedPropertyTrait.php | 183 +
.../Object/Access/OverloadedPropertyTrait.php | 65 +
.../src/Grav/Framework/Object/ArrayObject.php | 29 +
.../Object/Base/ObjectCollectionTrait.php | 185 +
.../Framework/Object/Base/ObjectTrait.php | 204 +
.../Collection/ObjectExpressionVisitor.php | 199 +
.../Interfaces/NestedObjectInterface.php | 58 +
.../Interfaces/ObjectCollectionInterface.php | 74 +
.../Object/Interfaces/ObjectInterface.php | 60 +
.../src/Grav/Framework/Object/LazyObject.php | 32 +
.../Framework/Object/ObjectCollection.php | 112 +
.../src/Grav/Framework/Object/ObjectIndex.php | 251 +
.../Object/Property/ArrayPropertyTrait.php | 110 +
.../Object/Property/LazyPropertyTrait.php | 118 +
.../Object/Property/MixedPropertyTrait.php | 123 +
.../Object/Property/ObjectPropertyTrait.php | 207 +
.../Grav/Framework/Object/PropertyObject.php | 29 +
.../Pagination/AbstractPagination.php | 326 +
.../Pagination/AbstractPaginationPage.php | 53 +
.../Interfaces/PaginationInterface.php | 43 +
.../Interfaces/PaginationPageInterface.php | 25 +
.../Grav/Framework/Pagination/Pagination.php | 20 +
.../Framework/Pagination/PaginationPage.php | 18 +
.../Grav/Framework/Parsedown/Parsedown.php | 1554 ++
.../Framework/Parsedown/ParsedownExtra.php | 532 +
.../src/Grav/Framework/Psr7/AbstractUri.php | 408 +
system/src/Grav/Framework/Psr7/Request.php | 34 +
system/src/Grav/Framework/Psr7/Response.php | 265 +
.../src/Grav/Framework/Psr7/ServerRequest.php | 372 +
system/src/Grav/Framework/Psr7/Stream.php | 25 +
.../Psr7/Traits/MessageDecoratorTrait.php | 140 +
.../Psr7/Traits/RequestDecoratorTrait.php | 112 +
.../Psr7/Traits/ResponseDecoratorTrait.php | 82 +
.../Traits/ServerRequestDecoratorTrait.php | 168 +
.../Psr7/Traits/StreamDecoratorTrait.php | 145 +
.../Traits/UploadedFileDecoratorTrait.php | 51 +
.../Psr7/Traits/UriDecorationTrait.php | 128 +
.../src/Grav/Framework/Psr7/UploadedFile.php | 33 +
system/src/Grav/Framework/Psr7/Uri.php | 134 +
.../Exception/InvalidArgumentException.php | 47 +
.../Exception/NotFoundException.php | 39 +
.../Exception/NotHandledException.php | 16 +
.../Exception/PageExpiredException.php | 27 +
.../Exception/RequestException.php | 97 +
.../RequestHandler/Middlewares/Exceptions.php | 44 +
.../RequestHandler/RequestHandler.php | 66 +
.../Traits/RequestHandlerTrait.php | 59 +
system/src/Grav/Framework/Route/Route.php | 396 +
.../src/Grav/Framework/Route/RouteFactory.php | 157 +
.../Session/Exceptions/SessionException.php | 14 +
system/src/Grav/Framework/Session/Session.php | 361 +
.../Framework/Session/SessionInterface.php | 148 +
system/src/Grav/Framework/Uri/Uri.php | 214 +
system/src/Grav/Framework/Uri/UriFactory.php | 166 +
.../src/Grav/Framework/Uri/UriPartsFilter.php | 141 +
system/src/Grav/Installer/Install.php | 287 +
system/templates/partials/messages.html.twig | 14 +
system/templates/partials/metadata.html.twig | 3 +
tmp/.gitkeep | 0
user/accounts/.gitkeep | 0
user/config/site.yaml | 7 +
user/config/system.yaml | 45 +
user/data/.gitkeep | 0
user/pages/01.home/default.md | 42 +
user/pages/02.typography/default.md | 155 +
user/plugins/.gitkeep | 0
user/plugins/admin/.gitattributes | 8 +
user/plugins/admin/.github/FUNDING.yml | 8 +
user/plugins/admin/CHANGELOG.md | 1775 ++
user/plugins/admin/CONTRIBUTING.md | 1 +
user/plugins/admin/LICENSE | 21 +
user/plugins/admin/README.md | 111 +
user/plugins/admin/admin.php | 1017 ++
user/plugins/admin/admin.yaml | 48 +
user/plugins/admin/assets/admin-dashboard.png | Bin 0 -> 241372 bytes
user/plugins/admin/blueprints.yaml | 528 +
.../blueprints/admin/pages/modular_new.yaml | 52 +
.../blueprints/admin/pages/modular_raw.yaml | 101 +
.../admin/blueprints/admin/pages/move.yaml | 7 +
.../admin/blueprints/admin/pages/new.yaml | 62 +
.../blueprints/admin/pages/new_folder.yaml | 31 +
.../admin/blueprints/admin/pages/raw.yaml | 106 +
.../admin/blueprints/config/media.yaml | 36 +
.../admin/classes/Twig/AdminTwigExtension.php | 118 +
user/plugins/admin/classes/admin.php | 1976 +++
.../admin/classes/adminbasecontroller.php | 1122 ++
.../plugins/admin/classes/admincontroller.php | 2668 +++
user/plugins/admin/classes/gpm.php | 429 +
user/plugins/admin/classes/popularity.php | 303 +
user/plugins/admin/classes/themes.php | 22 +
user/plugins/admin/classes/utils.php | 54 +
user/plugins/admin/codeception.yml | 18 +
user/plugins/admin/composer.json | 51 +
user/plugins/admin/composer.lock | 3028 ++++
user/plugins/admin/languages/ar.yaml | 308 +
user/plugins/admin/languages/bg.yaml | 361 +
user/plugins/admin/languages/br.yaml | 600 +
user/plugins/admin/languages/ca.yaml | 641 +
user/plugins/admin/languages/cs.yaml | 819 +
user/plugins/admin/languages/cy.yaml | 90 +
user/plugins/admin/languages/da.yaml | 737 +
user/plugins/admin/languages/de.yaml | 769 +
user/plugins/admin/languages/el.yaml | 710 +
user/plugins/admin/languages/en.yaml | 836 +
user/plugins/admin/languages/es.yaml | 758 +
user/plugins/admin/languages/et.yaml | 760 +
user/plugins/admin/languages/eu.yaml | 182 +
user/plugins/admin/languages/fa.yaml | 731 +
user/plugins/admin/languages/fi.yaml | 237 +
user/plugins/admin/languages/fr.yaml | 819 +
user/plugins/admin/languages/he.yaml | 418 +
user/plugins/admin/languages/hr.yaml | 609 +
user/plugins/admin/languages/hu.yaml | 756 +
user/plugins/admin/languages/id.yaml | 696 +
user/plugins/admin/languages/it.yaml | 724 +
user/plugins/admin/languages/ja.yaml | 645 +
user/plugins/admin/languages/ko.yaml | 108 +
user/plugins/admin/languages/lt.yaml | 363 +
user/plugins/admin/languages/nl.yaml | 737 +
user/plugins/admin/languages/no.yaml | 686 +
user/plugins/admin/languages/pl.yaml | 687 +
user/plugins/admin/languages/pt.yaml | 552 +
user/plugins/admin/languages/ro.yaml | 819 +
user/plugins/admin/languages/ru.yaml | 812 +
user/plugins/admin/languages/sk.yaml | 555 +
user/plugins/admin/languages/sl.yaml | 245 +
user/plugins/admin/languages/sr.yaml | 819 +
user/plugins/admin/languages/sv.yaml | 632 +
user/plugins/admin/languages/th.yaml | 690 +
user/plugins/admin/languages/tlh.yaml | 9 +
user/plugins/admin/languages/tr.yaml | 717 +
user/plugins/admin/languages/uk.yaml | 552 +
user/plugins/admin/languages/vi.yaml | 73 +
user/plugins/admin/languages/zh-tw.yaml | 706 +
user/plugins/admin/languages/zh.yaml | 819 +
user/plugins/admin/pages/admin/ajax.md | 8 +
user/plugins/admin/pages/admin/backup.md | 9 +
user/plugins/admin/pages/admin/cache.md | 10 +
user/plugins/admin/pages/admin/config.md | 8 +
user/plugins/admin/pages/admin/dashboard.md | 8 +
user/plugins/admin/pages/admin/denied.md | 5 +
user/plugins/admin/pages/admin/error.md | 10 +
user/plugins/admin/pages/admin/feed.md | 8 +
user/plugins/admin/pages/admin/forgot.md | 13 +
user/plugins/admin/pages/admin/info.md | 9 +
user/plugins/admin/pages/admin/installer.md | 8 +
user/plugins/admin/pages/admin/login.md | 38 +
user/plugins/admin/pages/admin/media.md | 9 +
.../admin/pages/admin/notifications.md | 8 +
.../plugins/admin/pages/admin/pages-filter.md | 9 +
user/plugins/admin/pages/admin/pages.md | 8 +
user/plugins/admin/pages/admin/plugins.md | 8 +
user/plugins/admin/pages/admin/preview.md | 8 +
user/plugins/admin/pages/admin/register.md | 58 +
user/plugins/admin/pages/admin/reset.md | 17 +
user/plugins/admin/pages/admin/site.md | 9 +
user/plugins/admin/pages/admin/statistics.md | 8 +
user/plugins/admin/pages/admin/system.md | 9 +
user/plugins/admin/pages/admin/themes.md | 8 +
user/plugins/admin/pages/admin/tools.md | 7 +
user/plugins/admin/pages/admin/update.md | 9 +
user/plugins/admin/pages/admin/user.md | 9 +
user/plugins/admin/tests/_bootstrap.php | 11 +
.../admin/tests/_support/Helper/Unit.php | 80 +
.../admin/tests/_support/UnitTester.php | 26 +
user/plugins/admin/tests/unit.suite.yml | 9 +
user/plugins/admin/tests/unit/_bootstrap.php | 3 +
.../tests/unit/classes/controllerTest.php | 42 +
user/plugins/admin/themes/grav/.eslintrc | 165 +
.../admin/themes/grav/app/dashboard/backup.js | 42 +
.../admin/themes/grav/app/dashboard/cache.js | 49 +
.../admin/themes/grav/app/dashboard/chart.js | 138 +
.../admin/themes/grav/app/dashboard/index.js | 12 +
.../admin/themes/grav/app/dashboard/update.js | 1 +
.../themes/grav/app/forms/fields/array.js | 193 +
.../grav/app/forms/fields/collections.js | 261 +
.../grav/app/forms/fields/colorpicker.js | 581 +
.../themes/grav/app/forms/fields/cron.js | 145 +
.../themes/grav/app/forms/fields/datetime.js | 63 +
.../themes/grav/app/forms/fields/editor.js | 237 +
.../grav/app/forms/fields/editor/buttons.js | 416 +
.../grav/app/forms/fields/filepicker.js | 140 +
.../themes/grav/app/forms/fields/files.js | 383 +
.../grav/app/forms/fields/iconpicker.js | 298 +
.../themes/grav/app/forms/fields/index.js | 72 +
.../grav/app/forms/fields/mediapicker.js | 92 +
.../grav/app/forms/fields/multilevel.js | 279 +
.../themes/grav/app/forms/fields/selectize.js | 58 +
.../grav/app/forms/fields/selectunique.js | 160 +
.../themes/grav/app/forms/fields/text.js | 13 +
.../admin/themes/grav/app/forms/form.js | 139 +
.../admin/themes/grav/app/forms/index.js | 16 +
.../admin/themes/grav/app/forms/state.js | 150 +
user/plugins/admin/themes/grav/app/main.js | 78 +
.../admin/themes/grav/app/media/index.js | 230 +
.../admin/themes/grav/app/pages/filter.js | 148 +
.../admin/themes/grav/app/pages/index.js | 53 +
.../admin/themes/grav/app/pages/page/add.js | 67 +
.../themes/grav/app/pages/page/delete.js | 15 +
.../grav/app/pages/page/disable-buttons.js | 5 +
.../admin/themes/grav/app/pages/page/index.js | 47 +
.../admin/themes/grav/app/pages/page/media.js | 201 +
.../admin/themes/grav/app/pages/page/move.js | 13 +
.../themes/grav/app/pages/page/multilang.js | 22 +
.../admin/themes/grav/app/pages/page/unset.js | 18 +
.../admin/themes/grav/app/pages/tree.js | 135 +
.../admin/themes/grav/app/plugins/index.js | 92 +
.../admin/themes/grav/app/themes/index.js | 46 +
.../admin/themes/grav/app/tools/index.js | 1 +
.../admin/themes/grav/app/tools/logs.js | 14 +
.../grav/app/updates/channel-switcher.js | 24 +
.../admin/themes/grav/app/updates/check.js | 26 +
.../admin/themes/grav/app/updates/feed.js | 68 +
.../admin/themes/grav/app/updates/index.js | 186 +
.../themes/grav/app/updates/notifications.js | 170 +
.../admin/themes/grav/app/updates/update.js | 19 +
.../admin/themes/grav/app/utils/2fa.js | 32 +
.../grav/app/utils/bootstrap-collapse.js | 210 +
.../grav/app/utils/bootstrap-transition.js | 52 +
.../admin/themes/grav/app/utils/colors.js | 152 +
.../admin/themes/grav/app/utils/cron-ui.js | 864 +
.../themes/grav/app/utils/formatbytes.js | 11 +
.../admin/themes/grav/app/utils/gpm.js | 57 +
.../themes/grav/app/utils/jquery-utils.js | 50 +
.../admin/themes/grav/app/utils/keepalive.js | 32 +
.../admin/themes/grav/app/utils/offline.js | 21 +
.../admin/themes/grav/app/utils/packages.js | 470 +
.../admin/themes/grav/app/utils/request.js | 38 +
.../admin/themes/grav/app/utils/response.js | 101 +
.../admin/themes/grav/app/utils/scrollbar.js | 40 +
.../grav/app/utils/selectize-option-click.js | 42 +
.../grav/app/utils/selectize-required-fix.js | 28 +
.../admin/themes/grav/app/utils/sidebar.js | 179 +
.../admin/themes/grav/app/utils/storage.js | 41 +
.../themes/grav/app/utils/tabs-memory.js | 29 +
.../admin/themes/grav/app/utils/toastr.js | 6 +
.../admin/themes/grav/css-compiled/fonts.css | 3 +
.../themes/grav/css-compiled/fonts.css.map | 1 +
.../themes/grav/css-compiled/nucleus.css | 3 +
.../themes/grav/css-compiled/nucleus.css.map | 1 +
.../admin/themes/grav/css-compiled/preset.css | 3 +
.../themes/grav/css-compiled/preset.css.map | 1 +
.../themes/grav/css-compiled/simple-fonts.css | 3 +
.../grav/css-compiled/simple-fonts.css.map | 1 +
.../themes/grav/css-compiled/template.css | 7 +
.../themes/grav/css-compiled/template.css.map | 1 +
.../admin/themes/grav/css/chartist.min.css | 1 +
.../grav/css/codemirror/base16-light.css | 36 +
.../themes/grav/css/codemirror/codemirror.css | 332 +
.../themes/grav/css/codemirror/paper.css | 39 +
.../themes/grav/css/featherlight.min.css | 8 +
.../themes/grav/css/fork-awesome.min.css | 12 +
.../admin/themes/grav/css/hint.base.min.css | 5 +
.../admin/themes/grav/css/iconpicker.css | 223 +
.../admin/themes/grav/css/nucleus-ie10.css | 24 +
.../admin/themes/grav/css/nucleus-ie9.css | 62 +
user/plugins/admin/themes/grav/css/prism.css | 121 +
.../themes/grav/css/pure-0.5.0/grids-min.css | 15 +
.../admin/themes/grav/css/selectize.min.css | 1 +
.../themes/grav/fonts/forkawesome-webfont.eot | Bin 0 -> 186490 bytes
.../themes/grav/fonts/forkawesome-webfont.svg | 2810 ++++
.../themes/grav/fonts/forkawesome-webfont.ttf | Bin 0 -> 186300 bytes
.../grav/fonts/forkawesome-webfont.woff | Bin 0 -> 113404 bytes
.../grav/fonts/forkawesome-webfont.woff2 | Bin 0 -> 90420 bytes
.../rockettheme-apps/rockettheme-apps.eot | Bin 0 -> 4838 bytes
.../rockettheme-apps/rockettheme-apps.svg | 16 +
.../rockettheme-apps/rockettheme-apps.ttf | Bin 0 -> 4644 bytes
.../rockettheme-apps/rockettheme-apps.woff | Bin 0 -> 3348 bytes
user/plugins/admin/themes/grav/gulpfile.js | 110 +
.../admin/themes/grav/images/favicon.png | Bin 0 -> 13203 bytes
.../admin/themes/grav/images/grav-regular.svg | 1 +
.../admin/themes/grav/images/grav-small.svg | 1 +
.../plugins/admin/themes/grav/images/logo.svg | 1 +
.../admin/themes/grav/images/transparent.png | Bin 0 -> 5123 bytes
.../plugins/admin/themes/grav/js/admin.min.js | 31 +
.../themes/grav/js/form-attr.polyfill.js | 80 +
.../admin/themes/grav/js/vendor.min.js | 52 +
user/plugins/admin/themes/grav/package.json | 63 +
user/plugins/admin/themes/grav/scss.sh | 2 +
.../scss/configuration/fonts/_support.scss | 75 +
.../scss/configuration/nucleus/_base.scss | 14 +
.../configuration/nucleus/_breakpoints.scss | 16 +
.../scss/configuration/nucleus/_core.scss | 2 +
.../scss/configuration/nucleus/_layout.scss | 8 +
.../grav/scss/configuration/nucleus/_nav.scss | 3 +
.../configuration/nucleus/_typography.scss | 14 +
.../scss/configuration/template/_base.scss | 5 +
.../scss/configuration/template/_colors.scss | 15 +
.../configuration/template/_variables.scss | 22 +
.../plugins/admin/themes/grav/scss/fonts.scss | 10 +
.../admin/themes/grav/scss/nucleus.scss | 27 +
.../admin/themes/grav/scss/nucleus/_core.scss | 217 +
.../admin/themes/grav/scss/nucleus/_flex.scss | 195 +
.../themes/grav/scss/nucleus/_forms.scss | 62 +
.../themes/grav/scss/nucleus/_typography.scss | 86 +
.../grav/scss/nucleus/functions/_base.scss | 2 +
.../scss/nucleus/functions/_direction.scss | 37 +
.../grav/scss/nucleus/functions/_range.scss | 13 +
.../grav/scss/nucleus/mixins/_base.scss | 2 +
.../scss/nucleus/mixins/_breakpoints.scss | 44 +
.../grav/scss/nucleus/mixins/_utilities.scss | 30 +
.../scss/nucleus/particles/_align-text.scss | 46 +
.../scss/nucleus/particles/_visibility.scss | 0
.../admin/themes/grav/scss/preset.scss | 1750 ++
.../admin/themes/grav/scss/simple-fonts.scss | 11 +
.../admin/themes/grav/scss/template.scss | 97 +
.../themes/grav/scss/template/_admin.scss | 1323 ++
.../themes/grav/scss/template/_buttons.scss | 131 +
.../themes/grav/scss/template/_colors.scss | 19 +
.../themes/grav/scss/template/_core.scss | 51 +
.../themes/grav/scss/template/_custom.scss | 2 +
.../themes/grav/scss/template/_dropzone.scss | 285 +
.../themes/grav/scss/template/_editor.scss | 287 +
.../themes/grav/scss/template/_errors.scss | 17 +
.../grav/scss/template/_extensions.scss | 58 +
.../themes/grav/scss/template/_fonts.scss | 40 +
.../themes/grav/scss/template/_forms.scss | 789 +
.../admin/themes/grav/scss/template/_gpm.scss | 207 +
.../themes/grav/scss/template/_header.scss | 3 +
.../themes/grav/scss/template/_jqcron.scss | 105 +
.../themes/grav/scss/template/_login.scss | 191 +
.../themes/grav/scss/template/_media.scss | 331 +
.../grav/scss/template/_nav-toggle.scss | 71 +
.../grav/scss/template/_notifications.scss | 116 +
.../themes/grav/scss/template/_pages.scss | 352 +
.../themes/grav/scss/template/_phpinfo.scss | 35 +
.../themes/grav/scss/template/_remodal.scss | 329 +
.../themes/grav/scss/template/_tables.scss | 192 +
.../themes/grav/scss/template/_tabs.scss | 118 +
.../themes/grav/scss/template/_toastr.scss | 183 +
.../themes/grav/scss/template/_tools.scss | 101 +
.../grav/scss/template/_typography.scss | 162 +
.../themes/grav/scss/template/_utilities.scss | 5 +
.../grav/scss/template/modules/_base.scss | 5 +
.../template/modules/_bourbon_essentials.scss | 120 +
.../grav/scss/template/modules/_buttons.scss | 60 +
.../scss/template/modules/_colorpicker.scss | 253 +
.../template/modules/_datetimepicker.scss | 466 +
.../scss/template/modules/_input-range.scss | 87 +
.../scss/template/modules/_scrollbars.scss | 98 +
.../scss/template/modules/_toggle-switch.scss | 20 +
.../bourbon/_bourbon-deprecated-upcoming.scss | 8 +
.../grav/scss/vendor/bourbon/_bourbon.scss | 77 +
.../scss/vendor/bourbon/addons/_button.scss | 374 +
.../scss/vendor/bourbon/addons/_clearfix.scss | 23 +
.../bourbon/addons/_directional-values.scss | 111 +
.../scss/vendor/bourbon/addons/_ellipsis.scss | 7 +
.../vendor/bourbon/addons/_font-family.scss | 5 +
.../vendor/bourbon/addons/_hide-text.scss | 10 +
.../bourbon/addons/_html5-input-types.scss | 86 +
.../scss/vendor/bourbon/addons/_position.scss | 32 +
.../scss/vendor/bourbon/addons/_prefixer.scss | 45 +
.../grav/scss/vendor/bourbon/addons/_rem.scss | 33 +
.../vendor/bourbon/addons/_retina-image.scss | 31 +
.../scss/vendor/bourbon/addons/_size.scss | 16 +
.../bourbon/addons/_timing-functions.scss | 32 +
.../scss/vendor/bourbon/addons/_triangle.scss | 83 +
.../vendor/bourbon/addons/_word-wrap.scss | 8 +
.../scss/vendor/bourbon/css3/_animation.scss | 52 +
.../scss/vendor/bourbon/css3/_appearance.scss | 3 +
.../bourbon/css3/_backface-visibility.scss | 6 +
.../bourbon/css3/_background-image.scss | 42 +
.../scss/vendor/bourbon/css3/_background.scss | 55 +
.../vendor/bourbon/css3/_border-image.scss | 59 +
.../vendor/bourbon/css3/_border-radius.scss | 22 +
.../scss/vendor/bourbon/css3/_box-sizing.scss | 4 +
.../grav/scss/vendor/bourbon/css3/_calc.scss | 4 +
.../scss/vendor/bourbon/css3/_columns.scss | 47 +
.../scss/vendor/bourbon/css3/_filter.scss | 5 +
.../scss/vendor/bourbon/css3/_flex-box.scss | 321 +
.../scss/vendor/bourbon/css3/_font-face.scss | 23 +
.../bourbon/css3/_font-feature-settings.scss | 10 +
.../bourbon/css3/_hidpi-media-query.scss | 10 +
.../scss/vendor/bourbon/css3/_hyphens.scss | 4 +
.../vendor/bourbon/css3/_image-rendering.scss | 14 +
.../scss/vendor/bourbon/css3/_keyframes.scss | 35 +
.../vendor/bourbon/css3/_linear-gradient.scss | 38 +
.../vendor/bourbon/css3/_perspective.scss | 8 +
.../vendor/bourbon/css3/_placeholder.scss | 8 +
.../vendor/bourbon/css3/_radial-gradient.scss | 39 +
.../scss/vendor/bourbon/css3/_transform.scss | 15 +
.../scss/vendor/bourbon/css3/_transition.scss | 77 +
.../vendor/bourbon/css3/_user-select.scss | 3 +
.../vendor/bourbon/functions/_assign.scss | 11 +
.../bourbon/functions/_color-lightness.scss | 13 +
.../vendor/bourbon/functions/_flex-grid.scss | 39 +
.../bourbon/functions/_golden-ratio.scss | 3 +
.../vendor/bourbon/functions/_grid-width.scss | 13 +
.../bourbon/functions/_modular-scale.scss | 66 +
.../vendor/bourbon/functions/_px-to-em.scss | 13 +
.../vendor/bourbon/functions/_px-to-rem.scss | 15 +
.../bourbon/functions/_strip-units.scss | 5 +
.../vendor/bourbon/functions/_tint-shade.scss | 9 +
.../functions/_transition-property-name.scss | 22 +
.../vendor/bourbon/functions/_unpack.scss | 17 +
.../bourbon/helpers/_convert-units.scss | 15 +
.../helpers/_gradient-positions-parser.scss | 13 +
.../scss/vendor/bourbon/helpers/_is-num.scss | 8 +
.../bourbon/helpers/_linear-angle-parser.scss | 25 +
.../helpers/_linear-gradient-parser.scss | 41 +
.../helpers/_linear-positions-parser.scss | 61 +
.../helpers/_linear-side-corner-parser.scss | 31 +
.../bourbon/helpers/_radial-arg-parser.scss | 69 +
.../helpers/_radial-gradient-parser.scss | 50 +
.../helpers/_radial-positions-parser.scss | 18 +
.../bourbon/helpers/_render-gradients.scss | 26 +
.../bourbon/helpers/_shape-size-stripper.scss | 10 +
.../vendor/bourbon/helpers/_str-to-num.scss | 50 +
.../vendor/bourbon/settings/_prefixer.scss | 6 +
.../vendor/bourbon/settings/_px-to-em.scss | 1 +
.../vendor/color-schemer/_color-schemer.scss | 31 +
.../color-schemer/color-schemer/_cmyk.scss | 14 +
.../color-schemer/_color-adjustments.scss | 30 +
.../color-schemer/_color-schemer.scss | 208 +
.../color-schemer/_colorblind.scss | 29 +
.../color-schemer/_comparison.scss | 15 +
.../color-schemer/_equalize.scss | 5 +
.../color-schemer/_harmonize.scss | 59 +
.../color-schemer/_interpolation.scss | 34 +
.../color-schemer/color-schemer/_mix.scss | 40 +
.../color-schemer/color-schemer/_mixins.scss | 29 +
.../color-schemer/color-schemer/_ryb.scss | 76 +
.../color-schemer/_tint-shade.scss | 9 +
.../themes/grav/templates/config.html.twig | 90 +
.../themes/grav/templates/dashboard.html.twig | 70 +
.../themes/grav/templates/default.json.twig | 5 +
.../themes/grav/templates/denied.html.twig | 18 +
.../grav/templates/email/base.html.twig | 194 +
.../themes/grav/templates/empty.html.twig | 0
.../themes/grav/templates/error.html.twig | 20 +
.../themes/grav/templates/error.json.twig | 1 +
.../themes/grav/templates/forgot.html.twig | 17 +
.../grav/templates/forms/field.html.twig | 114 +
.../forms/fields/array/array.html.twig | 96 +
.../backupshistory/backupshistory.html.twig | 32 +
.../fields/blueprint/blueprint.html.twig | 12 +
.../fields/colorpicker/colorpicker.html.twig | 38 +
.../forms/fields/column/column.html.twig | 14 +
.../forms/fields/columns/columns.html.twig | 12 +
.../forms/fields/cron/cron.html.twig | 6 +
.../fields/cronstatus/cronstatus.html.twig | 71 +
.../fields/dateformat/dateformat.html.twig | 24 +
.../forms/fields/datetime/datetime.html.twig | 26 +
.../forms/fields/editor/editor.html.twig | 53 +
.../forms/fields/fieldset/fieldset.html.twig | 99 +
.../forms/fields/file/file.html.twig | 116 +
.../fields/filepicker/filepicker.html.twig | 17 +
.../fields/frontmatter/frontmatter.html.twig | 10 +
.../fields/iconpicker/iconpicker.html.twig | 45 +
.../forms/fields/iconpicker/icons.yaml | 6570 ++++++++
.../forms/fields/list/list.html.twig | 195 +
.../forms/fields/markdown/markdown.html.twig | 10 +
.../fields/mediapicker/mediapicker.html.twig | 20 +
.../fields/multilevel/multilevel.html.twig | 120 +
.../forms/fields/order/order.html.twig | 55 +
.../fields/pagemedia/pagemedia.html.twig | 58 +
.../pagemediaselect/pagemediaselect.html.twig | 2 +
.../forms/fields/pages/pages.html.twig | 52 +
.../forms/fields/parents/parents.html.twig | 26 +
.../fields/permissions/permissions.html.twig | 70 +
.../forms/fields/range/range.html.twig | 42 +
.../forms/fields/section/section.html.twig | 26 +
.../fields/selectize/selectize.html.twig | 19 +
.../selectunique/selectunique.html.twig | 42 +
.../forms/fields/taxonomy/taxonomy.html.twig | 30 +
.../fields/themeselect/themeselect.html.twig | 31 +
.../forms/fields/userinfo/userinfo.html.twig | 19 +
.../templates/forms/fields/xss/xss.html.twig | 6 +
.../themes/grav/templates/installer.html.twig | 13 +
.../themes/grav/templates/login.html.twig | 11 +
.../templates/media-list-content.html.twig | 19 +
.../themes/grav/templates/pages.html.twig | 448 +
.../partials/backups-button.html.twig | 21 +
.../templates/partials/base-root.html.twig | 137 +
.../grav/templates/partials/base.html.twig | 1 +
.../partials/blueprints-new-folder.html.twig | 21 +
.../partials/blueprints-new.html.twig | 21 +
.../partials/blueprints-raw.html.twig | 17 +
.../templates/partials/blueprints.html.twig | 35 +
.../partials/dashboard-feed.html.twig | 14 +
.../partials/dashboard-maintenance.html.twig | 33 +
.../dashboard-notifications.html.twig | 13 +
.../partials/dashboard-pages.html.twig | 19 +
.../partials/dashboard-statistics.html.twig | 24 +
.../templates/partials/feed-block.html.twig | 3 +
.../grav/templates/partials/footer.html.twig | 5 +
.../grav/templates/partials/header.html.twig | 11 +
.../partials/javascript-config.html.twig | 43 +
.../templates/partials/javascripts.html.twig | 11 +
.../templates/partials/list-sort.html.twig | 12 +
.../templates/partials/login-form.html.twig | 31 +
.../templates/partials/login-logo.html.twig | 14 +
.../templates/partials/login-logout.html.twig | 15 +
.../templates/partials/login-twofa.html.twig | 26 +
.../grav/templates/partials/login.html.twig | 34 +
.../grav/templates/partials/logo.html.twig | 20 +
.../partials/media-list-wrapper.html.twig | 32 +
.../media-list-wrapper__list.html.twig | 23 +
...edia-list-wrapper__list__filters.html.twig | 28 +
.../media-list-wrapper__sidebar.html.twig | 50 +
.../templates/partials/messages.html.twig | 14 +
.../partials/modal-add-package.html.twig | 89 +
.../partials/modal-changes-detected.html.twig | 13 +
.../modal-reinstall-package.html.twig | 38 +
.../partials/modal-remove-package.html.twig | 44 +
.../partials/modal-update-packages.html.twig | 89 +
.../partials/nav-quick-tray.html.twig | 40 +
.../templates/partials/nav-toggle.html.twig | 3 +
.../partials/nav-user-avatar.html.twig | 2 +
.../partials/nav-user-details.html.twig | 19 +
.../grav/templates/partials/nav.html.twig | 96 +
.../templates/partials/noscript.html.twig | 42 +
.../notification-dashboard-block.html.twig | 6 +
.../notification-feed-block.html.twig | 3 +
.../notification-plugins-block.html.twig | 6 +
.../notification-themes-block.html.twig | 6 +
.../partials/notification-top-block.html.twig | 6 +
.../partials/page-children.html.twig | 11 +
.../templates/partials/page-legend.html.twig | 11 +
.../templates/partials/page-move.html.twig | 20 +
.../templates/partials/plugin-data.html.twig | 63 +
.../partials/plugins-details.html.twig | 62 +
.../templates/partials/plugins-list.html.twig | 74 +
.../templates/partials/register.html.twig | 22 +
.../partials/release-toggle.html.twig | 9 +
.../partials/spinning-wheel.html.twig | 3 +
.../templates/partials/stylesheets.html.twig | 17 +
.../grav/templates/partials/theme.html.twig | 13 +
.../partials/themes-details.html.twig | 120 +
.../templates/partials/themes-list.html.twig | 91 +
.../partials/tools-backups-titlebar.html.twig | 7 +
.../partials/tools-backups.html.twig | 76 +
.../partials/tools-direct-install.html.twig | 29 +
.../templates/partials/tools-logs.html.twig | 78 +
.../partials/tools-reports.html.twig | 15 +
.../tools-scheduler-titlebar.html.twig | 6 +
.../partials/tools-scheduler.html.twig | 33 +
.../partials/userinfo-avatar-credit.html.twig | 1 +
.../partials/userinfo-avatar.html.twig | 5 +
.../themes/grav/templates/plugins.html.twig | 89 +
.../themes/grav/templates/preview.html.twig | 24 +
.../themes/grav/templates/register.html.twig | 28 +
.../grav/templates/reports/security.html.twig | 20 +
.../templates/reports/yamllinter.html.twig | 22 +
.../themes/grav/templates/reset.html.twig | 19 +
.../grav/templates/statistics.html.twig | 15 +
.../themes/grav/templates/themes.html.twig | 83 +
.../themes/grav/templates/tools.html.twig | 50 +
.../grav/templates/unauthorized.html.twig | 1 +
.../themes/grav/templates/user.html.twig | 64 +
user/plugins/admin/themes/grav/theme.yaml | 0
user/plugins/admin/themes/grav/watch.sh | 27 +
.../plugins/admin/themes/grav/webpack.conf.js | 41 +
.../plugins/admin/twig/AdminTwigExtension.php | 6 +
user/plugins/admin/vendor/autoload.php | 7 +
user/plugins/admin/vendor/bin/picofeed | 135 +
.../admin/vendor/composer/ClassLoader.php | 445 +
user/plugins/admin/vendor/composer/LICENSE | 21 +
.../vendor/composer/autoload_classmap.php | 18 +
.../vendor/composer/autoload_namespaces.php | 10 +
.../admin/vendor/composer/autoload_psr4.php | 11 +
.../admin/vendor/composer/autoload_real.php | 52 +
.../admin/vendor/composer/autoload_static.php | 63 +
.../admin/vendor/composer/installed.json | 169 +
.../admin/vendor/composer/semver/CHANGELOG.md | 78 +
.../admin/vendor/composer/semver/LICENSE | 19 +
.../admin/vendor/composer/semver/README.md | 70 +
.../vendor/composer/semver/composer.json | 57 +
.../vendor/composer/semver/src/Comparator.php | 111 +
.../src/Constraint/AbstractConstraint.php | 63 +
.../semver/src/Constraint/Constraint.php | 215 +
.../src/Constraint/ConstraintInterface.php | 32 +
.../semver/src/Constraint/EmptyConstraint.php | 59 +
.../semver/src/Constraint/MultiConstraint.php | 120 +
.../vendor/composer/semver/src/Semver.php | 127 +
.../composer/semver/src/VersionParser.php | 545 +
.../plugins/admin/vendor/p3k/picofeed/LICENSE | 21 +
.../vendor/p3k/picofeed/lib/PicoFeed/Base.php | 38 +
.../picofeed/lib/PicoFeed/Client/Client.php | 712 +
.../lib/PicoFeed/Client/ClientException.php | 14 +
.../p3k/picofeed/lib/PicoFeed/Client/Curl.php | 412 +
.../PicoFeed/Client/ForbiddenException.php | 10 +
.../lib/PicoFeed/Client/HttpHeaders.php | 79 +
.../Client/InvalidCertificateException.php | 12 +
.../PicoFeed/Client/InvalidUrlException.php | 12 +
.../PicoFeed/Client/MaxRedirectException.php | 12 +
.../lib/PicoFeed/Client/MaxSizeException.php | 12 +
.../picofeed/lib/PicoFeed/Client/Stream.php | 205 +
.../lib/PicoFeed/Client/TimeoutException.php | 12 +
.../PicoFeed/Client/UnauthorizedException.php | 10 +
.../p3k/picofeed/lib/PicoFeed/Client/Url.php | 283 +
.../picofeed/lib/PicoFeed/Config/Config.php | 102 +
.../lib/PicoFeed/Encoding/Encoding.php | 33 +
.../lib/PicoFeed/Filter/Attribute.php | 700 +
.../picofeed/lib/PicoFeed/Filter/Filter.php | 144 +
.../p3k/picofeed/lib/PicoFeed/Filter/Html.php | 243 +
.../p3k/picofeed/lib/PicoFeed/Filter/Tag.php | 208 +
.../Generator/ContentGeneratorInterface.php | 23 +
.../Generator/FileContentGenerator.php | 36 +
.../Generator/YoutubeContentGenerator.php | 67 +
.../picofeed/lib/PicoFeed/Logging/Logger.php | 114 +
.../p3k/picofeed/lib/PicoFeed/Parser/Atom.php | 395 +
.../lib/PicoFeed/Parser/DateParser.php | 128 +
.../p3k/picofeed/lib/PicoFeed/Parser/Feed.php | 315 +
.../p3k/picofeed/lib/PicoFeed/Parser/Item.php | 562 +
.../PicoFeed/Parser/MalformedXmlException.php | 13 +
.../picofeed/lib/PicoFeed/Parser/Parser.php | 397 +
.../lib/PicoFeed/Parser/ParserException.php | 15 +
.../lib/PicoFeed/Parser/ParserInterface.php | 191 +
.../picofeed/lib/PicoFeed/Parser/Rss10.php | 318 +
.../picofeed/lib/PicoFeed/Parser/Rss20.php | 330 +
.../picofeed/lib/PicoFeed/Parser/Rss91.php | 13 +
.../picofeed/lib/PicoFeed/Parser/Rss92.php | 13 +
.../PicoFeed/Parser/XmlEntityException.php | 13 +
.../lib/PicoFeed/Parser/XmlParser.php | 246 +
.../lib/PicoFeed/PicoFeedException.php | 14 +
.../Processor/ContentFilterProcessor.php | 39 +
.../Processor/ContentGeneratorProcessor.php | 49 +
.../PicoFeed/Processor/ItemPostProcessor.php | 106 +
.../Processor/ItemProcessorInterface.php | 25 +
.../PicoFeed/Processor/ScraperProcessor.php | 96 +
.../picofeed/lib/PicoFeed/Reader/Favicon.php | 186 +
.../picofeed/lib/PicoFeed/Reader/Reader.php | 189 +
.../lib/PicoFeed/Reader/ReaderException.php | 14 +
.../Reader/SubscriptionNotFoundException.php | 12 +
.../Reader/UnsupportedFeedFormatException.php | 12 +
.../lib/PicoFeed/Rules/.blog.lemonde.fr.php | 14 +
.../lib/PicoFeed/Rules/.blogs.nytimes.com.php | 15 +
.../picofeed/lib/PicoFeed/Rules/.igen.fr.php | 13 +
.../lib/PicoFeed/Rules/.nytimes.com.php | 11 +
.../lib/PicoFeed/Rules/.over-blog.com.php | 11 +
.../lib/PicoFeed/Rules/.phoronix.com.php | 12 +
.../lib/PicoFeed/Rules/.slate.com.php | 20 +
.../lib/PicoFeed/Rules/.theguardian.com.php | 14 +
.../lib/PicoFeed/Rules/.wikipedia.org.php | 29 +
.../lib/PicoFeed/Rules/.wired.com.php | 44 +
.../picofeed/lib/PicoFeed/Rules/.wsj.com.php | 15 +
.../picofeed/lib/PicoFeed/Rules/01net.com.php | 18 +
.../p3k/picofeed/lib/PicoFeed/Rules/24.hu.php | 16 +
.../picofeed/lib/PicoFeed/Rules/444.hu.php | 19 +
.../picofeed/lib/PicoFeed/Rules/888.hu.php | 16 +
.../lib/PicoFeed/Rules/abstrusegoose.com.php | 8 +
.../lib/PicoFeed/Rules/achgut.com.php | 16 +
.../PicoFeed/Rules/adventuregamers.com.php | 23 +
.../lib/PicoFeed/Rules/alainonline.net.php | 14 +
.../lib/PicoFeed/Rules/aljazeera.com.php | 25 +
.../lib/PicoFeed/Rules/allafrica.com.php | 20 +
.../PicoFeed/Rules/allgemeine-zeitung.de.php | 23 +
.../PicoFeed/Rules/amazingsuperpowers.com.php | 8 +
.../lib/PicoFeed/Rules/anythingcomic.com.php | 13 +
.../picofeed/lib/PicoFeed/Rules/ap.org.php | 13 +
.../lib/PicoFeed/Rules/areadvd.de.php | 10 +
.../lib/PicoFeed/Rules/arstechnica.com.php | 25 +
.../picofeed/lib/PicoFeed/Rules/atv.hu.php | 18 +
.../lib/PicoFeed/Rules/awkwardzombie.com.php | 10 +
.../lib/PicoFeed/Rules/backchannel.com.php | 18 +
.../lib/PicoFeed/Rules/bangkokpost.com.php | 19 +
.../lib/PicoFeed/Rules/bauerwilli.com.php | 17 +
.../picofeed/lib/PicoFeed/Rules/bgr.com.php | 15 +
.../lib/PicoFeed/Rules/bigfootjustice.com.php | 8 +
.../lib/PicoFeed/Rules/bigpicture.ru.php | 31 +
.../lib/PicoFeed/Rules/bizjournals.com.php | 12 +
.../lib/PicoFeed/Rules/biztimes.com.php | 22 +
.../PicoFeed/Rules/bleepingcomputer.com.php | 15 +
.../lib/PicoFeed/Rules/blog.fefe.de.php | 13 +
.../lib/PicoFeed/Rules/blog.mapillary.com.php | 11 +
.../lib/PicoFeed/Rules/brewers.mlb.com.php | 22 +
.../PicoFeed/Rules/buenosairesherald.com.php | 17 +
.../lib/PicoFeed/Rules/bunicomic.com.php | 13 +
.../lib/PicoFeed/Rules/buttersafe.com.php | 13 +
.../lib/PicoFeed/Rules/cad-comic.com.php | 12 +
.../Rules/chaoslife.findchaos.com.php | 10 +
.../lib/PicoFeed/Rules/chinafile.com.php | 18 +
.../picofeed/lib/PicoFeed/Rules/cicero.de.php | 17 +
.../lib/PicoFeed/Rules/cliquerefresh.com.php | 10 +
.../picofeed/lib/PicoFeed/Rules/cnet.com.php | 37 +
.../lib/PicoFeed/Rules/coinwelt.de.php | 14 +
.../lib/PicoFeed/Rules/consomac.fr.php | 13 +
.../lib/PicoFeed/Rules/cowbirdsinlove.com.php | 8 +
.../picofeed/lib/PicoFeed/Rules/crash.net.php | 18 +
.../lib/PicoFeed/Rules/csmonitor.com.php | 19 +
.../lib/PicoFeed/Rules/dailyjs.com.php | 19 +
.../lib/PicoFeed/Rules/dailyreporter.com.php | 15 +
.../lib/PicoFeed/Rules/dailytech.com.php | 13 +
.../lib/PicoFeed/Rules/degroupnews.com.php | 14 +
.../lib/PicoFeed/Rules/derstandard.at.php | 14 +
.../lib/PicoFeed/Rules/dilbert.com.php | 11 +
.../PicoFeed/Rules/discovermagazine.com.php | 26 +
.../lib/PicoFeed/Rules/distrowatch.com.php | 13 +
.../lib/PicoFeed/Rules/dozodomo.com.php | 15 +
.../PicoFeed/Rules/drawingboardcomic.com.php | 15 +
.../picofeed/lib/PicoFeed/Rules/e-w-e.ru.php | 22 +
.../lib/PicoFeed/Rules/economist.com.php | 25 +
.../Rules/encyclopedie.naheulbeuk.com.php | 13 +
.../lib/PicoFeed/Rules/endlessorigami.com.php | 8 +
.../lib/PicoFeed/Rules/engadget.com.php | 10 +
.../PicoFeed/Rules/escapistmagazine.com.php | 45 +
.../lib/PicoFeed/Rules/espn.go.com.php | 11 +
.../lib/PicoFeed/Rules/exocomics.com.php | 15 +
.../lib/PicoFeed/Rules/explosm.net.php | 13 +
.../Rules/extrafabulouscomics.com.php | 8 +
.../lib/PicoFeed/Rules/factroom.ru.php | 27 +
.../lib/PicoFeed/Rules/fastcodesign.com.php | 13 +
.../lib/PicoFeed/Rules/fastcoexist.com.php | 13 +
.../lib/PicoFeed/Rules/fastcompany.com.php | 13 +
.../lib/PicoFeed/Rules/ffworld.com.php | 13 +
.../lib/PicoFeed/Rules/foreignpolicy.com.php | 21 +
.../lib/PicoFeed/Rules/fossbytes.com.php | 18 +
.../lib/PicoFeed/Rules/fototelegraf.ru.php | 19 +
.../PicoFeed/Rules/fowllanguagecomics.com.php | 10 +
.../lib/PicoFeed/Rules/gamechannel.hu.php | 15 +
.../lib/PicoFeed/Rules/gamestar.hu.php | 17 +
.../picofeed/lib/PicoFeed/Rules/geek.com.php | 17 +
.../lib/PicoFeed/Rules/geektimes.ru.php | 12 +
.../PicoFeed/Rules/gerbilwithajetpack.com.php | 12 +
.../lib/PicoFeed/Rules/giantitp.com.php | 12 +
.../lib/PicoFeed/Rules/github.com.php | 14 +
.../lib/PicoFeed/Rules/gocomics.com.php | 12 +
.../picofeed/lib/PicoFeed/Rules/golem.de.php | 21 +
.../lib/PicoFeed/Rules/gondola.hu.php | 22 +
.../lib/PicoFeed/Rules/gorabbit.ru.php | 19 +
.../lib/PicoFeed/Rules/habrahabr.ru.php | 12 +
.../lib/PicoFeed/Rules/happletea.com.php | 18 +
.../lib/PicoFeed/Rules/hardware.fr.php | 11 +
.../picofeed/lib/PicoFeed/Rules/heise.de.php | 79 +
.../lib/PicoFeed/Rules/hirek.prim.hu.php | 14 +
.../lib/PicoFeed/Rules/hotshowlife.com.php | 23 +
.../lib/PicoFeed/Rules/huffingtonpost.com.php | 13 +
.../picofeed/lib/PicoFeed/Rules/hvg.hu.php | 17 +
.../picofeed/lib/PicoFeed/Rules/idokep.hu.php | 18 +
.../lib/PicoFeed/Rules/imogenquest.net.php | 8 +
.../picofeed/lib/PicoFeed/Rules/index.hu.php | 29 +
.../lib/PicoFeed/Rules/indiehaven.com.php | 11 +
.../lib/PicoFeed/Rules/inforadio.hu.php | 25 +
.../picofeed/lib/PicoFeed/Rules/ing.dk.php | 12 +
.../lib/PicoFeed/Rules/invisiblebread.com.php | 8 +
.../lib/PicoFeed/Rules/ir.amd.com.php | 10 +
.../lib/PicoFeed/Rules/japantimes.co.jp.php | 21 +
.../lib/PicoFeed/Rules/japantoday.com.php | 15 +
.../lib/PicoFeed/Rules/journaldugeek.com.php | 11 +
.../lib/PicoFeed/Rules/jsonline.com.php | 37 +
.../lib/PicoFeed/Rules/justcoolidea.ru.php | 19 +
.../picofeed/lib/PicoFeed/Rules/kanpai.fr.php | 13 +
.../PicoFeed/Rules/karriere.jobfinder.dk.php | 12 +
.../lib/PicoFeed/Rules/kisalfold.hu.php | 17 +
.../lib/PicoFeed/Rules/kiszamolo.hu.php | 14 +
.../picofeed/lib/PicoFeed/Rules/kodi.tv.php | 11 +
.../lib/PicoFeed/Rules/koreaherald.com.php | 11 +
.../lib/PicoFeed/Rules/koreatimes.php | 14 +
.../PicoFeed/Rules/lastplacecomics.com.php | 8 +
.../lib/PicoFeed/Rules/legorafi.fr.php | 22 +
.../lib/PicoFeed/Rules/lejapon.fr.php | 17 +
.../lib/PicoFeed/Rules/lesjoiesducode.fr.php | 13 +
.../picofeed/lib/PicoFeed/Rules/lfg.co.php | 12 +
.../lib/PicoFeed/Rules/lifehacker.com.php | 18 +
.../lib/PicoFeed/Rules/lifehacker.ru.php | 22 +
.../lib/PicoFeed/Rules/linux-magazin.de.php | 16 +
.../picofeed/lib/PicoFeed/Rules/linux.org.php | 14 +
.../lib/PicoFeed/Rules/linux.org.ru.php | 13 +
.../lib/PicoFeed/Rules/linuxinsider.com.php | 20 +
.../p3k/picofeed/lib/PicoFeed/Rules/lists.php | 13 +
.../lib/PicoFeed/Rules/loadingartist.com.php | 8 +
.../lib/PicoFeed/Rules/loldwell.com.php | 10 +
.../lib/PicoFeed/Rules/lukesurl.com.php | 15 +
.../picofeed/lib/PicoFeed/Rules/macg.co.php | 13 +
.../lib/PicoFeed/Rules/maclife.de.php | 11 +
.../lib/PicoFeed/Rules/magyarkurir.hu.php | 21 +
.../picofeed/lib/PicoFeed/Rules/marc.info.php | 13 +
.../PicoFeed/Rules/marriedtothesea.com.php | 12 +
.../lib/PicoFeed/Rules/marycagle.com.php | 13 +
.../Rules/maximumble.thebookofbiff.com.php | 10 +
.../lib/PicoFeed/Rules/medium.com.php | 19 +
.../lib/PicoFeed/Rules/mercworks.net.php | 17 +
.../lib/PicoFeed/Rules/metronieuws.nl.php | 10 +
.../lib/PicoFeed/Rules/milwaukeenns.php | 14 +
.../picofeed/lib/PicoFeed/Rules/mno.hu.php | 14 +
.../Rules/mokepon.smackjeeves.com.php | 10 +
.../lib/PicoFeed/Rules/monandroid.com.php | 13 +
.../lib/PicoFeed/Rules/monwindows.com.php | 13 +
.../lib/PicoFeed/Rules/moya-planeta.ru.php | 21 +
.../lib/PicoFeed/Rules/mrlovenstein.com.php | 9 +
.../lib/PicoFeed/Rules/muckrock.com.php | 20 +
.../PicoFeed/Rules/mynorthshorenow.com.php | 27 +
.../lib/PicoFeed/Rules/nakedCapitalism.php | 11 +
.../picofeed/lib/PicoFeed/Rules/nasa.gov.php | 14 +
.../lib/PicoFeed/Rules/nat-geo.ru.php | 11 +
.../PicoFeed/Rules/nationaljournal.com.php | 15 +
.../lib/PicoFeed/Rules/nature.com.php | 13 +
.../picofeed/lib/PicoFeed/Rules/nba.com.php | 15 +
.../lib/PicoFeed/Rules/nedroid.com.php | 8 +
.../lib/PicoFeed/Rules/networkworld.com.php | 20 +
.../lib/PicoFeed/Rules/neustadt-ticker.de.php | 15 +
.../lib/PicoFeed/Rules/nextinpact.com.php | 18 +
.../lib/PicoFeed/Rules/niceteethcomic.com.php | 10 +
.../lib/PicoFeed/Rules/nichtlustig.de.php | 8 +
.../picofeed/lib/PicoFeed/Rules/nlcafe.hu.php | 18 +
.../lib/PicoFeed/Rules/novo-argumente.com.php | 16 +
.../picofeed/lib/PicoFeed/Rules/oglaf.com.php | 19 +
.../picofeed/lib/PicoFeed/Rules/onhax.net.php | 15 +
.../lib/PicoFeed/Rules/onlinekosten.de.php | 13 +
.../lib/PicoFeed/Rules/onmilwaukee.php | 24 +
.../lib/PicoFeed/Rules/openculture.com.php | 11 +
.../lib/PicoFeed/Rules/opennet.ru.php | 13 +
.../PicoFeed/Rules/openrightsgroup.org.php | 20 +
.../lib/PicoFeed/Rules/opensource.com.php | 22 +
.../lib/PicoFeed/Rules/optipess.com.php | 8 +
.../picofeed/lib/PicoFeed/Rules/origo.hu.php | 14 +
.../lib/PicoFeed/Rules/osnews.com.php | 11 +
.../lib/PicoFeed/Rules/pastebin.com.php | 13 +
.../lib/PicoFeed/Rules/pcgameshardware.de.php | 16 +
.../lib/PicoFeed/Rules/peebleslab.com.php | 9 +
.../lib/PicoFeed/Rules/penny-arcade.com.php | 21 +
.../lib/PicoFeed/Rules/pixelbeat.org.php | 12 +
.../lib/PicoFeed/Rules/plus.google.com.php | 11 +
.../lib/PicoFeed/Rules/popstrip.com.php | 8 +
.../lib/PicoFeed/Rules/portfolio.hu.php | 15 +
.../lib/PicoFeed/Rules/pro-linux.de.php | 16 +
.../PicoFeed/Rules/publicpolicyforum.org.php | 15 +
.../picofeed/lib/PicoFeed/Rules/publy.ru.php | 24 +
.../lib/PicoFeed/Rules/putaindecode.fr.php | 16 +
.../lib/PicoFeed/Rules/recode.net.php | 20 +
.../PicoFeed/Rules/retractionwatch.com.php | 18 +
.../PicoFeed/Rules/rockpapershotgun.com.php | 11 +
.../PicoFeed/Rules/rue89.nouvelobs.com.php | 13 +
.../lib/PicoFeed/Rules/rugbyrama.fr.php | 20 +
.../lib/PicoFeed/Rules/salonkolumnisten.com | 17 +
.../lib/PicoFeed/Rules/satwcomic.com.php | 13 +
.../PicoFeed/Rules/science-skeptical.de.php | 14 +
.../lib/PicoFeed/Rules/scrumalliance.org.php | 12 +
.../lib/PicoFeed/Rules/securityfocus.com.php | 17 +
.../PicoFeed/Rules/sentfromthemoon.com.php | 18 +
.../lib/PicoFeed/Rules/sitepoint.com.php | 13 +
.../lib/PicoFeed/Rules/slashdot.org.php | 11 +
.../PicoFeed/Rules/smallhousebliss.com.php | 19 +
.../lib/PicoFeed/Rules/smarthomewelt.de.php | 10 +
.../PicoFeed/Rules/smashingmagazine.com.php | 10 +
.../lib/PicoFeed/Rules/smbc-comics.com.php | 14 +
.../lib/PicoFeed/Rules/snopes.com.php | 22 +
.../lib/PicoFeed/Rules/soundandvision.com.php | 21 +
.../lib/PicoFeed/Rules/spiegel.de.php | 14 +
.../lib/PicoFeed/Rules/stereophile.com.php | 11 +
.../lib/PicoFeed/Rules/stupidfox.net.php | 13 +
.../lib/PicoFeed/Rules/subtraction.com.php | 15 +
.../p3k/picofeed/lib/PicoFeed/Rules/sz.de.php | 10 +
.../lib/PicoFeed/Rules/takprosto.cc.php | 21 +
.../lib/PicoFeed/Rules/techcrunch.com.php | 15 +
.../PicoFeed/Rules/the-ebook-reader.com.php | 15 +
.../lib/PicoFeed/Rules/theatlantic.com.php | 23 +
.../lib/PicoFeed/Rules/theawkwardyeti.com.php | 12 +
.../lib/PicoFeed/Rules/thecodinglove.com.php | 10 +
.../PicoFeed/Rules/thedoghousediaries.com.php | 18 +
.../lib/PicoFeed/Rules/thegamercat.com.php | 10 +
.../lib/PicoFeed/Rules/thehindu.com.php | 19 +
.../lib/PicoFeed/Rules/thelocal.se.php | 17 +
.../lib/PicoFeed/Rules/themerepublic.net.php | 10 +
.../lib/PicoFeed/Rules/themoscowtimes.com.php | 18 +
.../lib/PicoFeed/Rules/thenewslens.com.php | 21 +
.../lib/PicoFeed/Rules/theodd1sout.com.php | 8 +
.../lib/PicoFeed/Rules/theonion.com.php | 12 +
.../lib/PicoFeed/Rules/theregister.co.uk.php | 18 +
.../lib/PicoFeed/Rules/thestandard.com.hk.php | 22 +
.../lib/PicoFeed/Rules/theverge.com.php | 16 +
.../lib/PicoFeed/Rules/threepanelsoul.com.php | 11 +
.../lib/PicoFeed/Rules/tichyseinblick.de.php | 22 +
.../Rules/timesofindia.indiatimes.com.php | 14 +
.../lib/PicoFeed/Rules/totalcar.hu.php | 18 +
.../lib/PicoFeed/Rules/tozsdeforum.hu.php | 15 +
.../lib/PicoFeed/Rules/travel-dealz.de.php | 15 +
.../lib/PicoFeed/Rules/travelo.hu.php | 17 +
.../lib/PicoFeed/Rules/treehugger.com.php | 14 +
.../lib/PicoFeed/Rules/treelobsters.com.php | 8 +
.../lib/PicoFeed/Rules/tutorialzine.com.php | 20 +
.../lib/PicoFeed/Rules/twogag.com.php | 8 +
.../PicoFeed/Rules/twokinds.keenspot.com.php | 10 +
.../lib/PicoFeed/Rules/undeadly.org.php | 14 +
.../picofeed/lib/PicoFeed/Rules/upi.com.php | 15 +
.../lib/PicoFeed/Rules/usatoday.com.php | 27 +
.../lib/PicoFeed/Rules/version2.dk.php | 12 +
.../picofeed/lib/PicoFeed/Rules/vezess.hu.php | 20 +
.../lib/PicoFeed/Rules/vgcats.com.php | 15 +
.../picofeed/lib/PicoFeed/Rules/vuxml.org.php | 17 +
.../PicoFeed/Rules/wausaudailyherald.com.php | 27 +
.../picofeed/lib/PicoFeed/Rules/welt.de.php | 20 +
.../lib/PicoFeed/Rules/westfalen-blatt.de.php | 16 +
.../lib/PicoFeed/Rules/www.bbc.co.uk.php | 33 +
.../lib/PicoFeed/Rules/www.bdgest.com.php | 15 +
.../lib/PicoFeed/Rules/www.bgr.in.php | 23 +
.../PicoFeed/Rules/www.businessweek.com.php | 15 +
.../lib/PicoFeed/Rules/www.cnn.com.php | 24 +
.../lib/PicoFeed/Rules/www.developpez.com.php | 21 +
.../lib/PicoFeed/Rules/www.egscomics.com.php | 12 +
.../Rules/www.fakingnews.firstpost.com.php | 17 +
.../lib/PicoFeed/Rules/www.forbes.com.php | 20 +
.../PicoFeed/Rules/www.franceculture.fr.php | 14 +
.../Rules/www.futura-sciences.com.php | 19 +
.../PicoFeed/Rules/www.geekculture.com.php | 13 +
.../lib/PicoFeed/Rules/www.howtogeek.com.php | 14 +
.../lib/PicoFeed/Rules/www.lepoint.fr.php | 18 +
.../PicoFeed/Rules/www.lesnumeriques.com.php | 25 +
.../lib/PicoFeed/Rules/www.mac4ever.com.php | 13 +
.../lib/PicoFeed/Rules/www.makeuseof.com.php | 18 +
.../Rules/www.monsieur-le-chien.fr.php | 11 +
.../lib/PicoFeed/Rules/www.npr.org.php | 28 +
.../lib/PicoFeed/Rules/www.numerama.com.php | 15 +
.../lib/PicoFeed/Rules/www.oneindia.com.php | 14 +
.../Rules/www.pseudo-sciences.org.php | 16 +
.../lib/PicoFeed/Rules/www.sciencemag.org.php | 16 +
.../lib/PicoFeed/Rules/www.slate.fr.php | 19 +
.../PicoFeed/Rules/www.universfreebox.com.php | 15 +
.../lib/PicoFeed/Rules/www.zeit.de.php | 41 +
.../picofeed/lib/PicoFeed/Rules/xkcd.com.php | 8 +
.../lib/PicoFeed/Rules/ymatuhin.ru.php | 21 +
.../lib/PicoFeed/Rules/zarojel.hu.php | 19 +
.../picofeed/lib/PicoFeed/Rules/zdnet.com.php | 23 +
.../picofeed/lib/PicoFeed/Rules/zoom.hu.php | 17 +
.../lib/PicoFeed/Scraper/CandidateParser.php | 281 +
.../lib/PicoFeed/Scraper/ParserInterface.php | 20 +
.../lib/PicoFeed/Scraper/RuleLoader.php | 104 +
.../lib/PicoFeed/Scraper/RuleParser.php | 102 +
.../picofeed/lib/PicoFeed/Scraper/Scraper.php | 282 +
.../PicoFeed/Serialization/Subscription.php | 175 +
.../Serialization/SubscriptionList.php | 75 +
.../Serialization/SubscriptionListBuilder.php | 204 +
.../Serialization/SubscriptionListParser.php | 100 +
.../Serialization/SubscriptionParser.php | 142 +
.../PicoFeed/Syndication/AtomFeedBuilder.php | 65 +
.../lib/PicoFeed/Syndication/AtomHelper.php | 139 +
.../PicoFeed/Syndication/AtomItemBuilder.php | 63 +
.../lib/PicoFeed/Syndication/FeedBuilder.php | 185 +
.../lib/PicoFeed/Syndication/ItemBuilder.php | 209 +
.../PicoFeed/Syndication/Rss20FeedBuilder.php | 76 +
.../lib/PicoFeed/Syndication/Rss20Helper.php | 115 +
.../PicoFeed/Syndication/Rss20ItemBuilder.php | 67 +
.../admin/vendor/p3k/picofeed/picofeed | 135 +
.../vendor/zendframework/zendxml/CHANGELOG.md | 104 +
.../vendor/zendframework/zendxml/LICENSE.md | 27 +
.../vendor/zendframework/zendxml/README.md | 48 +
.../zendframework/zendxml/composer.json | 54 +
.../src/Exception/ExceptionInterface.php | 12 +
.../Exception/InvalidArgumentException.php | 15 +
.../src/Exception/RuntimeException.php | 15 +
.../zendframework/zendxml/src/Security.php | 406 +
user/plugins/email/CHANGELOG.md | 269 +
user/plugins/email/LICENSE | 21 +
user/plugins/email/README.md | 488 +
user/plugins/email/blueprints.yaml | 246 +
user/plugins/email/classes/Email.php | 545 +
user/plugins/email/classes/Utils.php | 48 +
.../email/cli/ClearQueueFailuresCommand.php | 65 +
user/plugins/email/cli/FlushQueueCommand.php | 65 +
user/plugins/email/cli/TestEmailCommand.php | 101 +
user/plugins/email/composer.json | 33 +
user/plugins/email/composer.lock | 494 +
user/plugins/email/email.php | 174 +
user/plugins/email/email.yaml | 22 +
user/plugins/email/languages.yaml | 164 +
.../email/templates/email/base.html.twig | 214 +
user/plugins/email/vendor/autoload.php | 7 +
.../email/vendor/composer/ClassLoader.php | 445 +
user/plugins/email/vendor/composer/LICENSE | 21 +
.../vendor/composer/autoload_classmap.php | 10 +
.../email/vendor/composer/autoload_files.php | 14 +
.../vendor/composer/autoload_namespaces.php | 9 +
.../email/vendor/composer/autoload_psr4.php | 17 +
.../email/vendor/composer/autoload_real.php | 73 +
.../email/vendor/composer/autoload_static.php | 88 +
.../email/vendor/composer/installed.json | 489 +
.../email/vendor/doctrine/lexer/LICENSE | 19 +
.../email/vendor/doctrine/lexer/README.md | 9 +
.../email/vendor/doctrine/lexer/composer.json | 41 +
.../Doctrine/Common/Lexer/AbstractLexer.php | 328 +
.../EmailValidator/EmailLexer.php | 279 +
.../EmailValidator/EmailParser.php | 137 +
.../EmailValidator/EmailValidator.php | 67 +
.../Exception/AtextAfterCFWS.php | 9 +
.../EmailValidator/Exception/CRLFAtTheEnd.php | 9 +
.../EmailValidator/Exception/CRLFX2.php | 9 +
.../EmailValidator/Exception/CRNoLF.php | 9 +
.../Exception/CharNotAllowed.php | 9 +
.../Exception/CommaInDomain.php | 9 +
.../Exception/ConsecutiveAt.php | 9 +
.../Exception/ConsecutiveDot.php | 9 +
.../Exception/DomainHyphened.php | 9 +
.../EmailValidator/Exception/DotAtEnd.php | 9 +
.../EmailValidator/Exception/DotAtStart.php | 9 +
.../EmailValidator/Exception/ExpectingAT.php | 9 +
.../Exception/ExpectingATEXT.php | 9 +
.../Exception/ExpectingCTEXT.php | 9 +
.../Exception/ExpectingDTEXT.php | 9 +
.../Exception/ExpectingDomainLiteralClose.php | 9 +
.../Exception/ExpectingQPair.php | 9 +
.../EmailValidator/Exception/InvalidEmail.php | 14 +
.../EmailValidator/Exception/NoDNSRecord.php | 9 +
.../EmailValidator/Exception/NoDomainPart.php | 9 +
.../EmailValidator/Exception/NoLocalPart.php | 9 +
.../Exception/UnclosedComment.php | 9 +
.../Exception/UnclosedQuotedString.php | 9 +
.../Exception/UnopenedComment.php | 9 +
.../EmailValidator/Parser/DomainPart.php | 414 +
.../EmailValidator/Parser/LocalPart.php | 145 +
.../EmailValidator/Parser/Parser.php | 249 +
.../Validation/DNSCheckValidation.php | 77 +
.../Validation/EmailValidation.php | 34 +
.../Validation/Error/RFCWarnings.php | 11 +
.../Validation/Error/SpoofEmail.php | 11 +
.../Exception/EmptyValidationList.php | 16 +
.../Validation/MultipleErrors.php | 32 +
.../Validation/MultipleValidationWithAnd.php | 124 +
.../Validation/NoRFCWarningsValidation.php | 41 +
.../Validation/RFCValidation.php | 49 +
.../Validation/SpoofCheckValidation.php | 51 +
.../EmailValidator/Warning/AddressLiteral.php | 14 +
.../EmailValidator/Warning/CFWSNearAt.php | 13 +
.../EmailValidator/Warning/CFWSWithFWS.php | 13 +
.../EmailValidator/Warning/Comment.php | 13 +
.../Warning/DeprecatedComment.php | 13 +
.../EmailValidator/Warning/DomainLiteral.php | 14 +
.../EmailValidator/Warning/DomainTooLong.php | 14 +
.../EmailValidator/Warning/EmailTooLong.php | 15 +
.../EmailValidator/Warning/IPV6BadChar.php | 14 +
.../EmailValidator/Warning/IPV6ColonEnd.php | 14 +
.../EmailValidator/Warning/IPV6ColonStart.php | 14 +
.../EmailValidator/Warning/IPV6Deprecated.php | 14 +
.../Warning/IPV6DoubleColon.php | 14 +
.../EmailValidator/Warning/IPV6GroupCount.php | 14 +
.../EmailValidator/Warning/IPV6MaxGroups.php | 14 +
.../EmailValidator/Warning/LabelTooLong.php | 14 +
.../EmailValidator/Warning/LocalTooLong.php | 15 +
.../EmailValidator/Warning/NoDNSMXRecord.php | 14 +
.../EmailValidator/Warning/ObsoleteDTEXT.php | 14 +
.../EmailValidator/Warning/QuotedPart.php | 17 +
.../EmailValidator/Warning/QuotedString.php | 17 +
.../EmailValidator/Warning/TLD.php | 13 +
.../EmailValidator/Warning/Warning.php | 47 +
.../vendor/egulias/email-validator/LICENSE | 19 +
.../vendor/egulias/email-validator/README.md | 82 +
.../egulias/email-validator/composer.json | 38 +
.../egulias/email-validator/phpunit.xml.dist | 25 +
.../email-validator/psalm.baseline.xml | 19 +
.../vendor/egulias/email-validator/psalm.xml | 19 +
.../swiftmailer/swiftmailer/.gitattributes | 9 +
.../swiftmailer/.github/ISSUE_TEMPLATE.md | 19 +
.../.github/PULL_REQUEST_TEMPLATE.md | 14 +
.../swiftmailer/swiftmailer/.php_cs.dist | 16 +
.../vendor/swiftmailer/swiftmailer/CHANGES | 354 +
.../vendor/swiftmailer/swiftmailer/LICENSE | 19 +
.../vendor/swiftmailer/swiftmailer/README.md | 19 +
.../swiftmailer/swiftmailer/composer.json | 43 +
.../swiftmailer/swiftmailer/doc/headers.rst | 621 +
.../swiftmailer/swiftmailer/doc/index.rst | 12 +
.../swiftmailer/doc/introduction.rst | 61 +
.../swiftmailer/swiftmailer/doc/japanese.rst | 19 +
.../swiftmailer/swiftmailer/doc/messages.rst | 947 ++
.../swiftmailer/swiftmailer/doc/plugins.rst | 337 +
.../swiftmailer/swiftmailer/doc/sending.rst | 453 +
.../swiftmailer/lib/classes/Swift.php | 78 +
.../lib/classes/Swift/AddressEncoder.php | 25 +
.../AddressEncoder/IdnAddressEncoder.php | 50 +
.../AddressEncoder/Utf8AddressEncoder.php | 36 +
.../classes/Swift/AddressEncoderException.php | 32 +
.../lib/classes/Swift/Attachment.php | 54 +
.../AbstractFilterableInputStream.php | 176 +
.../Swift/ByteStream/ArrayByteStream.php | 178 +
.../Swift/ByteStream/FileByteStream.php | 216 +
.../ByteStream/TemporaryFileByteStream.php | 42 +
.../lib/classes/Swift/CharacterReader.php | 67 +
.../GenericFixedWidthReader.php | 97 +
.../Swift/CharacterReader/UsAsciiReader.php | 84 +
.../Swift/CharacterReader/Utf8Reader.php | 176 +
.../classes/Swift/CharacterReaderFactory.php | 26 +
.../SimpleCharacterReaderFactory.php | 124 +
.../lib/classes/Swift/CharacterStream.php | 89 +
.../CharacterStream/ArrayCharacterStream.php | 291 +
.../CharacterStream/NgCharacterStream.php | 262 +
.../lib/classes/Swift/ConfigurableSpool.php | 63 +
.../lib/classes/Swift/DependencyContainer.php | 391 +
.../lib/classes/Swift/DependencyException.php | 27 +
.../lib/classes/Swift/EmbeddedFile.php | 53 +
.../swiftmailer/lib/classes/Swift/Encoder.php | 28 +
.../classes/Swift/Encoder/Base64Encoder.php | 58 +
.../lib/classes/Swift/Encoder/QpEncoder.php | 300 +
.../classes/Swift/Encoder/Rfc2231Encoder.php | 90 +
.../lib/classes/Swift/Events/CommandEvent.php | 64 +
.../classes/Swift/Events/CommandListener.php | 24 +
.../lib/classes/Swift/Events/Event.php | 38 +
.../classes/Swift/Events/EventDispatcher.php | 83 +
.../classes/Swift/Events/EventListener.php | 18 +
.../lib/classes/Swift/Events/EventObject.php | 61 +
.../classes/Swift/Events/ResponseEvent.php | 64 +
.../classes/Swift/Events/ResponseListener.php | 24 +
.../lib/classes/Swift/Events/SendEvent.php | 126 +
.../lib/classes/Swift/Events/SendListener.php | 31 +
.../Swift/Events/SimpleEventDispatcher.php | 143 +
.../Swift/Events/TransportChangeEvent.php | 27 +
.../Swift/Events/TransportChangeListener.php | 45 +
.../Swift/Events/TransportExceptionEvent.php | 43 +
.../Events/TransportExceptionListener.php | 24 +
.../lib/classes/Swift/FailoverTransport.php | 33 +
.../lib/classes/Swift/FileSpool.php | 208 +
.../lib/classes/Swift/FileStream.php | 24 +
.../lib/classes/Swift/Filterable.php | 32 +
.../lib/classes/Swift/IdGenerator.php | 22 +
.../swiftmailer/lib/classes/Swift/Image.php | 43 +
.../lib/classes/Swift/InputByteStream.php | 75 +
.../lib/classes/Swift/IoException.php | 28 +
.../lib/classes/Swift/KeyCache.php | 105 +
.../classes/Swift/KeyCache/ArrayKeyCache.php | 203 +
.../classes/Swift/KeyCache/DiskKeyCache.php | 295 +
.../Swift/KeyCache/KeyCacheInputStream.php | 51 +
.../classes/Swift/KeyCache/NullKeyCache.php | 113 +
.../KeyCache/SimpleKeyCacheInputStream.php | 123 +
.../classes/Swift/LoadBalancedTransport.php | 33 +
.../swiftmailer/lib/classes/Swift/Mailer.php | 98 +
.../Swift/Mailer/ArrayRecipientIterator.php | 53 +
.../Swift/Mailer/RecipientIterator.php | 32 +
.../lib/classes/Swift/MemorySpool.php | 110 +
.../swiftmailer/lib/classes/Swift/Message.php | 279 +
.../lib/classes/Swift/Mime/Attachment.php | 144 +
.../classes/Swift/Mime/CharsetObserver.php | 24 +
.../lib/classes/Swift/Mime/ContentEncoder.php | 34 +
.../ContentEncoder/Base64ContentEncoder.php | 101 +
.../ContentEncoder/NativeQpContentEncoder.php | 123 +
.../ContentEncoder/NullContentEncoder.php | 79 +
.../ContentEncoder/PlainContentEncoder.php | 164 +
.../Mime/ContentEncoder/QpContentEncoder.php | 134 +
.../ContentEncoder/QpContentEncoderProxy.php | 96 +
.../Mime/ContentEncoder/RawContentEncoder.php | 65 +
.../lib/classes/Swift/Mime/EmbeddedFile.php | 41 +
.../classes/Swift/Mime/EncodingObserver.php | 24 +
.../lib/classes/Swift/Mime/Header.php | 93 +
.../lib/classes/Swift/Mime/HeaderEncoder.php | 24 +
.../HeaderEncoder/Base64HeaderEncoder.php | 55 +
.../Mime/HeaderEncoder/QpHeaderEncoder.php | 65 +
.../Swift/Mime/Headers/AbstractHeader.php | 476 +
.../classes/Swift/Mime/Headers/DateHeader.php | 113 +
.../Mime/Headers/IdentificationHeader.php | 186 +
.../Swift/Mime/Headers/MailboxHeader.php | 360 +
.../Swift/Mime/Headers/OpenDKIMHeader.php | 135 +
.../Mime/Headers/ParameterizedHeader.php | 255 +
.../classes/Swift/Mime/Headers/PathHeader.php | 155 +
.../Swift/Mime/Headers/UnstructuredHeader.php | 109 +
.../lib/classes/Swift/Mime/IdGenerator.php | 54 +
.../lib/classes/Swift/Mime/MimePart.php | 199 +
.../Swift/Mime/SimpleHeaderFactory.php | 195 +
.../classes/Swift/Mime/SimpleHeaderSet.php | 399 +
.../lib/classes/Swift/Mime/SimpleMessage.php | 642 +
.../classes/Swift/Mime/SimpleMimeEntity.php | 820 +
.../lib/classes/Swift/MimePart.php | 45 +
.../lib/classes/Swift/NullTransport.php | 26 +
.../lib/classes/Swift/OutputByteStream.php | 46 +
.../classes/Swift/Plugins/AntiFloodPlugin.php | 137 +
.../Swift/Plugins/BandwidthMonitorPlugin.php | 154 +
.../Swift/Plugins/Decorator/Replacements.php | 31 +
.../classes/Swift/Plugins/DecoratorPlugin.php | 200 +
.../Swift/Plugins/ImpersonatePlugin.php | 65 +
.../lib/classes/Swift/Plugins/Logger.php | 36 +
.../classes/Swift/Plugins/LoggerPlugin.php | 126 +
.../Swift/Plugins/Loggers/ArrayLogger.php | 72 +
.../Swift/Plugins/Loggers/EchoLogger.php | 58 +
.../classes/Swift/Plugins/MessageLogger.php | 70 +
.../Swift/Plugins/Pop/Pop3Connection.php | 31 +
.../Swift/Plugins/Pop/Pop3Exception.php | 27 +
.../Swift/Plugins/PopBeforeSmtpPlugin.php | 254 +
.../Swift/Plugins/RedirectingPlugin.php | 201 +
.../lib/classes/Swift/Plugins/Reporter.php | 32 +
.../classes/Swift/Plugins/ReporterPlugin.php | 57 +
.../Swift/Plugins/Reporters/HitReporter.php | 58 +
.../Swift/Plugins/Reporters/HtmlReporter.php | 38 +
.../lib/classes/Swift/Plugins/Sleeper.php | 24 +
.../classes/Swift/Plugins/ThrottlerPlugin.php | 196 +
.../lib/classes/Swift/Plugins/Timer.php | 24 +
.../lib/classes/Swift/Preferences.php | 100 +
.../Swift/ReplacementFilterFactory.php | 27 +
.../classes/Swift/RfcComplianceException.php | 27 +
.../lib/classes/Swift/SendmailTransport.php | 33 +
.../swiftmailer/lib/classes/Swift/Signer.php | 19 +
.../lib/classes/Swift/Signers/BodySigner.php | 33 +
.../lib/classes/Swift/Signers/DKIMSigner.php | 682 +
.../classes/Swift/Signers/DomainKeySigner.php | 504 +
.../classes/Swift/Signers/HeaderSigner.php | 65 +
.../classes/Swift/Signers/OpenDKIMSigner.php | 183 +
.../lib/classes/Swift/Signers/SMimeSigner.php | 542 +
.../lib/classes/Swift/SmtpTransport.php | 42 +
.../swiftmailer/lib/classes/Swift/Spool.php | 53 +
.../lib/classes/Swift/SpoolTransport.php | 33 +
.../lib/classes/Swift/StreamFilter.php | 35 +
.../ByteArrayReplacementFilter.php | 166 +
.../StreamFilters/StringReplacementFilter.php | 70 +
.../StringReplacementFilterFactory.php | 45 +
.../lib/classes/Swift/SwiftException.php | 28 +
.../lib/classes/Swift/Transport.php | 79 +
.../Swift/Transport/AbstractSmtpTransport.php | 543 +
.../Esmtp/Auth/CramMd5Authenticator.php | 75 +
.../Esmtp/Auth/LoginAuthenticator.php | 45 +
.../Esmtp/Auth/NTLMAuthenticator.php | 681 +
.../Esmtp/Auth/PlainAuthenticator.php | 44 +
.../Esmtp/Auth/XOAuth2Authenticator.php | 64 +
.../Swift/Transport/Esmtp/AuthHandler.php | 268 +
.../Swift/Transport/Esmtp/Authenticator.php | 37 +
.../Transport/Esmtp/EightBitMimeHandler.php | 113 +
.../Swift/Transport/Esmtp/SmtpUtf8Handler.php | 107 +
.../classes/Swift/Transport/EsmtpHandler.php | 86 +
.../Swift/Transport/EsmtpTransport.php | 446 +
.../Swift/Transport/FailoverTransport.php | 105 +
.../lib/classes/Swift/Transport/IoBuffer.php | 67 +
.../Swift/Transport/LoadBalancedTransport.php | 194 +
.../classes/Swift/Transport/NullTransport.php | 98 +
.../Swift/Transport/SendmailTransport.php | 158 +
.../lib/classes/Swift/Transport/SmtpAgent.php | 36 +
.../Swift/Transport/SpoolTransport.php | 120 +
.../classes/Swift/Transport/StreamBuffer.php | 329 +
.../lib/classes/Swift/TransportException.php | 28 +
.../lib/dependency_maps/cache_deps.php | 23 +
.../lib/dependency_maps/message_deps.php | 9 +
.../lib/dependency_maps/mime_deps.php | 134 +
.../lib/dependency_maps/transport_deps.php | 97 +
.../swiftmailer/lib/mime_types.php | 1007 ++
.../swiftmailer/lib/preferences.php | 19 +
.../swiftmailer/lib/swift_required.php | 22 +
.../lib/swiftmailer_generate_mimes_config.php | 182 +
.../swiftmailer/swiftmailer/phpunit.xml.dist | 38 +
.../tests/IdenticalBinaryConstraint.php | 62 +
.../swiftmailer/tests/StreamCollector.php | 11 +
.../tests/SwiftMailerSmokeTestCase.php | 46 +
.../swiftmailer/tests/SwiftMailerTestCase.php | 38 +
.../_samples/charsets/iso-2022-jp/one.txt | 11 +
.../_samples/charsets/iso-8859-1/one.txt | 19 +
.../tests/_samples/charsets/utf-8/one.txt | 22 +
.../tests/_samples/charsets/utf-8/three.txt | 45 +
.../tests/_samples/charsets/utf-8/two.txt | 3 +
.../tests/_samples/dkim/dkim.test.priv | 15 +
.../tests/_samples/dkim/dkim.test.pub | 6 +
.../swiftmailer/tests/_samples/files/data.txt | 1 +
.../tests/_samples/files/swiftmailer.png | Bin 0 -> 3194 bytes
.../tests/_samples/files/textfile.zip | Bin 0 -> 202 bytes
.../swiftmailer/tests/_samples/smime/CA.srl | 1 +
.../swiftmailer/tests/_samples/smime/ca.crt | 21 +
.../swiftmailer/tests/_samples/smime/ca.key | 27 +
.../tests/_samples/smime/create-cert.sh | 40 +
.../tests/_samples/smime/encrypt.crt | 19 +
.../tests/_samples/smime/encrypt.key | 27 +
.../tests/_samples/smime/encrypt2.crt | 19 +
.../tests/_samples/smime/encrypt2.key | 27 +
.../tests/_samples/smime/intermediate.crt | 19 +
.../tests/_samples/smime/intermediate.key | 27 +
.../swiftmailer/tests/_samples/smime/sign.crt | 19 +
.../swiftmailer/tests/_samples/smime/sign.key | 27 +
.../tests/_samples/smime/sign2.crt | 19 +
.../tests/_samples/smime/sign2.key | 27 +
.../tests/acceptance.conf.php.default | 37 +
.../Swift/AttachmentAcceptanceTest.php | 12 +
.../FileByteStreamAcceptanceTest.php | 162 +
...leCharacterReaderFactoryAcceptanceTest.php | 179 +
.../DependencyContainerAcceptanceTest.php | 22 +
.../Swift/EmbeddedFileAcceptanceTest.php | 12 +
.../Encoder/Base64EncoderAcceptanceTest.php | 45 +
.../Swift/Encoder/QpEncoderAcceptanceTest.php | 54 +
.../Encoder/Rfc2231EncoderAcceptanceTest.php | 50 +
.../KeyCache/ArrayKeyCacheAcceptanceTest.php | 173 +
.../KeyCache/DiskKeyCacheAcceptanceTest.php | 173 +
.../Swift/MessageAcceptanceTest.php | 55 +
.../Swift/Mime/AttachmentAcceptanceTest.php | 126 +
.../Base64ContentEncoderAcceptanceTest.php | 56 +
.../NativeQpContentEncoderAcceptanceTest.php | 88 +
.../PlainContentEncoderAcceptanceTest.php | 88 +
.../QpContentEncoderAcceptanceTest.php | 160 +
.../Swift/Mime/EmbeddedFileAcceptanceTest.php | 139 +
.../Base64HeaderEncoderAcceptanceTest.php | 32 +
.../Swift/Mime/MimePartAcceptanceTest.php | 130 +
.../Mime/SimpleMessageAcceptanceTest.php | 1250 ++
.../Swift/MimePartAcceptanceTest.php | 15 +
.../AbstractStreamBufferAcceptanceTest.php | 131 +
.../BasicSocketAcceptanceTest.php | 33 +
.../StreamBuffer/ProcessAcceptanceTest.php | 26 +
.../StreamBuffer/SocketTimeoutTest.php | 65 +
.../StreamBuffer/SslSocketAcceptanceTest.php | 40 +
.../StreamBuffer/TlsSocketAcceptanceTest.php | 39 +
.../swiftmailer/tests/bootstrap.php | 21 +
.../tests/bug/Swift/Bug111Test.php | 42 +
.../tests/bug/Swift/Bug118Test.php | 20 +
.../tests/bug/Swift/Bug206Test.php | 40 +
.../tests/bug/Swift/Bug274Test.php | 25 +
.../swiftmailer/tests/bug/Swift/Bug34Test.php | 75 +
.../swiftmailer/tests/bug/Swift/Bug35Test.php | 73 +
.../swiftmailer/tests/bug/Swift/Bug38Test.php | 192 +
.../tests/bug/Swift/Bug518Test.php | 38 +
.../swiftmailer/tests/bug/Swift/Bug51Test.php | 110 +
.../tests/bug/Swift/Bug534Test.php | 38 +
.../tests/bug/Swift/Bug650Test.php | 38 +
.../swiftmailer/tests/bug/Swift/Bug71Test.php | 20 +
.../swiftmailer/tests/bug/Swift/Bug76Test.php | 71 +
...FileByteStreamConsecutiveReadCallsTest.php | 18 +
.../tests/fixtures/MimeEntityFixture.php | 67 +
.../swiftmailer/tests/smoke.conf.php.default | 63 +
.../smoke/Swift/Smoke/AttachmentSmokeTest.php | 33 +
.../smoke/Swift/Smoke/BasicSmokeTest.php | 23 +
.../Smoke/HtmlWithAttachmentSmokeTest.php | 33 +
.../Swift/Smoke/InternationalSmokeTest.php | 40 +
.../Swift/ByteStream/ArrayByteStreamTest.php | 202 +
.../GenericFixedWidthReaderTest.php | 43 +
.../CharacterReader/UsAsciiReaderTest.php | 52 +
.../Swift/CharacterReader/Utf8ReaderTest.php | 65 +
.../ArrayCharacterStreamTest.php | 358 +
.../unit/Swift/DependencyContainerTest.php | 191 +
.../unit/Swift/Encoder/Base64EncoderTest.php | 173 +
.../unit/Swift/Encoder/QpEncoderTest.php | 400 +
.../unit/Swift/Encoder/Rfc2231EncoderTest.php | 141 +
.../unit/Swift/Events/CommandEventTest.php | 34 +
.../unit/Swift/Events/EventObjectTest.php | 32 +
.../unit/Swift/Events/ResponseEventTest.php | 38 +
.../tests/unit/Swift/Events/SendEventTest.php | 96 +
.../Events/SimpleEventDispatcherTest.php | 142 +
.../Swift/Events/TransportChangeEventTest.php | 30 +
.../Events/TransportExceptionEventTest.php | 41 +
.../unit/Swift/KeyCache/ArrayKeyCacheTest.php | 240 +
.../SimpleKeyCacheInputStreamTest.php | 73 +
.../Mailer/ArrayRecipientIteratorTest.php | 42 +
.../tests/unit/Swift/MailerTest.php | 145 +
.../tests/unit/Swift/MessageTest.php | 133 +
.../Swift/Mime/AbstractMimeEntityTest.php | 1092 ++
.../tests/unit/Swift/Mime/AttachmentTest.php | 321 +
.../Base64ContentEncoderTest.php | 323 +
.../PlainContentEncoderTest.php | 171 +
.../ContentEncoder/QpContentEncoderTest.php | 516 +
.../unit/Swift/Mime/EmbeddedFileTest.php | 59 +
.../HeaderEncoder/Base64HeaderEncoderTest.php | 13 +
.../HeaderEncoder/QpHeaderEncoderTest.php | 221 +
.../Swift/Mime/Headers/DateHeaderTest.php | 90 +
.../Mime/Headers/IdentificationHeaderTest.php | 192 +
.../Swift/Mime/Headers/MailboxHeaderTest.php | 367 +
.../Mime/Headers/ParameterizedHeaderTest.php | 396 +
.../Swift/Mime/Headers/PathHeaderTest.php | 95 +
.../Mime/Headers/UnstructuredHeaderTest.php | 353 +
.../tests/unit/Swift/Mime/IdGeneratorTest.php | 32 +
.../tests/unit/Swift/Mime/MimePartTest.php | 234 +
.../Swift/Mime/SimpleHeaderFactoryTest.php | 169 +
.../unit/Swift/Mime/SimpleHeaderSetTest.php | 734 +
.../unit/Swift/Mime/SimpleMessageTest.php | 837 +
.../unit/Swift/Mime/SimpleMimeEntityTest.php | 12 +
.../Swift/Plugins/AntiFloodPluginTest.php | 93 +
.../Plugins/BandwidthMonitorPluginTest.php | 128 +
.../Swift/Plugins/DecoratorPluginTest.php | 284 +
.../unit/Swift/Plugins/LoggerPluginTest.php | 188 +
.../Swift/Plugins/Loggers/ArrayLoggerTest.php | 65 +
.../Swift/Plugins/Loggers/EchoLoggerTest.php | 24 +
.../Swift/Plugins/PopBeforeSmtpPluginTest.php | 101 +
.../Swift/Plugins/RedirectingPluginTest.php | 183 +
.../unit/Swift/Plugins/ReporterPluginTest.php | 86 +
.../Plugins/Reporters/HitReporterTest.php | 64 +
.../Plugins/Reporters/HtmlReporterTest.php | 54 +
.../Swift/Plugins/ThrottlerPluginTest.php | 102 +
.../unit/Swift/Signers/DKIMSignerTest.php | 220 +
.../unit/Swift/Signers/OpenDKIMSignerTest.php | 45 +
.../unit/Swift/Signers/SMimeSignerTest.php | 653 +
.../ByteArrayReplacementFilterTest.php | 129 +
.../StringReplacementFilterFactoryTest.php | 36 +
.../StringReplacementFilterTest.php | 59 +
.../AbstractSmtpEventSupportTest.php | 558 +
.../unit/Swift/Transport/AbstractSmtpTest.php | 1400 ++
.../Esmtp/Auth/CramMd5AuthenticatorTest.php | 65 +
.../Esmtp/Auth/LoginAuthenticatorTest.php | 65 +
.../Esmtp/Auth/NTLMAuthenticatorTest.php | 204 +
.../Esmtp/Auth/PlainAuthenticatorTest.php | 68 +
.../Swift/Transport/Esmtp/AuthHandlerTest.php | 165 +
.../EsmtpTransport/ExtensionSupportTest.php | 561 +
.../Swift/Transport/EsmtpTransportTest.php | 651 +
.../Swift/Transport/FailoverTransportTest.php | 600 +
.../Transport/LoadBalancedTransportTest.php | 838 +
.../Swift/Transport/SendmailTransportTest.php | 150 +
.../unit/Swift/Transport/StreamBufferTest.php | 43 +
.../vendor/symfony/polyfill-iconv/Iconv.php | 741 +
.../vendor/symfony/polyfill-iconv/LICENSE | 19 +
.../vendor/symfony/polyfill-iconv/README.md | 14 +
.../Resources/charset/from.big5.php | 13719 ++++++++++++++++
.../Resources/charset/from.cp037.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.cp1006.php | Bin 0 -> 3860 bytes
.../Resources/charset/from.cp1026.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.cp424.php | Bin 0 -> 3210 bytes
.../Resources/charset/from.cp437.php | Bin 0 -> 3841 bytes
.../Resources/charset/from.cp500.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.cp737.php | Bin 0 -> 3834 bytes
.../Resources/charset/from.cp775.php | Bin 0 -> 3815 bytes
.../Resources/charset/from.cp850.php | Bin 0 -> 3809 bytes
.../Resources/charset/from.cp852.php | Bin 0 -> 3808 bytes
.../Resources/charset/from.cp855.php | Bin 0 -> 3809 bytes
.../Resources/charset/from.cp856.php | Bin 0 -> 3194 bytes
.../Resources/charset/from.cp857.php | Bin 0 -> 3763 bytes
.../Resources/charset/from.cp860.php | Bin 0 -> 3840 bytes
.../Resources/charset/from.cp861.php | Bin 0 -> 3841 bytes
.../Resources/charset/from.cp862.php | Bin 0 -> 3841 bytes
.../Resources/charset/from.cp863.php | Bin 0 -> 3841 bytes
.../Resources/charset/from.cp864.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.cp865.php | Bin 0 -> 3841 bytes
.../Resources/charset/from.cp866.php | Bin 0 -> 3831 bytes
.../Resources/charset/from.cp869.php | Bin 0 -> 3676 bytes
.../Resources/charset/from.cp874.php | Bin 0 -> 3410 bytes
.../Resources/charset/from.cp875.php | Bin 0 -> 3776 bytes
.../Resources/charset/from.cp932.php | Bin 0 -> 134095 bytes
.../Resources/charset/from.cp936.php | Bin 0 -> 372283 bytes
.../Resources/charset/from.cp949.php | Bin 0 -> 291504 bytes
.../Resources/charset/from.cp950.php | Bin 0 -> 231436 bytes
.../Resources/charset/from.iso-8859-1.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.iso-8859-10.php | Bin 0 -> 3780 bytes
.../Resources/charset/from.iso-8859-11.php | Bin 0 -> 3746 bytes
.../Resources/charset/from.iso-8859-13.php | Bin 0 -> 3783 bytes
.../Resources/charset/from.iso-8859-14.php | Bin 0 -> 3801 bytes
.../Resources/charset/from.iso-8859-15.php | Bin 0 -> 3780 bytes
.../Resources/charset/from.iso-8859-16.php | Bin 0 -> 3782 bytes
.../Resources/charset/from.iso-8859-2.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.iso-8859-3.php | Bin 0 -> 3674 bytes
.../Resources/charset/from.iso-8859-4.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.iso-8859-5.php | Bin 0 -> 3780 bytes
.../Resources/charset/from.iso-8859-6.php | Bin 0 -> 3104 bytes
.../Resources/charset/from.iso-8859-7.php | Bin 0 -> 3692 bytes
.../Resources/charset/from.iso-8859-8.php | Bin 0 -> 3242 bytes
.../Resources/charset/from.iso-8859-9.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.koi8-r.php | Bin 0 -> 3835 bytes
.../Resources/charset/from.koi8-u.php | Bin 0 -> 3827 bytes
.../Resources/charset/from.us-ascii.php | Bin 0 -> 1859 bytes
.../Resources/charset/from.windows-1250.php | Bin 0 -> 3721 bytes
.../Resources/charset/from.windows-1251.php | Bin 0 -> 3782 bytes
.../Resources/charset/from.windows-1252.php | Bin 0 -> 3721 bytes
.../Resources/charset/from.windows-1253.php | Bin 0 -> 3542 bytes
.../Resources/charset/from.windows-1254.php | Bin 0 -> 3691 bytes
.../Resources/charset/from.windows-1255.php | Bin 0 -> 3454 bytes
.../Resources/charset/from.windows-1256.php | Bin 0 -> 3800 bytes
.../Resources/charset/from.windows-1257.php | Bin 0 -> 3616 bytes
.../Resources/charset/from.windows-1258.php | Bin 0 -> 3662 bytes
.../Resources/charset/translit.php | 4098 +++++
.../symfony/polyfill-iconv/bootstrap.php | 46 +
.../symfony/polyfill-iconv/composer.json | 34 +
.../vendor/symfony/polyfill-intl-idn/Idn.php | 283 +
.../vendor/symfony/polyfill-intl-idn/LICENSE | 19 +
.../symfony/polyfill-intl-idn/README.md | 12 +
.../symfony/polyfill-intl-idn/bootstrap.php | 61 +
.../symfony/polyfill-intl-idn/composer.json | 36 +
.../vendor/symfony/polyfill-mbstring/LICENSE | 19 +
.../symfony/polyfill-mbstring/Mbstring.php | 847 +
.../symfony/polyfill-mbstring/README.md | 13 +
.../Resources/unidata/lowerCase.php | 1096 ++
.../Resources/unidata/titleCaseRegexp.php | 5 +
.../Resources/unidata/upperCase.php | 1104 ++
.../symfony/polyfill-mbstring/bootstrap.php | 64 +
.../symfony/polyfill-mbstring/composer.json | 34 +
.../vendor/symfony/polyfill-php72/LICENSE | 19 +
.../vendor/symfony/polyfill-php72/Php72.php | 216 +
.../vendor/symfony/polyfill-php72/README.md | 27 +
.../symfony/polyfill-php72/bootstrap.php | 36 +
.../symfony/polyfill-php72/composer.json | 31 +
user/plugins/error/CHANGELOG.md | 76 +
user/plugins/error/LICENSE | 21 +
user/plugins/error/README.md | 93 +
user/plugins/error/assets/readme_1.png | Bin 0 -> 41685 bytes
user/plugins/error/blueprints.yaml | 36 +
user/plugins/error/cli/LogCommand.php | 130 +
user/plugins/error/composer.json | 39 +
user/plugins/error/error.php | 85 +
user/plugins/error/error.yaml | 3 +
user/plugins/error/languages.yaml | 55 +
user/plugins/error/pages/error.md | 13 +
user/plugins/error/templates/error.html.twig | 3 +
user/plugins/error/templates/error.json.twig | 1 +
user/plugins/error/vendor/autoload.php | 7 +
.../error/vendor/composer/ClassLoader.php | 445 +
user/plugins/error/vendor/composer/LICENSE | 21 +
.../vendor/composer/autoload_classmap.php | 10 +
.../vendor/composer/autoload_namespaces.php | 9 +
.../error/vendor/composer/autoload_psr4.php | 10 +
.../error/vendor/composer/autoload_real.php | 52 +
.../error/vendor/composer/autoload_static.php | 36 +
.../error/vendor/composer/installed.json | 1 +
user/plugins/form/.eslintrc | 165 +
user/plugins/form/CHANGELOG.md | 1027 ++
user/plugins/form/LICENSE | 21 +
user/plugins/form/README.md | 37 +
user/plugins/form/app/fields/array.js | 194 +
user/plugins/form/app/fields/file.js | 340 +
user/plugins/form/app/fields/form.js | 94 +
user/plugins/form/app/fields/index.js | 7 +
user/plugins/form/app/fields/media.js | 174 +
user/plugins/form/app/fields/tabs.js | 14 +
user/plugins/form/app/main.js | 4 +
user/plugins/form/app/utils/keep-alive.js | 15 +
user/plugins/form/assets/dropzone.min.css | 1 +
user/plugins/form/assets/form-styles.css | 80 +
user/plugins/form/assets/form-styles.min.css | 1 +
user/plugins/form/assets/form.min.js | 41 +
user/plugins/form/assets/form.vendor.js | 24 +
.../form/assets/object.assign.polyfill.js | 29 +
user/plugins/form/assets/signature_pad.js | 617 +
user/plugins/form/blueprints.yaml | 199 +
user/plugins/form/classes/Form.php | 1331 ++
user/plugins/form/classes/FormFactory.php | 40 +
user/plugins/form/classes/Forms.php | 92 +
user/plugins/form/composer.json | 40 +
user/plugins/form/composer.lock | 71 +
user/plugins/form/form.php | 1105 ++
user/plugins/form/form.yaml | 20 +
user/plugins/form/gulpfile.js | 84 +
user/plugins/form/languages.yaml | 823 +
user/plugins/form/package.json | 45 +
user/plugins/form/scss/form-styles.scss | 289 +
.../form/templates/form-messages.html.twig | 2 +
.../form/templates/form-messages.json.twig | 2 +
user/plugins/form/templates/form.html.twig | 8 +
user/plugins/form/templates/form.json.twig | 1 +
.../plugins/form/templates/formdata.html.twig | 20 +
.../form/templates/forms/ajax.json.twig | 5 +
.../form/templates/forms/data.html.twig | 1 +
.../form/templates/forms/data.txt.twig | 1 +
.../templates/forms/default/data.html.twig | 63 +
.../templates/forms/default/data.txt.twig | 21 +
.../templates/forms/default/field.html.twig | 155 +
.../templates/forms/default/fields.html.twig | 15 +
.../templates/forms/default/form.html.twig | 178 +
.../forms/default/toggleable.html.twig | 9 +
.../forms/dropzone/template.html.twig | 39 +
.../form/templates/forms/field.html.twig | 1 +
.../forms/fields/array/array.html.twig | 99 +
.../forms/fields/avatar/avatar.html.twig | 10 +
.../forms/fields/captcha/captcha.html.twig | 96 +
.../forms/fields/checkbox/checkbox.html.twig | 37 +
.../fields/checkboxes/checkboxes.html.twig | 42 +
.../forms/fields/color/color.html.twig | 6 +
.../forms/fields/column/column.html.twig | 9 +
.../forms/fields/columns/columns.html.twig | 9 +
.../fields/conditional/conditional.html.twig | 21 +
.../forms/fields/date/date.html.twig | 8 +
.../forms/fields/date/edit_list.html.twig | 1 +
.../forms/fields/datetime/datetime.html.twig | 2 +
.../forms/fields/datetime/edit_list.html.twig | 1 +
.../forms/fields/display/display.html.twig | 17 +
.../forms/fields/email/email.html.twig | 7 +
.../forms/fields/fieldset/fieldset.html.twig | 14 +
.../forms/fields/file/file.html.twig | 119 +
.../forms/fields/formname/formname.html.twig | 5 +
.../forms/fields/formtask/formtask.html.twig | 8 +
.../forms/fields/hidden/hidden.html.twig | 9 +
.../forms/fields/honeypot/honeypot.html.twig | 12 +
.../forms/fields/ignore/ignore.html.twig | 0
.../templates/forms/fields/key/key.html.twig | 27 +
.../forms/fields/month/month.html.twig | 6 +
.../forms/fields/number/number.html.twig | 9 +
.../forms/fields/password/password.html.twig | 8 +
.../forms/fields/radio/radio.html.twig | 24 +
.../forms/fields/range/range.html.twig | 9 +
.../forms/fields/section/section.html.twig | 21 +
.../forms/fields/select/select.html.twig | 69 +
.../select_optgroup/select_optgroup.html.twig | 2 +
.../fields/signature/signature.html.twig | 105 +
.../forms/fields/spacer/spacer.html.twig | 19 +
.../forms/fields/switch/switch.html.twig | 1 +
.../templates/forms/fields/tab/tab.html.twig | 9 +
.../forms/fields/tabs/tabs.html.twig | 66 +
.../templates/forms/fields/tel/tel.html.twig | 6 +
.../forms/fields/text/edit_list.html.twig | 5 +
.../forms/fields/text/text.html.twig | 39 +
.../forms/fields/textarea/textarea.html.twig | 42 +
.../forms/fields/time/edit_list.html.twig | 1 +
.../forms/fields/time/time.html.twig | 6 +
.../forms/fields/toggle/edit_list.html.twig | 5 +
.../forms/fields/toggle/toggle.html.twig | 66 +
.../forms/fields/uniqueid/uniqueid.html.twig | 5 +
.../forms/fields/url/edit_list.html.twig | 1 +
.../templates/forms/fields/url/url.html.twig | 6 +
.../forms/fields/value/value.html.twig | 18 +
.../forms/fields/week/week.html.twig | 6 +
.../form/templates/forms/form.html.twig | 1 +
.../templates/forms/layouts/button.html.twig | 12 +
.../forms/layouts/field-variables.html.twig | 1 +
.../templates/forms/layouts/field.html.twig | 52 +
.../templates/forms/layouts/form.html.twig | 7 +
.../form/templates/modular/form.html.twig | 4 +
.../partials/form-messages.html.twig | 6 +
.../partials/form-messages.json.twig | 3 +
user/plugins/form/vendor/autoload.php | 7 +
.../form/vendor/composer/ClassLoader.php | 445 +
user/plugins/form/vendor/composer/LICENSE | 21 +
.../vendor/composer/autoload_classmap.php | 10 +
.../vendor/composer/autoload_namespaces.php | 9 +
.../form/vendor/composer/autoload_psr4.php | 11 +
.../form/vendor/composer/autoload_real.php | 52 +
.../form/vendor/composer/autoload_static.php | 44 +
.../form/vendor/composer/installed.json | 51 +
.../.github/ISSUE_TEMPLATE/bug_report.md | 28 +
.../vendor/google/recaptcha/ARCHITECTURE.md | 64 +
.../vendor/google/recaptcha/CONTRIBUTING.md | 49 +
.../form/vendor/google/recaptcha/LICENSE | 29 +
.../form/vendor/google/recaptcha/README.md | 140 +
.../form/vendor/google/recaptcha/app.yaml | 8 +
.../vendor/google/recaptcha/composer.json | 39 +
.../recaptcha/examples/appengine-https.php | 42 +
.../google/recaptcha/examples/config.php.dist | 46 +
.../google/recaptcha/examples/examples.css | 37 +
.../examples/google0afd8760fd68f119.html | 1 +
.../google/recaptcha/examples/index.php | 79 +
.../recaptcha-content-security-policy.php | 152 +
.../recaptcha-v2-checkbox-explicit.php | 148 +
.../examples/recaptcha-v2-checkbox.php | 139 +
.../examples/recaptcha-v2-invisible.php | 141 +
.../examples/recaptcha-v3-request-scores.php | 120 +
.../examples/recaptcha-v3-verify.php | 59 +
.../google/recaptcha/examples/robots.txt | 2 +
.../vendor/google/recaptcha/phpunit.xml.dist | 20 +
.../recaptcha/src/ReCaptcha/ReCaptcha.php | 269 +
.../recaptcha/src/ReCaptcha/RequestMethod.php | 50 +
.../src/ReCaptcha/RequestMethod/Curl.php | 82 +
.../src/ReCaptcha/RequestMethod/CurlPost.php | 104 +
.../src/ReCaptcha/RequestMethod/Post.php | 88 +
.../src/ReCaptcha/RequestMethod/Socket.php | 112 +
.../ReCaptcha/RequestMethod/SocketPost.php | 108 +
.../src/ReCaptcha/RequestParameters.php | 111 +
.../recaptcha/src/ReCaptcha/Response.php | 218 +
.../vendor/google/recaptcha/src/autoload.php | 69 +
.../tests/ReCaptcha/ReCaptchaTest.php | 198 +
.../ReCaptcha/RequestMethod/CurlPostTest.php | 123 +
.../ReCaptcha/RequestMethod/PostTest.php | 149 +
.../RequestMethod/SocketPostTest.php | 136 +
.../tests/ReCaptcha/RequestParametersTest.php | 70 +
.../tests/ReCaptcha/ResponseTest.php | 173 +
user/plugins/form/webpack.conf.js | 65 +
user/plugins/login/CHANGELOG.md | 737 +
user/plugins/login/LICENSE | 21 +
user/plugins/login/README.md | 556 +
user/plugins/login/blueprints.yaml | 464 +
user/plugins/login/classes/Controller.php | 684 +
.../login/classes/Events/UserLoginEvent.php | 393 +
user/plugins/login/classes/Login.php | 724 +
user/plugins/login/classes/LoginCache.php | 105 +
user/plugins/login/classes/RateLimiter.php | 110 +
.../login/classes/RememberMe/RememberMe.php | 43 +
.../login/classes/RememberMe/TokenStorage.php | 172 +
.../classes/TwoFactorAuth/BaconQrProvider.php | 32 +
.../classes/TwoFactorAuth/TwoFactorAuth.php | 76 +
.../login/cli/ChangePasswordCommand.php | 177 +
.../login/cli/ChangeUserStateCommand.php | 157 +
user/plugins/login/cli/LookupUserCommand.php | 94 +
user/plugins/login/cli/NewUserCommand.php | 302 +
user/plugins/login/composer.json | 49 +
user/plugins/login/composer.lock | 214 +
user/plugins/login/css/login.css | 86 +
user/plugins/login/js/2fa.js | 34 +
user/plugins/login/languages/de.yaml | 139 +
user/plugins/login/languages/en.yaml | 154 +
user/plugins/login/languages/es.yaml | 126 +
user/plugins/login/languages/fr.yaml | 97 +
user/plugins/login/languages/hr.yaml | 54 +
user/plugins/login/languages/hu.yaml | 35 +
user/plugins/login/languages/no.yaml | 73 +
user/plugins/login/languages/ro.yaml | 97 +
user/plugins/login/languages/ru.yaml | 145 +
user/plugins/login/languages/uk.yaml | 145 +
user/plugins/login/login.php | 1257 ++
user/plugins/login/login.yaml | 63 +
user/plugins/login/pages/forgot.md | 22 +
user/plugins/login/pages/login.md | 42 +
user/plugins/login/pages/profile.md | 81 +
user/plugins/login/pages/register.md | 59 +
user/plugins/login/pages/reset.md | 35 +
user/plugins/login/pages/unauthorized.md | 6 +
user/plugins/login/templates/forgot.html.twig | 6 +
.../fields/2fa_secret/2fa_secret.html.twig | 31 +
user/plugins/login/templates/login.html.twig | 6 +
user/plugins/login/templates/login.json.twig | 5 +
.../templates/partials/forgot-form.html.twig | 21 +
.../templates/partials/login-form.html.twig | 64 +
.../templates/partials/login-status.html.twig | 5 +
.../templates/partials/login-twofa.html.twig | 25 +
.../templates/partials/reset-form.html.twig | 25 +
.../plugins/login/templates/profile.html.twig | 9 +
.../plugins/login/templates/profile.json.twig | 1 +
.../login/templates/register.html.twig | 1 +
user/plugins/login/templates/reset.html.twig | 8 +
.../login/templates/unauthorized.html.twig | 1 +
user/plugins/login/vendor/autoload.php | 7 +
.../vendor/bacon/bacon-qr-code/CHANGELOG.md | 37 +
.../login/vendor/bacon/bacon-qr-code/LICENSE | 22 +
.../vendor/bacon/bacon-qr-code/Module.php | 37 +
.../vendor/bacon/bacon-qr-code/README.md | 24 +
.../bacon/bacon-qr-code/autoload_classmap.php | 43 +
.../bacon/bacon-qr-code/autoload_function.php | 12 +
.../bacon/bacon-qr-code/autoload_register.php | 2 +
.../vendor/bacon/bacon-qr-code/composer.json | 29 +
.../src/BaconQrCode/Common/AbstractEnum.php | 115 +
.../src/BaconQrCode/Common/BitArray.php | 435 +
.../src/BaconQrCode/Common/BitMatrix.php | 350 +
.../src/BaconQrCode/Common/BitUtils.php | 51 +
.../BaconQrCode/Common/CharacterSetEci.php | 134 +
.../src/BaconQrCode/Common/EcBlock.php | 65 +
.../src/BaconQrCode/Common/EcBlocks.php | 101 +
.../Common/ErrorCorrectionLevel.php | 62 +
.../BaconQrCode/Common/FormatInformation.php | 236 +
.../src/BaconQrCode/Common/Mode.php | 70 +
.../BaconQrCode/Common/ReedSolomonCodec.php | 476 +
.../src/BaconQrCode/Common/Version.php | 687 +
.../src/BaconQrCode/Encoder/BlockPair.php | 64 +
.../src/BaconQrCode/Encoder/ByteMatrix.php | 158 +
.../src/BaconQrCode/Encoder/Encoder.php | 687 +
.../src/BaconQrCode/Encoder/MaskUtil.php | 291 +
.../src/BaconQrCode/Encoder/MatrixUtil.php | 580 +
.../src/BaconQrCode/Encoder/QrCode.php | 201 +
.../Exception/ExceptionInterface.php | 14 +
.../Exception/InvalidArgumentException.php | 14 +
.../Exception/OutOfBoundsException.php | 14 +
.../Exception/RuntimeException.php | 14 +
.../Exception/UnexpectedValueException.php | 14 +
.../BaconQrCode/Exception/WriterException.php | 14 +
.../src/BaconQrCode/Renderer/Color/Cmyk.php | 160 +
.../Renderer/Color/ColorInterface.php | 37 +
.../src/BaconQrCode/Renderer/Color/Gray.php | 84 +
.../src/BaconQrCode/Renderer/Color/Rgb.php | 148 +
.../Renderer/Image/AbstractRenderer.php | 338 +
.../Image/Decorator/DecoratorInterface.php | 63 +
.../Image/Decorator/FinderPattern.php | 210 +
.../src/BaconQrCode/Renderer/Image/Eps.php | 152 +
.../src/BaconQrCode/Renderer/Image/Png.php | 115 +
.../Renderer/Image/RendererInterface.php | 61 +
.../src/BaconQrCode/Renderer/Image/Svg.php | 146 +
.../Renderer/RendererInterface.php | 26 +
.../src/BaconQrCode/Renderer/Text/Html.php | 91 +
.../src/BaconQrCode/Renderer/Text/Plain.php | 150 +
.../bacon-qr-code/src/BaconQrCode/Writer.php | 105 +
.../bacon-qr-code/src/Common/BitArray.php | 372 +
.../bacon-qr-code/src/Common/BitMatrix.php | 313 +
.../bacon-qr-code/src/Common/BitUtils.php | 41 +
.../src/Common/CharacterSetEci.php | 180 +
.../bacon-qr-code/src/Common/EcBlock.php | 49 +
.../bacon-qr-code/src/Common/EcBlocks.php | 74 +
.../src/Common/ErrorCorrectionLevel.php | 63 +
.../src/Common/FormatInformation.php | 203 +
.../bacon/bacon-qr-code/src/Common/Mode.php | 76 +
.../src/Common/ReedSolomonCodec.php | 468 +
.../bacon-qr-code/src/Common/Version.php | 596 +
.../bacon-qr-code/src/Encoder/BlockPair.php | 58 +
.../bacon-qr-code/src/Encoder/ByteMatrix.php | 150 +
.../bacon-qr-code/src/Encoder/Encoder.php | 652 +
.../bacon-qr-code/src/Encoder/MaskUtil.php | 271 +
.../bacon-qr-code/src/Encoder/MatrixUtil.php | 513 +
.../bacon-qr-code/src/Encoder/QrCode.php | 141 +
.../src/Exception/ExceptionInterface.php | 10 +
.../Exception/InvalidArgumentException.php | 8 +
.../src/Exception/OutOfBoundsException.php | 8 +
.../src/Exception/RuntimeException.php | 8 +
.../Exception/UnexpectedValueException.php | 8 +
.../src/Exception/WriterException.php | 8 +
.../src/Renderer/Color/Alpha.php | 57 +
.../bacon-qr-code/src/Renderer/Color/Cmyk.php | 103 +
.../src/Renderer/Color/ColorInterface.php | 22 +
.../bacon-qr-code/src/Renderer/Color/Gray.php | 46 +
.../bacon-qr-code/src/Renderer/Color/Rgb.php | 88 +
.../src/Renderer/Eye/CompositeEye.php | 38 +
.../src/Renderer/Eye/EyeInterface.php | 26 +
.../src/Renderer/Eye/ModuleEye.php | 54 +
.../src/Renderer/Eye/SimpleCircleEye.php | 54 +
.../src/Renderer/Eye/SquareEye.php | 53 +
.../src/Renderer/Image/EpsImageBackEnd.php | 376 +
.../Renderer/Image/ImageBackEndInterface.php | 87 +
.../Renderer/Image/ImagickImageBackEnd.php | 339 +
.../src/Renderer/Image/SvgImageBackEnd.php | 369 +
.../Renderer/Image/TransformationMatrix.php | 67 +
.../src/Renderer/ImageRenderer.php | 152 +
.../src/Renderer/Module/DotsModule.php | 63 +
.../src/Renderer/Module/EdgeIterator/Edge.php | 100 +
.../Module/EdgeIterator/EdgeIterator.php | 169 +
.../src/Renderer/Module/ModuleInterface.php | 18 +
.../src/Renderer/Module/RoundnessModule.php | 129 +
.../src/Renderer/Module/SquareModule.php | 47 +
.../bacon-qr-code/src/Renderer/Path/Close.php | 29 +
.../bacon-qr-code/src/Renderer/Path/Curve.php | 92 +
.../src/Renderer/Path/EllipticArc.php | 278 +
.../bacon-qr-code/src/Renderer/Path/Line.php | 41 +
.../bacon-qr-code/src/Renderer/Path/Move.php | 41 +
.../src/Renderer/Path/OperationInterface.php | 12 +
.../bacon-qr-code/src/Renderer/Path/Path.php | 106 +
.../src/Renderer/PlainTextRenderer.php | 86 +
.../src/Renderer/RendererInterface.php | 11 +
.../src/Renderer/RendererStyle/EyeFill.php | 74 +
.../src/Renderer/RendererStyle/Fill.php | 168 +
.../src/Renderer/RendererStyle/Gradient.php | 46 +
.../Renderer/RendererStyle/GradientType.php | 22 +
.../Renderer/RendererStyle/RendererStyle.php | 90 +
.../vendor/bacon/bacon-qr-code/src/Writer.php | 68 +
.../tests/BaconQrCode/Common/BitArrayTest.php | 201 +
.../BaconQrCode/Common/BitMatrixTest.php | 119 +
.../tests/BaconQrCode/Common/BitUtilsTest.php | 30 +
.../Common/ErrorCorrectionLevelTest.php | 40 +
.../Common/FormatInformationTest.php | 104 +
.../tests/BaconQrCode/Common/ModeTest.php | 42 +
.../Common/ReedSolomonCodecTest.php | 111 +
.../tests/BaconQrCode/Common/VersionTest.php | 88 +
.../tests/BaconQrCode/Encoder/EncoderTest.php | 468 +
.../BaconQrCode/Encoder/MaskUtilTest.php | 281 +
.../BaconQrCode/Encoder/MatrixUtilTest.php | 336 +
.../BaconQrCode/Renderer/Text/HtmlTest.php | 99 +
.../BaconQrCode/Renderer/Text/TextTest.php | 149 +
.../bacon/bacon-qr-code/tests/bootstrap.php | 10 +
.../bacon/bacon-qr-code/tests/phpunit.xml | 11 +
.../login/vendor/birke/rememberme/LICENSE | 21 +
.../login/vendor/birke/rememberme/README.md | 40 +
.../vendor/birke/rememberme/composer.json | 24 +
.../birke/rememberme/example/action.php | 119 +
.../birke/rememberme/example/css/style.css | 157 +
.../vendor/birke/rememberme/example/index.php | 42 +
.../example/templates/cookie_was_stolen.php | 4 +
.../rememberme/example/templates/login.php | 14 +
.../example/templates/user_is_logged_in.php | 31 +
.../birke/rememberme/example/tokens/.gitkeep | 0
.../login/vendor/birke/rememberme/phpunit.xml | 7 +
.../src/Rememberme/Authenticator.php | 293 +
.../rememberme/src/Rememberme/Cookie.php | 104 +
.../rememberme/src/Rememberme/Storage/DB.php | 145 +
.../src/Rememberme/Storage/File.php | 119 +
.../rememberme/src/Rememberme/Storage/PDO.php | 121 +
.../Rememberme/Storage/StorageInterface.php | 66 +
.../birke/rememberme/test/CookieTest.php | 31 +
.../birke/rememberme/test/RemembermeTest.php | 352 +
.../birke/rememberme/test/Storage/PDO.php | 98 +
.../birke/rememberme/test/Storage/tokens.xml | 8 +
.../birke/rememberme/test/bootstrap.php | 3 +
.../login/vendor/composer/ClassLoader.php | 445 +
user/plugins/login/vendor/composer/LICENSE | 21 +
.../vendor/composer/autoload_classmap.php | 10 +
.../login/vendor/composer/autoload_files.php | 10 +
.../vendor/composer/autoload_namespaces.php | 10 +
.../login/vendor/composer/autoload_psr4.php | 13 +
.../login/vendor/composer/autoload_real.php | 70 +
.../login/vendor/composer/autoload_static.php | 72 +
.../login/vendor/composer/installed.json | 200 +
.../login/vendor/dasprid/enum/.coveralls.yml | 2 +
.../login/vendor/dasprid/enum/README.md | 164 +
.../login/vendor/dasprid/enum/composer.json | 30 +
.../login/vendor/dasprid/enum/phpcs.xml | 30 +
.../vendor/dasprid/enum/phpunit.xml.dist | 17 +
.../vendor/dasprid/enum/src/AbstractEnum.php | 241 +
.../login/vendor/dasprid/enum/src/EnumMap.php | 375 +
.../Exception/CloneNotSupportedException.php | 10 +
.../enum/src/Exception/ExceptionInterface.php | 10 +
.../src/Exception/ExpectationException.php | 10 +
.../Exception/IllegalArgumentException.php | 10 +
.../enum/src/Exception/MismatchException.php | 10 +
.../SerializeNotSupportedException.php | 10 +
.../UnserializeNotSupportedException.php | 10 +
.../vendor/dasprid/enum/src/NullValue.php | 55 +
.../dasprid/enum/test/AbstractEnumTest.php | 121 +
.../vendor/dasprid/enum/test/EnumMapTest.php | 243 +
.../dasprid/enum/test/NullValueTest.php | 31 +
.../login/vendor/dasprid/enum/test/Planet.php | 73 +
.../vendor/dasprid/enum/test/WeekDay.php | 26 +
.../paragonie/random_compat/CHANGELOG.md | 290 +
.../vendor/paragonie/random_compat/LICENSE | 22 +
.../paragonie/random_compat/RATIONALE.md | 42 +
.../vendor/paragonie/random_compat/README.md | 176 +
.../paragonie/random_compat/SECURITY.md | 108 +
.../paragonie/random_compat/build-phar.sh | 5 +
.../paragonie/random_compat/composer.json | 35 +
.../dist/random_compat.phar.pubkey | 5 +
.../dist/random_compat.phar.pubkey.asc | 11 +
.../random_compat/lib/byte_safe_strings.php | 181 +
.../random_compat/lib/cast_to_int.php | 74 +
.../random_compat/lib/error_polyfill.php | 49 +
.../paragonie/random_compat/lib/random.php | 247 +
.../lib/random_bytes_com_dotnet.php | 88 +
.../lib/random_bytes_dev_urandom.php | 150 +
.../lib/random_bytes_libsodium.php | 88 +
.../lib/random_bytes_libsodium_legacy.php | 92 +
.../random_compat/lib/random_bytes_mcrypt.php | 77 +
.../lib/random_bytes_openssl.php | 86 +
.../random_compat/lib/random_int.php | 190 +
.../random_compat/other/build_phar.php | 57 +
.../random_compat/other/ide_stubs/COM.php | 20 +
.../random_compat/other/ide_stubs/README.md | 7 +
.../other/ide_stubs/com_exception.php | 11 +
.../other/ide_stubs/libsodium.php | 90 +
.../random_compat/psalm-autoload.php | 9 +
.../vendor/paragonie/random_compat/psalm.xml | 15 +
.../vendor/robthree/twofactorauth/LICENSE | 22 +
.../vendor/robthree/twofactorauth/README.md | 199 +
.../twofactorauth/TwoFactorAuth.phpproj | 70 +
.../robthree/twofactorauth/TwoFactorAuth.sln | 22 +
.../robthree/twofactorauth/composer.json | 36 +
.../robthree/twofactorauth/composer.lock | 980 ++
.../robthree/twofactorauth/demo/demo.php | 35 +
.../robthree/twofactorauth/demo/loader.php | 50 +
.../Providers/Qr/BaseHTTPQRCodeProvider.php | 27 +
.../lib/Providers/Qr/IQRCodeProvider.php | 9 +
.../Qr/ImageChartsQRCodeProvider.php | 39 +
.../lib/Providers/Qr/QRException.php | 5 +
.../lib/Providers/Qr/QRServerProvider.php | 71 +
.../lib/Providers/Qr/QRicketProvider.php | 54 +
.../lib/Providers/Rng/CSRNGProvider.php | 14 +
.../lib/Providers/Rng/HashRNGProvider.php | 28 +
.../lib/Providers/Rng/IRNGProvider.php | 9 +
.../lib/Providers/Rng/MCryptRNGProvider.php | 23 +
.../lib/Providers/Rng/OpenSSLRNGProvider.php | 25 +
.../lib/Providers/Rng/RNGException.php | 5 +
.../lib/Providers/Time/HttpTimeProvider.php | 54 +
.../lib/Providers/Time/ITimeProvider.php | 8 +
.../Time/LocalMachineTimeProvider.php | 9 +
.../lib/Providers/Time/NTPTimeProvider.php | 54 +
.../lib/Providers/Time/TimeException.php | 5 +
.../twofactorauth/lib/TwoFactorAuth.php | 256 +
.../lib/TwoFactorAuthException.php | 7 +
.../vendor/robthree/twofactorauth/logo.png | Bin 0 -> 2636 bytes
.../multifactorauthforeveryone.png | Bin 0 -> 20735 bytes
.../vendor/robthree/twofactorauth/phpunit.xml | 20 +
.../twofactorauth/phpunit.xml.tmppica | 0
.../twofactorauth/tests/TwoFactorAuthTest.php | 409 +
user/plugins/markdown-notices/CHANGELOG.md | 30 +
user/plugins/markdown-notices/LICENSE | 21 +
user/plugins/markdown-notices/README.md | 62 +
.../markdown-notices/assets/notices.css | 32 +
.../markdown-notices/assets/screenshot.png | Bin 0 -> 86632 bytes
user/plugins/markdown-notices/blueprints.yaml | 55 +
user/plugins/markdown-notices/languages.yaml | 29 +
.../markdown-notices/markdown-notices.php | 84 +
.../markdown-notices/markdown-notices.yaml | 4 +
user/plugins/problems/CHANGELOG.md | 143 +
user/plugins/problems/LICENSE | 21 +
user/plugins/problems/README.md | 92 +
user/plugins/problems/assets/cli.png | Bin 0 -> 401907 bytes
user/plugins/problems/assets/code-3.svg | 11 +
user/plugins/problems/assets/grav-logo.svg | 1 +
user/plugins/problems/assets/heart.svg | 5 +
user/plugins/problems/assets/readme_1.jpg | Bin 0 -> 368222 bytes
user/plugins/problems/blueprints.yaml | 38 +
.../problems/classes/Problems/Apache.php | 54 +
.../classes/Problems/Base/Problem.php | 87 +
.../classes/Problems/Base/ProblemChecker.php | 130 +
.../classes/Problems/EssentialFolders.php | 66 +
.../problems/classes/Problems/PHPModules.php | 133 +
.../problems/classes/Problems/PHPVersion.php | 36 +
.../problems/classes/Problems/Permissions.php | 35 +
user/plugins/problems/cli/CheckCommand.php | 102 +
user/plugins/problems/composer.json | 32 +
user/plugins/problems/css/admin.css | 51 +
user/plugins/problems/css/admin.min.css | 1 +
user/plugins/problems/css/spectre-icons.css | 168 +
.../problems/css/spectre-icons.min.css | 1 +
user/plugins/problems/css/spectre.css | 1278 ++
user/plugins/problems/css/spectre.min.css | 1 +
user/plugins/problems/gulpfile.js | 39 +
user/plugins/problems/languages.yaml | 14 +
user/plugins/problems/package.json | 45 +
user/plugins/problems/problems.php | 142 +
user/plugins/problems/problems.yaml | 2 +
user/plugins/problems/scss/_accordions.scss | 38 +
user/plugins/problems/scss/_animations.scss | 20 +
user/plugins/problems/scss/_asian.scss | 38 +
user/plugins/problems/scss/_autocomplete.scss | 47 +
user/plugins/problems/scss/_avatars.scss | 77 +
user/plugins/problems/scss/_badges.scss | 60 +
user/plugins/problems/scss/_bars.scss | 71 +
user/plugins/problems/scss/_base.scss | 44 +
user/plugins/problems/scss/_breadcrumbs.scss | 29 +
user/plugins/problems/scss/_buttons.scss | 195 +
user/plugins/problems/scss/_calendars.scss | 222 +
user/plugins/problems/scss/_cards.scss | 43 +
user/plugins/problems/scss/_carousels.scss | 126 +
user/plugins/problems/scss/_chips.scss | 30 +
user/plugins/problems/scss/_codes.scss | 31 +
.../problems/scss/_comparison-sliders.scss | 115 +
user/plugins/problems/scss/_dropdowns.scss | 36 +
user/plugins/problems/scss/_empty.scss | 21 +
user/plugins/problems/scss/_filters.scss | 37 +
user/plugins/problems/scss/_forms.scss | 545 +
user/plugins/problems/scss/_icons.scss | 5 +
user/plugins/problems/scss/_labels.scss | 34 +
user/plugins/problems/scss/_layout.scss | 424 +
user/plugins/problems/scss/_media.scss | 75 +
user/plugins/problems/scss/_menus.scss | 62 +
user/plugins/problems/scss/_meters.scss | 57 +
user/plugins/problems/scss/_mixins.scss | 11 +
user/plugins/problems/scss/_modals.scss | 87 +
user/plugins/problems/scss/_navbar.scss | 29 +
user/plugins/problems/scss/_navs.scss | 34 +
user/plugins/problems/scss/_normalize.scss | 446 +
user/plugins/problems/scss/_off-canvas.scss | 95 +
user/plugins/problems/scss/_pagination.scss | 61 +
user/plugins/problems/scss/_panels.scss | 23 +
user/plugins/problems/scss/_parallax.scss | 135 +
user/plugins/problems/scss/_popovers.scss | 65 +
user/plugins/problems/scss/_problems.scss | 72 +
user/plugins/problems/scss/_progress.scss | 45 +
user/plugins/problems/scss/_sliders.scss | 99 +
user/plugins/problems/scss/_steps.scss | 70 +
user/plugins/problems/scss/_tables.scss | 57 +
user/plugins/problems/scss/_tabs.scss | 66 +
user/plugins/problems/scss/_tiles.scss | 38 +
user/plugins/problems/scss/_timelines.scss | 54 +
user/plugins/problems/scss/_toasts.scss | 42 +
user/plugins/problems/scss/_tooltips.scss | 79 +
user/plugins/problems/scss/_typography.scss | 128 +
user/plugins/problems/scss/_utilities.scss | 8 +
user/plugins/problems/scss/_variables.scss | 116 +
user/plugins/problems/scss/admin.scss | 151 +
.../problems/scss/icons/_icons-action.scss | 316 +
.../problems/scss/icons/_icons-core.scss | 53 +
.../scss/icons/_icons-navigation.scss | 133 +
.../problems/scss/icons/_icons-object.scss | 176 +
.../plugins/problems/scss/mixins/_avatar.scss | 6 +
.../plugins/problems/scss/mixins/_button.scss | 54 +
.../problems/scss/mixins/_clearfix.scss | 8 +
user/plugins/problems/scss/mixins/_color.scss | 27 +
user/plugins/problems/scss/mixins/_label.scss | 11 +
.../problems/scss/mixins/_position.scss | 65 +
.../plugins/problems/scss/mixins/_shadow.scss | 9 +
user/plugins/problems/scss/mixins/_text.scss | 6 +
user/plugins/problems/scss/mixins/_toast.scss | 5 +
.../problems/scss/mixins/_transition.scss | 4 +
user/plugins/problems/scss/spectre-icons.scss | 10 +
user/plugins/problems/scss/spectre.scss | 51 +
.../problems/scss/utilities/_colors.scss | 31 +
.../problems/scss/utilities/_cursors.scss | 24 +
.../problems/scss/utilities/_display.scss | 44 +
.../problems/scss/utilities/_divider.scss | 50 +
.../problems/scss/utilities/_loading.scss | 34 +
.../problems/scss/utilities/_position.scss | 50 +
.../problems/scss/utilities/_shapes.scss | 8 +
.../problems/scss/utilities/_text.scss | 64 +
.../problems/templates/problems.html.twig | 34 +
.../reports/problems-report.html.twig | 33 +
user/plugins/problems/vendor/autoload.php | 7 +
.../problems/vendor/composer/ClassLoader.php | 445 +
user/plugins/problems/vendor/composer/LICENSE | 21 +
.../vendor/composer/autoload_classmap.php | 10 +
.../vendor/composer/autoload_namespaces.php | 9 +
.../vendor/composer/autoload_psr4.php | 11 +
.../vendor/composer/autoload_real.php | 52 +
.../vendor/composer/autoload_static.php | 41 +
.../problems/vendor/composer/installed.json | 1 +
user/themes/.gitkeep | 0
user/themes/quark/CHANGELOG.md | 177 +
user/themes/quark/LICENSE | 21 +
user/themes/quark/README.md | 152 +
.../themes/quark/assets/quark-screenshots.jpg | Bin 0 -> 198055 bytes
user/themes/quark/blueprints.yaml | 176 +
user/themes/quark/blueprints/blog.yaml | 94 +
user/themes/quark/blueprints/default.yaml | 15 +
user/themes/quark/blueprints/item.yaml | 113 +
.../quark/blueprints/modular/features.yaml | 38 +
.../themes/quark/blueprints/modular/hero.yaml | 23 +
.../themes/quark/blueprints/modular/text.yaml | 19 +
.../quark/blueprints/partials/blog-bits.yaml | 64 +
.../themes/quark/css-compiled/spectre-exp.css | 369 +
.../quark/css-compiled/spectre-exp.min.css | 1 +
.../quark/css-compiled/spectre-icons.css | 172 +
.../quark/css-compiled/spectre-icons.min.css | 1 +
user/themes/quark/css-compiled/spectre.css | 1257 ++
.../themes/quark/css-compiled/spectre.min.css | 1 +
user/themes/quark/css-compiled/theme.css | 406 +
user/themes/quark/css-compiled/theme.min.css | 1 +
user/themes/quark/css/bricklayer.css | 49 +
user/themes/quark/css/custom.css | 0
user/themes/quark/css/line-awesome.min.css | 4 +
user/themes/quark/fonts/line-awesome.eot | Bin 0 -> 213245 bytes
user/themes/quark/fonts/line-awesome.svg | 2954 ++++
user/themes/quark/fonts/line-awesome.ttf | Bin 0 -> 263504 bytes
user/themes/quark/fonts/line-awesome.woff | Bin 0 -> 117372 bytes
user/themes/quark/fonts/line-awesome.woff2 | Bin 0 -> 76372 bytes
user/themes/quark/gulpfile.js | 43 +
user/themes/quark/images/favicon.png | Bin 0 -> 13203 bytes
user/themes/quark/images/grav-logo.svg | 1 +
user/themes/quark/images/logo/.gitkeep | 0
user/themes/quark/js/bricklayer.min.js | 1 +
user/themes/quark/js/jquery.treemenu.js | 87 +
.../quark/js/scopedQuerySelectorShim.min.js | 9 +
user/themes/quark/js/singlepagenav.min.js | 8 +
user/themes/quark/js/site.js | 59 +
user/themes/quark/js/smooth-scroll.min.js | 6 +
user/themes/quark/languages.yaml | 288 +
user/themes/quark/package.json | 49 +
user/themes/quark/quark.php | 56 +
user/themes/quark/quark.yaml | 12 +
user/themes/quark/screenshot.jpg | Bin 0 -> 159731 bytes
user/themes/quark/scss/spectre-exp.scss | 19 +
user/themes/quark/scss/spectre-icons.scss | 11 +
user/themes/quark/scss/spectre.scss | 53 +
.../quark/scss/spectre/_accordions.scss | 38 +
.../quark/scss/spectre/_animations.scss | 20 +
user/themes/quark/scss/spectre/_asian.scss | 43 +
.../quark/scss/spectre/_autocomplete.scss | 47 +
user/themes/quark/scss/spectre/_avatars.scss | 77 +
user/themes/quark/scss/spectre/_badges.scss | 60 +
user/themes/quark/scss/spectre/_bars.scss | 71 +
user/themes/quark/scss/spectre/_base.scss | 44 +
.../quark/scss/spectre/_breadcrumbs.scss | 29 +
user/themes/quark/scss/spectre/_buttons.scss | 193 +
.../themes/quark/scss/spectre/_calendars.scss | 222 +
user/themes/quark/scss/spectre/_cards.scss | 43 +
.../themes/quark/scss/spectre/_carousels.scss | 136 +
user/themes/quark/scss/spectre/_chips.scss | 33 +
user/themes/quark/scss/spectre/_codes.scss | 31 +
.../scss/spectre/_comparison-sliders.scss | 115 +
.../themes/quark/scss/spectre/_dropdowns.scss | 36 +
user/themes/quark/scss/spectre/_empty.scss | 21 +
user/themes/quark/scss/spectre/_filters.scss | 37 +
user/themes/quark/scss/spectre/_forms.scss | 555 +
user/themes/quark/scss/spectre/_hero.scss | 22 +
user/themes/quark/scss/spectre/_icons.scss | 5 +
user/themes/quark/scss/spectre/_labels.scss | 34 +
user/themes/quark/scss/spectre/_layout.scss | 444 +
user/themes/quark/scss/spectre/_media.scss | 75 +
user/themes/quark/scss/spectre/_menus.scss | 66 +
user/themes/quark/scss/spectre/_meters.scss | 57 +
user/themes/quark/scss/spectre/_mixins.scss | 10 +
user/themes/quark/scss/spectre/_modals.scss | 87 +
user/themes/quark/scss/spectre/_navbar.scss | 28 +
user/themes/quark/scss/spectre/_navs.scss | 34 +
.../themes/quark/scss/spectre/_normalize.scss | 446 +
.../quark/scss/spectre/_off-canvas.scss | 95 +
.../quark/scss/spectre/_pagination.scss | 60 +
user/themes/quark/scss/spectre/_panels.scss | 23 +
user/themes/quark/scss/spectre/_parallax.scss | 135 +
user/themes/quark/scss/spectre/_popovers.scss | 65 +
user/themes/quark/scss/spectre/_progress.scss | 45 +
user/themes/quark/scss/spectre/_sliders.scss | 99 +
user/themes/quark/scss/spectre/_steps.scss | 71 +
user/themes/quark/scss/spectre/_tables.scss | 57 +
user/themes/quark/scss/spectre/_tabs.scss | 66 +
user/themes/quark/scss/spectre/_tiles.scss | 38 +
.../themes/quark/scss/spectre/_timelines.scss | 56 +
user/themes/quark/scss/spectre/_toasts.scss | 48 +
user/themes/quark/scss/spectre/_tooltips.scss | 79 +
.../quark/scss/spectre/_typography.scss | 129 +
.../themes/quark/scss/spectre/_utilities.scss | 8 +
.../themes/quark/scss/spectre/_variables.scss | 117 +
.../quark/scss/spectre/_viewer-360.scss | 34 +
.../scss/spectre/icons/_icons-action.scss | 315 +
.../quark/scss/spectre/icons/_icons-core.scss | 54 +
.../scss/spectre/icons/_icons-navigation.scss | 127 +
.../scss/spectre/icons/_icons-object.scss | 161 +
.../quark/scss/spectre/mixins/_avatar.scss | 6 +
.../quark/scss/spectre/mixins/_button.scss | 54 +
.../quark/scss/spectre/mixins/_clearfix.scss | 8 +
.../quark/scss/spectre/mixins/_color.scss | 27 +
.../quark/scss/spectre/mixins/_label.scss | 11 +
.../quark/scss/spectre/mixins/_position.scss | 65 +
.../quark/scss/spectre/mixins/_shadow.scss | 9 +
.../quark/scss/spectre/mixins/_text.scss | 6 +
.../quark/scss/spectre/mixins/_toast.scss | 5 +
.../quark/scss/spectre/spectre-exp.scss | 18 +
.../quark/scss/spectre/spectre-icons.scss | 10 +
user/themes/quark/scss/spectre/spectre.scss | 49 +
.../quark/scss/spectre/utilities/_colors.scss | 31 +
.../scss/spectre/utilities/_cursors.scss | 24 +
.../scss/spectre/utilities/_display.scss | 44 +
.../scss/spectre/utilities/_divider.scss | 50 +
.../scss/spectre/utilities/_loading.scss | 34 +
.../scss/spectre/utilities/_position.scss | 54 +
.../quark/scss/spectre/utilities/_shapes.scss | 8 +
.../quark/scss/spectre/utilities/_text.scss | 64 +
user/themes/quark/scss/theme.scss | 21 +
user/themes/quark/scss/theme/_animation.scss | 23 +
user/themes/quark/scss/theme/_blog.scss | 114 +
user/themes/quark/scss/theme/_extensions.scss | 7 +
user/themes/quark/scss/theme/_fonts.scss | 1 +
user/themes/quark/scss/theme/_footer.scss | 17 +
user/themes/quark/scss/theme/_forms.scss | 77 +
user/themes/quark/scss/theme/_framework.scss | 156 +
user/themes/quark/scss/theme/_header.scss | 101 +
user/themes/quark/scss/theme/_menu.scss | 94 +
user/themes/quark/scss/theme/_mixins.scss | 77 +
user/themes/quark/scss/theme/_mobile.scss | 193 +
user/themes/quark/scss/theme/_onepage.scss | 122 +
user/themes/quark/scss/theme/_typography.scss | 178 +
user/themes/quark/scss/theme/_variables.scss | 38 +
.../quark/templates/blocks/base.html.twig | 3 +
user/themes/quark/templates/blog.html.twig | 63 +
user/themes/quark/templates/default.html.twig | 5 +
user/themes/quark/templates/error.html.twig | 12 +
.../forms/fields/checkbox/checkbox.html.twig | 32 +
.../fields/checkboxes/checkboxes.html.twig | 44 +
.../forms/fields/radio/radio.html.twig | 26 +
.../forms/fields/switch/switch.html.twig | 3 +
user/themes/quark/templates/item.html.twig | 41 +
.../quark/templates/macros/macros.html.twig | 16 +
user/themes/quark/templates/modular.html.twig | 60 +
.../templates/modular/features.html.twig | 30 +
.../quark/templates/modular/hero.html.twig | 4 +
.../quark/templates/modular/text.html.twig | 21 +
.../templates/partials/archives.html.twig | 13 +
.../quark/templates/partials/base.html.twig | 113 +
.../templates/partials/blog-item.html.twig | 30 +
.../partials/blog-list-item.html.twig | 27 +
.../templates/partials/blog/date.html.twig | 5 +
.../partials/blog/page-summary.html.twig | 8 +
.../partials/blog/taxonomy.html.twig | 7 +
.../templates/partials/blog/title.html.twig | 11 +
.../quark/templates/partials/footer.html.twig | 5 +
.../partials/form-messages.html.twig | 6 +
.../quark/templates/partials/hero.html.twig | 7 +
.../quark/templates/partials/layout.html.twig | 14 +
.../quark/templates/partials/logo.html.twig | 9 +
.../templates/partials/messages.html.twig | 17 +
.../templates/partials/navigation.html.twig | 6 +
.../templates/partials/relatedpages.html.twig | 15 +
.../templates/partials/sidebar.html.twig | 43 +
.../templates/partials/taxonomylist.html.twig | 10 +
user/themes/quark/thumbnail.jpg | Bin 0 -> 49487 bytes
.../antoligy/dom-string-iterators/README.md | 5 +
.../src/DOMLettersIterator.php | 114 +
.../src/DOMWordsIterator.php | 117 +
vendor/autoload.php | 7 +
vendor/bin/var-dump-server | 63 +
vendor/composer/ClassLoader.php | 445 +
vendor/composer/LICENSE | 21 +
vendor/composer/autoload_classmap.php | 1467 ++
vendor/composer/autoload_files.php | 20 +
vendor/composer/autoload_namespaces.php | 14 +
vendor/composer/autoload_psr4.php | 56 +
vendor/composer/autoload_real.php | 74 +
vendor/composer/autoload_static.php | 1808 ++
vendor/composer/ca-bundle/LICENSE | 19 +
vendor/composer/ca-bundle/README.md | 85 +
vendor/composer/ca-bundle/composer.json | 54 +
vendor/composer/ca-bundle/res/cacert.pem | 3447 ++++
vendor/composer/ca-bundle/src/CaBundle.php | 325 +
vendor/composer/installed.json | 2647 +++
vendor/doctrine/cache/LICENSE | 19 +
vendor/doctrine/cache/README.md | 9 +
vendor/doctrine/cache/UPGRADE.md | 16 +
.../lib/Doctrine/Common/Cache/ApcCache.php | 105 +
.../lib/Doctrine/Common/Cache/ApcuCache.php | 106 +
.../lib/Doctrine/Common/Cache/ArrayCache.php | 113 +
.../cache/lib/Doctrine/Common/Cache/Cache.php | 90 +
.../Doctrine/Common/Cache/CacheProvider.php | 325 +
.../lib/Doctrine/Common/Cache/ChainCache.php | 195 +
.../Doctrine/Common/Cache/ClearableCache.php | 21 +
.../Common/Cache/CouchbaseBucketCache.php | 197 +
.../Doctrine/Common/Cache/CouchbaseCache.php | 105 +
.../Doctrine/Common/Cache/ExtMongoDBCache.php | 198 +
.../lib/Doctrine/Common/Cache/FileCache.php | 281 +
.../Doctrine/Common/Cache/FilesystemCache.php | 102 +
.../Doctrine/Common/Cache/FlushableCache.php | 18 +
.../Doctrine/Common/Cache/InvalidCacheId.php | 25 +
.../Common/Cache/LegacyMongoDBCache.php | 175 +
.../Doctrine/Common/Cache/MemcacheCache.php | 104 +
.../Doctrine/Common/Cache/MemcachedCache.php | 170 +
.../Doctrine/Common/Cache/MongoDBCache.php | 112 +
.../Common/Cache/MultiDeleteCache.php | 22 +
.../Doctrine/Common/Cache/MultiGetCache.php | 23 +
.../Common/Cache/MultiOperationCache.php | 12 +
.../Doctrine/Common/Cache/MultiPutCache.php | 24 +
.../Doctrine/Common/Cache/PhpFileCache.php | 118 +
.../lib/Doctrine/Common/Cache/PredisCache.php | 143 +
.../lib/Doctrine/Common/Cache/RedisCache.php | 181 +
.../Doctrine/Common/Cache/SQLite3Cache.php | 206 +
.../lib/Doctrine/Common/Cache/Version.php | 8 +
.../lib/Doctrine/Common/Cache/VoidCache.php | 59 +
.../Doctrine/Common/Cache/WinCacheCache.php | 106 +
.../lib/Doctrine/Common/Cache/XcacheCache.php | 104 +
.../Doctrine/Common/Cache/ZendDataCache.php | 69 +
.../collections/.doctrine-project.json | 17 +
vendor/doctrine/collections/CONTRIBUTING.md | 54 +
vendor/doctrine/collections/LICENSE | 19 +
vendor/doctrine/collections/README.md | 92 +
.../docs/en/derived-collections.rst | 26 +
.../docs/en/expression-builder.rst | 173 +
.../collections/docs/en/expressions.rst | 102 +
vendor/doctrine/collections/docs/en/index.rst | 327 +
.../collections/docs/en/lazy-collections.rst | 26 +
.../doctrine/collections/docs/en/sidebar.rst | 8 +
.../Collections/AbstractLazyCollection.php | 369 +
.../Common/Collections/ArrayCollection.php | 441 +
.../Common/Collections/Collection.php | 297 +
.../Doctrine/Common/Collections/Criteria.php | 222 +
.../Expr/ClosureExpressionVisitor.php | 262 +
.../Common/Collections/Expr/Comparison.php | 80 +
.../Collections/Expr/CompositeExpression.php | 68 +
.../Common/Collections/Expr/Expression.php | 14 +
.../Collections/Expr/ExpressionVisitor.php | 55 +
.../Common/Collections/Expr/Value.php | 33 +
.../Common/Collections/ExpressionBuilder.php | 180 +
.../Common/Collections/Selectable.php | 32 +
vendor/doctrine/collections/psalm.xml.dist | 54 +
.../.github/workflows/ci.yml | 32 +
.../phpuseragentparser/.helpers/constants.php | 15 +
vendor/donatj/phpuseragentparser/.mddoc.xml | 108 +
.../donatj/phpuseragentparser/CONTRIBUTING.md | 18 +
vendor/donatj/phpuseragentparser/LICENSE.md | 22 +
vendor/donatj/phpuseragentparser/Makefile | 13 +
vendor/donatj/phpuseragentparser/README.md | 181 +
.../phpuseragentparser/bin/benchmark.php | 24 +
.../bin/constant_generator.php | 77 +
.../bin/init_user_agent.php | 13 +
.../bin/user_agent_sorter.php | 100 +
.../src/UserAgent/Browsers.php | 52 +
.../src/UserAgent/Platforms.php | 39 +
.../src/UserAgent/UserAgent.php | 57 +
.../src/UserAgent/UserAgentInterface.php | 25 +
.../src/UserAgent/UserAgentParser.php | 39 +
.../src/UserAgentParser.php | 210 +
.../tests/UserAgentParserFunctionTest.php | 50 +
.../tests/UserAgentParserObjectTest.php | 45 +
.../phpuseragentparser/tests/user_agents.json | 1047 ++
.../cron-expression/CHANGELOG.md | 36 +
vendor/dragonmantank/cron-expression/LICENSE | 19 +
.../dragonmantank/cron-expression/README.md | 71 +
.../src/Cron/AbstractField.php | 148 +
.../src/Cron/CronExpression.php | 389 +
.../src/Cron/DayOfMonthField.php | 173 +
.../src/Cron/DayOfWeekField.php | 141 +
.../cron-expression/src/Cron/FieldFactory.php | 57 +
.../src/Cron/FieldInterface.php | 40 +
.../cron-expression/src/Cron/HoursField.php | 71 +
.../cron-expression/src/Cron/MinutesField.php | 62 +
.../cron-expression/src/Cron/MonthField.php | 44 +
.../cron-expression/src/Cron/YearField.php | 37 +
vendor/filp/whoops/CHANGELOG.md | 57 +
vendor/filp/whoops/LICENSE.md | 19 +
.../src/Whoops/Exception/ErrorException.php | 17 +
.../whoops/src/Whoops/Exception/Formatter.php | 73 +
.../whoops/src/Whoops/Exception/Frame.php | 295 +
.../src/Whoops/Exception/FrameCollection.php | 203 +
.../whoops/src/Whoops/Exception/Inspector.php | 323 +
.../src/Whoops/Handler/CallbackHandler.php | 52 +
.../whoops/src/Whoops/Handler/Handler.php | 95 +
.../src/Whoops/Handler/HandlerInterface.php | 36 +
.../Whoops/Handler/JsonResponseHandler.php | 88 +
.../src/Whoops/Handler/PlainTextHandler.php | 354 +
.../src/Whoops/Handler/PrettyPageHandler.php | 815 +
.../src/Whoops/Handler/XmlResponseHandler.php | 107 +
.../src/Whoops/Resources/css/whoops.base.css | 604 +
.../src/Whoops/Resources/js/clipboard.min.js | 7 +
.../src/Whoops/Resources/js/prettify.min.js | 28 +
.../src/Whoops/Resources/js/whoops.base.js | 210 +
.../src/Whoops/Resources/js/zepto.min.js | 2 +
.../Resources/views/env_details.html.php | 42 +
.../Resources/views/frame_code.html.php | 63 +
.../Resources/views/frame_list.html.php | 17 +
.../Resources/views/frames_container.html.php | 3 +
.../views/frames_description.html.php | 14 +
.../Whoops/Resources/views/header.html.php | 96 +
.../Resources/views/header_outer.html.php | 3 +
.../Whoops/Resources/views/layout.html.php | 33 +
.../Resources/views/panel_details.html.php | 2 +
.../views/panel_details_outer.html.php | 3 +
.../Resources/views/panel_left.html.php | 4 +
.../Resources/views/panel_left_outer.html.php | 3 +
vendor/filp/whoops/src/Whoops/Run.php | 452 +
.../filp/whoops/src/Whoops/RunInterface.php | 131 +
.../src/Whoops/Util/HtmlDumperOutput.php | 36 +
vendor/filp/whoops/src/Whoops/Util/Misc.php | 77 +
.../whoops/src/Whoops/Util/SystemFacade.php | 137 +
.../whoops/src/Whoops/Util/TemplateHelper.php | 352 +
vendor/gregwar/cache/Gregwar/Cache/Cache.php | 365 +
.../cache/Gregwar/Cache/CacheInterface.php | 131 +
.../cache/Gregwar/Cache/GarbageCollect.php | 86 +
vendor/gregwar/cache/Gregwar/Cache/LICENSE | 19 +
vendor/gregwar/cache/Gregwar/Cache/README.md | 165 +
.../gregwar/cache/Gregwar/Cache/autoload.php | 16 +
.../image/Gregwar/Image/Adapter/Adapter.php | 58 +
.../Image/Adapter/AdapterInterface.php | 399 +
.../image/Gregwar/Image/Adapter/Common.php | 394 +
.../image/Gregwar/Image/Adapter/GD.php | 665 +
.../image/Gregwar/Image/Adapter/Imagick.php | 432 +
.../Image/Exceptions/GenerationError.php | 16 +
.../image/Gregwar/Image/GarbageCollect.php | 82 +
vendor/gregwar/image/Gregwar/Image/Image.php | 796 +
.../image/Gregwar/Image/ImageColor.php | 98 +
vendor/gregwar/image/Gregwar/Image/LICENSE | 19 +
vendor/gregwar/image/Gregwar/Image/README.md | 278 +
.../image/Gregwar/Image/Source/Create.php | 38 +
.../image/Gregwar/Image/Source/Data.php | 26 +
.../image/Gregwar/Image/Source/File.php | 67 +
.../image/Gregwar/Image/Source/Resource.php | 21 +
.../image/Gregwar/Image/Source/Source.php | 34 +
.../gregwar/image/Gregwar/Image/autoload.php | 21 +
.../image/Gregwar/Image/images/error.jpg | Bin 0 -> 1108 bytes
vendor/guzzlehttp/psr7/CHANGELOG.md | 270 +
vendor/guzzlehttp/psr7/LICENSE | 19 +
vendor/guzzlehttp/psr7/README.md | 809 +
vendor/guzzlehttp/psr7/src/AppendStream.php | 244 +
vendor/guzzlehttp/psr7/src/BufferStream.php | 140 +
vendor/guzzlehttp/psr7/src/CachingStream.php | 139 +
vendor/guzzlehttp/psr7/src/DroppingStream.php | 43 +
vendor/guzzlehttp/psr7/src/FnStream.php | 160 +
vendor/guzzlehttp/psr7/src/Header.php | 71 +
vendor/guzzlehttp/psr7/src/InflateStream.php | 53 +
vendor/guzzlehttp/psr7/src/LazyOpenStream.php | 40 +
vendor/guzzlehttp/psr7/src/LimitStream.php | 156 +
vendor/guzzlehttp/psr7/src/Message.php | 252 +
vendor/guzzlehttp/psr7/src/MessageTrait.php | 214 +
vendor/guzzlehttp/psr7/src/MimeType.php | 140 +
.../guzzlehttp/psr7/src/MultipartStream.php | 154 +
vendor/guzzlehttp/psr7/src/NoSeekStream.php | 23 +
vendor/guzzlehttp/psr7/src/PumpStream.php | 168 +
vendor/guzzlehttp/psr7/src/Query.php | 108 +
vendor/guzzlehttp/psr7/src/Request.php | 152 +
vendor/guzzlehttp/psr7/src/Response.php | 155 +
vendor/guzzlehttp/psr7/src/Rfc7230.php | 18 +
vendor/guzzlehttp/psr7/src/ServerRequest.php | 378 +
vendor/guzzlehttp/psr7/src/Stream.php | 270 +
.../psr7/src/StreamDecoratorTrait.php | 151 +
vendor/guzzlehttp/psr7/src/StreamWrapper.php | 163 +
vendor/guzzlehttp/psr7/src/UploadedFile.php | 325 +
vendor/guzzlehttp/psr7/src/Uri.php | 761 +
vendor/guzzlehttp/psr7/src/UriNormalizer.php | 217 +
vendor/guzzlehttp/psr7/src/UriResolver.php | 220 +
vendor/guzzlehttp/psr7/src/Utils.php | 398 +
vendor/guzzlehttp/psr7/src/functions.php | 417 +
.../guzzlehttp/psr7/src/functions_include.php | 6 +
vendor/kodus/psr7-server/CHANGELOG.md | 36 +
vendor/kodus/psr7-server/LICENSE | 21 +
vendor/kodus/psr7-server/README.md | 38 +
.../psr7-server/src/ServerRequestCreator.php | 279 +
.../src/ServerRequestCreatorInterface.php | 58 +
.../climate/.github/workflows/buildcheck.yml | 47 +
vendor/league/climate/CHANGELOG.md | 191 +
vendor/league/climate/CONTRIBUTING.md | 32 +
vendor/league/climate/Dockerfile | 13 +
vendor/league/climate/LICENSE.md | 21 +
vendor/league/climate/README.md | 44 +
vendor/league/climate/src/ASCII/404.txt | 6 +
vendor/league/climate/src/ASCII/bender.txt | 17 +
vendor/league/climate/src/ASCII/failed.txt | 6 +
.../league/climate/src/ASCII/fancy-bender.txt | 17 +
vendor/league/climate/src/ASCII/passed.txt | 6 +
vendor/league/climate/src/ASCII/php | 6 +
.../climate/src/ASCII/the-league-big.txt | 102 +
.../climate/src/ASCII/the-league-bigger.txt | 153 +
.../climate/src/ASCII/the-league-massive.txt | 255 +
.../league/climate/src/ASCII/the-league.txt | 51 +
.../league/climate/src/Argument/Argument.php | 416 +
vendor/league/climate/src/Argument/Filter.php | 183 +
.../league/climate/src/Argument/Manager.php | 251 +
vendor/league/climate/src/Argument/Parser.php | 296 +
.../league/climate/src/Argument/Summary.php | 215 +
vendor/league/climate/src/CLImate.php | 445 +
.../Decorator/Component/BackgroundColor.php | 72 +
.../src/Decorator/Component/BaseDecorator.php | 53 +
.../climate/src/Decorator/Component/Color.php | 100 +
.../src/Decorator/Component/Command.php | 77 +
.../Component/DecoratorInterface.php | 28 +
.../src/Decorator/Component/Format.php | 89 +
.../climate/src/Decorator/Parser/Ansi.php | 174 +
.../climate/src/Decorator/Parser/NonAnsi.php | 19 +
.../climate/src/Decorator/Parser/Parser.php | 38 +
.../src/Decorator/Parser/ParserFactory.php | 26 +
.../src/Decorator/Parser/ParserImporter.php | 23 +
vendor/league/climate/src/Decorator/Style.php | 295 +
vendor/league/climate/src/Decorator/Tags.php | 76 +
.../climate/src/Exceptions/Exception.php | 7 +
.../Exceptions/InvalidArgumentException.php | 7 +
.../src/Exceptions/RuntimeException.php | 7 +
.../Exceptions/UnexpectedValueException.php | 7 +
vendor/league/climate/src/Logger.php | 174 +
vendor/league/climate/src/Settings/Art.php | 22 +
.../league/climate/src/Settings/Manager.php | 84 +
.../climate/src/Settings/SettingsImporter.php | 32 +
.../src/Settings/SettingsInterface.php | 11 +
.../Basic/BasicTerminalObject.php | 45 +
.../Basic/BasicTerminalObjectInterface.php | 34 +
.../src/TerminalObject/Basic/Border.php | 67 +
.../climate/src/TerminalObject/Basic/Br.php | 16 +
.../src/TerminalObject/Basic/Clear.php | 21 +
.../src/TerminalObject/Basic/ClearLine.php | 36 +
.../src/TerminalObject/Basic/Columns.php | 207 +
.../climate/src/TerminalObject/Basic/Draw.php | 30 +
.../climate/src/TerminalObject/Basic/Dump.php | 36 +
.../src/TerminalObject/Basic/Flank.php | 74 +
.../src/TerminalObject/Basic/Inline.php | 16 +
.../climate/src/TerminalObject/Basic/Json.php | 28 +
.../climate/src/TerminalObject/Basic/Out.php | 28 +
.../src/TerminalObject/Basic/Repeatable.php | 18 +
.../climate/src/TerminalObject/Basic/Tab.php | 29 +
.../src/TerminalObject/Basic/Table.php | 265 +
.../src/TerminalObject/Dynamic/Animation.php | 213 +
.../Dynamic/Animation/Keyframe.php | 265 +
.../Dynamic/Checkbox/Checkbox.php | 219 +
.../Dynamic/Checkbox/CheckboxGroup.php | 191 +
.../Dynamic/Checkbox/RadioGroup.php | 38 +
.../src/TerminalObject/Dynamic/Checkboxes.php | 159 +
.../src/TerminalObject/Dynamic/Confirm.php | 44 +
.../Dynamic/DynamicTerminalObject.php | 18 +
.../DynamicTerminalObjectInterface.php | 27 +
.../src/TerminalObject/Dynamic/Input.php | 283 +
.../TerminalObject/Dynamic/InputAbstract.php | 37 +
.../src/TerminalObject/Dynamic/Padding.php | 141 +
.../src/TerminalObject/Dynamic/Password.php | 13 +
.../src/TerminalObject/Dynamic/Progress.php | 315 +
.../src/TerminalObject/Dynamic/Radio.php | 51 +
.../src/TerminalObject/Dynamic/Spinner.php | 159 +
.../climate/src/TerminalObject/Helper/Art.php | 160 +
.../src/TerminalObject/Helper/Sleeper.php | 37 +
.../Helper/SleeperInterface.php | 13 +
.../TerminalObject/Helper/StringLength.php | 112 +
.../src/TerminalObject/Router/BaseRouter.php | 89 +
.../src/TerminalObject/Router/BasicRouter.php | 42 +
.../TerminalObject/Router/DynamicRouter.php | 32 +
.../Router/ExtensionCollection.php | 147 +
.../src/TerminalObject/Router/Router.php | 157 +
.../TerminalObject/Router/RouterInterface.php | 29 +
vendor/league/climate/src/Util/Cursor.php | 94 +
vendor/league/climate/src/Util/Helper.php | 50 +
vendor/league/climate/src/Util/Output.php | 315 +
.../climate/src/Util/OutputImporter.php | 23 +
.../src/Util/Reader/ReaderInterface.php | 16 +
.../league/climate/src/Util/Reader/Stdin.php | 95 +
.../league/climate/src/Util/System/Linux.php | 104 +
.../league/climate/src/Util/System/System.php | 68 +
.../climate/src/Util/System/SystemFactory.php | 44 +
.../climate/src/Util/System/Windows.php | 78 +
.../league/climate/src/Util/UtilFactory.php | 66 +
.../league/climate/src/Util/UtilImporter.php | 23 +
.../league/climate/src/Util/Writer/Buffer.php | 44 +
.../league/climate/src/Util/Writer/File.php | 101 +
.../league/climate/src/Util/Writer/StdErr.php | 16 +
.../league/climate/src/Util/Writer/StdOut.php | 16 +
.../src/Util/Writer/WriterInterface.php | 13 +
vendor/matthiasmullie/minify/LICENSE | 18 +
.../minify/data/js/keywords_after.txt | 7 +
.../minify/data/js/keywords_before.txt | 26 +
.../minify/data/js/keywords_reserved.txt | 63 +
.../minify/data/js/operators.txt | 46 +
.../minify/data/js/operators_after.txt | 43 +
.../minify/data/js/operators_before.txt | 43 +
vendor/matthiasmullie/minify/src/CSS.php | 752 +
.../matthiasmullie/minify/src/Exception.php | 20 +
.../minify/src/Exceptions/BasicException.php | 23 +
.../src/Exceptions/FileImportException.php | 21 +
.../minify/src/Exceptions/IOException.php | 21 +
vendor/matthiasmullie/minify/src/JS.php | 612 +
vendor/matthiasmullie/minify/src/Minify.php | 497 +
vendor/matthiasmullie/path-converter/LICENSE | 18 +
.../path-converter/src/Converter.php | 204 +
.../path-converter/src/ConverterInterface.php | 24 +
.../path-converter/src/NoConverter.php | 23 +
vendor/maximebf/debugbar/LICENSE | 19 +
.../DebugBar/Bridge/CacheCacheCollector.php | 75 +
.../src/DebugBar/Bridge/DoctrineCollector.php | 115 +
.../src/DebugBar/Bridge/MonologCollector.php | 118 +
.../src/DebugBar/Bridge/Propel2Collector.php | 307 +
.../src/DebugBar/Bridge/PropelCollector.php | 253 +
.../src/DebugBar/Bridge/SlimCollector.php | 66 +
.../Bridge/SwiftMailer/SwiftLogCollector.php | 44 +
.../Bridge/SwiftMailer/SwiftMailCollector.php | 92 +
.../Twig/TimeableTwigExtensionProfiler.php | 60 +
.../Bridge/Twig/TraceableTwigEnvironment.php | 419 +
.../Bridge/Twig/TraceableTwigTemplate.php | 138 +
.../DebugBar/Bridge/Twig/TwigCollector.php | 89 +
.../DebugBar/Bridge/TwigProfileCollector.php | 197 +
.../DataCollector/AggregatedCollector.php | 189 +
.../DebugBar/DataCollector/AssetProvider.php | 43 +
.../DataCollector/ConfigCollector.php | 120 +
.../DebugBar/DataCollector/DataCollector.php | 234 +
.../DataCollector/DataCollectorInterface.php | 31 +
.../DataCollector/ExceptionsCollector.php | 143 +
.../DataCollector/LocalizationCollector.php | 73 +
.../DataCollector/MemoryCollector.php | 96 +
.../MessagesAggregateInterface.php | 21 +
.../DataCollector/MessagesCollector.php | 245 +
.../DataCollector/PDO/PDOCollector.php | 206 +
.../DataCollector/PDO/TraceablePDO.php | 311 +
.../PDO/TraceablePDOStatement.php | 130 +
.../DataCollector/PDO/TracedStatement.php | 271 +
.../DataCollector/PhpInfoCollector.php | 51 +
.../src/DebugBar/DataCollector/Renderable.php | 25 +
.../DataCollector/RequestDataCollector.php | 100 +
.../DataCollector/TimeDataCollector.php | 247 +
.../DebugBar/DataFormatter/DataFormatter.php | 83 +
.../DataFormatter/DataFormatterInterface.php | 42 +
.../DataFormatter/DebugBarVarDumper.php | 315 +
.../VarDumper/DebugBarHtmlDumper.php | 17 +
.../DataFormatter/VarDumper/SeekingData.php | 103 +
.../debugbar/src/DebugBar/DebugBar.php | 493 +
.../src/DebugBar/DebugBarException.php | 16 +
.../src/DebugBar/HttpDriverInterface.php | 64 +
.../src/DebugBar/JavascriptRenderer.php | 1152 ++
.../debugbar/src/DebugBar/OpenHandler.php | 117 +
.../debugbar/src/DebugBar/PhpHttpDriver.php | 70 +
.../src/DebugBar/RequestIdGenerator.php | 43 +
.../DebugBar/RequestIdGeneratorInterface.php | 25 +
.../src/DebugBar/Resources/debugbar.css | 314 +
.../src/DebugBar/Resources/debugbar.js | 1216 ++
.../src/DebugBar/Resources/openhandler.css | 70 +
.../src/DebugBar/Resources/openhandler.js | 202 +
.../src/DebugBar/Resources/widgets.css | 261 +
.../src/DebugBar/Resources/widgets.js | 583 +
.../Resources/widgets/mails/widget.css | 12 +
.../Resources/widgets/mails/widget.js | 40 +
.../Resources/widgets/sqlqueries/widget.css | 118 +
.../Resources/widgets/sqlqueries/widget.js | 171 +
.../Resources/widgets/templates/widget.css | 66 +
.../Resources/widgets/templates/widget.js | 90 +
.../src/DebugBar/StandardDebugBar.php | 34 +
.../src/DebugBar/Storage/FileStorage.php | 128 +
.../src/DebugBar/Storage/MemcachedStorage.php | 158 +
.../src/DebugBar/Storage/PdoStorage.php | 137 +
.../src/DebugBar/Storage/RedisStorage.php | 97 +
.../src/DebugBar/Storage/StorageInterface.php | 45 +
.../DebugBar/Storage/pdo_storage_schema.sql | 16 +
vendor/miljar/php-exif/CHANGELOG.rst | 27 +
vendor/miljar/php-exif/LICENSE | 18 +
vendor/miljar/php-exif/README.md | 50 +
.../lib/PHPExif/Adapter/AdapterAbstract.php | 132 +
.../lib/PHPExif/Adapter/AdapterInterface.php | 33 +
.../php-exif/lib/PHPExif/Adapter/Exiftool.php | 202 +
.../php-exif/lib/PHPExif/Adapter/Native.php | 235 +
.../PHPExif/Adapter/NoAdapterException.php | 28 +
vendor/miljar/php-exif/lib/PHPExif/Exif.php | 843 +
.../PHPExif/Hydrator/HydratorInterface.php | 33 +
.../php-exif/lib/PHPExif/Hydrator/Mutator.php | 56 +
.../php-exif/lib/PHPExif/Mapper/Exiftool.php | 210 +
.../lib/PHPExif/Mapper/MapperInterface.php | 33 +
.../php-exif/lib/PHPExif/Mapper/Native.php | 289 +
.../php-exif/lib/PHPExif/Reader/Reader.php | 111 +
.../lib/PHPExif/Reader/ReaderInterface.php | 33 +
vendor/monolog/monolog/CHANGELOG.md | 415 +
vendor/monolog/monolog/LICENSE | 19 +
vendor/monolog/monolog/README.md | 94 +
.../monolog/src/Monolog/ErrorHandler.php | 238 +
.../Monolog/Formatter/ChromePHPFormatter.php | 78 +
.../Monolog/Formatter/ElasticaFormatter.php | 89 +
.../Monolog/Formatter/FlowdockFormatter.php | 116 +
.../Monolog/Formatter/FluentdFormatter.php | 88 +
.../Monolog/Formatter/FormatterInterface.php | 36 +
.../Formatter/GelfMessageFormatter.php | 138 +
.../src/Monolog/Formatter/HtmlFormatter.php | 142 +
.../src/Monolog/Formatter/JsonFormatter.php | 212 +
.../src/Monolog/Formatter/LineFormatter.php | 181 +
.../src/Monolog/Formatter/LogglyFormatter.php | 47 +
.../Monolog/Formatter/LogstashFormatter.php | 166 +
.../Monolog/Formatter/MongoDBFormatter.php | 107 +
.../Monolog/Formatter/NormalizerFormatter.php | 180 +
.../src/Monolog/Formatter/ScalarFormatter.php | 48 +
.../Monolog/Formatter/WildfireFormatter.php | 113 +
.../src/Monolog/Handler/AbstractHandler.php | 196 +
.../Handler/AbstractProcessingHandler.php | 68 +
.../Monolog/Handler/AbstractSyslogHandler.php | 101 +
.../src/Monolog/Handler/AmqpHandler.php | 148 +
.../Monolog/Handler/BrowserConsoleHandler.php | 241 +
.../src/Monolog/Handler/BufferHandler.php | 148 +
.../src/Monolog/Handler/ChromePHPHandler.php | 212 +
.../src/Monolog/Handler/CouchDBHandler.php | 72 +
.../src/Monolog/Handler/CubeHandler.php | 152 +
.../monolog/src/Monolog/Handler/Curl/Util.php | 57 +
.../Monolog/Handler/DeduplicationHandler.php | 169 +
.../Handler/DoctrineCouchDBHandler.php | 45 +
.../src/Monolog/Handler/DynamoDbHandler.php | 107 +
.../Monolog/Handler/ElasticSearchHandler.php | 128 +
.../src/Monolog/Handler/ErrorLogHandler.php | 82 +
.../src/Monolog/Handler/FilterHandler.php | 172 +
.../ActivationStrategyInterface.php | 28 +
.../ChannelLevelActivationStrategy.php | 59 +
.../ErrorLevelActivationStrategy.php | 34 +
.../Monolog/Handler/FingersCrossedHandler.php | 207 +
.../src/Monolog/Handler/FirePHPHandler.php | 195 +
.../src/Monolog/Handler/FleepHookHandler.php | 126 +
.../src/Monolog/Handler/FlowdockHandler.php | 128 +
.../Handler/FormattableHandlerInterface.php | 39 +
.../Handler/FormattableHandlerTrait.php | 63 +
.../src/Monolog/Handler/GelfHandler.php | 65 +
.../src/Monolog/Handler/GroupHandler.php | 117 +
.../src/Monolog/Handler/HandlerInterface.php | 90 +
.../src/Monolog/Handler/HandlerWrapper.php | 116 +
.../src/Monolog/Handler/HipChatHandler.php | 367 +
.../src/Monolog/Handler/IFTTTHandler.php | 70 +
.../src/Monolog/Handler/InsightOpsHandler.php | 62 +
.../src/Monolog/Handler/LogEntriesHandler.php | 55 +
.../src/Monolog/Handler/LogglyHandler.php | 102 +
.../src/Monolog/Handler/MailHandler.php | 67 +
.../src/Monolog/Handler/MandrillHandler.php | 68 +
.../Handler/MissingExtensionException.php | 21 +
.../src/Monolog/Handler/MongoDBHandler.php | 59 +
.../Monolog/Handler/NativeMailerHandler.php | 185 +
.../src/Monolog/Handler/NewRelicHandler.php | 205 +
.../src/Monolog/Handler/NullHandler.php | 45 +
.../src/Monolog/Handler/PHPConsoleHandler.php | 243 +
.../Handler/ProcessableHandlerInterface.php | 40 +
.../Handler/ProcessableHandlerTrait.php | 73 +
.../src/Monolog/Handler/PsrHandler.php | 56 +
.../src/Monolog/Handler/PushoverHandler.php | 185 +
.../src/Monolog/Handler/RavenHandler.php | 234 +
.../src/Monolog/Handler/RedisHandler.php | 98 +
.../src/Monolog/Handler/RollbarHandler.php | 144 +
.../Monolog/Handler/RotatingFileHandler.php | 191 +
.../src/Monolog/Handler/SamplingHandler.php | 113 +
.../src/Monolog/Handler/Slack/SlackRecord.php | 299 +
.../src/Monolog/Handler/SlackHandler.php | 221 +
.../Monolog/Handler/SlackWebhookHandler.php | 121 +
.../src/Monolog/Handler/SlackbotHandler.php | 84 +
.../src/Monolog/Handler/SocketHandler.php | 385 +
.../src/Monolog/Handler/StreamHandler.php | 179 +
.../Monolog/Handler/SwiftMailerHandler.php | 111 +
.../src/Monolog/Handler/SyslogHandler.php | 67 +
.../Monolog/Handler/SyslogUdp/UdpSocket.php | 56 +
.../src/Monolog/Handler/SyslogUdpHandler.php | 124 +
.../src/Monolog/Handler/TestHandler.php | 177 +
.../Handler/WhatFailureGroupHandler.php | 72 +
.../Monolog/Handler/ZendMonitorHandler.php | 101 +
vendor/monolog/monolog/src/Monolog/Logger.php | 796 +
.../src/Monolog/Processor/GitProcessor.php | 64 +
.../Processor/IntrospectionProcessor.php | 112 +
.../Processor/MemoryPeakUsageProcessor.php | 35 +
.../src/Monolog/Processor/MemoryProcessor.php | 63 +
.../Processor/MemoryUsageProcessor.php | 35 +
.../Monolog/Processor/MercurialProcessor.php | 63 +
.../Monolog/Processor/ProcessIdProcessor.php | 31 +
.../Monolog/Processor/ProcessorInterface.php | 25 +
.../Processor/PsrLogMessageProcessor.php | 50 +
.../src/Monolog/Processor/TagProcessor.php | 44 +
.../src/Monolog/Processor/UidProcessor.php | 59 +
.../src/Monolog/Processor/WebProcessor.php | 113 +
.../monolog/monolog/src/Monolog/Registry.php | 134 +
.../src/Monolog/ResettableInterface.php | 31 +
.../monolog/src/Monolog/SignalHandler.php | 115 +
vendor/monolog/monolog/src/Monolog/Utils.php | 189 +
vendor/nyholm/psr7/CHANGELOG.md | 96 +
vendor/nyholm/psr7/LICENSE | 21 +
vendor/nyholm/psr7/README.md | 111 +
vendor/nyholm/psr7/phpstan.baseline.dist | 42 +
.../psr7/src/Factory/HttplugFactory.php | 40 +
.../nyholm/psr7/src/Factory/Psr17Factory.php | 73 +
vendor/nyholm/psr7/src/LowercaseTrait.php | 20 +
vendor/nyholm/psr7/src/MessageTrait.php | 209 +
vendor/nyholm/psr7/src/Request.php | 45 +
vendor/nyholm/psr7/src/RequestTrait.php | 113 +
vendor/nyholm/psr7/src/Response.php | 88 +
vendor/nyholm/psr7/src/ServerRequest.php | 162 +
vendor/nyholm/psr7/src/Stream.php | 273 +
vendor/nyholm/psr7/src/UploadedFile.php | 171 +
vendor/nyholm/psr7/src/Uri.php | 312 +
vendor/phive/twig-extensions-deferred/LICENSE | 21 +
.../phive/twig-extensions-deferred/README.md | 128 +
.../src/DeferredBlockNode.php | 29 +
.../src/DeferredExtension.php | 63 +
.../src/DeferredNode.php | 13 +
.../src/DeferredNodeVisitor.php | 41 +
.../src/DeferredTokenParser.php | 57 +
vendor/php-http/message-factory/CHANGELOG.md | 65 +
vendor/php-http/message-factory/LICENSE | 19 +
vendor/php-http/message-factory/README.md | 36 +
.../message-factory/src/MessageFactory.php | 12 +
.../message-factory/src/RequestFactory.php | 34 +
.../message-factory/src/ResponseFactory.php | 35 +
.../message-factory/src/StreamFactory.php | 25 +
.../message-factory/src/UriFactory.php | 24 +
vendor/pimple/pimple/CHANGELOG | 59 +
vendor/pimple/pimple/LICENSE | 19 +
vendor/pimple/pimple/README.rst | 326 +
vendor/pimple/pimple/src/Pimple/Container.php | 298 +
.../Exception/ExpectedInvokableException.php | 38 +
.../Exception/FrozenServiceException.php | 45 +
.../InvalidServiceIdentifierException.php | 45 +
.../Exception/UnknownIdentifierException.php | 45 +
.../pimple/src/Pimple/Psr11/Container.php | 55 +
.../src/Pimple/Psr11/ServiceLocator.php | 75 +
.../pimple/src/Pimple/ServiceIterator.php | 69 +
.../src/Pimple/ServiceProviderInterface.php | 46 +
vendor/psr/cache/CHANGELOG.md | 16 +
vendor/psr/cache/LICENSE.txt | 19 +
vendor/psr/cache/README.md | 9 +
vendor/psr/cache/composer.json | 25 +
vendor/psr/cache/src/CacheException.php | 10 +
vendor/psr/cache/src/CacheItemInterface.php | 105 +
.../psr/cache/src/CacheItemPoolInterface.php | 138 +
.../cache/src/InvalidArgumentException.php | 13 +
vendor/psr/container/LICENSE | 21 +
vendor/psr/container/README.md | 5 +
.../src/ContainerExceptionInterface.php | 13 +
.../psr/container/src/ContainerInterface.php | 37 +
.../src/NotFoundExceptionInterface.php | 13 +
vendor/psr/http-factory/LICENSE | 21 +
vendor/psr/http-factory/README.md | 10 +
.../src/RequestFactoryInterface.php | 18 +
.../src/ResponseFactoryInterface.php | 18 +
.../src/ServerRequestFactoryInterface.php | 24 +
.../src/StreamFactoryInterface.php | 45 +
.../src/UploadedFileFactoryInterface.php | 34 +
.../http-factory/src/UriFactoryInterface.php | 17 +
vendor/psr/http-message/CHANGELOG.md | 36 +
vendor/psr/http-message/LICENSE | 19 +
vendor/psr/http-message/README.md | 13 +
.../psr/http-message/src/MessageInterface.php | 187 +
.../psr/http-message/src/RequestInterface.php | 129 +
.../http-message/src/ResponseInterface.php | 68 +
.../src/ServerRequestInterface.php | 261 +
.../psr/http-message/src/StreamInterface.php | 158 +
.../src/UploadedFileInterface.php | 123 +
vendor/psr/http-message/src/UriInterface.php | 323 +
vendor/psr/http-server-handler/LICENSE | 21 +
vendor/psr/http-server-handler/README.md | 6 +
.../src/RequestHandlerInterface.php | 22 +
vendor/psr/http-server-middleware/LICENSE | 21 +
vendor/psr/http-server-middleware/README.md | 6 +
.../src/MiddlewareInterface.php | 25 +
vendor/psr/log/LICENSE | 19 +
vendor/psr/log/Psr/Log/AbstractLogger.php | 128 +
.../log/Psr/Log/InvalidArgumentException.php | 7 +
vendor/psr/log/Psr/Log/LogLevel.php | 18 +
.../psr/log/Psr/Log/LoggerAwareInterface.php | 18 +
vendor/psr/log/Psr/Log/LoggerAwareTrait.php | 26 +
vendor/psr/log/Psr/Log/LoggerInterface.php | 125 +
vendor/psr/log/Psr/Log/LoggerTrait.php | 142 +
vendor/psr/log/Psr/Log/NullLogger.php | 30 +
vendor/psr/log/Psr/Log/Test/DummyTest.php | 18 +
.../log/Psr/Log/Test/LoggerInterfaceTest.php | 138 +
vendor/psr/log/Psr/Log/Test/TestLogger.php | 147 +
vendor/psr/log/README.md | 58 +
vendor/psr/simple-cache/LICENSE.md | 21 +
vendor/psr/simple-cache/README.md | 8 +
.../psr/simple-cache/src/CacheException.php | 10 +
.../psr/simple-cache/src/CacheInterface.php | 114 +
.../src/InvalidArgumentException.php | 13 +
vendor/ralouphie/getallheaders/LICENSE | 21 +
vendor/ralouphie/getallheaders/README.md | 27 +
.../getallheaders/src/getallheaders.php | 46 +
.../toolbox/ArrayTraits/src/ArrayAccess.php | 66 +
.../src/ArrayAccessWithGetters.php | 57 +
.../toolbox/ArrayTraits/src/Constructor.php | 24 +
.../toolbox/ArrayTraits/src/Countable.php | 24 +
.../toolbox/ArrayTraits/src/Export.php | 51 +
.../ArrayTraits/src/ExportInterface.php | 35 +
.../toolbox/ArrayTraits/src/Iterator.php | 77 +
.../ArrayTraits/src/NestedArrayAccess.php | 190 +
.../src/NestedArrayAccessWithGetters.php | 57 +
.../toolbox/ArrayTraits/src/Serializable.php | 34 +
.../toolbox/Blueprints/src/BlueprintForm.php | 600 +
.../Blueprints/src/BlueprintSchema.php | 716 +
.../toolbox/Blueprints/src/Blueprints.php | 12 +
.../Blueprints/tests/BlueprintFormTest.php | 96 +
.../Blueprints/tests/BlueprintSchemaTest.php | 90 +
.../tests/data/blueprint/basic.yaml | 41 +
.../tests/data/blueprint/empty.yaml | 0
.../tests/data/blueprint/extends.yaml | 17 +
.../tests/data/blueprint/import.yaml | 4 +
.../data/blueprint/partials/address.yaml | 17 +
.../tests/data/form/items/basic.yaml | 40 +
.../tests/data/form/items/empty.yaml | 1 +
.../tests/data/form/items/extends.yaml | 34 +
.../tests/data/form/items/import.yaml | 8 +
.../Blueprints/tests/data/input/basic.yaml | 12 +
.../Blueprints/tests/data/input/empty.yaml | 7 +
.../tests/data/schema/defaults/basic.yaml | 4 +
.../tests/data/schema/defaults/empty.yaml | 0
.../tests/data/schema/extra/basic.yaml | 8 +
.../tests/data/schema/extra/empty.yaml | 7 +
.../tests/data/schema/init/basic.yaml | 88 +
.../tests/data/schema/init/empty.yaml | 11 +
.../tests/data/schema/merge/basic.yaml | 14 +
.../tests/data/schema/merge/empty.yaml | 7 +
.../tests/data/schema/state/basic.yaml | 81 +
.../tests/data/schema/state/empty.yaml | 11 +
.../toolbox/Blueprints/tests/helper.php | 9 +
vendor/rockettheme/toolbox/CHANGELOG.md | 188 +
.../src/Yaml/Exception/ExceptionInterface.php | 21 +
.../src/Yaml/Exception/ParseException.php | 144 +
.../src/Yaml/Exception/RuntimeException.php | 21 +
.../toolbox/Compat/src/Yaml/Inline.php | 501 +
.../toolbox/Compat/src/Yaml/Parser.php | 852 +
.../toolbox/Compat/src/Yaml/Unescaper.php | 156 +
.../toolbox/Compat/src/Yaml/Yaml.php | 74 +
.../rockettheme/toolbox/DI/src/Container.php | 15 +
.../DI/src/ServiceProviderInterface.php | 15 +
.../rockettheme/toolbox/Event/src/Event.php | 24 +
.../toolbox/Event/src/EventDispatcher.php | 25 +
.../Event/src/EventSubscriberInterface.php | 15 +
vendor/rockettheme/toolbox/File/src/File.php | 477 +
.../toolbox/File/src/FileInterface.php | 106 +
.../rockettheme/toolbox/File/src/IniFile.php | 76 +
.../rockettheme/toolbox/File/src/JsonFile.php | 57 +
.../rockettheme/toolbox/File/src/LogFile.php | 71 +
.../toolbox/File/src/MarkdownFile.php | 172 +
.../rockettheme/toolbox/File/src/MoFile.php | 160 +
.../rockettheme/toolbox/File/src/PhpFile.php | 105 +
.../rockettheme/toolbox/File/src/YamlFile.php | 140 +
vendor/rockettheme/toolbox/LICENSE | 21 +
vendor/rockettheme/toolbox/README.md | 56 +
.../src/RecursiveUniformResourceIterator.php | 50 +
.../src/ResourceLocatorInterface.php | 45 +
.../src/UniformResourceIterator.php | 250 +
.../src/UniformResourceLocator.php | 486 +
.../tests/UniformResourceLocatorTest.php | 258 +
.../tests/data/base/all/base.txt | 0
.../tests/data/base/all/base_all.txt | 0
.../tests/data/base/all/base_local.txt | 0
.../tests/data/base/all/base_override.txt | 0
.../tests/data/local/all/base_all.txt | 0
.../tests/data/local/all/base_local.txt | 0
.../tests/data/local/all/local.txt | 0
.../tests/data/local/all/local_override.txt | 0
.../tests/data/override/all/base_all.txt | 0
.../tests/data/override/all/base_override.txt | 0
.../data/override/all/local_override.txt | 0
.../tests/data/override/all/override.txt | 0
.../toolbox/Session/src/Message.php | 94 +
.../toolbox/Session/src/Session.php | 265 +
.../toolbox/Session/tests/MessageTest.php | 13 +
.../StreamWrapper/src/ReadOnlyStream.php | 94 +
.../toolbox/StreamWrapper/src/Stream.php | 314 +
.../StreamWrapper/src/StreamBuilder.php | 94 +
.../StreamWrapper/src/StreamInterface.php | 270 +
vendor/seld/cli-prompt/LICENSE | 19 +
vendor/seld/cli-prompt/README.md | 61 +
vendor/seld/cli-prompt/res/example.php | 15 +
vendor/seld/cli-prompt/res/hiddeninput.exe | Bin 0 -> 9216 bytes
vendor/seld/cli-prompt/src/CliPrompt.php | 113 +
vendor/symfony/console/Application.php | 1190 ++
vendor/symfony/console/CHANGELOG.md | 140 +
vendor/symfony/console/Command/Command.php | 654 +
.../symfony/console/Command/HelpCommand.php | 81 +
.../symfony/console/Command/ListCommand.php | 90 +
.../symfony/console/Command/LockableTrait.php | 71 +
.../CommandLoader/CommandLoaderInterface.php | 46 +
.../CommandLoader/ContainerCommandLoader.php | 64 +
.../CommandLoader/FactoryCommandLoader.php | 62 +
vendor/symfony/console/ConsoleEvents.php | 47 +
.../AddConsoleCommandPass.php | 98 +
.../Descriptor/ApplicationDescription.php | 144 +
.../symfony/console/Descriptor/Descriptor.php | 107 +
.../Descriptor/DescriptorInterface.php | 31 +
.../console/Descriptor/JsonDescriptor.php | 170 +
.../console/Descriptor/MarkdownDescriptor.php | 182 +
.../console/Descriptor/TextDescriptor.php | 342 +
.../console/Descriptor/XmlDescriptor.php | 245 +
.../console/Event/ConsoleCommandEvent.php | 60 +
.../console/Event/ConsoleErrorEvent.php | 58 +
vendor/symfony/console/Event/ConsoleEvent.php | 67 +
.../console/Event/ConsoleTerminateEvent.php | 53 +
.../console/EventListener/ErrorListener.php | 91 +
.../Exception/CommandNotFoundException.php | 43 +
.../console/Exception/ExceptionInterface.php | 21 +
.../Exception/InvalidArgumentException.php | 19 +
.../Exception/InvalidOptionException.php | 21 +
.../console/Exception/LogicException.php | 19 +
.../Exception/NamespaceNotFoundException.php | 21 +
.../console/Exception/RuntimeException.php | 19 +
.../console/Formatter/OutputFormatter.php | 282 +
.../Formatter/OutputFormatterInterface.php | 71 +
.../Formatter/OutputFormatterStyle.php | 183 +
.../OutputFormatterStyleInterface.php | 62 +
.../Formatter/OutputFormatterStyleStack.php | 110 +
.../WrappableOutputFormatterInterface.php | 25 +
.../console/Helper/DebugFormatterHelper.php | 127 +
.../console/Helper/DescriptorHelper.php | 94 +
.../console/Helper/FormatterHelper.php | 106 +
vendor/symfony/console/Helper/Helper.php | 138 +
.../console/Helper/HelperInterface.php | 39 +
vendor/symfony/console/Helper/HelperSet.php | 108 +
.../console/Helper/InputAwareHelper.php | 33 +
.../symfony/console/Helper/ProcessHelper.php | 156 +
vendor/symfony/console/Helper/ProgressBar.php | 527 +
.../console/Helper/ProgressIndicator.php | 269 +
.../symfony/console/Helper/QuestionHelper.php | 474 +
.../console/Helper/SymfonyQuestionHelper.php | 96 +
vendor/symfony/console/Helper/Table.php | 813 +
vendor/symfony/console/Helper/TableCell.php | 68 +
vendor/symfony/console/Helper/TableRows.php | 32 +
.../symfony/console/Helper/TableSeparator.php | 25 +
vendor/symfony/console/Helper/TableStyle.php | 458 +
vendor/symfony/console/Input/ArgvInput.php | 365 +
vendor/symfony/console/Input/ArrayInput.php | 206 +
vendor/symfony/console/Input/Input.php | 203 +
.../symfony/console/Input/InputArgument.php | 129 +
.../console/Input/InputAwareInterface.php | 26 +
.../symfony/console/Input/InputDefinition.php | 404 +
.../symfony/console/Input/InputInterface.php | 163 +
vendor/symfony/console/Input/InputOption.php | 208 +
.../Input/StreamableInputInterface.php | 37 +
vendor/symfony/console/Input/StringInput.php | 72 +
vendor/symfony/console/LICENSE | 19 +
.../symfony/console/Logger/ConsoleLogger.php | 124 +
.../symfony/console/Output/BufferedOutput.php | 45 +
.../symfony/console/Output/ConsoleOutput.php | 161 +
.../console/Output/ConsoleOutputInterface.php | 32 +
.../console/Output/ConsoleSectionOutput.php | 141 +
vendor/symfony/console/Output/NullOutput.php | 123 +
vendor/symfony/console/Output/Output.php | 177 +
.../console/Output/OutputInterface.php | 114 +
.../symfony/console/Output/StreamOutput.php | 124 +
.../console/Question/ChoiceQuestion.php | 182 +
.../console/Question/ConfirmationQuestion.php | 59 +
vendor/symfony/console/Question/Question.php | 246 +
vendor/symfony/console/README.md | 20 +
.../console/Resources/bin/hiddeninput.exe | Bin 0 -> 9216 bytes
vendor/symfony/console/Style/OutputStyle.php | 155 +
.../symfony/console/Style/StyleInterface.php | 154 +
vendor/symfony/console/Style/SymfonyStyle.php | 438 +
vendor/symfony/console/Terminal.php | 137 +
vendor/symfony/contracts/CHANGELOG.md | 24 +
.../contracts/Cache/CacheInterface.php | 57 +
vendor/symfony/contracts/Cache/CacheTrait.php | 78 +
.../contracts/Cache/CallbackInterface.php | 30 +
.../symfony/contracts/Cache/ItemInterface.php | 65 +
vendor/symfony/contracts/Cache/LICENSE | 19 +
vendor/symfony/contracts/Cache/README.md | 9 +
.../Cache/TagAwareCacheInterface.php | 38 +
vendor/symfony/contracts/Cache/composer.json | 38 +
.../contracts/EventDispatcher/Event.php | 96 +
.../EventDispatcherInterface.php | 58 +
.../symfony/contracts/EventDispatcher/LICENSE | 19 +
.../contracts/EventDispatcher/README.md | 9 +
.../contracts/EventDispatcher/composer.json | 38 +
.../contracts/HttpClient/ChunkInterface.php | 73 +
.../Exception/ClientExceptionInterface.php | 23 +
.../Exception/DecodingExceptionInterface.php | 23 +
.../Exception/ExceptionInterface.php | 23 +
.../Exception/HttpExceptionInterface.php | 26 +
.../RedirectionExceptionInterface.php | 23 +
.../Exception/ServerExceptionInterface.php | 23 +
.../Exception/TransportExceptionInterface.php | 23 +
.../HttpClient/HttpClientInterface.php | 95 +
vendor/symfony/contracts/HttpClient/LICENSE | 19 +
vendor/symfony/contracts/HttpClient/README.md | 9 +
.../HttpClient/ResponseInterface.php | 111 +
.../HttpClient/ResponseStreamInterface.php | 26 +
.../HttpClient/Test/Fixtures/web/index.php | 183 +
.../HttpClient/Test/HttpClientTestCase.php | 1004 ++
.../HttpClient/Test/TestHttpServer.php | 46 +
.../contracts/HttpClient/composer.json | 37 +
vendor/symfony/contracts/LICENSE | 19 +
vendor/symfony/contracts/README.md | 54 +
vendor/symfony/contracts/Service/LICENSE | 19 +
vendor/symfony/contracts/Service/README.md | 9 +
.../contracts/Service/ResetInterface.php | 30 +
.../contracts/Service/ServiceLocatorTrait.php | 126 +
.../Service/ServiceProviderInterface.php | 36 +
.../Service/ServiceSubscriberInterface.php | 53 +
.../Service/ServiceSubscriberTrait.php | 63 +
.../Service/Test/ServiceLocatorTest.php | 92 +
.../symfony/contracts/Service/composer.json | 38 +
.../contracts/Tests/Cache/CacheTraitTest.php | 165 +
.../Service/ServiceSubscriberTraitTest.php | 65 +
vendor/symfony/contracts/Translation/LICENSE | 19 +
.../Translation/LocaleAwareInterface.php | 31 +
.../symfony/contracts/Translation/README.md | 9 +
.../Translation/Test/TranslatorTest.php | 353 +
.../Translation/TranslatorInterface.php | 65 +
.../contracts/Translation/TranslatorTrait.php | 257 +
.../contracts/Translation/composer.json | 37 +
vendor/symfony/contracts/composer.json | 53 +
vendor/symfony/contracts/phpunit.xml.dist | 35 +
vendor/symfony/event-dispatcher/CHANGELOG.md | 55 +
.../Debug/TraceableEventDispatcher.php | 346 +
.../TraceableEventDispatcherInterface.php | 37 +
.../Debug/WrappedListener.php | 125 +
.../RegisterListenersPass.php | 136 +
vendor/symfony/event-dispatcher/Event.php | 58 +
.../event-dispatcher/EventDispatcher.php | 236 +
.../EventDispatcherInterface.php | 93 +
.../EventSubscriberInterface.php | 46 +
.../symfony/event-dispatcher/GenericEvent.php | 175 +
.../ImmutableEventDispatcher.php | 91 +
vendor/symfony/event-dispatcher/LICENSE | 19 +
vendor/symfony/event-dispatcher/README.md | 15 +
vendor/symfony/polyfill-ctype/Ctype.php | 227 +
vendor/symfony/polyfill-ctype/LICENSE | 19 +
vendor/symfony/polyfill-ctype/README.md | 12 +
vendor/symfony/polyfill-ctype/bootstrap.php | 46 +
vendor/symfony/polyfill-iconv/Iconv.php | 741 +
vendor/symfony/polyfill-iconv/LICENSE | 19 +
vendor/symfony/polyfill-iconv/README.md | 14 +
.../Resources/charset/from.big5.php | 13719 ++++++++++++++++
.../Resources/charset/from.cp037.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.cp1006.php | Bin 0 -> 3860 bytes
.../Resources/charset/from.cp1026.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.cp424.php | Bin 0 -> 3210 bytes
.../Resources/charset/from.cp437.php | Bin 0 -> 3841 bytes
.../Resources/charset/from.cp500.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.cp737.php | Bin 0 -> 3834 bytes
.../Resources/charset/from.cp775.php | Bin 0 -> 3815 bytes
.../Resources/charset/from.cp850.php | Bin 0 -> 3809 bytes
.../Resources/charset/from.cp852.php | Bin 0 -> 3808 bytes
.../Resources/charset/from.cp855.php | Bin 0 -> 3809 bytes
.../Resources/charset/from.cp856.php | Bin 0 -> 3194 bytes
.../Resources/charset/from.cp857.php | Bin 0 -> 3763 bytes
.../Resources/charset/from.cp860.php | Bin 0 -> 3840 bytes
.../Resources/charset/from.cp861.php | Bin 0 -> 3841 bytes
.../Resources/charset/from.cp862.php | Bin 0 -> 3841 bytes
.../Resources/charset/from.cp863.php | Bin 0 -> 3841 bytes
.../Resources/charset/from.cp864.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.cp865.php | Bin 0 -> 3841 bytes
.../Resources/charset/from.cp866.php | Bin 0 -> 3831 bytes
.../Resources/charset/from.cp869.php | Bin 0 -> 3676 bytes
.../Resources/charset/from.cp874.php | Bin 0 -> 3410 bytes
.../Resources/charset/from.cp875.php | Bin 0 -> 3776 bytes
.../Resources/charset/from.cp932.php | Bin 0 -> 134095 bytes
.../Resources/charset/from.cp936.php | Bin 0 -> 372283 bytes
.../Resources/charset/from.cp949.php | Bin 0 -> 291504 bytes
.../Resources/charset/from.cp950.php | Bin 0 -> 231436 bytes
.../Resources/charset/from.iso-8859-1.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.iso-8859-10.php | Bin 0 -> 3780 bytes
.../Resources/charset/from.iso-8859-11.php | Bin 0 -> 3746 bytes
.../Resources/charset/from.iso-8859-13.php | Bin 0 -> 3783 bytes
.../Resources/charset/from.iso-8859-14.php | Bin 0 -> 3801 bytes
.../Resources/charset/from.iso-8859-15.php | Bin 0 -> 3780 bytes
.../Resources/charset/from.iso-8859-16.php | Bin 0 -> 3782 bytes
.../Resources/charset/from.iso-8859-2.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.iso-8859-3.php | Bin 0 -> 3674 bytes
.../Resources/charset/from.iso-8859-4.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.iso-8859-5.php | Bin 0 -> 3780 bytes
.../Resources/charset/from.iso-8859-6.php | Bin 0 -> 3104 bytes
.../Resources/charset/from.iso-8859-7.php | Bin 0 -> 3692 bytes
.../Resources/charset/from.iso-8859-8.php | Bin 0 -> 3242 bytes
.../Resources/charset/from.iso-8859-9.php | Bin 0 -> 3779 bytes
.../Resources/charset/from.koi8-r.php | Bin 0 -> 3835 bytes
.../Resources/charset/from.koi8-u.php | Bin 0 -> 3827 bytes
.../Resources/charset/from.us-ascii.php | Bin 0 -> 1859 bytes
.../Resources/charset/from.windows-1250.php | Bin 0 -> 3721 bytes
.../Resources/charset/from.windows-1251.php | Bin 0 -> 3782 bytes
.../Resources/charset/from.windows-1252.php | Bin 0 -> 3721 bytes
.../Resources/charset/from.windows-1253.php | Bin 0 -> 3542 bytes
.../Resources/charset/from.windows-1254.php | Bin 0 -> 3691 bytes
.../Resources/charset/from.windows-1255.php | Bin 0 -> 3454 bytes
.../Resources/charset/from.windows-1256.php | Bin 0 -> 3800 bytes
.../Resources/charset/from.windows-1257.php | Bin 0 -> 3616 bytes
.../Resources/charset/from.windows-1258.php | Bin 0 -> 3662 bytes
.../Resources/charset/translit.php | 4103 +++++
vendor/symfony/polyfill-iconv/bootstrap.php | 84 +
vendor/symfony/polyfill-mbstring/LICENSE | 19 +
vendor/symfony/polyfill-mbstring/Mbstring.php | 847 +
vendor/symfony/polyfill-mbstring/README.md | 13 +
.../Resources/unidata/lowerCase.php | 1397 ++
.../Resources/unidata/titleCaseRegexp.php | 5 +
.../Resources/unidata/upperCase.php | 1414 ++
.../symfony/polyfill-mbstring/bootstrap.php | 141 +
vendor/symfony/polyfill-php72/LICENSE | 19 +
vendor/symfony/polyfill-php72/Php72.php | 217 +
vendor/symfony/polyfill-php72/README.md | 28 +
vendor/symfony/polyfill-php72/bootstrap.php | 57 +
vendor/symfony/polyfill-php73/LICENSE | 19 +
vendor/symfony/polyfill-php73/Php73.php | 43 +
vendor/symfony/polyfill-php73/README.md | 18 +
.../Resources/stubs/JsonException.php | 14 +
vendor/symfony/polyfill-php73/bootstrap.php | 31 +
vendor/symfony/process/CHANGELOG.md | 90 +
.../process/Exception/ExceptionInterface.php | 21 +
.../Exception/InvalidArgumentException.php | 21 +
.../process/Exception/LogicException.php | 21 +
.../Exception/ProcessFailedException.php | 54 +
.../Exception/ProcessSignaledException.php | 41 +
.../Exception/ProcessTimedOutException.php | 69 +
.../process/Exception/RuntimeException.php | 21 +
vendor/symfony/process/ExecutableFinder.php | 88 +
vendor/symfony/process/InputStream.php | 90 +
vendor/symfony/process/LICENSE | 19 +
.../symfony/process/PhpExecutableFinder.php | 101 +
vendor/symfony/process/PhpProcess.php | 75 +
.../symfony/process/Pipes/AbstractPipes.php | 178 +
.../symfony/process/Pipes/PipesInterface.php | 67 +
vendor/symfony/process/Pipes/UnixPipes.php | 153 +
vendor/symfony/process/Pipes/WindowsPipes.php | 191 +
vendor/symfony/process/Process.php | 1653 ++
vendor/symfony/process/ProcessUtils.php | 69 +
vendor/symfony/process/README.md | 13 +
vendor/symfony/var-dumper/CHANGELOG.md | 37 +
.../symfony/var-dumper/Caster/AmqpCaster.php | 210 +
vendor/symfony/var-dumper/Caster/ArgsStub.php | 80 +
vendor/symfony/var-dumper/Caster/Caster.php | 163 +
.../symfony/var-dumper/Caster/ClassStub.php | 106 +
.../symfony/var-dumper/Caster/ConstStub.php | 33 +
.../var-dumper/Caster/CutArrayStub.php | 30 +
vendor/symfony/var-dumper/Caster/CutStub.php | 59 +
.../symfony/var-dumper/Caster/DOMCaster.php | 302 +
.../symfony/var-dumper/Caster/DateCaster.php | 122 +
.../var-dumper/Caster/DoctrineCaster.php | 60 +
vendor/symfony/var-dumper/Caster/EnumStub.php | 30 +
.../var-dumper/Caster/ExceptionCaster.php | 357 +
.../symfony/var-dumper/Caster/FrameStub.php | 30 +
.../symfony/var-dumper/Caster/GmpCaster.php | 30 +
.../symfony/var-dumper/Caster/IntlCaster.php | 170 +
vendor/symfony/var-dumper/Caster/LinkStub.php | 108 +
.../var-dumper/Caster/MemcachedCaster.php | 79 +
.../symfony/var-dumper/Caster/PdoCaster.php | 120 +
.../symfony/var-dumper/Caster/PgSqlCaster.php | 154 +
.../var-dumper/Caster/ProxyManagerCaster.php | 31 +
.../symfony/var-dumper/Caster/RedisCaster.php | 150 +
.../var-dumper/Caster/ReflectionCaster.php | 378 +
.../var-dumper/Caster/ResourceCaster.php | 72 +
.../symfony/var-dumper/Caster/SplCaster.php | 213 +
.../symfony/var-dumper/Caster/StubCaster.php | 82 +
.../var-dumper/Caster/SymfonyCaster.php | 43 +
.../symfony/var-dumper/Caster/TraceStub.php | 36 +
.../var-dumper/Caster/XmlReaderCaster.php | 77 +
.../var-dumper/Caster/XmlResourceCaster.php | 61 +
.../var-dumper/Cloner/AbstractCloner.php | 340 +
.../var-dumper/Cloner/ClonerInterface.php | 27 +
vendor/symfony/var-dumper/Cloner/Cursor.php | 43 +
vendor/symfony/var-dumper/Cloner/Data.php | 423 +
.../var-dumper/Cloner/DumperInterface.php | 60 +
vendor/symfony/var-dumper/Cloner/Stub.php | 67 +
.../symfony/var-dumper/Cloner/VarCloner.php | 302 +
.../Command/Descriptor/CliDescriptor.php | 81 +
.../Descriptor/DumpDescriptorInterface.php | 23 +
.../Command/Descriptor/HtmlDescriptor.php | 119 +
.../var-dumper/Command/ServerDumpCommand.php | 99 +
.../var-dumper/Dumper/AbstractDumper.php | 211 +
.../symfony/var-dumper/Dumper/CliDumper.php | 597 +
.../ContextProvider/CliContextProvider.php | 32 +
.../ContextProviderInterface.php | 25 +
.../RequestContextProvider.php | 49 +
.../ContextProvider/SourceContextProvider.php | 126 +
.../var-dumper/Dumper/DataDumperInterface.php | 24 +
.../symfony/var-dumper/Dumper/HtmlDumper.php | 959 ++
.../var-dumper/Dumper/ServerDumper.php | 53 +
.../Exception/ThrowingCasterException.php | 26 +
vendor/symfony/var-dumper/LICENSE | 19 +
vendor/symfony/var-dumper/README.md | 15 +
.../var-dumper/Resources/bin/var-dump-server | 63 +
.../Resources/css/htmlDescriptor.css | 130 +
.../var-dumper/Resources/functions/dump.php | 43 +
.../var-dumper/Resources/js/htmlDescriptor.js | 10 +
.../symfony/var-dumper/Server/Connection.php | 95 +
.../symfony/var-dumper/Server/DumpServer.php | 107 +
vendor/symfony/var-dumper/VarDumper.php | 54 +
vendor/symfony/yaml/CHANGELOG.md | 184 +
vendor/symfony/yaml/Command/LintCommand.php | 253 +
vendor/symfony/yaml/Dumper.php | 112 +
vendor/symfony/yaml/Escaper.php | 101 +
.../symfony/yaml/Exception/DumpException.php | 21 +
.../yaml/Exception/ExceptionInterface.php | 21 +
.../symfony/yaml/Exception/ParseException.php | 139 +
.../yaml/Exception/RuntimeException.php | 21 +
vendor/symfony/yaml/Inline.php | 746 +
vendor/symfony/yaml/LICENSE | 19 +
vendor/symfony/yaml/Parser.php | 1075 ++
vendor/symfony/yaml/README.md | 13 +
vendor/symfony/yaml/Tag/TaggedValue.php | 38 +
vendor/symfony/yaml/Unescaper.php | 138 +
vendor/symfony/yaml/Yaml.php | 101 +
vendor/twig/twig/.gitattributes | 2 +
vendor/twig/twig/CHANGELOG | 1154 ++
vendor/twig/twig/LICENSE | 27 +
vendor/twig/twig/README.rst | 24 +
vendor/twig/twig/drupal_test.sh | 50 +
vendor/twig/twig/lib/Twig/Autoloader.php | 52 +
vendor/twig/twig/lib/Twig/BaseNodeVisitor.php | 11 +
.../twig/twig/lib/Twig/Cache/Filesystem.php | 11 +
vendor/twig/twig/lib/Twig/Cache/Null.php | 11 +
vendor/twig/twig/lib/Twig/CacheInterface.php | 11 +
vendor/twig/twig/lib/Twig/Compiler.php | 11 +
.../twig/twig/lib/Twig/CompilerInterface.php | 34 +
.../twig/lib/Twig/ContainerRuntimeLoader.php | 11 +
vendor/twig/twig/lib/Twig/Environment.php | 11 +
vendor/twig/twig/lib/Twig/Error.php | 11 +
vendor/twig/twig/lib/Twig/Error/Loader.php | 11 +
vendor/twig/twig/lib/Twig/Error/Runtime.php | 11 +
vendor/twig/twig/lib/Twig/Error/Syntax.php | 11 +
.../twig/lib/Twig/ExistsLoaderInterface.php | 11 +
.../twig/twig/lib/Twig/ExpressionParser.php | 11 +
vendor/twig/twig/lib/Twig/Extension.php | 11 +
vendor/twig/twig/lib/Twig/Extension/Core.php | 11 +
vendor/twig/twig/lib/Twig/Extension/Debug.php | 11 +
.../twig/twig/lib/Twig/Extension/Escaper.php | 11 +
.../lib/Twig/Extension/GlobalsInterface.php | 11 +
.../Twig/Extension/InitRuntimeInterface.php | 11 +
.../twig/lib/Twig/Extension/Optimizer.php | 11 +
.../twig/twig/lib/Twig/Extension/Profiler.php | 11 +
.../twig/twig/lib/Twig/Extension/Sandbox.php | 11 +
.../twig/twig/lib/Twig/Extension/Staging.php | 11 +
.../twig/lib/Twig/Extension/StringLoader.php | 11 +
.../twig/twig/lib/Twig/ExtensionInterface.php | 11 +
.../twig/lib/Twig/FactoryRuntimeLoader.php | 11 +
.../Twig/FileExtensionEscapingStrategy.php | 11 +
vendor/twig/twig/lib/Twig/Filter.php | 86 +
vendor/twig/twig/lib/Twig/Filter/Function.php | 40 +
vendor/twig/twig/lib/Twig/Filter/Method.php | 44 +
vendor/twig/twig/lib/Twig/Filter/Node.php | 42 +
.../twig/lib/Twig/FilterCallableInterface.php | 24 +
vendor/twig/twig/lib/Twig/FilterInterface.php | 45 +
vendor/twig/twig/lib/Twig/Function.php | 76 +
.../twig/twig/lib/Twig/Function/Function.php | 41 +
vendor/twig/twig/lib/Twig/Function/Method.php | 45 +
vendor/twig/twig/lib/Twig/Function/Node.php | 42 +
.../lib/Twig/FunctionCallableInterface.php | 24 +
.../twig/twig/lib/Twig/FunctionInterface.php | 42 +
vendor/twig/twig/lib/Twig/Lexer.php | 11 +
vendor/twig/twig/lib/Twig/LexerInterface.php | 36 +
vendor/twig/twig/lib/Twig/Loader/Array.php | 11 +
vendor/twig/twig/lib/Twig/Loader/Chain.php | 11 +
.../twig/twig/lib/Twig/Loader/Filesystem.php | 11 +
vendor/twig/twig/lib/Twig/Loader/String.php | 63 +
vendor/twig/twig/lib/Twig/LoaderInterface.php | 11 +
vendor/twig/twig/lib/Twig/Markup.php | 11 +
vendor/twig/twig/lib/Twig/Node.php | 11 +
vendor/twig/twig/lib/Twig/Node/AutoEscape.php | 11 +
vendor/twig/twig/lib/Twig/Node/Block.php | 11 +
.../twig/lib/Twig/Node/BlockReference.php | 11 +
vendor/twig/twig/lib/Twig/Node/Body.php | 11 +
.../twig/twig/lib/Twig/Node/CheckSecurity.php | 11 +
vendor/twig/twig/lib/Twig/Node/Deprecated.php | 11 +
vendor/twig/twig/lib/Twig/Node/Do.php | 11 +
vendor/twig/twig/lib/Twig/Node/Embed.php | 11 +
vendor/twig/twig/lib/Twig/Node/Expression.php | 11 +
.../twig/lib/Twig/Node/Expression/Array.php | 11 +
.../lib/Twig/Node/Expression/AssignName.php | 11 +
.../twig/lib/Twig/Node/Expression/Binary.php | 11 +
.../lib/Twig/Node/Expression/Binary/Add.php | 11 +
.../lib/Twig/Node/Expression/Binary/And.php | 11 +
.../Node/Expression/Binary/BitwiseAnd.php | 11 +
.../Twig/Node/Expression/Binary/BitwiseOr.php | 11 +
.../Node/Expression/Binary/BitwiseXor.php | 11 +
.../Twig/Node/Expression/Binary/Concat.php | 11 +
.../lib/Twig/Node/Expression/Binary/Div.php | 11 +
.../Twig/Node/Expression/Binary/EndsWith.php | 11 +
.../lib/Twig/Node/Expression/Binary/Equal.php | 11 +
.../Twig/Node/Expression/Binary/FloorDiv.php | 11 +
.../Twig/Node/Expression/Binary/Greater.php | 11 +
.../Node/Expression/Binary/GreaterEqual.php | 11 +
.../lib/Twig/Node/Expression/Binary/In.php | 11 +
.../lib/Twig/Node/Expression/Binary/Less.php | 11 +
.../Twig/Node/Expression/Binary/LessEqual.php | 11 +
.../Twig/Node/Expression/Binary/Matches.php | 11 +
.../lib/Twig/Node/Expression/Binary/Mod.php | 11 +
.../lib/Twig/Node/Expression/Binary/Mul.php | 11 +
.../Twig/Node/Expression/Binary/NotEqual.php | 11 +
.../lib/Twig/Node/Expression/Binary/NotIn.php | 11 +
.../lib/Twig/Node/Expression/Binary/Or.php | 11 +
.../lib/Twig/Node/Expression/Binary/Power.php | 11 +
.../lib/Twig/Node/Expression/Binary/Range.php | 11 +
.../Node/Expression/Binary/StartsWith.php | 11 +
.../lib/Twig/Node/Expression/Binary/Sub.php | 11 +
.../Twig/Node/Expression/BlockReference.php | 11 +
.../twig/lib/Twig/Node/Expression/Call.php | 11 +
.../lib/Twig/Node/Expression/Conditional.php | 11 +
.../lib/Twig/Node/Expression/Constant.php | 11 +
.../Node/Expression/ExtensionReference.php | 35 +
.../twig/lib/Twig/Node/Expression/Filter.php | 11 +
.../Twig/Node/Expression/Filter/Default.php | 11 +
.../lib/Twig/Node/Expression/Function.php | 11 +
.../twig/lib/Twig/Node/Expression/GetAttr.php | 11 +
.../lib/Twig/Node/Expression/MethodCall.php | 11 +
.../twig/lib/Twig/Node/Expression/Name.php | 11 +
.../lib/Twig/Node/Expression/NullCoalesce.php | 11 +
.../twig/lib/Twig/Node/Expression/Parent.php | 11 +
.../lib/Twig/Node/Expression/TempName.php | 11 +
.../twig/lib/Twig/Node/Expression/Test.php | 11 +
.../Twig/Node/Expression/Test/Constant.php | 11 +
.../lib/Twig/Node/Expression/Test/Defined.php | 11 +
.../Twig/Node/Expression/Test/Divisibleby.php | 11 +
.../lib/Twig/Node/Expression/Test/Even.php | 11 +
.../lib/Twig/Node/Expression/Test/Null.php | 11 +
.../lib/Twig/Node/Expression/Test/Odd.php | 11 +
.../lib/Twig/Node/Expression/Test/Sameas.php | 11 +
.../twig/lib/Twig/Node/Expression/Unary.php | 11 +
.../lib/Twig/Node/Expression/Unary/Neg.php | 11 +
.../lib/Twig/Node/Expression/Unary/Not.php | 11 +
.../lib/Twig/Node/Expression/Unary/Pos.php | 11 +
vendor/twig/twig/lib/Twig/Node/Flush.php | 11 +
vendor/twig/twig/lib/Twig/Node/For.php | 11 +
vendor/twig/twig/lib/Twig/Node/ForLoop.php | 11 +
vendor/twig/twig/lib/Twig/Node/If.php | 11 +
vendor/twig/twig/lib/Twig/Node/Import.php | 11 +
vendor/twig/twig/lib/Twig/Node/Include.php | 11 +
vendor/twig/twig/lib/Twig/Node/Macro.php | 11 +
vendor/twig/twig/lib/Twig/Node/Module.php | 11 +
vendor/twig/twig/lib/Twig/Node/Print.php | 11 +
vendor/twig/twig/lib/Twig/Node/Sandbox.php | 11 +
.../twig/lib/Twig/Node/SandboxedPrint.php | 11 +
vendor/twig/twig/lib/Twig/Node/Set.php | 11 +
vendor/twig/twig/lib/Twig/Node/SetTemp.php | 11 +
vendor/twig/twig/lib/Twig/Node/Spaceless.php | 11 +
vendor/twig/twig/lib/Twig/Node/Text.php | 11 +
vendor/twig/twig/lib/Twig/Node/With.php | 11 +
.../twig/lib/Twig/NodeCaptureInterface.php | 11 +
vendor/twig/twig/lib/Twig/NodeInterface.php | 34 +
.../twig/lib/Twig/NodeOutputInterface.php | 11 +
vendor/twig/twig/lib/Twig/NodeTraverser.php | 11 +
.../twig/lib/Twig/NodeVisitor/Escaper.php | 11 +
.../twig/lib/Twig/NodeVisitor/Optimizer.php | 11 +
.../lib/Twig/NodeVisitor/SafeAnalysis.php | 11 +
.../twig/lib/Twig/NodeVisitor/Sandbox.php | 11 +
.../twig/lib/Twig/NodeVisitorInterface.php | 11 +
vendor/twig/twig/lib/Twig/Parser.php | 11 +
vendor/twig/twig/lib/Twig/ParserInterface.php | 33 +
.../twig/lib/Twig/Profiler/Dumper/Base.php | 11 +
.../lib/Twig/Profiler/Dumper/Blackfire.php | 11 +
.../twig/lib/Twig/Profiler/Dumper/Html.php | 11 +
.../twig/lib/Twig/Profiler/Dumper/Text.php | 11 +
.../lib/Twig/Profiler/Node/EnterProfile.php | 11 +
.../lib/Twig/Profiler/Node/LeaveProfile.php | 11 +
.../Twig/Profiler/NodeVisitor/Profiler.php | 11 +
.../twig/twig/lib/Twig/Profiler/Profile.php | 11 +
.../twig/lib/Twig/RuntimeLoaderInterface.php | 11 +
.../twig/lib/Twig/Sandbox/SecurityError.php | 11 +
.../Sandbox/SecurityNotAllowedFilterError.php | 11 +
.../SecurityNotAllowedFunctionError.php | 11 +
.../Sandbox/SecurityNotAllowedMethodError.php | 11 +
.../SecurityNotAllowedPropertyError.php | 11 +
.../Sandbox/SecurityNotAllowedTagError.php | 11 +
.../twig/lib/Twig/Sandbox/SecurityPolicy.php | 11 +
.../Twig/Sandbox/SecurityPolicyInterface.php | 11 +
vendor/twig/twig/lib/Twig/SimpleFilter.php | 11 +
vendor/twig/twig/lib/Twig/SimpleFunction.php | 11 +
vendor/twig/twig/lib/Twig/SimpleTest.php | 11 +
vendor/twig/twig/lib/Twig/Source.php | 11 +
.../lib/Twig/SourceContextLoaderInterface.php | 11 +
vendor/twig/twig/lib/Twig/Template.php | 11 +
.../twig/twig/lib/Twig/TemplateInterface.php | 50 +
vendor/twig/twig/lib/Twig/TemplateWrapper.php | 11 +
vendor/twig/twig/lib/Twig/Test.php | 37 +
vendor/twig/twig/lib/Twig/Test/Function.php | 38 +
.../lib/Twig/Test/IntegrationTestCase.php | 11 +
vendor/twig/twig/lib/Twig/Test/Method.php | 42 +
vendor/twig/twig/lib/Twig/Test/Node.php | 40 +
.../twig/twig/lib/Twig/Test/NodeTestCase.php | 11 +
.../twig/lib/Twig/TestCallableInterface.php | 22 +
vendor/twig/twig/lib/Twig/TestInterface.php | 27 +
vendor/twig/twig/lib/Twig/Token.php | 11 +
vendor/twig/twig/lib/Twig/TokenParser.php | 11 +
.../twig/lib/Twig/TokenParser/AutoEscape.php | 11 +
.../twig/twig/lib/Twig/TokenParser/Block.php | 11 +
.../twig/lib/Twig/TokenParser/Deprecated.php | 11 +
vendor/twig/twig/lib/Twig/TokenParser/Do.php | 11 +
.../twig/twig/lib/Twig/TokenParser/Embed.php | 11 +
.../twig/lib/Twig/TokenParser/Extends.php | 11 +
.../twig/twig/lib/Twig/TokenParser/Filter.php | 11 +
.../twig/twig/lib/Twig/TokenParser/Flush.php | 11 +
vendor/twig/twig/lib/Twig/TokenParser/For.php | 11 +
.../twig/twig/lib/Twig/TokenParser/From.php | 11 +
vendor/twig/twig/lib/Twig/TokenParser/If.php | 11 +
.../twig/twig/lib/Twig/TokenParser/Import.php | 11 +
.../twig/lib/Twig/TokenParser/Include.php | 11 +
.../twig/twig/lib/Twig/TokenParser/Macro.php | 11 +
.../twig/lib/Twig/TokenParser/Sandbox.php | 11 +
vendor/twig/twig/lib/Twig/TokenParser/Set.php | 11 +
.../twig/lib/Twig/TokenParser/Spaceless.php | 11 +
vendor/twig/twig/lib/Twig/TokenParser/Use.php | 11 +
.../twig/twig/lib/Twig/TokenParser/With.php | 11 +
.../twig/twig/lib/Twig/TokenParserBroker.php | 122 +
.../lib/Twig/TokenParserBrokerInterface.php | 46 +
.../twig/lib/Twig/TokenParserInterface.php | 11 +
vendor/twig/twig/lib/Twig/TokenStream.php | 11 +
.../lib/Twig/Util/DeprecationCollector.php | 11 +
.../lib/Twig/Util/TemplateDirIterator.php | 11 +
vendor/twig/twig/src/Cache/CacheInterface.php | 60 +
.../twig/twig/src/Cache/FilesystemCache.php | 93 +
vendor/twig/twig/src/Cache/NullCache.php | 42 +
vendor/twig/twig/src/Compiler.php | 288 +
vendor/twig/twig/src/Environment.php | 1638 ++
vendor/twig/twig/src/Error/Error.php | 325 +
vendor/twig/twig/src/Error/LoaderError.php | 23 +
vendor/twig/twig/src/Error/RuntimeError.php | 24 +
vendor/twig/twig/src/Error/SyntaxError.php | 57 +
vendor/twig/twig/src/ExpressionParser.php | 839 +
.../twig/src/Extension/AbstractExtension.php | 72 +
.../twig/twig/src/Extension/CoreExtension.php | 1744 ++
.../twig/src/Extension/DebugExtension.php | 76 +
.../twig/src/Extension/EscaperExtension.php | 120 +
.../twig/src/Extension/ExtensionInterface.php | 101 +
.../twig/src/Extension/GlobalsInterface.php | 26 +
.../src/Extension/InitRuntimeInterface.php | 26 +
.../twig/src/Extension/OptimizerExtension.php | 39 +
.../twig/src/Extension/ProfilerExtension.php | 53 +
.../Extension/RuntimeExtensionInterface.php | 19 +
.../twig/src/Extension/SandboxExtension.php | 109 +
.../twig/src/Extension/StagingExtension.php | 117 +
.../src/Extension/StringLoaderExtension.php | 54 +
.../src/FileExtensionEscapingStrategy.php | 62 +
vendor/twig/twig/src/Lexer.php | 538 +
vendor/twig/twig/src/Loader/ArrayLoader.php | 102 +
vendor/twig/twig/src/Loader/ChainLoader.php | 164 +
.../twig/src/Loader/ExistsLoaderInterface.php | 33 +
.../twig/twig/src/Loader/FilesystemLoader.php | 323 +
.../twig/twig/src/Loader/LoaderInterface.php | 61 +
.../Loader/SourceContextLoaderInterface.php | 38 +
vendor/twig/twig/src/Markup.php | 41 +
vendor/twig/twig/src/Node/AutoEscapeNode.php | 40 +
vendor/twig/twig/src/Node/BlockNode.php | 45 +
.../twig/twig/src/Node/BlockReferenceNode.php | 38 +
vendor/twig/twig/src/Node/BodyNode.php | 23 +
.../twig/twig/src/Node/CheckSecurityNode.php | 85 +
.../twig/twig/src/Node/CheckToStringNode.php | 42 +
vendor/twig/twig/src/Node/DeprecatedNode.php | 55 +
vendor/twig/twig/src/Node/DoNode.php | 40 +
vendor/twig/twig/src/Node/EmbedNode.php | 52 +
.../Node/Expression/AbstractExpression.php | 26 +
.../src/Node/Expression/ArrayExpression.php | 88 +
.../Expression/ArrowFunctionExpression.php | 64 +
.../Node/Expression/AssignNameExpression.php | 29 +
.../Node/Expression/Binary/AbstractBinary.php | 43 +
.../src/Node/Expression/Binary/AddBinary.php | 25 +
.../src/Node/Expression/Binary/AndBinary.php | 25 +
.../Expression/Binary/BitwiseAndBinary.php | 25 +
.../Expression/Binary/BitwiseOrBinary.php | 25 +
.../Expression/Binary/BitwiseXorBinary.php | 25 +
.../Node/Expression/Binary/ConcatBinary.php | 25 +
.../src/Node/Expression/Binary/DivBinary.php | 25 +
.../Node/Expression/Binary/EndsWithBinary.php | 37 +
.../Node/Expression/Binary/EqualBinary.php | 24 +
.../Node/Expression/Binary/FloorDivBinary.php | 31 +
.../Node/Expression/Binary/GreaterBinary.php | 24 +
.../Expression/Binary/GreaterEqualBinary.php | 24 +
.../src/Node/Expression/Binary/InBinary.php | 35 +
.../src/Node/Expression/Binary/LessBinary.php | 24 +
.../Expression/Binary/LessEqualBinary.php | 24 +
.../Node/Expression/Binary/MatchesBinary.php | 35 +
.../src/Node/Expression/Binary/ModBinary.php | 25 +
.../src/Node/Expression/Binary/MulBinary.php | 25 +
.../Node/Expression/Binary/NotEqualBinary.php | 24 +
.../Node/Expression/Binary/NotInBinary.php | 35 +
.../src/Node/Expression/Binary/OrBinary.php | 25 +
.../Node/Expression/Binary/PowerBinary.php | 39 +
.../Node/Expression/Binary/RangeBinary.php | 35 +
.../Expression/Binary/StartsWithBinary.php | 37 +
.../src/Node/Expression/Binary/SubBinary.php | 25 +
.../Expression/BlockReferenceExpression.php | 98 +
.../src/Node/Expression/CallExpression.php | 306 +
.../Node/Expression/ConditionalExpression.php | 38 +
.../Node/Expression/ConstantExpression.php | 30 +
.../Node/Expression/Filter/DefaultFilter.php | 54 +
.../src/Node/Expression/FilterExpression.php | 47 +
.../Node/Expression/FunctionExpression.php | 51 +
.../src/Node/Expression/GetAttrExpression.php | 80 +
.../twig/src/Node/Expression/InlinePrint.php | 35 +
.../Node/Expression/MethodCallExpression.php | 48 +
.../src/Node/Expression/NameExpression.php | 119 +
.../Expression/NullCoalesceExpression.php | 62 +
.../src/Node/Expression/ParentExpression.php | 48 +
.../Node/Expression/TempNameExpression.php | 33 +
.../src/Node/Expression/Test/ConstantTest.php | 51 +
.../src/Node/Expression/Test/DefinedTest.php | 71 +
.../Node/Expression/Test/DivisiblebyTest.php | 38 +
.../src/Node/Expression/Test/EvenTest.php | 37 +
.../src/Node/Expression/Test/NullTest.php | 36 +
.../twig/src/Node/Expression/Test/OddTest.php | 37 +
.../src/Node/Expression/Test/SameasTest.php | 36 +
.../src/Node/Expression/TestExpression.php | 51 +
.../Node/Expression/Unary/AbstractUnary.php | 35 +
.../src/Node/Expression/Unary/NegUnary.php | 25 +
.../src/Node/Expression/Unary/NotUnary.php | 25 +
.../src/Node/Expression/Unary/PosUnary.php | 25 +
vendor/twig/twig/src/Node/FlushNode.php | 37 +
vendor/twig/twig/src/Node/ForLoopNode.php | 56 +
vendor/twig/twig/src/Node/ForNode.php | 119 +
vendor/twig/twig/src/Node/IfNode.php | 72 +
vendor/twig/twig/src/Node/ImportNode.php | 57 +
vendor/twig/twig/src/Node/IncludeNode.php | 108 +
vendor/twig/twig/src/Node/MacroNode.php | 136 +
vendor/twig/twig/src/Node/ModuleNode.php | 492 +
vendor/twig/twig/src/Node/Node.php | 274 +
.../twig/src/Node/NodeCaptureInterface.php | 23 +
.../twig/src/Node/NodeOutputInterface.php | 23 +
vendor/twig/twig/src/Node/PrintNode.php | 41 +
vendor/twig/twig/src/Node/SandboxNode.php | 54 +
.../twig/twig/src/Node/SandboxedPrintNode.php | 69 +
vendor/twig/twig/src/Node/SetNode.php | 107 +
vendor/twig/twig/src/Node/SetTempNode.php | 44 +
vendor/twig/twig/src/Node/SpacelessNode.php | 47 +
vendor/twig/twig/src/Node/TextNode.php | 40 +
vendor/twig/twig/src/Node/WithNode.php | 72 +
vendor/twig/twig/src/NodeTraverser.php | 89 +
.../src/NodeVisitor/AbstractNodeVisitor.php | 59 +
.../src/NodeVisitor/EscaperNodeVisitor.php | 209 +
.../src/NodeVisitor/NodeVisitorInterface.php | 50 +
.../src/NodeVisitor/OptimizerNodeVisitor.php | 273 +
.../NodeVisitor/SafeAnalysisNodeVisitor.php | 164 +
.../src/NodeVisitor/SandboxNodeVisitor.php | 137 +
vendor/twig/twig/src/Parser.php | 439 +
.../twig/src/Profiler/Dumper/BaseDumper.php | 65 +
.../src/Profiler/Dumper/BlackfireDumper.php | 76 +
.../twig/src/Profiler/Dumper/HtmlDumper.php | 51 +
.../twig/src/Profiler/Dumper/TextDumper.php | 39 +
.../src/Profiler/Node/EnterProfileNode.php | 44 +
.../src/Profiler/Node/LeaveProfileNode.php | 38 +
.../NodeVisitor/ProfilerNodeVisitor.php | 80 +
vendor/twig/twig/src/Profiler/Profile.php | 188 +
.../RuntimeLoader/ContainerRuntimeLoader.php | 41 +
.../RuntimeLoader/FactoryRuntimeLoader.php | 41 +
.../RuntimeLoader/RuntimeLoaderInterface.php | 31 +
.../twig/twig/src/Sandbox/SecurityError.php | 25 +
.../Sandbox/SecurityNotAllowedFilterError.php | 35 +
.../SecurityNotAllowedFunctionError.php | 35 +
.../Sandbox/SecurityNotAllowedMethodError.php | 42 +
.../SecurityNotAllowedPropertyError.php | 42 +
.../Sandbox/SecurityNotAllowedTagError.php | 35 +
.../twig/twig/src/Sandbox/SecurityPolicy.php | 129 +
.../src/Sandbox/SecurityPolicyInterface.php | 28 +
vendor/twig/twig/src/Source.php | 55 +
vendor/twig/twig/src/Template.php | 731 +
vendor/twig/twig/src/TemplateWrapper.php | 161 +
.../twig/src/Test/IntegrationTestCase.php | 257 +
vendor/twig/twig/src/Test/NodeTestCase.php | 79 +
vendor/twig/twig/src/Token.php | 215 +
.../src/TokenParser/AbstractTokenParser.php | 34 +
.../twig/src/TokenParser/ApplyTokenParser.php | 58 +
.../src/TokenParser/AutoEscapeTokenParser.php | 88 +
.../twig/src/TokenParser/BlockTokenParser.php | 80 +
.../src/TokenParser/DeprecatedTokenParser.php | 44 +
.../twig/src/TokenParser/DoTokenParser.php | 39 +
.../twig/src/TokenParser/EmbedTokenParser.php | 74 +
.../src/TokenParser/ExtendsTokenParser.php | 54 +
.../src/TokenParser/FilterTokenParser.php | 59 +
.../twig/src/TokenParser/FlushTokenParser.php | 39 +
.../twig/src/TokenParser/ForTokenParser.php | 136 +
.../twig/src/TokenParser/FromTokenParser.php | 72 +
.../twig/src/TokenParser/IfTokenParser.php | 91 +
.../src/TokenParser/ImportTokenParser.php | 45 +
.../src/TokenParser/IncludeTokenParser.php | 68 +
.../twig/src/TokenParser/MacroTokenParser.php | 68 +
.../src/TokenParser/SandboxTokenParser.php | 67 +
.../twig/src/TokenParser/SetTokenParser.php | 74 +
.../src/TokenParser/SpacelessTokenParser.php | 53 +
.../src/TokenParser/TokenParserInterface.php | 51 +
.../twig/src/TokenParser/UseTokenParser.php | 75 +
.../twig/src/TokenParser/WithTokenParser.php | 57 +
vendor/twig/twig/src/TokenStream.php | 201 +
vendor/twig/twig/src/TwigFilter.php | 128 +
vendor/twig/twig/src/TwigFunction.php | 118 +
vendor/twig/twig/src/TwigTest.php | 87 +
.../twig/src/Util/DeprecationCollector.php | 92 +
.../twig/src/Util/TemplateDirIterator.php | 30 +
vendor/willdurand/negotiation/CONTRIBUTING.md | 33 +
vendor/willdurand/negotiation/LICENSE | 19 +
vendor/willdurand/negotiation/README.md | 162 +
.../src/Negotiation/AbstractNegotiator.php | 118 +
.../negotiation/src/Negotiation/Accept.php | 46 +
.../src/Negotiation/AcceptCharset.php | 7 +
.../src/Negotiation/AcceptEncoding.php | 7 +
.../src/Negotiation/AcceptHeader.php | 7 +
.../src/Negotiation/AcceptLanguage.php | 49 +
.../src/Negotiation/BaseAccept.php | 154 +
.../src/Negotiation/CharsetNegotiator.php | 14 +
.../src/Negotiation/EncodingNegotiator.php | 14 +
.../src/Negotiation/Exception/Exception.php | 7 +
.../Negotiation/Exception/InvalidArgument.php | 7 +
.../Negotiation/Exception/InvalidHeader.php | 7 +
.../Negotiation/Exception/InvalidLanguage.php | 7 +
.../Exception/InvalidMediaType.php | 7 +
.../src/Negotiation/LanguageNegotiator.php | 41 +
.../negotiation/src/Negotiation/Match.php | 62 +
.../src/Negotiation/Negotiator.php | 89 +
webserver-configs/Caddyfile | 24 +
webserver-configs/Caddyfile-0.8.x | 33 +
webserver-configs/htaccess.txt | 75 +
webserver-configs/lighttpd.conf | 48 +
webserver-configs/nginx.conf | 44 +
webserver-configs/web.config | 42 +
4183 files changed, 488526 insertions(+)
create mode 100644 .github/FUNDING.yml
create mode 100644 .htaccess
create mode 100644 CHANGELOG.md
create mode 100644 CODE_OF_CONDUCT.md
create mode 100644 CONTRIBUTING.md
create mode 100644 LICENSE.txt
create mode 100644 README.md
create mode 100644 assets/.gitkeep
create mode 100644 backup/.gitkeep
create mode 100755 bin/composer.phar
create mode 100755 bin/gpm
create mode 100755 bin/grav
create mode 100755 bin/plugin
create mode 100644 cache/.gitkeep
create mode 100644 composer.json
create mode 100644 composer.lock
create mode 100644 images/.gitkeep
create mode 100644 index.php
create mode 100644 logs/.gitkeep
create mode 100644 now.json
create mode 100644 robots.txt
create mode 100644 system/aliases.php
create mode 100644 system/assets/debugger.css
create mode 100644 system/assets/grav.png
create mode 100644 system/assets/jquery/jquery-2.1.4.min.js
create mode 100644 system/assets/jquery/jquery-2.x.min.js
create mode 100644 system/assets/jquery/jquery-3.x.min.js
create mode 100644 system/assets/responsive-overlays/1x.png
create mode 100644 system/assets/responsive-overlays/2x.png
create mode 100644 system/assets/responsive-overlays/3x.png
create mode 100644 system/assets/responsive-overlays/4x.png
create mode 100644 system/assets/responsive-overlays/unknown.png
create mode 100644 system/assets/whoops.css
create mode 100644 system/blueprints/config/backups.yaml
create mode 100644 system/blueprints/config/media.yaml
create mode 100644 system/blueprints/config/scheduler.yaml
create mode 100644 system/blueprints/config/security.yaml
create mode 100644 system/blueprints/config/site.yaml
create mode 100644 system/blueprints/config/streams.yaml
create mode 100644 system/blueprints/config/system.yaml
create mode 100644 system/blueprints/pages/default.yaml
create mode 100644 system/blueprints/pages/external.yaml
create mode 100644 system/blueprints/pages/modular.yaml
create mode 100644 system/blueprints/user/account.yaml
create mode 100644 system/blueprints/user/account_new.yaml
create mode 100644 system/blueprints/user/accounts.yaml
create mode 100644 system/blueprints/user/group.yaml
create mode 100644 system/blueprints/user/group_new.yaml
create mode 100644 system/config/backups.yaml
create mode 100644 system/config/media.yaml
create mode 100644 system/config/security.yaml
create mode 100644 system/config/site.yaml
create mode 100644 system/config/streams.yaml
create mode 100644 system/config/system.yaml
create mode 100644 system/defines.php
create mode 100644 system/images/media/thumb-3dm.png
create mode 100644 system/images/media/thumb-3ds.png
create mode 100644 system/images/media/thumb-3g2.png
create mode 100644 system/images/media/thumb-3gp.png
create mode 100644 system/images/media/thumb-7z.png
create mode 100644 system/images/media/thumb-aac.png
create mode 100644 system/images/media/thumb-ai.png
create mode 100644 system/images/media/thumb-aif.png
create mode 100644 system/images/media/thumb-apk.png
create mode 100644 system/images/media/thumb-app.png
create mode 100644 system/images/media/thumb-asf.png
create mode 100644 system/images/media/thumb-asp.png
create mode 100644 system/images/media/thumb-aspx.png
create mode 100644 system/images/media/thumb-asx.png
create mode 100644 system/images/media/thumb-avi.png
create mode 100644 system/images/media/thumb-bak.png
create mode 100644 system/images/media/thumb-bat.png
create mode 100644 system/images/media/thumb-bin.png
create mode 100644 system/images/media/thumb-bmp.png
create mode 100644 system/images/media/thumb-cab.png
create mode 100644 system/images/media/thumb-cad.png
create mode 100644 system/images/media/thumb-cdr.png
create mode 100644 system/images/media/thumb-cer.png
create mode 100644 system/images/media/thumb-cfg.png
create mode 100644 system/images/media/thumb-cfm.png
create mode 100644 system/images/media/thumb-cgi.png
create mode 100644 system/images/media/thumb-com.png
create mode 100644 system/images/media/thumb-cpl.png
create mode 100644 system/images/media/thumb-cpp.png
create mode 100644 system/images/media/thumb-crx.png
create mode 100644 system/images/media/thumb-csr.png
create mode 100644 system/images/media/thumb-css.png
create mode 100644 system/images/media/thumb-csv.png
create mode 100644 system/images/media/thumb-cue.png
create mode 100644 system/images/media/thumb-cur.png
create mode 100644 system/images/media/thumb-dat.png
create mode 100644 system/images/media/thumb-db.png
create mode 100644 system/images/media/thumb-dbf.png
create mode 100644 system/images/media/thumb-dds.png
create mode 100644 system/images/media/thumb-dem.png
create mode 100644 system/images/media/thumb-dll.png
create mode 100644 system/images/media/thumb-dmg.png
create mode 100644 system/images/media/thumb-dmp.png
create mode 100644 system/images/media/thumb-doc.png
create mode 100644 system/images/media/thumb-docx.png
create mode 100644 system/images/media/thumb-drv.png
create mode 100644 system/images/media/thumb-dtd.png
create mode 100644 system/images/media/thumb-dwg.png
create mode 100644 system/images/media/thumb-dxf.png
create mode 100644 system/images/media/thumb-elf.png
create mode 100644 system/images/media/thumb-eot.png
create mode 100644 system/images/media/thumb-eps.png
create mode 100644 system/images/media/thumb-exe.png
create mode 100644 system/images/media/thumb-fla.png
create mode 100644 system/images/media/thumb-flv.png
create mode 100644 system/images/media/thumb-fnt.png
create mode 100644 system/images/media/thumb-fon.png
create mode 100644 system/images/media/thumb-gam.png
create mode 100644 system/images/media/thumb-gbr.png
create mode 100644 system/images/media/thumb-ged.png
create mode 100644 system/images/media/thumb-gif.png
create mode 100644 system/images/media/thumb-gpx.png
create mode 100644 system/images/media/thumb-gz.png
create mode 100644 system/images/media/thumb-gzip.png
create mode 100644 system/images/media/thumb-hqz.png
create mode 100644 system/images/media/thumb-html.png
create mode 100644 system/images/media/thumb-icns.png
create mode 100644 system/images/media/thumb-ico.png
create mode 100644 system/images/media/thumb-ics.png
create mode 100644 system/images/media/thumb-iff.png
create mode 100644 system/images/media/thumb-indd.png
create mode 100644 system/images/media/thumb-iso.png
create mode 100644 system/images/media/thumb-jar.png
create mode 100644 system/images/media/thumb-jpg.png
create mode 100644 system/images/media/thumb-js.png
create mode 100644 system/images/media/thumb-json.png
create mode 100644 system/images/media/thumb-jsp.png
create mode 100644 system/images/media/thumb-key.png
create mode 100644 system/images/media/thumb-kml.png
create mode 100644 system/images/media/thumb-kmz.png
create mode 100644 system/images/media/thumb-lnk.png
create mode 100644 system/images/media/thumb-log.png
create mode 100644 system/images/media/thumb-lua.png
create mode 100644 system/images/media/thumb-m3u.png
create mode 100644 system/images/media/thumb-m4a.png
create mode 100644 system/images/media/thumb-m4v.png
create mode 100644 system/images/media/thumb-max.png
create mode 100644 system/images/media/thumb-mdb.png
create mode 100644 system/images/media/thumb-mdf.png
create mode 100644 system/images/media/thumb-mid.png
create mode 100644 system/images/media/thumb-mim.png
create mode 100644 system/images/media/thumb-mov.png
create mode 100644 system/images/media/thumb-mp3.png
create mode 100644 system/images/media/thumb-mp4.png
create mode 100644 system/images/media/thumb-mpa.png
create mode 100644 system/images/media/thumb-mpe.png
create mode 100644 system/images/media/thumb-mpg.png
create mode 100644 system/images/media/thumb-msg.png
create mode 100644 system/images/media/thumb-msi.png
create mode 100644 system/images/media/thumb-nes.png
create mode 100644 system/images/media/thumb-obj.png
create mode 100644 system/images/media/thumb-odb.png
create mode 100644 system/images/media/thumb-odc.png
create mode 100644 system/images/media/thumb-odf.png
create mode 100644 system/images/media/thumb-odg.png
create mode 100644 system/images/media/thumb-odi.png
create mode 100644 system/images/media/thumb-odp.png
create mode 100644 system/images/media/thumb-ods.png
create mode 100644 system/images/media/thumb-odt.png
create mode 100644 system/images/media/thumb-odx.png
create mode 100644 system/images/media/thumb-ogg.png
create mode 100644 system/images/media/thumb-pct.png
create mode 100644 system/images/media/thumb-pdb.png
create mode 100644 system/images/media/thumb-pdf.png
create mode 100644 system/images/media/thumb-pif.png
create mode 100644 system/images/media/thumb-pkg.png
create mode 100644 system/images/media/thumb-pl.png
create mode 100644 system/images/media/thumb-png.png
create mode 100644 system/images/media/thumb-pps.png
create mode 100644 system/images/media/thumb-ppt.png
create mode 100644 system/images/media/thumb-pptx.png
create mode 100644 system/images/media/thumb-ps.png
create mode 100644 system/images/media/thumb-psd.png
create mode 100644 system/images/media/thumb-pub.png
create mode 100644 system/images/media/thumb-py.png
create mode 100644 system/images/media/thumb-ra.png
create mode 100644 system/images/media/thumb-rar.png
create mode 100644 system/images/media/thumb-raw.png
create mode 100644 system/images/media/thumb-rm.png
create mode 100644 system/images/media/thumb-rom.png
create mode 100644 system/images/media/thumb-rpm.png
create mode 100644 system/images/media/thumb-rss.png
create mode 100644 system/images/media/thumb-rtf.png
create mode 100644 system/images/media/thumb-sav.png
create mode 100644 system/images/media/thumb-sdf.png
create mode 100644 system/images/media/thumb-sql.png
create mode 100644 system/images/media/thumb-srt.png
create mode 100644 system/images/media/thumb-svg.png
create mode 100644 system/images/media/thumb-swf.png
create mode 100644 system/images/media/thumb-sys.png
create mode 100644 system/images/media/thumb-tar.png
create mode 100644 system/images/media/thumb-tex.png
create mode 100644 system/images/media/thumb-tga.png
create mode 100644 system/images/media/thumb-thm.png
create mode 100644 system/images/media/thumb-tiff.png
create mode 100644 system/images/media/thumb-tmp.png
create mode 100644 system/images/media/thumb-ttf.png
create mode 100644 system/images/media/thumb-txt.png
create mode 100644 system/images/media/thumb-uue.png
create mode 100644 system/images/media/thumb-vb.png
create mode 100644 system/images/media/thumb-vcd.png
create mode 100644 system/images/media/thumb-vcf.png
create mode 100644 system/images/media/thumb-wav.png
create mode 100644 system/images/media/thumb-webm.png
create mode 100644 system/images/media/thumb-wma.png
create mode 100644 system/images/media/thumb-wmv.png
create mode 100644 system/images/media/thumb-woff.png
create mode 100644 system/images/media/thumb-woff2.png
create mode 100644 system/images/media/thumb-wpd.png
create mode 100644 system/images/media/thumb-wps.png
create mode 100644 system/images/media/thumb-wsf.png
create mode 100644 system/images/media/thumb-xls.png
create mode 100644 system/images/media/thumb-xlsx.png
create mode 100644 system/images/media/thumb-xml.png
create mode 100644 system/images/media/thumb-yuv.png
create mode 100644 system/images/media/thumb-zip.png
create mode 100644 system/images/media/thumb.png
create mode 100644 system/install.php
create mode 100644 system/languages/ar.yaml
create mode 100644 system/languages/bg.yaml
create mode 100644 system/languages/ca.yaml
create mode 100644 system/languages/cs.yaml
create mode 100644 system/languages/da.yaml
create mode 100644 system/languages/de.yaml
create mode 100644 system/languages/el.yaml
create mode 100644 system/languages/en.yaml
create mode 100644 system/languages/es.yaml
create mode 100644 system/languages/et.yaml
create mode 100644 system/languages/eu.yaml
create mode 100644 system/languages/fa.yaml
create mode 100644 system/languages/fi.yaml
create mode 100644 system/languages/fr.yaml
create mode 100644 system/languages/he.yaml
create mode 100644 system/languages/hr.yaml
create mode 100644 system/languages/hu.yaml
create mode 100644 system/languages/id.yaml
create mode 100644 system/languages/is.yaml
create mode 100644 system/languages/it.yaml
create mode 100644 system/languages/ja.yaml
create mode 100644 system/languages/ko.yaml
create mode 100644 system/languages/lt.yaml
create mode 100644 system/languages/nb.yaml
create mode 100644 system/languages/nl.yaml
create mode 100644 system/languages/no.yaml
create mode 100644 system/languages/pl.yaml
create mode 100644 system/languages/pt.yaml
create mode 100644 system/languages/ro.yaml
create mode 100644 system/languages/ru.yaml
create mode 100644 system/languages/sk.yaml
create mode 100644 system/languages/sl.yaml
create mode 100644 system/languages/sv.yaml
create mode 100644 system/languages/th.yaml
create mode 100644 system/languages/tr.yaml
create mode 100644 system/languages/uk.yaml
create mode 100644 system/languages/vi.yaml
create mode 100644 system/languages/zh-tw.yaml
create mode 100644 system/languages/zh.yaml
create mode 100644 system/pages/notfound.md
create mode 100644 system/router.php
create mode 100644 system/src/Grav/Common/Assets.php
create mode 100644 system/src/Grav/Common/Assets/BaseAsset.php
create mode 100644 system/src/Grav/Common/Assets/Css.php
create mode 100644 system/src/Grav/Common/Assets/InlineCss.php
create mode 100644 system/src/Grav/Common/Assets/InlineJs.php
create mode 100644 system/src/Grav/Common/Assets/Js.php
create mode 100644 system/src/Grav/Common/Assets/Pipeline.php
create mode 100644 system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
create mode 100644 system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
create mode 100644 system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php
create mode 100644 system/src/Grav/Common/Backup/Backups.php
create mode 100644 system/src/Grav/Common/Browser.php
create mode 100644 system/src/Grav/Common/Cache.php
create mode 100644 system/src/Grav/Common/Composer.php
create mode 100644 system/src/Grav/Common/Config/CompiledBase.php
create mode 100644 system/src/Grav/Common/Config/CompiledBlueprints.php
create mode 100644 system/src/Grav/Common/Config/CompiledConfig.php
create mode 100644 system/src/Grav/Common/Config/CompiledLanguages.php
create mode 100644 system/src/Grav/Common/Config/Config.php
create mode 100644 system/src/Grav/Common/Config/ConfigFileFinder.php
create mode 100644 system/src/Grav/Common/Config/Languages.php
create mode 100644 system/src/Grav/Common/Config/Setup.php
create mode 100644 system/src/Grav/Common/Data/Blueprint.php
create mode 100644 system/src/Grav/Common/Data/BlueprintSchema.php
create mode 100644 system/src/Grav/Common/Data/Blueprints.php
create mode 100644 system/src/Grav/Common/Data/Data.php
create mode 100644 system/src/Grav/Common/Data/DataInterface.php
create mode 100644 system/src/Grav/Common/Data/Validation.php
create mode 100644 system/src/Grav/Common/Data/ValidationException.php
create mode 100644 system/src/Grav/Common/Debugger.php
create mode 100644 system/src/Grav/Common/Errors/BareHandler.php
create mode 100644 system/src/Grav/Common/Errors/Errors.php
create mode 100644 system/src/Grav/Common/Errors/Resources/error.css
create mode 100644 system/src/Grav/Common/Errors/Resources/layout.html.php
create mode 100644 system/src/Grav/Common/Errors/SimplePageHandler.php
create mode 100644 system/src/Grav/Common/Errors/SystemFacade.php
create mode 100644 system/src/Grav/Common/File/CompiledFile.php
create mode 100644 system/src/Grav/Common/File/CompiledJsonFile.php
create mode 100644 system/src/Grav/Common/File/CompiledMarkdownFile.php
create mode 100644 system/src/Grav/Common/File/CompiledYamlFile.php
create mode 100644 system/src/Grav/Common/Filesystem/Archiver.php
create mode 100644 system/src/Grav/Common/Filesystem/Folder.php
create mode 100644 system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php
create mode 100644 system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php
create mode 100644 system/src/Grav/Common/Filesystem/ZipArchiver.php
create mode 100644 system/src/Grav/Common/Form/FormFlash.php
create mode 100644 system/src/Grav/Common/GPM/AbstractCollection.php
create mode 100644 system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php
create mode 100644 system/src/Grav/Common/GPM/Common/CachedCollection.php
create mode 100644 system/src/Grav/Common/GPM/Common/Package.php
create mode 100644 system/src/Grav/Common/GPM/GPM.php
create mode 100644 system/src/Grav/Common/GPM/Installer.php
create mode 100644 system/src/Grav/Common/GPM/Licenses.php
create mode 100644 system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php
create mode 100644 system/src/Grav/Common/GPM/Local/Package.php
create mode 100644 system/src/Grav/Common/GPM/Local/Packages.php
create mode 100644 system/src/Grav/Common/GPM/Local/Plugins.php
create mode 100644 system/src/Grav/Common/GPM/Local/Themes.php
create mode 100644 system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php
create mode 100644 system/src/Grav/Common/GPM/Remote/GravCore.php
create mode 100644 system/src/Grav/Common/GPM/Remote/Package.php
create mode 100644 system/src/Grav/Common/GPM/Remote/Packages.php
create mode 100644 system/src/Grav/Common/GPM/Remote/Plugins.php
create mode 100644 system/src/Grav/Common/GPM/Remote/Themes.php
create mode 100644 system/src/Grav/Common/GPM/Response.php
create mode 100644 system/src/Grav/Common/GPM/Upgrader.php
create mode 100644 system/src/Grav/Common/Getters.php
create mode 100644 system/src/Grav/Common/Grav.php
create mode 100644 system/src/Grav/Common/GravTrait.php
create mode 100644 system/src/Grav/Common/Helpers/Base32.php
create mode 100644 system/src/Grav/Common/Helpers/Excerpts.php
create mode 100644 system/src/Grav/Common/Helpers/Exif.php
create mode 100644 system/src/Grav/Common/Helpers/LogViewer.php
create mode 100644 system/src/Grav/Common/Helpers/Truncator.php
create mode 100644 system/src/Grav/Common/Helpers/YamlLinter.php
create mode 100644 system/src/Grav/Common/Inflector.php
create mode 100644 system/src/Grav/Common/Iterator.php
create mode 100644 system/src/Grav/Common/Language/Language.php
create mode 100644 system/src/Grav/Common/Language/LanguageCodes.php
create mode 100644 system/src/Grav/Common/Markdown/Parsedown.php
create mode 100644 system/src/Grav/Common/Markdown/ParsedownExtra.php
create mode 100644 system/src/Grav/Common/Markdown/ParsedownGravTrait.php
create mode 100644 system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php
create mode 100644 system/src/Grav/Common/Media/Interfaces/MediaInterface.php
create mode 100644 system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php
create mode 100644 system/src/Grav/Common/Media/Traits/MediaTrait.php
create mode 100644 system/src/Grav/Common/Page/Collection.php
create mode 100644 system/src/Grav/Common/Page/Header.php
create mode 100644 system/src/Grav/Common/Page/Interfaces/PageContentInterface.php
create mode 100644 system/src/Grav/Common/Page/Interfaces/PageInterface.php
create mode 100644 system/src/Grav/Common/Page/Interfaces/PageLegacyInterface.php
create mode 100644 system/src/Grav/Common/Page/Interfaces/PageRoutableInterface.php
create mode 100644 system/src/Grav/Common/Page/Interfaces/PageTranslateInterface.php
create mode 100644 system/src/Grav/Common/Page/Markdown/Excerpts.php
create mode 100644 system/src/Grav/Common/Page/Media.php
create mode 100644 system/src/Grav/Common/Page/Medium/AbstractMedia.php
create mode 100644 system/src/Grav/Common/Page/Medium/AudioMedium.php
create mode 100644 system/src/Grav/Common/Page/Medium/GlobalMedia.php
create mode 100644 system/src/Grav/Common/Page/Medium/ImageFile.php
create mode 100644 system/src/Grav/Common/Page/Medium/ImageMedium.php
create mode 100644 system/src/Grav/Common/Page/Medium/Link.php
create mode 100644 system/src/Grav/Common/Page/Medium/Medium.php
create mode 100644 system/src/Grav/Common/Page/Medium/MediumFactory.php
create mode 100644 system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php
create mode 100644 system/src/Grav/Common/Page/Medium/RenderableInterface.php
create mode 100644 system/src/Grav/Common/Page/Medium/StaticImageMedium.php
create mode 100644 system/src/Grav/Common/Page/Medium/StaticResizeTrait.php
create mode 100644 system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php
create mode 100644 system/src/Grav/Common/Page/Medium/VideoMedium.php
create mode 100644 system/src/Grav/Common/Page/Page.php
create mode 100644 system/src/Grav/Common/Page/Pages.php
create mode 100644 system/src/Grav/Common/Page/Types.php
create mode 100644 system/src/Grav/Common/Plugin.php
create mode 100644 system/src/Grav/Common/Plugins.php
create mode 100644 system/src/Grav/Common/Processors/AssetsProcessor.php
create mode 100644 system/src/Grav/Common/Processors/BackupsProcessor.php
create mode 100644 system/src/Grav/Common/Processors/ConfigurationProcessor.php
create mode 100644 system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php
create mode 100644 system/src/Grav/Common/Processors/DebuggerProcessor.php
create mode 100644 system/src/Grav/Common/Processors/ErrorsProcessor.php
create mode 100644 system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php
create mode 100644 system/src/Grav/Common/Processors/InitializeProcessor.php
create mode 100644 system/src/Grav/Common/Processors/LoggerProcessor.php
create mode 100644 system/src/Grav/Common/Processors/PagesProcessor.php
create mode 100644 system/src/Grav/Common/Processors/PluginsProcessor.php
create mode 100644 system/src/Grav/Common/Processors/ProcessorBase.php
create mode 100644 system/src/Grav/Common/Processors/ProcessorInterface.php
create mode 100644 system/src/Grav/Common/Processors/RenderProcessor.php
create mode 100644 system/src/Grav/Common/Processors/RequestProcessor.php
create mode 100644 system/src/Grav/Common/Processors/SchedulerProcessor.php
create mode 100644 system/src/Grav/Common/Processors/TasksProcessor.php
create mode 100644 system/src/Grav/Common/Processors/ThemesProcessor.php
create mode 100644 system/src/Grav/Common/Processors/TwigProcessor.php
create mode 100644 system/src/Grav/Common/Scheduler/Cron.php
create mode 100644 system/src/Grav/Common/Scheduler/IntervalTrait.php
create mode 100644 system/src/Grav/Common/Scheduler/Job.php
create mode 100644 system/src/Grav/Common/Scheduler/Scheduler.php
create mode 100644 system/src/Grav/Common/Security.php
create mode 100644 system/src/Grav/Common/Service/AccountsServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/AssetsServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/BackupsServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/ConfigServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/ErrorServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/FilesystemServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/InflectorServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/LoggerServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/OutputServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/PagesServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/RequestServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/SchedulerServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/SessionServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/StreamsServiceProvider.php
create mode 100644 system/src/Grav/Common/Service/TaskServiceProvider.php
create mode 100644 system/src/Grav/Common/Session.php
create mode 100644 system/src/Grav/Common/Taxonomy.php
create mode 100644 system/src/Grav/Common/Theme.php
create mode 100644 system/src/Grav/Common/Themes.php
create mode 100644 system/src/Grav/Common/Twig/Node/TwigNodeCache.php
create mode 100644 system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php
create mode 100644 system/src/Grav/Common/Twig/Node/TwigNodeRender.php
create mode 100644 system/src/Grav/Common/Twig/Node/TwigNodeScript.php
create mode 100644 system/src/Grav/Common/Twig/Node/TwigNodeStyle.php
create mode 100644 system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php
create mode 100644 system/src/Grav/Common/Twig/Node/TwigNodeThrow.php
create mode 100644 system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php
create mode 100644 system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php
create mode 100644 system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php
create mode 100644 system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php
create mode 100644 system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php
create mode 100644 system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php
create mode 100644 system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php
create mode 100644 system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php
create mode 100644 system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php
create mode 100644 system/src/Grav/Common/Twig/Twig.php
create mode 100644 system/src/Grav/Common/Twig/TwigEnvironment.php
create mode 100644 system/src/Grav/Common/Twig/TwigExtension.php
create mode 100644 system/src/Grav/Common/Twig/WriteCacheFileTrait.php
create mode 100644 system/src/Grav/Common/Uri.php
create mode 100644 system/src/Grav/Common/User/Authentication.php
create mode 100644 system/src/Grav/Common/User/DataUser/User.php
create mode 100644 system/src/Grav/Common/User/DataUser/UserCollection.php
create mode 100644 system/src/Grav/Common/User/FlexUser/Storage/UserFileStorage.php
create mode 100644 system/src/Grav/Common/User/FlexUser/Storage/UserFolderStorage.php
create mode 100644 system/src/Grav/Common/User/FlexUser/User.php
create mode 100644 system/src/Grav/Common/User/FlexUser/UserCollection.php
create mode 100644 system/src/Grav/Common/User/FlexUser/UserIndex.php
create mode 100644 system/src/Grav/Common/User/Group.php
create mode 100644 system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php
create mode 100644 system/src/Grav/Common/User/Interfaces/UserInterface.php
create mode 100644 system/src/Grav/Common/User/Traits/UserTrait.php
create mode 100644 system/src/Grav/Common/User/User.php
create mode 100644 system/src/Grav/Common/Utils.php
create mode 100644 system/src/Grav/Common/Yaml.php
create mode 100644 system/src/Grav/Console/Cli/BackupCommand.php
create mode 100644 system/src/Grav/Console/Cli/CleanCommand.php
create mode 100644 system/src/Grav/Console/Cli/ClearCacheCommand.php
create mode 100644 system/src/Grav/Console/Cli/ComposerCommand.php
create mode 100644 system/src/Grav/Console/Cli/InstallCommand.php
create mode 100644 system/src/Grav/Console/Cli/LogViewerCommand.php
create mode 100644 system/src/Grav/Console/Cli/NewProjectCommand.php
create mode 100644 system/src/Grav/Console/Cli/SandboxCommand.php
create mode 100644 system/src/Grav/Console/Cli/SchedulerCommand.php
create mode 100644 system/src/Grav/Console/Cli/SecurityCommand.php
create mode 100644 system/src/Grav/Console/Cli/YamlLinterCommand.php
create mode 100644 system/src/Grav/Console/ConsoleCommand.php
create mode 100644 system/src/Grav/Console/ConsoleTrait.php
create mode 100644 system/src/Grav/Console/Gpm/DirectInstallCommand.php
create mode 100644 system/src/Grav/Console/Gpm/IndexCommand.php
create mode 100644 system/src/Grav/Console/Gpm/InfoCommand.php
create mode 100644 system/src/Grav/Console/Gpm/InstallCommand.php
create mode 100644 system/src/Grav/Console/Gpm/SelfupgradeCommand.php
create mode 100644 system/src/Grav/Console/Gpm/UninstallCommand.php
create mode 100644 system/src/Grav/Console/Gpm/UpdateCommand.php
create mode 100644 system/src/Grav/Console/Gpm/VersionCommand.php
create mode 100644 system/src/Grav/Console/TerminalObjects/Table.php
create mode 100644 system/src/Grav/Framework/Cache/AbstractCache.php
create mode 100644 system/src/Grav/Framework/Cache/Adapter/ChainCache.php
create mode 100644 system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
create mode 100644 system/src/Grav/Framework/Cache/Adapter/FileCache.php
create mode 100644 system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
create mode 100644 system/src/Grav/Framework/Cache/Adapter/SessionCache.php
create mode 100644 system/src/Grav/Framework/Cache/CacheInterface.php
create mode 100644 system/src/Grav/Framework/Cache/CacheTrait.php
create mode 100644 system/src/Grav/Framework/Cache/Exception/CacheException.php
create mode 100644 system/src/Grav/Framework/Cache/Exception/InvalidArgumentException.php
create mode 100644 system/src/Grav/Framework/Collection/AbstractFileCollection.php
create mode 100644 system/src/Grav/Framework/Collection/AbstractIndexCollection.php
create mode 100644 system/src/Grav/Framework/Collection/AbstractLazyCollection.php
create mode 100644 system/src/Grav/Framework/Collection/ArrayCollection.php
create mode 100644 system/src/Grav/Framework/Collection/CollectionInterface.php
create mode 100644 system/src/Grav/Framework/Collection/FileCollection.php
create mode 100644 system/src/Grav/Framework/Collection/FileCollectionInterface.php
create mode 100644 system/src/Grav/Framework/ContentBlock/ContentBlock.php
create mode 100644 system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
create mode 100644 system/src/Grav/Framework/ContentBlock/HtmlBlock.php
create mode 100644 system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php
create mode 100644 system/src/Grav/Framework/DI/Container.php
create mode 100644 system/src/Grav/Framework/File/AbstractFile.php
create mode 100644 system/src/Grav/Framework/File/CsvFile.php
create mode 100644 system/src/Grav/Framework/File/DataFile.php
create mode 100644 system/src/Grav/Framework/File/File.php
create mode 100644 system/src/Grav/Framework/File/Formatter/AbstractFormatter.php
create mode 100644 system/src/Grav/Framework/File/Formatter/CsvFormatter.php
create mode 100644 system/src/Grav/Framework/File/Formatter/FormatterInterface.php
create mode 100644 system/src/Grav/Framework/File/Formatter/IniFormatter.php
create mode 100644 system/src/Grav/Framework/File/Formatter/JsonFormatter.php
create mode 100644 system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php
create mode 100644 system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
create mode 100644 system/src/Grav/Framework/File/Formatter/YamlFormatter.php
create mode 100644 system/src/Grav/Framework/File/IniFile.php
create mode 100644 system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php
create mode 100644 system/src/Grav/Framework/File/Interfaces/FileInterface.php
create mode 100644 system/src/Grav/Framework/File/JsonFile.php
create mode 100644 system/src/Grav/Framework/File/MarkdownFile.php
create mode 100644 system/src/Grav/Framework/File/YamlFile.php
create mode 100644 system/src/Grav/Framework/Filesystem/Filesystem.php
create mode 100644 system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
create mode 100644 system/src/Grav/Framework/Flex/Flex.php
create mode 100644 system/src/Grav/Framework/Flex/FlexCollection.php
create mode 100644 system/src/Grav/Framework/Flex/FlexDirectory.php
create mode 100644 system/src/Grav/Framework/Flex/FlexForm.php
create mode 100644 system/src/Grav/Framework/Flex/FlexIndex.php
create mode 100644 system/src/Grav/Framework/Flex/FlexObject.php
create mode 100644 system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php
create mode 100644 system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php
create mode 100644 system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php
create mode 100644 system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php
create mode 100644 system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php
create mode 100644 system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
create mode 100644 system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php
create mode 100644 system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php
create mode 100644 system/src/Grav/Framework/Flex/Storage/FileStorage.php
create mode 100644 system/src/Grav/Framework/Flex/Storage/FolderStorage.php
create mode 100644 system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
create mode 100644 system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php
create mode 100644 system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
create mode 100644 system/src/Grav/Framework/Form/FormFlash.php
create mode 100644 system/src/Grav/Framework/Form/FormFlashFile.php
create mode 100644 system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php
create mode 100644 system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php
create mode 100644 system/src/Grav/Framework/Form/Interfaces/FormInterface.php
create mode 100644 system/src/Grav/Framework/Form/Traits/FormTrait.php
create mode 100644 system/src/Grav/Framework/Interfaces/RenderInterface.php
create mode 100644 system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php
create mode 100644 system/src/Grav/Framework/Media/Interfaces/MediaInterface.php
create mode 100644 system/src/Grav/Framework/Media/Interfaces/MediaManipulationInterface.php
create mode 100644 system/src/Grav/Framework/Media/Interfaces/MediaObjectInterface.php
create mode 100644 system/src/Grav/Framework/Object/Access/ArrayAccessTrait.php
create mode 100644 system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php
create mode 100644 system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php
create mode 100644 system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
create mode 100644 system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php
create mode 100644 system/src/Grav/Framework/Object/ArrayObject.php
create mode 100644 system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php
create mode 100644 system/src/Grav/Framework/Object/Base/ObjectTrait.php
create mode 100644 system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
create mode 100644 system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
create mode 100644 system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php
create mode 100644 system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php
create mode 100644 system/src/Grav/Framework/Object/LazyObject.php
create mode 100644 system/src/Grav/Framework/Object/ObjectCollection.php
create mode 100644 system/src/Grav/Framework/Object/ObjectIndex.php
create mode 100644 system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
create mode 100644 system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php
create mode 100644 system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php
create mode 100644 system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
create mode 100644 system/src/Grav/Framework/Object/PropertyObject.php
create mode 100644 system/src/Grav/Framework/Pagination/AbstractPagination.php
create mode 100644 system/src/Grav/Framework/Pagination/AbstractPaginationPage.php
create mode 100644 system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
create mode 100644 system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php
create mode 100644 system/src/Grav/Framework/Pagination/Pagination.php
create mode 100644 system/src/Grav/Framework/Pagination/PaginationPage.php
create mode 100644 system/src/Grav/Framework/Parsedown/Parsedown.php
create mode 100644 system/src/Grav/Framework/Parsedown/ParsedownExtra.php
create mode 100644 system/src/Grav/Framework/Psr7/AbstractUri.php
create mode 100644 system/src/Grav/Framework/Psr7/Request.php
create mode 100644 system/src/Grav/Framework/Psr7/Response.php
create mode 100644 system/src/Grav/Framework/Psr7/ServerRequest.php
create mode 100644 system/src/Grav/Framework/Psr7/Stream.php
create mode 100644 system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php
create mode 100644 system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php
create mode 100644 system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php
create mode 100644 system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php
create mode 100644 system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php
create mode 100644 system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php
create mode 100644 system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php
create mode 100644 system/src/Grav/Framework/Psr7/UploadedFile.php
create mode 100644 system/src/Grav/Framework/Psr7/Uri.php
create mode 100644 system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php
create mode 100644 system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
create mode 100644 system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php
create mode 100644 system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php
create mode 100644 system/src/Grav/Framework/RequestHandler/Exception/RequestException.php
create mode 100644 system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
create mode 100644 system/src/Grav/Framework/RequestHandler/RequestHandler.php
create mode 100644 system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
create mode 100644 system/src/Grav/Framework/Route/Route.php
create mode 100644 system/src/Grav/Framework/Route/RouteFactory.php
create mode 100644 system/src/Grav/Framework/Session/Exceptions/SessionException.php
create mode 100644 system/src/Grav/Framework/Session/Session.php
create mode 100644 system/src/Grav/Framework/Session/SessionInterface.php
create mode 100644 system/src/Grav/Framework/Uri/Uri.php
create mode 100644 system/src/Grav/Framework/Uri/UriFactory.php
create mode 100644 system/src/Grav/Framework/Uri/UriPartsFilter.php
create mode 100644 system/src/Grav/Installer/Install.php
create mode 100644 system/templates/partials/messages.html.twig
create mode 100644 system/templates/partials/metadata.html.twig
create mode 100644 tmp/.gitkeep
create mode 100644 user/accounts/.gitkeep
create mode 100644 user/config/site.yaml
create mode 100644 user/config/system.yaml
create mode 100644 user/data/.gitkeep
create mode 100644 user/pages/01.home/default.md
create mode 100644 user/pages/02.typography/default.md
create mode 100644 user/plugins/.gitkeep
create mode 100644 user/plugins/admin/.gitattributes
create mode 100644 user/plugins/admin/.github/FUNDING.yml
create mode 100644 user/plugins/admin/CHANGELOG.md
create mode 100644 user/plugins/admin/CONTRIBUTING.md
create mode 100644 user/plugins/admin/LICENSE
create mode 100644 user/plugins/admin/README.md
create mode 100644 user/plugins/admin/admin.php
create mode 100644 user/plugins/admin/admin.yaml
create mode 100644 user/plugins/admin/assets/admin-dashboard.png
create mode 100644 user/plugins/admin/blueprints.yaml
create mode 100644 user/plugins/admin/blueprints/admin/pages/modular_new.yaml
create mode 100644 user/plugins/admin/blueprints/admin/pages/modular_raw.yaml
create mode 100644 user/plugins/admin/blueprints/admin/pages/move.yaml
create mode 100644 user/plugins/admin/blueprints/admin/pages/new.yaml
create mode 100644 user/plugins/admin/blueprints/admin/pages/new_folder.yaml
create mode 100644 user/plugins/admin/blueprints/admin/pages/raw.yaml
create mode 100644 user/plugins/admin/blueprints/config/media.yaml
create mode 100644 user/plugins/admin/classes/Twig/AdminTwigExtension.php
create mode 100644 user/plugins/admin/classes/admin.php
create mode 100644 user/plugins/admin/classes/adminbasecontroller.php
create mode 100644 user/plugins/admin/classes/admincontroller.php
create mode 100644 user/plugins/admin/classes/gpm.php
create mode 100644 user/plugins/admin/classes/popularity.php
create mode 100644 user/plugins/admin/classes/themes.php
create mode 100644 user/plugins/admin/classes/utils.php
create mode 100644 user/plugins/admin/codeception.yml
create mode 100644 user/plugins/admin/composer.json
create mode 100644 user/plugins/admin/composer.lock
create mode 100644 user/plugins/admin/languages/ar.yaml
create mode 100644 user/plugins/admin/languages/bg.yaml
create mode 100644 user/plugins/admin/languages/br.yaml
create mode 100644 user/plugins/admin/languages/ca.yaml
create mode 100644 user/plugins/admin/languages/cs.yaml
create mode 100644 user/plugins/admin/languages/cy.yaml
create mode 100644 user/plugins/admin/languages/da.yaml
create mode 100644 user/plugins/admin/languages/de.yaml
create mode 100644 user/plugins/admin/languages/el.yaml
create mode 100644 user/plugins/admin/languages/en.yaml
create mode 100644 user/plugins/admin/languages/es.yaml
create mode 100644 user/plugins/admin/languages/et.yaml
create mode 100644 user/plugins/admin/languages/eu.yaml
create mode 100644 user/plugins/admin/languages/fa.yaml
create mode 100644 user/plugins/admin/languages/fi.yaml
create mode 100644 user/plugins/admin/languages/fr.yaml
create mode 100644 user/plugins/admin/languages/he.yaml
create mode 100644 user/plugins/admin/languages/hr.yaml
create mode 100644 user/plugins/admin/languages/hu.yaml
create mode 100644 user/plugins/admin/languages/id.yaml
create mode 100644 user/plugins/admin/languages/it.yaml
create mode 100644 user/plugins/admin/languages/ja.yaml
create mode 100644 user/plugins/admin/languages/ko.yaml
create mode 100644 user/plugins/admin/languages/lt.yaml
create mode 100644 user/plugins/admin/languages/nl.yaml
create mode 100644 user/plugins/admin/languages/no.yaml
create mode 100644 user/plugins/admin/languages/pl.yaml
create mode 100644 user/plugins/admin/languages/pt.yaml
create mode 100644 user/plugins/admin/languages/ro.yaml
create mode 100644 user/plugins/admin/languages/ru.yaml
create mode 100644 user/plugins/admin/languages/sk.yaml
create mode 100644 user/plugins/admin/languages/sl.yaml
create mode 100644 user/plugins/admin/languages/sr.yaml
create mode 100644 user/plugins/admin/languages/sv.yaml
create mode 100644 user/plugins/admin/languages/th.yaml
create mode 100644 user/plugins/admin/languages/tlh.yaml
create mode 100644 user/plugins/admin/languages/tr.yaml
create mode 100644 user/plugins/admin/languages/uk.yaml
create mode 100644 user/plugins/admin/languages/vi.yaml
create mode 100644 user/plugins/admin/languages/zh-tw.yaml
create mode 100644 user/plugins/admin/languages/zh.yaml
create mode 100644 user/plugins/admin/pages/admin/ajax.md
create mode 100644 user/plugins/admin/pages/admin/backup.md
create mode 100644 user/plugins/admin/pages/admin/cache.md
create mode 100644 user/plugins/admin/pages/admin/config.md
create mode 100644 user/plugins/admin/pages/admin/dashboard.md
create mode 100644 user/plugins/admin/pages/admin/denied.md
create mode 100644 user/plugins/admin/pages/admin/error.md
create mode 100644 user/plugins/admin/pages/admin/feed.md
create mode 100644 user/plugins/admin/pages/admin/forgot.md
create mode 100644 user/plugins/admin/pages/admin/info.md
create mode 100644 user/plugins/admin/pages/admin/installer.md
create mode 100644 user/plugins/admin/pages/admin/login.md
create mode 100644 user/plugins/admin/pages/admin/media.md
create mode 100644 user/plugins/admin/pages/admin/notifications.md
create mode 100644 user/plugins/admin/pages/admin/pages-filter.md
create mode 100644 user/plugins/admin/pages/admin/pages.md
create mode 100644 user/plugins/admin/pages/admin/plugins.md
create mode 100644 user/plugins/admin/pages/admin/preview.md
create mode 100644 user/plugins/admin/pages/admin/register.md
create mode 100644 user/plugins/admin/pages/admin/reset.md
create mode 100644 user/plugins/admin/pages/admin/site.md
create mode 100644 user/plugins/admin/pages/admin/statistics.md
create mode 100644 user/plugins/admin/pages/admin/system.md
create mode 100644 user/plugins/admin/pages/admin/themes.md
create mode 100644 user/plugins/admin/pages/admin/tools.md
create mode 100644 user/plugins/admin/pages/admin/update.md
create mode 100644 user/plugins/admin/pages/admin/user.md
create mode 100644 user/plugins/admin/tests/_bootstrap.php
create mode 100644 user/plugins/admin/tests/_support/Helper/Unit.php
create mode 100644 user/plugins/admin/tests/_support/UnitTester.php
create mode 100644 user/plugins/admin/tests/unit.suite.yml
create mode 100644 user/plugins/admin/tests/unit/_bootstrap.php
create mode 100644 user/plugins/admin/tests/unit/classes/controllerTest.php
create mode 100644 user/plugins/admin/themes/grav/.eslintrc
create mode 100644 user/plugins/admin/themes/grav/app/dashboard/backup.js
create mode 100644 user/plugins/admin/themes/grav/app/dashboard/cache.js
create mode 100644 user/plugins/admin/themes/grav/app/dashboard/chart.js
create mode 100644 user/plugins/admin/themes/grav/app/dashboard/index.js
create mode 100644 user/plugins/admin/themes/grav/app/dashboard/update.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/array.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/collections.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/colorpicker.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/cron.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/datetime.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/editor.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/editor/buttons.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/filepicker.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/files.js
create mode 100755 user/plugins/admin/themes/grav/app/forms/fields/iconpicker.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/index.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/mediapicker.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/multilevel.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/selectize.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/selectunique.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/fields/text.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/form.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/index.js
create mode 100644 user/plugins/admin/themes/grav/app/forms/state.js
create mode 100644 user/plugins/admin/themes/grav/app/main.js
create mode 100644 user/plugins/admin/themes/grav/app/media/index.js
create mode 100644 user/plugins/admin/themes/grav/app/pages/filter.js
create mode 100644 user/plugins/admin/themes/grav/app/pages/index.js
create mode 100644 user/plugins/admin/themes/grav/app/pages/page/add.js
create mode 100644 user/plugins/admin/themes/grav/app/pages/page/delete.js
create mode 100644 user/plugins/admin/themes/grav/app/pages/page/disable-buttons.js
create mode 100644 user/plugins/admin/themes/grav/app/pages/page/index.js
create mode 100644 user/plugins/admin/themes/grav/app/pages/page/media.js
create mode 100644 user/plugins/admin/themes/grav/app/pages/page/move.js
create mode 100644 user/plugins/admin/themes/grav/app/pages/page/multilang.js
create mode 100644 user/plugins/admin/themes/grav/app/pages/page/unset.js
create mode 100644 user/plugins/admin/themes/grav/app/pages/tree.js
create mode 100644 user/plugins/admin/themes/grav/app/plugins/index.js
create mode 100644 user/plugins/admin/themes/grav/app/themes/index.js
create mode 100644 user/plugins/admin/themes/grav/app/tools/index.js
create mode 100644 user/plugins/admin/themes/grav/app/tools/logs.js
create mode 100644 user/plugins/admin/themes/grav/app/updates/channel-switcher.js
create mode 100644 user/plugins/admin/themes/grav/app/updates/check.js
create mode 100644 user/plugins/admin/themes/grav/app/updates/feed.js
create mode 100644 user/plugins/admin/themes/grav/app/updates/index.js
create mode 100644 user/plugins/admin/themes/grav/app/updates/notifications.js
create mode 100644 user/plugins/admin/themes/grav/app/updates/update.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/2fa.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/bootstrap-collapse.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/bootstrap-transition.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/colors.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/cron-ui.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/formatbytes.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/gpm.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/jquery-utils.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/keepalive.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/offline.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/packages.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/request.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/response.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/scrollbar.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/selectize-option-click.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/selectize-required-fix.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/sidebar.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/storage.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/tabs-memory.js
create mode 100644 user/plugins/admin/themes/grav/app/utils/toastr.js
create mode 100644 user/plugins/admin/themes/grav/css-compiled/fonts.css
create mode 100644 user/plugins/admin/themes/grav/css-compiled/fonts.css.map
create mode 100644 user/plugins/admin/themes/grav/css-compiled/nucleus.css
create mode 100644 user/plugins/admin/themes/grav/css-compiled/nucleus.css.map
create mode 100644 user/plugins/admin/themes/grav/css-compiled/preset.css
create mode 100644 user/plugins/admin/themes/grav/css-compiled/preset.css.map
create mode 100644 user/plugins/admin/themes/grav/css-compiled/simple-fonts.css
create mode 100644 user/plugins/admin/themes/grav/css-compiled/simple-fonts.css.map
create mode 100644 user/plugins/admin/themes/grav/css-compiled/template.css
create mode 100644 user/plugins/admin/themes/grav/css-compiled/template.css.map
create mode 100755 user/plugins/admin/themes/grav/css/chartist.min.css
create mode 100644 user/plugins/admin/themes/grav/css/codemirror/base16-light.css
create mode 100644 user/plugins/admin/themes/grav/css/codemirror/codemirror.css
create mode 100644 user/plugins/admin/themes/grav/css/codemirror/paper.css
create mode 100644 user/plugins/admin/themes/grav/css/featherlight.min.css
create mode 100755 user/plugins/admin/themes/grav/css/fork-awesome.min.css
create mode 100644 user/plugins/admin/themes/grav/css/hint.base.min.css
create mode 100755 user/plugins/admin/themes/grav/css/iconpicker.css
create mode 100644 user/plugins/admin/themes/grav/css/nucleus-ie10.css
create mode 100644 user/plugins/admin/themes/grav/css/nucleus-ie9.css
create mode 100644 user/plugins/admin/themes/grav/css/prism.css
create mode 100644 user/plugins/admin/themes/grav/css/pure-0.5.0/grids-min.css
create mode 100644 user/plugins/admin/themes/grav/css/selectize.min.css
create mode 100755 user/plugins/admin/themes/grav/fonts/forkawesome-webfont.eot
create mode 100755 user/plugins/admin/themes/grav/fonts/forkawesome-webfont.svg
create mode 100755 user/plugins/admin/themes/grav/fonts/forkawesome-webfont.ttf
create mode 100755 user/plugins/admin/themes/grav/fonts/forkawesome-webfont.woff
create mode 100755 user/plugins/admin/themes/grav/fonts/forkawesome-webfont.woff2
create mode 100644 user/plugins/admin/themes/grav/fonts/rockettheme-apps/rockettheme-apps.eot
create mode 100644 user/plugins/admin/themes/grav/fonts/rockettheme-apps/rockettheme-apps.svg
create mode 100644 user/plugins/admin/themes/grav/fonts/rockettheme-apps/rockettheme-apps.ttf
create mode 100644 user/plugins/admin/themes/grav/fonts/rockettheme-apps/rockettheme-apps.woff
create mode 100644 user/plugins/admin/themes/grav/gulpfile.js
create mode 100644 user/plugins/admin/themes/grav/images/favicon.png
create mode 100644 user/plugins/admin/themes/grav/images/grav-regular.svg
create mode 100644 user/plugins/admin/themes/grav/images/grav-small.svg
create mode 100644 user/plugins/admin/themes/grav/images/logo.svg
create mode 100644 user/plugins/admin/themes/grav/images/transparent.png
create mode 100644 user/plugins/admin/themes/grav/js/admin.min.js
create mode 100644 user/plugins/admin/themes/grav/js/form-attr.polyfill.js
create mode 100644 user/plugins/admin/themes/grav/js/vendor.min.js
create mode 100644 user/plugins/admin/themes/grav/package.json
create mode 100755 user/plugins/admin/themes/grav/scss.sh
create mode 100644 user/plugins/admin/themes/grav/scss/configuration/fonts/_support.scss
create mode 100644 user/plugins/admin/themes/grav/scss/configuration/nucleus/_base.scss
create mode 100644 user/plugins/admin/themes/grav/scss/configuration/nucleus/_breakpoints.scss
create mode 100644 user/plugins/admin/themes/grav/scss/configuration/nucleus/_core.scss
create mode 100644 user/plugins/admin/themes/grav/scss/configuration/nucleus/_layout.scss
create mode 100644 user/plugins/admin/themes/grav/scss/configuration/nucleus/_nav.scss
create mode 100644 user/plugins/admin/themes/grav/scss/configuration/nucleus/_typography.scss
create mode 100644 user/plugins/admin/themes/grav/scss/configuration/template/_base.scss
create mode 100644 user/plugins/admin/themes/grav/scss/configuration/template/_colors.scss
create mode 100644 user/plugins/admin/themes/grav/scss/configuration/template/_variables.scss
create mode 100644 user/plugins/admin/themes/grav/scss/fonts.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/_core.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/_flex.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/_forms.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/_typography.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/functions/_base.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/functions/_direction.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/functions/_range.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/mixins/_base.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/mixins/_breakpoints.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/mixins/_utilities.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/particles/_align-text.scss
create mode 100644 user/plugins/admin/themes/grav/scss/nucleus/particles/_visibility.scss
create mode 100644 user/plugins/admin/themes/grav/scss/preset.scss
create mode 100644 user/plugins/admin/themes/grav/scss/simple-fonts.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_admin.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_buttons.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_colors.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_core.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_custom.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_dropzone.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_editor.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_errors.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_extensions.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_fonts.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_forms.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_gpm.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_header.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_jqcron.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_login.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_media.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_nav-toggle.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_notifications.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_pages.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_phpinfo.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_remodal.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_tables.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_tabs.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_toastr.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_tools.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_typography.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/_utilities.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/modules/_base.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/modules/_bourbon_essentials.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/modules/_buttons.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/modules/_colorpicker.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/modules/_datetimepicker.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/modules/_input-range.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/modules/_scrollbars.scss
create mode 100644 user/plugins/admin/themes/grav/scss/template/modules/_toggle-switch.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/_bourbon-deprecated-upcoming.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/_bourbon.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_button.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_clearfix.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_directional-values.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_ellipsis.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_font-family.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_hide-text.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_html5-input-types.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_position.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_prefixer.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_rem.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_retina-image.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_size.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_timing-functions.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_triangle.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/addons/_word-wrap.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_animation.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_appearance.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_backface-visibility.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_background-image.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_background.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_border-image.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_border-radius.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_box-sizing.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_calc.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_columns.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_filter.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_flex-box.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_font-face.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_font-feature-settings.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_hidpi-media-query.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_hyphens.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_image-rendering.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_keyframes.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_linear-gradient.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_perspective.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_placeholder.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_radial-gradient.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_transform.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_transition.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/css3/_user-select.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_assign.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_color-lightness.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_flex-grid.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_golden-ratio.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_grid-width.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_modular-scale.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_px-to-em.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_px-to-rem.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_strip-units.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_tint-shade.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_transition-property-name.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/functions/_unpack.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_convert-units.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_gradient-positions-parser.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_is-num.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_linear-angle-parser.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_linear-gradient-parser.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_linear-positions-parser.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_linear-side-corner-parser.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_radial-arg-parser.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_radial-gradient-parser.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_radial-positions-parser.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_render-gradients.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_shape-size-stripper.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/helpers/_str-to-num.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/settings/_prefixer.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/bourbon/settings/_px-to-em.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/_color-schemer.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_cmyk.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_color-adjustments.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_color-schemer.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_colorblind.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_comparison.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_equalize.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_harmonize.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_interpolation.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_mix.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_mixins.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_ryb.scss
create mode 100644 user/plugins/admin/themes/grav/scss/vendor/color-schemer/color-schemer/_tint-shade.scss
create mode 100644 user/plugins/admin/themes/grav/templates/config.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/dashboard.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/default.json.twig
create mode 100644 user/plugins/admin/themes/grav/templates/denied.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/email/base.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/empty.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/error.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/error.json.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forgot.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/field.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/array/array.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/backupshistory/backupshistory.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/blueprint/blueprint.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/colorpicker/colorpicker.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/column/column.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/columns/columns.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/cron/cron.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/cronstatus/cronstatus.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/dateformat/dateformat.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/datetime/datetime.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/editor/editor.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/fieldset/fieldset.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/file/file.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/filepicker/filepicker.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/frontmatter/frontmatter.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/iconpicker/iconpicker.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/iconpicker/icons.yaml
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/list/list.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/markdown/markdown.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/mediapicker/mediapicker.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/multilevel/multilevel.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/order/order.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/pagemedia/pagemedia.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/pagemediaselect/pagemediaselect.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/pages/pages.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/parents/parents.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/permissions/permissions.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/range/range.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/section/section.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/selectize/selectize.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/selectunique/selectunique.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/taxonomy/taxonomy.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/themeselect/themeselect.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/userinfo/userinfo.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/forms/fields/xss/xss.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/installer.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/login.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/media-list-content.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/pages.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/backups-button.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/base-root.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/base.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/blueprints-new-folder.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/blueprints-new.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/blueprints-raw.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/blueprints.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/dashboard-feed.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/dashboard-maintenance.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/dashboard-notifications.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/dashboard-pages.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/dashboard-statistics.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/feed-block.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/footer.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/header.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/javascript-config.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/javascripts.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/list-sort.html.twig
create mode 100755 user/plugins/admin/themes/grav/templates/partials/login-form.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/login-logo.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/login-logout.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/login-twofa.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/login.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/logo.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/media-list-wrapper.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/media-list-wrapper__list.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/media-list-wrapper__list__filters.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/media-list-wrapper__sidebar.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/messages.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/modal-add-package.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/modal-changes-detected.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/modal-reinstall-package.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/modal-remove-package.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/modal-update-packages.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/nav-quick-tray.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/nav-toggle.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/nav-user-avatar.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/nav-user-details.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/nav.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/noscript.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/notification-dashboard-block.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/notification-feed-block.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/notification-plugins-block.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/notification-themes-block.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/notification-top-block.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/page-children.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/page-legend.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/page-move.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/plugin-data.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/plugins-details.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/plugins-list.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/register.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/release-toggle.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/spinning-wheel.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/stylesheets.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/theme.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/themes-details.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/themes-list.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/tools-backups-titlebar.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/tools-backups.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/tools-direct-install.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/tools-logs.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/tools-reports.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/tools-scheduler-titlebar.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/tools-scheduler.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/userinfo-avatar-credit.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/partials/userinfo-avatar.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/plugins.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/preview.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/register.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/reports/security.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/reports/yamllinter.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/reset.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/statistics.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/themes.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/tools.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/unauthorized.html.twig
create mode 100644 user/plugins/admin/themes/grav/templates/user.html.twig
create mode 100644 user/plugins/admin/themes/grav/theme.yaml
create mode 100755 user/plugins/admin/themes/grav/watch.sh
create mode 100644 user/plugins/admin/themes/grav/webpack.conf.js
create mode 100644 user/plugins/admin/twig/AdminTwigExtension.php
create mode 100644 user/plugins/admin/vendor/autoload.php
create mode 100755 user/plugins/admin/vendor/bin/picofeed
create mode 100644 user/plugins/admin/vendor/composer/ClassLoader.php
create mode 100644 user/plugins/admin/vendor/composer/LICENSE
create mode 100644 user/plugins/admin/vendor/composer/autoload_classmap.php
create mode 100644 user/plugins/admin/vendor/composer/autoload_namespaces.php
create mode 100644 user/plugins/admin/vendor/composer/autoload_psr4.php
create mode 100644 user/plugins/admin/vendor/composer/autoload_real.php
create mode 100644 user/plugins/admin/vendor/composer/autoload_static.php
create mode 100644 user/plugins/admin/vendor/composer/installed.json
create mode 100644 user/plugins/admin/vendor/composer/semver/CHANGELOG.md
create mode 100644 user/plugins/admin/vendor/composer/semver/LICENSE
create mode 100644 user/plugins/admin/vendor/composer/semver/README.md
create mode 100644 user/plugins/admin/vendor/composer/semver/composer.json
create mode 100644 user/plugins/admin/vendor/composer/semver/src/Comparator.php
create mode 100644 user/plugins/admin/vendor/composer/semver/src/Constraint/AbstractConstraint.php
create mode 100644 user/plugins/admin/vendor/composer/semver/src/Constraint/Constraint.php
create mode 100644 user/plugins/admin/vendor/composer/semver/src/Constraint/ConstraintInterface.php
create mode 100644 user/plugins/admin/vendor/composer/semver/src/Constraint/EmptyConstraint.php
create mode 100644 user/plugins/admin/vendor/composer/semver/src/Constraint/MultiConstraint.php
create mode 100644 user/plugins/admin/vendor/composer/semver/src/Semver.php
create mode 100644 user/plugins/admin/vendor/composer/semver/src/VersionParser.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/LICENSE
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Base.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/Client.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/ClientException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/Curl.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/ForbiddenException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/HttpHeaders.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/InvalidCertificateException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/InvalidUrlException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/MaxRedirectException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/MaxSizeException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/Stream.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/TimeoutException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/UnauthorizedException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Client/Url.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Config/Config.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Encoding/Encoding.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Filter/Attribute.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Filter/Filter.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Filter/Html.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Filter/Tag.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Generator/ContentGeneratorInterface.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Generator/FileContentGenerator.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Generator/YoutubeContentGenerator.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Logging/Logger.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/Atom.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/DateParser.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/Feed.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/Item.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/Parser.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/ParserException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/ParserInterface.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/Rss10.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/Rss20.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/Rss91.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/Rss92.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/XmlEntityException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Parser/XmlParser.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/PicoFeedException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Processor/ContentFilterProcessor.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Processor/ContentGeneratorProcessor.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Processor/ItemPostProcessor.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Processor/ItemProcessorInterface.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Processor/ScraperProcessor.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Reader/Favicon.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Reader/Reader.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Reader/ReaderException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Reader/SubscriptionNotFoundException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Reader/UnsupportedFeedFormatException.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/.blog.lemonde.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/.blogs.nytimes.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/.igen.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/.nytimes.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/.over-blog.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/.phoronix.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/.slate.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/.theguardian.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/.wikipedia.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/.wired.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/.wsj.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/01net.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/24.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/444.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/888.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/abstrusegoose.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/achgut.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/adventuregamers.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/alainonline.net.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/aljazeera.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/allafrica.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/allgemeine-zeitung.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/amazingsuperpowers.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/anythingcomic.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/ap.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/areadvd.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/arstechnica.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/atv.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/awkwardzombie.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/backchannel.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/bangkokpost.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/bauerwilli.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/bgr.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/bigfootjustice.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/bigpicture.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/bizjournals.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/biztimes.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/bleepingcomputer.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/blog.fefe.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/blog.mapillary.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/brewers.mlb.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/buenosairesherald.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/bunicomic.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/buttersafe.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/cad-comic.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/chaoslife.findchaos.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/chinafile.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/cicero.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/cliquerefresh.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/cnet.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/coinwelt.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/consomac.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/cowbirdsinlove.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/crash.net.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/csmonitor.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/dailyjs.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/dailyreporter.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/dailytech.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/degroupnews.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/derstandard.at.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/dilbert.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/discovermagazine.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/distrowatch.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/dozodomo.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/drawingboardcomic.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/e-w-e.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/economist.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/encyclopedie.naheulbeuk.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/endlessorigami.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/engadget.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/escapistmagazine.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/espn.go.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/exocomics.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/explosm.net.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/extrafabulouscomics.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/factroom.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/fastcodesign.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/fastcoexist.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/fastcompany.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/ffworld.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/foreignpolicy.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/fossbytes.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/fototelegraf.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/fowllanguagecomics.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/gamechannel.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/gamestar.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/geek.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/geektimes.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/gerbilwithajetpack.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/giantitp.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/github.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/gocomics.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/golem.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/gondola.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/gorabbit.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/habrahabr.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/happletea.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/hardware.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/heise.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/hirek.prim.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/hotshowlife.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/huffingtonpost.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/hvg.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/idokep.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/imogenquest.net.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/index.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/indiehaven.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/inforadio.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/ing.dk.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/invisiblebread.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/ir.amd.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/japantimes.co.jp.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/japantoday.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/journaldugeek.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/jsonline.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/justcoolidea.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/kanpai.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/karriere.jobfinder.dk.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/kisalfold.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/kiszamolo.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/kodi.tv.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/koreaherald.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/koreatimes.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/lastplacecomics.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/legorafi.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/lejapon.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/lesjoiesducode.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/lfg.co.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/lifehacker.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/lifehacker.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/linux-magazin.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/linux.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/linux.org.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/linuxinsider.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/lists.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/loadingartist.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/loldwell.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/lukesurl.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/macg.co.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/maclife.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/magyarkurir.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/marc.info.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/marriedtothesea.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/marycagle.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/maximumble.thebookofbiff.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/medium.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/mercworks.net.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/metronieuws.nl.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/milwaukeenns.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/mno.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/mokepon.smackjeeves.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/monandroid.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/monwindows.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/moya-planeta.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/mrlovenstein.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/muckrock.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/mynorthshorenow.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/nakedCapitalism.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/nasa.gov.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/nat-geo.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/nationaljournal.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/nature.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/nba.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/nedroid.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/networkworld.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/neustadt-ticker.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/nextinpact.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/niceteethcomic.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/nichtlustig.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/nlcafe.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/novo-argumente.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/oglaf.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/onhax.net.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/onlinekosten.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/onmilwaukee.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/openculture.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/opennet.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/openrightsgroup.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/opensource.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/optipess.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/origo.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/osnews.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/pastebin.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/pcgameshardware.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/peebleslab.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/penny-arcade.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/pixelbeat.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/plus.google.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/popstrip.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/portfolio.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/pro-linux.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/publicpolicyforum.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/publy.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/putaindecode.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/recode.net.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/retractionwatch.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/rockpapershotgun.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/rue89.nouvelobs.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/rugbyrama.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/salonkolumnisten.com
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/satwcomic.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/science-skeptical.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/scrumalliance.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/securityfocus.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/sentfromthemoon.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/sitepoint.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/slashdot.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/smallhousebliss.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/smarthomewelt.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/smashingmagazine.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/smbc-comics.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/snopes.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/soundandvision.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/spiegel.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/stereophile.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/stupidfox.net.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/subtraction.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/sz.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/takprosto.cc.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/techcrunch.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/the-ebook-reader.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/theatlantic.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/theawkwardyeti.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/thecodinglove.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/thedoghousediaries.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/thegamercat.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/thehindu.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/thelocal.se.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/themerepublic.net.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/themoscowtimes.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/thenewslens.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/theodd1sout.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/theonion.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/theregister.co.uk.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/thestandard.com.hk.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/theverge.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/threepanelsoul.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/tichyseinblick.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/timesofindia.indiatimes.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/totalcar.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/tozsdeforum.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/travel-dealz.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/travelo.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/treehugger.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/treelobsters.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/tutorialzine.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/twogag.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/twokinds.keenspot.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/undeadly.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/upi.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/usatoday.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/version2.dk.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/vezess.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/vgcats.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/vuxml.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/wausaudailyherald.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/welt.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/westfalen-blatt.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.bbc.co.uk.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.bdgest.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.bgr.in.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.businessweek.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.cnn.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.developpez.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.egscomics.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.fakingnews.firstpost.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.forbes.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.franceculture.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.futura-sciences.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.geekculture.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.howtogeek.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.lepoint.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.lesnumeriques.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.mac4ever.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.makeuseof.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.monsieur-le-chien.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.npr.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.numerama.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.oneindia.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.pseudo-sciences.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.sciencemag.org.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.slate.fr.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.universfreebox.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/www.zeit.de.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/xkcd.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/ymatuhin.ru.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/zarojel.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/zdnet.com.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Rules/zoom.hu.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Scraper/CandidateParser.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Scraper/ParserInterface.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Scraper/RuleLoader.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Scraper/RuleParser.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Scraper/Scraper.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Serialization/Subscription.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Serialization/SubscriptionList.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Serialization/SubscriptionListBuilder.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Serialization/SubscriptionListParser.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Serialization/SubscriptionParser.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Syndication/AtomFeedBuilder.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Syndication/AtomHelper.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Syndication/AtomItemBuilder.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Syndication/FeedBuilder.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Syndication/ItemBuilder.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Syndication/Rss20FeedBuilder.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Syndication/Rss20Helper.php
create mode 100644 user/plugins/admin/vendor/p3k/picofeed/lib/PicoFeed/Syndication/Rss20ItemBuilder.php
create mode 100755 user/plugins/admin/vendor/p3k/picofeed/picofeed
create mode 100644 user/plugins/admin/vendor/zendframework/zendxml/CHANGELOG.md
create mode 100644 user/plugins/admin/vendor/zendframework/zendxml/LICENSE.md
create mode 100644 user/plugins/admin/vendor/zendframework/zendxml/README.md
create mode 100644 user/plugins/admin/vendor/zendframework/zendxml/composer.json
create mode 100644 user/plugins/admin/vendor/zendframework/zendxml/src/Exception/ExceptionInterface.php
create mode 100644 user/plugins/admin/vendor/zendframework/zendxml/src/Exception/InvalidArgumentException.php
create mode 100644 user/plugins/admin/vendor/zendframework/zendxml/src/Exception/RuntimeException.php
create mode 100644 user/plugins/admin/vendor/zendframework/zendxml/src/Security.php
create mode 100644 user/plugins/email/CHANGELOG.md
create mode 100644 user/plugins/email/LICENSE
create mode 100644 user/plugins/email/README.md
create mode 100644 user/plugins/email/blueprints.yaml
create mode 100644 user/plugins/email/classes/Email.php
create mode 100644 user/plugins/email/classes/Utils.php
create mode 100644 user/plugins/email/cli/ClearQueueFailuresCommand.php
create mode 100644 user/plugins/email/cli/FlushQueueCommand.php
create mode 100644 user/plugins/email/cli/TestEmailCommand.php
create mode 100644 user/plugins/email/composer.json
create mode 100644 user/plugins/email/composer.lock
create mode 100644 user/plugins/email/email.php
create mode 100644 user/plugins/email/email.yaml
create mode 100644 user/plugins/email/languages.yaml
create mode 100644 user/plugins/email/templates/email/base.html.twig
create mode 100644 user/plugins/email/vendor/autoload.php
create mode 100644 user/plugins/email/vendor/composer/ClassLoader.php
create mode 100644 user/plugins/email/vendor/composer/LICENSE
create mode 100644 user/plugins/email/vendor/composer/autoload_classmap.php
create mode 100644 user/plugins/email/vendor/composer/autoload_files.php
create mode 100644 user/plugins/email/vendor/composer/autoload_namespaces.php
create mode 100644 user/plugins/email/vendor/composer/autoload_psr4.php
create mode 100644 user/plugins/email/vendor/composer/autoload_real.php
create mode 100644 user/plugins/email/vendor/composer/autoload_static.php
create mode 100644 user/plugins/email/vendor/composer/installed.json
create mode 100644 user/plugins/email/vendor/doctrine/lexer/LICENSE
create mode 100644 user/plugins/email/vendor/doctrine/lexer/README.md
create mode 100644 user/plugins/email/vendor/doctrine/lexer/composer.json
create mode 100644 user/plugins/email/vendor/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/EmailLexer.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/EmailParser.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/EmailValidator.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/CRLFAtTheEnd.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/CRLFX2.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/CRNoLF.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/CharNotAllowed.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/CommaInDomain.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/ConsecutiveAt.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/ConsecutiveDot.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/DomainHyphened.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/DotAtEnd.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/DotAtStart.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingAT.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingATEXT.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingCTEXT.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingDTEXT.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingDomainLiteralClose.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/InvalidEmail.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/NoDomainPart.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/NoLocalPart.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/UnclosedQuotedString.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Exception/UnopenedComment.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Parser/DomainPart.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Parser/LocalPart.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Parser/Parser.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Validation/EmailValidation.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Validation/Error/RFCWarnings.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Validation/Error/SpoofEmail.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Validation/RFCValidation.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/AddressLiteral.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/Comment.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/DomainLiteral.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/DomainTooLong.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/EmailTooLong.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/LabelTooLong.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/QuotedPart.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/QuotedString.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/TLD.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/EmailValidator/Warning/Warning.php
create mode 100644 user/plugins/email/vendor/egulias/email-validator/LICENSE
create mode 100644 user/plugins/email/vendor/egulias/email-validator/README.md
create mode 100644 user/plugins/email/vendor/egulias/email-validator/composer.json
create mode 100644 user/plugins/email/vendor/egulias/email-validator/phpunit.xml.dist
create mode 100644 user/plugins/email/vendor/egulias/email-validator/psalm.baseline.xml
create mode 100644 user/plugins/email/vendor/egulias/email-validator/psalm.xml
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/.gitattributes
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/.github/ISSUE_TEMPLATE.md
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/.github/PULL_REQUEST_TEMPLATE.md
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/.php_cs.dist
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/CHANGES
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/LICENSE
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/README.md
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/composer.json
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/doc/headers.rst
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/doc/index.rst
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/doc/introduction.rst
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/doc/japanese.rst
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/doc/messages.rst
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/doc/plugins.rst
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/doc/sending.rst
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/AddressEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/AddressEncoder/Utf8AddressEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/AddressEncoderException.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Attachment.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/EmbeddedFile.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/Event.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventListener.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventObject.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendEvent.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FailoverTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Filterable.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/IdGenerator.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Image.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/IoException.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Message.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NullContentEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimePart.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Logger.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Preferences.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/RfcComplianceException.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SendmailTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/dependency_maps/cache_deps.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/dependency_maps/message_deps.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/mime_types.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/preferences.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/swift_required.php
create mode 100755 user/plugins/email/vendor/swiftmailer/swiftmailer/lib/swiftmailer_generate_mimes_config.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/phpunit.xml.dist
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/IdenticalBinaryConstraint.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/StreamCollector.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/SwiftMailerSmokeTestCase.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/SwiftMailerTestCase.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/charsets/iso-2022-jp/one.txt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/charsets/iso-8859-1/one.txt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/charsets/utf-8/one.txt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/charsets/utf-8/three.txt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/charsets/utf-8/two.txt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/dkim/dkim.test.priv
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/dkim/dkim.test.pub
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/files/data.txt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/files/swiftmailer.png
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/files/textfile.zip
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/CA.srl
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/ca.crt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/ca.key
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/create-cert.sh
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt.crt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt.key
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt2.crt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt2.key
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/intermediate.crt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/intermediate.key
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign.crt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign.key
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign2.crt
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign2.key
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance.conf.php.default
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/AttachmentAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/ByteStream/FileByteStreamAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/DependencyContainerAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EmbeddedFileAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/Base64EncoderAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/QpEncoderAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/Rfc2231EncoderAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/ArrayKeyCacheAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MessageAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/NativeQpContentEncoderAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/QpContentEncoderAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/MimePartAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MimePartAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/ProcessAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/TlsSocketAcceptanceTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bootstrap.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug518Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug534Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug650Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/bug/Swift/BugFileByteStreamConsecutiveReadCallsTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/fixtures/MimeEntityFixture.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/smoke.conf.php.default
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/AttachmentSmokeTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/BasicSmokeTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/InternationalSmokeTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/DependencyContainerTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Base64EncoderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/QpEncoderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/CommandEventTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/EventObjectTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/ResponseEventTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SendEventTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SimpleEventDispatcherTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportChangeEventTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportExceptionEventTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mailer/ArrayRecipientIteratorTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/MailerTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/MessageTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AbstractMimeEntityTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AttachmentTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/EmbeddedFileTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/QpHeaderEncoderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/DateHeaderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/IdGeneratorTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/MimePartTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderSetTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMessageTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMimeEntityTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/AntiFloodPluginTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/DecoratorPluginTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/LoggerPluginTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/ArrayLoggerTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/RedirectingPluginTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ReporterPluginTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ThrottlerPluginTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/DKIMSignerTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/OpenDKIMSignerTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/SMimeSignerTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/ByteArrayReplacementFilterTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransportTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/FailoverTransportTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/LoadBalancedTransportTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/SendmailTransportTest.php
create mode 100644 user/plugins/email/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/StreamBufferTest.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Iconv.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/LICENSE
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/README.md
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.big5.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp037.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp1006.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp1026.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp424.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp437.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp500.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp737.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp775.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp850.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp852.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp855.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp856.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp857.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp860.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp861.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp862.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp863.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp864.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp865.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp866.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp869.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp874.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp875.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp932.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp936.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp949.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.cp950.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-1.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-10.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-11.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-13.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-14.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-15.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-16.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-2.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-3.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-4.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-5.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-6.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-7.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-8.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-9.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.koi8-r.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.koi8-u.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.us-ascii.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1250.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1251.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1252.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1253.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1254.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1255.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1256.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1257.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1258.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/Resources/charset/translit.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/bootstrap.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-iconv/composer.json
create mode 100644 user/plugins/email/vendor/symfony/polyfill-intl-idn/Idn.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-intl-idn/LICENSE
create mode 100644 user/plugins/email/vendor/symfony/polyfill-intl-idn/README.md
create mode 100644 user/plugins/email/vendor/symfony/polyfill-intl-idn/bootstrap.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-intl-idn/composer.json
create mode 100644 user/plugins/email/vendor/symfony/polyfill-mbstring/LICENSE
create mode 100644 user/plugins/email/vendor/symfony/polyfill-mbstring/Mbstring.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-mbstring/README.md
create mode 100644 user/plugins/email/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-mbstring/bootstrap.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-mbstring/composer.json
create mode 100644 user/plugins/email/vendor/symfony/polyfill-php72/LICENSE
create mode 100644 user/plugins/email/vendor/symfony/polyfill-php72/Php72.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-php72/README.md
create mode 100644 user/plugins/email/vendor/symfony/polyfill-php72/bootstrap.php
create mode 100644 user/plugins/email/vendor/symfony/polyfill-php72/composer.json
create mode 100644 user/plugins/error/CHANGELOG.md
create mode 100644 user/plugins/error/LICENSE
create mode 100644 user/plugins/error/README.md
create mode 100644 user/plugins/error/assets/readme_1.png
create mode 100644 user/plugins/error/blueprints.yaml
create mode 100644 user/plugins/error/cli/LogCommand.php
create mode 100644 user/plugins/error/composer.json
create mode 100644 user/plugins/error/error.php
create mode 100644 user/plugins/error/error.yaml
create mode 100644 user/plugins/error/languages.yaml
create mode 100644 user/plugins/error/pages/error.md
create mode 100644 user/plugins/error/templates/error.html.twig
create mode 100644 user/plugins/error/templates/error.json.twig
create mode 100644 user/plugins/error/vendor/autoload.php
create mode 100644 user/plugins/error/vendor/composer/ClassLoader.php
create mode 100644 user/plugins/error/vendor/composer/LICENSE
create mode 100644 user/plugins/error/vendor/composer/autoload_classmap.php
create mode 100644 user/plugins/error/vendor/composer/autoload_namespaces.php
create mode 100644 user/plugins/error/vendor/composer/autoload_psr4.php
create mode 100644 user/plugins/error/vendor/composer/autoload_real.php
create mode 100644 user/plugins/error/vendor/composer/autoload_static.php
create mode 100644 user/plugins/error/vendor/composer/installed.json
create mode 100644 user/plugins/form/.eslintrc
create mode 100644 user/plugins/form/CHANGELOG.md
create mode 100644 user/plugins/form/LICENSE
create mode 100644 user/plugins/form/README.md
create mode 100644 user/plugins/form/app/fields/array.js
create mode 100644 user/plugins/form/app/fields/file.js
create mode 100644 user/plugins/form/app/fields/form.js
create mode 100644 user/plugins/form/app/fields/index.js
create mode 100644 user/plugins/form/app/fields/media.js
create mode 100644 user/plugins/form/app/fields/tabs.js
create mode 100644 user/plugins/form/app/main.js
create mode 100644 user/plugins/form/app/utils/keep-alive.js
create mode 100644 user/plugins/form/assets/dropzone.min.css
create mode 100644 user/plugins/form/assets/form-styles.css
create mode 100644 user/plugins/form/assets/form-styles.min.css
create mode 100644 user/plugins/form/assets/form.min.js
create mode 100644 user/plugins/form/assets/form.vendor.js
create mode 100644 user/plugins/form/assets/object.assign.polyfill.js
create mode 100755 user/plugins/form/assets/signature_pad.js
create mode 100644 user/plugins/form/blueprints.yaml
create mode 100644 user/plugins/form/classes/Form.php
create mode 100644 user/plugins/form/classes/FormFactory.php
create mode 100644 user/plugins/form/classes/Forms.php
create mode 100644 user/plugins/form/composer.json
create mode 100644 user/plugins/form/composer.lock
create mode 100644 user/plugins/form/form.php
create mode 100644 user/plugins/form/form.yaml
create mode 100644 user/plugins/form/gulpfile.js
create mode 100644 user/plugins/form/languages.yaml
create mode 100644 user/plugins/form/package.json
create mode 100644 user/plugins/form/scss/form-styles.scss
create mode 100644 user/plugins/form/templates/form-messages.html.twig
create mode 100644 user/plugins/form/templates/form-messages.json.twig
create mode 100644 user/plugins/form/templates/form.html.twig
create mode 100644 user/plugins/form/templates/form.json.twig
create mode 100644 user/plugins/form/templates/formdata.html.twig
create mode 100644 user/plugins/form/templates/forms/ajax.json.twig
create mode 100644 user/plugins/form/templates/forms/data.html.twig
create mode 100644 user/plugins/form/templates/forms/data.txt.twig
create mode 100644 user/plugins/form/templates/forms/default/data.html.twig
create mode 100644 user/plugins/form/templates/forms/default/data.txt.twig
create mode 100644 user/plugins/form/templates/forms/default/field.html.twig
create mode 100644 user/plugins/form/templates/forms/default/fields.html.twig
create mode 100644 user/plugins/form/templates/forms/default/form.html.twig
create mode 100644 user/plugins/form/templates/forms/default/toggleable.html.twig
create mode 100644 user/plugins/form/templates/forms/dropzone/template.html.twig
create mode 100644 user/plugins/form/templates/forms/field.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/array/array.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/avatar/avatar.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/captcha/captcha.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/checkbox/checkbox.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/checkboxes/checkboxes.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/color/color.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/column/column.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/columns/columns.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/conditional/conditional.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/date/date.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/date/edit_list.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/datetime/datetime.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/datetime/edit_list.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/display/display.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/email/email.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/fieldset/fieldset.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/file/file.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/formname/formname.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/formtask/formtask.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/hidden/hidden.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/honeypot/honeypot.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/ignore/ignore.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/key/key.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/month/month.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/number/number.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/password/password.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/radio/radio.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/range/range.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/section/section.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/select/select.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/select_optgroup/select_optgroup.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/signature/signature.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/spacer/spacer.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/switch/switch.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/tab/tab.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/tabs/tabs.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/tel/tel.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/text/edit_list.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/text/text.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/textarea/textarea.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/time/edit_list.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/time/time.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/toggle/edit_list.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/toggle/toggle.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/uniqueid/uniqueid.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/url/edit_list.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/url/url.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/value/value.html.twig
create mode 100644 user/plugins/form/templates/forms/fields/week/week.html.twig
create mode 100644 user/plugins/form/templates/forms/form.html.twig
create mode 100644 user/plugins/form/templates/forms/layouts/button.html.twig
create mode 100644 user/plugins/form/templates/forms/layouts/field-variables.html.twig
create mode 100644 user/plugins/form/templates/forms/layouts/field.html.twig
create mode 100644 user/plugins/form/templates/forms/layouts/form.html.twig
create mode 100644 user/plugins/form/templates/modular/form.html.twig
create mode 100644 user/plugins/form/templates/partials/form-messages.html.twig
create mode 100644 user/plugins/form/templates/partials/form-messages.json.twig
create mode 100644 user/plugins/form/vendor/autoload.php
create mode 100644 user/plugins/form/vendor/composer/ClassLoader.php
create mode 100644 user/plugins/form/vendor/composer/LICENSE
create mode 100644 user/plugins/form/vendor/composer/autoload_classmap.php
create mode 100644 user/plugins/form/vendor/composer/autoload_namespaces.php
create mode 100644 user/plugins/form/vendor/composer/autoload_psr4.php
create mode 100644 user/plugins/form/vendor/composer/autoload_real.php
create mode 100644 user/plugins/form/vendor/composer/autoload_static.php
create mode 100644 user/plugins/form/vendor/composer/installed.json
create mode 100644 user/plugins/form/vendor/google/recaptcha/.github/ISSUE_TEMPLATE/bug_report.md
create mode 100644 user/plugins/form/vendor/google/recaptcha/ARCHITECTURE.md
create mode 100644 user/plugins/form/vendor/google/recaptcha/CONTRIBUTING.md
create mode 100644 user/plugins/form/vendor/google/recaptcha/LICENSE
create mode 100644 user/plugins/form/vendor/google/recaptcha/README.md
create mode 100644 user/plugins/form/vendor/google/recaptcha/app.yaml
create mode 100644 user/plugins/form/vendor/google/recaptcha/composer.json
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/appengine-https.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/config.php.dist
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/examples.css
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/google0afd8760fd68f119.html
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/index.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/recaptcha-content-security-policy.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v2-checkbox-explicit.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v2-checkbox.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v2-invisible.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v3-request-scores.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/recaptcha-v3-verify.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/examples/robots.txt
create mode 100644 user/plugins/form/vendor/google/recaptcha/phpunit.xml.dist
create mode 100644 user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Curl.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/CurlPost.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Socket.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/SocketPost.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/RequestParameters.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/src/ReCaptcha/Response.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/src/autoload.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/ReCaptchaTest.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/CurlPostTest.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/PostTest.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestMethod/SocketPostTest.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/RequestParametersTest.php
create mode 100644 user/plugins/form/vendor/google/recaptcha/tests/ReCaptcha/ResponseTest.php
create mode 100644 user/plugins/form/webpack.conf.js
create mode 100644 user/plugins/login/CHANGELOG.md
create mode 100644 user/plugins/login/LICENSE
create mode 100644 user/plugins/login/README.md
create mode 100644 user/plugins/login/blueprints.yaml
create mode 100644 user/plugins/login/classes/Controller.php
create mode 100644 user/plugins/login/classes/Events/UserLoginEvent.php
create mode 100755 user/plugins/login/classes/Login.php
create mode 100644 user/plugins/login/classes/LoginCache.php
create mode 100644 user/plugins/login/classes/RateLimiter.php
create mode 100644 user/plugins/login/classes/RememberMe/RememberMe.php
create mode 100644 user/plugins/login/classes/RememberMe/TokenStorage.php
create mode 100644 user/plugins/login/classes/TwoFactorAuth/BaconQrProvider.php
create mode 100644 user/plugins/login/classes/TwoFactorAuth/TwoFactorAuth.php
create mode 100644 user/plugins/login/cli/ChangePasswordCommand.php
create mode 100644 user/plugins/login/cli/ChangeUserStateCommand.php
create mode 100644 user/plugins/login/cli/LookupUserCommand.php
create mode 100644 user/plugins/login/cli/NewUserCommand.php
create mode 100644 user/plugins/login/composer.json
create mode 100644 user/plugins/login/composer.lock
create mode 100644 user/plugins/login/css/login.css
create mode 100644 user/plugins/login/js/2fa.js
create mode 100644 user/plugins/login/languages/de.yaml
create mode 100644 user/plugins/login/languages/en.yaml
create mode 100644 user/plugins/login/languages/es.yaml
create mode 100644 user/plugins/login/languages/fr.yaml
create mode 100644 user/plugins/login/languages/hr.yaml
create mode 100644 user/plugins/login/languages/hu.yaml
create mode 100644 user/plugins/login/languages/no.yaml
create mode 100644 user/plugins/login/languages/ro.yaml
create mode 100644 user/plugins/login/languages/ru.yaml
create mode 100644 user/plugins/login/languages/uk.yaml
create mode 100755 user/plugins/login/login.php
create mode 100644 user/plugins/login/login.yaml
create mode 100644 user/plugins/login/pages/forgot.md
create mode 100644 user/plugins/login/pages/login.md
create mode 100644 user/plugins/login/pages/profile.md
create mode 100644 user/plugins/login/pages/register.md
create mode 100644 user/plugins/login/pages/reset.md
create mode 100644 user/plugins/login/pages/unauthorized.md
create mode 100644 user/plugins/login/templates/forgot.html.twig
create mode 100644 user/plugins/login/templates/forms/fields/2fa_secret/2fa_secret.html.twig
create mode 100644 user/plugins/login/templates/login.html.twig
create mode 100644 user/plugins/login/templates/login.json.twig
create mode 100644 user/plugins/login/templates/partials/forgot-form.html.twig
create mode 100755 user/plugins/login/templates/partials/login-form.html.twig
create mode 100755 user/plugins/login/templates/partials/login-status.html.twig
create mode 100644 user/plugins/login/templates/partials/login-twofa.html.twig
create mode 100644 user/plugins/login/templates/partials/reset-form.html.twig
create mode 100644 user/plugins/login/templates/profile.html.twig
create mode 100644 user/plugins/login/templates/profile.json.twig
create mode 100644 user/plugins/login/templates/register.html.twig
create mode 100644 user/plugins/login/templates/reset.html.twig
create mode 100644 user/plugins/login/templates/unauthorized.html.twig
create mode 100644 user/plugins/login/vendor/autoload.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/CHANGELOG.md
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/LICENSE
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/Module.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/README.md
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/autoload_classmap.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/autoload_function.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/autoload_register.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/composer.json
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/AbstractEnum.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitArray.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitMatrix.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitUtils.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/CharacterSetEci.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/EcBlock.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/EcBlocks.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/ErrorCorrectionLevel.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/FormatInformation.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/Mode.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/ReedSolomonCodec.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/Version.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/BlockPair.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/ByteMatrix.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/Encoder.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MaskUtil.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MatrixUtil.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/QrCode.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/ExceptionInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/InvalidArgumentException.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/OutOfBoundsException.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/RuntimeException.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/UnexpectedValueException.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/WriterException.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/Cmyk.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/ColorInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/Gray.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/Rgb.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/AbstractRenderer.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Decorator/DecoratorInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Decorator/FinderPattern.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Eps.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Png.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/RendererInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Svg.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/RendererInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Text/Html.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Text/Plain.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/BaconQrCode/Writer.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Common/BitArray.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Common/BitMatrix.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Common/BitUtils.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Common/CharacterSetEci.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Common/EcBlock.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Common/EcBlocks.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Common/ErrorCorrectionLevel.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Common/FormatInformation.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Common/Mode.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Common/ReedSolomonCodec.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Common/Version.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Encoder/BlockPair.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Encoder/ByteMatrix.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Encoder/MaskUtil.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Encoder/MatrixUtil.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Encoder/QrCode.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Exception/ExceptionInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Exception/InvalidArgumentException.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Exception/OutOfBoundsException.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Exception/RuntimeException.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Exception/UnexpectedValueException.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Exception/WriterException.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Color/Alpha.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Color/Cmyk.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Color/ColorInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Color/Gray.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Color/Rgb.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Eye/CompositeEye.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Eye/EyeInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Eye/ModuleEye.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Eye/SimpleCircleEye.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Eye/SquareEye.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Image/EpsImageBackEnd.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Image/ImageBackEndInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Image/ImagickImageBackEnd.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Image/SvgImageBackEnd.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Image/TransformationMatrix.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/ImageRenderer.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Module/DotsModule.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Module/EdgeIterator/Edge.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Module/EdgeIterator/EdgeIterator.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Module/ModuleInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Module/RoundnessModule.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Module/SquareModule.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Path/Close.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Path/Curve.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Path/EllipticArc.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Path/Line.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Path/Move.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Path/OperationInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/Path/Path.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/PlainTextRenderer.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/RendererInterface.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/EyeFill.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Fill.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Gradient.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/GradientType.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/RendererStyle.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/src/Writer.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitArrayTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitMatrixTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitUtilsTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ErrorCorrectionLevelTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/FormatInformationTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ModeTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ReedSolomonCodecTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/VersionTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/EncoderTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MaskUtilTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MatrixUtilTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/HtmlTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/TextTest.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/bootstrap.php
create mode 100644 user/plugins/login/vendor/bacon/bacon-qr-code/tests/phpunit.xml
create mode 100644 user/plugins/login/vendor/birke/rememberme/LICENSE
create mode 100644 user/plugins/login/vendor/birke/rememberme/README.md
create mode 100644 user/plugins/login/vendor/birke/rememberme/composer.json
create mode 100644 user/plugins/login/vendor/birke/rememberme/example/action.php
create mode 100644 user/plugins/login/vendor/birke/rememberme/example/css/style.css
create mode 100644 user/plugins/login/vendor/birke/rememberme/example/index.php
create mode 100644 user/plugins/login/vendor/birke/rememberme/example/templates/cookie_was_stolen.php
create mode 100644 user/plugins/login/vendor/birke/rememberme/example/templates/login.php
create mode 100644 user/plugins/login/vendor/birke/rememberme/example/templates/user_is_logged_in.php
create mode 100644 user/plugins/login/vendor/birke/rememberme/example/tokens/.gitkeep
create mode 100644 user/plugins/login/vendor/birke/rememberme/phpunit.xml
create mode 100755 user/plugins/login/vendor/birke/rememberme/src/Rememberme/Authenticator.php
create mode 100755 user/plugins/login/vendor/birke/rememberme/src/Rememberme/Cookie.php
create mode 100755 user/plugins/login/vendor/birke/rememberme/src/Rememberme/Storage/DB.php
create mode 100644 user/plugins/login/vendor/birke/rememberme/src/Rememberme/Storage/File.php
create mode 100755 user/plugins/login/vendor/birke/rememberme/src/Rememberme/Storage/PDO.php
create mode 100755 user/plugins/login/vendor/birke/rememberme/src/Rememberme/Storage/StorageInterface.php
create mode 100644 user/plugins/login/vendor/birke/rememberme/test/CookieTest.php
create mode 100755 user/plugins/login/vendor/birke/rememberme/test/RemembermeTest.php
create mode 100755 user/plugins/login/vendor/birke/rememberme/test/Storage/PDO.php
create mode 100755 user/plugins/login/vendor/birke/rememberme/test/Storage/tokens.xml
create mode 100755 user/plugins/login/vendor/birke/rememberme/test/bootstrap.php
create mode 100644 user/plugins/login/vendor/composer/ClassLoader.php
create mode 100644 user/plugins/login/vendor/composer/LICENSE
create mode 100644 user/plugins/login/vendor/composer/autoload_classmap.php
create mode 100644 user/plugins/login/vendor/composer/autoload_files.php
create mode 100644 user/plugins/login/vendor/composer/autoload_namespaces.php
create mode 100644 user/plugins/login/vendor/composer/autoload_psr4.php
create mode 100644 user/plugins/login/vendor/composer/autoload_real.php
create mode 100644 user/plugins/login/vendor/composer/autoload_static.php
create mode 100644 user/plugins/login/vendor/composer/installed.json
create mode 100644 user/plugins/login/vendor/dasprid/enum/.coveralls.yml
create mode 100644 user/plugins/login/vendor/dasprid/enum/README.md
create mode 100644 user/plugins/login/vendor/dasprid/enum/composer.json
create mode 100644 user/plugins/login/vendor/dasprid/enum/phpcs.xml
create mode 100644 user/plugins/login/vendor/dasprid/enum/phpunit.xml.dist
create mode 100644 user/plugins/login/vendor/dasprid/enum/src/AbstractEnum.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/src/EnumMap.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/src/Exception/CloneNotSupportedException.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/src/Exception/ExceptionInterface.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/src/Exception/ExpectationException.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/src/Exception/IllegalArgumentException.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/src/Exception/MismatchException.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/src/Exception/SerializeNotSupportedException.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/src/Exception/UnserializeNotSupportedException.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/src/NullValue.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/test/AbstractEnumTest.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/test/EnumMapTest.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/test/NullValueTest.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/test/Planet.php
create mode 100644 user/plugins/login/vendor/dasprid/enum/test/WeekDay.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/CHANGELOG.md
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/LICENSE
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/RATIONALE.md
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/README.md
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/SECURITY.md
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/build-phar.sh
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/composer.json
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey.asc
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/lib/byte_safe_strings.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/lib/cast_to_int.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/lib/error_polyfill.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/lib/random.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/lib/random_bytes_openssl.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/lib/random_int.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/other/build_phar.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/other/ide_stubs/COM.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/other/ide_stubs/README.md
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/other/ide_stubs/com_exception.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/other/ide_stubs/libsodium.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/psalm-autoload.php
create mode 100644 user/plugins/login/vendor/paragonie/random_compat/psalm.xml
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/LICENSE
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/README.md
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/TwoFactorAuth.phpproj
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/TwoFactorAuth.sln
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/composer.json
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/composer.lock
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/demo/demo.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/demo/loader.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Qr/BaseHTTPQRCodeProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Qr/IQRCodeProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Qr/ImageChartsQRCodeProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Qr/QRException.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Qr/QRServerProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Qr/QRicketProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Rng/CSRNGProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Rng/HashRNGProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Rng/IRNGProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Rng/MCryptRNGProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Rng/OpenSSLRNGProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Rng/RNGException.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Time/HttpTimeProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Time/ITimeProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Time/LocalMachineTimeProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Time/NTPTimeProvider.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/Providers/Time/TimeException.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/TwoFactorAuth.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/lib/TwoFactorAuthException.php
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/logo.png
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/multifactorauthforeveryone.png
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/phpunit.xml
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/phpunit.xml.tmppica
create mode 100644 user/plugins/login/vendor/robthree/twofactorauth/tests/TwoFactorAuthTest.php
create mode 100644 user/plugins/markdown-notices/CHANGELOG.md
create mode 100644 user/plugins/markdown-notices/LICENSE
create mode 100644 user/plugins/markdown-notices/README.md
create mode 100644 user/plugins/markdown-notices/assets/notices.css
create mode 100644 user/plugins/markdown-notices/assets/screenshot.png
create mode 100644 user/plugins/markdown-notices/blueprints.yaml
create mode 100644 user/plugins/markdown-notices/languages.yaml
create mode 100644 user/plugins/markdown-notices/markdown-notices.php
create mode 100644 user/plugins/markdown-notices/markdown-notices.yaml
create mode 100644 user/plugins/problems/CHANGELOG.md
create mode 100644 user/plugins/problems/LICENSE
create mode 100644 user/plugins/problems/README.md
create mode 100644 user/plugins/problems/assets/cli.png
create mode 100644 user/plugins/problems/assets/code-3.svg
create mode 100644 user/plugins/problems/assets/grav-logo.svg
create mode 100644 user/plugins/problems/assets/heart.svg
create mode 100644 user/plugins/problems/assets/readme_1.jpg
create mode 100644 user/plugins/problems/blueprints.yaml
create mode 100644 user/plugins/problems/classes/Problems/Apache.php
create mode 100644 user/plugins/problems/classes/Problems/Base/Problem.php
create mode 100644 user/plugins/problems/classes/Problems/Base/ProblemChecker.php
create mode 100644 user/plugins/problems/classes/Problems/EssentialFolders.php
create mode 100644 user/plugins/problems/classes/Problems/PHPModules.php
create mode 100644 user/plugins/problems/classes/Problems/PHPVersion.php
create mode 100644 user/plugins/problems/classes/Problems/Permissions.php
create mode 100644 user/plugins/problems/cli/CheckCommand.php
create mode 100644 user/plugins/problems/composer.json
create mode 100644 user/plugins/problems/css/admin.css
create mode 100644 user/plugins/problems/css/admin.min.css
create mode 100755 user/plugins/problems/css/spectre-icons.css
create mode 100755 user/plugins/problems/css/spectre-icons.min.css
create mode 100755 user/plugins/problems/css/spectre.css
create mode 100755 user/plugins/problems/css/spectre.min.css
create mode 100644 user/plugins/problems/gulpfile.js
create mode 100644 user/plugins/problems/languages.yaml
create mode 100755 user/plugins/problems/package.json
create mode 100644 user/plugins/problems/problems.php
create mode 100644 user/plugins/problems/problems.yaml
create mode 100755 user/plugins/problems/scss/_accordions.scss
create mode 100755 user/plugins/problems/scss/_animations.scss
create mode 100755 user/plugins/problems/scss/_asian.scss
create mode 100755 user/plugins/problems/scss/_autocomplete.scss
create mode 100755 user/plugins/problems/scss/_avatars.scss
create mode 100755 user/plugins/problems/scss/_badges.scss
create mode 100755 user/plugins/problems/scss/_bars.scss
create mode 100755 user/plugins/problems/scss/_base.scss
create mode 100755 user/plugins/problems/scss/_breadcrumbs.scss
create mode 100755 user/plugins/problems/scss/_buttons.scss
create mode 100755 user/plugins/problems/scss/_calendars.scss
create mode 100755 user/plugins/problems/scss/_cards.scss
create mode 100755 user/plugins/problems/scss/_carousels.scss
create mode 100755 user/plugins/problems/scss/_chips.scss
create mode 100755 user/plugins/problems/scss/_codes.scss
create mode 100755 user/plugins/problems/scss/_comparison-sliders.scss
create mode 100755 user/plugins/problems/scss/_dropdowns.scss
create mode 100755 user/plugins/problems/scss/_empty.scss
create mode 100755 user/plugins/problems/scss/_filters.scss
create mode 100755 user/plugins/problems/scss/_forms.scss
create mode 100755 user/plugins/problems/scss/_icons.scss
create mode 100755 user/plugins/problems/scss/_labels.scss
create mode 100755 user/plugins/problems/scss/_layout.scss
create mode 100755 user/plugins/problems/scss/_media.scss
create mode 100755 user/plugins/problems/scss/_menus.scss
create mode 100755 user/plugins/problems/scss/_meters.scss
create mode 100755 user/plugins/problems/scss/_mixins.scss
create mode 100755 user/plugins/problems/scss/_modals.scss
create mode 100755 user/plugins/problems/scss/_navbar.scss
create mode 100755 user/plugins/problems/scss/_navs.scss
create mode 100755 user/plugins/problems/scss/_normalize.scss
create mode 100755 user/plugins/problems/scss/_off-canvas.scss
create mode 100755 user/plugins/problems/scss/_pagination.scss
create mode 100755 user/plugins/problems/scss/_panels.scss
create mode 100755 user/plugins/problems/scss/_parallax.scss
create mode 100755 user/plugins/problems/scss/_popovers.scss
create mode 100644 user/plugins/problems/scss/_problems.scss
create mode 100755 user/plugins/problems/scss/_progress.scss
create mode 100755 user/plugins/problems/scss/_sliders.scss
create mode 100755 user/plugins/problems/scss/_steps.scss
create mode 100755 user/plugins/problems/scss/_tables.scss
create mode 100755 user/plugins/problems/scss/_tabs.scss
create mode 100755 user/plugins/problems/scss/_tiles.scss
create mode 100755 user/plugins/problems/scss/_timelines.scss
create mode 100755 user/plugins/problems/scss/_toasts.scss
create mode 100755 user/plugins/problems/scss/_tooltips.scss
create mode 100755 user/plugins/problems/scss/_typography.scss
create mode 100755 user/plugins/problems/scss/_utilities.scss
create mode 100755 user/plugins/problems/scss/_variables.scss
create mode 100644 user/plugins/problems/scss/admin.scss
create mode 100755 user/plugins/problems/scss/icons/_icons-action.scss
create mode 100755 user/plugins/problems/scss/icons/_icons-core.scss
create mode 100755 user/plugins/problems/scss/icons/_icons-navigation.scss
create mode 100755 user/plugins/problems/scss/icons/_icons-object.scss
create mode 100755 user/plugins/problems/scss/mixins/_avatar.scss
create mode 100755 user/plugins/problems/scss/mixins/_button.scss
create mode 100755 user/plugins/problems/scss/mixins/_clearfix.scss
create mode 100755 user/plugins/problems/scss/mixins/_color.scss
create mode 100755 user/plugins/problems/scss/mixins/_label.scss
create mode 100755 user/plugins/problems/scss/mixins/_position.scss
create mode 100755 user/plugins/problems/scss/mixins/_shadow.scss
create mode 100755 user/plugins/problems/scss/mixins/_text.scss
create mode 100755 user/plugins/problems/scss/mixins/_toast.scss
create mode 100755 user/plugins/problems/scss/mixins/_transition.scss
create mode 100755 user/plugins/problems/scss/spectre-icons.scss
create mode 100755 user/plugins/problems/scss/spectre.scss
create mode 100755 user/plugins/problems/scss/utilities/_colors.scss
create mode 100755 user/plugins/problems/scss/utilities/_cursors.scss
create mode 100755 user/plugins/problems/scss/utilities/_display.scss
create mode 100755 user/plugins/problems/scss/utilities/_divider.scss
create mode 100755 user/plugins/problems/scss/utilities/_loading.scss
create mode 100755 user/plugins/problems/scss/utilities/_position.scss
create mode 100755 user/plugins/problems/scss/utilities/_shapes.scss
create mode 100755 user/plugins/problems/scss/utilities/_text.scss
create mode 100644 user/plugins/problems/templates/problems.html.twig
create mode 100644 user/plugins/problems/templates/reports/problems-report.html.twig
create mode 100644 user/plugins/problems/vendor/autoload.php
create mode 100644 user/plugins/problems/vendor/composer/ClassLoader.php
create mode 100644 user/plugins/problems/vendor/composer/LICENSE
create mode 100644 user/plugins/problems/vendor/composer/autoload_classmap.php
create mode 100644 user/plugins/problems/vendor/composer/autoload_namespaces.php
create mode 100644 user/plugins/problems/vendor/composer/autoload_psr4.php
create mode 100644 user/plugins/problems/vendor/composer/autoload_real.php
create mode 100644 user/plugins/problems/vendor/composer/autoload_static.php
create mode 100644 user/plugins/problems/vendor/composer/installed.json
create mode 100644 user/themes/.gitkeep
create mode 100644 user/themes/quark/CHANGELOG.md
create mode 100644 user/themes/quark/LICENSE
create mode 100644 user/themes/quark/README.md
create mode 100644 user/themes/quark/assets/quark-screenshots.jpg
create mode 100644 user/themes/quark/blueprints.yaml
create mode 100644 user/themes/quark/blueprints/blog.yaml
create mode 100644 user/themes/quark/blueprints/default.yaml
create mode 100644 user/themes/quark/blueprints/item.yaml
create mode 100644 user/themes/quark/blueprints/modular/features.yaml
create mode 100644 user/themes/quark/blueprints/modular/hero.yaml
create mode 100644 user/themes/quark/blueprints/modular/text.yaml
create mode 100644 user/themes/quark/blueprints/partials/blog-bits.yaml
create mode 100755 user/themes/quark/css-compiled/spectre-exp.css
create mode 100755 user/themes/quark/css-compiled/spectre-exp.min.css
create mode 100755 user/themes/quark/css-compiled/spectre-icons.css
create mode 100755 user/themes/quark/css-compiled/spectre-icons.min.css
create mode 100755 user/themes/quark/css-compiled/spectre.css
create mode 100755 user/themes/quark/css-compiled/spectre.min.css
create mode 100644 user/themes/quark/css-compiled/theme.css
create mode 100644 user/themes/quark/css-compiled/theme.min.css
create mode 100755 user/themes/quark/css/bricklayer.css
create mode 100644 user/themes/quark/css/custom.css
create mode 100644 user/themes/quark/css/line-awesome.min.css
create mode 100644 user/themes/quark/fonts/line-awesome.eot
create mode 100644 user/themes/quark/fonts/line-awesome.svg
create mode 100644 user/themes/quark/fonts/line-awesome.ttf
create mode 100644 user/themes/quark/fonts/line-awesome.woff
create mode 100644 user/themes/quark/fonts/line-awesome.woff2
create mode 100755 user/themes/quark/gulpfile.js
create mode 100644 user/themes/quark/images/favicon.png
create mode 100644 user/themes/quark/images/grav-logo.svg
create mode 100644 user/themes/quark/images/logo/.gitkeep
create mode 100755 user/themes/quark/js/bricklayer.min.js
create mode 100755 user/themes/quark/js/jquery.treemenu.js
create mode 100644 user/themes/quark/js/scopedQuerySelectorShim.min.js
create mode 100644 user/themes/quark/js/singlepagenav.min.js
create mode 100644 user/themes/quark/js/site.js
create mode 100644 user/themes/quark/js/smooth-scroll.min.js
create mode 100644 user/themes/quark/languages.yaml
create mode 100755 user/themes/quark/package.json
create mode 100644 user/themes/quark/quark.php
create mode 100644 user/themes/quark/quark.yaml
create mode 100644 user/themes/quark/screenshot.jpg
create mode 100755 user/themes/quark/scss/spectre-exp.scss
create mode 100755 user/themes/quark/scss/spectre-icons.scss
create mode 100755 user/themes/quark/scss/spectre.scss
create mode 100755 user/themes/quark/scss/spectre/_accordions.scss
create mode 100755 user/themes/quark/scss/spectre/_animations.scss
create mode 100755 user/themes/quark/scss/spectre/_asian.scss
create mode 100755 user/themes/quark/scss/spectre/_autocomplete.scss
create mode 100755 user/themes/quark/scss/spectre/_avatars.scss
create mode 100755 user/themes/quark/scss/spectre/_badges.scss
create mode 100755 user/themes/quark/scss/spectre/_bars.scss
create mode 100755 user/themes/quark/scss/spectre/_base.scss
create mode 100755 user/themes/quark/scss/spectre/_breadcrumbs.scss
create mode 100755 user/themes/quark/scss/spectre/_buttons.scss
create mode 100755 user/themes/quark/scss/spectre/_calendars.scss
create mode 100755 user/themes/quark/scss/spectre/_cards.scss
create mode 100755 user/themes/quark/scss/spectre/_carousels.scss
create mode 100755 user/themes/quark/scss/spectre/_chips.scss
create mode 100755 user/themes/quark/scss/spectre/_codes.scss
create mode 100755 user/themes/quark/scss/spectre/_comparison-sliders.scss
create mode 100755 user/themes/quark/scss/spectre/_dropdowns.scss
create mode 100755 user/themes/quark/scss/spectre/_empty.scss
create mode 100755 user/themes/quark/scss/spectre/_filters.scss
create mode 100755 user/themes/quark/scss/spectre/_forms.scss
create mode 100755 user/themes/quark/scss/spectre/_hero.scss
create mode 100755 user/themes/quark/scss/spectre/_icons.scss
create mode 100755 user/themes/quark/scss/spectre/_labels.scss
create mode 100755 user/themes/quark/scss/spectre/_layout.scss
create mode 100755 user/themes/quark/scss/spectre/_media.scss
create mode 100755 user/themes/quark/scss/spectre/_menus.scss
create mode 100755 user/themes/quark/scss/spectre/_meters.scss
create mode 100755 user/themes/quark/scss/spectre/_mixins.scss
create mode 100755 user/themes/quark/scss/spectre/_modals.scss
create mode 100755 user/themes/quark/scss/spectre/_navbar.scss
create mode 100755 user/themes/quark/scss/spectre/_navs.scss
create mode 100755 user/themes/quark/scss/spectre/_normalize.scss
create mode 100755 user/themes/quark/scss/spectre/_off-canvas.scss
create mode 100755 user/themes/quark/scss/spectre/_pagination.scss
create mode 100755 user/themes/quark/scss/spectre/_panels.scss
create mode 100755 user/themes/quark/scss/spectre/_parallax.scss
create mode 100755 user/themes/quark/scss/spectre/_popovers.scss
create mode 100755 user/themes/quark/scss/spectre/_progress.scss
create mode 100755 user/themes/quark/scss/spectre/_sliders.scss
create mode 100755 user/themes/quark/scss/spectre/_steps.scss
create mode 100755 user/themes/quark/scss/spectre/_tables.scss
create mode 100755 user/themes/quark/scss/spectre/_tabs.scss
create mode 100755 user/themes/quark/scss/spectre/_tiles.scss
create mode 100755 user/themes/quark/scss/spectre/_timelines.scss
create mode 100755 user/themes/quark/scss/spectre/_toasts.scss
create mode 100755 user/themes/quark/scss/spectre/_tooltips.scss
create mode 100755 user/themes/quark/scss/spectre/_typography.scss
create mode 100755 user/themes/quark/scss/spectre/_utilities.scss
create mode 100755 user/themes/quark/scss/spectre/_variables.scss
create mode 100755 user/themes/quark/scss/spectre/_viewer-360.scss
create mode 100755 user/themes/quark/scss/spectre/icons/_icons-action.scss
create mode 100755 user/themes/quark/scss/spectre/icons/_icons-core.scss
create mode 100755 user/themes/quark/scss/spectre/icons/_icons-navigation.scss
create mode 100755 user/themes/quark/scss/spectre/icons/_icons-object.scss
create mode 100755 user/themes/quark/scss/spectre/mixins/_avatar.scss
create mode 100755 user/themes/quark/scss/spectre/mixins/_button.scss
create mode 100755 user/themes/quark/scss/spectre/mixins/_clearfix.scss
create mode 100755 user/themes/quark/scss/spectre/mixins/_color.scss
create mode 100755 user/themes/quark/scss/spectre/mixins/_label.scss
create mode 100755 user/themes/quark/scss/spectre/mixins/_position.scss
create mode 100755 user/themes/quark/scss/spectre/mixins/_shadow.scss
create mode 100755 user/themes/quark/scss/spectre/mixins/_text.scss
create mode 100755 user/themes/quark/scss/spectre/mixins/_toast.scss
create mode 100755 user/themes/quark/scss/spectre/spectre-exp.scss
create mode 100755 user/themes/quark/scss/spectre/spectre-icons.scss
create mode 100755 user/themes/quark/scss/spectre/spectre.scss
create mode 100755 user/themes/quark/scss/spectre/utilities/_colors.scss
create mode 100755 user/themes/quark/scss/spectre/utilities/_cursors.scss
create mode 100755 user/themes/quark/scss/spectre/utilities/_display.scss
create mode 100755 user/themes/quark/scss/spectre/utilities/_divider.scss
create mode 100755 user/themes/quark/scss/spectre/utilities/_loading.scss
create mode 100755 user/themes/quark/scss/spectre/utilities/_position.scss
create mode 100755 user/themes/quark/scss/spectre/utilities/_shapes.scss
create mode 100755 user/themes/quark/scss/spectre/utilities/_text.scss
create mode 100644 user/themes/quark/scss/theme.scss
create mode 100644 user/themes/quark/scss/theme/_animation.scss
create mode 100644 user/themes/quark/scss/theme/_blog.scss
create mode 100644 user/themes/quark/scss/theme/_extensions.scss
create mode 100644 user/themes/quark/scss/theme/_fonts.scss
create mode 100644 user/themes/quark/scss/theme/_footer.scss
create mode 100644 user/themes/quark/scss/theme/_forms.scss
create mode 100644 user/themes/quark/scss/theme/_framework.scss
create mode 100644 user/themes/quark/scss/theme/_header.scss
create mode 100644 user/themes/quark/scss/theme/_menu.scss
create mode 100644 user/themes/quark/scss/theme/_mixins.scss
create mode 100644 user/themes/quark/scss/theme/_mobile.scss
create mode 100644 user/themes/quark/scss/theme/_onepage.scss
create mode 100644 user/themes/quark/scss/theme/_typography.scss
create mode 100644 user/themes/quark/scss/theme/_variables.scss
create mode 100644 user/themes/quark/templates/blocks/base.html.twig
create mode 100644 user/themes/quark/templates/blog.html.twig
create mode 100644 user/themes/quark/templates/default.html.twig
create mode 100644 user/themes/quark/templates/error.html.twig
create mode 100644 user/themes/quark/templates/forms/fields/checkbox/checkbox.html.twig
create mode 100644 user/themes/quark/templates/forms/fields/checkboxes/checkboxes.html.twig
create mode 100644 user/themes/quark/templates/forms/fields/radio/radio.html.twig
create mode 100644 user/themes/quark/templates/forms/fields/switch/switch.html.twig
create mode 100644 user/themes/quark/templates/item.html.twig
create mode 100644 user/themes/quark/templates/macros/macros.html.twig
create mode 100644 user/themes/quark/templates/modular.html.twig
create mode 100644 user/themes/quark/templates/modular/features.html.twig
create mode 100644 user/themes/quark/templates/modular/hero.html.twig
create mode 100644 user/themes/quark/templates/modular/text.html.twig
create mode 100644 user/themes/quark/templates/partials/archives.html.twig
create mode 100644 user/themes/quark/templates/partials/base.html.twig
create mode 100644 user/themes/quark/templates/partials/blog-item.html.twig
create mode 100644 user/themes/quark/templates/partials/blog-list-item.html.twig
create mode 100644 user/themes/quark/templates/partials/blog/date.html.twig
create mode 100644 user/themes/quark/templates/partials/blog/page-summary.html.twig
create mode 100644 user/themes/quark/templates/partials/blog/taxonomy.html.twig
create mode 100644 user/themes/quark/templates/partials/blog/title.html.twig
create mode 100644 user/themes/quark/templates/partials/footer.html.twig
create mode 100644 user/themes/quark/templates/partials/form-messages.html.twig
create mode 100644 user/themes/quark/templates/partials/hero.html.twig
create mode 100644 user/themes/quark/templates/partials/layout.html.twig
create mode 100644 user/themes/quark/templates/partials/logo.html.twig
create mode 100644 user/themes/quark/templates/partials/messages.html.twig
create mode 100644 user/themes/quark/templates/partials/navigation.html.twig
create mode 100644 user/themes/quark/templates/partials/relatedpages.html.twig
create mode 100644 user/themes/quark/templates/partials/sidebar.html.twig
create mode 100644 user/themes/quark/templates/partials/taxonomylist.html.twig
create mode 100644 user/themes/quark/thumbnail.jpg
create mode 100644 vendor/antoligy/dom-string-iterators/README.md
create mode 100644 vendor/antoligy/dom-string-iterators/src/DOMLettersIterator.php
create mode 100644 vendor/antoligy/dom-string-iterators/src/DOMWordsIterator.php
create mode 100644 vendor/autoload.php
create mode 100755 vendor/bin/var-dump-server
create mode 100644 vendor/composer/ClassLoader.php
create mode 100644 vendor/composer/LICENSE
create mode 100644 vendor/composer/autoload_classmap.php
create mode 100644 vendor/composer/autoload_files.php
create mode 100644 vendor/composer/autoload_namespaces.php
create mode 100644 vendor/composer/autoload_psr4.php
create mode 100644 vendor/composer/autoload_real.php
create mode 100644 vendor/composer/autoload_static.php
create mode 100644 vendor/composer/ca-bundle/LICENSE
create mode 100644 vendor/composer/ca-bundle/README.md
create mode 100644 vendor/composer/ca-bundle/composer.json
create mode 100644 vendor/composer/ca-bundle/res/cacert.pem
create mode 100644 vendor/composer/ca-bundle/src/CaBundle.php
create mode 100644 vendor/composer/installed.json
create mode 100644 vendor/doctrine/cache/LICENSE
create mode 100644 vendor/doctrine/cache/README.md
create mode 100644 vendor/doctrine/cache/UPGRADE.md
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcuCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/ChainCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/ClearableCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseBucketCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/ExtMongoDBCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/FlushableCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/InvalidCacheId.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/LegacyMongoDBCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcacheCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/MongoDBCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiDeleteCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiOperationCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/PredisCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/RedisCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/SQLite3Cache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/Version.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/VoidCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/XcacheCache.php
create mode 100644 vendor/doctrine/cache/lib/Doctrine/Common/Cache/ZendDataCache.php
create mode 100644 vendor/doctrine/collections/.doctrine-project.json
create mode 100644 vendor/doctrine/collections/CONTRIBUTING.md
create mode 100644 vendor/doctrine/collections/LICENSE
create mode 100644 vendor/doctrine/collections/README.md
create mode 100644 vendor/doctrine/collections/docs/en/derived-collections.rst
create mode 100644 vendor/doctrine/collections/docs/en/expression-builder.rst
create mode 100644 vendor/doctrine/collections/docs/en/expressions.rst
create mode 100644 vendor/doctrine/collections/docs/en/index.rst
create mode 100644 vendor/doctrine/collections/docs/en/lazy-collections.rst
create mode 100644 vendor/doctrine/collections/docs/en/sidebar.rst
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/AbstractLazyCollection.php
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/Collection.php
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/Criteria.php
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Comparison.php
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Expression.php
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Value.php
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/ExpressionBuilder.php
create mode 100644 vendor/doctrine/collections/lib/Doctrine/Common/Collections/Selectable.php
create mode 100644 vendor/doctrine/collections/psalm.xml.dist
create mode 100644 vendor/donatj/phpuseragentparser/.github/workflows/ci.yml
create mode 100644 vendor/donatj/phpuseragentparser/.helpers/constants.php
create mode 100644 vendor/donatj/phpuseragentparser/.mddoc.xml
create mode 100644 vendor/donatj/phpuseragentparser/CONTRIBUTING.md
create mode 100644 vendor/donatj/phpuseragentparser/LICENSE.md
create mode 100644 vendor/donatj/phpuseragentparser/Makefile
create mode 100644 vendor/donatj/phpuseragentparser/README.md
create mode 100644 vendor/donatj/phpuseragentparser/bin/benchmark.php
create mode 100644 vendor/donatj/phpuseragentparser/bin/constant_generator.php
create mode 100644 vendor/donatj/phpuseragentparser/bin/init_user_agent.php
create mode 100644 vendor/donatj/phpuseragentparser/bin/user_agent_sorter.php
create mode 100644 vendor/donatj/phpuseragentparser/src/UserAgent/Browsers.php
create mode 100644 vendor/donatj/phpuseragentparser/src/UserAgent/Platforms.php
create mode 100644 vendor/donatj/phpuseragentparser/src/UserAgent/UserAgent.php
create mode 100644 vendor/donatj/phpuseragentparser/src/UserAgent/UserAgentInterface.php
create mode 100644 vendor/donatj/phpuseragentparser/src/UserAgent/UserAgentParser.php
create mode 100644 vendor/donatj/phpuseragentparser/src/UserAgentParser.php
create mode 100644 vendor/donatj/phpuseragentparser/tests/UserAgentParserFunctionTest.php
create mode 100644 vendor/donatj/phpuseragentparser/tests/UserAgentParserObjectTest.php
create mode 100644 vendor/donatj/phpuseragentparser/tests/user_agents.json
create mode 100644 vendor/dragonmantank/cron-expression/CHANGELOG.md
create mode 100644 vendor/dragonmantank/cron-expression/LICENSE
create mode 100644 vendor/dragonmantank/cron-expression/README.md
create mode 100644 vendor/dragonmantank/cron-expression/src/Cron/AbstractField.php
create mode 100644 vendor/dragonmantank/cron-expression/src/Cron/CronExpression.php
create mode 100644 vendor/dragonmantank/cron-expression/src/Cron/DayOfMonthField.php
create mode 100644 vendor/dragonmantank/cron-expression/src/Cron/DayOfWeekField.php
create mode 100644 vendor/dragonmantank/cron-expression/src/Cron/FieldFactory.php
create mode 100644 vendor/dragonmantank/cron-expression/src/Cron/FieldInterface.php
create mode 100644 vendor/dragonmantank/cron-expression/src/Cron/HoursField.php
create mode 100644 vendor/dragonmantank/cron-expression/src/Cron/MinutesField.php
create mode 100644 vendor/dragonmantank/cron-expression/src/Cron/MonthField.php
create mode 100644 vendor/dragonmantank/cron-expression/src/Cron/YearField.php
create mode 100644 vendor/filp/whoops/CHANGELOG.md
create mode 100644 vendor/filp/whoops/LICENSE.md
create mode 100644 vendor/filp/whoops/src/Whoops/Exception/ErrorException.php
create mode 100644 vendor/filp/whoops/src/Whoops/Exception/Formatter.php
create mode 100644 vendor/filp/whoops/src/Whoops/Exception/Frame.php
create mode 100644 vendor/filp/whoops/src/Whoops/Exception/FrameCollection.php
create mode 100644 vendor/filp/whoops/src/Whoops/Exception/Inspector.php
create mode 100644 vendor/filp/whoops/src/Whoops/Handler/CallbackHandler.php
create mode 100644 vendor/filp/whoops/src/Whoops/Handler/Handler.php
create mode 100644 vendor/filp/whoops/src/Whoops/Handler/HandlerInterface.php
create mode 100644 vendor/filp/whoops/src/Whoops/Handler/JsonResponseHandler.php
create mode 100644 vendor/filp/whoops/src/Whoops/Handler/PlainTextHandler.php
create mode 100644 vendor/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php
create mode 100644 vendor/filp/whoops/src/Whoops/Handler/XmlResponseHandler.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/css/whoops.base.css
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/js/clipboard.min.js
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/js/prettify.min.js
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/js/whoops.base.js
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/js/zepto.min.js
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/env_details.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/frame_code.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/frame_list.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/frames_container.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/frames_description.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/header.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/header_outer.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/layout.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/panel_details.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/panel_details_outer.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/panel_left.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Resources/views/panel_left_outer.html.php
create mode 100644 vendor/filp/whoops/src/Whoops/Run.php
create mode 100644 vendor/filp/whoops/src/Whoops/RunInterface.php
create mode 100644 vendor/filp/whoops/src/Whoops/Util/HtmlDumperOutput.php
create mode 100644 vendor/filp/whoops/src/Whoops/Util/Misc.php
create mode 100644 vendor/filp/whoops/src/Whoops/Util/SystemFacade.php
create mode 100644 vendor/filp/whoops/src/Whoops/Util/TemplateHelper.php
create mode 100755 vendor/gregwar/cache/Gregwar/Cache/Cache.php
create mode 100644 vendor/gregwar/cache/Gregwar/Cache/CacheInterface.php
create mode 100644 vendor/gregwar/cache/Gregwar/Cache/GarbageCollect.php
create mode 100644 vendor/gregwar/cache/Gregwar/Cache/LICENSE
create mode 100644 vendor/gregwar/cache/Gregwar/Cache/README.md
create mode 100644 vendor/gregwar/cache/Gregwar/Cache/autoload.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/Adapter/Adapter.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/Adapter/AdapterInterface.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/Adapter/Common.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/Adapter/GD.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/Adapter/Imagick.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/Exceptions/GenerationError.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/GarbageCollect.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/Image.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/ImageColor.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/LICENSE
create mode 100644 vendor/gregwar/image/Gregwar/Image/README.md
create mode 100644 vendor/gregwar/image/Gregwar/Image/Source/Create.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/Source/Data.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/Source/File.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/Source/Resource.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/Source/Source.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/autoload.php
create mode 100644 vendor/gregwar/image/Gregwar/Image/images/error.jpg
create mode 100644 vendor/guzzlehttp/psr7/CHANGELOG.md
create mode 100644 vendor/guzzlehttp/psr7/LICENSE
create mode 100644 vendor/guzzlehttp/psr7/README.md
create mode 100644 vendor/guzzlehttp/psr7/src/AppendStream.php
create mode 100644 vendor/guzzlehttp/psr7/src/BufferStream.php
create mode 100644 vendor/guzzlehttp/psr7/src/CachingStream.php
create mode 100644 vendor/guzzlehttp/psr7/src/DroppingStream.php
create mode 100644 vendor/guzzlehttp/psr7/src/FnStream.php
create mode 100644 vendor/guzzlehttp/psr7/src/Header.php
create mode 100644 vendor/guzzlehttp/psr7/src/InflateStream.php
create mode 100644 vendor/guzzlehttp/psr7/src/LazyOpenStream.php
create mode 100644 vendor/guzzlehttp/psr7/src/LimitStream.php
create mode 100644 vendor/guzzlehttp/psr7/src/Message.php
create mode 100644 vendor/guzzlehttp/psr7/src/MessageTrait.php
create mode 100644 vendor/guzzlehttp/psr7/src/MimeType.php
create mode 100644 vendor/guzzlehttp/psr7/src/MultipartStream.php
create mode 100644 vendor/guzzlehttp/psr7/src/NoSeekStream.php
create mode 100644 vendor/guzzlehttp/psr7/src/PumpStream.php
create mode 100644 vendor/guzzlehttp/psr7/src/Query.php
create mode 100644 vendor/guzzlehttp/psr7/src/Request.php
create mode 100644 vendor/guzzlehttp/psr7/src/Response.php
create mode 100644 vendor/guzzlehttp/psr7/src/Rfc7230.php
create mode 100644 vendor/guzzlehttp/psr7/src/ServerRequest.php
create mode 100644 vendor/guzzlehttp/psr7/src/Stream.php
create mode 100644 vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php
create mode 100644 vendor/guzzlehttp/psr7/src/StreamWrapper.php
create mode 100644 vendor/guzzlehttp/psr7/src/UploadedFile.php
create mode 100644 vendor/guzzlehttp/psr7/src/Uri.php
create mode 100644 vendor/guzzlehttp/psr7/src/UriNormalizer.php
create mode 100644 vendor/guzzlehttp/psr7/src/UriResolver.php
create mode 100644 vendor/guzzlehttp/psr7/src/Utils.php
create mode 100644 vendor/guzzlehttp/psr7/src/functions.php
create mode 100644 vendor/guzzlehttp/psr7/src/functions_include.php
create mode 100644 vendor/kodus/psr7-server/CHANGELOG.md
create mode 100644 vendor/kodus/psr7-server/LICENSE
create mode 100644 vendor/kodus/psr7-server/README.md
create mode 100644 vendor/kodus/psr7-server/src/ServerRequestCreator.php
create mode 100644 vendor/kodus/psr7-server/src/ServerRequestCreatorInterface.php
create mode 100644 vendor/league/climate/.github/workflows/buildcheck.yml
create mode 100644 vendor/league/climate/CHANGELOG.md
create mode 100644 vendor/league/climate/CONTRIBUTING.md
create mode 100644 vendor/league/climate/Dockerfile
create mode 100644 vendor/league/climate/LICENSE.md
create mode 100644 vendor/league/climate/README.md
create mode 100644 vendor/league/climate/src/ASCII/404.txt
create mode 100644 vendor/league/climate/src/ASCII/bender.txt
create mode 100644 vendor/league/climate/src/ASCII/failed.txt
create mode 100644 vendor/league/climate/src/ASCII/fancy-bender.txt
create mode 100644 vendor/league/climate/src/ASCII/passed.txt
create mode 100644 vendor/league/climate/src/ASCII/php
create mode 100644 vendor/league/climate/src/ASCII/the-league-big.txt
create mode 100644 vendor/league/climate/src/ASCII/the-league-bigger.txt
create mode 100644 vendor/league/climate/src/ASCII/the-league-massive.txt
create mode 100644 vendor/league/climate/src/ASCII/the-league.txt
create mode 100644 vendor/league/climate/src/Argument/Argument.php
create mode 100644 vendor/league/climate/src/Argument/Filter.php
create mode 100644 vendor/league/climate/src/Argument/Manager.php
create mode 100644 vendor/league/climate/src/Argument/Parser.php
create mode 100644 vendor/league/climate/src/Argument/Summary.php
create mode 100644 vendor/league/climate/src/CLImate.php
create mode 100644 vendor/league/climate/src/Decorator/Component/BackgroundColor.php
create mode 100644 vendor/league/climate/src/Decorator/Component/BaseDecorator.php
create mode 100644 vendor/league/climate/src/Decorator/Component/Color.php
create mode 100644 vendor/league/climate/src/Decorator/Component/Command.php
create mode 100644 vendor/league/climate/src/Decorator/Component/DecoratorInterface.php
create mode 100644 vendor/league/climate/src/Decorator/Component/Format.php
create mode 100644 vendor/league/climate/src/Decorator/Parser/Ansi.php
create mode 100644 vendor/league/climate/src/Decorator/Parser/NonAnsi.php
create mode 100644 vendor/league/climate/src/Decorator/Parser/Parser.php
create mode 100644 vendor/league/climate/src/Decorator/Parser/ParserFactory.php
create mode 100644 vendor/league/climate/src/Decorator/Parser/ParserImporter.php
create mode 100644 vendor/league/climate/src/Decorator/Style.php
create mode 100644 vendor/league/climate/src/Decorator/Tags.php
create mode 100644 vendor/league/climate/src/Exceptions/Exception.php
create mode 100644 vendor/league/climate/src/Exceptions/InvalidArgumentException.php
create mode 100644 vendor/league/climate/src/Exceptions/RuntimeException.php
create mode 100644 vendor/league/climate/src/Exceptions/UnexpectedValueException.php
create mode 100644 vendor/league/climate/src/Logger.php
create mode 100644 vendor/league/climate/src/Settings/Art.php
create mode 100644 vendor/league/climate/src/Settings/Manager.php
create mode 100644 vendor/league/climate/src/Settings/SettingsImporter.php
create mode 100644 vendor/league/climate/src/Settings/SettingsInterface.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/BasicTerminalObject.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/BasicTerminalObjectInterface.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Border.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Br.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Clear.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/ClearLine.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Columns.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Draw.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Dump.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Flank.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Inline.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Json.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Out.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Repeatable.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Tab.php
create mode 100644 vendor/league/climate/src/TerminalObject/Basic/Table.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Animation.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Animation/Keyframe.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Checkbox/Checkbox.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Checkbox/CheckboxGroup.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Checkbox/RadioGroup.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Checkboxes.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Confirm.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/DynamicTerminalObject.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/DynamicTerminalObjectInterface.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Input.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/InputAbstract.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Padding.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Password.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Progress.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Radio.php
create mode 100644 vendor/league/climate/src/TerminalObject/Dynamic/Spinner.php
create mode 100644 vendor/league/climate/src/TerminalObject/Helper/Art.php
create mode 100644 vendor/league/climate/src/TerminalObject/Helper/Sleeper.php
create mode 100644 vendor/league/climate/src/TerminalObject/Helper/SleeperInterface.php
create mode 100644 vendor/league/climate/src/TerminalObject/Helper/StringLength.php
create mode 100644 vendor/league/climate/src/TerminalObject/Router/BaseRouter.php
create mode 100644 vendor/league/climate/src/TerminalObject/Router/BasicRouter.php
create mode 100644 vendor/league/climate/src/TerminalObject/Router/DynamicRouter.php
create mode 100644 vendor/league/climate/src/TerminalObject/Router/ExtensionCollection.php
create mode 100644 vendor/league/climate/src/TerminalObject/Router/Router.php
create mode 100644 vendor/league/climate/src/TerminalObject/Router/RouterInterface.php
create mode 100644 vendor/league/climate/src/Util/Cursor.php
create mode 100644 vendor/league/climate/src/Util/Helper.php
create mode 100644 vendor/league/climate/src/Util/Output.php
create mode 100644 vendor/league/climate/src/Util/OutputImporter.php
create mode 100644 vendor/league/climate/src/Util/Reader/ReaderInterface.php
create mode 100644 vendor/league/climate/src/Util/Reader/Stdin.php
create mode 100644 vendor/league/climate/src/Util/System/Linux.php
create mode 100644 vendor/league/climate/src/Util/System/System.php
create mode 100644 vendor/league/climate/src/Util/System/SystemFactory.php
create mode 100644 vendor/league/climate/src/Util/System/Windows.php
create mode 100644 vendor/league/climate/src/Util/UtilFactory.php
create mode 100644 vendor/league/climate/src/Util/UtilImporter.php
create mode 100644 vendor/league/climate/src/Util/Writer/Buffer.php
create mode 100644 vendor/league/climate/src/Util/Writer/File.php
create mode 100644 vendor/league/climate/src/Util/Writer/StdErr.php
create mode 100644 vendor/league/climate/src/Util/Writer/StdOut.php
create mode 100644 vendor/league/climate/src/Util/Writer/WriterInterface.php
create mode 100644 vendor/matthiasmullie/minify/LICENSE
create mode 100644 vendor/matthiasmullie/minify/data/js/keywords_after.txt
create mode 100644 vendor/matthiasmullie/minify/data/js/keywords_before.txt
create mode 100644 vendor/matthiasmullie/minify/data/js/keywords_reserved.txt
create mode 100644 vendor/matthiasmullie/minify/data/js/operators.txt
create mode 100644 vendor/matthiasmullie/minify/data/js/operators_after.txt
create mode 100644 vendor/matthiasmullie/minify/data/js/operators_before.txt
create mode 100644 vendor/matthiasmullie/minify/src/CSS.php
create mode 100644 vendor/matthiasmullie/minify/src/Exception.php
create mode 100644 vendor/matthiasmullie/minify/src/Exceptions/BasicException.php
create mode 100644 vendor/matthiasmullie/minify/src/Exceptions/FileImportException.php
create mode 100644 vendor/matthiasmullie/minify/src/Exceptions/IOException.php
create mode 100644 vendor/matthiasmullie/minify/src/JS.php
create mode 100644 vendor/matthiasmullie/minify/src/Minify.php
create mode 100644 vendor/matthiasmullie/path-converter/LICENSE
create mode 100644 vendor/matthiasmullie/path-converter/src/Converter.php
create mode 100644 vendor/matthiasmullie/path-converter/src/ConverterInterface.php
create mode 100644 vendor/matthiasmullie/path-converter/src/NoConverter.php
create mode 100644 vendor/maximebf/debugbar/LICENSE
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/CacheCacheCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/DoctrineCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/MonologCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/Propel2Collector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/PropelCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/SlimCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/SwiftMailer/SwiftLogCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/SwiftMailer/SwiftMailCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/Twig/TimeableTwigExtensionProfiler.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/Twig/TraceableTwigEnvironment.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/Twig/TraceableTwigTemplate.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/Twig/TwigCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Bridge/TwigProfileCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/AggregatedCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/AssetProvider.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/ConfigCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/DataCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/DataCollectorInterface.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/ExceptionsCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/LocalizationCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/MemoryCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/MessagesAggregateInterface.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/MessagesCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/PDO/PDOCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/PDO/TraceablePDO.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/PDO/TraceablePDOStatement.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/PDO/TracedStatement.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/PhpInfoCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/Renderable.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/RequestDataCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataCollector/TimeDataCollector.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataFormatter/DataFormatter.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataFormatter/DataFormatterInterface.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataFormatter/DebugBarVarDumper.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataFormatter/VarDumper/DebugBarHtmlDumper.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DataFormatter/VarDumper/SeekingData.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DebugBar.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/DebugBarException.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/HttpDriverInterface.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/JavascriptRenderer.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/OpenHandler.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/PhpHttpDriver.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/RequestIdGenerator.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/RequestIdGeneratorInterface.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/debugbar.css
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/debugbar.js
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/openhandler.css
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/openhandler.js
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/widgets.css
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/widgets.js
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/widgets/mails/widget.css
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/widgets/mails/widget.js
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/widgets/sqlqueries/widget.css
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/widgets/sqlqueries/widget.js
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/widgets/templates/widget.css
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Resources/widgets/templates/widget.js
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/StandardDebugBar.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Storage/FileStorage.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Storage/MemcachedStorage.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Storage/PdoStorage.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Storage/RedisStorage.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Storage/StorageInterface.php
create mode 100644 vendor/maximebf/debugbar/src/DebugBar/Storage/pdo_storage_schema.sql
create mode 100644 vendor/miljar/php-exif/CHANGELOG.rst
create mode 100755 vendor/miljar/php-exif/LICENSE
create mode 100755 vendor/miljar/php-exif/README.md
create mode 100644 vendor/miljar/php-exif/lib/PHPExif/Adapter/AdapterAbstract.php
create mode 100644 vendor/miljar/php-exif/lib/PHPExif/Adapter/AdapterInterface.php
create mode 100644 vendor/miljar/php-exif/lib/PHPExif/Adapter/Exiftool.php
create mode 100644 vendor/miljar/php-exif/lib/PHPExif/Adapter/Native.php
create mode 100644 vendor/miljar/php-exif/lib/PHPExif/Adapter/NoAdapterException.php
create mode 100755 vendor/miljar/php-exif/lib/PHPExif/Exif.php
create mode 100644 vendor/miljar/php-exif/lib/PHPExif/Hydrator/HydratorInterface.php
create mode 100644 vendor/miljar/php-exif/lib/PHPExif/Hydrator/Mutator.php
create mode 100644 vendor/miljar/php-exif/lib/PHPExif/Mapper/Exiftool.php
create mode 100644 vendor/miljar/php-exif/lib/PHPExif/Mapper/MapperInterface.php
create mode 100644 vendor/miljar/php-exif/lib/PHPExif/Mapper/Native.php
create mode 100755 vendor/miljar/php-exif/lib/PHPExif/Reader/Reader.php
create mode 100644 vendor/miljar/php-exif/lib/PHPExif/Reader/ReaderInterface.php
create mode 100644 vendor/monolog/monolog/CHANGELOG.md
create mode 100644 vendor/monolog/monolog/LICENSE
create mode 100644 vendor/monolog/monolog/README.md
create mode 100644 vendor/monolog/monolog/src/Monolog/ErrorHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerInterface.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/FormattableHandlerTrait.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerInterface.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/ProcessableHandlerTrait.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/SlackbotHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Logger.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Registry.php
create mode 100644 vendor/monolog/monolog/src/Monolog/ResettableInterface.php
create mode 100644 vendor/monolog/monolog/src/Monolog/SignalHandler.php
create mode 100644 vendor/monolog/monolog/src/Monolog/Utils.php
create mode 100644 vendor/nyholm/psr7/CHANGELOG.md
create mode 100644 vendor/nyholm/psr7/LICENSE
create mode 100644 vendor/nyholm/psr7/README.md
create mode 100644 vendor/nyholm/psr7/phpstan.baseline.dist
create mode 100644 vendor/nyholm/psr7/src/Factory/HttplugFactory.php
create mode 100644 vendor/nyholm/psr7/src/Factory/Psr17Factory.php
create mode 100644 vendor/nyholm/psr7/src/LowercaseTrait.php
create mode 100644 vendor/nyholm/psr7/src/MessageTrait.php
create mode 100644 vendor/nyholm/psr7/src/Request.php
create mode 100644 vendor/nyholm/psr7/src/RequestTrait.php
create mode 100644 vendor/nyholm/psr7/src/Response.php
create mode 100644 vendor/nyholm/psr7/src/ServerRequest.php
create mode 100644 vendor/nyholm/psr7/src/Stream.php
create mode 100644 vendor/nyholm/psr7/src/UploadedFile.php
create mode 100644 vendor/nyholm/psr7/src/Uri.php
create mode 100644 vendor/phive/twig-extensions-deferred/LICENSE
create mode 100644 vendor/phive/twig-extensions-deferred/README.md
create mode 100755 vendor/phive/twig-extensions-deferred/src/DeferredBlockNode.php
create mode 100644 vendor/phive/twig-extensions-deferred/src/DeferredExtension.php
create mode 100755 vendor/phive/twig-extensions-deferred/src/DeferredNode.php
create mode 100644 vendor/phive/twig-extensions-deferred/src/DeferredNodeVisitor.php
create mode 100644 vendor/phive/twig-extensions-deferred/src/DeferredTokenParser.php
create mode 100644 vendor/php-http/message-factory/CHANGELOG.md
create mode 100644 vendor/php-http/message-factory/LICENSE
create mode 100644 vendor/php-http/message-factory/README.md
create mode 100644 vendor/php-http/message-factory/src/MessageFactory.php
create mode 100644 vendor/php-http/message-factory/src/RequestFactory.php
create mode 100644 vendor/php-http/message-factory/src/ResponseFactory.php
create mode 100644 vendor/php-http/message-factory/src/StreamFactory.php
create mode 100644 vendor/php-http/message-factory/src/UriFactory.php
create mode 100644 vendor/pimple/pimple/CHANGELOG
create mode 100644 vendor/pimple/pimple/LICENSE
create mode 100644 vendor/pimple/pimple/README.rst
create mode 100644 vendor/pimple/pimple/src/Pimple/Container.php
create mode 100644 vendor/pimple/pimple/src/Pimple/Exception/ExpectedInvokableException.php
create mode 100644 vendor/pimple/pimple/src/Pimple/Exception/FrozenServiceException.php
create mode 100644 vendor/pimple/pimple/src/Pimple/Exception/InvalidServiceIdentifierException.php
create mode 100644 vendor/pimple/pimple/src/Pimple/Exception/UnknownIdentifierException.php
create mode 100644 vendor/pimple/pimple/src/Pimple/Psr11/Container.php
create mode 100644 vendor/pimple/pimple/src/Pimple/Psr11/ServiceLocator.php
create mode 100644 vendor/pimple/pimple/src/Pimple/ServiceIterator.php
create mode 100644 vendor/pimple/pimple/src/Pimple/ServiceProviderInterface.php
create mode 100644 vendor/psr/cache/CHANGELOG.md
create mode 100644 vendor/psr/cache/LICENSE.txt
create mode 100644 vendor/psr/cache/README.md
create mode 100644 vendor/psr/cache/composer.json
create mode 100644 vendor/psr/cache/src/CacheException.php
create mode 100644 vendor/psr/cache/src/CacheItemInterface.php
create mode 100644 vendor/psr/cache/src/CacheItemPoolInterface.php
create mode 100644 vendor/psr/cache/src/InvalidArgumentException.php
create mode 100644 vendor/psr/container/LICENSE
create mode 100644 vendor/psr/container/README.md
create mode 100644 vendor/psr/container/src/ContainerExceptionInterface.php
create mode 100644 vendor/psr/container/src/ContainerInterface.php
create mode 100644 vendor/psr/container/src/NotFoundExceptionInterface.php
create mode 100644 vendor/psr/http-factory/LICENSE
create mode 100644 vendor/psr/http-factory/README.md
create mode 100644 vendor/psr/http-factory/src/RequestFactoryInterface.php
create mode 100644 vendor/psr/http-factory/src/ResponseFactoryInterface.php
create mode 100644 vendor/psr/http-factory/src/ServerRequestFactoryInterface.php
create mode 100644 vendor/psr/http-factory/src/StreamFactoryInterface.php
create mode 100644 vendor/psr/http-factory/src/UploadedFileFactoryInterface.php
create mode 100644 vendor/psr/http-factory/src/UriFactoryInterface.php
create mode 100644 vendor/psr/http-message/CHANGELOG.md
create mode 100644 vendor/psr/http-message/LICENSE
create mode 100644 vendor/psr/http-message/README.md
create mode 100644 vendor/psr/http-message/src/MessageInterface.php
create mode 100644 vendor/psr/http-message/src/RequestInterface.php
create mode 100644 vendor/psr/http-message/src/ResponseInterface.php
create mode 100644 vendor/psr/http-message/src/ServerRequestInterface.php
create mode 100644 vendor/psr/http-message/src/StreamInterface.php
create mode 100644 vendor/psr/http-message/src/UploadedFileInterface.php
create mode 100644 vendor/psr/http-message/src/UriInterface.php
create mode 100644 vendor/psr/http-server-handler/LICENSE
create mode 100644 vendor/psr/http-server-handler/README.md
create mode 100644 vendor/psr/http-server-handler/src/RequestHandlerInterface.php
create mode 100644 vendor/psr/http-server-middleware/LICENSE
create mode 100644 vendor/psr/http-server-middleware/README.md
create mode 100644 vendor/psr/http-server-middleware/src/MiddlewareInterface.php
create mode 100644 vendor/psr/log/LICENSE
create mode 100644 vendor/psr/log/Psr/Log/AbstractLogger.php
create mode 100644 vendor/psr/log/Psr/Log/InvalidArgumentException.php
create mode 100644 vendor/psr/log/Psr/Log/LogLevel.php
create mode 100644 vendor/psr/log/Psr/Log/LoggerAwareInterface.php
create mode 100644 vendor/psr/log/Psr/Log/LoggerAwareTrait.php
create mode 100644 vendor/psr/log/Psr/Log/LoggerInterface.php
create mode 100644 vendor/psr/log/Psr/Log/LoggerTrait.php
create mode 100644 vendor/psr/log/Psr/Log/NullLogger.php
create mode 100644 vendor/psr/log/Psr/Log/Test/DummyTest.php
create mode 100644 vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php
create mode 100644 vendor/psr/log/Psr/Log/Test/TestLogger.php
create mode 100644 vendor/psr/log/README.md
create mode 100644 vendor/psr/simple-cache/LICENSE.md
create mode 100644 vendor/psr/simple-cache/README.md
create mode 100644 vendor/psr/simple-cache/src/CacheException.php
create mode 100644 vendor/psr/simple-cache/src/CacheInterface.php
create mode 100644 vendor/psr/simple-cache/src/InvalidArgumentException.php
create mode 100644 vendor/ralouphie/getallheaders/LICENSE
create mode 100644 vendor/ralouphie/getallheaders/README.md
create mode 100644 vendor/ralouphie/getallheaders/src/getallheaders.php
create mode 100644 vendor/rockettheme/toolbox/ArrayTraits/src/ArrayAccess.php
create mode 100644 vendor/rockettheme/toolbox/ArrayTraits/src/ArrayAccessWithGetters.php
create mode 100644 vendor/rockettheme/toolbox/ArrayTraits/src/Constructor.php
create mode 100644 vendor/rockettheme/toolbox/ArrayTraits/src/Countable.php
create mode 100644 vendor/rockettheme/toolbox/ArrayTraits/src/Export.php
create mode 100644 vendor/rockettheme/toolbox/ArrayTraits/src/ExportInterface.php
create mode 100644 vendor/rockettheme/toolbox/ArrayTraits/src/Iterator.php
create mode 100644 vendor/rockettheme/toolbox/ArrayTraits/src/NestedArrayAccess.php
create mode 100644 vendor/rockettheme/toolbox/ArrayTraits/src/NestedArrayAccessWithGetters.php
create mode 100644 vendor/rockettheme/toolbox/ArrayTraits/src/Serializable.php
create mode 100644 vendor/rockettheme/toolbox/Blueprints/src/BlueprintForm.php
create mode 100644 vendor/rockettheme/toolbox/Blueprints/src/BlueprintSchema.php
create mode 100644 vendor/rockettheme/toolbox/Blueprints/src/Blueprints.php
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/BlueprintFormTest.php
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/BlueprintSchemaTest.php
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/blueprint/basic.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/blueprint/empty.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/blueprint/extends.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/blueprint/import.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/blueprint/partials/address.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/form/items/basic.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/form/items/empty.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/form/items/extends.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/form/items/import.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/input/basic.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/input/empty.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/schema/defaults/basic.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/schema/defaults/empty.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/schema/extra/basic.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/schema/extra/empty.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/schema/init/basic.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/schema/init/empty.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/schema/merge/basic.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/schema/merge/empty.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/schema/state/basic.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/data/schema/state/empty.yaml
create mode 100644 vendor/rockettheme/toolbox/Blueprints/tests/helper.php
create mode 100644 vendor/rockettheme/toolbox/CHANGELOG.md
create mode 100755 vendor/rockettheme/toolbox/Compat/src/Yaml/Exception/ExceptionInterface.php
create mode 100755 vendor/rockettheme/toolbox/Compat/src/Yaml/Exception/ParseException.php
create mode 100755 vendor/rockettheme/toolbox/Compat/src/Yaml/Exception/RuntimeException.php
create mode 100755 vendor/rockettheme/toolbox/Compat/src/Yaml/Inline.php
create mode 100755 vendor/rockettheme/toolbox/Compat/src/Yaml/Parser.php
create mode 100755 vendor/rockettheme/toolbox/Compat/src/Yaml/Unescaper.php
create mode 100755 vendor/rockettheme/toolbox/Compat/src/Yaml/Yaml.php
create mode 100644 vendor/rockettheme/toolbox/DI/src/Container.php
create mode 100644 vendor/rockettheme/toolbox/DI/src/ServiceProviderInterface.php
create mode 100644 vendor/rockettheme/toolbox/Event/src/Event.php
create mode 100644 vendor/rockettheme/toolbox/Event/src/EventDispatcher.php
create mode 100644 vendor/rockettheme/toolbox/Event/src/EventSubscriberInterface.php
create mode 100644 vendor/rockettheme/toolbox/File/src/File.php
create mode 100644 vendor/rockettheme/toolbox/File/src/FileInterface.php
create mode 100644 vendor/rockettheme/toolbox/File/src/IniFile.php
create mode 100644 vendor/rockettheme/toolbox/File/src/JsonFile.php
create mode 100644 vendor/rockettheme/toolbox/File/src/LogFile.php
create mode 100644 vendor/rockettheme/toolbox/File/src/MarkdownFile.php
create mode 100644 vendor/rockettheme/toolbox/File/src/MoFile.php
create mode 100644 vendor/rockettheme/toolbox/File/src/PhpFile.php
create mode 100644 vendor/rockettheme/toolbox/File/src/YamlFile.php
create mode 100644 vendor/rockettheme/toolbox/LICENSE
create mode 100644 vendor/rockettheme/toolbox/README.md
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/src/RecursiveUniformResourceIterator.php
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/src/ResourceLocatorInterface.php
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/src/UniformResourceIterator.php
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/src/UniformResourceLocator.php
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/UniformResourceLocatorTest.php
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/base/all/base.txt
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/base/all/base_all.txt
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/base/all/base_local.txt
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/base/all/base_override.txt
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/local/all/base_all.txt
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/local/all/base_local.txt
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/local/all/local.txt
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/local/all/local_override.txt
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/override/all/base_all.txt
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/override/all/base_override.txt
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/override/all/local_override.txt
create mode 100644 vendor/rockettheme/toolbox/ResourceLocator/tests/data/override/all/override.txt
create mode 100644 vendor/rockettheme/toolbox/Session/src/Message.php
create mode 100644 vendor/rockettheme/toolbox/Session/src/Session.php
create mode 100644 vendor/rockettheme/toolbox/Session/tests/MessageTest.php
create mode 100644 vendor/rockettheme/toolbox/StreamWrapper/src/ReadOnlyStream.php
create mode 100644 vendor/rockettheme/toolbox/StreamWrapper/src/Stream.php
create mode 100644 vendor/rockettheme/toolbox/StreamWrapper/src/StreamBuilder.php
create mode 100644 vendor/rockettheme/toolbox/StreamWrapper/src/StreamInterface.php
create mode 100644 vendor/seld/cli-prompt/LICENSE
create mode 100644 vendor/seld/cli-prompt/README.md
create mode 100644 vendor/seld/cli-prompt/res/example.php
create mode 100644 vendor/seld/cli-prompt/res/hiddeninput.exe
create mode 100644 vendor/seld/cli-prompt/src/CliPrompt.php
create mode 100644 vendor/symfony/console/Application.php
create mode 100644 vendor/symfony/console/CHANGELOG.md
create mode 100644 vendor/symfony/console/Command/Command.php
create mode 100644 vendor/symfony/console/Command/HelpCommand.php
create mode 100644 vendor/symfony/console/Command/ListCommand.php
create mode 100644 vendor/symfony/console/Command/LockableTrait.php
create mode 100644 vendor/symfony/console/CommandLoader/CommandLoaderInterface.php
create mode 100644 vendor/symfony/console/CommandLoader/ContainerCommandLoader.php
create mode 100644 vendor/symfony/console/CommandLoader/FactoryCommandLoader.php
create mode 100644 vendor/symfony/console/ConsoleEvents.php
create mode 100644 vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php
create mode 100644 vendor/symfony/console/Descriptor/ApplicationDescription.php
create mode 100644 vendor/symfony/console/Descriptor/Descriptor.php
create mode 100644 vendor/symfony/console/Descriptor/DescriptorInterface.php
create mode 100644 vendor/symfony/console/Descriptor/JsonDescriptor.php
create mode 100644 vendor/symfony/console/Descriptor/MarkdownDescriptor.php
create mode 100644 vendor/symfony/console/Descriptor/TextDescriptor.php
create mode 100644 vendor/symfony/console/Descriptor/XmlDescriptor.php
create mode 100644 vendor/symfony/console/Event/ConsoleCommandEvent.php
create mode 100644 vendor/symfony/console/Event/ConsoleErrorEvent.php
create mode 100644 vendor/symfony/console/Event/ConsoleEvent.php
create mode 100644 vendor/symfony/console/Event/ConsoleTerminateEvent.php
create mode 100644 vendor/symfony/console/EventListener/ErrorListener.php
create mode 100644 vendor/symfony/console/Exception/CommandNotFoundException.php
create mode 100644 vendor/symfony/console/Exception/ExceptionInterface.php
create mode 100644 vendor/symfony/console/Exception/InvalidArgumentException.php
create mode 100644 vendor/symfony/console/Exception/InvalidOptionException.php
create mode 100644 vendor/symfony/console/Exception/LogicException.php
create mode 100644 vendor/symfony/console/Exception/NamespaceNotFoundException.php
create mode 100644 vendor/symfony/console/Exception/RuntimeException.php
create mode 100644 vendor/symfony/console/Formatter/OutputFormatter.php
create mode 100644 vendor/symfony/console/Formatter/OutputFormatterInterface.php
create mode 100644 vendor/symfony/console/Formatter/OutputFormatterStyle.php
create mode 100644 vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php
create mode 100644 vendor/symfony/console/Formatter/OutputFormatterStyleStack.php
create mode 100644 vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.php
create mode 100644 vendor/symfony/console/Helper/DebugFormatterHelper.php
create mode 100644 vendor/symfony/console/Helper/DescriptorHelper.php
create mode 100644 vendor/symfony/console/Helper/FormatterHelper.php
create mode 100644 vendor/symfony/console/Helper/Helper.php
create mode 100644 vendor/symfony/console/Helper/HelperInterface.php
create mode 100644 vendor/symfony/console/Helper/HelperSet.php
create mode 100644 vendor/symfony/console/Helper/InputAwareHelper.php
create mode 100644 vendor/symfony/console/Helper/ProcessHelper.php
create mode 100644 vendor/symfony/console/Helper/ProgressBar.php
create mode 100644 vendor/symfony/console/Helper/ProgressIndicator.php
create mode 100644 vendor/symfony/console/Helper/QuestionHelper.php
create mode 100644 vendor/symfony/console/Helper/SymfonyQuestionHelper.php
create mode 100644 vendor/symfony/console/Helper/Table.php
create mode 100644 vendor/symfony/console/Helper/TableCell.php
create mode 100644 vendor/symfony/console/Helper/TableRows.php
create mode 100644 vendor/symfony/console/Helper/TableSeparator.php
create mode 100644 vendor/symfony/console/Helper/TableStyle.php
create mode 100644 vendor/symfony/console/Input/ArgvInput.php
create mode 100644 vendor/symfony/console/Input/ArrayInput.php
create mode 100644 vendor/symfony/console/Input/Input.php
create mode 100644 vendor/symfony/console/Input/InputArgument.php
create mode 100644 vendor/symfony/console/Input/InputAwareInterface.php
create mode 100644 vendor/symfony/console/Input/InputDefinition.php
create mode 100644 vendor/symfony/console/Input/InputInterface.php
create mode 100644 vendor/symfony/console/Input/InputOption.php
create mode 100644 vendor/symfony/console/Input/StreamableInputInterface.php
create mode 100644 vendor/symfony/console/Input/StringInput.php
create mode 100644 vendor/symfony/console/LICENSE
create mode 100644 vendor/symfony/console/Logger/ConsoleLogger.php
create mode 100644 vendor/symfony/console/Output/BufferedOutput.php
create mode 100644 vendor/symfony/console/Output/ConsoleOutput.php
create mode 100644 vendor/symfony/console/Output/ConsoleOutputInterface.php
create mode 100644 vendor/symfony/console/Output/ConsoleSectionOutput.php
create mode 100644 vendor/symfony/console/Output/NullOutput.php
create mode 100644 vendor/symfony/console/Output/Output.php
create mode 100644 vendor/symfony/console/Output/OutputInterface.php
create mode 100644 vendor/symfony/console/Output/StreamOutput.php
create mode 100644 vendor/symfony/console/Question/ChoiceQuestion.php
create mode 100644 vendor/symfony/console/Question/ConfirmationQuestion.php
create mode 100644 vendor/symfony/console/Question/Question.php
create mode 100644 vendor/symfony/console/README.md
create mode 100644 vendor/symfony/console/Resources/bin/hiddeninput.exe
create mode 100644 vendor/symfony/console/Style/OutputStyle.php
create mode 100644 vendor/symfony/console/Style/StyleInterface.php
create mode 100644 vendor/symfony/console/Style/SymfonyStyle.php
create mode 100644 vendor/symfony/console/Terminal.php
create mode 100644 vendor/symfony/contracts/CHANGELOG.md
create mode 100644 vendor/symfony/contracts/Cache/CacheInterface.php
create mode 100644 vendor/symfony/contracts/Cache/CacheTrait.php
create mode 100644 vendor/symfony/contracts/Cache/CallbackInterface.php
create mode 100644 vendor/symfony/contracts/Cache/ItemInterface.php
create mode 100644 vendor/symfony/contracts/Cache/LICENSE
create mode 100644 vendor/symfony/contracts/Cache/README.md
create mode 100644 vendor/symfony/contracts/Cache/TagAwareCacheInterface.php
create mode 100644 vendor/symfony/contracts/Cache/composer.json
create mode 100644 vendor/symfony/contracts/EventDispatcher/Event.php
create mode 100644 vendor/symfony/contracts/EventDispatcher/EventDispatcherInterface.php
create mode 100644 vendor/symfony/contracts/EventDispatcher/LICENSE
create mode 100644 vendor/symfony/contracts/EventDispatcher/README.md
create mode 100644 vendor/symfony/contracts/EventDispatcher/composer.json
create mode 100644 vendor/symfony/contracts/HttpClient/ChunkInterface.php
create mode 100644 vendor/symfony/contracts/HttpClient/Exception/ClientExceptionInterface.php
create mode 100644 vendor/symfony/contracts/HttpClient/Exception/DecodingExceptionInterface.php
create mode 100644 vendor/symfony/contracts/HttpClient/Exception/ExceptionInterface.php
create mode 100644 vendor/symfony/contracts/HttpClient/Exception/HttpExceptionInterface.php
create mode 100644 vendor/symfony/contracts/HttpClient/Exception/RedirectionExceptionInterface.php
create mode 100644 vendor/symfony/contracts/HttpClient/Exception/ServerExceptionInterface.php
create mode 100644 vendor/symfony/contracts/HttpClient/Exception/TransportExceptionInterface.php
create mode 100644 vendor/symfony/contracts/HttpClient/HttpClientInterface.php
create mode 100644 vendor/symfony/contracts/HttpClient/LICENSE
create mode 100644 vendor/symfony/contracts/HttpClient/README.md
create mode 100644 vendor/symfony/contracts/HttpClient/ResponseInterface.php
create mode 100644 vendor/symfony/contracts/HttpClient/ResponseStreamInterface.php
create mode 100644 vendor/symfony/contracts/HttpClient/Test/Fixtures/web/index.php
create mode 100644 vendor/symfony/contracts/HttpClient/Test/HttpClientTestCase.php
create mode 100644 vendor/symfony/contracts/HttpClient/Test/TestHttpServer.php
create mode 100644 vendor/symfony/contracts/HttpClient/composer.json
create mode 100644 vendor/symfony/contracts/LICENSE
create mode 100644 vendor/symfony/contracts/README.md
create mode 100644 vendor/symfony/contracts/Service/LICENSE
create mode 100644 vendor/symfony/contracts/Service/README.md
create mode 100644 vendor/symfony/contracts/Service/ResetInterface.php
create mode 100644 vendor/symfony/contracts/Service/ServiceLocatorTrait.php
create mode 100644 vendor/symfony/contracts/Service/ServiceProviderInterface.php
create mode 100644 vendor/symfony/contracts/Service/ServiceSubscriberInterface.php
create mode 100644 vendor/symfony/contracts/Service/ServiceSubscriberTrait.php
create mode 100644 vendor/symfony/contracts/Service/Test/ServiceLocatorTest.php
create mode 100644 vendor/symfony/contracts/Service/composer.json
create mode 100644 vendor/symfony/contracts/Tests/Cache/CacheTraitTest.php
create mode 100644 vendor/symfony/contracts/Tests/Service/ServiceSubscriberTraitTest.php
create mode 100644 vendor/symfony/contracts/Translation/LICENSE
create mode 100644 vendor/symfony/contracts/Translation/LocaleAwareInterface.php
create mode 100644 vendor/symfony/contracts/Translation/README.md
create mode 100644 vendor/symfony/contracts/Translation/Test/TranslatorTest.php
create mode 100644 vendor/symfony/contracts/Translation/TranslatorInterface.php
create mode 100644 vendor/symfony/contracts/Translation/TranslatorTrait.php
create mode 100644 vendor/symfony/contracts/Translation/composer.json
create mode 100644 vendor/symfony/contracts/composer.json
create mode 100644 vendor/symfony/contracts/phpunit.xml.dist
create mode 100644 vendor/symfony/event-dispatcher/CHANGELOG.md
create mode 100644 vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php
create mode 100644 vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcherInterface.php
create mode 100644 vendor/symfony/event-dispatcher/Debug/WrappedListener.php
create mode 100644 vendor/symfony/event-dispatcher/DependencyInjection/RegisterListenersPass.php
create mode 100644 vendor/symfony/event-dispatcher/Event.php
create mode 100644 vendor/symfony/event-dispatcher/EventDispatcher.php
create mode 100644 vendor/symfony/event-dispatcher/EventDispatcherInterface.php
create mode 100644 vendor/symfony/event-dispatcher/EventSubscriberInterface.php
create mode 100644 vendor/symfony/event-dispatcher/GenericEvent.php
create mode 100644 vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php
create mode 100644 vendor/symfony/event-dispatcher/LICENSE
create mode 100644 vendor/symfony/event-dispatcher/README.md
create mode 100644 vendor/symfony/polyfill-ctype/Ctype.php
create mode 100644 vendor/symfony/polyfill-ctype/LICENSE
create mode 100644 vendor/symfony/polyfill-ctype/README.md
create mode 100644 vendor/symfony/polyfill-ctype/bootstrap.php
create mode 100644 vendor/symfony/polyfill-iconv/Iconv.php
create mode 100644 vendor/symfony/polyfill-iconv/LICENSE
create mode 100644 vendor/symfony/polyfill-iconv/README.md
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.big5.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp037.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp1006.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp1026.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp424.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp437.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp500.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp737.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp775.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp850.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp852.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp855.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp856.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp857.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp860.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp861.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp862.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp863.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp864.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp865.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp866.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp869.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp874.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp875.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp932.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp936.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp949.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.cp950.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-1.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-10.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-11.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-13.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-14.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-15.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-16.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-2.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-3.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-4.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-5.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-6.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-7.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-8.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.iso-8859-9.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.koi8-r.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.koi8-u.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.us-ascii.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1250.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1251.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1252.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1253.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1254.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1255.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1256.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1257.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/from.windows-1258.php
create mode 100644 vendor/symfony/polyfill-iconv/Resources/charset/translit.php
create mode 100644 vendor/symfony/polyfill-iconv/bootstrap.php
create mode 100644 vendor/symfony/polyfill-mbstring/LICENSE
create mode 100644 vendor/symfony/polyfill-mbstring/Mbstring.php
create mode 100644 vendor/symfony/polyfill-mbstring/README.md
create mode 100644 vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php
create mode 100644 vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php
create mode 100644 vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php
create mode 100644 vendor/symfony/polyfill-mbstring/bootstrap.php
create mode 100644 vendor/symfony/polyfill-php72/LICENSE
create mode 100644 vendor/symfony/polyfill-php72/Php72.php
create mode 100644 vendor/symfony/polyfill-php72/README.md
create mode 100644 vendor/symfony/polyfill-php72/bootstrap.php
create mode 100644 vendor/symfony/polyfill-php73/LICENSE
create mode 100644 vendor/symfony/polyfill-php73/Php73.php
create mode 100644 vendor/symfony/polyfill-php73/README.md
create mode 100644 vendor/symfony/polyfill-php73/Resources/stubs/JsonException.php
create mode 100644 vendor/symfony/polyfill-php73/bootstrap.php
create mode 100644 vendor/symfony/process/CHANGELOG.md
create mode 100644 vendor/symfony/process/Exception/ExceptionInterface.php
create mode 100644 vendor/symfony/process/Exception/InvalidArgumentException.php
create mode 100644 vendor/symfony/process/Exception/LogicException.php
create mode 100644 vendor/symfony/process/Exception/ProcessFailedException.php
create mode 100644 vendor/symfony/process/Exception/ProcessSignaledException.php
create mode 100644 vendor/symfony/process/Exception/ProcessTimedOutException.php
create mode 100644 vendor/symfony/process/Exception/RuntimeException.php
create mode 100644 vendor/symfony/process/ExecutableFinder.php
create mode 100644 vendor/symfony/process/InputStream.php
create mode 100644 vendor/symfony/process/LICENSE
create mode 100644 vendor/symfony/process/PhpExecutableFinder.php
create mode 100644 vendor/symfony/process/PhpProcess.php
create mode 100644 vendor/symfony/process/Pipes/AbstractPipes.php
create mode 100644 vendor/symfony/process/Pipes/PipesInterface.php
create mode 100644 vendor/symfony/process/Pipes/UnixPipes.php
create mode 100644 vendor/symfony/process/Pipes/WindowsPipes.php
create mode 100644 vendor/symfony/process/Process.php
create mode 100644 vendor/symfony/process/ProcessUtils.php
create mode 100644 vendor/symfony/process/README.md
create mode 100644 vendor/symfony/var-dumper/CHANGELOG.md
create mode 100644 vendor/symfony/var-dumper/Caster/AmqpCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/ArgsStub.php
create mode 100644 vendor/symfony/var-dumper/Caster/Caster.php
create mode 100644 vendor/symfony/var-dumper/Caster/ClassStub.php
create mode 100644 vendor/symfony/var-dumper/Caster/ConstStub.php
create mode 100644 vendor/symfony/var-dumper/Caster/CutArrayStub.php
create mode 100644 vendor/symfony/var-dumper/Caster/CutStub.php
create mode 100644 vendor/symfony/var-dumper/Caster/DOMCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/DateCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/DoctrineCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/EnumStub.php
create mode 100644 vendor/symfony/var-dumper/Caster/ExceptionCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/FrameStub.php
create mode 100644 vendor/symfony/var-dumper/Caster/GmpCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/IntlCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/LinkStub.php
create mode 100644 vendor/symfony/var-dumper/Caster/MemcachedCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/PdoCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/PgSqlCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/ProxyManagerCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/RedisCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/ReflectionCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/ResourceCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/SplCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/StubCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/SymfonyCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/TraceStub.php
create mode 100644 vendor/symfony/var-dumper/Caster/XmlReaderCaster.php
create mode 100644 vendor/symfony/var-dumper/Caster/XmlResourceCaster.php
create mode 100644 vendor/symfony/var-dumper/Cloner/AbstractCloner.php
create mode 100644 vendor/symfony/var-dumper/Cloner/ClonerInterface.php
create mode 100644 vendor/symfony/var-dumper/Cloner/Cursor.php
create mode 100644 vendor/symfony/var-dumper/Cloner/Data.php
create mode 100644 vendor/symfony/var-dumper/Cloner/DumperInterface.php
create mode 100644 vendor/symfony/var-dumper/Cloner/Stub.php
create mode 100644 vendor/symfony/var-dumper/Cloner/VarCloner.php
create mode 100644 vendor/symfony/var-dumper/Command/Descriptor/CliDescriptor.php
create mode 100644 vendor/symfony/var-dumper/Command/Descriptor/DumpDescriptorInterface.php
create mode 100644 vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php
create mode 100644 vendor/symfony/var-dumper/Command/ServerDumpCommand.php
create mode 100644 vendor/symfony/var-dumper/Dumper/AbstractDumper.php
create mode 100644 vendor/symfony/var-dumper/Dumper/CliDumper.php
create mode 100644 vendor/symfony/var-dumper/Dumper/ContextProvider/CliContextProvider.php
create mode 100644 vendor/symfony/var-dumper/Dumper/ContextProvider/ContextProviderInterface.php
create mode 100644 vendor/symfony/var-dumper/Dumper/ContextProvider/RequestContextProvider.php
create mode 100644 vendor/symfony/var-dumper/Dumper/ContextProvider/SourceContextProvider.php
create mode 100644 vendor/symfony/var-dumper/Dumper/DataDumperInterface.php
create mode 100644 vendor/symfony/var-dumper/Dumper/HtmlDumper.php
create mode 100644 vendor/symfony/var-dumper/Dumper/ServerDumper.php
create mode 100644 vendor/symfony/var-dumper/Exception/ThrowingCasterException.php
create mode 100644 vendor/symfony/var-dumper/LICENSE
create mode 100644 vendor/symfony/var-dumper/README.md
create mode 100755 vendor/symfony/var-dumper/Resources/bin/var-dump-server
create mode 100644 vendor/symfony/var-dumper/Resources/css/htmlDescriptor.css
create mode 100644 vendor/symfony/var-dumper/Resources/functions/dump.php
create mode 100644 vendor/symfony/var-dumper/Resources/js/htmlDescriptor.js
create mode 100644 vendor/symfony/var-dumper/Server/Connection.php
create mode 100644 vendor/symfony/var-dumper/Server/DumpServer.php
create mode 100644 vendor/symfony/var-dumper/VarDumper.php
create mode 100644 vendor/symfony/yaml/CHANGELOG.md
create mode 100644 vendor/symfony/yaml/Command/LintCommand.php
create mode 100644 vendor/symfony/yaml/Dumper.php
create mode 100644 vendor/symfony/yaml/Escaper.php
create mode 100644 vendor/symfony/yaml/Exception/DumpException.php
create mode 100644 vendor/symfony/yaml/Exception/ExceptionInterface.php
create mode 100644 vendor/symfony/yaml/Exception/ParseException.php
create mode 100644 vendor/symfony/yaml/Exception/RuntimeException.php
create mode 100644 vendor/symfony/yaml/Inline.php
create mode 100644 vendor/symfony/yaml/LICENSE
create mode 100644 vendor/symfony/yaml/Parser.php
create mode 100644 vendor/symfony/yaml/README.md
create mode 100644 vendor/symfony/yaml/Tag/TaggedValue.php
create mode 100644 vendor/symfony/yaml/Unescaper.php
create mode 100644 vendor/symfony/yaml/Yaml.php
create mode 100644 vendor/twig/twig/.gitattributes
create mode 100644 vendor/twig/twig/CHANGELOG
create mode 100644 vendor/twig/twig/LICENSE
create mode 100644 vendor/twig/twig/README.rst
create mode 100755 vendor/twig/twig/drupal_test.sh
create mode 100644 vendor/twig/twig/lib/Twig/Autoloader.php
create mode 100644 vendor/twig/twig/lib/Twig/BaseNodeVisitor.php
create mode 100644 vendor/twig/twig/lib/Twig/Cache/Filesystem.php
create mode 100644 vendor/twig/twig/lib/Twig/Cache/Null.php
create mode 100644 vendor/twig/twig/lib/Twig/CacheInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Compiler.php
create mode 100644 vendor/twig/twig/lib/Twig/CompilerInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/ContainerRuntimeLoader.php
create mode 100644 vendor/twig/twig/lib/Twig/Environment.php
create mode 100644 vendor/twig/twig/lib/Twig/Error.php
create mode 100644 vendor/twig/twig/lib/Twig/Error/Loader.php
create mode 100644 vendor/twig/twig/lib/Twig/Error/Runtime.php
create mode 100644 vendor/twig/twig/lib/Twig/Error/Syntax.php
create mode 100644 vendor/twig/twig/lib/Twig/ExistsLoaderInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/ExpressionParser.php
create mode 100644 vendor/twig/twig/lib/Twig/Extension.php
create mode 100644 vendor/twig/twig/lib/Twig/Extension/Core.php
create mode 100644 vendor/twig/twig/lib/Twig/Extension/Debug.php
create mode 100644 vendor/twig/twig/lib/Twig/Extension/Escaper.php
create mode 100644 vendor/twig/twig/lib/Twig/Extension/GlobalsInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Extension/InitRuntimeInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Extension/Optimizer.php
create mode 100644 vendor/twig/twig/lib/Twig/Extension/Profiler.php
create mode 100644 vendor/twig/twig/lib/Twig/Extension/Sandbox.php
create mode 100644 vendor/twig/twig/lib/Twig/Extension/Staging.php
create mode 100644 vendor/twig/twig/lib/Twig/Extension/StringLoader.php
create mode 100644 vendor/twig/twig/lib/Twig/ExtensionInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/FactoryRuntimeLoader.php
create mode 100644 vendor/twig/twig/lib/Twig/FileExtensionEscapingStrategy.php
create mode 100644 vendor/twig/twig/lib/Twig/Filter.php
create mode 100644 vendor/twig/twig/lib/Twig/Filter/Function.php
create mode 100644 vendor/twig/twig/lib/Twig/Filter/Method.php
create mode 100644 vendor/twig/twig/lib/Twig/Filter/Node.php
create mode 100644 vendor/twig/twig/lib/Twig/FilterCallableInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/FilterInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Function.php
create mode 100644 vendor/twig/twig/lib/Twig/Function/Function.php
create mode 100644 vendor/twig/twig/lib/Twig/Function/Method.php
create mode 100644 vendor/twig/twig/lib/Twig/Function/Node.php
create mode 100644 vendor/twig/twig/lib/Twig/FunctionCallableInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/FunctionInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Lexer.php
create mode 100644 vendor/twig/twig/lib/Twig/LexerInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Loader/Array.php
create mode 100644 vendor/twig/twig/lib/Twig/Loader/Chain.php
create mode 100644 vendor/twig/twig/lib/Twig/Loader/Filesystem.php
create mode 100644 vendor/twig/twig/lib/Twig/Loader/String.php
create mode 100644 vendor/twig/twig/lib/Twig/LoaderInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Markup.php
create mode 100644 vendor/twig/twig/lib/Twig/Node.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/AutoEscape.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Block.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/BlockReference.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Body.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/CheckSecurity.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Deprecated.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Do.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Embed.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Array.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/AssignName.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Add.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/And.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Div.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/In.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Less.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Or.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Power.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Range.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Call.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Conditional.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Constant.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Filter.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Filter/Default.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Function.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/GetAttr.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/MethodCall.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Name.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/NullCoalesce.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Parent.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/TempName.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Test.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Test/Constant.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Test/Defined.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Test/Even.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Test/Null.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Test/Odd.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Unary.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Unary/Not.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Flush.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/For.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/ForLoop.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/If.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Import.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Include.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Macro.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Module.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Print.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Sandbox.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/SandboxedPrint.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Set.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/SetTemp.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Spaceless.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/Text.php
create mode 100644 vendor/twig/twig/lib/Twig/Node/With.php
create mode 100644 vendor/twig/twig/lib/Twig/NodeCaptureInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/NodeInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/NodeOutputInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/NodeTraverser.php
create mode 100644 vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php
create mode 100644 vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php
create mode 100644 vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php
create mode 100644 vendor/twig/twig/lib/Twig/NodeVisitor/Sandbox.php
create mode 100644 vendor/twig/twig/lib/Twig/NodeVisitorInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Parser.php
create mode 100644 vendor/twig/twig/lib/Twig/ParserInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Profiler/Dumper/Base.php
create mode 100644 vendor/twig/twig/lib/Twig/Profiler/Dumper/Blackfire.php
create mode 100644 vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php
create mode 100644 vendor/twig/twig/lib/Twig/Profiler/Dumper/Text.php
create mode 100644 vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php
create mode 100644 vendor/twig/twig/lib/Twig/Profiler/Node/LeaveProfile.php
create mode 100644 vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php
create mode 100644 vendor/twig/twig/lib/Twig/Profiler/Profile.php
create mode 100644 vendor/twig/twig/lib/Twig/RuntimeLoaderInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Sandbox/SecurityError.php
create mode 100644 vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php
create mode 100644 vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php
create mode 100644 vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php
create mode 100644 vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php
create mode 100644 vendor/twig/twig/lib/Twig/Sandbox/SecurityNotAllowedTagError.php
create mode 100644 vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php
create mode 100644 vendor/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/SimpleFilter.php
create mode 100644 vendor/twig/twig/lib/Twig/SimpleFunction.php
create mode 100644 vendor/twig/twig/lib/Twig/SimpleTest.php
create mode 100644 vendor/twig/twig/lib/Twig/Source.php
create mode 100644 vendor/twig/twig/lib/Twig/SourceContextLoaderInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Template.php
create mode 100644 vendor/twig/twig/lib/Twig/TemplateInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/TemplateWrapper.php
create mode 100644 vendor/twig/twig/lib/Twig/Test.php
create mode 100644 vendor/twig/twig/lib/Twig/Test/Function.php
create mode 100644 vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php
create mode 100644 vendor/twig/twig/lib/Twig/Test/Method.php
create mode 100644 vendor/twig/twig/lib/Twig/Test/Node.php
create mode 100644 vendor/twig/twig/lib/Twig/Test/NodeTestCase.php
create mode 100644 vendor/twig/twig/lib/Twig/TestCallableInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/TestInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/Token.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Block.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Deprecated.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Do.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Embed.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Extends.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Filter.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Flush.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/For.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/From.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/If.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Import.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Include.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Macro.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Sandbox.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Set.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Spaceless.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/Use.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParser/With.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParserBroker.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenParserInterface.php
create mode 100644 vendor/twig/twig/lib/Twig/TokenStream.php
create mode 100644 vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php
create mode 100644 vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php
create mode 100644 vendor/twig/twig/src/Cache/CacheInterface.php
create mode 100644 vendor/twig/twig/src/Cache/FilesystemCache.php
create mode 100644 vendor/twig/twig/src/Cache/NullCache.php
create mode 100644 vendor/twig/twig/src/Compiler.php
create mode 100644 vendor/twig/twig/src/Environment.php
create mode 100644 vendor/twig/twig/src/Error/Error.php
create mode 100644 vendor/twig/twig/src/Error/LoaderError.php
create mode 100644 vendor/twig/twig/src/Error/RuntimeError.php
create mode 100644 vendor/twig/twig/src/Error/SyntaxError.php
create mode 100644 vendor/twig/twig/src/ExpressionParser.php
create mode 100644 vendor/twig/twig/src/Extension/AbstractExtension.php
create mode 100644 vendor/twig/twig/src/Extension/CoreExtension.php
create mode 100644 vendor/twig/twig/src/Extension/DebugExtension.php
create mode 100644 vendor/twig/twig/src/Extension/EscaperExtension.php
create mode 100644 vendor/twig/twig/src/Extension/ExtensionInterface.php
create mode 100644 vendor/twig/twig/src/Extension/GlobalsInterface.php
create mode 100644 vendor/twig/twig/src/Extension/InitRuntimeInterface.php
create mode 100644 vendor/twig/twig/src/Extension/OptimizerExtension.php
create mode 100644 vendor/twig/twig/src/Extension/ProfilerExtension.php
create mode 100644 vendor/twig/twig/src/Extension/RuntimeExtensionInterface.php
create mode 100644 vendor/twig/twig/src/Extension/SandboxExtension.php
create mode 100644 vendor/twig/twig/src/Extension/StagingExtension.php
create mode 100644 vendor/twig/twig/src/Extension/StringLoaderExtension.php
create mode 100644 vendor/twig/twig/src/FileExtensionEscapingStrategy.php
create mode 100644 vendor/twig/twig/src/Lexer.php
create mode 100644 vendor/twig/twig/src/Loader/ArrayLoader.php
create mode 100644 vendor/twig/twig/src/Loader/ChainLoader.php
create mode 100644 vendor/twig/twig/src/Loader/ExistsLoaderInterface.php
create mode 100644 vendor/twig/twig/src/Loader/FilesystemLoader.php
create mode 100644 vendor/twig/twig/src/Loader/LoaderInterface.php
create mode 100644 vendor/twig/twig/src/Loader/SourceContextLoaderInterface.php
create mode 100644 vendor/twig/twig/src/Markup.php
create mode 100644 vendor/twig/twig/src/Node/AutoEscapeNode.php
create mode 100644 vendor/twig/twig/src/Node/BlockNode.php
create mode 100644 vendor/twig/twig/src/Node/BlockReferenceNode.php
create mode 100644 vendor/twig/twig/src/Node/BodyNode.php
create mode 100644 vendor/twig/twig/src/Node/CheckSecurityNode.php
create mode 100644 vendor/twig/twig/src/Node/CheckToStringNode.php
create mode 100644 vendor/twig/twig/src/Node/DeprecatedNode.php
create mode 100644 vendor/twig/twig/src/Node/DoNode.php
create mode 100644 vendor/twig/twig/src/Node/EmbedNode.php
create mode 100644 vendor/twig/twig/src/Node/Expression/AbstractExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/ArrayExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/ArrowFunctionExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/AssignNameExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/AbstractBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/AddBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/AndBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/BitwiseAndBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/BitwiseOrBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/BitwiseXorBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/ConcatBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/DivBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/EndsWithBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/EqualBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/FloorDivBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/GreaterBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/GreaterEqualBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/InBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/LessBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/LessEqualBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/MatchesBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/ModBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/MulBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/NotEqualBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/NotInBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/OrBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/PowerBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/RangeBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/StartsWithBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Binary/SubBinary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/BlockReferenceExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/CallExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/ConditionalExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/ConstantExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Filter/DefaultFilter.php
create mode 100644 vendor/twig/twig/src/Node/Expression/FilterExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/FunctionExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/GetAttrExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/InlinePrint.php
create mode 100644 vendor/twig/twig/src/Node/Expression/MethodCallExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/NameExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/NullCoalesceExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/ParentExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/TempNameExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Test/ConstantTest.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Test/DefinedTest.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Test/DivisiblebyTest.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Test/EvenTest.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Test/NullTest.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Test/OddTest.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Test/SameasTest.php
create mode 100644 vendor/twig/twig/src/Node/Expression/TestExpression.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Unary/AbstractUnary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Unary/NegUnary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Unary/NotUnary.php
create mode 100644 vendor/twig/twig/src/Node/Expression/Unary/PosUnary.php
create mode 100644 vendor/twig/twig/src/Node/FlushNode.php
create mode 100644 vendor/twig/twig/src/Node/ForLoopNode.php
create mode 100644 vendor/twig/twig/src/Node/ForNode.php
create mode 100644 vendor/twig/twig/src/Node/IfNode.php
create mode 100644 vendor/twig/twig/src/Node/ImportNode.php
create mode 100644 vendor/twig/twig/src/Node/IncludeNode.php
create mode 100644 vendor/twig/twig/src/Node/MacroNode.php
create mode 100644 vendor/twig/twig/src/Node/ModuleNode.php
create mode 100644 vendor/twig/twig/src/Node/Node.php
create mode 100644 vendor/twig/twig/src/Node/NodeCaptureInterface.php
create mode 100644 vendor/twig/twig/src/Node/NodeOutputInterface.php
create mode 100644 vendor/twig/twig/src/Node/PrintNode.php
create mode 100644 vendor/twig/twig/src/Node/SandboxNode.php
create mode 100644 vendor/twig/twig/src/Node/SandboxedPrintNode.php
create mode 100644 vendor/twig/twig/src/Node/SetNode.php
create mode 100644 vendor/twig/twig/src/Node/SetTempNode.php
create mode 100644 vendor/twig/twig/src/Node/SpacelessNode.php
create mode 100644 vendor/twig/twig/src/Node/TextNode.php
create mode 100644 vendor/twig/twig/src/Node/WithNode.php
create mode 100644 vendor/twig/twig/src/NodeTraverser.php
create mode 100644 vendor/twig/twig/src/NodeVisitor/AbstractNodeVisitor.php
create mode 100644 vendor/twig/twig/src/NodeVisitor/EscaperNodeVisitor.php
create mode 100644 vendor/twig/twig/src/NodeVisitor/NodeVisitorInterface.php
create mode 100644 vendor/twig/twig/src/NodeVisitor/OptimizerNodeVisitor.php
create mode 100644 vendor/twig/twig/src/NodeVisitor/SafeAnalysisNodeVisitor.php
create mode 100644 vendor/twig/twig/src/NodeVisitor/SandboxNodeVisitor.php
create mode 100644 vendor/twig/twig/src/Parser.php
create mode 100644 vendor/twig/twig/src/Profiler/Dumper/BaseDumper.php
create mode 100644 vendor/twig/twig/src/Profiler/Dumper/BlackfireDumper.php
create mode 100644 vendor/twig/twig/src/Profiler/Dumper/HtmlDumper.php
create mode 100644 vendor/twig/twig/src/Profiler/Dumper/TextDumper.php
create mode 100644 vendor/twig/twig/src/Profiler/Node/EnterProfileNode.php
create mode 100644 vendor/twig/twig/src/Profiler/Node/LeaveProfileNode.php
create mode 100644 vendor/twig/twig/src/Profiler/NodeVisitor/ProfilerNodeVisitor.php
create mode 100644 vendor/twig/twig/src/Profiler/Profile.php
create mode 100644 vendor/twig/twig/src/RuntimeLoader/ContainerRuntimeLoader.php
create mode 100644 vendor/twig/twig/src/RuntimeLoader/FactoryRuntimeLoader.php
create mode 100644 vendor/twig/twig/src/RuntimeLoader/RuntimeLoaderInterface.php
create mode 100644 vendor/twig/twig/src/Sandbox/SecurityError.php
create mode 100644 vendor/twig/twig/src/Sandbox/SecurityNotAllowedFilterError.php
create mode 100644 vendor/twig/twig/src/Sandbox/SecurityNotAllowedFunctionError.php
create mode 100644 vendor/twig/twig/src/Sandbox/SecurityNotAllowedMethodError.php
create mode 100644 vendor/twig/twig/src/Sandbox/SecurityNotAllowedPropertyError.php
create mode 100644 vendor/twig/twig/src/Sandbox/SecurityNotAllowedTagError.php
create mode 100644 vendor/twig/twig/src/Sandbox/SecurityPolicy.php
create mode 100644 vendor/twig/twig/src/Sandbox/SecurityPolicyInterface.php
create mode 100644 vendor/twig/twig/src/Source.php
create mode 100644 vendor/twig/twig/src/Template.php
create mode 100644 vendor/twig/twig/src/TemplateWrapper.php
create mode 100644 vendor/twig/twig/src/Test/IntegrationTestCase.php
create mode 100644 vendor/twig/twig/src/Test/NodeTestCase.php
create mode 100644 vendor/twig/twig/src/Token.php
create mode 100644 vendor/twig/twig/src/TokenParser/AbstractTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/ApplyTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/AutoEscapeTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/BlockTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/DeprecatedTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/DoTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/EmbedTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/ExtendsTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/FilterTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/FlushTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/ForTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/FromTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/IfTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/ImportTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/IncludeTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/MacroTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/SandboxTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/SetTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/SpacelessTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/TokenParserInterface.php
create mode 100644 vendor/twig/twig/src/TokenParser/UseTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenParser/WithTokenParser.php
create mode 100644 vendor/twig/twig/src/TokenStream.php
create mode 100644 vendor/twig/twig/src/TwigFilter.php
create mode 100644 vendor/twig/twig/src/TwigFunction.php
create mode 100644 vendor/twig/twig/src/TwigTest.php
create mode 100644 vendor/twig/twig/src/Util/DeprecationCollector.php
create mode 100644 vendor/twig/twig/src/Util/TemplateDirIterator.php
create mode 100644 vendor/willdurand/negotiation/CONTRIBUTING.md
create mode 100644 vendor/willdurand/negotiation/LICENSE
create mode 100644 vendor/willdurand/negotiation/README.md
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/AbstractNegotiator.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/Accept.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/AcceptCharset.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/AcceptEncoding.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/AcceptHeader.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/AcceptLanguage.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/BaseAccept.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/CharsetNegotiator.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/EncodingNegotiator.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/Exception/Exception.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/Exception/InvalidArgument.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/Exception/InvalidHeader.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/Exception/InvalidLanguage.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/Exception/InvalidMediaType.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/LanguageNegotiator.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/Match.php
create mode 100644 vendor/willdurand/negotiation/src/Negotiation/Negotiator.php
create mode 100644 webserver-configs/Caddyfile
create mode 100644 webserver-configs/Caddyfile-0.8.x
create mode 100644 webserver-configs/htaccess.txt
create mode 100644 webserver-configs/lighttpd.conf
create mode 100644 webserver-configs/nginx.conf
create mode 100644 webserver-configs/web.config
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..e84f52b
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,8 @@
+# These are supported funding model platforms
+
+github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
+patreon: # Replace with a single Patreon username
+open_collective: grav
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+custom: # Replace with a single custom sponsorship URL
diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..ef79a4b
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,75 @@
+
+
+RewriteEngine On
+
+## Begin RewriteBase
+# If you are getting 500 or 404 errors on subpages, you may have to uncomment the RewriteBase entry
+# You should change the '/' to your appropriate subfolder. For example if you have
+# your Grav install at the root of your site '/' should work, else it might be something
+# along the lines of: RewriteBase /
+##
+
+# RewriteBase /
+
+## End - RewriteBase
+
+## Begin - X-Forwarded-Proto
+# In some hosted or load balanced environments, SSL negotiation happens upstream.
+# In order for Grav to recognize the connection as secure, you need to uncomment
+# the following lines.
+#
+# RewriteCond %{HTTP:X-Forwarded-Proto} https
+# RewriteRule .* - [E=HTTPS:on]
+#
+## End - X-Forwarded-Proto
+
+## Begin - Exploits
+# If you experience problems on your site block out the operations listed below
+# This attempts to block the most common type of exploit `attempts` to Grav
+#
+# Block out any script trying to base64_encode data within the URL.
+RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
+# Block out any script that includes a \n";
+ }
+}
diff --git a/system/src/Grav/Common/Assets/Js.php b/system/src/Grav/Common/Assets/Js.php
new file mode 100644
index 0000000..cce86d9
--- /dev/null
+++ b/system/src/Grav/Common/Assets/Js.php
@@ -0,0 +1,36 @@
+ 'js',
+ ];
+
+ $merged_attributes = Utils::arrayMergeRecursiveUnique($base_options, $elements);
+
+ parent::__construct($merged_attributes, $key);
+ }
+
+ public function render()
+ {
+ if (isset($this->attributes['loading']) && $this->attributes['loading'] === 'inline') {
+ $buffer = $this->gatherLinks( [$this], self::JS_ASSET);
+ return '\n";
+ }
+
+ return '\n";
+ }
+}
diff --git a/system/src/Grav/Common/Assets/Pipeline.php b/system/src/Grav/Common/Assets/Pipeline.php
new file mode 100644
index 0000000..b009585
--- /dev/null
+++ b/system/src/Grav/Common/Assets/Pipeline.php
@@ -0,0 +1,273 @@
+base_url = rtrim($uri->rootUrl($config->get('system.absolute_urls')), '/') . '/';
+ $this->assets_dir = $locator->findResource('asset://') . DS;
+ $this->assets_url = $locator->findResource('asset://', false);
+ }
+
+ /**
+ * Minify and concatenate CSS
+ *
+ * @param array $assets
+ * @param string $group
+ * @param array $attributes
+ *
+ * @return bool|string URL or generated content if available, else false
+ */
+ public function renderCss($assets, $group, $attributes = [])
+ {
+ // temporary list of assets to pipeline
+ $inline_group = false;
+
+ if (array_key_exists('loading', $attributes) && $attributes['loading'] === 'inline') {
+ $inline_group = true;
+ unset($attributes['loading']);
+ }
+
+ // Store Attributes
+ $this->attributes = array_merge(['type' => 'text/css', 'rel' => 'stylesheet'], $attributes);
+
+ // Compute uid based on assets and timestamp
+ $json_assets = json_encode($assets);
+ $uid = md5($json_assets . $this->css_minify . $this->css_rewrite . $group);
+ $file = $uid . '.css';
+ $relative_path = "{$this->base_url}{$this->assets_url}/{$file}";
+
+ $buffer = null;
+
+ if (file_exists($this->assets_dir . $file)) {
+ $buffer = file_get_contents($this->assets_dir . $file) . "\n";
+ } else {
+ //if nothing found get out of here!
+ if (empty($assets)) {
+ return false;
+ }
+
+ // Concatenate files
+ $buffer = $this->gatherLinks($assets, self::CSS_ASSET);
+
+ // Minify if required
+ if ($this->shouldMinify('css')) {
+ $minifier = new \MatthiasMullie\Minify\CSS();
+ $minifier->add($buffer);
+ $buffer = $minifier->minify();
+ }
+
+ // Write file
+ if (trim($buffer) !== '') {
+ file_put_contents($this->assets_dir . $file, $buffer);
+ }
+ }
+
+ if ($inline_group) {
+ $output = "\n";
+ } else {
+ $this->asset = $relative_path;
+ $output = ' renderAttributes() . ">\n";
+ }
+
+ return $output;
+ }
+
+ /**
+ * Minify and concatenate JS files.
+ *
+ * @param array $assets
+ * @param string $group
+ * @param array $attributes
+ *
+ * @return bool|string URL or generated content if available, else false
+ */
+ public function renderJs($assets, $group, $attributes = [])
+ {
+ // temporary list of assets to pipeline
+ $inline_group = false;
+
+ if (array_key_exists('loading', $attributes) && $attributes['loading'] === 'inline') {
+ $inline_group = true;
+ unset($attributes['loading']);
+ }
+
+ // Store Attributes
+ $this->attributes = $attributes;
+
+ // Compute uid based on assets and timestamp
+ $json_assets = json_encode($assets);
+ $uid = md5($json_assets . $this->js_minify . $group);
+ $file = $uid . '.js';
+ $relative_path = "{$this->base_url}{$this->assets_url}/{$file}";
+
+ $buffer = null;
+
+ if (file_exists($this->assets_dir . $file)) {
+ $buffer = file_get_contents($this->assets_dir . $file) . "\n";
+ } else {
+ //if nothing found get out of here!
+ if (empty($assets)) {
+ return false;
+ }
+
+ // Concatenate files
+ $buffer = $this->gatherLinks($assets, self::JS_ASSET);
+
+ // Minify if required
+ if ($this->shouldMinify('js')) {
+ $minifier = new \MatthiasMullie\Minify\JS();
+ $minifier->add($buffer);
+ $buffer = $minifier->minify();
+ }
+
+ // Write file
+ if (trim($buffer) !== '') {
+ file_put_contents($this->assets_dir . $file, $buffer);
+ }
+ }
+
+ if ($inline_group) {
+ $output = '\n";
+ } else {
+ $this->asset = $relative_path;
+ $output = '\n";
+ }
+
+ return $output;
+ }
+
+
+ /**
+ * Finds relative CSS urls() and rewrites the URL with an absolute one
+ *
+ * @param string $file the css source file
+ * @param string $dir , $local relative path to the css file
+ * @param bool $local is this a local or remote asset
+ *
+ * @return mixed
+ */
+ protected function cssRewrite($file, $dir, $local)
+ {
+ // Strip any sourcemap comments
+ $file = preg_replace(self::CSS_SOURCEMAP_REGEX, '', $file);
+
+ // Find any css url() elements, grab the URLs and calculate an absolute path
+ // Then replace the old url with the new one
+ $file = (string)preg_replace_callback(self::CSS_URL_REGEX, function ($matches) use ($dir, $local) {
+
+ $old_url = $matches[2];
+
+ // Ensure link is not rooted to web server, a data URL, or to a remote host
+ if (preg_match(self::FIRST_FORWARDSLASH_REGEX, $old_url) || Utils::startsWith($old_url, 'data:') || $this->isRemoteLink($old_url)) {
+ return $matches[0];
+ }
+
+ // clean leading /
+ $old_url = Utils::normalizePath($dir . '/' . $old_url);
+ if (preg_match(self::FIRST_FORWARDSLASH_REGEX, $old_url)) {
+ $old_url = ltrim($old_url, '/');
+ }
+
+ $new_url = ($local ? $this->base_url: '') . $old_url;
+
+ $fixed = str_replace($matches[2], $new_url, $matches[0]);
+
+ return $fixed;
+ }, $file);
+
+ return $file;
+ }
+
+
+
+ private function shouldMinify($type = 'css')
+ {
+ $check = $type . '_minify';
+ $win_check = $type . '_minify_windows';
+
+ $minify = (bool) $this->$check;
+
+ // If this is a Windows server, and minify_windows is false (default value) skip the
+ // minification process because it will cause Apache to die/crash due to insufficient
+ // ThreadStackSize in httpd.conf - See: https://bugs.php.net/bug.php?id=47689
+ if (stripos(php_uname('s'), 'WIN') === 0 && !$this->{$win_check}) {
+ $minify = false;
+ }
+
+ return $minify;
+ }
+}
diff --git a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
new file mode 100644
index 0000000..0a1d149
--- /dev/null
+++ b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
@@ -0,0 +1,182 @@
+rootUrl(true);
+
+ // Sanity check for local URLs with absolute URL's enabled
+ if (Utils::startsWith($link, $base)) {
+ return false;
+ }
+
+ return (0 === strpos($link, 'http://') || 0 === strpos($link, 'https://') || 0 === strpos($link, '//'));
+ }
+
+ /**
+ * Download and concatenate the content of several links.
+ *
+ * @param array $assets
+ * @param bool $css
+ *
+ * @return string
+ */
+ protected function gatherLinks(array $assets, $css = true)
+ {
+ $buffer = '';
+
+
+ foreach ($assets as $id => $asset) {
+ $local = true;
+
+ $link = $asset->getAsset();
+ $relative_path = $link;
+
+ if (static::isRemoteLink($link)) {
+ $local = false;
+ if (0 === strpos($link, '//')) {
+ $link = 'http:' . $link;
+ }
+ $relative_dir = \dirname($relative_path);
+ } else {
+ // Fix to remove relative dir if grav is in one
+ if (($this->base_url !== '/') && Utils::startsWith($relative_path, $this->base_url)) {
+ $base_url = '#' . preg_quote($this->base_url, '#') . '#';
+ $relative_path = ltrim(preg_replace($base_url, '/', $link, 1), '/');
+ }
+
+ $relative_dir = \dirname($relative_path);
+ $link = ROOT_DIR . $relative_path;
+ }
+
+ $file = ($this->fetch_command instanceof \Closure) ? @$this->fetch_command->__invoke($link) : @file_get_contents($link);
+
+ // No file found, skip it...
+ if ($file === false) {
+ continue;
+ }
+
+ // Double check last character being
+ if (!$css) {
+ $file = rtrim($file, ' ;') . ';';
+ }
+
+ // If this is CSS + the file is local + rewrite enabled
+ if ($css && $this->css_rewrite) {
+ $file = $this->cssRewrite($file, $relative_dir, $local);
+ }
+
+ $file = rtrim($file) . PHP_EOL;
+ $buffer .= $file;
+ }
+
+ // Pull out @imports and move to top
+ if ($css) {
+ $buffer = $this->moveImports($buffer);
+ }
+
+ return $buffer;
+ }
+
+ /**
+ * Moves @import statements to the top of the file per the CSS specification
+ *
+ * @param string $file the file containing the combined CSS files
+ *
+ * @return string the modified file with any @imports at the top of the file
+ */
+ protected function moveImports($file)
+ {
+ $imports = [];
+
+ $file = (string)preg_replace_callback(self::CSS_IMPORT_REGEX, function ($matches) use (&$imports) {
+ $imports[] = $matches[0];
+
+ return '';
+ }, $file);
+
+ return implode("\n", $imports) . "\n\n" . $file;
+ }
+
+ /**
+ *
+ * Build an HTML attribute string from an array.
+ *
+ * @return string
+ */
+ protected function renderAttributes()
+ {
+ $html = '';
+ $no_key = ['loading'];
+
+ foreach ($this->attributes as $key => $value) {
+ if (is_numeric($key)) {
+ $key = $value;
+ }
+ if (\is_array($value)) {
+ $value = implode(' ', $value);
+ }
+
+ if (\in_array($key, $no_key, true)) {
+ $element = htmlentities($value, ENT_QUOTES, 'UTF-8', false);
+ } else {
+ $element = $key . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
+ }
+
+ $html .= ' ' . $element;
+ }
+
+ return $html;
+ }
+
+ /**
+ * Render Querystring
+ *
+ * @param string $asset
+ * @return string
+ */
+ protected function renderQueryString($asset = null)
+ {
+ $querystring = '';
+
+ $asset = $asset ?? $this->asset;
+
+ if (!empty($this->query)) {
+ if (Utils::contains($asset, '?')) {
+ $querystring .= '&' . $this->query;
+ } else {
+ $querystring .= '?' . $this->query;
+ }
+ }
+
+ if ($this->timestamp) {
+ if (Utils::contains($asset, '?') || $querystring) {
+ $querystring .= '&' . $this->timestamp;
+ } else {
+ $querystring .= '?' . $this->timestamp;
+ }
+ }
+
+ return $querystring;
+ }
+}
diff --git a/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
new file mode 100644
index 0000000..7f91c6d
--- /dev/null
+++ b/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
@@ -0,0 +1,129 @@
+ null, 'pipeline' => true, 'loading' => null, 'group' => null];
+ $arguments = $this->createArgumentsFromLegacy($args, $defaults);
+ break;
+
+ case(Assets::INLINE_JS_TYPE):
+ $defaults = ['priority' => null, 'group' => null, 'attributes' => null];
+ $arguments = $this->createArgumentsFromLegacy($args, $defaults);
+
+ // special case to handle old attributes being passed in
+ if (isset($arguments['attributes'])) {
+ $old_attributes = $arguments['attributes'];
+ if (is_array($old_attributes)) {
+ $arguments = array_merge($arguments, $old_attributes);
+ } else {
+ $arguments['type'] = $old_attributes;
+ }
+ }
+ unset($arguments['attributes']);
+
+ break;
+
+ case(Assets::INLINE_CSS_TYPE):
+ $defaults = ['priority' => null, 'group' => null];
+ $arguments = $this->createArgumentsFromLegacy($args, $defaults);
+ break;
+
+ default:
+ case(Assets::CSS_TYPE):
+ $defaults = ['priority' => null, 'pipeline' => true, 'group' => null, 'loading' => null];
+ $arguments = $this->createArgumentsFromLegacy($args, $defaults);
+ }
+
+ return $arguments;
+ }
+
+ protected function createArgumentsFromLegacy(array $args, array $defaults)
+ {
+ // Remove arguments with old default values.
+ $arguments = [];
+ foreach ($args as $arg) {
+ $default = current($defaults);
+ if ($arg !== $default) {
+ $arguments[key($defaults)] = $arg;
+ }
+ next($defaults);
+ }
+
+ return $arguments;
+ }
+
+ /**
+ * Convenience wrapper for async loading of JavaScript
+ *
+ * @param string|array $asset
+ * @param int $priority
+ * @param bool $pipeline
+ * @param string $group name of the group
+ *
+ * @return \Grav\Common\Assets
+ * @deprecated Please use dynamic method with ['loading' => 'async'].
+ */
+ public function addAsyncJs($asset, $priority = 10, $pipeline = true, $group = 'head')
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use dynamic method with [\'loading\' => \'async\']', E_USER_DEPRECATED);
+
+ return $this->addJs($asset, $priority, $pipeline, 'async', $group);
+ }
+
+ /**
+ * Convenience wrapper for deferred loading of JavaScript
+ *
+ * @param string|array $asset
+ * @param int $priority
+ * @param bool $pipeline
+ * @param string $group name of the group
+ *
+ * @return \Grav\Common\Assets
+ * @deprecated Please use dynamic method with ['loading' => 'defer'].
+ */
+ public function addDeferJs($asset, $priority = 10, $pipeline = true, $group = 'head')
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use dynamic method with [\'loading\' => \'defer\']', E_USER_DEPRECATED);
+
+ return $this->addJs($asset, $priority, $pipeline, 'defer', $group);
+ }
+
+}
diff --git a/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php
new file mode 100644
index 0000000..84b83e3
--- /dev/null
+++ b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php
@@ -0,0 +1,343 @@
+collections[$asset]) || isset($this->assets_css[$asset]) || isset($this->assets_js[$asset]);
+ }
+
+ /**
+ * Return the array of all the registered collections
+ *
+ * @return array
+ */
+ public function getCollections()
+ {
+ return $this->collections;
+ }
+
+ /**
+ * Set the array of collections explicitly
+ *
+ * @param array $collections
+ *
+ * @return $this
+ */
+ public function setCollection($collections)
+ {
+ $this->collections = $collections;
+
+ return $this;
+ }
+
+ /**
+ * Return the array of all the registered CSS assets
+ * If a $key is provided, it will try to return only that asset
+ * else it will return null
+ *
+ * @param null|string $key the asset key
+ * @return array
+ */
+ public function getCss($key = null)
+ {
+ if (null !== $key) {
+ $asset_key = md5($key);
+
+ return $this->assets_css[$asset_key] ?? null;
+ }
+
+ return $this->assets_css;
+ }
+
+ /**
+ * Return the array of all the registered JS assets
+ * If a $key is provided, it will try to return only that asset
+ * else it will return null
+ *
+ * @param null|string $key the asset key
+ * @return array
+ */
+ public function getJs($key = null)
+ {
+ if (null !== $key) {
+ $asset_key = md5($key);
+
+ return $this->assets_js[$asset_key] ?? null;
+ }
+
+ return $this->assets_js;
+ }
+
+ /**
+ * Set the whole array of CSS assets
+ *
+ * @param array $css
+ *
+ * @return $this
+ */
+ public function setCss($css)
+ {
+ $this->assets_css = $css;
+
+ return $this;
+ }
+
+ /**
+ * Set the whole array of JS assets
+ *
+ * @param array $js
+ *
+ * @return $this
+ */
+ public function setJs($js)
+ {
+ $this->assets_js = $js;
+
+ return $this;
+ }
+
+ /**
+ * Removes an item from the CSS array if set
+ *
+ * @param string $key The asset key
+ *
+ * @return $this
+ */
+ public function removeCss($key)
+ {
+ $asset_key = md5($key);
+ if (isset($this->assets_css[$asset_key])) {
+ unset($this->assets_css[$asset_key]);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Removes an item from the JS array if set
+ *
+ * @param string $key The asset key
+ *
+ * @return $this
+ */
+ public function removeJs($key)
+ {
+ $asset_key = md5($key);
+ if (isset($this->assets_js[$asset_key])) {
+ unset($this->assets_js[$asset_key]);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Sets the state of CSS Pipeline
+ *
+ * @param bool $value
+ *
+ * @return $this
+ */
+ public function setCssPipeline($value)
+ {
+ $this->css_pipeline = (bool)$value;
+
+ return $this;
+ }
+
+ /**
+ * Sets the state of JS Pipeline
+ *
+ * @param bool $value
+ *
+ * @return $this
+ */
+ public function setJsPipeline($value)
+ {
+ $this->js_pipeline = (bool)$value;
+
+ return $this;
+ }
+
+ /**
+ * Reset all assets.
+ *
+ * @return $this
+ */
+ public function reset()
+ {
+ $this->resetCss();
+ $this->resetJs();
+ $this->setCssPipeline(false);
+ $this->setJsPipeline(false);
+
+ return $this;
+ }
+
+ /**
+ * Reset JavaScript assets.
+ *
+ * @return $this
+ */
+ public function resetJs()
+ {
+ $this->assets_js = [];
+
+ return $this;
+ }
+
+ /**
+ * Reset CSS assets.
+ *
+ * @return $this
+ */
+ public function resetCss()
+ {
+ $this->assets_css = [];
+
+ return $this;
+ }
+
+ /**
+ * Explicitly set's a timestamp for assets
+ *
+ * @param string|int $value
+ */
+ public function setTimestamp($value)
+ {
+ $this->timestamp = $value;
+ }
+
+ /**
+ * Get the timestamp for assets
+ *
+ * @param bool $include_join
+ * @return string
+ */
+ public function getTimestamp($include_join = true)
+ {
+ if ($this->timestamp) {
+ return $include_join ? '?' . $this->timestamp : $this->timestamp;
+ }
+
+ return null;
+ }
+
+ /**
+ * Add all assets matching $pattern within $directory.
+ *
+ * @param string $directory Relative to the Grav root path, or a stream identifier
+ * @param string $pattern (regex)
+ *
+ * @return $this
+ */
+ public function addDir($directory, $pattern = self::DEFAULT_REGEX)
+ {
+ $root_dir = rtrim(ROOT_DIR, '/');
+
+ // Check if $directory is a stream.
+ if (strpos($directory, '://')) {
+ $directory = Grav::instance()['locator']->findResource($directory, null);
+ }
+
+ // Get files
+ $files = $this->rglob($root_dir . DIRECTORY_SEPARATOR . $directory, $pattern, $root_dir . '/');
+
+ // No luck? Nothing to do
+ if (!$files) {
+ return $this;
+ }
+
+ // Add CSS files
+ if ($pattern === self::CSS_REGEX) {
+ foreach ($files as $file) {
+ $this->addCss($file);
+ }
+
+ return $this;
+ }
+
+ // Add JavaScript files
+ if ($pattern === self::JS_REGEX) {
+ foreach ($files as $file) {
+ $this->addJs($file);
+ }
+
+ return $this;
+ }
+
+ // Unknown pattern.
+ foreach ($files as $asset) {
+ $this->add($asset);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Add all JavaScript assets within $directory
+ *
+ * @param string $directory Relative to the Grav root path, or a stream identifier
+ *
+ * @return $this
+ */
+ public function addDirJs($directory)
+ {
+ return $this->addDir($directory, self::JS_REGEX);
+ }
+
+ /**
+ * Add all CSS assets within $directory
+ *
+ * @param string $directory Relative to the Grav root path, or a stream identifier
+ *
+ * @return $this
+ */
+ public function addDirCss($directory)
+ {
+ return $this->addDir($directory, self::CSS_REGEX);
+ }
+
+ /**
+ * Recursively get files matching $pattern within $directory.
+ *
+ * @param string $directory
+ * @param string $pattern (regex)
+ * @param string $ltrim Will be trimmed from the left of the file path
+ *
+ * @return array
+ */
+ protected function rglob($directory, $pattern, $ltrim = null)
+ {
+ $iterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory,
+ \FilesystemIterator::SKIP_DOTS)), $pattern);
+ $offset = \strlen($ltrim);
+ $files = [];
+
+ foreach ($iterator as $file) {
+ $files[] = substr($file->getPathname(), $offset);
+ }
+
+ return $files;
+ }
+
+
+}
diff --git a/system/src/Grav/Common/Backup/Backups.php b/system/src/Grav/Common/Backup/Backups.php
new file mode 100644
index 0000000..9582b9e
--- /dev/null
+++ b/system/src/Grav/Common/Backup/Backups.php
@@ -0,0 +1,261 @@
+addListener('onSchedulerInitialized', [$this, 'onSchedulerInitialized']);
+ Grav::instance()->fireEvent('onBackupsInitialized', new Event(['backups' => $this]));
+ }
+
+ public function setup()
+ {
+ if (null === static::$backup_dir) {
+ static::$backup_dir = Grav::instance()['locator']->findResource('backup://', true, true);
+ Folder::create(static::$backup_dir);
+ }
+ }
+
+ public function onSchedulerInitialized(Event $event)
+ {
+ /** @var Scheduler $scheduler */
+ $scheduler = $event['scheduler'];
+
+ /** @var Inflector $inflector */
+ $inflector = Grav::instance()['inflector'];
+
+ foreach (static::getBackupProfiles() as $id => $profile) {
+ $at = $profile['schedule_at'];
+ $name = $inflector::hyphenize($profile['name']);
+ $logs = 'logs/backup-' . $name . '.out';
+ /** @var Job $job */
+ $job = $scheduler->addFunction('Grav\Common\Backup\Backups::backup', [$id], $name );
+ $job->at($at);
+ $job->output($logs);
+ $job->backlink('/tools/backups');
+ }
+ }
+
+ public function getBackupDownloadUrl($backup, $base_url)
+ {
+ $param_sep = $param_sep = Grav::instance()['config']->get('system.param_sep', ':');
+ $download = urlencode(base64_encode($backup));
+ $url = rtrim(Grav::instance()['uri']->rootUrl(true), '/') . '/' . trim($base_url,
+ '/') . '/task' . $param_sep . 'backup/download' . $param_sep . $download . '/admin-nonce' . $param_sep . Utils::getNonce('admin-form');
+
+ return $url;
+ }
+
+ public static function getBackupProfiles()
+ {
+ return Grav::instance()['config']->get('backups.profiles');
+ }
+
+ public static function getPurgeConfig()
+ {
+ return Grav::instance()['config']->get('backups.purge');
+ }
+
+ public function getBackupNames()
+ {
+ return array_column(static::getBackupProfiles(), 'name');
+ }
+
+ public static function getTotalBackupsSize()
+ {
+ $backups = static::getAvailableBackups();
+ $size = array_sum(array_column($backups, 'size'));
+
+ return $size ?? 0;
+ }
+
+ public static function getAvailableBackups($force = false)
+ {
+ if ($force || null === static::$backups) {
+ static::$backups = [];
+ $backups_itr = new \GlobIterator(static::$backup_dir . '/*.zip', \FilesystemIterator::KEY_AS_FILENAME);
+ $inflector = Grav::instance()['inflector'];
+ $long_date_format = DATE_RFC2822;
+
+ /**
+ * @var string $name
+ * @var \SplFileInfo $file
+ */
+ foreach ($backups_itr as $name => $file) {
+
+ if (preg_match(static::BACKUP_FILENAME_REGEXZ, $name, $matches)) {
+ $date = \DateTime::createFromFormat(static::BACKUP_DATE_FORMAT, $matches[2]);
+ $timestamp = $date->getTimestamp();
+ $backup = new \stdClass();
+ $backup->title = $inflector->titleize($matches[1]);
+ $backup->time = $date;
+ $backup->date = $date->format($long_date_format);
+ $backup->filename = $name;
+ $backup->path = $file->getPathname();
+ $backup->size = $file->getSize();
+ static::$backups[$timestamp] = $backup;
+ }
+ }
+ // Reverse Key Sort to get in reverse date order
+ krsort(static::$backups);
+ }
+
+ return static::$backups;
+ }
+
+ /**
+ * Backup
+ *
+ * @param int $id
+ * @param callable|null $status
+ *
+ * @return null|string
+ */
+ public static function backup($id = 0, callable $status = null)
+ {
+ $profiles = static::getBackupProfiles();
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+
+ if (isset($profiles[$id])) {
+ $backup = (object) $profiles[$id];
+ } else {
+ throw new \RuntimeException('No backups defined...');
+ }
+
+ $name = Grav::instance()['inflector']->underscorize($backup->name);
+ $date = date(static::BACKUP_DATE_FORMAT, time());
+ $filename = trim($name, '_') . '--' . $date . '.zip';
+ $destination = static::$backup_dir . DS . $filename;
+ $max_execution_time = ini_set('max_execution_time', 600);
+ $backup_root = $backup->root;
+
+ if ($locator->isStream($backup_root)) {
+ $backup_root = $locator->findResource($backup_root);
+ } else {
+ $backup_root = rtrim(GRAV_ROOT . $backup_root, '/');
+ }
+
+ if (!file_exists($backup_root)) {
+ throw new \RuntimeException("Backup location: {$backup_root} does not exist...");
+ }
+
+ $options = [
+ 'exclude_files' => static::convertExclude($backup->exclude_files ?? ''),
+ 'exclude_paths' => static::convertExclude($backup->exclude_paths ?? ''),
+ ];
+
+ /** @var Archiver $archiver */
+ $archiver = Archiver::create('zip');
+ $archiver->setArchive($destination)->setOptions($options)->compress($backup_root, $status)->addEmptyFolders($options['exclude_paths'], $status);
+
+ $status && $status([
+ 'type' => 'message',
+ 'message' => 'Done...',
+ ]);
+
+ $status && $status([
+ 'type' => 'progress',
+ 'complete' => true
+ ]);
+
+ if ($max_execution_time !== false) {
+ ini_set('max_execution_time', $max_execution_time);
+ }
+
+ // Log the backup
+ Grav::instance()['log']->notice('Backup Created: ' . $destination);
+
+ // Fire Finished event
+ Grav::instance()->fireEvent('onBackupFinished', new Event(['backup' => $destination]));
+
+ // Purge anything required
+ static::purge();
+
+ // Log
+ $log = JsonFile::instance(Grav::instance()['locator']->findResource("log://backup.log", true, true));
+ $log->content([
+ 'time' => time(),
+ 'location' => $destination
+ ]);
+ $log->save();
+
+ return $destination;
+ }
+
+ public static function purge()
+ {
+ $purge_config = static::getPurgeConfig();
+ $trigger = $purge_config['trigger'];
+ $backups = static::getAvailableBackups(true);
+
+ switch ($trigger)
+ {
+ case 'number':
+ $backups_count = count($backups);
+ if ($backups_count > $purge_config['max_backups_count']) {
+ $last = end($backups);
+ unlink ($last->path);
+ static::purge();
+ }
+ break;
+
+ case 'time':
+ $last = end($backups);
+ $now = new \DateTime();
+ $interval = $now->diff($last->time);
+ if ($interval->days > $purge_config['max_backups_time']) {
+ unlink($last->path);
+ static::purge();
+ }
+ break;
+
+ default:
+ $used_space = static::getTotalBackupsSize();
+ $max_space = $purge_config['max_backups_space'] * 1024 * 1024 * 1024;
+ if ($used_space > $max_space) {
+ $last = end($backups);
+ unlink($last->path);
+ static::purge();
+ }
+ break;
+ }
+ }
+
+ protected static function convertExclude($exclude)
+ {
+ $lines = preg_split("/[\s,]+/", $exclude);
+ return array_map('trim', $lines, array_fill(0, \count($lines), '/'));
+ }
+}
diff --git a/system/src/Grav/Common/Browser.php b/system/src/Grav/Common/Browser.php
new file mode 100644
index 0000000..8d0d687
--- /dev/null
+++ b/system/src/Grav/Common/Browser.php
@@ -0,0 +1,151 @@
+useragent = parse_user_agent();
+ } catch (\InvalidArgumentException $e) {
+ $this->useragent = parse_user_agent("Mozilla/5.0 (compatible; Unknown;)");
+ }
+ }
+
+ /**
+ * Get the current browser identifier
+ *
+ * Currently detected browsers:
+ *
+ * Android Browser
+ * BlackBerry Browser
+ * Camino
+ * Kindle / Silk
+ * Firefox / Iceweasel
+ * Safari
+ * Internet Explorer
+ * IEMobile
+ * Chrome
+ * Opera
+ * Midori
+ * Vivaldi
+ * TizenBrowser
+ * Lynx
+ * Wget
+ * Curl
+ *
+ * @return string the lowercase browser name
+ */
+ public function getBrowser()
+ {
+ return strtolower($this->useragent['browser']);
+ }
+
+ /**
+ * Get the current platform identifier
+ *
+ * Currently detected platforms:
+ *
+ * Desktop
+ * -> Windows
+ * -> Linux
+ * -> Macintosh
+ * -> Chrome OS
+ * Mobile
+ * -> Android
+ * -> iPhone
+ * -> iPad / iPod Touch
+ * -> Windows Phone OS
+ * -> Kindle
+ * -> Kindle Fire
+ * -> BlackBerry
+ * -> Playbook
+ * -> Tizen
+ * Console
+ * -> Nintendo 3DS
+ * -> New Nintendo 3DS
+ * -> Nintendo Wii
+ * -> Nintendo WiiU
+ * -> PlayStation 3
+ * -> PlayStation 4
+ * -> PlayStation Vita
+ * -> Xbox 360
+ * -> Xbox One
+ *
+ * @return string the lowercase platform name
+ */
+ public function getPlatform()
+ {
+ return strtolower($this->useragent['platform']);
+ }
+
+ /**
+ * Get the current full version identifier
+ *
+ * @return string the browser full version identifier
+ */
+ public function getLongVersion()
+ {
+ return $this->useragent['version'];
+ }
+
+ /**
+ * Get the current major version identifier
+ *
+ * @return string the browser major version identifier
+ */
+ public function getVersion()
+ {
+ $version = explode('.', $this->getLongVersion());
+
+ return (int)$version[0];
+ }
+
+ /**
+ * Determine if the request comes from a human, or from a bot/crawler
+ *
+ * @return bool
+ */
+ public function isHuman()
+ {
+ $browser = $this->getBrowser();
+ if (empty($browser)) {
+ return false;
+ }
+
+ if (preg_match('~(bot|crawl)~i', $browser)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Determine if “Do Not Track” is set by browser
+ * @see https://www.w3.org/TR/tracking-dnt/
+ *
+ * @return bool
+ */
+ public function isTrackable(): bool
+ {
+ return !(isset($_SERVER['HTTP_DNT']) && $_SERVER['HTTP_DNT'] === '1');
+ }
+}
diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php
new file mode 100644
index 0000000..94eae59
--- /dev/null
+++ b/system/src/Grav/Common/Cache.php
@@ -0,0 +1,656 @@
+init($grav);
+ }
+
+ /**
+ * Initialization that sets a base key and the driver based on configuration settings
+ *
+ * @param Grav $grav
+ *
+ * @return void
+ */
+ public function init(Grav $grav)
+ {
+ /** @var Config $config */
+ $this->config = $grav['config'];
+ $this->now = time();
+
+ if (null === $this->enabled) {
+ $this->enabled = (bool)$this->config->get('system.cache.enabled');
+ }
+
+ /** @var Uri $uri */
+ $uri = $grav['uri'];
+
+ $prefix = $this->config->get('system.cache.prefix');
+ $uniqueness = substr(md5($uri->rootUrl(true) . $this->config->key() . GRAV_VERSION), 2, 8);
+
+ // Cache key allows us to invalidate all cache on configuration changes.
+ $this->key = ($prefix ? $prefix : 'g') . '-' . $uniqueness;
+ $this->cache_dir = $grav['locator']->findResource('cache://doctrine/' . $uniqueness, true, true);
+ $this->driver_setting = $this->config->get('system.cache.driver');
+ $this->driver = $this->getCacheDriver();
+ $this->driver->setNamespace($this->key);
+
+ /** @var EventDispatcher $dispatcher */
+ $dispatcher = Grav::instance()['events'];
+ $dispatcher->addListener('onSchedulerInitialized', [$this, 'onSchedulerInitialized']);
+ }
+
+ /**
+ * @return CacheInterface
+ */
+ public function getSimpleCache()
+ {
+ if (null === $this->simpleCache) {
+ $cache = new \Grav\Framework\Cache\Adapter\DoctrineCache($this->driver, '', $this->getLifetime());
+
+ // Disable cache key validation.
+ $cache->setValidation(false);
+
+ $this->simpleCache = $cache;
+ }
+
+ return $this->simpleCache;
+ }
+
+ /**
+ * Deletes the old out of date file-based caches
+ *
+ * @return int
+ */
+ public function purgeOldCache()
+ {
+ $cache_dir = dirname($this->cache_dir);
+ $current = basename($this->cache_dir);
+ $count = 0;
+
+ foreach (new \DirectoryIterator($cache_dir) as $file) {
+ $dir = $file->getBasename();
+ if ($dir === $current || $file->isDot() || $file->isFile()) {
+ continue;
+ }
+
+ Folder::delete($file->getPathname());
+ $count++;
+ }
+
+ return $count;
+ }
+
+ /**
+ * Public accessor to set the enabled state of the cache
+ *
+ * @param bool|int $enabled
+ */
+ public function setEnabled($enabled)
+ {
+ $this->enabled = (bool)$enabled;
+ }
+
+ /**
+ * Returns the current enabled state
+ *
+ * @return bool
+ */
+ public function getEnabled()
+ {
+ return $this->enabled;
+ }
+
+ /**
+ * Get cache state
+ *
+ * @return string
+ */
+ public function getCacheStatus()
+ {
+ return 'Cache: [' . ($this->enabled ? 'true' : 'false') . '] Setting: [' . $this->driver_setting . '] Driver: [' . $this->driver_name . ']';
+ }
+
+ /**
+ * Automatically picks the cache mechanism to use. If you pick one manually it will use that
+ * If there is no config option for $driver in the config, or it's set to 'auto', it will
+ * pick the best option based on which cache extensions are installed.
+ *
+ * @return DoctrineCache\CacheProvider The cache driver to use
+ */
+ public function getCacheDriver()
+ {
+ $setting = $this->driver_setting;
+ $driver_name = 'file';
+
+ // CLI compatibility requires a non-volatile cache driver
+ if ($this->config->get('system.cache.cli_compatibility') && (
+ $setting === 'auto' || $this->isVolatileDriver($setting))) {
+ $setting = $driver_name;
+ }
+
+ if (!$setting || $setting === 'auto') {
+ if (extension_loaded('apcu')) {
+ $driver_name = 'apcu';
+ } elseif (extension_loaded('wincache')) {
+ $driver_name = 'wincache';
+ }
+ } else {
+ $driver_name = $setting;
+ }
+
+ $this->driver_name = $driver_name;
+
+ switch ($driver_name) {
+ case 'apc':
+ case 'apcu':
+ $driver = new DoctrineCache\ApcuCache();
+ break;
+
+ case 'wincache':
+ $driver = new DoctrineCache\WinCacheCache();
+ break;
+
+ case 'memcache':
+ if (extension_loaded('memcache')) {
+ $memcache = new \Memcache();
+ $memcache->connect($this->config->get('system.cache.memcache.server', 'localhost'),
+ $this->config->get('system.cache.memcache.port', 11211));
+ $driver = new DoctrineCache\MemcacheCache();
+ $driver->setMemcache($memcache);
+ } else {
+ throw new \LogicException('Memcache PHP extension has not been installed');
+ }
+ break;
+
+ case 'memcached':
+ if (extension_loaded('memcached')) {
+ $memcached = new \Memcached();
+ $memcached->addServer($this->config->get('system.cache.memcached.server', 'localhost'),
+ $this->config->get('system.cache.memcached.port', 11211));
+ $driver = new DoctrineCache\MemcachedCache();
+ $driver->setMemcached($memcached);
+ } else {
+ throw new \LogicException('Memcached PHP extension has not been installed');
+ }
+ break;
+
+ case 'redis':
+ if (extension_loaded('redis')) {
+ $redis = new \Redis();
+ $socket = $this->config->get('system.cache.redis.socket', false);
+ $password = $this->config->get('system.cache.redis.password', false);
+
+ if ($socket) {
+ $redis->connect($socket);
+ } else {
+ $redis->connect($this->config->get('system.cache.redis.server', 'localhost'),
+ $this->config->get('system.cache.redis.port', 6379));
+ }
+
+ // Authenticate with password if set
+ if ($password && !$redis->auth($password)) {
+ throw new \RedisException('Redis authentication failed');
+ }
+
+ $driver = new DoctrineCache\RedisCache();
+ $driver->setRedis($redis);
+ } else {
+ throw new \LogicException('Redis PHP extension has not been installed');
+ }
+ break;
+
+ default:
+ $driver = new DoctrineCache\FilesystemCache($this->cache_dir);
+ break;
+ }
+
+ return $driver;
+ }
+
+ /**
+ * Gets a cached entry if it exists based on an id. If it does not exist, it returns false
+ *
+ * @param string $id the id of the cached entry
+ *
+ * @return object|bool returns the cached entry, can be any type, or false if doesn't exist
+ */
+ public function fetch($id)
+ {
+ if ($this->enabled) {
+ return $this->driver->fetch($id);
+ }
+
+ return false;
+ }
+
+ /**
+ * Stores a new cached entry.
+ *
+ * @param string $id the id of the cached entry
+ * @param array|object $data the data for the cached entry to store
+ * @param int $lifetime the lifetime to store the entry in seconds
+ */
+ public function save($id, $data, $lifetime = null)
+ {
+ if ($this->enabled) {
+ if ($lifetime === null) {
+ $lifetime = $this->getLifetime();
+ }
+ $this->driver->save($id, $data, $lifetime);
+ }
+ }
+
+ /**
+ * Deletes an item in the cache based on the id
+ *
+ * @param string $id the id of the cached data entry
+ * @return bool true if the item was deleted successfully
+ */
+ public function delete($id)
+ {
+ if ($this->enabled) {
+ return $this->driver->delete($id);
+ }
+
+ return false;
+ }
+
+ /**
+ * Deletes all cache
+ *
+ * @return bool
+ */
+ public function deleteAll()
+ {
+ if ($this->enabled) {
+ return $this->driver->deleteAll();
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns a boolean state of whether or not the item exists in the cache based on id key
+ *
+ * @param string $id the id of the cached data entry
+ * @return bool true if the cached items exists
+ */
+ public function contains($id)
+ {
+ if ($this->enabled) {
+ return $this->driver->contains(($id));
+ }
+
+ return false;
+ }
+
+ /**
+ * Getter method to get the cache key
+ */
+ public function getKey()
+ {
+ return $this->key;
+ }
+
+ /**
+ * Setter method to set key (Advanced)
+ */
+ public function setKey($key)
+ {
+ $this->key = $key;
+ $this->driver->setNamespace($this->key);
+ }
+
+ /**
+ * Helper method to clear all Grav caches
+ *
+ * @param string $remove standard|all|assets-only|images-only|cache-only
+ *
+ * @return array
+ */
+ public static function clearCache($remove = 'standard')
+ {
+ $locator = Grav::instance()['locator'];
+ $output = [];
+ $user_config = USER_DIR . 'config/system.yaml';
+
+ switch ($remove) {
+ case 'all':
+ $remove_paths = self::$all_remove;
+ break;
+ case 'assets-only':
+ $remove_paths = self::$assets_remove;
+ break;
+ case 'images-only':
+ $remove_paths = self::$images_remove;
+ break;
+ case 'cache-only':
+ $remove_paths = self::$cache_remove;
+ break;
+ case 'tmp-only':
+ $remove_paths = self::$tmp_remove;
+ break;
+ case 'invalidate':
+ $remove_paths = [];
+ break;
+ default:
+ if (Grav::instance()['config']->get('system.cache.clear_images_by_default')) {
+ $remove_paths = self::$standard_remove;
+ } else {
+ $remove_paths = self::$standard_remove_no_images;
+ }
+
+ }
+
+ // Delete entries in the doctrine cache if required
+ if (in_array($remove, ['all', 'standard'])) {
+ $cache = Grav::instance()['cache'];
+ $cache->driver->deleteAll();
+ }
+
+ // Clearing cache event to add paths to clear
+ Grav::instance()->fireEvent('onBeforeCacheClear', new Event(['remove' => $remove, 'paths' => &$remove_paths]));
+
+ foreach ($remove_paths as $stream) {
+
+ // Convert stream to a real path
+ try {
+ $path = $locator->findResource($stream, true, true);
+ if($path === false) continue;
+
+ $anything = false;
+ $files = glob($path . '/*');
+
+ if (is_array($files)) {
+ foreach ($files as $file) {
+ if (is_link($file)) {
+ $output[] = 'Skipping symlink: ' . $file;
+ } elseif (is_file($file)) {
+ if (@unlink($file)) {
+ $anything = true;
+ }
+ } elseif (is_dir($file)) {
+ if (Folder::delete($file)) {
+ $anything = true;
+ }
+ }
+ }
+ }
+
+ if ($anything) {
+ $output[] = 'Cleared: ' . $path . '/*';
+ }
+ } catch (\Exception $e) {
+ // stream not found or another error while deleting files.
+ $output[] = 'ERROR: ' . $e->getMessage();
+ }
+ }
+
+ $output[] = '';
+
+ if (($remove === 'all' || $remove === 'standard') && file_exists($user_config)) {
+ touch($user_config);
+
+ $output[] = 'Touched: ' . $user_config;
+ $output[] = '';
+ }
+
+ // Clear stat cache
+ @clearstatcache();
+
+ // Clear opcache
+ if (function_exists('opcache_reset')) {
+ @opcache_reset();
+ }
+
+ return $output;
+ }
+
+ public static function invalidateCache()
+ {
+ $user_config = USER_DIR . 'config/system.yaml';
+
+ if (file_exists($user_config)) {
+ touch($user_config);
+ }
+
+ // Clear stat cache
+ @clearstatcache();
+
+ // Clear opcache
+ if (function_exists('opcache_reset')) {
+ @opcache_reset();
+ }
+
+ }
+
+ /**
+ * Set the cache lifetime programmatically
+ *
+ * @param int $future timestamp
+ */
+ public function setLifetime($future)
+ {
+ if (!$future) {
+ return;
+ }
+
+ $interval = (int)($future - $this->now);
+ if ($interval > 0 && $interval < $this->getLifetime()) {
+ $this->lifetime = $interval;
+ }
+ }
+
+
+ /**
+ * Retrieve the cache lifetime (in seconds)
+ *
+ * @return mixed
+ */
+ public function getLifetime()
+ {
+ if ($this->lifetime === null) {
+ $this->lifetime = (int)($this->config->get('system.cache.lifetime') ?: 604800); // 1 week default
+ }
+
+ return $this->lifetime;
+ }
+
+ /**
+ * Returns the current driver name
+ *
+ * @return mixed
+ */
+ public function getDriverName()
+ {
+ return $this->driver_name;
+ }
+
+ /**
+ * Returns the current driver setting
+ *
+ * @return mixed
+ */
+ public function getDriverSetting()
+ {
+ return $this->driver_setting;
+ }
+
+ /**
+ * is this driver a volatile driver in that it resides in PHP process memory
+ *
+ * @param string $setting
+ * @return bool
+ */
+ public function isVolatileDriver($setting)
+ {
+ if (in_array($setting, ['apc', 'apcu', 'xcache', 'wincache'])) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Static function to call as a scheduled Job to purge old Doctrine files
+ */
+ public static function purgeJob()
+ {
+ /** @var Cache $cache */
+ $cache = Grav::instance()['cache'];
+ $deleted_folders = $cache->purgeOldCache();
+
+ echo 'Purged ' . $deleted_folders . ' old cache folders...';
+ }
+
+ /**
+ * Static function to call as a scheduled Job to clear Grav cache
+ *
+ * @param string $type
+ */
+ public static function clearJob($type)
+ {
+ $result = static::clearCache($type);
+ static::invalidateCache();
+
+ echo strip_tags(implode("\n", $result));
+ }
+
+ public function onSchedulerInitialized(Event $event)
+ {
+ /** @var Scheduler $scheduler */
+ $scheduler = $event['scheduler'];
+ $config = Grav::instance()['config'];
+
+ // File Cache Purge
+ $at = $config->get('system.cache.purge_at');
+ $name = 'cache-purge';
+ $logs = 'logs/' . $name . '.out';
+
+ $job = $scheduler->addFunction('Grav\Common\Cache::purgeJob', [], $name );
+ $job->at($at);
+ $job->output($logs);
+ $job->backlink('/config/system#caching');
+
+ // Cache Clear
+ $at = $config->get('system.cache.clear_at');
+ $clear_type = $config->get('system.cache.clear_job_type');
+ $name = 'cache-clear';
+ $logs = 'logs/' . $name . '.out';
+
+ $job = $scheduler->addFunction('Grav\Common\Cache::clearJob', [$clear_type], $name );
+ $job->at($at);
+ $job->output($logs);
+ $job->backlink('/config/system#caching');
+
+ }
+
+
+}
diff --git a/system/src/Grav/Common/Composer.php b/system/src/Grav/Common/Composer.php
new file mode 100644
index 0000000..c6abb2c
--- /dev/null
+++ b/system/src/Grav/Common/Composer.php
@@ -0,0 +1,61 @@
+path = $path ? rtrim($path, '\\/') . '/' : '';
+ $this->cacheFolder = $cacheFolder;
+ $this->files = $files;
+ $this->timestamp = 0;
+ }
+
+ /**
+ * Get filename for the compiled PHP file.
+ *
+ * @param string $name
+ * @return $this
+ */
+ public function name($name = null)
+ {
+ if (!$this->name) {
+ $this->name = $name ?: md5(json_encode(array_keys($this->files)));
+ }
+
+ return $this;
+ }
+
+ /**
+ * Function gets called when cached configuration is saved.
+ */
+ public function modified() {}
+
+ /**
+ * Get timestamp of compiled configuration
+ *
+ * @return int Timestamp of compiled configuration
+ */
+ public function timestamp()
+ {
+ return $this->timestamp ?: time();
+ }
+
+ /**
+ * Load the configuration.
+ *
+ * @return mixed
+ */
+ public function load()
+ {
+ if ($this->object) {
+ return $this->object;
+ }
+
+ $filename = $this->createFilename();
+ if (!$this->loadCompiledFile($filename) && $this->loadFiles()) {
+ $this->saveCompiledFile($filename);
+ }
+
+ return $this->object;
+ }
+
+ /**
+ * Returns checksum from the configuration files.
+ *
+ * You can set $this->checksum = false to disable this check.
+ *
+ * @return bool|string
+ */
+ public function checksum()
+ {
+ if (null === $this->checksum) {
+ $this->checksum = md5(json_encode($this->files) . $this->version);
+ }
+
+ return $this->checksum;
+ }
+
+ protected function createFilename()
+ {
+ return "{$this->cacheFolder}/{$this->name()->name}.php";
+ }
+
+ /**
+ * Create configuration object.
+ *
+ * @param array $data
+ */
+ abstract protected function createObject(array $data = []);
+
+ /**
+ * Finalize configuration object.
+ */
+ abstract protected function finalizeObject();
+
+ /**
+ * Load single configuration file and append it to the correct position.
+ *
+ * @param string $name Name of the position.
+ * @param string $filename File to be loaded.
+ */
+ abstract protected function loadFile($name, $filename);
+
+ /**
+ * Load and join all configuration files.
+ *
+ * @return bool
+ * @internal
+ */
+ protected function loadFiles()
+ {
+ $this->createObject();
+
+ $list = array_reverse($this->files);
+ foreach ($list as $files) {
+ foreach ($files as $name => $item) {
+ $this->loadFile($name, $this->path . $item['file']);
+ }
+ }
+
+ $this->finalizeObject();
+
+ return true;
+ }
+
+ /**
+ * Load compiled file.
+ *
+ * @param string $filename
+ * @return bool
+ * @internal
+ */
+ protected function loadCompiledFile($filename)
+ {
+ if (!file_exists($filename)) {
+ return false;
+ }
+
+ $cache = include $filename;
+ if (
+ !\is_array($cache)
+ || !isset($cache['checksum'], $cache['data'], $cache['@class'])
+ || $cache['@class'] !== \get_class($this)
+ ) {
+ return false;
+ }
+
+ // Load real file if cache isn't up to date (or is invalid).
+ if ($cache['checksum'] !== $this->checksum()) {
+ return false;
+ }
+
+ $this->createObject($cache['data']);
+ $this->timestamp = $cache['timestamp'] ?? 0;
+
+ $this->finalizeObject();
+
+ return true;
+ }
+
+ /**
+ * Save compiled file.
+ *
+ * @param string $filename
+ * @throws \RuntimeException
+ * @internal
+ */
+ protected function saveCompiledFile($filename)
+ {
+ $file = PhpFile::instance($filename);
+
+ // Attempt to lock the file for writing.
+ try {
+ $file->lock(false);
+ } catch (\Exception $e) {
+ // Another process has locked the file; we will check this in a bit.
+ }
+
+ if ($file->locked() === false) {
+ // File was already locked by another process.
+ return;
+ }
+
+ $cache = [
+ '@class' => \get_class($this),
+ 'timestamp' => time(),
+ 'checksum' => $this->checksum(),
+ 'files' => $this->files,
+ 'data' => $this->getState()
+ ];
+
+ $file->save($cache);
+ $file->unlock();
+ $file->free();
+
+ $this->modified();
+ }
+
+ protected function getState()
+ {
+ return $this->object->toArray();
+ }
+}
diff --git a/system/src/Grav/Common/Config/CompiledBlueprints.php b/system/src/Grav/Common/Config/CompiledBlueprints.php
new file mode 100644
index 0000000..9ad7be6
--- /dev/null
+++ b/system/src/Grav/Common/Config/CompiledBlueprints.php
@@ -0,0 +1,119 @@
+version = 2;
+ }
+
+ /**
+ * Returns checksum from the configuration files.
+ *
+ * You can set $this->checksum = false to disable this check.
+ *
+ * @return bool|string
+ */
+ public function checksum()
+ {
+ if (null === $this->checksum) {
+ $this->checksum = md5(json_encode($this->files) . json_encode($this->getTypes()) . $this->version);
+ }
+
+ return $this->checksum;
+ }
+
+ /**
+ * Create configuration object.
+ *
+ * @param array $data
+ */
+ protected function createObject(array $data = [])
+ {
+ $this->object = (new BlueprintSchema($data))->setTypes($this->getTypes());
+ }
+
+ /**
+ * Get list of form field types.
+ *
+ * @return array
+ */
+ protected function getTypes()
+ {
+ return Grav::instance()['plugins']->formFieldTypes ?: [];
+ }
+
+ /**
+ * Finalize configuration object.
+ */
+ protected function finalizeObject()
+ {
+ }
+
+ /**
+ * Load single configuration file and append it to the correct position.
+ *
+ * @param string $name Name of the position.
+ * @param array $files Files to be loaded.
+ */
+ protected function loadFile($name, $files)
+ {
+ // Load blueprint file.
+ $blueprint = new Blueprint($files);
+
+ $this->object->embed($name, $blueprint->load()->toArray(), '/', true);
+ }
+
+ /**
+ * Load and join all configuration files.
+ *
+ * @return bool
+ * @internal
+ */
+ protected function loadFiles()
+ {
+ $this->createObject();
+
+ // Convert file list into parent list.
+ $list = [];
+ /** @var array $files */
+ foreach ($this->files as $files) {
+ foreach ($files as $name => $item) {
+ $list[$name][] = $this->path . $item['file'];
+ }
+ }
+
+ // Load files.
+ foreach ($list as $name => $files) {
+ $this->loadFile($name, $files);
+ }
+
+ $this->finalizeObject();
+
+ return true;
+ }
+
+ protected function getState()
+ {
+ return $this->object->getState();
+ }
+}
diff --git a/system/src/Grav/Common/Config/CompiledConfig.php b/system/src/Grav/Common/Config/CompiledConfig.php
new file mode 100644
index 0000000..1c92edd
--- /dev/null
+++ b/system/src/Grav/Common/Config/CompiledConfig.php
@@ -0,0 +1,101 @@
+version = 1;
+ }
+
+ /**
+ * Set blueprints for the configuration.
+ *
+ * @param callable $blueprints
+ * @return $this
+ */
+ public function setBlueprints(callable $blueprints)
+ {
+ $this->callable = $blueprints;
+
+ return $this;
+ }
+
+ /**
+ * @param bool $withDefaults
+ * @return mixed
+ */
+ public function load($withDefaults = false)
+ {
+ $this->withDefaults = $withDefaults;
+
+ return parent::load();
+ }
+
+ /**
+ * Create configuration object.
+ *
+ * @param array $data
+ */
+ protected function createObject(array $data = [])
+ {
+ if ($this->withDefaults && empty($data) && \is_callable($this->callable)) {
+ $blueprints = $this->callable;
+ $data = $blueprints()->getDefaults();
+ }
+
+ $this->object = new Config($data, $this->callable);
+ }
+
+ /**
+ * Finalize configuration object.
+ */
+ protected function finalizeObject()
+ {
+ $this->object->checksum($this->checksum());
+ $this->object->timestamp($this->timestamp());
+ }
+
+ /**
+ * Function gets called when cached configuration is saved.
+ */
+ public function modified()
+ {
+ $this->object->modified(true);
+ }
+
+ /**
+ * Load single configuration file and append it to the correct position.
+ *
+ * @param string $name Name of the position.
+ * @param string $filename File to be loaded.
+ */
+ protected function loadFile($name, $filename)
+ {
+ $file = CompiledYamlFile::instance($filename);
+ $this->object->join($name, $file->content(), '/');
+ $file->free();
+ }
+}
diff --git a/system/src/Grav/Common/Config/CompiledLanguages.php b/system/src/Grav/Common/Config/CompiledLanguages.php
new file mode 100644
index 0000000..ef18145
--- /dev/null
+++ b/system/src/Grav/Common/Config/CompiledLanguages.php
@@ -0,0 +1,67 @@
+version = 1;
+ }
+
+ /**
+ * Create configuration object.
+ *
+ * @param array $data
+ */
+ protected function createObject(array $data = [])
+ {
+ $this->object = new Languages($data);
+ }
+
+ /**
+ * Finalize configuration object.
+ */
+ protected function finalizeObject()
+ {
+ $this->object->checksum($this->checksum());
+ $this->object->timestamp($this->timestamp());
+ }
+
+
+ /**
+ * Function gets called when cached configuration is saved.
+ */
+ public function modified()
+ {
+ $this->object->modified(true);
+ }
+
+ /**
+ * Load single configuration file and append it to the correct position.
+ *
+ * @param string $name Name of the position.
+ * @param string $filename File to be loaded.
+ */
+ protected function loadFile($name, $filename)
+ {
+ $file = CompiledYamlFile::instance($filename);
+ if (preg_match('|languages\.yaml$|', $filename)) {
+ $this->object->mergeRecursive((array) $file->content());
+ } else {
+ $this->object->mergeRecursive([$name => $file->content()]);
+ }
+ $file->free();
+ }
+}
diff --git a/system/src/Grav/Common/Config/Config.php b/system/src/Grav/Common/Config/Config.php
new file mode 100644
index 0000000..7b80846
--- /dev/null
+++ b/system/src/Grav/Common/Config/Config.php
@@ -0,0 +1,126 @@
+key) {
+ $this->key = md5($this->checksum . $this->timestamp);
+ }
+
+ return $this->key;
+ }
+
+ public function checksum($checksum = null)
+ {
+ if ($checksum !== null) {
+ $this->checksum = $checksum;
+ }
+
+ return $this->checksum;
+ }
+
+ public function modified($modified = null)
+ {
+ if ($modified !== null) {
+ $this->modified = $modified;
+ }
+
+ return $this->modified;
+ }
+
+ public function timestamp($timestamp = null)
+ {
+ if ($timestamp !== null) {
+ $this->timestamp = $timestamp;
+ }
+
+ return $this->timestamp;
+ }
+
+ public function reload()
+ {
+ $grav = Grav::instance();
+
+ // Load new configuration.
+ $config = ConfigServiceProvider::load($grav);
+
+ /** @var Debugger $debugger */
+ $debugger = $grav['debugger'];
+
+ if ($config->modified()) {
+ // Update current configuration.
+ $this->items = $config->toArray();
+ $this->checksum($config->checksum());
+ $this->modified(true);
+
+ $debugger->addMessage('Configuration was changed and saved.');
+ }
+
+ return $this;
+ }
+
+ public function debug()
+ {
+ /** @var Debugger $debugger */
+ $debugger = Grav::instance()['debugger'];
+
+ $debugger->addMessage('Environment Name: ' . $this->environment);
+ if ($this->modified()) {
+ $debugger->addMessage('Configuration reloaded and cached.');
+ }
+ }
+
+ public function init()
+ {
+ $setup = Grav::instance()['setup']->toArray();
+ foreach ($setup as $key => $value) {
+ if ($key === 'streams' || !\is_array($value)) {
+ // Optimized as streams and simple values are fully defined in setup.
+ $this->items[$key] = $value;
+ } else {
+ $this->joinDefaults($key, $value);
+ }
+ }
+
+ // Legacy value - Override the media.upload_limit based on PHP values
+ $this->items['system']['media']['upload_limit'] = Utils::getUploadLimit();
+ }
+
+ /**
+ * @return mixed
+ * @deprecated 1.5 Use Grav::instance()['languages'] instead.
+ */
+ public function getLanguages()
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use Grav::instance()[\'languages\'] instead', E_USER_DEPRECATED);
+
+ return Grav::instance()['languages'];
+ }
+}
diff --git a/system/src/Grav/Common/Config/ConfigFileFinder.php b/system/src/Grav/Common/Config/ConfigFileFinder.php
new file mode 100644
index 0000000..1e7adca
--- /dev/null
+++ b/system/src/Grav/Common/Config/ConfigFileFinder.php
@@ -0,0 +1,263 @@
+base = $base ? "{$base}/" : '';
+
+ return $this;
+ }
+
+ /**
+ * Return all locations for all the files with a timestamp.
+ *
+ * @param array $paths List of folders to look from.
+ * @param string $pattern Pattern to match the file. Pattern will also be removed from the key.
+ * @param int $levels Maximum number of recursive directories.
+ * @return array
+ */
+ public function locateFiles(array $paths, $pattern = '|\.yaml$|', $levels = -1)
+ {
+ $list = [];
+ foreach ($paths as $folder) {
+ $list += $this->detectRecursive($folder, $pattern, $levels);
+ }
+ return $list;
+ }
+
+ /**
+ * Return all locations for all the files with a timestamp.
+ *
+ * @param array $paths List of folders to look from.
+ * @param string $pattern Pattern to match the file. Pattern will also be removed from the key.
+ * @param int $levels Maximum number of recursive directories.
+ * @return array
+ */
+ public function getFiles(array $paths, $pattern = '|\.yaml$|', $levels = -1)
+ {
+ $list = [];
+ foreach ($paths as $folder) {
+ $path = trim(Folder::getRelativePath($folder), '/');
+
+ $files = $this->detectRecursive($folder, $pattern, $levels);
+
+ $list += $files[trim($path, '/')];
+ }
+ return $list;
+ }
+
+ /**
+ * Return all paths for all the files with a timestamp.
+ *
+ * @param array $paths List of folders to look from.
+ * @param string $pattern Pattern to match the file. Pattern will also be removed from the key.
+ * @param int $levels Maximum number of recursive directories.
+ * @return array
+ */
+ public function listFiles(array $paths, $pattern = '|\.yaml$|', $levels = -1)
+ {
+ $list = [];
+ foreach ($paths as $folder) {
+ $list = array_merge_recursive($list, $this->detectAll($folder, $pattern, $levels));
+ }
+ return $list;
+ }
+
+ /**
+ * Find filename from a list of folders.
+ *
+ * Note: Only finds the last override.
+ *
+ * @param string $filename
+ * @param array $folders
+ * @return array
+ */
+ public function locateFileInFolder($filename, array $folders)
+ {
+ $list = [];
+ foreach ($folders as $folder) {
+ $list += $this->detectInFolder($folder, $filename);
+ }
+ return $list;
+ }
+
+ /**
+ * Find filename from a list of folders.
+ *
+ * @param array $folders
+ * @param string $filename
+ * @return array
+ */
+ public function locateInFolders(array $folders, $filename = null)
+ {
+ $list = [];
+ foreach ($folders as $folder) {
+ $path = trim(Folder::getRelativePath($folder), '/');
+ $list[$path] = $this->detectInFolder($folder, $filename);
+ }
+ return $list;
+ }
+
+ /**
+ * Return all existing locations for a single file with a timestamp.
+ *
+ * @param array $paths Filesystem paths to look up from.
+ * @param string $name Configuration file to be located.
+ * @param string $ext File extension (optional, defaults to .yaml).
+ * @return array
+ */
+ public function locateFile(array $paths, $name, $ext = '.yaml')
+ {
+ $filename = preg_replace('|[.\/]+|', '/', $name) . $ext;
+
+ $list = [];
+ foreach ($paths as $folder) {
+ $path = trim(Folder::getRelativePath($folder), '/');
+
+ if (is_file("{$folder}/{$filename}")) {
+ $modified = filemtime("{$folder}/{$filename}");
+ } else {
+ $modified = 0;
+ }
+ $basename = $this->base . $name;
+ $list[$path] = [$basename => ['file' => "{$path}/{$filename}", 'modified' => $modified]];
+ }
+
+ return $list;
+ }
+
+ /**
+ * Detects all directories with a configuration file and returns them with last modification time.
+ *
+ * @param string $folder Location to look up from.
+ * @param string $pattern Pattern to match the file. Pattern will also be removed from the key.
+ * @param int $levels Maximum number of recursive directories.
+ * @return array
+ * @internal
+ */
+ protected function detectRecursive($folder, $pattern, $levels)
+ {
+ $path = trim(Folder::getRelativePath($folder), '/');
+
+ if (is_dir($folder)) {
+ // Find all system and user configuration files.
+ $options = [
+ 'levels' => $levels,
+ 'compare' => 'Filename',
+ 'pattern' => $pattern,
+ 'filters' => [
+ 'pre-key' => $this->base,
+ 'key' => $pattern,
+ 'value' => function (\RecursiveDirectoryIterator $file) use ($path) {
+ return ['file' => "{$path}/{$file->getSubPathname()}", 'modified' => $file->getMTime()];
+ }
+ ],
+ 'key' => 'SubPathname'
+ ];
+
+ $list = Folder::all($folder, $options);
+
+ ksort($list);
+ } else {
+ $list = [];
+ }
+
+ return [$path => $list];
+ }
+
+ /**
+ * Detects all directories with the lookup file and returns them with last modification time.
+ *
+ * @param string $folder Location to look up from.
+ * @param string $lookup Filename to be located (defaults to directory name).
+ * @return array
+ * @internal
+ */
+ protected function detectInFolder($folder, $lookup = null)
+ {
+ $folder = rtrim($folder, '/');
+ $path = trim(Folder::getRelativePath($folder), '/');
+ $base = $path === $folder ? '' : ($path ? substr($folder, 0, -strlen($path)) : $folder . '/');
+
+ $list = [];
+
+ if (is_dir($folder)) {
+ $iterator = new \DirectoryIterator($folder);
+
+ /** @var \DirectoryIterator $directory */
+ foreach ($iterator as $directory) {
+ if (!$directory->isDir() || $directory->isDot()) {
+ continue;
+ }
+
+ $name = $directory->getFilename();
+ $find = ($lookup ?: $name) . '.yaml';
+ $filename = "{$path}/{$name}/{$find}";
+
+ if (file_exists($base . $filename)) {
+ $basename = $this->base . $name;
+ $list[$basename] = ['file' => $filename, 'modified' => filemtime($base . $filename)];
+ }
+ }
+ }
+
+ return $list;
+ }
+
+ /**
+ * Detects all plugins with a configuration file and returns them with last modification time.
+ *
+ * @param string $folder Location to look up from.
+ * @param string $pattern Pattern to match the file. Pattern will also be removed from the key.
+ * @param int $levels Maximum number of recursive directories.
+ * @return array
+ * @internal
+ */
+ protected function detectAll($folder, $pattern, $levels)
+ {
+ $path = trim(Folder::getRelativePath($folder), '/');
+
+ if (is_dir($folder)) {
+ // Find all system and user configuration files.
+ $options = [
+ 'levels' => $levels,
+ 'compare' => 'Filename',
+ 'pattern' => $pattern,
+ 'filters' => [
+ 'pre-key' => $this->base,
+ 'key' => $pattern,
+ 'value' => function (\RecursiveDirectoryIterator $file) use ($path) {
+ return ["{$path}/{$file->getSubPathname()}" => $file->getMTime()];
+ }
+ ],
+ 'key' => 'SubPathname'
+ ];
+
+ $list = Folder::all($folder, $options);
+
+ ksort($list);
+ } else {
+ $list = [];
+ }
+
+ return $list;
+ }
+}
diff --git a/system/src/Grav/Common/Config/Languages.php b/system/src/Grav/Common/Config/Languages.php
new file mode 100644
index 0000000..9c76dc5
--- /dev/null
+++ b/system/src/Grav/Common/Config/Languages.php
@@ -0,0 +1,83 @@
+checksum = $checksum;
+ }
+
+ return $this->checksum;
+ }
+
+ public function modified($modified = null)
+ {
+ if ($modified !== null) {
+ $this->modified = $modified;
+ }
+
+ return $this->modified;
+ }
+
+ public function timestamp($timestamp = null)
+ {
+ if ($timestamp !== null) {
+ $this->timestamp = $timestamp;
+ }
+
+ return $this->timestamp;
+ }
+
+ public function reformat()
+ {
+ if (isset($this->items['plugins'])) {
+ $this->items = array_merge_recursive($this->items, $this->items['plugins']);
+ unset($this->items['plugins']);
+ }
+ }
+
+ public function mergeRecursive(array $data)
+ {
+ $this->items = Utils::arrayMergeRecursiveUnique($this->items, $data);
+ }
+
+ public function flattenByLang($lang)
+ {
+ $language = $this->items[$lang];
+ return Utils::arrayFlattenDotNotation($language);
+ }
+
+ public function unflatten($array)
+ {
+ return Utils::arrayUnflattenDotNotation($array);
+ }
+}
diff --git a/system/src/Grav/Common/Config/Setup.php b/system/src/Grav/Common/Config/Setup.php
new file mode 100644
index 0000000..6a4d336
--- /dev/null
+++ b/system/src/Grav/Common/Config/Setup.php
@@ -0,0 +1,321 @@
+ 'unknown',
+ '127.0.0.1' => 'localhost',
+ '::1' => 'localhost'
+ ];
+
+ /**
+ * @var string Current environment normalized to lower case.
+ */
+ public static $environment;
+
+ protected $streams = [
+ 'system' => [
+ 'type' => 'ReadOnlyStream',
+ 'prefixes' => [
+ '' => ['system'],
+ ]
+ ],
+ 'user' => [
+ 'type' => 'ReadOnlyStream',
+ 'force' => true,
+ 'prefixes' => [
+ '' => ['user'],
+ ]
+ ],
+ 'environment' => [
+ 'type' => 'ReadOnlyStream'
+ // If not defined, environment will be set up in the constructor.
+ ],
+ 'asset' => [
+ 'type' => 'Stream',
+ 'prefixes' => [
+ '' => ['assets'],
+ ]
+ ],
+ 'blueprints' => [
+ 'type' => 'ReadOnlyStream',
+ 'prefixes' => [
+ '' => ['environment://blueprints', 'user://blueprints', 'system/blueprints'],
+ ]
+ ],
+ 'config' => [
+ 'type' => 'ReadOnlyStream',
+ 'prefixes' => [
+ '' => ['environment://config', 'user://config', 'system/config'],
+ ]
+ ],
+ 'plugins' => [
+ 'type' => 'ReadOnlyStream',
+ 'prefixes' => [
+ '' => ['user://plugins'],
+ ]
+ ],
+ 'plugin' => [
+ 'type' => 'ReadOnlyStream',
+ 'prefixes' => [
+ '' => ['user://plugins'],
+ ]
+ ],
+ 'themes' => [
+ 'type' => 'ReadOnlyStream',
+ 'prefixes' => [
+ '' => ['user://themes'],
+ ]
+ ],
+ 'languages' => [
+ 'type' => 'ReadOnlyStream',
+ 'prefixes' => [
+ '' => ['environment://languages', 'user://languages', 'system/languages'],
+ ]
+ ],
+ 'cache' => [
+ 'type' => 'Stream',
+ 'force' => true,
+ 'prefixes' => [
+ '' => ['cache'],
+ 'images' => ['images']
+ ]
+ ],
+ 'log' => [
+ 'type' => 'Stream',
+ 'force' => true,
+ 'prefixes' => [
+ '' => ['logs']
+ ]
+ ],
+ 'backup' => [
+ 'type' => 'Stream',
+ 'force' => true,
+ 'prefixes' => [
+ '' => ['backup']
+ ]
+ ],
+ 'tmp' => [
+ 'type' => 'Stream',
+ 'force' => true,
+ 'prefixes' => [
+ '' => ['tmp']
+ ]
+ ],
+ 'image' => [
+ 'type' => 'Stream',
+ 'prefixes' => [
+ '' => ['user://images', 'system://images']
+ ]
+ ],
+ 'page' => [
+ 'type' => 'ReadOnlyStream',
+ 'prefixes' => [
+ '' => ['user://pages']
+ ]
+ ],
+ 'user-data' => [
+ 'type' => 'Stream',
+ 'force' => true,
+ 'prefixes' => [
+ '' => ['user://data']
+ ]
+ ],
+ 'account' => [
+ 'type' => 'ReadOnlyStream',
+ 'prefixes' => [
+ '' => ['user://accounts']
+ ]
+ ],
+ ];
+
+ /**
+ * @param Container|array $container
+ */
+ public function __construct($container)
+ {
+ // If no environment is set, make sure we get one (CLI or hostname).
+ if (!static::$environment) {
+ if (\defined('GRAV_CLI')) {
+ static::$environment = 'cli';
+ } else {
+ /** @var ServerRequestInterface $request */
+ $request = $container['request'];
+ $host = $request->getUri()->getHost();
+
+ static::$environment = Utils::substrToString($host, ':');
+ }
+ }
+
+ // Resolve server aliases to the proper environment.
+ $environment = $this->environments[static::$environment] ?? static::$environment;
+
+ // Pre-load setup.php which contains our initial configuration.
+ // Configuration may contain dynamic parts, which is why we need to always load it.
+ // If "GRAV_SETUP_PATH" has been defined, use it, otherwise use defaults.
+ $file = \defined('GRAV_SETUP_PATH') ? GRAV_SETUP_PATH : GRAV_ROOT . '/setup.php';
+ $setup = is_file($file) ? (array) include $file : [];
+
+ // Add default streams defined in beginning of the class.
+ if (!isset($setup['streams']['schemes'])) {
+ $setup['streams']['schemes'] = [];
+ }
+ $setup['streams']['schemes'] += $this->streams;
+
+ // Initialize class.
+ parent::__construct($setup);
+
+ // Set up environment.
+ $this->def('environment', $environment);
+ $this->def('streams.schemes.environment.prefixes', ['' => ["user://{$this->get('environment')}"]]);
+ }
+
+ /**
+ * @return $this
+ * @throws \RuntimeException
+ * @throws \InvalidArgumentException
+ */
+ public function init()
+ {
+ $locator = new UniformResourceLocator(GRAV_ROOT);
+ $files = [];
+
+ $guard = 5;
+ do {
+ $check = $files;
+ $this->initializeLocator($locator);
+ $files = $locator->findResources('config://streams.yaml');
+
+ if ($check === $files) {
+ break;
+ }
+
+ // Update streams.
+ foreach (array_reverse($files) as $path) {
+ $file = CompiledYamlFile::instance($path);
+ $content = (array)$file->content();
+ if (!empty($content['schemes'])) {
+ $this->items['streams']['schemes'] = $content['schemes'] + $this->items['streams']['schemes'];
+ }
+ }
+ } while (--$guard);
+
+ if (!$guard) {
+ throw new \RuntimeException('Setup: Configuration reload loop detected!');
+ }
+
+ // Make sure we have valid setup.
+ $this->check($locator);
+
+ return $this;
+ }
+
+ /**
+ * Initialize resource locator by using the configuration.
+ *
+ * @param UniformResourceLocator $locator
+ * @throws \BadMethodCallException
+ */
+ public function initializeLocator(UniformResourceLocator $locator)
+ {
+ $locator->reset();
+
+ $schemes = (array) $this->get('streams.schemes', []);
+
+ foreach ($schemes as $scheme => $config) {
+ if (isset($config['paths'])) {
+ $locator->addPath($scheme, '', $config['paths']);
+ }
+
+ $override = $config['override'] ?? false;
+ $force = $config['force'] ?? false;
+
+ if (isset($config['prefixes'])) {
+ foreach ((array)$config['prefixes'] as $prefix => $paths) {
+ $locator->addPath($scheme, $prefix, $paths, $override, $force);
+ }
+ }
+ }
+ }
+
+ /**
+ * Get available streams and their types from the configuration.
+ *
+ * @return array
+ */
+ public function getStreams()
+ {
+ $schemes = [];
+ foreach ((array) $this->get('streams.schemes') as $scheme => $config) {
+ $type = $config['type'] ?? 'ReadOnlyStream';
+ if ($type[0] !== '\\') {
+ $type = '\\RocketTheme\\Toolbox\\StreamWrapper\\' . $type;
+ }
+
+ $schemes[$scheme] = $type;
+ }
+
+ return $schemes;
+ }
+
+ /**
+ * @param UniformResourceLocator $locator
+ * @throws \InvalidArgumentException
+ * @throws \BadMethodCallException
+ * @throws \RuntimeException
+ */
+ protected function check(UniformResourceLocator $locator)
+ {
+ $streams = $this->items['streams']['schemes'] ?? null;
+ if (!\is_array($streams)) {
+ throw new \InvalidArgumentException('Configuration is missing streams.schemes!');
+ }
+ $diff = array_keys(array_diff_key($this->streams, $streams));
+ if ($diff) {
+ throw new \InvalidArgumentException(
+ sprintf('Configuration is missing keys %s from streams.schemes!', implode(', ', $diff))
+ );
+ }
+
+ try {
+ if (!$locator->findResource('environment://config', true)) {
+ // If environment does not have its own directory, remove it from the lookup.
+ $this->set('streams.schemes.environment.prefixes', ['config' => []]);
+ $this->initializeLocator($locator);
+ }
+
+ // Create security.yaml if it doesn't exist.
+ $filename = $locator->findResource('config://security.yaml', true, true);
+ $security_file = CompiledYamlFile::instance($filename);
+ $security_content = (array)$security_file->content();
+
+ if (!isset($security_content['salt'])) {
+ $security_content = array_merge($security_content, ['salt' => Utils::generateRandomString(14)]);
+ $security_file->content($security_content);
+ $security_file->save();
+ $security_file->free();
+ }
+ } catch (\RuntimeException $e) {
+ throw new \RuntimeException(sprintf('Grav failed to initialize: %s', $e->getMessage()), 500, $e);
+ }
+ }
+}
diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php
new file mode 100644
index 0000000..e703777
--- /dev/null
+++ b/system/src/Grav/Common/Data/Blueprint.php
@@ -0,0 +1,428 @@
+blueprintSchema) {
+ $this->blueprintSchema = clone $this->blueprintSchema;
+ }
+ }
+
+ public function setScope($scope)
+ {
+ $this->scope = $scope;
+ }
+
+ /**
+ * Set default values for field types.
+ *
+ * @param array $types
+ * @return $this
+ */
+ public function setTypes(array $types)
+ {
+ $this->initInternals();
+
+ $this->blueprintSchema->setTypes($types);
+
+ return $this;
+ }
+
+ /**
+ * Get nested structure containing default values defined in the blueprints.
+ *
+ * Fields without default value are ignored in the list.
+ *
+ * @return array
+ */
+ public function getDefaults()
+ {
+ $this->initInternals();
+
+ if (null === $this->defaults) {
+ $this->defaults = $this->blueprintSchema->getDefaults();
+ }
+
+ return $this->defaults;
+ }
+
+ /**
+ * Initialize blueprints with its dynamic fields.
+ *
+ * @return $this
+ */
+ public function init()
+ {
+ foreach ($this->dynamic as $key => $data) {
+ // Locate field.
+ $path = explode('/', $key);
+ $current = &$this->items;
+
+ foreach ($path as $field) {
+ if (\is_object($current)) {
+ // Handle objects.
+ if (!isset($current->{$field})) {
+ $current->{$field} = [];
+ }
+
+ $current = &$current->{$field};
+ } else {
+ // Handle arrays and scalars.
+ if (!\is_array($current)) {
+ $current = [$field => []];
+ } elseif (!isset($current[$field])) {
+ $current[$field] = [];
+ }
+
+ $current = &$current[$field];
+ }
+ }
+
+ // Set dynamic property.
+ foreach ($data as $property => $call) {
+ $action = $call['action'];
+ $method = 'dynamic' . ucfirst($action);
+
+ if (isset($this->handlers[$action])) {
+ $callable = $this->handlers[$action];
+ $callable($current, $property, $call);
+ } elseif (method_exists($this, $method)) {
+ $this->{$method}($current, $property, $call);
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Merge two arrays by using blueprints.
+ *
+ * @param array $data1
+ * @param array $data2
+ * @param string $name Optional
+ * @param string $separator Optional
+ * @return array
+ */
+ public function mergeData(array $data1, array $data2, $name = null, $separator = '.')
+ {
+ $this->initInternals();
+
+ return $this->blueprintSchema->mergeData($data1, $data2, $name, $separator);
+ }
+
+ /**
+ * Process data coming from a form.
+ *
+ * @param array $data
+ * @param array $toggles
+ * @return array
+ */
+ public function processForm(array $data, array $toggles = [])
+ {
+ $this->initInternals();
+
+ return $this->blueprintSchema->processForm($data, $toggles);
+ }
+
+ /**
+ * Return data fields that do not exist in blueprints.
+ *
+ * @param array $data
+ * @param string $prefix
+ * @return array
+ */
+ public function extra(array $data, $prefix = '')
+ {
+ $this->initInternals();
+
+ return $this->blueprintSchema->extra($data, $prefix);
+ }
+
+ /**
+ * Validate data against blueprints.
+ *
+ * @param array $data
+ * @throws \RuntimeException
+ */
+ public function validate(array $data)
+ {
+ $this->initInternals();
+
+ $this->blueprintSchema->validate($data);
+ }
+
+ /**
+ * Filter data by using blueprints.
+ *
+ * @param array $data
+ * @param bool $missingValuesAsNull
+ * @param bool $keepEmptyValues
+ * @return array
+ */
+ public function filter(array $data, bool $missingValuesAsNull = false, bool $keepEmptyValues = false)
+ {
+ $this->initInternals();
+
+ return $this->blueprintSchema->filter($data, $missingValuesAsNull, $keepEmptyValues);
+ }
+
+
+ /**
+ * Flatten data by using blueprints.
+ *
+ * @param array $data
+ * @return array
+ */
+ public function flattenData(array $data)
+ {
+ $this->initInternals();
+
+ return $this->blueprintSchema->flattenData($data);
+ }
+
+
+ /**
+ * Return blueprint data schema.
+ *
+ * @return BlueprintSchema
+ */
+ public function schema()
+ {
+ $this->initInternals();
+
+ return $this->blueprintSchema;
+ }
+
+ public function addDynamicHandler(string $name, callable $callable): void
+ {
+ $this->handlers[$name] = $callable;
+ }
+
+ /**
+ * Initialize validator.
+ */
+ protected function initInternals()
+ {
+ if (null === $this->blueprintSchema) {
+ $types = Grav::instance()['plugins']->formFieldTypes;
+
+ $this->blueprintSchema = new BlueprintSchema;
+
+ if ($types) {
+ $this->blueprintSchema->setTypes($types);
+ }
+
+ $this->blueprintSchema->embed('', $this->items);
+ $this->blueprintSchema->init();
+ $this->defaults = null;
+ }
+ }
+
+ /**
+ * @param string $filename
+ * @return string
+ */
+ protected function loadFile($filename)
+ {
+ $file = CompiledYamlFile::instance($filename);
+ $content = $file->content();
+ $file->free();
+
+ return $content;
+ }
+
+ /**
+ * @param string|array $path
+ * @param string $context
+ * @return array
+ */
+ protected function getFiles($path, $context = null)
+ {
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+
+ if (\is_string($path) && !$locator->isStream($path)) {
+ // Find path overrides.
+ $paths = (array) ($this->overrides[$path] ?? null);
+
+ // Add path pointing to default context.
+ if ($context === null) {
+ $context = $this->context;
+ }
+
+ if ($context && $context[\strlen($context)-1] !== '/') {
+ $context .= '/';
+ }
+
+ $path = $context . $path;
+
+ if (!preg_match('/\.yaml$/', $path)) {
+ $path .= '.yaml';
+ }
+
+ $paths[] = $path;
+ } else {
+ $paths = (array) $path;
+ }
+
+ $files = [];
+ foreach ($paths as $lookup) {
+ if (\is_string($lookup) && strpos($lookup, '://')) {
+ $files = array_merge($files, $locator->findResources($lookup));
+ } else {
+ $files[] = $lookup;
+ }
+ }
+
+ return array_values(array_unique($files));
+ }
+
+ /**
+ * @param array $field
+ * @param string $property
+ * @param array $call
+ */
+ protected function dynamicData(array &$field, $property, array &$call)
+ {
+ $params = $call['params'];
+
+ if (\is_array($params)) {
+ $function = array_shift($params);
+ } else {
+ $function = $params;
+ $params = [];
+ }
+
+ [$o, $f] = explode('::', $function, 2);
+
+ $data = null;
+ if (!$f) {
+ if (\function_exists($o)) {
+ $data = \call_user_func_array($o, $params);
+ }
+ } else {
+ if (method_exists($o, $f)) {
+ $data = \call_user_func_array([$o, $f], $params);
+ }
+ }
+
+ // If function returns a value,
+ if (null !== $data) {
+ if (\is_array($data) && isset($field[$property]) && \is_array($field[$property])) {
+ // Combine field and @data-field together.
+ $field[$property] += $data;
+ } else {
+ // Or create/replace field with @data-field.
+ $field[$property] = $data;
+ }
+ }
+ }
+
+ /**
+ * @param array $field
+ * @param string $property
+ * @param array $call
+ */
+ protected function dynamicConfig(array &$field, $property, array &$call)
+ {
+ $value = $call['params'];
+ $default = $field[$property] ?? null;
+ $config = Grav::instance()['config']->get($value, $default);
+
+ if (null !== $config) {
+ $field[$property] = $config;
+ }
+ }
+
+ /**
+ * @param array $field
+ * @param string $property
+ * @param array $call
+ */
+ protected function dynamicSecurity(array &$field, $property, array &$call)
+ {
+ if ($property || !empty($field['validate']['ignore'])) {
+ return;
+ }
+
+ $grav = Grav::instance();
+ $actions = (array)$call['params'];
+
+ /** @var UserInterface|null $user */
+ $user = $grav['user'] ?? null;
+ foreach ($actions as $action) {
+ if (!$user || !$user->authorize($action)) {
+ $this->addPropertyRecursive($field, 'validate', ['ignore' => true]);
+ return;
+ }
+ }
+ }
+
+ /**
+ * @param array $field
+ * @param string $property
+ * @param array $call
+ */
+ protected function dynamicScope(array &$field, $property, array &$call)
+ {
+ if ($property && $property !== 'ignore') {
+ return;
+ }
+
+ $scopes = (array)$call['params'];
+ $matches = \in_array($this->scope, $scopes, true);
+ if ($this->scope && $property !== 'ignore') {
+ $matches = !$matches;
+ }
+
+ if ($matches) {
+ $this->addPropertyRecursive($field, 'validate', ['ignore' => true]);
+ return;
+ }
+ }
+
+ protected function addPropertyRecursive(array &$field, $property, $value)
+ {
+ if (\is_array($value) && isset($field[$property]) && \is_array($field[$property])) {
+ $field[$property] = array_merge_recursive($field[$property], $value);
+ } else {
+ $field[$property] = $value;
+ }
+
+ if (!empty($field['fields'])) {
+ foreach ($field['fields'] as $key => &$child) {
+ $this->addPropertyRecursive($child, $property, $value);
+ }
+ }
+ }
+}
diff --git a/system/src/Grav/Common/Data/BlueprintSchema.php b/system/src/Grav/Common/Data/BlueprintSchema.php
new file mode 100644
index 0000000..beebaa6
--- /dev/null
+++ b/system/src/Grav/Common/Data/BlueprintSchema.php
@@ -0,0 +1,330 @@
+ true,
+ 'help' => true,
+ 'placeholder' => true,
+ 'placeholder_key' => true,
+ 'placeholder_value' => true,
+ 'fields' => true
+ ];
+
+ /**
+ * @return array
+ */
+ public function getTypes()
+ {
+ return $this->types;
+ }
+
+ /**
+ * @param string $name
+ * @return array
+ */
+ public function getType($name)
+ {
+ return $this->types[$name] ?? [];
+ }
+
+ /**
+ * Validate data against blueprints.
+ *
+ * @param array $data
+ * @throws \RuntimeException
+ */
+ public function validate(array $data)
+ {
+ try {
+ $messages = $this->validateArray($data, $this->nested);
+
+ } catch (\RuntimeException $e) {
+ throw (new ValidationException($e->getMessage(), $e->getCode(), $e))->setMessages();
+ }
+
+ if (!empty($messages)) {
+ throw (new ValidationException())->setMessages($messages);
+ }
+ }
+
+ /**
+ * @param array $data
+ * @param array $toggles
+ * @return array
+ */
+ public function processForm(array $data, array $toggles = [])
+ {
+ return $this->processFormRecursive($data, $toggles, $this->nested);
+ }
+
+ /**
+ * Filter data by using blueprints.
+ *
+ * @param array $data Incoming data, for example from a form.
+ * @param bool $missingValuesAsNull Include missing values as nulls.
+ * @param bool $keepEmptyValues Include empty values.
+ * @return array
+ */
+ public function filter(array $data, $missingValuesAsNull = false, $keepEmptyValues = false)
+ {
+ return $this->filterArray($data, $this->nested, $missingValuesAsNull, $keepEmptyValues);
+ }
+
+ /**
+ * Flatten data by using blueprints.
+ *
+ * @param array $data Data to be flattened.
+ * @return array
+ */
+ public function flattenData(array $data)
+ {
+ return $this->flattenArray($data, $this->nested, '');
+ }
+
+ /**
+ * @param array $data
+ * @param array $rules
+ * @param string $prefix
+ * @return array
+ */
+ protected function flattenArray(array $data, array $rules, string $prefix)
+ {
+ $array = [];
+
+ foreach ($data as $key => $field) {
+ $val = $rules[$key] ?? $rules['*'] ?? null;
+ $rule = is_string($val) ? $this->items[$val] : null;
+
+ if ($rule || isset($val['*'])) {
+ // Item has been defined in blueprints.
+ $array[$prefix.$key] = $field;
+ } elseif (is_array($field) && is_array($val)) {
+ // Array has been defined in blueprints.
+ $array += $this->flattenArray($field, $val, $prefix . $key . '.');
+ } else {
+ // Undefined/extra item.
+ $array[$prefix.$key] = $field;
+ }
+ }
+ return $array;
+ }
+
+ /**
+ * @param array $data
+ * @param array $rules
+ * @return array
+ * @throws \RuntimeException
+ */
+ protected function validateArray(array $data, array $rules)
+ {
+ $messages = $this->checkRequired($data, $rules);
+
+ foreach ($data as $key => $child) {
+ $val = $rules[$key] ?? $rules['*'] ?? null;
+ $rule = \is_string($val) ? $this->items[$val] : null;
+
+ if ($rule) {
+ // Item has been defined in blueprints.
+ if (!empty($rule['disabled']) || !empty($rule['validate']['ignore'])) {
+ // Skip validation in the ignored field.
+ continue;
+ }
+
+ $messages += Validation::validate($child, $rule);
+ } elseif (\is_array($child) && \is_array($val)) {
+ // Array has been defined in blueprints.
+ $messages += $this->validateArray($child, $val);
+ } elseif (isset($rules['validation']) && $rules['validation'] === 'strict') {
+ // Undefined/extra item.
+ throw new \RuntimeException(sprintf('%s is not defined in blueprints', $key));
+ }
+ }
+
+ return $messages;
+ }
+
+ /**
+ * @param array $data
+ * @param array $rules
+ * @param bool $missingValuesAsNull
+ * @param bool $keepEmptyValues
+ * @return array
+ */
+ protected function filterArray(array $data, array $rules, $missingValuesAsNull, $keepEmptyValues)
+ {
+ $results = [];
+
+ if ($missingValuesAsNull) {
+ // First pass is to fill up all the fields with null. This is done to lock the ordering of the fields.
+ foreach ($rules as $key => $rule) {
+ if ($key && !isset($results[$key])) {
+ $val = $rules[$key] ?? $rules['*'] ?? null;
+ $rule = \is_string($val) ? $this->items[$val] : null;
+
+ if (empty($rule['disabled']) && empty($rule['validate']['ignore'])) {
+ continue;
+ }
+ }
+ }
+ }
+
+ foreach ($data as $key => $field) {
+ $val = $rules[$key] ?? $rules['*'] ?? null;
+ $rule = \is_string($val) ? $this->items[$val] : null;
+
+ if ($rule) {
+ // Item has been defined in blueprints.
+ if (!empty($rule['disabled']) || !empty($rule['validate']['ignore'])) {
+ // Skip any data in the ignored field.
+ unset($results[$key]);
+ continue;
+ }
+
+ $field = Validation::filter($field, $rule);
+ } elseif (\is_array($field) && \is_array($val)) {
+ // Array has been defined in blueprints.
+ $field = $this->filterArray($field, $val, $missingValuesAsNull, $keepEmptyValues);
+
+ } elseif (isset($rules['validation']) && $rules['validation'] === 'strict') {
+ // Skip any extra data.
+ continue;
+ }
+
+ if ($keepEmptyValues || (null !== $field && (!\is_array($field) || !empty($field)))) {
+ $results[$key] = $field;
+ }
+ }
+
+ return $results ?: null;
+ }
+
+ /**
+ * @param array|null $data
+ * @param array $toggles
+ * @param array $nested
+ * @return array|null
+ */
+ protected function processFormRecursive(?array $data, array $toggles, array $nested)
+ {
+ foreach ($nested as $key => $value) {
+ if ($key === '') {
+ continue;
+ }
+ if ($key === '*') {
+ // TODO: Add support to collections.
+ continue;
+ }
+ if (is_array($value)) {
+ // Special toggle handling for all the nested data.
+ $toggle = $toggles[$key] ?? [];
+ if (!is_array($toggle)) {
+ if (!$toggle) {
+ $data[$key] = null;
+
+ continue;
+ }
+
+ $toggle = [];
+ }
+ // Recursively fetch the items.
+ $data[$key] = $this->processFormRecursive($data[$key] ?? null, $toggle, $value);
+ } else {
+ $field = $this->get($value);
+ // Do not add the field if:
+ if (
+ // Not an input field
+ !$field
+ // Field has been disabled
+ || !empty($field['disabled'])
+ // Field validation is set to be ignored
+ || !empty($field['validate']['ignore'])
+ // Field is toggleable and the toggle is turned off
+ || (!empty($field['toggleable']) && empty($toggles[$key]))
+ ) {
+ continue;
+ }
+ if (!isset($data[$key])) {
+ $data[$key] = null;
+ }
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * @param array $data
+ * @param array $fields
+ * @return array
+ */
+ protected function checkRequired(array $data, array $fields)
+ {
+ $messages = [];
+
+ foreach ($fields as $name => $field) {
+ if (!\is_string($field)) {
+ continue;
+ }
+
+ $field = $this->items[$field];
+
+ // Skip ignored field, it will not be required.
+ if (!empty($field['disabled']) || !empty($field['validate']['ignore'])) {
+ continue;
+ }
+
+ // Check if required.
+ if (isset($field['validate']['required'])
+ && $field['validate']['required'] === true) {
+
+ if (isset($data[$name])) {
+ continue;
+ }
+ if ($field['type'] === 'file' && isset($data['data']['name'][$name])) { //handle case of file input fields required
+ continue;
+ }
+
+ $value = $field['label'] ?? $field['name'];
+ $language = Grav::instance()['language'];
+ $message = sprintf($language->translate('GRAV.FORM.MISSING_REQUIRED_FIELD', null, true) . ' %s', $language->translate($value));
+ $messages[$field['name']][] = $message;
+ }
+ }
+
+ return $messages;
+ }
+
+ /**
+ * @param array $field
+ * @param string $property
+ * @param array $call
+ */
+ protected function dynamicConfig(array &$field, $property, array &$call)
+ {
+ $value = $call['params'];
+
+ $default = $field[$property] ?? null;
+ $config = Grav::instance()['config']->get($value, $default);
+
+ if (null !== $config) {
+ $field[$property] = $config;
+ }
+ }
+}
diff --git a/system/src/Grav/Common/Data/Blueprints.php b/system/src/Grav/Common/Data/Blueprints.php
new file mode 100644
index 0000000..1d0fcc6
--- /dev/null
+++ b/system/src/Grav/Common/Data/Blueprints.php
@@ -0,0 +1,114 @@
+search = $search;
+ }
+
+ /**
+ * Get blueprint.
+ *
+ * @param string $type Blueprint type.
+ * @return Blueprint
+ * @throws \RuntimeException
+ */
+ public function get($type)
+ {
+ if (!isset($this->instances[$type])) {
+ $blueprint = $this->loadFile($type);
+ $this->instances[$type] = $blueprint;
+ }
+
+ return $this->instances[$type];
+ }
+
+ /**
+ * Get all available blueprint types.
+ *
+ * @return array List of type=>name
+ */
+ public function types()
+ {
+ if ($this->types === null) {
+ $this->types = [];
+
+ $grav = Grav::instance();
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $grav['locator'];
+
+ // Get stream / directory iterator.
+ if ($locator->isStream($this->search)) {
+ $iterator = $locator->getIterator($this->search);
+ } else {
+ $iterator = new \DirectoryIterator($this->search);
+ }
+
+ /** @var \DirectoryIterator $file */
+ foreach ($iterator as $file) {
+ if (!$file->isFile() || '.' . $file->getExtension() !== YAML_EXT) {
+ continue;
+ }
+ $name = $file->getBasename(YAML_EXT);
+ $this->types[$name] = ucfirst(str_replace('_', ' ', $name));
+ }
+ }
+
+ return $this->types;
+ }
+
+
+ /**
+ * Load blueprint file.
+ *
+ * @param string $name Name of the blueprint.
+ * @return Blueprint
+ */
+ protected function loadFile($name)
+ {
+ $blueprint = new Blueprint($name);
+
+ if (\is_array($this->search) || \is_object($this->search)) {
+ // Page types.
+ $blueprint->setOverrides($this->search);
+ $blueprint->setContext('blueprints://pages');
+ } else {
+ $blueprint->setContext($this->search);
+ }
+
+ try {
+ $blueprint->load()->init();
+ } catch (\RuntimeException $e) {
+ $log = Grav::instance()['log'];
+ $log->error(sprintf('Blueprint %s cannot be loaded: %s', $name, $e->getMessage()));
+
+ throw $e;
+ }
+
+ return $blueprint;
+ }
+}
diff --git a/system/src/Grav/Common/Data/Data.php b/system/src/Grav/Common/Data/Data.php
new file mode 100644
index 0000000..97b5530
--- /dev/null
+++ b/system/src/Grav/Common/Data/Data.php
@@ -0,0 +1,327 @@
+items = $items;
+ $this->blueprints = $blueprints;
+ }
+
+ /**
+ * @param bool $value
+ * @return $this
+ */
+ public function setKeepEmptyValues(bool $value)
+ {
+ $this->keepEmptyValues = $value;
+
+ return $this;
+ }
+
+ /**
+ * @param bool $value
+ * @return $this
+ */
+ public function setMissingValuesAsNull(bool $value)
+ {
+ $this->missingValuesAsNull = $value;
+
+ return $this;
+ }
+
+ /**
+ * Get value by using dot notation for nested arrays/objects.
+ *
+ * @example $value = $data->value('this.is.my.nested.variable');
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $default Default value (or null).
+ * @param string $separator Separator, defaults to '.'
+ * @return mixed Value.
+ */
+ public function value($name, $default = null, $separator = '.')
+ {
+ return $this->get($name, $default, $separator);
+ }
+
+ /**
+ * Join nested values together by using blueprints.
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $value Value to be joined.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ * @throws \RuntimeException
+ */
+ public function join($name, $value, $separator = '.')
+ {
+ $old = $this->get($name, null, $separator);
+ if ($old !== null) {
+ if (!\is_array($old)) {
+ throw new \RuntimeException('Value ' . $old);
+ }
+
+ if (\is_object($value)) {
+ $value = (array) $value;
+ } elseif (!\is_array($value)) {
+ throw new \RuntimeException('Value ' . $value);
+ }
+
+ $value = $this->blueprints()->mergeData($old, $value, $name, $separator);
+ }
+
+ $this->set($name, $value, $separator);
+
+ return $this;
+ }
+
+ /**
+ * Get nested structure containing default values defined in the blueprints.
+ *
+ * Fields without default value are ignored in the list.
+
+ * @return array
+ */
+ public function getDefaults()
+ {
+ return $this->blueprints()->getDefaults();
+ }
+
+ /**
+ * Set default values by using blueprints.
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $value Value to be joined.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function joinDefaults($name, $value, $separator = '.')
+ {
+ if (\is_object($value)) {
+ $value = (array) $value;
+ }
+
+ $old = $this->get($name, null, $separator);
+ if ($old !== null) {
+ $value = $this->blueprints()->mergeData($value, $old, $name, $separator);
+ }
+
+ $this->set($name, $value, $separator);
+
+ return $this;
+ }
+
+ /**
+ * Get value from the configuration and join it with given data.
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param array|object $value Value to be joined.
+ * @param string $separator Separator, defaults to '.'
+ * @return array
+ * @throws \RuntimeException
+ */
+ public function getJoined($name, $value, $separator = '.')
+ {
+ if (\is_object($value)) {
+ $value = (array) $value;
+ } elseif (!\is_array($value)) {
+ throw new \RuntimeException('Value ' . $value);
+ }
+
+ $old = $this->get($name, null, $separator);
+
+ if ($old === null) {
+ // No value set; no need to join data.
+ return $value;
+ }
+
+ if (!\is_array($old)) {
+ throw new \RuntimeException('Value ' . $old);
+ }
+
+ // Return joined data.
+ return $this->blueprints()->mergeData($old, $value, $name, $separator);
+ }
+
+
+ /**
+ * Merge two configurations together.
+ *
+ * @param array $data
+ * @return $this
+ */
+ public function merge(array $data)
+ {
+ $this->items = $this->blueprints()->mergeData($this->items, $data);
+
+ return $this;
+ }
+
+ /**
+ * Set default values to the configuration if variables were not set.
+ *
+ * @param array $data
+ * @return $this
+ */
+ public function setDefaults(array $data)
+ {
+ $this->items = $this->blueprints()->mergeData($data, $this->items);
+
+ return $this;
+ }
+
+ /**
+ * Validate by blueprints.
+ *
+ * @return $this
+ * @throws \Exception
+ */
+ public function validate()
+ {
+ $this->blueprints()->validate($this->items);
+
+ return $this;
+ }
+
+ /**
+ * @return $this
+ */
+ public function filter()
+ {
+ $args = func_get_args();
+ $missingValuesAsNull = (bool)(array_shift($args) ?? $this->missingValuesAsNull);
+ $keepEmptyValues = (bool)(array_shift($args) ?? $this->keepEmptyValues);
+
+ $this->items = $this->blueprints()->filter($this->items, $missingValuesAsNull, $keepEmptyValues);
+
+ return $this;
+ }
+
+ /**
+ * Get extra items which haven't been defined in blueprints.
+ *
+ * @return array
+ */
+ public function extra()
+ {
+ return $this->blueprints()->extra($this->items);
+ }
+
+ /**
+ * Return blueprints.
+ *
+ * @return Blueprint
+ */
+ public function blueprints()
+ {
+ if (!$this->blueprints){
+ $this->blueprints = new Blueprint;
+ } elseif (\is_callable($this->blueprints)) {
+ // Lazy load blueprints.
+ $blueprints = $this->blueprints;
+ $this->blueprints = $blueprints();
+ }
+ return $this->blueprints;
+ }
+
+ /**
+ * Save data if storage has been defined.
+ * @throws \RuntimeException
+ */
+ public function save()
+ {
+ $file = $this->file();
+ if ($file) {
+ $file->save($this->items);
+ }
+ }
+
+ /**
+ * Returns whether the data already exists in the storage.
+ *
+ * NOTE: This method does not check if the data is current.
+ *
+ * @return bool
+ */
+ public function exists()
+ {
+ $file = $this->file();
+
+ return $file && $file->exists();
+ }
+
+ /**
+ * Return unmodified data as raw string.
+ *
+ * NOTE: This function only returns data which has been saved to the storage.
+ *
+ * @return string
+ */
+ public function raw()
+ {
+ $file = $this->file();
+
+ return $file ? $file->raw() : '';
+ }
+
+ /**
+ * Set or get the data storage.
+ *
+ * @param FileInterface $storage Optionally enter a new storage.
+ * @return FileInterface
+ */
+ public function file(FileInterface $storage = null)
+ {
+ if ($storage) {
+ $this->storage = $storage;
+ }
+
+ return $this->storage;
+ }
+
+ public function jsonSerialize()
+ {
+ return $this->items;
+ }
+}
diff --git a/system/src/Grav/Common/Data/DataInterface.php b/system/src/Grav/Common/Data/DataInterface.php
new file mode 100644
index 0000000..91279b2
--- /dev/null
+++ b/system/src/Grav/Common/Data/DataInterface.php
@@ -0,0 +1,70 @@
+value('this.is.my.nested.variable');
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $default Default value (or null).
+ * @param string $separator Separator, defaults to '.'
+ * @return mixed Value.
+ */
+ public function value($name, $default = null, $separator = '.');
+
+ /**
+ * Merge external data.
+ *
+ * @param array $data
+ * @return mixed
+ */
+ public function merge(array $data);
+
+ /**
+ * Return blueprints.
+ */
+ public function blueprints();
+
+ /**
+ * Validate by blueprints.
+ *
+ * @throws \Exception
+ */
+ public function validate();
+
+ /**
+ * Filter all items by using blueprints.
+ */
+ public function filter();
+
+ /**
+ * Get extra items which haven't been defined in blueprints.
+ */
+ public function extra();
+
+ /**
+ * Save data into the file.
+ */
+ public function save();
+
+ /**
+ * Set or get the data storage.
+ *
+ * @param FileInterface $storage Optionally enter a new storage.
+ * @return FileInterface
+ */
+ public function file(FileInterface $storage = null);
+}
diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php
new file mode 100644
index 0000000..a2bf0c5
--- /dev/null
+++ b/system/src/Grav/Common/Data/Validation.php
@@ -0,0 +1,813 @@
+translate($field['validate']['message'])
+ : $language->translate('GRAV.FORM.INVALID_INPUT', null, true) . ' "' . $language->translate($name) . '"';
+
+
+ // Validate type with fallback type text.
+ $method = 'type' . str_replace('-', '_', $type);
+
+ // If this is a YAML field validate/filter as such
+ if (isset($field['yaml']) && $field['yaml'] === true) {
+ $method = 'typeYaml';
+ }
+
+ $messages = [];
+
+ $success = method_exists(__CLASS__, $method) ? self::$method($value, $validate, $field) : true;
+ if (!$success) {
+ $messages[$field['name']][] = $message;
+ }
+
+ // Check individual rules.
+ foreach ($validate as $rule => $params) {
+ $method = 'validate' . ucfirst(str_replace('-', '_', $rule));
+
+ if (method_exists(__CLASS__, $method)) {
+ $success = self::$method($value, $params);
+
+ if (!$success) {
+ $messages[$field['name']][] = $message;
+ }
+ }
+ }
+
+ return $messages;
+ }
+
+ /**
+ * Filter value against a blueprint field definition.
+ *
+ * @param mixed $value
+ * @param array $field
+ * @return mixed Filtered value.
+ */
+ public static function filter($value, array $field)
+ {
+ $validate = (array)($field['filter'] ?? $field['validate'] ?? null);
+
+ // If value isn't required, we will return null if empty value is given.
+ if (($value === null || $value === '') && empty($validate['required'])) {
+ return null;
+ }
+
+ if (!isset($field['type'])) {
+ $field['type'] = 'text';
+ }
+ $type = $field['filter']['type'] ?? $field['validate']['type'] ?? $field['type'];
+
+ $method = 'filter' . ucfirst(str_replace('-', '_', $type));
+
+ // If this is a YAML field validate/filter as such
+ if (isset($field['yaml']) && $field['yaml'] === true) {
+ $method = 'filterYaml';
+ }
+
+ if (!method_exists(__CLASS__, $method)) {
+ $method = isset($field['array']) && $field['array'] === true ? 'filterArray' : 'filterText';
+ }
+
+ return self::$method($value, $validate, $field);
+ }
+
+ /**
+ * HTML5 input: text
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeText($value, array $params, array $field)
+ {
+ if (!\is_string($value) && !is_numeric($value)) {
+ return false;
+ }
+
+ $value = (string)$value;
+
+ if (!empty($params['trim'])) {
+ $value = trim($value);
+ }
+
+ if (isset($params['min']) && \strlen($value) < $params['min']) {
+ return false;
+ }
+
+ if (isset($params['max']) && \strlen($value) > $params['max']) {
+ return false;
+ }
+
+ $min = $params['min'] ?? 0;
+ if (isset($params['step']) && (\strlen($value) - $min) % $params['step'] === 0) {
+ return false;
+ }
+
+ if ((!isset($params['multiline']) || !$params['multiline']) && preg_match('/\R/um', $value)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ protected static function filterText($value, array $params, array $field)
+ {
+ if (!\is_string($value) && !is_numeric($value)) {
+ return '';
+ }
+
+ if (!empty($params['trim'])) {
+ $value = trim($value);
+ }
+
+ return (string) $value;
+ }
+
+ /**
+ * @param mixed $value
+ * @param array $params
+ * @param array $field
+ * @return string|null
+ */
+ protected static function filterCheckbox($value, array $params, array $field)
+ {
+ $value = (string)$value;
+ $field_value = (string)($field['value'] ?? '1');
+
+ return $value === $field_value ? $value : null;
+ }
+
+ protected static function filterCommaList($value, array $params, array $field)
+ {
+ return \is_array($value) ? $value : preg_split('/\s*,\s*/', $value, -1, PREG_SPLIT_NO_EMPTY);
+ }
+
+ public static function typeCommaList($value, array $params, array $field)
+ {
+ return \is_array($value) ? true : self::typeText($value, $params, $field);
+ }
+
+ protected static function filterLower($value, array $params)
+ {
+ return strtolower($value);
+ }
+
+ protected static function filterUpper($value, array $params)
+ {
+ return strtoupper($value);
+ }
+
+
+ /**
+ * HTML5 input: textarea
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeTextarea($value, array $params, array $field)
+ {
+ if (!isset($params['multiline'])) {
+ $params['multiline'] = true;
+ }
+
+ return self::typeText($value, $params, $field);
+ }
+
+ /**
+ * HTML5 input: password
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typePassword($value, array $params, array $field)
+ {
+ return self::typeText($value, $params, $field);
+ }
+
+ /**
+ * HTML5 input: hidden
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeHidden($value, array $params, array $field)
+ {
+ return self::typeText($value, $params, $field);
+ }
+
+ /**
+ * Custom input: checkbox list
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeCheckboxes($value, array $params, array $field)
+ {
+ // Set multiple: true so checkboxes can easily use min/max counts to control number of options required
+ $field['multiple'] = true;
+
+ return self::typeArray((array) $value, $params, $field);
+ }
+
+ protected static function filterCheckboxes($value, array $params, array $field)
+ {
+ return self::filterArray($value, $params, $field);
+ }
+
+ /**
+ * HTML5 input: checkbox
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeCheckbox($value, array $params, array $field)
+ {
+ $value = (string)$value;
+ $field_value = (string)($field['value'] ?? '1');
+
+ return $value === $field_value;
+ }
+
+ /**
+ * HTML5 input: radio
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeRadio($value, array $params, array $field)
+ {
+ return self::typeArray((array) $value, $params, $field);
+ }
+
+ /**
+ * Custom input: toggle
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeToggle($value, array $params, array $field)
+ {
+ if (\is_bool($value)) {
+ $value = (int)$value;
+ }
+
+ return self::typeArray((array) $value, $params, $field);
+ }
+
+ /**
+ * Custom input: file
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeFile($value, array $params, array $field)
+ {
+ return self::typeArray((array)$value, $params, $field);
+ }
+
+ protected static function filterFile($value, array $params, array $field)
+ {
+ return (array)$value;
+ }
+
+ /**
+ * HTML5 input: select
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeSelect($value, array $params, array $field)
+ {
+ return self::typeArray((array) $value, $params, $field);
+ }
+
+ /**
+ * HTML5 input: number
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeNumber($value, array $params, array $field)
+ {
+ if (!is_numeric($value)) {
+ return false;
+ }
+
+ if (isset($params['min']) && $value < $params['min']) {
+ return false;
+ }
+
+ if (isset($params['max']) && $value > $params['max']) {
+ return false;
+ }
+
+ $min = $params['min'] ?? 0;
+
+ return !(isset($params['step']) && fmod($value - $min, $params['step']) === 0);
+ }
+
+ protected static function filterNumber($value, array $params, array $field)
+ {
+ return (string)(int)$value !== (string)(float)$value ? (float) $value : (int) $value;
+ }
+
+ protected static function filterDateTime($value, array $params, array $field)
+ {
+ $format = Grav::instance()['config']->get('system.pages.dateformat.default');
+ if ($format) {
+ $converted = new \DateTime($value);
+ return $converted->format($format);
+ }
+ return $value;
+ }
+
+
+ /**
+ * HTML5 input: range
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeRange($value, array $params, array $field)
+ {
+ return self::typeNumber($value, $params, $field);
+ }
+
+ protected static function filterRange($value, array $params, array $field)
+ {
+ return self::filterNumber($value, $params, $field);
+ }
+
+ /**
+ * HTML5 input: color
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeColor($value, array $params, array $field)
+ {
+ return preg_match('/^\#[0-9a-fA-F]{3}[0-9a-fA-F]{3}?$/u', $value);
+ }
+
+ /**
+ * HTML5 input: email
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeEmail($value, array $params, array $field)
+ {
+ $values = !\is_array($value) ? explode(',', preg_replace('/\s+/', '', $value)) : $value;
+
+ foreach ($values as $val) {
+ if (!(self::typeText($val, $params, $field) && filter_var($val, FILTER_VALIDATE_EMAIL))) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * HTML5 input: url
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+
+ public static function typeUrl($value, array $params, array $field)
+ {
+ return self::typeText($value, $params, $field) && filter_var($value, FILTER_VALIDATE_URL);
+ }
+
+ /**
+ * HTML5 input: datetime
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeDatetime($value, array $params, array $field)
+ {
+ if ($value instanceof \DateTime) {
+ return true;
+ }
+ if (!\is_string($value)) {
+ return false;
+ }
+ if (!isset($params['format'])) {
+ return false !== strtotime($value);
+ }
+
+ $dateFromFormat = \DateTime::createFromFormat($params['format'], $value);
+
+ return $dateFromFormat && $value === date($params['format'], $dateFromFormat->getTimestamp());
+ }
+
+ /**
+ * HTML5 input: datetime-local
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeDatetimeLocal($value, array $params, array $field)
+ {
+ return self::typeDatetime($value, $params, $field);
+ }
+
+ /**
+ * HTML5 input: date
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeDate($value, array $params, array $field)
+ {
+ if (!isset($params['format'])) {
+ $params['format'] = 'Y-m-d';
+ }
+
+ return self::typeDatetime($value, $params, $field);
+ }
+
+ /**
+ * HTML5 input: time
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeTime($value, array $params, array $field)
+ {
+ if (!isset($params['format'])) {
+ $params['format'] = 'H:i';
+ }
+
+ return self::typeDatetime($value, $params, $field);
+ }
+
+ /**
+ * HTML5 input: month
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeMonth($value, array $params, array $field)
+ {
+ if (!isset($params['format'])) {
+ $params['format'] = 'Y-m';
+ }
+
+ return self::typeDatetime($value, $params, $field);
+ }
+
+ /**
+ * HTML5 input: week
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeWeek($value, array $params, array $field)
+ {
+ if (!isset($params['format']) && !preg_match('/^\d{4}-W\d{2}$/u', $value)) {
+ return false;
+ }
+
+ return self::typeDatetime($value, $params, $field);
+ }
+
+ /**
+ * Custom input: array
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeArray($value, array $params, array $field)
+ {
+ if (!\is_array($value)) {
+ return false;
+ }
+
+ if (isset($field['multiple'])) {
+ if (isset($params['min']) && \count($value) < $params['min']) {
+ return false;
+ }
+
+ if (isset($params['max']) && \count($value) > $params['max']) {
+ return false;
+ }
+
+ $min = $params['min'] ?? 0;
+ if (isset($params['step']) && (\count($value) - $min) % $params['step'] === 0) {
+ return false;
+ }
+ }
+
+ // If creating new values is allowed, no further checks are needed.
+ if (!empty($field['selectize']['create'])) {
+ return true;
+ }
+
+ $options = $field['options'] ?? [];
+ $use = $field['use'] ?? 'values';
+
+ if (empty($field['selectize']) || empty($field['multiple'])) {
+ $options = array_keys($options);
+ }
+ if ($use === 'keys') {
+ $value = array_keys($value);
+ }
+
+ return !($options && array_diff($value, $options));
+ }
+
+ protected static function filterArray($value, $params, $field)
+ {
+ $values = (array) $value;
+ $options = isset($field['options']) ? array_keys($field['options']) : [];
+ $multi = $field['multiple'] ?? false;
+
+ if (\count($values) === 1 && isset($values[0]) && $values[0] === '') {
+ return null;
+ }
+
+
+ if ($options) {
+ $useKey = isset($field['use']) && $field['use'] === 'keys';
+ foreach ($values as $key => $val) {
+ $values[$key] = $useKey ? (bool) $val : $val;
+ }
+ }
+
+ if ($multi) {
+ foreach ($values as $key => $val) {
+ if (\is_array($val)) {
+ $val = implode(',', $val);
+ $values[$key] = array_map('trim', explode(',', $val));
+ } else {
+ $values[$key] = trim($val);
+ }
+ }
+ }
+
+ if (isset($field['ignore_empty']) && Utils::isPositive($field['ignore_empty'])) {
+ foreach ($values as $key => $val) {
+ if ($val === '') {
+ unset($values[$key]);
+ } elseif (\is_array($val)) {
+ foreach ($val as $inner_key => $inner_value) {
+ if ($inner_value === '') {
+ unset($val[$inner_key]);
+ }
+ }
+ }
+
+ $values[$key] = $val;
+ }
+ }
+
+ return $values;
+ }
+
+ public static function typeList($value, array $params, array $field)
+ {
+ if (!\is_array($value)) {
+ return false;
+ }
+
+ if (isset($field['fields'])) {
+ foreach ($value as $key => $item) {
+ foreach ($field['fields'] as $subKey => $subField) {
+ $subKey = trim($subKey, '.');
+ $subValue = $item[$subKey] ?? null;
+ self::validate($subValue, $subField);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ protected static function filterList($value, array $params, array $field)
+ {
+ return (array) $value;
+ }
+
+ public static function filterYaml($value, $params)
+ {
+ if (!\is_string($value)) {
+ return $value;
+ }
+
+ return (array) Yaml::parse($value);
+
+ }
+
+ /**
+ * Custom input: ignore (will not validate)
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeIgnore($value, array $params, array $field)
+ {
+ return true;
+ }
+
+ public static function filterIgnore($value, array $params, array $field)
+ {
+ return $value;
+ }
+
+ /**
+ * Input value which can be ignored.
+ *
+ * @param mixed $value Value to be validated.
+ * @param array $params Validation parameters.
+ * @param array $field Blueprint for the field.
+ * @return bool True if validation succeeded.
+ */
+ public static function typeUnset($value, array $params, array $field)
+ {
+ return true;
+ }
+
+ public static function filterUnset($value, array $params, array $field)
+ {
+ return null;
+ }
+
+ // HTML5 attributes (min, max and range are handled inside the types)
+
+ public static function validateRequired($value, $params)
+ {
+ if (is_scalar($value)) {
+ return (bool) $params !== true || $value !== '';
+ }
+
+ return (bool) $params !== true || !empty($value);
+ }
+
+ public static function validatePattern($value, $params)
+ {
+ return (bool) preg_match("`^{$params}$`u", $value);
+ }
+
+
+ // Internal types
+
+ public static function validateAlpha($value, $params)
+ {
+ return ctype_alpha($value);
+ }
+
+ public static function validateAlnum($value, $params)
+ {
+ return ctype_alnum($value);
+ }
+
+ public static function typeBool($value, $params)
+ {
+ return \is_bool($value) || $value == 1 || $value == 0;
+ }
+
+ public static function validateBool($value, $params)
+ {
+ return \is_bool($value) || $value == 1 || $value == 0;
+ }
+
+ protected static function filterBool($value, $params)
+ {
+ return (bool) $value;
+ }
+
+ public static function validateDigit($value, $params)
+ {
+ return ctype_digit($value);
+ }
+
+ public static function validateFloat($value, $params)
+ {
+ return \is_float(filter_var($value, FILTER_VALIDATE_FLOAT));
+ }
+
+ protected static function filterFloat($value, $params)
+ {
+ return (float) $value;
+ }
+
+ public static function validateHex($value, $params)
+ {
+ return ctype_xdigit($value);
+ }
+
+ public static function validateInt($value, $params)
+ {
+ return is_numeric($value) && (int)$value == $value;
+ }
+
+ protected static function filterInt($value, $params)
+ {
+ return (int)$value;
+ }
+
+ public static function validateArray($value, $params)
+ {
+ return \is_array($value) || ($value instanceof \ArrayAccess && $value instanceof \Traversable && $value instanceof \Countable);
+ }
+
+ public static function filterItem_List($value, $params)
+ {
+ return array_values(array_filter($value, function($v) { return !empty($v); } ));
+ }
+
+ public static function validateJson($value, $params)
+ {
+ return (bool) (@json_decode($value));
+ }
+}
diff --git a/system/src/Grav/Common/Data/ValidationException.php b/system/src/Grav/Common/Data/ValidationException.php
new file mode 100644
index 0000000..8bdb057
--- /dev/null
+++ b/system/src/Grav/Common/Data/ValidationException.php
@@ -0,0 +1,38 @@
+messages = $messages;
+
+ $language = Grav::instance()['language'];
+ $this->message = $language->translate('GRAV.FORM.VALIDATION_FAIL', null, true) . ' ' . $this->message;
+
+ foreach ($messages as $variable => &$list) {
+ $list = array_unique($list);
+ foreach ($list as $message) {
+ $this->message .= " $message";
+ }
+ }
+
+ return $this;
+ }
+
+ public function getMessages()
+ {
+ return $this->messages;
+ }
+}
diff --git a/system/src/Grav/Common/Debugger.php b/system/src/Grav/Common/Debugger.php
new file mode 100644
index 0000000..0737209
--- /dev/null
+++ b/system/src/Grav/Common/Debugger.php
@@ -0,0 +1,606 @@
+init() gets called.
+ $this->enabled = true;
+
+ $debugbar = new DebugBar();
+ $debugbar->addCollector(new PhpInfoCollector());
+ $debugbar->addCollector(new MessagesCollector());
+ $debugbar->addCollector(new RequestDataCollector());
+ $debugbar->addCollector(new TimeDataCollector($_SERVER['REQUEST_TIME_FLOAT'] ?? GRAV_REQUEST_TIME));
+
+ $debugbar['time']->addMeasure('Server', $debugbar['time']->getRequestStartTime(), GRAV_REQUEST_TIME);
+ $debugbar['time']->addMeasure('Loading', GRAV_REQUEST_TIME, $currentTime);
+ $debugbar['time']->addMeasure('Debugger', $currentTime, microtime(true));
+
+ $this->debugbar = $debugbar;
+
+ // Set deprecation collector.
+ $this->setErrorHandler();
+ }
+
+ /**
+ * Initialize the debugger
+ *
+ * @return $this
+ * @throws \DebugBar\DebugBarException
+ */
+ public function init()
+ {
+ if ($this->initialized) {
+ return $this;
+ }
+
+ $this->grav = Grav::instance();
+ $this->config = $this->grav['config'];
+
+ // Enable/disable debugger based on configuration.
+ $this->enabled = (bool)$this->config->get('system.debugger.enabled');
+
+ if ($this->enabled()) {
+ $this->initialized = true;
+
+ $plugins_config = (array)$this->config->get('plugins');
+
+ ksort($plugins_config);
+
+ $debugbar = $this->debugbar;
+ $debugbar->addCollector(new MemoryCollector());
+ $debugbar->addCollector(new ExceptionsCollector());
+ $debugbar->addCollector(new ConfigCollector((array)$this->config->get('system'), 'Config'));
+ $debugbar->addCollector(new ConfigCollector($plugins_config, 'Plugins'));
+ $this->addMessage('Grav v' . GRAV_VERSION);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set/get the enabled state of the debugger
+ *
+ * @param bool $state If null, the method returns the enabled value. If set, the method sets the enabled state
+ *
+ * @return bool
+ */
+ public function enabled($state = null)
+ {
+ if ($state !== null) {
+ $this->enabled = (bool)$state;
+ }
+
+ return $this->enabled;
+ }
+
+ /**
+ * Add the debugger assets to the Grav Assets
+ *
+ * @return $this
+ */
+ public function addAssets()
+ {
+ if ($this->enabled()) {
+
+ // Only add assets if Page is HTML
+ $page = $this->grav['page'];
+ if ($page->templateFormat() !== 'html') {
+ return $this;
+ }
+
+ /** @var Assets $assets */
+ $assets = $this->grav['assets'];
+
+ // Add jquery library
+ $assets->add('jquery', 101);
+
+ $this->renderer = $this->debugbar->getJavascriptRenderer();
+ $this->renderer->setIncludeVendors(false);
+
+ // Get the required CSS files
+ list($css_files, $js_files) = $this->renderer->getAssets(null, JavascriptRenderer::RELATIVE_URL);
+ foreach ((array)$css_files as $css) {
+ $assets->addCss($css);
+ }
+
+ $assets->addCss('/system/assets/debugger.css');
+
+ foreach ((array)$js_files as $js) {
+ $assets->addJs($js);
+ }
+ }
+
+ return $this;
+ }
+
+ public function getCaller($limit = 2)
+ {
+ $trace = debug_backtrace(false, $limit);
+
+ return array_pop($trace);
+ }
+
+ /**
+ * Adds a data collector
+ *
+ * @param DataCollectorInterface $collector
+ *
+ * @return $this
+ * @throws \DebugBar\DebugBarException
+ */
+ public function addCollector($collector)
+ {
+ $this->debugbar->addCollector($collector);
+
+ return $this;
+ }
+
+ /**
+ * Returns a data collector
+ *
+ * @param DataCollectorInterface $collector
+ *
+ * @return DataCollectorInterface
+ * @throws \DebugBar\DebugBarException
+ */
+ public function getCollector($collector)
+ {
+ return $this->debugbar->getCollector($collector);
+ }
+
+ /**
+ * Displays the debug bar
+ *
+ * @return $this
+ */
+ public function render()
+ {
+ if ($this->enabled()) {
+ // Only add assets if Page is HTML
+ $page = $this->grav['page'];
+ if (!$this->renderer || $page->templateFormat() !== 'html') {
+ return $this;
+ }
+
+ $this->addDeprecations();
+
+ echo $this->renderer->render();
+ }
+
+ return $this;
+ }
+
+ /**
+ * Sends the data through the HTTP headers
+ *
+ * @return $this
+ */
+ public function sendDataInHeaders()
+ {
+ if ($this->enabled()) {
+ $this->addDeprecations();
+ $this->debugbar->sendDataInHeaders();
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns collected debugger data.
+ *
+ * @return array
+ */
+ public function getData()
+ {
+ if (!$this->enabled()) {
+ return null;
+ }
+
+ $this->addDeprecations();
+ $this->timers = [];
+
+ return $this->debugbar->getData();
+ }
+
+ /**
+ * Start a timer with an associated name and description
+ *
+ * @param string $name
+ * @param string|null $description
+ *
+ * @return $this
+ */
+ public function startTimer($name, $description = null)
+ {
+ if (strpos($name, '_') === 0 || $this->enabled()) {
+ $this->debugbar['time']->startMeasure($name, $description);
+ $this->timers[] = $name;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Stop the named timer
+ *
+ * @param string $name
+ *
+ * @return $this
+ */
+ public function stopTimer($name)
+ {
+ if (\in_array($name, $this->timers, true) && (strpos($name, '_') === 0 || $this->enabled())) {
+ $this->debugbar['time']->stopMeasure($name);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Dump variables into the Messages tab of the Debug Bar
+ *
+ * @param mixed $message
+ * @param string $label
+ * @param bool $isString
+ *
+ * @return $this
+ */
+ public function addMessage($message, $label = 'info', $isString = true)
+ {
+ if ($this->enabled()) {
+ $this->debugbar['messages']->addMessage($message, $label, $isString);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Dump exception into the Messages tab of the Debug Bar
+ *
+ * @param \Exception $e
+ * @return Debugger
+ */
+ public function addException(\Exception $e)
+ {
+ if ($this->initialized && $this->enabled()) {
+ $this->debugbar['exceptions']->addException($e);
+ }
+
+ return $this;
+ }
+
+ public function setErrorHandler()
+ {
+ $this->errorHandler = set_error_handler(
+ [$this, 'deprecatedErrorHandler']
+ );
+ }
+
+ /**
+ * @param int $errno
+ * @param string $errstr
+ * @param string $errfile
+ * @param int $errline
+ * @return bool
+ */
+ public function deprecatedErrorHandler($errno, $errstr, $errfile, $errline)
+ {
+ if ($errno !== E_USER_DEPRECATED && $errno !== E_DEPRECATED) {
+ if ($this->errorHandler) {
+ return \call_user_func($this->errorHandler, $errno, $errstr, $errfile, $errline);
+ }
+
+ return true;
+ }
+
+ if (!$this->enabled()) {
+ return true;
+ }
+
+ // Figure out error scope from the error.
+ $scope = 'unknown';
+ if (stripos($errstr, 'grav') !== false) {
+ $scope = 'grav';
+ } elseif (strpos($errfile, '/twig/') !== false) {
+ $scope = 'twig';
+ } elseif (stripos($errfile, '/yaml/') !== false) {
+ $scope = 'yaml';
+ } elseif (strpos($errfile, '/vendor/') !== false) {
+ $scope = 'vendor';
+ }
+
+ // Clean up backtrace to make it more useful.
+ $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
+
+ // Skip current call.
+ array_shift($backtrace);
+
+ // Find yaml file where the error happened.
+ if ($scope === 'yaml') {
+ foreach ($backtrace as $current) {
+ if (isset($current['args'])) {
+ foreach ($current['args'] as $arg) {
+ if ($arg instanceof \SplFileInfo) {
+ $arg = $arg->getPathname();
+ }
+ if (\is_string($arg) && preg_match('/.+\.(yaml|md)$/i', $arg)) {
+ $errfile = $arg;
+ $errline = 0;
+
+ break 2;
+ }
+ }
+ }
+ }
+ }
+
+ // Filter arguments.
+ $cut = 0;
+ $previous = null;
+ foreach ($backtrace as $i => &$current) {
+ if (isset($current['args'])) {
+ $args = [];
+ foreach ($current['args'] as $arg) {
+ if (\is_string($arg)) {
+ $arg = "'" . $arg . "'";
+ if (mb_strlen($arg) > 100) {
+ $arg = 'string';
+ }
+ } elseif (\is_bool($arg)) {
+ $arg = $arg ? 'true' : 'false';
+ } elseif (\is_scalar($arg)) {
+ $arg = $arg;
+ } elseif (\is_object($arg)) {
+ $arg = get_class($arg) . ' $object';
+ } elseif (\is_array($arg)) {
+ $arg = '$array';
+ } else {
+ $arg = '$object';
+ }
+
+ $args[] = $arg;
+ }
+ $current['args'] = $args;
+ }
+
+ $object = $current['object'] ?? null;
+ unset($current['object']);
+
+ $reflection = null;
+ if ($object instanceof TemplateWrapper) {
+ $reflection = new \ReflectionObject($object);
+ $property = $reflection->getProperty('template');
+ $property->setAccessible(true);
+ $object = $property->getValue($object);
+ }
+
+ if ($object instanceof Template) {
+ $file = $current['file'] ?? null;
+
+ if (preg_match('`(Template.php|TemplateWrapper.php)$`', $file)) {
+ $current = null;
+ continue;
+ }
+
+ $debugInfo = $object->getDebugInfo();
+
+ $line = 1;
+ if (!$reflection) {
+ foreach ($debugInfo as $codeLine => $templateLine) {
+ if ($codeLine <= $current['line']) {
+ $line = $templateLine;
+ break;
+ }
+ }
+ }
+
+ $src = $object->getSourceContext();
+ //$code = preg_split('/\r\n|\r|\n/', $src->getCode());
+ //$current['twig']['twig'] = trim($code[$line - 1]);
+ $current['twig']['file'] = $src->getPath();
+ $current['twig']['line'] = $line;
+
+ $prevFile = $previous['file'] ?? null;
+ if ($prevFile && $file === $prevFile) {
+ $prevLine = $previous['line'];
+
+ $line = 1;
+ foreach ($debugInfo as $codeLine => $templateLine) {
+ if ($codeLine <= $prevLine) {
+ $line = $templateLine;
+ break;
+ }
+ }
+
+ //$previous['twig']['twig'] = trim($code[$line - 1]);
+ $previous['twig']['file'] = $src->getPath();
+ $previous['twig']['line'] = $line;
+ }
+
+ $cut = $i;
+ } elseif ($object instanceof ProcessorInterface) {
+ $cut = $cut ?: $i;
+ break;
+ }
+
+ $previous = &$backtrace[$i];
+ }
+ unset($current);
+
+ if ($cut) {
+ $backtrace = array_slice($backtrace, 0, $cut + 1);
+ }
+ $backtrace = array_values(array_filter($backtrace));
+
+ // Skip vendor libraries and the method where error was triggered.
+ foreach ($backtrace as $i => $current) {
+ if (!isset($current['file'])) {
+ continue;
+ }
+ if (strpos($current['file'], '/vendor/') !== false) {
+ $cut = $i + 1;
+ continue;
+ }
+ if (isset($current['function']) && ($current['function'] === 'user_error' || $current['function'] === 'trigger_error')) {
+ $cut = $i + 1;
+ continue;
+ }
+
+ break;
+ }
+
+ if ($cut) {
+ $backtrace = array_slice($backtrace, $cut);
+ }
+ $backtrace = array_values(array_filter($backtrace));
+
+ $current = reset($backtrace);
+
+ // If the issue happened inside twig file, change the file and line to match that file.
+ $file = $current['twig']['file'] ?? '';
+ if ($file) {
+ $errfile = $file;
+ $errline = $current['twig']['line'] ?? 0;
+ }
+
+ $deprecation = [
+ 'scope' => $scope,
+ 'message' => $errstr,
+ 'file' => $errfile,
+ 'line' => $errline,
+ 'trace' => $backtrace,
+ 'count' => 1
+ ];
+
+ $this->deprecations[] = $deprecation;
+
+ // Do not pass forward.
+ return true;
+ }
+
+ protected function addDeprecations()
+ {
+ if (!$this->deprecations) {
+ return;
+ }
+
+ $collector = new MessagesCollector('deprecated');
+ $this->addCollector($collector);
+ $collector->addMessage('Your site is using following deprecated features:');
+
+ /** @var array $deprecated */
+ foreach ($this->deprecations as $deprecated) {
+ list($message, $scope) = $this->getDepracatedMessage($deprecated);
+
+ $collector->addMessage($message, $scope);
+ }
+ }
+
+ protected function getDepracatedMessage($deprecated)
+ {
+ $scope = $deprecated['scope'];
+
+ $trace = [];
+ if (isset($deprecated['trace'])) {
+ foreach ($deprecated['trace'] as $current) {
+ $class = $current['class'] ?? '';
+ $type = $current['type'] ?? '';
+ $function = $this->getFunction($current);
+ if (isset($current['file'])) {
+ $current['file'] = str_replace(GRAV_ROOT . '/', '', $current['file']);
+ }
+
+ unset($current['class'], $current['type'], $current['function'], $current['args']);
+
+ if (isset($current['twig'])) {
+ $trace[] = $current['twig'];
+ } else {
+ $trace[] = ['call' => $class . $type . $function] + $current;
+ }
+ }
+ }
+
+ $array = [
+ 'message' => $deprecated['message'],
+ 'file' => $deprecated['file'],
+ 'line' => $deprecated['line'],
+ 'trace' => $trace
+ ];
+
+ return [
+ array_filter($array),
+ $scope
+ ];
+ }
+
+ protected function getFunction($trace)
+ {
+ if (!isset($trace['function'])) {
+ return '';
+ }
+
+ return $trace['function'] . '(' . implode(', ', $trace['args'] ?? []) . ')';
+ }
+}
diff --git a/system/src/Grav/Common/Errors/BareHandler.php b/system/src/Grav/Common/Errors/BareHandler.php
new file mode 100644
index 0000000..52effc6
--- /dev/null
+++ b/system/src/Grav/Common/Errors/BareHandler.php
@@ -0,0 +1,32 @@
+getInspector();
+ $code = $inspector->getException()->getCode();
+ if ( ($code >= 400) && ($code < 600) )
+ {
+ $this->getRun()->sendHttpCode($code);
+ }
+
+ return Handler::QUIT;
+ }
+
+}
diff --git a/system/src/Grav/Common/Errors/Errors.php b/system/src/Grav/Common/Errors/Errors.php
new file mode 100644
index 0000000..dbc955e
--- /dev/null
+++ b/system/src/Grav/Common/Errors/Errors.php
@@ -0,0 +1,73 @@
+get('system.errors');
+ $jsonRequest = $_SERVER && isset($_SERVER['HTTP_ACCEPT']) && $_SERVER['HTTP_ACCEPT'] === 'application/json';
+
+ // Setup Whoops-based error handler
+ $system = new SystemFacade;
+ $whoops = new Whoops\Run($system);
+
+ $verbosity = 1;
+
+ if (isset($config['display'])) {
+ if (is_int($config['display'])) {
+ $verbosity = $config['display'];
+ } else {
+ $verbosity = $config['display'] ? 1 : 0;
+ }
+ }
+
+ switch ($verbosity) {
+ case 1:
+ $error_page = new Whoops\Handler\PrettyPageHandler;
+ $error_page->setPageTitle('Crikey! There was an error...');
+ $error_page->addResourcePath(GRAV_ROOT . '/system/assets');
+ $error_page->addCustomCss('whoops.css');
+ $whoops->pushHandler($error_page);
+ break;
+ case -1:
+ $whoops->pushHandler(new BareHandler);
+ break;
+ default:
+ $whoops->pushHandler(new SimplePageHandler);
+ break;
+ }
+
+ if (Whoops\Util\Misc::isAjaxRequest() || $jsonRequest) {
+ $whoops->pushHandler(new Whoops\Handler\JsonResponseHandler);
+ }
+
+ if (isset($config['log']) && $config['log']) {
+ $logger = $grav['log'];
+ $whoops->pushHandler(function($exception, $inspector, $run) use ($logger) {
+ try {
+ $logger->addCritical($exception->getMessage() . ' - Trace: ' . $exception->getTraceAsString());
+ } catch (\Exception $e) {
+ echo $e;
+ }
+ });
+ }
+
+ $whoops->register();
+
+ // Re-register deprecation handler.
+ $grav['debugger']->setErrorHandler();
+ }
+}
diff --git a/system/src/Grav/Common/Errors/Resources/error.css b/system/src/Grav/Common/Errors/Resources/error.css
new file mode 100644
index 0000000..11ce3fd
--- /dev/null
+++ b/system/src/Grav/Common/Errors/Resources/error.css
@@ -0,0 +1,52 @@
+html, body {
+ height: 100%
+}
+body {
+ margin:0 3rem;
+ padding:0;
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 1.5rem;
+ line-height: 1.4;
+ display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
+ display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
+ display: -ms-flexbox; /* TWEENER - IE 10 */
+ display: -webkit-flex; /* NEW - Chrome */
+ display: flex;
+ -webkit-align-items: center;
+ align-items: center;
+ -webkit-justify-content: center;
+ justify-content: center;
+}
+.container {
+ margin: 0rem;
+ max-width: 600px;
+ padding-bottom:5rem;
+}
+
+header {
+ color: #000;
+ font-size: 4rem;
+ letter-spacing: 2px;
+ line-height: 1.1;
+ margin-bottom: 2rem;
+}
+p {
+ font-family: Optima, Segoe, "Segoe UI", Candara, Calibri, Arial, sans-serif;
+ color: #666;
+}
+
+h5 {
+ font-weight: normal;
+ color: #999;
+ font-size: 1rem;
+}
+
+h6 {
+ font-weight: normal;
+ color: #999;
+}
+
+code {
+ font-weight: bold;
+ font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
+}
diff --git a/system/src/Grav/Common/Errors/Resources/layout.html.php b/system/src/Grav/Common/Errors/Resources/layout.html.php
new file mode 100644
index 0000000..6699959
--- /dev/null
+++ b/system/src/Grav/Common/Errors/Resources/layout.html.php
@@ -0,0 +1,30 @@
+
+
+
+
+
+ Whoops there was an error!
+
+
+
+
+
+
+
+
+
+
Sorry, something went terribly wrong!
+
+
-
+
+
For further details please review your logs/ folder, or enable displaying of errors in your system configuration.
+
+
+
+
diff --git a/system/src/Grav/Common/Errors/SimplePageHandler.php b/system/src/Grav/Common/Errors/SimplePageHandler.php
new file mode 100644
index 0000000..311d722
--- /dev/null
+++ b/system/src/Grav/Common/Errors/SimplePageHandler.php
@@ -0,0 +1,108 @@
+searchPaths[] = __DIR__ . '/Resources';
+ }
+
+ /**
+ * @return int|null
+ */
+ public function handle()
+ {
+ $inspector = $this->getInspector();
+
+ $helper = new TemplateHelper();
+ $templateFile = $this->getResource('layout.html.php');
+ $cssFile = $this->getResource('error.css');
+
+ $code = $inspector->getException()->getCode();
+ if ( ($code >= 400) && ($code < 600) )
+ {
+ $this->getRun()->sendHttpCode($code);
+ }
+ $message = $inspector->getException()->getMessage();
+
+ if ($inspector->getException() instanceof \ErrorException) {
+ $code = Misc::translateErrorCode($code);
+ }
+
+ $vars = array(
+ 'stylesheet' => file_get_contents($cssFile),
+ 'code' => $code,
+ 'message' => filter_var(rawurldecode($message), FILTER_SANITIZE_STRING),
+ );
+
+ $helper->setVariables($vars);
+ $helper->render($templateFile);
+
+ return Handler::QUIT;
+ }
+
+ /**
+ * @param string $resource
+ *
+ * @return string
+ * @throws \RuntimeException
+ */
+ protected function getResource($resource)
+ {
+ // If the resource was found before, we can speed things up
+ // by caching its absolute, resolved path:
+ if (isset($this->resourceCache[$resource])) {
+ return $this->resourceCache[$resource];
+ }
+
+ // Search through available search paths, until we find the
+ // resource we're after:
+ foreach ($this->searchPaths as $path) {
+ $fullPath = "{$path}/{$resource}";
+
+ if (is_file($fullPath)) {
+ // Cache the result:
+ $this->resourceCache[$resource] = $fullPath;
+ return $fullPath;
+ }
+ }
+
+ // If we got this far, nothing was found.
+ throw new \RuntimeException(
+ "Could not find resource '{$resource}' in any resource paths (searched: " . implode(', ', $this->searchPaths). ')'
+ );
+ }
+
+ public function addResourcePath($path)
+ {
+ if (!is_dir($path)) {
+ throw new \InvalidArgumentException(
+ "'{$path}' is not a valid directory"
+ );
+ }
+
+ array_unshift($this->searchPaths, $path);
+ }
+
+ public function getResourcePaths()
+ {
+ return $this->searchPaths;
+ }
+}
diff --git a/system/src/Grav/Common/Errors/SystemFacade.php b/system/src/Grav/Common/Errors/SystemFacade.php
new file mode 100644
index 0000000..02ef0cf
--- /dev/null
+++ b/system/src/Grav/Common/Errors/SystemFacade.php
@@ -0,0 +1,40 @@
+whoopsShutdownHandler = $function;
+ register_shutdown_function([$this, 'handleShutdown']);
+ }
+
+ /**
+ * Special case to deal with Fatal errors and the like.
+ */
+ public function handleShutdown()
+ {
+ $error = $this->getLastError();
+
+ // Ignore core warnings and errors.
+ if ($error && !($error['type'] & (E_CORE_WARNING | E_CORE_ERROR))) {
+ $handler = $this->whoopsShutdownHandler;
+ $handler();
+ }
+ }
+}
diff --git a/system/src/Grav/Common/File/CompiledFile.php b/system/src/Grav/Common/File/CompiledFile.php
new file mode 100644
index 0000000..f4b1e8d
--- /dev/null
+++ b/system/src/Grav/Common/File/CompiledFile.php
@@ -0,0 +1,110 @@
+raw === null && $this->content === null) {
+ $key = md5($this->filename);
+ $file = PhpFile::instance(CACHE_DIR . "compiled/files/{$key}{$this->extension}.php");
+
+ $modified = $this->modified();
+
+ if (!$modified) {
+ return $this->decode($this->raw());
+ }
+
+ $class = get_class($this);
+
+ $cache = $file->exists() ? $file->content() : null;
+
+ // Load real file if cache isn't up to date (or is invalid).
+ if (
+ !isset($cache['@class'])
+ || $cache['@class'] !== $class
+ || $cache['modified'] !== $modified
+ || $cache['filename'] !== $this->filename
+ ) {
+ // Attempt to lock the file for writing.
+ try {
+ $file->lock(false);
+ } catch (\Exception $e) {
+ // Another process has locked the file; we will check this in a bit.
+ }
+
+ // Decode RAW file into compiled array.
+ $data = (array)$this->decode($this->raw());
+ $cache = [
+ '@class' => $class,
+ 'filename' => $this->filename,
+ 'modified' => $modified,
+ 'data' => $data
+ ];
+
+ // If compiled file wasn't already locked by another process, save it.
+ if ($file->locked() !== false) {
+ $file->save($cache);
+ $file->unlock();
+
+ // Compile cached file into bytecode cache
+ if (function_exists('opcache_invalidate')) {
+ // Silence error if function exists, but is restricted.
+ @opcache_invalidate($file->filename(), true);
+ }
+ }
+ }
+ $file->free();
+
+ $this->content = $cache['data'];
+ }
+
+ } catch (\Exception $e) {
+ throw new \RuntimeException(sprintf('Failed to read %s: %s', basename($this->filename), $e->getMessage()), 500, $e);
+ }
+
+ return parent::content($var);
+ }
+
+ /**
+ * Serialize file.
+ */
+ public function __sleep()
+ {
+ return [
+ 'filename',
+ 'extension',
+ 'raw',
+ 'content',
+ 'settings'
+ ];
+ }
+
+ /**
+ * Unserialize file.
+ */
+ public function __wakeup()
+ {
+ if (!isset(static::$instances[$this->filename])) {
+ static::$instances[$this->filename] = $this;
+ }
+ }
+}
diff --git a/system/src/Grav/Common/File/CompiledJsonFile.php b/system/src/Grav/Common/File/CompiledJsonFile.php
new file mode 100644
index 0000000..d73e817
--- /dev/null
+++ b/system/src/Grav/Common/File/CompiledJsonFile.php
@@ -0,0 +1,29 @@
+ ['.DS_Store'],
+ 'exclude_paths' => []
+ ];
+
+ protected $archive_file;
+
+ public static function create($compression)
+ {
+ if ($compression === 'zip') {
+ return new ZipArchiver();
+ }
+
+ return new ZipArchiver();
+ }
+
+ public function setArchive($archive_file)
+ {
+ $this->archive_file = $archive_file;
+ return $this;
+ }
+
+ public function setOptions($options)
+ {
+ // Set infinite PHP execution time if possible.
+ if (function_exists('set_time_limit') && !Utils::isFunctionDisabled('set_time_limit')) {
+ set_time_limit(0);
+ }
+
+ $this->options = $options + $this->options;
+ return $this;
+ }
+
+ public abstract function compress($folder, callable $status = null);
+
+ public abstract function extract($destination, callable $status = null);
+
+ public abstract function addEmptyFolders($folders, callable $status = null);
+
+ protected function getArchiveFiles($rootPath)
+ {
+ $exclude_paths = $this->options['exclude_paths'];
+ $exclude_files = $this->options['exclude_files'];
+ $dirItr = new \RecursiveDirectoryIterator($rootPath, \RecursiveDirectoryIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS | \FilesystemIterator::UNIX_PATHS);
+ $filterItr = new RecursiveDirectoryFilterIterator($dirItr, $rootPath, $exclude_paths, $exclude_files);
+ $files = new \RecursiveIteratorIterator($filterItr, \RecursiveIteratorIterator::SELF_FIRST);
+
+ return $files;
+ }
+
+}
diff --git a/system/src/Grav/Common/Filesystem/Folder.php b/system/src/Grav/Common/Filesystem/Folder.php
new file mode 100644
index 0000000..781c9d3
--- /dev/null
+++ b/system/src/Grav/Common/Filesystem/Folder.php
@@ -0,0 +1,526 @@
+isStream($path)) {
+ $directory = $locator->getRecursiveIterator($path, $flags);
+ } else {
+ $directory = new \RecursiveDirectoryIterator($path, $flags);
+ }
+ $filter = new RecursiveFolderFilterIterator($directory);
+ $iterator = new \RecursiveIteratorIterator($filter, \RecursiveIteratorIterator::SELF_FIRST);
+
+ /** @var \RecursiveDirectoryIterator $file */
+ foreach ($iterator as $dir) {
+ $dir_modified = $dir->getMTime();
+ if ($dir_modified > $last_modified) {
+ $last_modified = $dir_modified;
+ }
+ }
+
+ return $last_modified;
+ }
+
+ /**
+ * Recursively find the last modified time under given path by file.
+ *
+ * @param string $path
+ * @param string $extensions which files to search for specifically
+ *
+ * @return int
+ */
+ public static function lastModifiedFile($path, $extensions = 'md|yaml')
+ {
+ if (!file_exists($path)) {
+ return 0;
+ }
+
+ $last_modified = 0;
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
+ if ($locator->isStream($path)) {
+ $directory = $locator->getRecursiveIterator($path, $flags);
+ } else {
+ $directory = new \RecursiveDirectoryIterator($path, $flags);
+ }
+ $recursive = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);
+ $iterator = new \RegexIterator($recursive, '/^.+\.'.$extensions.'$/i');
+
+ /** @var \RecursiveDirectoryIterator $file */
+ foreach ($iterator as $filepath => $file) {
+ try {
+ $file_modified = $file->getMTime();
+ if ($file_modified > $last_modified) {
+ $last_modified = $file_modified;
+ }
+ } catch (\Exception $e) {
+ Grav::instance()['log']->error('Could not process file: ' . $e->getMessage());
+ }
+ }
+
+ return $last_modified;
+ }
+
+ /**
+ * Recursively md5 hash all files in a path
+ *
+ * @param string $path
+ * @return string
+ */
+ public static function hashAllFiles($path)
+ {
+ $files = [];
+
+ if (file_exists($path)) {
+ $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ if ($locator->isStream($path)) {
+ $directory = $locator->getRecursiveIterator($path, $flags);
+ } else {
+ $directory = new \RecursiveDirectoryIterator($path, $flags);
+ }
+
+ $iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);
+
+ foreach ($iterator as $file) {
+ $files[] = $file->getPathname() . '?'. $file->getMTime();
+ }
+ }
+
+ return md5(serialize($files));
+ }
+
+ /**
+ * Get relative path between target and base path. If path isn't relative, return full path.
+ *
+ * @param string $path
+ * @param mixed|string $base
+ *
+ * @return string
+ */
+ public static function getRelativePath($path, $base = GRAV_ROOT)
+ {
+ if ($base) {
+ $base = preg_replace('![\\\/]+!', '/', $base);
+ $path = preg_replace('![\\\/]+!', '/', $path);
+ if (strpos($path, $base) === 0) {
+ $path = ltrim(substr($path, strlen($base)), '/');
+ }
+ }
+
+ return $path;
+ }
+
+ /**
+ * Get relative path between target and base path. If path isn't relative, return full path.
+ *
+ * @param string $path
+ * @param string $base
+ * @return string
+ */
+ public static function getRelativePathDotDot($path, $base)
+ {
+ // Normalize paths.
+ $base = preg_replace('![\\\/]+!', '/', $base);
+ $path = preg_replace('![\\\/]+!', '/', $path);
+
+ if ($path === $base) {
+ return '';
+ }
+
+ $baseParts = explode('/', ltrim($base, '/'));
+ $pathParts = explode('/', ltrim($path, '/'));
+
+ array_pop($baseParts);
+ $lastPart = array_pop($pathParts);
+ foreach ($baseParts as $i => $directory) {
+ if (isset($pathParts[$i]) && $pathParts[$i] === $directory) {
+ unset($baseParts[$i], $pathParts[$i]);
+ } else {
+ break;
+ }
+ }
+ $pathParts[] = $lastPart;
+ $path = str_repeat('../', count($baseParts)) . implode('/', $pathParts);
+
+ return '' === $path
+ || strpos($path, '/') === 0
+ || false !== ($colonPos = strpos($path, ':')) && ($colonPos < ($slashPos = strpos($path, '/')) || false === $slashPos)
+ ? "./$path" : $path;
+ }
+
+ /**
+ * Shift first directory out of the path.
+ *
+ * @param string $path
+ * @return string
+ */
+ public static function shift(&$path)
+ {
+ $parts = explode('/', trim($path, '/'), 2);
+ $result = array_shift($parts);
+ $path = array_shift($parts);
+
+ return $result ?: null;
+ }
+
+ /**
+ * Return recursive list of all files and directories under given path.
+ *
+ * @param string $path
+ * @param array $params
+ * @return array
+ * @throws \RuntimeException
+ */
+ public static function all($path, array $params = [])
+ {
+ if ($path === false) {
+ throw new \RuntimeException("Path doesn't exist.");
+ }
+ if (!file_exists($path)) {
+ return [];
+ }
+
+ $compare = isset($params['compare']) ? 'get' . $params['compare'] : null;
+ $pattern = $params['pattern'] ?? null;
+ $filters = $params['filters'] ?? null;
+ $recursive = $params['recursive'] ?? true;
+ $levels = $params['levels'] ?? -1;
+ $key = isset($params['key']) ? 'get' . $params['key'] : null;
+ $value = 'get' . ($params['value'] ?? ($recursive ? 'SubPathname' : 'Filename'));
+ $folders = $params['folders'] ?? true;
+ $files = $params['files'] ?? true;
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ if ($recursive) {
+ $flags = \RecursiveDirectoryIterator::SKIP_DOTS + \FilesystemIterator::UNIX_PATHS
+ + \FilesystemIterator::CURRENT_AS_SELF + \FilesystemIterator::FOLLOW_SYMLINKS;
+ if ($locator->isStream($path)) {
+ $directory = $locator->getRecursiveIterator($path, $flags);
+ } else {
+ $directory = new \RecursiveDirectoryIterator($path, $flags);
+ }
+ $iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);
+ $iterator->setMaxDepth(max($levels, -1));
+ } else {
+ if ($locator->isStream($path)) {
+ $iterator = $locator->getIterator($path);
+ } else {
+ $iterator = new \FilesystemIterator($path);
+ }
+ }
+
+ $results = [];
+
+ /** @var \RecursiveDirectoryIterator $file */
+ foreach ($iterator as $file) {
+ // Ignore hidden files.
+ if (strpos($file->getFilename(), '.') === 0 && $file->isFile()) {
+ continue;
+ }
+ if (!$folders && $file->isDir()) {
+ continue;
+ }
+ if (!$files && $file->isFile()) {
+ continue;
+ }
+ if ($compare && $pattern && !preg_match($pattern, $file->{$compare}())) {
+ continue;
+ }
+ $fileKey = $key ? $file->{$key}() : null;
+ $filePath = $file->{$value}();
+ if ($filters) {
+ if (isset($filters['key'])) {
+ $pre = !empty($filters['pre-key']) ? $filters['pre-key'] : '';
+ $fileKey = $pre . preg_replace($filters['key'], '', $fileKey);
+ }
+ if (isset($filters['value'])) {
+ $filter = $filters['value'];
+ if (is_callable($filter)) {
+ $filePath = $filter($file);
+ } else {
+ $filePath = preg_replace($filter, '', $filePath);
+ }
+ }
+ }
+
+ if ($fileKey !== null) {
+ $results[$fileKey] = $filePath;
+ } else {
+ $results[] = $filePath;
+ }
+ }
+
+ return $results;
+ }
+
+ /**
+ * Recursively copy directory in filesystem.
+ *
+ * @param string $source
+ * @param string $target
+ * @param string $ignore Ignore files matching pattern (regular expression).
+ * @throws \RuntimeException
+ */
+ public static function copy($source, $target, $ignore = null)
+ {
+ $source = rtrim($source, '\\/');
+ $target = rtrim($target, '\\/');
+
+ if (!is_dir($source)) {
+ throw new \RuntimeException('Cannot copy non-existing folder.');
+ }
+
+ // Make sure that path to the target exists before copying.
+ self::create($target);
+
+ $success = true;
+
+ // Go through all sub-directories and copy everything.
+ $files = self::all($source);
+ foreach ($files as $file) {
+ if ($ignore && preg_match($ignore, $file)) {
+ continue;
+ }
+ $src = $source .'/'. $file;
+ $dst = $target .'/'. $file;
+
+ if (is_dir($src)) {
+ // Create current directory (if it doesn't exist).
+ if (!is_dir($dst)) {
+ $success &= @mkdir($dst, 0777, true);
+ }
+ } else {
+ // Or copy current file.
+ $success &= @copy($src, $dst);
+ }
+ }
+
+ if (!$success) {
+ $error = error_get_last();
+ throw new \RuntimeException($error['message'] ?? 'Unknown error');
+ }
+
+ // Make sure that the change will be detected when caching.
+ @touch(dirname($target));
+ }
+
+ /**
+ * Move directory in filesystem.
+ *
+ * @param string $source
+ * @param string $target
+ * @throws \RuntimeException
+ */
+ public static function move($source, $target)
+ {
+ if (!file_exists($source) || !is_dir($source)) {
+ // Rename fails if source folder does not exist.
+ throw new \RuntimeException('Cannot move non-existing folder.');
+ }
+
+ // Don't do anything if the source is the same as the new target
+ if ($source === $target) {
+ return;
+ }
+
+ if (file_exists($target)) {
+ // Rename fails if target folder exists.
+ throw new \RuntimeException('Cannot move files to existing folder/file.');
+ }
+
+ // Make sure that path to the target exists before moving.
+ self::create(dirname($target));
+
+ // Silence warnings (chmod failed etc).
+ @rename($source, $target);
+
+ // Rename function can fail while still succeeding, so let's check if the folder exists.
+ if (!file_exists($target) || !is_dir($target)) {
+ // In some rare cases rename() creates file, not a folder. Get rid of it.
+ if (file_exists($target)) {
+ @unlink($target);
+ }
+ // Rename doesn't support moving folders across filesystems. Use copy instead.
+ self::copy($source, $target);
+ self::delete($source);
+ }
+
+ // Make sure that the change will be detected when caching.
+ @touch(dirname($source));
+ @touch(dirname($target));
+ @touch($target);
+ }
+
+ /**
+ * Recursively delete directory from filesystem.
+ *
+ * @param string $target
+ * @param bool $include_target
+ * @return bool
+ * @throws \RuntimeException
+ */
+ public static function delete($target, $include_target = true)
+ {
+ if (!is_dir($target)) {
+ return false;
+ }
+
+ $success = self::doDelete($target, $include_target);
+
+ if (!$success) {
+ $error = error_get_last();
+ throw new \RuntimeException($error['message']);
+ }
+
+ // Make sure that the change will be detected when caching.
+ if ($include_target) {
+ @touch(dirname($target));
+ } else {
+ @touch($target);
+ }
+
+ return $success;
+ }
+
+ /**
+ * @param string $folder
+ * @throws \RuntimeException
+ */
+ public static function mkdir($folder)
+ {
+ self::create($folder);
+ }
+
+ /**
+ * @param string $folder
+ * @throws \RuntimeException
+ */
+ public static function create($folder)
+ {
+ // Silence error for open_basedir; should fail in mkdir instead.
+ if (@is_dir($folder)) {
+ return;
+ }
+
+ $success = @mkdir($folder, 0777, true);
+
+ if (!$success) {
+ // Take yet another look, make sure that the folder doesn't exist.
+ clearstatcache(true, $folder);
+ if (!@is_dir($folder)) {
+ throw new \RuntimeException(sprintf('Unable to create directory: %s', $folder));
+ }
+ }
+ }
+
+ /**
+ * Recursive copy of one directory to another
+ *
+ * @param string $src
+ * @param string $dest
+ *
+ * @return bool
+ * @throws \RuntimeException
+ */
+ public static function rcopy($src, $dest)
+ {
+
+ // If the src is not a directory do a simple file copy
+ if (!is_dir($src)) {
+ copy($src, $dest);
+ return true;
+ }
+
+ // If the destination directory does not exist create it
+ if (!is_dir($dest)) {
+ static::create($dest);
+ }
+
+ // Open the source directory to read in files
+ $i = new \DirectoryIterator($src);
+ /** @var \DirectoryIterator $f */
+ foreach ($i as $f) {
+ if ($f->isFile()) {
+ copy($f->getRealPath(), "{$dest}/" . $f->getFilename());
+ } else {
+ if (!$f->isDot() && $f->isDir()) {
+ static::rcopy($f->getRealPath(), "{$dest}/{$f}");
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @param string $folder
+ * @param bool $include_target
+ * @return bool
+ * @internal
+ */
+ protected static function doDelete($folder, $include_target = true)
+ {
+ // Special case for symbolic links.
+ if ($include_target && is_link($folder)) {
+ return @unlink($folder);
+ }
+
+ // Go through all items in filesystem and recursively remove everything.
+ $files = array_diff(scandir($folder, SCANDIR_SORT_NONE), array('.', '..'));
+ foreach ($files as $file) {
+ $path = "{$folder}/{$file}";
+ is_dir($path) ? self::doDelete($path) : @unlink($path);
+ }
+
+ return $include_target ? @rmdir($folder) : true;
+ }
+
+ /**
+ * Does a directory contain children
+ *
+ * @param string $directory
+ * @return int|false
+ */
+ public static function countChildren($directory) {
+ if (!is_dir($directory)) {
+ return false;
+ }
+ $directories = glob($directory . '/*', GLOB_ONLYDIR);
+
+ return count($directories);
+ }
+}
diff --git a/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php b/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php
new file mode 100644
index 0000000..c662fc4
--- /dev/null
+++ b/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php
@@ -0,0 +1,67 @@
+current();
+ $filename = $file->getFilename();
+ $relative_filename = str_replace($this::$root . '/', '', $file->getPathname());
+
+ if ($file->isDir()) {
+ if (in_array($relative_filename, $this::$ignore_folders, true)) {
+ return false;
+ }
+ if (!in_array($filename, $this::$ignore_files, true)) {
+ return true;
+ }
+ } elseif ($file->isFile() && !in_array($filename, $this::$ignore_files, true)) {
+ return true;
+ }
+ return false;
+ }
+
+ public function getChildren()
+ {
+ /** @var RecursiveDirectoryFilterIterator $iterator */
+ $iterator = $this->getInnerIterator();
+
+ return new self($iterator->getChildren(), $this::$root, $this::$ignore_folders, $this::$ignore_files);
+ }
+}
diff --git a/system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php b/system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php
new file mode 100644
index 0000000..eb493db
--- /dev/null
+++ b/system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php
@@ -0,0 +1,47 @@
+get('system.pages.ignore_folders');
+ }
+
+ $this::$ignore_folders = $ignore_folders;
+ }
+
+ /**
+ * Check whether the current element of the iterator is acceptable
+ *
+ * @return bool true if the current element is acceptable, otherwise false.
+ */
+ public function accept()
+ {
+ /** @var \SplFileInfo $current */
+ $current = $this->current();
+
+ return $current->isDir() && !in_array($current->getFilename(), $this::$ignore_folders, true);
+ }
+}
diff --git a/system/src/Grav/Common/Filesystem/ZipArchiver.php b/system/src/Grav/Common/Filesystem/ZipArchiver.php
new file mode 100644
index 0000000..91212f7
--- /dev/null
+++ b/system/src/Grav/Common/Filesystem/ZipArchiver.php
@@ -0,0 +1,111 @@
+open($this->archive_file);
+
+ if ($archive === true) {
+ Folder::create($destination);
+
+ if (!$zip->extractTo($destination)) {
+ throw new \RuntimeException('ZipArchiver: ZIP failed to extract ' . $this->archive_file . ' to ' . $destination);
+ }
+
+ $zip->close();
+ return $this;
+ }
+
+ throw new \RuntimeException('ZipArchiver: Failed to open ' . $this->archive_file);
+ }
+
+ public function compress($source, callable $status = null)
+ {
+ if (!extension_loaded('zip')) {
+ throw new \InvalidArgumentException('ZipArchiver: Zip PHP module not installed...');
+ }
+
+ if (!file_exists($source)) {
+ throw new \InvalidArgumentException('ZipArchiver: ' . $source . ' cannot be found...');
+ }
+
+ $zip = new \ZipArchive();
+ if (!$zip->open($this->archive_file, \ZipArchive::CREATE)) {
+ throw new \InvalidArgumentException('ZipArchiver:' . $this->archive_file . ' cannot be created...');
+ }
+
+ // Get real path for our folder
+ $rootPath = realpath($source);
+
+ $files = $this->getArchiveFiles($rootPath);
+
+ $status && $status([
+ 'type' => 'count',
+ 'steps' => iterator_count($files),
+ ]);
+
+ foreach ($files as $file) {
+ $filePath = $file->getPathname();
+ $relativePath = ltrim(substr($filePath, strlen($rootPath)), '/');
+
+ if ($file->isDir()) {
+ $zip->addEmptyDir($relativePath);
+ } else {
+ $zip->addFile($filePath, $relativePath);
+ }
+
+ $status && $status([
+ 'type' => 'progress',
+ ]);
+ }
+
+ $status && $status([
+ 'type' => 'message',
+ 'message' => 'Compressing...'
+ ]);
+
+ $zip->close();
+
+ return $this;
+ }
+
+ public function addEmptyFolders($folders, callable $status = null)
+ {
+ if (!extension_loaded('zip')) {
+ throw new \InvalidArgumentException('ZipArchiver: Zip PHP module not installed...');
+ }
+
+ $zip = new \ZipArchive();
+ if (!$zip->open($this->archive_file)) {
+ throw new \InvalidArgumentException('ZipArchiver: ' . $this->archive_file . ' cannot be opened...');
+ }
+
+ $status && $status([
+ 'type' => 'message',
+ 'message' => 'Adding empty folders...'
+ ]);
+
+ foreach($folders as $folder) {
+ $zip->addEmptyDir($folder);
+ $status && $status([
+ 'type' => 'progress',
+ ]);
+ }
+
+ $zip->close();
+
+ return $this;
+ }
+}
diff --git a/system/src/Grav/Common/Form/FormFlash.php b/system/src/Grav/Common/Form/FormFlash.php
new file mode 100644
index 0000000..b67313b
--- /dev/null
+++ b/system/src/Grav/Common/Form/FormFlash.php
@@ -0,0 +1,101 @@
+files as $field => $files) {
+ if (strpos($field, '/')) {
+ continue;
+ }
+ foreach ($files as $file) {
+ if (\is_array($file)) {
+ $file['tmp_name'] = $this->getTmpDir() . '/' . $file['tmp_name'];
+ $fields[$field][$file['path'] ?? $file['name']] = $file;
+ }
+ }
+ }
+
+ return $fields;
+ }
+
+ /**
+ * @param string $field
+ * @param string $filename
+ * @param array $upload
+ * @return bool
+ * @deprecated 1.6 For backwards compatibility only, do not use
+ */
+ public function uploadFile(string $field, string $filename, array $upload): bool
+ {
+ if (!$this->uniqueId) {
+ return false;
+ }
+
+ $tmp_dir = $this->getTmpDir();
+ Folder::create($tmp_dir);
+
+ $tmp_file = $upload['file']['tmp_name'];
+ $basename = basename($tmp_file);
+
+ if (!move_uploaded_file($tmp_file, $tmp_dir . '/' . $basename)) {
+ return false;
+ }
+
+ $upload['file']['tmp_name'] = $basename;
+ $upload['file']['name'] = $filename;
+
+ $this->addFileInternal($field, $filename, $upload['file']);
+
+ return true;
+ }
+
+ /**
+ * @param string $field
+ * @param string $filename
+ * @param array $upload
+ * @param array $crop
+ * @return bool
+ * @deprecated 1.6 For backwards compatibility only, do not use
+ */
+ public function cropFile(string $field, string $filename, array $upload, array $crop): bool
+ {
+ if (!$this->uniqueId) {
+ return false;
+ }
+
+ $tmp_dir = $this->getTmpDir();
+ Folder::create($tmp_dir);
+
+ $tmp_file = $upload['file']['tmp_name'];
+ $basename = basename($tmp_file);
+
+ if (!move_uploaded_file($tmp_file, $tmp_dir . '/' . $basename)) {
+ return false;
+ }
+
+ $upload['file']['tmp_name'] = $basename;
+ $upload['file']['name'] = $filename;
+
+ $this->addFileInternal($field, $filename, $upload['file'], $crop);
+
+ return true;
+ }
+}
diff --git a/system/src/Grav/Common/GPM/AbstractCollection.php b/system/src/Grav/Common/GPM/AbstractCollection.php
new file mode 100644
index 0000000..a9e1ac9
--- /dev/null
+++ b/system/src/Grav/Common/GPM/AbstractCollection.php
@@ -0,0 +1,31 @@
+toArray());
+ }
+
+ public function toArray()
+ {
+ $items = [];
+
+ foreach ($this->items as $name => $package) {
+ $items[$name] = $package->toArray();
+ }
+
+ return $items;
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php b/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php
new file mode 100644
index 0000000..bc4ecab
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php
@@ -0,0 +1,39 @@
+items as $name => $package) {
+ $items[$name] = $package->toArray();
+ }
+
+ return json_encode($items);
+ }
+
+ public function toArray()
+ {
+ $items = [];
+
+ foreach ($this->items as $name => $package) {
+ $items[$name] = $package->toArray();
+ }
+
+ return $items;
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Common/CachedCollection.php b/system/src/Grav/Common/GPM/Common/CachedCollection.php
new file mode 100644
index 0000000..a6fca4d
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Common/CachedCollection.php
@@ -0,0 +1,33 @@
+ $item) {
+ $this->append([$name => $item]);
+ }
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Common/Package.php b/system/src/Grav/Common/GPM/Common/Package.php
new file mode 100644
index 0000000..40d3759
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Common/Package.php
@@ -0,0 +1,70 @@
+data = $package;
+
+ if ($type) {
+ $this->data->set('package_type', $type);
+ }
+ }
+
+ /**
+ * @return Data
+ */
+ public function getData()
+ {
+ return $this->data;
+ }
+
+ public function __get($key)
+ {
+ return $this->data->get($key);
+ }
+
+ public function __set($key, $value)
+ {
+ return $this->data->set($key, $value);
+ }
+
+ public function __isset($key)
+ {
+ return isset($this->data->{$key});
+ }
+
+ public function __toString()
+ {
+ return $this->toJson();
+ }
+
+ public function toJson()
+ {
+ return $this->data->toJson();
+ }
+
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ return $this->data->toArray();
+ }
+}
diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php
new file mode 100644
index 0000000..6c9e7b0
--- /dev/null
+++ b/system/src/Grav/Common/GPM/GPM.php
@@ -0,0 +1,1160 @@
+ 'user/plugins/%name%',
+ 'themes' => 'user/themes/%name%',
+ 'skeletons' => 'user/'
+ ];
+
+ /**
+ * Creates a new GPM instance with Local and Remote packages available
+ * @param bool $refresh Applies to Remote Packages only and forces a refetch of data
+ * @param callable $callback Either a function or callback in array notation
+ */
+ public function __construct($refresh = false, $callback = null)
+ {
+ parent::__construct();
+ $this->cache = [];
+ $this->installed = new Local\Packages();
+ try {
+ $this->repository = new Remote\Packages($refresh, $callback);
+ $this->grav = new Remote\GravCore($refresh, $callback);
+ } catch (\Exception $e) {
+ }
+ }
+
+ /**
+ * Return the locally installed packages
+ *
+ * @return Local\Packages
+ */
+ public function getInstalled()
+ {
+ return $this->installed;
+ }
+
+ /**
+ * Returns the Locally installable packages
+ *
+ * @param array $list_type_installed
+ * @return array The installed packages
+ */
+ public function getInstallable($list_type_installed = ['plugins' => true, 'themes' => true])
+ {
+ $items = ['total' => 0];
+ foreach ($list_type_installed as $type => $type_installed) {
+ if ($type_installed === false) {
+ continue;
+ }
+ $methodInstallableType = 'getInstalled' . ucfirst($type);
+ $to_install = $this->$methodInstallableType();
+ $items[$type] = $to_install;
+ $items['total'] += count($to_install);
+ }
+ return $items;
+ }
+
+ /**
+ * Returns the amount of locally installed packages
+ * @return int Amount of installed packages
+ */
+ public function countInstalled()
+ {
+ $installed = $this->getInstalled();
+
+ return count($installed['plugins']) + count($installed['themes']);
+ }
+
+ /**
+ * Return the instance of a specific Package
+ *
+ * @param string $slug The slug of the Package
+ * @return Local\Package The instance of the Package
+ */
+ public function getInstalledPackage($slug)
+ {
+ if (isset($this->installed['plugins'][$slug])) {
+ return $this->installed['plugins'][$slug];
+ }
+
+ if (isset($this->installed['themes'][$slug])) {
+ return $this->installed['themes'][$slug];
+ }
+
+ return null;
+ }
+
+ /**
+ * Return the instance of a specific Plugin
+ * @param string $slug The slug of the Plugin
+ * @return Local\Package The instance of the Plugin
+ */
+ public function getInstalledPlugin($slug)
+ {
+ return $this->installed['plugins'][$slug];
+ }
+
+ /**
+ * Returns the Locally installed plugins
+ * @return Iterator The installed plugins
+ */
+ public function getInstalledPlugins()
+ {
+ return $this->installed['plugins'];
+ }
+
+ /**
+ * Checks if a Plugin is installed
+ * @param string $slug The slug of the Plugin
+ * @return bool True if the Plugin has been installed. False otherwise
+ */
+ public function isPluginInstalled($slug)
+ {
+ return isset($this->installed['plugins'][$slug]);
+ }
+
+ public function isPluginInstalledAsSymlink($slug)
+ {
+ return $this->installed['plugins'][$slug]->symlink;
+ }
+
+ /**
+ * Return the instance of a specific Theme
+ * @param string $slug The slug of the Theme
+ * @return Local\Package The instance of the Theme
+ */
+ public function getInstalledTheme($slug)
+ {
+ return $this->installed['themes'][$slug];
+ }
+
+ /**
+ * Returns the Locally installed themes
+ * @return Iterator The installed themes
+ */
+ public function getInstalledThemes()
+ {
+ return $this->installed['themes'];
+ }
+
+ /**
+ * Checks if a Theme is installed
+ * @param string $slug The slug of the Theme
+ * @return bool True if the Theme has been installed. False otherwise
+ */
+ public function isThemeInstalled($slug)
+ {
+ return isset($this->installed['themes'][$slug]);
+ }
+
+ /**
+ * Returns the amount of updates available
+ * @return int Amount of available updates
+ */
+ public function countUpdates()
+ {
+ $count = 0;
+
+ $count += count($this->getUpdatablePlugins());
+ $count += count($this->getUpdatableThemes());
+
+ return $count;
+ }
+
+ /**
+ * Returns an array of Plugins and Themes that can be updated.
+ * Plugins and Themes are extended with the `available` property that relies to the remote version
+ * @param array $list_type_update specifies what type of package to update
+ * @return array Array of updatable Plugins and Themes.
+ * Format: ['total' => int, 'plugins' => array, 'themes' => array]
+ */
+ public function getUpdatable($list_type_update = ['plugins' => true, 'themes' => true])
+ {
+
+ $items = ['total' => 0];
+ foreach ($list_type_update as $type => $type_updatable) {
+ if ($type_updatable === false) {
+ continue;
+ }
+ $methodUpdatableType = 'getUpdatable' . ucfirst($type);
+ $to_update = $this->$methodUpdatableType();
+ $items[$type] = $to_update;
+ $items['total'] += count($to_update);
+ }
+ return $items;
+ }
+
+ /**
+ * Returns an array of Plugins that can be updated.
+ * The Plugins are extended with the `available` property that relies to the remote version
+ * @return array Array of updatable Plugins
+ */
+ public function getUpdatablePlugins()
+ {
+ $items = [];
+ $repository = $this->repository['plugins'];
+
+ // local cache to speed things up
+ if (isset($this->cache[__METHOD__])) {
+ return $this->cache[__METHOD__];
+ }
+
+ foreach ($this->installed['plugins'] as $slug => $plugin) {
+ if (!isset($repository[$slug]) || $plugin->symlink || !$plugin->version || $plugin->gpm === false) {
+ continue;
+ }
+
+ $local_version = $plugin->version ?: 'Unknown';
+ $remote_version = $repository[$slug]->version;
+
+ if (version_compare($local_version, $remote_version) < 0) {
+ $repository[$slug]->available = $remote_version;
+ $repository[$slug]->version = $local_version;
+ $repository[$slug]->type = $repository[$slug]->release_type;
+ $items[$slug] = $repository[$slug];
+ }
+ }
+
+ $this->cache[__METHOD__] = $items;
+
+ return $items;
+ }
+
+ /**
+ * Get the latest release of a package from the GPM
+ *
+ * @param string $package_name
+ *
+ * @return string|null
+ */
+ public function getLatestVersionOfPackage($package_name)
+ {
+ $repository = $this->repository['plugins'];
+ if (isset($repository[$package_name])) {
+ return $repository[$package_name]->available ?: $repository[$package_name]->version;
+ }
+
+ //Not a plugin, it's a theme?
+ $repository = $this->repository['themes'];
+ if (isset($repository[$package_name])) {
+ return $repository[$package_name]->available ?: $repository[$package_name]->version;
+ }
+
+ return null;
+ }
+
+ /**
+ * Check if a Plugin or Theme is updatable
+ * @param string $slug The slug of the package
+ * @return bool True if updatable. False otherwise or if not found
+ */
+ public function isUpdatable($slug)
+ {
+ return $this->isPluginUpdatable($slug) || $this->isThemeUpdatable($slug);
+ }
+
+ /**
+ * Checks if a Plugin is updatable
+ * @param string $plugin The slug of the Plugin
+ * @return bool True if the Plugin is updatable. False otherwise
+ */
+ public function isPluginUpdatable($plugin)
+ {
+ return array_key_exists($plugin, (array)$this->getUpdatablePlugins());
+ }
+
+ /**
+ * Returns an array of Themes that can be updated.
+ * The Themes are extended with the `available` property that relies to the remote version
+ * @return array Array of updatable Themes
+ */
+ public function getUpdatableThemes()
+ {
+ $items = [];
+ $repository = $this->repository['themes'];
+
+ // local cache to speed things up
+ if (isset($this->cache[__METHOD__])) {
+ return $this->cache[__METHOD__];
+ }
+
+ foreach ($this->installed['themes'] as $slug => $plugin) {
+ if (!isset($repository[$slug]) || $plugin->symlink || !$plugin->version || $plugin->gpm === false) {
+ continue;
+ }
+
+ $local_version = $plugin->version ?: 'Unknown';
+ $remote_version = $repository[$slug]->version;
+
+ if (version_compare($local_version, $remote_version) < 0) {
+ $repository[$slug]->available = $remote_version;
+ $repository[$slug]->version = $local_version;
+ $repository[$slug]->type = $repository[$slug]->release_type;
+ $items[$slug] = $repository[$slug];
+ }
+ }
+
+ $this->cache[__METHOD__] = $items;
+
+ return $items;
+ }
+
+ /**
+ * Checks if a Theme is Updatable
+ * @param string $theme The slug of the Theme
+ * @return bool True if the Theme is updatable. False otherwise
+ */
+ public function isThemeUpdatable($theme)
+ {
+ return array_key_exists($theme, (array)$this->getUpdatableThemes());
+ }
+
+ /**
+ * Get the release type of a package (stable / testing)
+ *
+ * @param string $package_name
+ *
+ * @return string|null
+ */
+ public function getReleaseType($package_name)
+ {
+ $repository = $this->repository['plugins'];
+ if (isset($repository[$package_name])) {
+ return $repository[$package_name]->release_type;
+ }
+
+ //Not a plugin, it's a theme?
+ $repository = $this->repository['themes'];
+ if (isset($repository[$package_name])) {
+ return $repository[$package_name]->release_type;
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns true if the package latest release is stable
+ *
+ * @param string $package_name
+ *
+ * @return bool
+ */
+ public function isStableRelease($package_name)
+ {
+ return $this->getReleaseType($package_name) === 'stable';
+ }
+
+ /**
+ * Returns true if the package latest release is testing
+ *
+ * @param string $package_name
+ *
+ * @return bool
+ */
+ public function isTestingRelease($package_name)
+ {
+ $hasTesting = isset($this->getInstalledPackage($package_name)->testing);
+ $testing = $hasTesting ? $this->getInstalledPackage($package_name)->testing : false;
+
+ return $this->getReleaseType($package_name) === 'testing' || $testing;
+ }
+
+ /**
+ * Returns a Plugin from the repository
+ * @param string $slug The slug of the Plugin
+ * @return mixed Package if found, NULL if not
+ */
+ public function getRepositoryPlugin($slug)
+ {
+ return @$this->repository['plugins'][$slug];
+ }
+
+ /**
+ * Returns the list of Plugins available in the repository
+ * @return Iterator The Plugins remotely available
+ */
+ public function getRepositoryPlugins()
+ {
+ return $this->repository['plugins'];
+ }
+
+ /**
+ * Returns a Theme from the repository
+ * @param string $slug The slug of the Theme
+ * @return mixed Package if found, NULL if not
+ */
+ public function getRepositoryTheme($slug)
+ {
+ return @$this->repository['themes'][$slug];
+ }
+
+ /**
+ * Returns the list of Themes available in the repository
+ * @return Iterator The Themes remotely available
+ */
+ public function getRepositoryThemes()
+ {
+ return $this->repository['themes'];
+ }
+
+ /**
+ * Returns the list of Plugins and Themes available in the repository
+ * @return Remote\Packages Available Plugins and Themes
+ * Format: ['plugins' => array, 'themes' => array]
+ */
+ public function getRepository()
+ {
+ return $this->repository;
+ }
+
+ /**
+ * Searches for a Package in the repository
+ * @param string $search Can be either the slug or the name
+ * @param bool $ignore_exception True if should not fire an exception (for use in Twig)
+ * @return Remote\Package|bool Package if found, FALSE if not
+ */
+ public function findPackage($search, $ignore_exception = false)
+ {
+ $search = strtolower($search);
+
+ $found = $this->getRepositoryTheme($search);
+ if ($found) {
+ return $found;
+ }
+
+ $found = $this->getRepositoryPlugin($search);
+ if ($found) {
+ return $found;
+ }
+
+ $themes = $this->getRepositoryThemes();
+ $plugins = $this->getRepositoryPlugins();
+
+ if (!$themes && !$plugins) {
+ if (!is_writable(ROOT_DIR . '/cache/gpm')) {
+ throw new \RuntimeException("The cache/gpm folder is not writable. Please check the folder permissions.");
+ }
+
+ if ($ignore_exception) {
+ return false;
+ }
+
+ throw new \RuntimeException("GPM not reachable. Please check your internet connection or check the Grav site is reachable");
+ }
+
+ if ($themes) {
+ foreach ($themes as $slug => $theme) {
+ if ($search == $slug || $search == $theme->name) {
+ return $theme;
+ }
+ }
+ }
+
+ if ($plugins) {
+ foreach ($plugins as $slug => $plugin) {
+ if ($search == $slug || $search == $plugin->name) {
+ return $plugin;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Download the zip package via the URL
+ *
+ * @param string $package_file
+ * @param string $tmp
+ * @return null|string
+ */
+ public static function downloadPackage($package_file, $tmp)
+ {
+ $package = parse_url($package_file);
+ $filename = basename($package['path']);
+
+ if (Grav::instance()['config']->get('system.gpm.official_gpm_only') && $package['host'] !== 'getgrav.org') {
+ throw new \RuntimeException("Only official GPM URLs are allowed. You can modify this behavior in the System configuration.");
+ }
+
+ $output = Response::get($package_file, []);
+
+ if ($output) {
+ Folder::create($tmp);
+ file_put_contents($tmp . DS . $filename, $output);
+ return $tmp . DS . $filename;
+ }
+
+ return null;
+ }
+
+ /**
+ * Copy the local zip package to tmp
+ *
+ * @param string $package_file
+ * @param string $tmp
+ * @return null|string
+ */
+ public static function copyPackage($package_file, $tmp)
+ {
+ $package_file = realpath($package_file);
+
+ if (file_exists($package_file)) {
+ $filename = basename($package_file);
+ Folder::create($tmp);
+ copy(realpath($package_file), $tmp . DS . $filename);
+ return $tmp . DS . $filename;
+ }
+
+ return null;
+ }
+
+ /**
+ * Try to guess the package type from the source files
+ *
+ * @param string $source
+ * @return bool|string
+ */
+ public static function getPackageType($source)
+ {
+ $plugin_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Plugin/m';
+ $theme_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Theme/m';
+
+ if (
+ file_exists($source . 'system/defines.php') &&
+ file_exists($source . 'system/config/system.yaml')
+ ) {
+ return 'grav';
+ }
+
+ // must have a blueprint
+ if (!file_exists($source . 'blueprints.yaml')) {
+ return false;
+ }
+
+ // either theme or plugin
+ $name = basename($source);
+ if (Utils::contains($name, 'theme')) {
+ return 'theme';
+ }
+ if (Utils::contains($name, 'plugin')) {
+ return 'plugin';
+ }
+ foreach (glob($source . '*.php') as $filename) {
+ $contents = file_get_contents($filename);
+ if (preg_match($theme_regex, $contents)) {
+ return 'theme';
+ }
+ if (preg_match($plugin_regex, $contents)) {
+ return 'plugin';
+ }
+ }
+
+ // Assume it's a theme
+ return 'theme';
+ }
+
+ /**
+ * Try to guess the package name from the source files
+ *
+ * @param string $source
+ * @return bool|string
+ */
+ public static function getPackageName($source)
+ {
+ $ignore_yaml_files = ['blueprints', 'languages'];
+
+ foreach (glob($source . '*.yaml') as $filename) {
+ $name = strtolower(basename($filename, '.yaml'));
+ if (in_array($name, $ignore_yaml_files)) {
+ continue;
+ }
+ return $name;
+ }
+ return false;
+ }
+
+ /**
+ * Find/Parse the blueprint file
+ *
+ * @param string $source
+ * @return array|bool
+ */
+ public static function getBlueprints($source)
+ {
+ $blueprint_file = $source . 'blueprints.yaml';
+ if (!file_exists($blueprint_file)) {
+ return false;
+ }
+
+ $file = YamlFile::instance($blueprint_file);
+ $blueprint = (array)$file->content();
+ $file->free();
+
+ return $blueprint;
+ }
+
+ /**
+ * Get the install path for a name and a particular type of package
+ *
+ * @param string $type
+ * @param string $name
+ * @return string
+ */
+ public static function getInstallPath($type, $name)
+ {
+ $locator = Grav::instance()['locator'];
+
+ if ($type === 'theme') {
+ $install_path = $locator->findResource('themes://', false) . DS . $name;
+ } else {
+ $install_path = $locator->findResource('plugins://', false) . DS . $name;
+ }
+ return $install_path;
+ }
+
+ /**
+ * Searches for a list of Packages in the repository
+ * @param array $searches An array of either slugs or names
+ * @return array Array of found Packages
+ * Format: ['total' => int, 'not_found' => array, ]
+ */
+ public function findPackages($searches = [])
+ {
+ $packages = ['total' => 0, 'not_found' => []];
+ $inflector = new Inflector();
+
+ foreach ($searches as $search) {
+ $repository = '';
+ // if this is an object, get the search data from the key
+ if (is_object($search)) {
+ $search = (array)$search;
+ $key = key($search);
+ $repository = $search[$key];
+ $search = $key;
+ }
+
+ $found = $this->findPackage($search);
+ if ($found) {
+ // set override repository if provided
+ if ($repository) {
+ $found->override_repository = $repository;
+ }
+ if (!isset($packages[$found->package_type])) {
+ $packages[$found->package_type] = [];
+ }
+
+ $packages[$found->package_type][$found->slug] = $found;
+ $packages['total']++;
+ } else {
+ // make a best guess at the type based on the repo URL
+ if (Utils::contains($repository, '-theme')) {
+ $type = 'themes';
+ } else {
+ $type = 'plugins';
+ }
+
+ $not_found = new \stdClass();
+ $not_found->name = $inflector::camelize($search);
+ $not_found->slug = $search;
+ $not_found->package_type = $type;
+ $not_found->install_path = str_replace('%name%', $search, $this->install_paths[$type]);
+ $not_found->override_repository = $repository;
+ $packages['not_found'][$search] = $not_found;
+ }
+ }
+
+ return $packages;
+ }
+
+ /**
+ * Return the list of packages that have the passed one as dependency
+ *
+ * @param string $slug The slug name of the package
+ *
+ * @return array
+ */
+ public function getPackagesThatDependOnPackage($slug)
+ {
+ $plugins = $this->getInstalledPlugins();
+ $themes = $this->getInstalledThemes();
+ $packages = array_merge($plugins->toArray(), $themes->toArray());
+
+ $dependent_packages = [];
+
+ foreach ($packages as $package_name => $package) {
+ if (isset($package['dependencies'])) {
+ foreach ($package['dependencies'] as $dependency) {
+ if (is_array($dependency) && isset($dependency['name'])) {
+ $dependency = $dependency['name'];
+ }
+
+ if ($dependency === $slug) {
+ $dependent_packages[] = $package_name;
+ }
+ }
+ }
+ }
+
+ return $dependent_packages;
+ }
+
+
+ /**
+ * Get the required version of a dependency of a package
+ *
+ * @param string $package_slug
+ * @param string $dependency_slug
+ *
+ * @return mixed
+ */
+ public function getVersionOfDependencyRequiredByPackage($package_slug, $dependency_slug)
+ {
+ $dependencies = $this->getInstalledPackage($package_slug)->dependencies;
+ foreach ($dependencies as $dependency) {
+ if (isset($dependency[$dependency_slug])) {
+ return $dependency[$dependency_slug];
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Check the package identified by $slug can be updated to the version passed as argument.
+ * Thrown an exception if it cannot be updated because another package installed requires it to be at an older version.
+ *
+ * @param string $slug
+ * @param string $version_with_operator
+ * @param array $ignore_packages_list
+ *
+ * @return bool
+ * @throws \RuntimeException
+ */
+ public function checkNoOtherPackageNeedsThisDependencyInALowerVersion(
+ $slug,
+ $version_with_operator,
+ $ignore_packages_list
+ ) {
+
+ // check if any of the currently installed package need this in a lower version than the one we need. In case, abort and tell which package
+ $dependent_packages = $this->getPackagesThatDependOnPackage($slug);
+ $version = $this->calculateVersionNumberFromDependencyVersion($version_with_operator);
+
+ if (count($dependent_packages)) {
+ foreach ($dependent_packages as $dependent_package) {
+ $other_dependency_version_with_operator = $this->getVersionOfDependencyRequiredByPackage($dependent_package,
+ $slug);
+ $other_dependency_version = $this->calculateVersionNumberFromDependencyVersion($other_dependency_version_with_operator);
+
+ // check version is compatible with the one needed by the current package
+ if ($this->versionFormatIsNextSignificantRelease($other_dependency_version_with_operator)) {
+ $compatible = $this->checkNextSignificantReleasesAreCompatible($version,
+ $other_dependency_version);
+ if (!$compatible) {
+ if (!in_array($dependent_package, $ignore_packages_list, true)) {
+ throw new \RuntimeException("Package $slug is required in an older version by package $dependent_package . This package needs a newer version, and because of this it cannot be installed. The $dependent_package package must be updated to use a newer release of $slug .",
+ 2);
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Check the passed packages list can be updated
+ *
+ * @param array $packages_names_list
+ *
+ * @throws \Exception
+ */
+ public function checkPackagesCanBeInstalled($packages_names_list)
+ {
+ foreach ($packages_names_list as $package_name) {
+ $this->checkNoOtherPackageNeedsThisDependencyInALowerVersion($package_name,
+ $this->getLatestVersionOfPackage($package_name), $packages_names_list);
+ }
+ }
+
+ /**
+ * Fetch the dependencies, check the installed packages and return an array with
+ * the list of packages with associated an information on what to do: install, update or ignore.
+ *
+ * `ignore` means the package is already installed and can be safely left as-is.
+ * `install` means the package is not installed and must be installed.
+ * `update` means the package is already installed and must be updated as a dependency needs a higher version.
+ *
+ * @param array $packages
+ *
+ * @return mixed
+ * @throws \Exception
+ */
+ public function getDependencies($packages)
+ {
+ $dependencies = $this->calculateMergedDependenciesOfPackages($packages);
+ foreach ($dependencies as $dependency_slug => $dependencyVersionWithOperator) {
+ if (\in_array($dependency_slug, $packages, true)) {
+ unset($dependencies[$dependency_slug]);
+ continue;
+ }
+
+ // Check PHP version
+ if ($dependency_slug === 'php') {
+ $current_php_version = phpversion();
+ if (version_compare($this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator),
+ $current_php_version) === 1
+ ) {
+ //Needs a Grav update first
+ throw new \RuntimeException("One of the packages require PHP {$dependencies['php']}. Please update PHP to resolve this");
+ }
+
+ unset($dependencies[$dependency_slug]);
+ continue;
+ }
+
+ //First, check for Grav dependency. If a dependency requires Grav > the current version, abort and tell.
+ if ($dependency_slug === 'grav') {
+ if (version_compare($this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator),
+ GRAV_VERSION) === 1
+ ) {
+ //Needs a Grav update first
+ throw new \RuntimeException("One of the packages require Grav {$dependencies['grav']}. Please update Grav to the latest release.");
+ }
+
+ unset($dependencies[$dependency_slug]);
+ continue;
+ }
+
+ if ($this->isPluginInstalled($dependency_slug)) {
+ if ($this->isPluginInstalledAsSymlink($dependency_slug)) {
+ unset($dependencies[$dependency_slug]);
+ continue;
+ }
+
+ $dependencyVersion = $this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator);
+
+ // get currently installed version
+ $locator = Grav::instance()['locator'];
+ $blueprints_path = $locator->findResource('plugins://' . $dependency_slug . DS . 'blueprints.yaml');
+ $file = YamlFile::instance($blueprints_path);
+ $package_yaml = $file->content();
+ $file->free();
+ $currentlyInstalledVersion = $package_yaml['version'];
+
+ // if requirement is next significant release, check is compatible with currently installed version, might not be
+ if ($this->versionFormatIsNextSignificantRelease($dependencyVersionWithOperator)) {
+ if ($this->firstVersionIsLower($dependencyVersion, $currentlyInstalledVersion)) {
+ $compatible = $this->checkNextSignificantReleasesAreCompatible($dependencyVersion,
+ $currentlyInstalledVersion);
+
+ if (!$compatible) {
+ throw new \RuntimeException('Dependency ' . $dependency_slug . ' is required in an older version than the one installed. This package must be updated. Please get in touch with its developer.',
+ 2);
+ }
+ }
+ }
+
+ //if I already have the latest release, remove the dependency
+ $latestRelease = $this->getLatestVersionOfPackage($dependency_slug);
+
+ if ($this->firstVersionIsLower($latestRelease, $dependencyVersion)) {
+ //throw an exception if a required version cannot be found in the GPM yet
+ throw new \RuntimeException('Dependency ' . $package_yaml['name'] . ' is required in version ' . $dependencyVersion . ' which is higher than the latest release, ' . $latestRelease . ' . Try running `bin/gpm -f index` to force a refresh of the GPM cache',
+ 1);
+ }
+
+ if ($this->firstVersionIsLower($currentlyInstalledVersion, $dependencyVersion)) {
+ $dependencies[$dependency_slug] = 'update';
+ } else {
+ if ($currentlyInstalledVersion == $latestRelease) {
+ unset($dependencies[$dependency_slug]);
+ } else {
+ // an update is not strictly required mark as 'ignore'
+ $dependencies[$dependency_slug] = 'ignore';
+ }
+ }
+ } else {
+ $dependencyVersion = $this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator);
+
+ // if requirement is next significant release, check is compatible with latest available version, might not be
+ if ($this->versionFormatIsNextSignificantRelease($dependencyVersionWithOperator)) {
+ $latestVersionOfPackage = $this->getLatestVersionOfPackage($dependency_slug);
+ if ($this->firstVersionIsLower($dependencyVersion, $latestVersionOfPackage)) {
+ $compatible = $this->checkNextSignificantReleasesAreCompatible($dependencyVersion,
+ $latestVersionOfPackage);
+
+ if (!$compatible) {
+ throw new \Exception('Dependency ' . $dependency_slug . ' is required in an older version than the latest release available, and it cannot be installed. This package must be updated. Please get in touch with its developer.',
+ 2);
+ }
+ }
+ }
+
+ $dependencies[$dependency_slug] = 'install';
+ }
+ }
+
+ $dependencies_slugs = array_keys($dependencies);
+ $this->checkNoOtherPackageNeedsTheseDependenciesInALowerVersion(array_merge($packages, $dependencies_slugs));
+
+ return $dependencies;
+ }
+
+ public function checkNoOtherPackageNeedsTheseDependenciesInALowerVersion($dependencies_slugs)
+ {
+ foreach ($dependencies_slugs as $dependency_slug) {
+ $this->checkNoOtherPackageNeedsThisDependencyInALowerVersion($dependency_slug,
+ $this->getLatestVersionOfPackage($dependency_slug), $dependencies_slugs);
+ }
+ }
+
+ private function firstVersionIsLower($firstVersion, $secondVersion)
+ {
+ return version_compare($firstVersion, $secondVersion) === -1;
+ }
+
+ /**
+ * Calculates and merges the dependencies of a package
+ *
+ * @param string $packageName The package information
+ *
+ * @param array $dependencies The dependencies array
+ *
+ * @return array
+ * @throws \Exception
+ */
+ private function calculateMergedDependenciesOfPackage($packageName, $dependencies)
+ {
+ $packageData = $this->findPackage($packageName);
+
+ //Check for dependencies
+ if (isset($packageData->dependencies)) {
+ foreach ($packageData->dependencies as $dependency) {
+ $current_package_name = $dependency['name'];
+ if (isset($dependency['version'])) {
+ $current_package_version_information = $dependency['version'];
+ }
+
+ if (!isset($dependencies[$current_package_name])) {
+ // Dependency added for the first time
+
+ if (!isset($current_package_version_information)) {
+ $dependencies[$current_package_name] = '*';
+ } else {
+ $dependencies[$current_package_name] = $current_package_version_information;
+ }
+
+ //Factor in the package dependencies too
+ $dependencies = $this->calculateMergedDependenciesOfPackage($current_package_name, $dependencies);
+ } else {
+ // Dependency already added by another package
+ //if this package requires a version higher than the currently stored one, store this requirement instead
+ if (isset($current_package_version_information) && $current_package_version_information !== '*') {
+
+ $currently_stored_version_information = $dependencies[$current_package_name];
+ $currently_stored_version_number = $this->calculateVersionNumberFromDependencyVersion($currently_stored_version_information);
+
+ $currently_stored_version_is_in_next_significant_release_format = false;
+ if ($this->versionFormatIsNextSignificantRelease($currently_stored_version_information)) {
+ $currently_stored_version_is_in_next_significant_release_format = true;
+ }
+
+ if (!$currently_stored_version_number) {
+ $currently_stored_version_number = '*';
+ }
+
+ $current_package_version_number = $this->calculateVersionNumberFromDependencyVersion($current_package_version_information);
+ if (!$current_package_version_number) {
+ throw new \RuntimeException('Bad format for version of dependency ' . $current_package_name . ' for package ' . $packageName,
+ 1);
+ }
+
+ $current_package_version_is_in_next_significant_release_format = false;
+ if ($this->versionFormatIsNextSignificantRelease($current_package_version_information)) {
+ $current_package_version_is_in_next_significant_release_format = true;
+ }
+
+ //If I had stored '*', change right away with the more specific version required
+ if ($currently_stored_version_number === '*') {
+ $dependencies[$current_package_name] = $current_package_version_information;
+ } else {
+ if (!$currently_stored_version_is_in_next_significant_release_format && !$current_package_version_is_in_next_significant_release_format) {
+ //Comparing versions equals or higher, a simple version_compare is enough
+ if (version_compare($currently_stored_version_number,
+ $current_package_version_number) === -1
+ ) { //Current package version is higher
+ $dependencies[$current_package_name] = $current_package_version_information;
+ }
+ } else {
+ $compatible = $this->checkNextSignificantReleasesAreCompatible($currently_stored_version_number,
+ $current_package_version_number);
+ if (!$compatible) {
+ throw new \RuntimeException('Dependency ' . $current_package_name . ' is required in two incompatible versions',
+ 2);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return $dependencies;
+ }
+
+ /**
+ * Calculates and merges the dependencies of the passed packages
+ *
+ * @param array $packages
+ *
+ * @return mixed
+ * @throws \Exception
+ */
+ public function calculateMergedDependenciesOfPackages($packages)
+ {
+ $dependencies = [];
+
+ foreach ($packages as $package) {
+ $dependencies = $this->calculateMergedDependenciesOfPackage($package, $dependencies);
+ }
+
+ return $dependencies;
+ }
+
+ /**
+ * Returns the actual version from a dependency version string.
+ * Examples:
+ * $versionInformation == '~2.0' => returns '2.0'
+ * $versionInformation == '>=2.0.2' => returns '2.0.2'
+ * $versionInformation == '2.0.2' => returns '2.0.2'
+ * $versionInformation == '*' => returns null
+ * $versionInformation == '' => returns null
+ *
+ * @param string $version
+ *
+ * @return null|string
+ */
+ public function calculateVersionNumberFromDependencyVersion($version)
+ {
+ if ($version === '*') {
+ return null;
+ }
+ if ($version === '') {
+ return null;
+ }
+ if ($this->versionFormatIsNextSignificantRelease($version)) {
+ return trim(substr($version, 1));
+ }
+ if ($this->versionFormatIsEqualOrHigher($version)) {
+ return trim(substr($version, 2));
+ }
+
+ return $version;
+ }
+
+ /**
+ * Check if the passed version information contains next significant release (tilde) operator
+ *
+ * Example: returns true for $version: '~2.0'
+ *
+ * @param string $version
+ *
+ * @return bool
+ */
+ public function versionFormatIsNextSignificantRelease($version): bool
+ {
+ return strpos($version, '~') === 0;
+ }
+
+ /**
+ * Check if the passed version information contains equal or higher operator
+ *
+ * Example: returns true for $version: '>=2.0'
+ *
+ * @param string $version
+ *
+ * @return bool
+ */
+ public function versionFormatIsEqualOrHigher($version): bool
+ {
+ return strpos($version, '>=') === 0;
+ }
+
+ /**
+ * Check if two releases are compatible by next significant release
+ *
+ * ~1.2 is equivalent to >=1.2 <2.0.0
+ * ~1.2.3 is equivalent to >=1.2.3 <1.3.0
+ *
+ * In short, allows the last digit specified to go up
+ *
+ * @param string $version1 the version string (e.g. '2.0.0' or '1.0')
+ * @param string $version2 the version string (e.g. '2.0.0' or '1.0')
+ *
+ * @return bool
+ */
+ public function checkNextSignificantReleasesAreCompatible($version1, $version2): bool
+ {
+ $version1array = explode('.', $version1);
+ $version2array = explode('.', $version2);
+
+ if (\count($version1array) > \count($version2array)) {
+ list($version1array, $version2array) = [$version2array, $version1array];
+ }
+
+ $i = 0;
+ while ($i < \count($version1array) - 1) {
+ if ($version1array[$i] != $version2array[$i]) {
+ return false;
+ }
+ $i++;
+ }
+
+ return true;
+ }
+
+}
diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php
new file mode 100644
index 0000000..cd51163
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Installer.php
@@ -0,0 +1,543 @@
+ true,
+ 'ignore_symlinks' => true,
+ 'sophisticated' => false,
+ 'theme' => false,
+ 'install_path' => '',
+ 'ignores' => [],
+ 'exclude_checks' => [self::EXISTS, self::NOT_FOUND, self::IS_LINK]
+ ];
+
+ /**
+ * Installs a given package to a given destination.
+ *
+ * @param string $zip the local path to ZIP package
+ * @param string $destination The local path to the Grav Instance
+ * @param array $options Options to use for installing. ie, ['install_path' => 'user/themes/antimatter']
+ * @param string $extracted The local path to the extacted ZIP package
+ * @param bool $keepExtracted True if you want to keep the original files
+ * @return bool True if everything went fine, False otherwise.
+ */
+ public static function install($zip, $destination, $options = [], $extracted = null, $keepExtracted = false)
+ {
+ $destination = rtrim($destination, DS);
+ $options = array_merge(self::$options, $options);
+ $install_path = rtrim($destination . DS . ltrim($options['install_path'], DS), DS);
+
+ if (!self::isGravInstance($destination) || !self::isValidDestination($install_path,
+ $options['exclude_checks'])
+ ) {
+ return false;
+ }
+
+ if ((self::lastErrorCode() === self::IS_LINK && $options['ignore_symlinks']) ||
+ (self::lastErrorCode() === self::EXISTS && !$options['overwrite'])
+ ) {
+ return false;
+ }
+
+ // Create a tmp location
+ $tmp_dir = Grav::instance()['locator']->findResource('tmp://', true, true);
+ $tmp = $tmp_dir . '/Grav-' . uniqid('', false);
+
+ if (!$extracted) {
+ $extracted = self::unZip($zip, $tmp);
+ if (!$extracted) {
+ Folder::delete($tmp);
+ return false;
+ }
+ }
+
+ if (!file_exists($extracted)) {
+ self::$error = self::INVALID_SOURCE;
+ return false;
+ }
+
+ $is_install = true;
+ $installer = self::loadInstaller($extracted, $is_install);
+
+ if (isset($options['is_update']) && $options['is_update'] === true) {
+ $method = 'preUpdate';
+ } else {
+ $method = 'preInstall';
+ }
+
+ if ($installer && method_exists($installer, $method)) {
+ $method_result = $installer::$method();
+ if ($method_result !== true) {
+ self::$error = 'An error occurred';
+ if (is_string($method_result)) {
+ self::$error = $method_result;
+ }
+
+ return false;
+ }
+ }
+
+ if (!$options['sophisticated']) {
+ if ($options['theme']) {
+ self::copyInstall($extracted, $install_path);
+ } else {
+ self::moveInstall($extracted, $install_path);
+ }
+ } else {
+ self::sophisticatedInstall($extracted, $install_path, $options['ignores'], $keepExtracted);
+ }
+
+ Folder::delete($tmp);
+
+ if (isset($options['is_update']) && $options['is_update'] === true) {
+ $method = 'postUpdate';
+ } else {
+ $method = 'postInstall';
+ }
+
+ self::$message = '';
+ if ($installer && method_exists($installer, $method)) {
+ self::$message = $installer::$method();
+ }
+
+ self::$error = self::OK;
+
+ return true;
+
+ }
+
+ /**
+ * Unzip a file to somewhere
+ *
+ * @param string $zip_file
+ * @param string $destination
+ * @return bool|string
+ */
+ public static function unZip($zip_file, $destination)
+ {
+ $zip = new \ZipArchive();
+ $archive = $zip->open($zip_file);
+
+ if ($archive === true) {
+ Folder::create($destination);
+
+ $unzip = $zip->extractTo($destination);
+
+
+ if (!$unzip) {
+ self::$error = self::ZIP_EXTRACT_ERROR;
+ Folder::delete($destination);
+ $zip->close();
+ return false;
+ }
+
+ $package_folder_name = preg_replace('#\./$#', '', $zip->getNameIndex(0));
+ $zip->close();
+
+ return $destination . '/' . $package_folder_name;
+ }
+
+ self::$error = self::ZIP_EXTRACT_ERROR;
+ self::$error_zip = $archive;
+ return false;
+ }
+
+ /**
+ * Instantiates and returns the package installer class
+ *
+ * @param string $installer_file_folder The folder path that contains install.php
+ * @param bool $is_install True if install, false if removal
+ *
+ * @return null|string
+ */
+ private static function loadInstaller($installer_file_folder, $is_install)
+ {
+ $installer = null;
+
+ $installer_file_folder = rtrim($installer_file_folder, DS);
+
+ $install_file = $installer_file_folder . DS . 'install.php';
+
+ if (file_exists($install_file)) {
+ require_once $install_file;
+ } else {
+ return null;
+ }
+
+ if ($is_install) {
+ $slug = '';
+ if (($pos = strpos($installer_file_folder, 'grav-plugin-')) !== false) {
+ $slug = substr($installer_file_folder, $pos + strlen('grav-plugin-'));
+ } elseif (($pos = strpos($installer_file_folder, 'grav-theme-')) !== false) {
+ $slug = substr($installer_file_folder, $pos + strlen('grav-theme-'));
+ }
+ } else {
+ $path_elements = explode('/', $installer_file_folder);
+ $slug = end($path_elements);
+ }
+
+ if (!$slug) {
+ return null;
+ }
+
+ $class_name = ucfirst($slug) . 'Install';
+
+ if (class_exists($class_name)) {
+ return $class_name;
+ }
+
+ $class_name_alphanumeric = preg_replace('/[^a-zA-Z0-9]+/', '', $class_name);
+
+ if (class_exists($class_name_alphanumeric)) {
+ return $class_name_alphanumeric;
+ }
+
+ return $installer;
+ }
+
+ /**
+ * @param string $source_path
+ * @param string $install_path
+ *
+ * @return bool
+ */
+ public static function moveInstall($source_path, $install_path)
+ {
+ if (file_exists($install_path)) {
+ Folder::delete($install_path);
+ }
+
+ Folder::move($source_path, $install_path);
+
+ return true;
+ }
+
+ /**
+ * @param string $source_path
+ * @param string $install_path
+ *
+ * @return bool
+ */
+ public static function copyInstall($source_path, $install_path)
+ {
+ if (empty($source_path)) {
+ throw new \RuntimeException("Directory $source_path is missing");
+ }
+
+ Folder::rcopy($source_path, $install_path);
+
+ return true;
+ }
+
+ /**
+ * @param string $source_path
+ * @param string $install_path
+ * @param array $ignores
+ * @param bool $keep_source
+ *
+ * @return bool
+ */
+ public static function sophisticatedInstall($source_path, $install_path, $ignores = [], $keep_source = false)
+ {
+ foreach (new \DirectoryIterator($source_path) as $file) {
+
+ if ($file->isLink() || $file->isDot() || \in_array($file->getFilename(), $ignores, true)) {
+ continue;
+ }
+
+ $path = $install_path . DS . $file->getFilename();
+
+ if ($file->isDir()) {
+ Folder::delete($path);
+ if ($keep_source) {
+ Folder::copy($file->getPathname(), $path);
+ } else {
+ Folder::move($file->getPathname(), $path);
+ }
+
+ if ($file->getFilename() === 'bin') {
+ foreach (glob($path . DS . '*') as $bin_file) {
+ @chmod($bin_file, 0755);
+ }
+ }
+ } else {
+ @unlink($path);
+ @copy($file->getPathname(), $path);
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Uninstalls one or more given package
+ *
+ * @param string $path The slug of the package(s)
+ * @param array $options Options to use for uninstalling
+ *
+ * @return bool True if everything went fine, False otherwise.
+ */
+ public static function uninstall($path, $options = [])
+ {
+ $options = array_merge(self::$options, $options);
+ if (!self::isValidDestination($path, $options['exclude_checks'])
+ ) {
+ return false;
+ }
+
+ $installer_file_folder = $path;
+ $is_install = false;
+ $installer = self::loadInstaller($installer_file_folder, $is_install);
+
+ if ($installer && method_exists($installer, 'preUninstall')) {
+ $method_result = $installer::preUninstall();
+ if ($method_result !== true) {
+ self::$error = 'An error occurred';
+ if (is_string($method_result)) {
+ self::$error = $method_result;
+ }
+
+ return false;
+ }
+ }
+
+ $result = Folder::delete($path);
+
+ self::$message = '';
+ if ($result && $installer && method_exists($installer, 'postUninstall')) {
+ self::$message = $installer::postUninstall();
+ }
+
+ return $result;
+ }
+
+ /**
+ * Runs a set of checks on the destination and sets the Error if any
+ *
+ * @param string $destination The directory to run validations at
+ * @param array $exclude An array of constants to exclude from the validation
+ *
+ * @return bool True if validation passed. False otherwise
+ */
+ public static function isValidDestination($destination, $exclude = [])
+ {
+ self::$error = 0;
+ self::$target = $destination;
+
+ if (is_link($destination)) {
+ self::$error = self::IS_LINK;
+ } elseif (file_exists($destination)) {
+ self::$error = self::EXISTS;
+ } elseif (!file_exists($destination)) {
+ self::$error = self::NOT_FOUND;
+ } elseif (!is_dir($destination)) {
+ self::$error = self::NOT_DIRECTORY;
+ }
+
+ if (\count($exclude) && \in_array(self::$error, $exclude, true)) {
+ return true;
+ }
+
+ return !self::$error;
+ }
+
+ /**
+ * Validates if the given path is a Grav Instance
+ *
+ * @param string $target The local path to the Grav Instance
+ *
+ * @return bool True if is a Grav Instance. False otherwise
+ */
+ public static function isGravInstance($target)
+ {
+ self::$error = 0;
+ self::$target = $target;
+
+ if (
+ !file_exists($target . DS . 'index.php') ||
+ !file_exists($target . DS . 'bin') ||
+ !file_exists($target . DS . 'user') ||
+ !file_exists($target . DS . 'system' . DS . 'config' . DS . 'system.yaml')
+ ) {
+ self::$error = self::NOT_GRAV_ROOT;
+ }
+
+ return !self::$error;
+ }
+
+ /**
+ * Returns the last message added by the installer
+ * @return string The message
+ */
+ public static function getMessage()
+ {
+ return self::$message;
+ }
+
+ /**
+ * Returns the last error occurred in a string message format
+ * @return string The message of the last error
+ */
+ public static function lastErrorMsg()
+ {
+ if (is_string(self::$error)) {
+ return self::$error;
+ }
+
+ switch (self::$error) {
+ case 0:
+ $msg = 'No Error';
+ break;
+
+ case self::EXISTS:
+ $msg = 'The target path "' . self::$target . '" already exists';
+ break;
+
+ case self::IS_LINK:
+ $msg = 'The target path "' . self::$target . '" is a symbolic link';
+ break;
+
+ case self::NOT_FOUND:
+ $msg = 'The target path "' . self::$target . '" does not appear to exist';
+ break;
+
+ case self::NOT_DIRECTORY:
+ $msg = 'The target path "' . self::$target . '" does not appear to be a folder';
+ break;
+
+ case self::NOT_GRAV_ROOT:
+ $msg = 'The target path "' . self::$target . '" does not appear to be a Grav instance';
+ break;
+
+ case self::ZIP_OPEN_ERROR:
+ $msg = 'Unable to open the package file';
+ break;
+
+ case self::ZIP_EXTRACT_ERROR:
+ $msg = 'Unable to extract the package. ';
+ if (self::$error_zip) {
+ switch(self::$error_zip) {
+ case \ZipArchive::ER_EXISTS:
+ $msg .= 'File already exists.';
+ break;
+
+ case \ZipArchive::ER_INCONS:
+ $msg .= 'Zip archive inconsistent.';
+ break;
+
+ case \ZipArchive::ER_MEMORY:
+ $msg .= 'Memory allocation failure.';
+ break;
+
+ case \ZipArchive::ER_NOENT:
+ $msg .= 'No such file.';
+ break;
+
+ case \ZipArchive::ER_NOZIP:
+ $msg .= 'Not a zip archive.';
+ break;
+
+ case \ZipArchive::ER_OPEN:
+ $msg .= "Can't open file.";
+ break;
+
+ case \ZipArchive::ER_READ:
+ $msg .= 'Read error.';
+ break;
+
+ case \ZipArchive::ER_SEEK:
+ $msg .= 'Seek error.';
+ break;
+ }
+ }
+ break;
+
+ case self::INVALID_SOURCE:
+ $msg = 'Invalid source file';
+ break;
+
+ default:
+ $msg = 'Unknown Error';
+ break;
+ }
+
+ return $msg;
+ }
+
+ /**
+ * Returns the last error code of the occurred error
+ * @return int|string The code of the last error
+ */
+ public static function lastErrorCode()
+ {
+ return self::$error;
+ }
+
+ /**
+ * Allows to manually set an error
+ *
+ * @param int|string $error the Error code
+ */
+
+ public static function setError($error)
+ {
+ self::$error = $error;
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Licenses.php b/system/src/Grav/Common/GPM/Licenses.php
new file mode 100644
index 0000000..14c9258
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Licenses.php
@@ -0,0 +1,123 @@
+content();
+ $slug = strtolower($slug);
+
+ if ($license && !self::validate($license)) {
+ return false;
+ }
+
+ if (!\is_string($license)) {
+ if (isset($data['licenses'][$slug])) {
+ unset($data['licenses'][$slug]);
+ } else {
+ return false;
+ }
+ } else {
+ $data['licenses'][$slug] = $license;
+ }
+
+ $licenses->save($data);
+ $licenses->free();
+
+ return true;
+ }
+
+ /**
+ * Returns the license for a Premium package
+ *
+ * @param string $slug
+ *
+ * @return array|string
+ */
+ public static function get($slug = null)
+ {
+ $licenses = self::getLicenseFile();
+ $data = (array)$licenses->content();
+ $licenses->free();
+ $slug = strtolower($slug);
+
+ if (!$slug) {
+ return $data['licenses'] ?? [];
+ }
+
+ return $data['licenses'][$slug] ?? '';
+ }
+
+
+ /**
+ * Validates the License format
+ *
+ * @param string $license
+ *
+ * @return bool
+ */
+ public static function validate($license = null)
+ {
+ if (!is_string($license)) {
+ return false;
+ }
+
+ return preg_match('#' . self::$regex. '#', $license);
+ }
+
+ /**
+ * Get the License File object
+ *
+ * @return \RocketTheme\Toolbox\File\FileInterface
+ */
+ public static function getLicenseFile()
+
+ {
+ if (!isset(self::$file)) {
+ $path = Grav::instance()['locator']->findResource('user-data://') . '/licenses.yaml';
+ if (!file_exists($path)) {
+ touch($path);
+ }
+ self::$file = CompiledYamlFile::instance($path);
+ }
+
+ return self::$file;
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php b/system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php
new file mode 100644
index 0000000..be565c9
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php
@@ -0,0 +1,25 @@
+ $data) {
+ $data->set('slug', $name);
+ $this->items[$name] = new Package($data, $this->type);
+ }
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Local/Package.php b/system/src/Grav/Common/GPM/Local/Package.php
new file mode 100644
index 0000000..88241a4
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Local/Package.php
@@ -0,0 +1,41 @@
+blueprints()->toArray());
+ parent::__construct($data, $package_type);
+
+ $this->settings = $package->toArray();
+
+ $html_description = Parsedown::instance()->line($this->__get('description'));
+ $this->data->set('slug', $package->__get('slug'));
+ $this->data->set('description_html', $html_description);
+ $this->data->set('description_plain', strip_tags($html_description));
+ $this->data->set('symlink', is_link(USER_DIR . $package_type . DS . $this->__get('slug')));
+ }
+
+ /**
+ * @return mixed
+ */
+ public function isEnabled()
+ {
+ return $this->settings['enabled'];
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Local/Packages.php b/system/src/Grav/Common/GPM/Local/Packages.php
new file mode 100644
index 0000000..14a0b0b
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Local/Packages.php
@@ -0,0 +1,25 @@
+ new Plugins(),
+ 'themes' => new Themes()
+ ];
+
+ parent::__construct($items);
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Local/Plugins.php b/system/src/Grav/Common/GPM/Local/Plugins.php
new file mode 100644
index 0000000..19adfb8
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Local/Plugins.php
@@ -0,0 +1,31 @@
+all());
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Local/Themes.php b/system/src/Grav/Common/GPM/Local/Themes.php
new file mode 100644
index 0000000..8607e6b
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Local/Themes.php
@@ -0,0 +1,28 @@
+all());
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php b/system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php
new file mode 100644
index 0000000..429c5b1
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php
@@ -0,0 +1,77 @@
+get('system.gpm.releases', 'stable');
+ $cache_dir = Grav::instance()['locator']->findResource('cache://gpm', true, true);
+ $this->cache = new FilesystemCache($cache_dir);
+
+ $this->repository = $repository . '?v=' . GRAV_VERSION . '&' . $channel . '=1';
+ $this->raw = $this->cache->fetch(md5($this->repository));
+
+ $this->fetch($refresh, $callback);
+ foreach (json_decode($this->raw, true) as $slug => $data) {
+ // Temporarily fix for using multisites
+ if (isset($data['install_path'])) {
+ $path = preg_replace('~^user/~i', 'user://', $data['install_path']);
+ $data['install_path'] = Grav::instance()['locator']->findResource($path, false, true);
+ }
+ $this->items[$slug] = new Package($data, $this->type);
+ }
+ }
+
+ public function fetch($refresh = false, $callback = null)
+ {
+ if (!$this->raw || $refresh) {
+ $response = Response::get($this->repository, [], $callback);
+ $this->raw = $response;
+ $this->cache->save(md5($this->repository), $this->raw, $this->lifetime);
+ }
+
+ return $this->raw;
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Remote/GravCore.php b/system/src/Grav/Common/GPM/Remote/GravCore.php
new file mode 100644
index 0000000..1d30120
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Remote/GravCore.php
@@ -0,0 +1,141 @@
+get('system.gpm.releases', 'stable');
+ $cache_dir = Grav::instance()['locator']->findResource('cache://gpm', true, true);
+ $this->cache = new FilesystemCache($cache_dir);
+ $this->repository .= '?v=' . GRAV_VERSION . '&' . $channel . '=1';
+ $this->raw = $this->cache->fetch(md5($this->repository));
+
+ $this->fetch($refresh, $callback);
+
+ $this->data = json_decode($this->raw, true);
+ $this->version = $this->data['version'] ?? '-';
+ $this->date = $this->data['date'] ?? '-';
+ $this->min_php = $this->data['min_php'] ?? null;
+
+ if (isset($this->data['assets'])) {
+ foreach ((array)$this->data['assets'] as $slug => $data) {
+ $this->items[$slug] = new Package($data);
+ }
+ }
+ }
+
+ /**
+ * Returns the list of assets associated to the latest version of Grav
+ *
+ * @return array list of assets
+ */
+ public function getAssets()
+ {
+ return $this->data['assets'];
+ }
+
+ /**
+ * Returns the changelog list for each version of Grav
+ *
+ * @param string $diff the version number to start the diff from
+ *
+ * @return array changelog list for each version
+ */
+ public function getChangelog($diff = null)
+ {
+ if (!$diff) {
+ return $this->data['changelog'];
+ }
+
+ $diffLog = [];
+ foreach ((array)$this->data['changelog'] as $version => $changelog) {
+ preg_match("/[\w\-\.]+/", $version, $cleanVersion);
+
+ if (!$cleanVersion || version_compare($diff, $cleanVersion[0], '>=')) {
+ continue;
+ }
+
+ $diffLog[$version] = $changelog;
+ }
+
+ return $diffLog;
+ }
+
+ /**
+ * Return the release date of the latest Grav
+ *
+ * @return string
+ */
+ public function getDate()
+ {
+ return $this->date;
+ }
+
+ /**
+ * Determine if this version of Grav is eligible to be updated
+ *
+ * @return mixed
+ */
+ public function isUpdatable()
+ {
+ return version_compare(GRAV_VERSION, $this->getVersion(), '<');
+ }
+
+ /**
+ * Returns the latest version of Grav available remotely
+ *
+ * @return string
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Returns the minimum PHP version
+ *
+ * @return null|string
+ */
+ public function getMinPHPVersion()
+ {
+ // If non min set, assume current PHP version
+ if (null === $this->min_php) {
+ $this->min_php = phpversion();
+ }
+ return $this->min_php;
+ }
+
+ /**
+ * Is this installation symlinked?
+ *
+ * @return bool
+ */
+ public function isSymlink()
+ {
+ return is_link(GRAV_ROOT . DS . 'index.php');
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Remote/Package.php b/system/src/Grav/Common/GPM/Remote/Package.php
new file mode 100644
index 0000000..196e92b
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Remote/Package.php
@@ -0,0 +1,27 @@
+data;
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Remote/Packages.php b/system/src/Grav/Common/GPM/Remote/Packages.php
new file mode 100644
index 0000000..46bc31f
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Remote/Packages.php
@@ -0,0 +1,25 @@
+ new Plugins($refresh, $callback),
+ 'themes' => new Themes($refresh, $callback)
+ ];
+
+ parent::__construct($items);
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Remote/Plugins.php b/system/src/Grav/Common/GPM/Remote/Plugins.php
new file mode 100644
index 0000000..1d905e3
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Remote/Plugins.php
@@ -0,0 +1,30 @@
+repository, $refresh, $callback);
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Remote/Themes.php b/system/src/Grav/Common/GPM/Remote/Themes.php
new file mode 100644
index 0000000..8024b40
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Remote/Themes.php
@@ -0,0 +1,30 @@
+repository, $refresh, $callback);
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Response.php b/system/src/Grav/Common/GPM/Response.php
new file mode 100644
index 0000000..c444ee8
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Response.php
@@ -0,0 +1,436 @@
+ [
+ CURLOPT_USERAGENT => 'Grav GPM',
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_FAILONERROR => true,
+ CURLOPT_TIMEOUT => 15,
+ CURLOPT_HEADER => false,
+ //CURLOPT_SSL_VERIFYPEER => true, // this is set in the constructor since it's a setting
+ /**
+ * Example of callback parameters from within your own class
+ */
+ //CURLOPT_NOPROGRESS => false,
+ //CURLOPT_PROGRESSFUNCTION => [$this, 'progress']
+ ],
+ 'fopen' => [
+ 'method' => 'GET',
+ 'user_agent' => 'Grav GPM',
+ 'max_redirects' => 5,
+ 'follow_location' => 1,
+ 'timeout' => 15,
+ /* // this is set in the constructor since it's a setting
+ 'ssl' => [
+ 'verify_peer' => true,
+ 'verify_peer_name' => true,
+ ],
+ */
+ /**
+ * Example of callback parameters from within your own class
+ */
+ //'notification' => [$this, 'progress']
+ ]
+ ];
+
+ /**
+ * Sets the preferred method to use for making HTTP calls.
+ *
+ * @param string $method Default is `auto`
+ *
+ * @return Response
+ */
+ public static function setMethod($method = 'auto')
+ {
+ if (!\in_array($method, ['auto', 'curl', 'fopen'], true)) {
+ $method = 'auto';
+ }
+
+ self::$method = $method;
+
+ return new self();
+ }
+
+ /**
+ * Makes a request to the URL by using the preferred method
+ *
+ * @param string $uri URL to call
+ * @param array $options An array of parameters for both `curl` and `fopen`
+ * @param callable $callback Either a function or callback in array notation
+ *
+ * @return string The response of the request
+ */
+ public static function get($uri = '', $options = [], $callback = null)
+ {
+ if (!self::isCurlAvailable() && !self::isFopenAvailable()) {
+ throw new \RuntimeException('Could not start an HTTP request. `allow_url_open` is disabled and `cURL` is not available');
+ }
+
+ // check if this function is available, if so use it to stop any timeouts
+ try {
+ if (function_exists('set_time_limit') && !Utils::isFunctionDisabled('set_time_limit')) {
+ set_time_limit(0);
+ }
+ } catch (\Exception $e) {
+ }
+
+ $config = Grav::instance()['config'];
+ $overrides = [];
+
+ // Override CA Bundle
+ $caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
+ if (is_dir($caPathOrFile) || (is_link($caPathOrFile) && is_dir(readlink($caPathOrFile)))) {
+ $overrides['curl'][CURLOPT_CAPATH] = $caPathOrFile;
+ $overrides['fopen']['ssl']['capath'] = $caPathOrFile;
+ } else {
+ $overrides['curl'][CURLOPT_CAINFO] = $caPathOrFile;
+ $overrides['fopen']['ssl']['cafile'] = $caPathOrFile;
+ }
+
+ // SSL Verify Peer and Proxy Setting
+ $settings = [
+ 'method' => $config->get('system.gpm.method', self::$method),
+ 'verify_peer' => $config->get('system.gpm.verify_peer', true),
+ // `system.proxy_url` is for fallback
+ // introduced with 1.1.0-beta.1 probably safe to remove at some point
+ 'proxy_url' => $config->get('system.gpm.proxy_url', $config->get('system.proxy_url', false)),
+ ];
+
+ if (!$settings['verify_peer']) {
+ $overrides = array_replace_recursive([], $overrides, [
+ 'curl' => [
+ CURLOPT_SSL_VERIFYPEER => $settings['verify_peer']
+ ],
+ 'fopen' => [
+ 'ssl' => [
+ 'verify_peer' => $settings['verify_peer'],
+ 'verify_peer_name' => $settings['verify_peer'],
+ ]
+ ]
+ ]);
+ }
+
+ // Proxy Setting
+ if ($settings['proxy_url']) {
+ $proxy = parse_url($settings['proxy_url']);
+ $fopen_proxy = ($proxy['scheme'] ?: 'http') . '://' . $proxy['host'] . (isset($proxy['port']) ? ':' . $proxy['port'] : '');
+
+ $overrides = array_replace_recursive([], $overrides, [
+ 'curl' => [
+ CURLOPT_PROXY => $proxy['host'],
+ CURLOPT_PROXYTYPE => 'HTTP'
+ ],
+ 'fopen' => [
+ 'proxy' => $fopen_proxy,
+ 'request_fulluri' => true
+ ]
+ ]);
+
+ if (isset($proxy['port'])) {
+ $overrides['curl'][CURLOPT_PROXYPORT] = $proxy['port'];
+ }
+
+ if (isset($proxy['user'], $proxy['pass'])) {
+ $fopen_auth = $auth = base64_encode($proxy['user'] . ':' . $proxy['pass']);
+ $overrides['curl'][CURLOPT_PROXYUSERPWD] = $proxy['user'] . ':' . $proxy['pass'];
+ $overrides['fopen']['header'] = "Proxy-Authorization: Basic $fopen_auth";
+ }
+ }
+
+ $options = array_replace_recursive(self::$defaults, $options, $overrides);
+ $method = 'get' . ucfirst(strtolower($settings['method']));
+
+ self::$callback = $callback;
+ return static::$method($uri, $options, $callback);
+ }
+
+ /**
+ * Checks if cURL is available
+ *
+ * @return bool
+ */
+ public static function isCurlAvailable()
+ {
+ return function_exists('curl_version');
+ }
+
+ /**
+ * Checks if the remote fopen request is enabled in PHP
+ *
+ * @return bool
+ */
+ public static function isFopenAvailable()
+ {
+ return preg_match('/1|yes|on|true/i', ini_get('allow_url_fopen'));
+ }
+
+ /**
+ * Is this a remote file or not
+ *
+ * @param string $file
+ * @return bool
+ */
+ public static function isRemote($file)
+ {
+ return (bool) filter_var($file, FILTER_VALIDATE_URL);
+ }
+
+ /**
+ * Progress normalized for cURL and Fopen
+ * Accepts a variable length of arguments passed in by stream method
+ */
+ public static function progress()
+ {
+ static $filesize = null;
+
+ $args = func_get_args();
+ $isCurlResource = is_resource($args[0]) && get_resource_type($args[0]) === 'curl';
+
+ $notification_code = !$isCurlResource ? $args[0] : false;
+ $bytes_transferred = $isCurlResource ? $args[2] : $args[4];
+
+ if ($isCurlResource) {
+ $filesize = $args[1];
+ } elseif ($notification_code == STREAM_NOTIFY_FILE_SIZE_IS) {
+ $filesize = $args[5];
+ }
+
+ if ($bytes_transferred > 0) {
+ if ($notification_code == STREAM_NOTIFY_PROGRESS | STREAM_NOTIFY_COMPLETED || $isCurlResource) {
+
+ $progress = [
+ 'code' => $notification_code,
+ 'filesize' => $filesize,
+ 'transferred' => $bytes_transferred,
+ 'percent' => $filesize <= 0 ? '-' : round(($bytes_transferred * 100) / $filesize, 1)
+ ];
+
+ if (self::$callback !== null) {
+ call_user_func(self::$callback, $progress);
+ }
+ }
+ }
+ }
+
+ /**
+ * Automatically picks the preferred method
+ *
+ * @return string The response of the request
+ */
+ private static function getAuto()
+ {
+ if (!ini_get('open_basedir') && self::isFopenAvailable()) {
+ return self::getFopen(func_get_args());
+ }
+
+ if (self::isCurlAvailable()) {
+ return self::getCurl(func_get_args());
+ }
+
+ return null;
+ }
+
+ /**
+ * Starts a HTTP request via fopen
+ *
+ * @return string The response of the request
+ */
+ private static function getFopen()
+ {
+ if (\count($args = func_get_args()) === 1) {
+ $args = $args[0];
+ }
+
+ $uri = $args[0];
+ $options = $args[1] ?? [];
+ $callback = $args[2] ?? null;
+
+ if ($callback) {
+ $options['fopen']['notification'] = ['self', 'progress'];
+ }
+
+ $options['fopen']['header'] = 'Referer: ' . Grav::instance()['uri']->rootUrl(true);
+ if (isset($options['fopen']['ssl'])) {
+ $ssl = $options['fopen']['ssl'];
+ unset($options['fopen']['ssl']);
+
+ $stream = stream_context_create([
+ 'http' => $options['fopen'],
+ 'ssl' => $ssl
+ ], $options['fopen']);
+ } else {
+ $stream = stream_context_create(['http' => $options['fopen']], $options['fopen']);
+ }
+
+
+ $content = @file_get_contents($uri, false, $stream);
+
+ if ($content === false) {
+ $code = null;
+ // Function file_get_contents() creates local variable $http_response_header, check it
+ if (isset($http_response_header)) {
+ $code = explode(' ', $http_response_header[0] ?? '')[1] ?? null;
+ }
+
+ switch ($code) {
+ case '404':
+ throw new \RuntimeException('Page not found');
+ case '401':
+ throw new \RuntimeException('Invalid LICENSE');
+ default:
+ throw new \RuntimeException("Error while trying to download (code: {$code}): {$uri}\n");
+ }
+ }
+
+ return $content;
+ }
+
+ /**
+ * Starts a HTTP request via cURL
+ *
+ * @return string The response of the request
+ */
+ private static function getCurl()
+ {
+ $args = func_get_args();
+ $args = count($args) > 1 ? $args : array_shift($args);
+
+ $uri = $args[0];
+ $options = $args[1] ?? [];
+ $callback = $args[2] ?? null;
+
+ $ch = curl_init($uri);
+
+ $response = static::curlExecFollow($ch, $options, $callback);
+ $errno = curl_errno($ch);
+
+ if ($errno) {
+ $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ $error_message = curl_strerror($errno) . "\n" . curl_error($ch);
+
+ switch ($code) {
+ case '404':
+ throw new \RuntimeException('Page not found');
+ case '401':
+ throw new \RuntimeException('Invalid LICENSE');
+ default:
+ throw new \RuntimeException("Error while trying to download (code: $code): $uri \nMessage: $error_message");
+ }
+ }
+
+ curl_close($ch);
+
+ return $response;
+ }
+
+ /**
+ * @param resource $ch
+ * @param array $options
+ * @param bool $callback
+ *
+ * @return bool|mixed
+ */
+ private static function curlExecFollow($ch, $options, $callback)
+ {
+ curl_setopt_array($ch, [ CURLOPT_REFERER => Grav::instance()['uri']->rootUrl(true) ]);
+
+ if ($callback) {
+ curl_setopt_array(
+ $ch,
+ [
+ CURLOPT_NOPROGRESS => false,
+ CURLOPT_PROGRESSFUNCTION => ['self', 'progress']
+ ]
+ );
+ }
+
+ // no open_basedir set, we can proceed normally
+ if (!ini_get('open_basedir')) {
+ curl_setopt_array($ch, $options['curl']);
+ return curl_exec($ch);
+ }
+
+ $max_redirects = $options['curl'][CURLOPT_MAXREDIRS] ?? 5;
+ $options['curl'][CURLOPT_FOLLOWLOCATION] = false;
+
+ // open_basedir set but no redirects to follow, we can disable followlocation and proceed normally
+ curl_setopt_array($ch, $options['curl']);
+ if ($max_redirects <= 0) {
+ return curl_exec($ch);
+ }
+
+ $uri = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
+ $rch = curl_copy_handle($ch);
+
+ curl_setopt($rch, CURLOPT_HEADER, true);
+ curl_setopt($rch, CURLOPT_NOBODY, true);
+ curl_setopt($rch, CURLOPT_FORBID_REUSE, false);
+ curl_setopt($rch, CURLOPT_RETURNTRANSFER, true);
+
+ do {
+ curl_setopt($rch, CURLOPT_URL, $uri);
+ $header = curl_exec($rch);
+
+ if (curl_errno($rch)) {
+ $code = 0;
+ } else {
+ $code = (int)curl_getinfo($rch, CURLINFO_HTTP_CODE);
+ if ($code === 301 || $code === 302 || $code === 303) {
+ preg_match('/(?:^|\n)Location:(.*?)\n/i', $header, $matches);
+ $uri = trim(array_pop($matches));
+ } else {
+ $code = 0;
+ }
+ }
+ } while ($code && --$max_redirects);
+
+ curl_close($rch);
+
+ if (!$max_redirects) {
+ if ($max_redirects === null) {
+ trigger_error('Too many redirects. When following redirects, libcurl hit the maximum amount.', E_USER_WARNING);
+ }
+
+ return false;
+ }
+
+ curl_setopt($ch, CURLOPT_URL, $uri);
+
+ return curl_exec($ch);
+ }
+}
diff --git a/system/src/Grav/Common/GPM/Upgrader.php b/system/src/Grav/Common/GPM/Upgrader.php
new file mode 100644
index 0000000..5d9406d
--- /dev/null
+++ b/system/src/Grav/Common/GPM/Upgrader.php
@@ -0,0 +1,142 @@
+remote = new Remote\GravCore($refresh, $callback);
+ }
+
+ /**
+ * Returns the release date of the latest version of Grav
+ *
+ * @return string
+ */
+ public function getReleaseDate()
+ {
+ return $this->remote->getDate();
+ }
+
+ /**
+ * Returns the version of the installed Grav
+ *
+ * @return string
+ */
+ public function getLocalVersion()
+ {
+ return GRAV_VERSION;
+ }
+
+ /**
+ * Returns the version of the remotely available Grav
+ *
+ * @return string
+ */
+ public function getRemoteVersion()
+ {
+ return $this->remote->getVersion();
+ }
+
+ /**
+ * Returns an array of assets available to download remotely
+ *
+ * @return array
+ */
+ public function getAssets()
+ {
+ return $this->remote->getAssets();
+ }
+
+ /**
+ * Returns the changelog list for each version of Grav
+ *
+ * @param string $diff the version number to start the diff from
+ *
+ * @return array return the changelog list for each version
+ */
+ public function getChangelog($diff = null)
+ {
+ return $this->remote->getChangelog($diff);
+ }
+
+ /**
+ * Make sure this meets minimum PHP requirements
+ *
+ * @return bool
+ */
+ public function meetsRequirements()
+ {
+ $current_php_version = phpversion();
+ if (version_compare($current_php_version, $this->minPHPVersion(), '<')) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Get minimum PHP version from remote
+ *
+ * @return null
+ */
+ public function minPHPVersion()
+ {
+ if (null === $this->min_php) {
+ $this->min_php = $this->remote->getMinPHPVersion();
+ }
+ return $this->min_php;
+ }
+
+ /**
+ * Checks if the currently installed Grav is upgradable to a newer version
+ *
+ * @return boolean True if it's upgradable, False otherwise.
+ */
+ public function isUpgradable()
+ {
+ return version_compare($this->getLocalVersion(), $this->getRemoteVersion(), '<');
+ }
+
+ /**
+ * Checks if Grav is currently symbolically linked
+ *
+ * @return boolean True if Grav is symlinked, False otherwise.
+ */
+
+ public function isSymlink()
+ {
+ return $this->remote->isSymlink();
+ }
+}
diff --git a/system/src/Grav/Common/Getters.php b/system/src/Grav/Common/Getters.php
new file mode 100644
index 0000000..e69116e
--- /dev/null
+++ b/system/src/Grav/Common/Getters.php
@@ -0,0 +1,161 @@
+offsetSet($offset, $value);
+ }
+
+ /**
+ * Magic getter method
+ *
+ * @param mixed $offset Medium name value
+ *
+ * @return mixed Medium value
+ */
+ public function __get($offset)
+ {
+ return $this->offsetGet($offset);
+ }
+
+ /**
+ * Magic method to determine if the attribute is set
+ *
+ * @param mixed $offset Medium name value
+ *
+ * @return boolean True if the value is set
+ */
+ public function __isset($offset)
+ {
+ return $this->offsetExists($offset);
+ }
+
+ /**
+ * Magic method to unset the attribute
+ *
+ * @param mixed $offset The name value to unset
+ */
+ public function __unset($offset)
+ {
+ $this->offsetUnset($offset);
+ }
+
+ /**
+ * @param mixed $offset
+ *
+ * @return bool
+ */
+ public function offsetExists($offset)
+ {
+ if ($this->gettersVariable) {
+ $var = $this->gettersVariable;
+
+ return isset($this->{$var}[$offset]);
+ }
+
+ return isset($this->{$offset});
+ }
+
+ /**
+ * @param mixed $offset
+ *
+ * @return mixed
+ */
+ public function offsetGet($offset)
+ {
+ if ($this->gettersVariable) {
+ $var = $this->gettersVariable;
+
+ return $this->{$var}[$offset] ?? null;
+ }
+
+ return $this->{$offset} ?? null;
+ }
+
+ /**
+ * @param mixed $offset
+ * @param mixed $value
+ */
+ public function offsetSet($offset, $value)
+ {
+ if ($this->gettersVariable) {
+ $var = $this->gettersVariable;
+ $this->{$var}[$offset] = $value;
+ } else {
+ $this->{$offset} = $value;
+ }
+ }
+
+ /**
+ * @param mixed $offset
+ */
+ public function offsetUnset($offset)
+ {
+ if ($this->gettersVariable) {
+ $var = $this->gettersVariable;
+ unset($this->{$var}[$offset]);
+ } else {
+ unset($this->{$offset});
+ }
+ }
+
+ /**
+ * @return int
+ */
+ public function count()
+ {
+ if ($this->gettersVariable) {
+ $var = $this->gettersVariable;
+ return \count($this->{$var});
+ }
+
+ return \count($this->toArray());
+ }
+
+ /**
+ * Returns an associative array of object properties.
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ if ($this->gettersVariable) {
+ $var = $this->gettersVariable;
+
+ return $this->{$var};
+ }
+
+ $properties = (array)$this;
+ $list = [];
+ foreach ($properties as $property => $value) {
+ if ($property[0] !== "\0") {
+ $list[$property] = $value;
+ }
+ }
+
+ return $list;
+ }
+}
diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php
new file mode 100644
index 0000000..458fe16
--- /dev/null
+++ b/system/src/Grav/Common/Grav.php
@@ -0,0 +1,618 @@
+ 'Grav\Common\Browser',
+ 'cache' => 'Grav\Common\Cache',
+ 'events' => 'RocketTheme\Toolbox\Event\EventDispatcher',
+ 'exif' => 'Grav\Common\Helpers\Exif',
+ 'plugins' => 'Grav\Common\Plugins',
+ 'scheduler' => 'Grav\Common\Scheduler\Scheduler',
+ 'taxonomy' => 'Grav\Common\Taxonomy',
+ 'themes' => 'Grav\Common\Themes',
+ 'twig' => 'Grav\Common\Twig\Twig',
+ 'uri' => 'Grav\Common\Uri',
+ ];
+
+ /**
+ * @var array All middleware processors that are processed in $this->process()
+ */
+ protected $middleware = [
+ 'configurationProcessor',
+ 'loggerProcessor',
+ 'errorsProcessor',
+ 'debuggerProcessor',
+ 'initializeProcessor',
+ 'pluginsProcessor',
+ 'themesProcessor',
+ 'requestProcessor',
+ 'tasksProcessor',
+ 'backupsProcessor',
+ 'schedulerProcessor',
+ 'assetsProcessor',
+ 'twigProcessor',
+ 'pagesProcessor',
+ 'debuggerAssetsProcessor',
+ 'renderProcessor',
+ ];
+
+ protected $initialized = [];
+
+ /**
+ * Reset the Grav instance.
+ */
+ public static function resetInstance()
+ {
+ if (self::$instance) {
+ self::$instance = null;
+ }
+ }
+
+ /**
+ * Return the Grav instance. Create it if it's not already instanced
+ *
+ * @param array $values
+ *
+ * @return Grav
+ */
+ public static function instance(array $values = [])
+ {
+ if (!self::$instance) {
+ self::$instance = static::load($values);
+ } elseif ($values) {
+ $instance = self::$instance;
+ foreach ($values as $key => $value) {
+ $instance->offsetSet($key, $value);
+ }
+ }
+
+ return self::$instance;
+ }
+
+ /**
+ * Setup Grav instance using specific environment.
+ *
+ * Initializes Grav streams by
+ *
+ * @param string|null $environment
+ * @return $this
+ */
+ public function setup(string $environment = null)
+ {
+ if (isset($this->initialized['setup'])) {
+ return $this;
+ }
+
+ $this->initialized['setup'] = true;
+
+ $this->measureTime('_setup', 'Site Setup', function () use ($environment) {
+ // Force environment if passed to the method.
+ if ($environment) {
+ Setup::$environment = $environment;
+ }
+
+ $this['setup'];
+ $this['streams'];
+ });
+
+ return $this;
+ }
+
+ /**
+ * Initialize CLI environment.
+ *
+ * Call after `$grav->setup($environment)`
+ *
+ * - Load configuration
+ * - Disable debugger
+ * - Set timezone, locale
+ * - Load plugins
+ * - Set Users type to be used in the site
+ *
+ * This method WILL NOT initialize assets, twig or pages.
+ *
+ * @param string|null $environment
+ * @return $this
+ */
+ public function initializeCli()
+ {
+ InitializeProcessor::initializeCli($this);
+
+ return $this;
+ }
+
+ /**
+ * Process a request
+ */
+ public function process()
+ {
+ if (isset($this->initialized['process'])) {
+ return;
+ }
+
+ // Initialize Grav if needed.
+ $this->setup();
+
+ $this->initialized['process'] = true;
+
+ $container = new Container(
+ [
+ 'configurationProcessor' => function () {
+ return new ConfigurationProcessor($this);
+ },
+ 'loggerProcessor' => function () {
+ return new LoggerProcessor($this);
+ },
+ 'errorsProcessor' => function () {
+ return new ErrorsProcessor($this);
+ },
+ 'debuggerProcessor' => function () {
+ return new DebuggerProcessor($this);
+ },
+ 'initializeProcessor' => function () {
+ return new InitializeProcessor($this);
+ },
+ 'backupsProcessor' => function () {
+ return new BackupsProcessor($this);
+ },
+ 'pluginsProcessor' => function () {
+ return new PluginsProcessor($this);
+ },
+ 'themesProcessor' => function () {
+ return new ThemesProcessor($this);
+ },
+ 'schedulerProcessor' => function () {
+ return new SchedulerProcessor($this);
+ },
+ 'requestProcessor' => function () {
+ return new RequestProcessor($this);
+ },
+ 'tasksProcessor' => function () {
+ return new TasksProcessor($this);
+ },
+ 'assetsProcessor' => function () {
+ return new AssetsProcessor($this);
+ },
+ 'twigProcessor' => function () {
+ return new TwigProcessor($this);
+ },
+ 'pagesProcessor' => function () {
+ return new PagesProcessor($this);
+ },
+ 'debuggerAssetsProcessor' => function () {
+ return new DebuggerAssetsProcessor($this);
+ },
+ 'renderProcessor' => function () {
+ return new RenderProcessor($this);
+ },
+ ]
+ );
+
+ $default = function (ServerRequestInterface $request) {
+ return new Response(404, ['Expires' => 0, 'Cache-Control' => 'no-cache, no-store, must-revalidate'], 'Not Found');
+ };
+
+ /** @var Debugger $debugger */
+ $debugger = $this['debugger'];
+
+ $collection = new RequestHandler($this->middleware, $default, $container);
+
+ $response = $collection->handle($this['request']);
+ $body = $response->getBody();
+
+ // Handle ETag and If-None-Match headers.
+ if ($response->getHeaderLine('ETag') === '1') {
+ $etag = md5($body);
+ $response = $response->withHeader('ETag', $etag);
+
+ if ($this['request']->getHeaderLine('If-None-Match') === $etag) {
+ $response = $response->withStatus(304);
+ $body = '';
+ }
+ }
+
+ $this->header($response);
+ echo $body;
+
+ $debugger->render();
+
+ register_shutdown_function([$this, 'shutdown']);
+ }
+
+ /**
+ * Set the system locale based on the language and configuration
+ */
+ public function setLocale()
+ {
+ // Initialize Locale if set and configured.
+ if ($this['language']->enabled() && $this['config']->get('system.languages.override_locale')) {
+ $language = $this['language']->getLanguage();
+ setlocale(LC_ALL, \strlen($language) < 3 ? ($language . '_' . strtoupper($language)) : $language);
+ } elseif ($this['config']->get('system.default_locale')) {
+ setlocale(LC_ALL, $this['config']->get('system.default_locale'));
+ }
+ }
+
+ /**
+ * Redirect browser to another location.
+ *
+ * @param string $route Internal route.
+ * @param int $code Redirection code (30x)
+ */
+ public function redirect($route, $code = null)
+ {
+ /** @var Uri $uri */
+ $uri = $this['uri'];
+
+ // Clean route for redirect
+ $route = preg_replace("#^\/[\\\/]+\/#", '/', $route);
+
+ // Check for code in route
+ $regex = '/.*(\[(30[1-7])\])$/';
+ preg_match($regex, $route, $matches);
+ if ($matches) {
+ $route = str_replace($matches[1], '', $matches[0]);
+ $code = $matches[2];
+ }
+
+ if ($code === null) {
+ $code = $this['config']->get('system.pages.redirect_default_code', 302);
+ }
+
+ if (isset($this['session'])) {
+ $this['session']->close();
+ }
+
+ if ($uri->isExternal($route)) {
+ $url = $route;
+ } else {
+ $url = rtrim($uri->rootUrl(), '/') . '/';
+
+ if ($this['config']->get('system.pages.redirect_trailing_slash', true)) {
+ $url .= trim($route, '/'); // Remove trailing slash
+ } else {
+ $url .= ltrim($route, '/'); // Support trailing slash default routes
+ }
+ }
+
+ header("Location: {$url}", true, $code);
+ exit();
+ }
+
+ /**
+ * Redirect browser to another location taking language into account (preferred)
+ *
+ * @param string $route Internal route.
+ * @param int $code Redirection code (30x)
+ */
+ public function redirectLangSafe($route, $code = null)
+ {
+ if (!$this['uri']->isExternal($route)) {
+ $this->redirect($this['pages']->route($route), $code);
+ } else {
+ $this->redirect($route, $code);
+ }
+ }
+
+ /**
+ * Set response header.
+ *
+ * @param ResponseInterface|null $response
+ */
+ public function header(ResponseInterface $response = null)
+ {
+ if (null === $response) {
+ /** @var PageInterface $page */
+ $page = $this['page'];
+ $response = new Response($page->httpResponseCode(), $page->httpHeaders(), '');
+ }
+
+ header("HTTP/{$response->getProtocolVersion()} {$response->getStatusCode()} {$response->getReasonPhrase()}");
+ foreach ($response->getHeaders() as $key => $values) {
+ foreach ($values as $i => $value) {
+ header($key . ': ' . $value, $i === 0);
+ }
+ }
+ }
+
+ /**
+ * Fires an event with optional parameters.
+ *
+ * @param string $eventName
+ * @param Event $event
+ *
+ * @return Event
+ */
+ public function fireEvent($eventName, Event $event = null)
+ {
+ /** @var EventDispatcher $events */
+ $events = $this['events'];
+
+ return $events->dispatch($eventName, $event);
+ }
+
+ /**
+ * Set the final content length for the page and flush the buffer
+ *
+ */
+ public function shutdown()
+ {
+ // Prevent user abort allowing onShutdown event to run without interruptions.
+ if (\function_exists('ignore_user_abort')) {
+ @ignore_user_abort(true);
+ }
+
+ // Close the session allowing new requests to be handled.
+ if (isset($this['session'])) {
+ $this['session']->close();
+ }
+
+ if ($this['config']->get('system.debugger.shutdown.close_connection', true)) {
+ // Flush the response and close the connection to allow time consuming tasks to be performed without leaving
+ // the connection to the client open. This will make page loads to feel much faster.
+
+ // FastCGI allows us to flush all response data to the client and finish the request.
+ $success = \function_exists('fastcgi_finish_request') ? @fastcgi_finish_request() : false;
+
+ if (!$success) {
+ // Unfortunately without FastCGI there is no way to force close the connection.
+ // We need to ask browser to close the connection for us.
+ if ($this['config']->get('system.cache.gzip')) {
+ // Flush gzhandler buffer if gzip setting was enabled.
+ ob_end_flush();
+
+ } else {
+ // Without gzip we have no other choice than to prevent server from compressing the output.
+ // This action turns off mod_deflate which would prevent us from closing the connection.
+ if ($this['config']->get('system.cache.allow_webserver_gzip')) {
+ header('Content-Encoding: identity');
+ } else {
+ header('Content-Encoding: none');
+ }
+
+ }
+
+
+ // Get length and close the connection.
+ header('Content-Length: ' . ob_get_length());
+ header('Connection: close');
+
+ ob_end_flush();
+ @ob_flush();
+ flush();
+ }
+ }
+
+ // Run any time consuming tasks.
+ $this->fireEvent('onShutdown');
+ }
+
+ /**
+ * Magic Catch All Function
+ *
+ * Used to call closures.
+ *
+ * Source: http://stackoverflow.com/questions/419804/closures-as-class-members
+ *
+ * @param string $method
+ * @param array $args
+ * @return
+ */
+ public function __call($method, $args)
+ {
+ $closure = $this->{$method} ?? null;
+
+ return is_callable($closure) ? $closure(...$args) : null;
+ }
+
+ /**
+ * Measure how long it takes to do an action.
+ *
+ * @param string $timerId
+ * @param string $timerTitle
+ * @param callable $callback
+ * @return mixed Returns value returned by the callable.
+ */
+ public function measureTime(string $timerId, string $timerTitle, callable $callback)
+ {
+ $debugger = $this['debugger'];
+ $debugger->startTimer($timerId, $timerTitle);
+ $result = $callback();
+ $debugger->stopTimer($timerId);
+
+ return $result;
+ }
+
+ /**
+ * Initialize and return a Grav instance
+ *
+ * @param array $values
+ *
+ * @return static
+ */
+ protected static function load(array $values)
+ {
+ $container = new static($values);
+
+ $container['debugger'] = new Debugger();
+ $container['grav'] = function (Container $container) {
+ user_error('Calling $grav[\'grav\'] or {{ grav.grav }} is deprecated since Grav 1.6, just use $grav or {{ grav }}', E_USER_DEPRECATED);
+
+ return $container;
+ };
+
+ $container->measureTime('_services', 'Services', function () use ($container) {
+ $container->registerServices();
+ });
+
+ return $container;
+ }
+
+ /**
+ * Register all services
+ * Services are defined in the diMap. They can either only the class
+ * of a Service Provider or a pair of serviceKey => serviceClass that
+ * gets directly mapped into the container.
+ *
+ * @return void
+ */
+ protected function registerServices()
+ {
+ foreach (self::$diMap as $serviceKey => $serviceClass) {
+ if (\is_int($serviceKey)) {
+ $this->register(new $serviceClass);
+ } else {
+ $this[$serviceKey] = function ($c) use ($serviceClass) {
+ return new $serviceClass($c);
+ };
+ }
+ }
+ }
+
+ /**
+ * This attempts to find media, other files, and download them
+ *
+ * @param string $path
+ */
+ public function fallbackUrl($path)
+ {
+ $this->fireEvent('onPageFallBackUrl');
+
+ /** @var Uri $uri */
+ $uri = $this['uri'];
+
+ /** @var Config $config */
+ $config = $this['config'];
+
+ $uri_extension = strtolower($uri->extension());
+ $fallback_types = $config->get('system.media.allowed_fallback_types', null);
+ $supported_types = $config->get('media.types');
+
+ // Check whitelist first, then ensure extension is a valid media type
+ if (!empty($fallback_types) && !\in_array($uri_extension, $fallback_types, true)) {
+ return false;
+ }
+ if (!array_key_exists($uri_extension, $supported_types)) {
+ return false;
+ }
+
+ $path_parts = pathinfo($path);
+
+ /** @var PageInterface $page */
+ $page = $this['pages']->dispatch($path_parts['dirname'], true);
+
+ if ($page) {
+ $media = $page->media()->all();
+ $parsed_url = parse_url(rawurldecode($uri->basename()));
+ $media_file = $parsed_url['path'];
+
+ // if this is a media object, try actions first
+ if (isset($media[$media_file])) {
+ /** @var Medium $medium */
+ $medium = $media[$media_file];
+ foreach ($uri->query(null, true) as $action => $params) {
+ if (\in_array($action, ImageMedium::$magic_actions, true)) {
+ \call_user_func_array([&$medium, $action], explode(',', $params));
+ }
+ }
+ Utils::download($medium->path(), false);
+ }
+
+ // unsupported media type, try to download it...
+ if ($uri_extension) {
+ $extension = $uri_extension;
+ } else {
+ if (isset($path_parts['extension'])) {
+ $extension = $path_parts['extension'];
+ } else {
+ $extension = null;
+ }
+ }
+
+ if ($extension) {
+ $download = true;
+ if (\in_array(ltrim($extension, '.'), $config->get('system.media.unsupported_inline_types', []), true)) {
+ $download = false;
+ }
+ Utils::download($page->path() . DIRECTORY_SEPARATOR . $uri->basename(), $download);
+ }
+
+ // Nothing found
+ return false;
+ }
+
+ return $page;
+ }
+}
diff --git a/system/src/Grav/Common/GravTrait.php b/system/src/Grav/Common/GravTrait.php
new file mode 100644
index 0000000..a82c23a
--- /dev/null
+++ b/system/src/Grav/Common/GravTrait.php
@@ -0,0 +1,33 @@
+', '?'
+ 0xFF,0x00,0x01,0x02,0x03,0x04,0x05,0x06, // '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G'
+ 0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E, // 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'
+ 0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16, // 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W'
+ 0x17,0x18,0x19,0xFF,0xFF,0xFF,0xFF,0xFF, // 'X', 'Y', 'Z', '[', '\', ']', '^', '_'
+ 0xFF,0x00,0x01,0x02,0x03,0x04,0x05,0x06, // '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g'
+ 0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E, // 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'
+ 0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16, // 'p', 'q', 'r', 's', 't', 'u', 'v', 'w'
+ 0x17,0x18,0x19,0xFF,0xFF,0xFF,0xFF,0xFF // 'x', 'y', 'z', '{', '|', '}', '~', 'DEL'
+ ];
+
+ /**
+ * Encode in Base32
+ *
+ * @param string $bytes
+ * @return string
+ */
+ public static function encode($bytes)
+ {
+ $i = 0; $index = 0;
+ $base32 = '';
+ $bytesLen = \strlen($bytes);
+
+ while ($i < $bytesLen) {
+ $currByte = \ord($bytes[$i]);
+
+ /* Is the current digit going to span a byte boundary? */
+ if ($index > 3) {
+ if (($i + 1) < $bytesLen) {
+ $nextByte = \ord($bytes[$i+1]);
+ } else {
+ $nextByte = 0;
+ }
+
+ $digit = $currByte & (0xFF >> $index);
+ $index = ($index + 5) % 8;
+ $digit <<= $index;
+ $digit |= $nextByte >> (8 - $index);
+ $i++;
+ } else {
+ $digit = ($currByte >> (8 - ($index + 5))) & 0x1F;
+ $index = ($index + 5) % 8;
+ if ($index === 0) {
+ $i++;
+ }
+ }
+
+ $base32 .= self::$base32Chars[$digit];
+ }
+ return $base32;
+ }
+
+ /**
+ * Decode in Base32
+ *
+ * @param string $base32
+ * @return string
+ */
+ public static function decode($base32)
+ {
+ $bytes = [];
+ $base32Len = \strlen($base32);
+ $base32LookupLen = \count(self::$base32Lookup);
+
+ for ($i = $base32Len * 5 / 8 - 1; $i >= 0; --$i) {
+ $bytes[] = 0;
+ }
+
+ for ($i = 0, $index = 0, $offset = 0; $i < $base32Len; $i++) {
+ $lookup = \ord($base32[$i]) - \ord('0');
+
+ /* Skip chars outside the lookup table */
+ if ($lookup < 0 || $lookup >= $base32LookupLen) {
+ continue;
+ }
+
+ $digit = self::$base32Lookup[$lookup];
+
+ /* If this digit is not in the table, ignore it */
+ if ($digit === 0xFF) {
+ continue;
+ }
+
+ if ($index <= 3) {
+ $index = ($index + 5) % 8;
+ if ($index === 0) {
+ $bytes[$offset] |= $digit;
+ $offset++;
+ if ($offset >= \count($bytes)) {
+ break;
+ }
+ } else {
+ $bytes[$offset] |= $digit << (8 - $index);
+ }
+ } else {
+ $index = ($index + 5) % 8;
+ $bytes[$offset] |= ($digit >> $index);
+ $offset++;
+ if ($offset >= \count($bytes)) {
+ break;
+ }
+ $bytes[$offset] |= $digit << (8 - $index);
+ }
+ }
+
+ $bites = '';
+ foreach ($bytes as $byte) {
+ $bites .= \chr($byte);
+ }
+
+ return $bites;
+ }
+}
diff --git a/system/src/Grav/Common/Helpers/Excerpts.php b/system/src/Grav/Common/Helpers/Excerpts.php
new file mode 100644
index 0000000..95e2b14
--- /dev/null
+++ b/system/src/Grav/Common/Helpers/Excerpts.php
@@ -0,0 +1,183 @@
+`
+ * @param PageInterface|null $page Page, defaults to the current page object
+ * @return string Returns final HTML string
+ */
+ public static function processImageHtml($html, PageInterface $page = null)
+ {
+ $excerpt = static::getExcerptFromHtml($html, 'img');
+
+ $original_src = $excerpt['element']['attributes']['src'];
+ $excerpt['element']['attributes']['href'] = $original_src;
+
+ $excerpt = static::processLinkExcerpt($excerpt, $page, 'image');
+
+ $excerpt['element']['attributes']['src'] = $excerpt['element']['attributes']['href'];
+ unset($excerpt['element']['attributes']['href']);
+
+ $excerpt = static::processImageExcerpt($excerpt, $page);
+
+ $excerpt['element']['attributes']['data-src'] = $original_src;
+
+ $html = static::getHtmlFromExcerpt($excerpt);
+
+ return $html;
+ }
+
+ /**
+ * Process Grav page link URL from HTML tag
+ *
+ * @param string $html HTML tag e.g. `Page Link `
+ * @param PageInterface|null $page Page, defaults to the current page object
+ * @return string Returns final HTML string
+ */
+ public static function processLinkHtml($html, PageInterface $page = null)
+ {
+ $excerpt = static::getExcerptFromHtml($html, 'a');
+
+ $original_href = $excerpt['element']['attributes']['href'];
+ $excerpt = static::processLinkExcerpt($excerpt, $page, 'link');
+ $excerpt['element']['attributes']['data-href'] = $original_href;
+
+ $html = static::getHtmlFromExcerpt($excerpt);
+
+ return $html;
+ }
+
+ /**
+ * Get an Excerpt array from a chunk of HTML
+ *
+ * @param string $html Chunk of HTML
+ * @param string $tag A tag, for example `img`
+ * @return array|null returns nested array excerpt
+ */
+ public static function getExcerptFromHtml($html, $tag)
+ {
+ $doc = new \DOMDocument('1.0', 'UTF-8');
+ $internalErrors = libxml_use_internal_errors(true);
+ $doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
+ libxml_use_internal_errors($internalErrors);
+
+ $elements = $doc->getElementsByTagName($tag);
+ $excerpt = null;
+ $inner = [];
+
+ /** @var \DOMElement $element */
+ foreach ($elements as $element) {
+ $attributes = [];
+ foreach ($element->attributes as $name => $value) {
+ $attributes[$name] = $value->value;
+ }
+ $excerpt = [
+ 'element' => [
+ 'name' => $element->tagName,
+ 'attributes' => $attributes
+ ]
+ ];
+
+ foreach ($element->childNodes as $node) {
+ $inner[] = $doc->saveHTML($node);
+ }
+
+ $excerpt = array_merge_recursive($excerpt, ['element' => ['text' => implode('', $inner)]]);
+
+
+ }
+
+ return $excerpt;
+ }
+
+ /**
+ * Rebuild HTML tag from an excerpt array
+ *
+ * @param array $excerpt
+ * @return string
+ */
+ public static function getHtmlFromExcerpt($excerpt)
+ {
+ $element = $excerpt['element'];
+ $html = '<'.$element['name'];
+
+ if (isset($element['attributes'])) {
+ foreach ($element['attributes'] as $name => $value) {
+ if ($value === null) {
+ continue;
+ }
+ $html .= ' '.$name.'="'.$value.'"';
+ }
+ }
+
+ if (isset($element['text'])) {
+ $html .= '>';
+ $html .= is_array($element['text']) ? static::getHtmlFromExcerpt(['element' => $element['text']]) : $element['text'];
+ $html .= ''.$element['name'].'>';
+ } else {
+ $html .= ' />';
+ }
+
+ return $html;
+ }
+
+ /**
+ * Process a Link excerpt
+ *
+ * @param array $excerpt
+ * @param PageInterface|null $page Page, defaults to the current page object
+ * @param string $type
+ * @return mixed
+ */
+ public static function processLinkExcerpt($excerpt, PageInterface $page = null, $type = 'link')
+ {
+ $excerpts = new ExcerptsObject($page);
+
+ return $excerpts->processLinkExcerpt($excerpt, $type);
+ }
+
+ /**
+ * Process an image excerpt
+ *
+ * @param array $excerpt
+ * @param PageInterface|null $page Page, defaults to the current page object
+ * @return array
+ */
+ public static function processImageExcerpt(array $excerpt, PageInterface $page = null)
+ {
+ $excerpts = new ExcerptsObject($page);
+
+ return $excerpts->processImageExcerpt($excerpt);
+ }
+
+ /**
+ * Process media actions
+ *
+ * @param Medium $medium
+ * @param string|array $url
+ * @param PageInterface|null $page Page, defaults to the current page object
+ * @return Medium
+ */
+ public static function processMediaActions($medium, $url, PageInterface $page = null)
+ {
+ $excerpts = new ExcerptsObject($page);
+
+ return $excerpts->processMediaActions($medium, $url);
+ }
+}
diff --git a/system/src/Grav/Common/Helpers/Exif.php b/system/src/Grav/Common/Helpers/Exif.php
new file mode 100644
index 0000000..15aff66
--- /dev/null
+++ b/system/src/Grav/Common/Helpers/Exif.php
@@ -0,0 +1,41 @@
+get('system.media.auto_metadata_exif')) {
+ if (function_exists('exif_read_data') && class_exists('\PHPExif\Reader\Reader')) {
+ $this->reader = \PHPExif\Reader\Reader::factory(\PHPExif\Reader\Reader::TYPE_NATIVE);
+ } else {
+ throw new \RuntimeException('Please enable the Exif extension for PHP or disable Exif support in Grav system configuration');
+ }
+ }
+ }
+
+ public function getReader()
+ {
+ if ($this->reader) {
+ return $this->reader;
+ }
+
+ return false;
+ }
+}
diff --git a/system/src/Grav/Common/Helpers/LogViewer.php b/system/src/Grav/Common/Helpers/LogViewer.php
new file mode 100644
index 0000000..397fb17
--- /dev/null
+++ b/system/src/Grav/Common/Helpers/LogViewer.php
@@ -0,0 +1,149 @@
+.*)\] (?P\w+).(?P\w+): (?P.*[^ ]+) (?P[^ ]+) (?P[^ ]+)/';
+
+ /**
+ * Get the objects of a tailed file
+ *
+ * @param string $filepath
+ * @param int $lines
+ * @param bool $desc
+ * @return array
+ */
+ public function objectTail($filepath, $lines = 1, $desc = true)
+ {
+ $data = $this->tail($filepath, $lines);
+ $tailed_log = explode(PHP_EOL, $data);
+ $line_objects = [];
+
+ foreach ($tailed_log as $line) {
+ $line_objects[] = $this->parse($line);
+ }
+
+ return $desc ? $line_objects : array_reverse($line_objects);
+ }
+
+ /**
+ * Optimized way to get just the last few entries of a log file
+ *
+ * @param string $filepath
+ * @param int $lines
+ * @return bool|string
+ */
+ public function tail($filepath, $lines = 1) {
+
+ $f = @fopen($filepath, "rb");
+ if ($f === false) return false;
+
+ else $buffer = ($lines < 2 ? 64 : ($lines < 10 ? 512 : 4096));
+
+ fseek($f, -1, SEEK_END);
+ if (fread($f, 1) != "\n") $lines -= 1;
+
+ // Start reading
+ $output = '';
+ $chunk = '';
+ // While we would like more
+ while (ftell($f) > 0 && $lines >= 0) {
+ // Figure out how far back we should jump
+ $seek = min(ftell($f), $buffer);
+ // Do the jump (backwards, relative to where we are)
+ fseek($f, -$seek, SEEK_CUR);
+ // Read a chunk and prepend it to our output
+ $output = ($chunk = fread($f, $seek)) . $output;
+ // Jump back to where we started reading
+ fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR);
+ // Decrease our line counter
+ $lines -= substr_count($chunk, "\n");
+ }
+ // While we have too many lines
+ // (Because of buffer size we might have read too many)
+ while ($lines++ < 0) {
+ // Find first newline and remove all text before that
+ $output = substr($output, strpos($output, "\n") + 1);
+ }
+ // Close file and return
+ fclose($f);
+
+ return trim($output);
+ }
+
+ /**
+ * Helper class to get level color
+ *
+ * @param string $level
+ * @return mixed|string
+ */
+ public static function levelColor($level)
+ {
+ $colors = [
+ 'DEBUG' => 'green',
+ 'INFO' => 'cyan',
+ 'NOTICE' => 'yellow',
+ 'WARNING' => 'yellow',
+ 'ERROR' => 'red',
+ 'CRITICAL' => 'red',
+ 'ALERT' => 'red',
+ 'EMERGENCY' => 'magenta'
+ ];
+ return $colors[$level] ?? 'white';
+ }
+
+ /**
+ * Parse a monolog row into array bits
+ *
+ * @param string $line
+ * @return array
+ */
+ public function parse($line)
+ {
+ if( !is_string($line) || strlen($line) === 0) {
+ return array();
+ }
+ preg_match($this->pattern, $line, $data);
+ if (!isset($data['date'])) {
+ return array();
+ }
+
+ preg_match('/(.*)- Trace:(.*)/', $data['message'], $matches);
+ if (is_array($matches) && isset($matches[1])) {
+ $data['message'] = trim($matches[1]);
+ $data['trace'] = trim($matches[2]);
+ }
+
+ return array(
+ 'date' => \DateTime::createFromFormat('Y-m-d H:i:s', $data['date']),
+ 'logger' => $data['logger'],
+ 'level' => $data['level'],
+ 'message' => $data['message'],
+ 'trace' => isset($data['trace']) ? $this->parseTrace($data['trace']) : null,
+ 'context' => json_decode($data['context'], true),
+ 'extra' => json_decode($data['extra'], true)
+ );
+ }
+
+ /**
+ * Parse text of trace into an array of lines
+ *
+ * @param string $trace
+ * @param int $rows
+ * @return array
+ */
+ public static function parseTrace($trace, $rows = 10)
+ {
+ $lines = array_filter(preg_split('/#\d*/m', $trace));
+ return array_slice($lines, 0, $rows);
+ }
+
+}
diff --git a/system/src/Grav/Common/Helpers/Truncator.php b/system/src/Grav/Common/Helpers/Truncator.php
new file mode 100644
index 0000000..d116bb3
--- /dev/null
+++ b/system/src/Grav/Common/Helpers/Truncator.php
@@ -0,0 +1,335 @@
+getElementsByTagName('div')->item(0);
+ $container = $container->parentNode->removeChild($container);
+
+ // Iterate over words.
+ $words = new DOMWordsIterator($container);
+ $truncated = false;
+ foreach ($words as $word) {
+
+ // If we have exceeded the limit, we delete the remainder of the content.
+ if ($words->key() >= $limit) {
+
+ // Grab current position.
+ $currentWordPosition = $words->currentWordPosition();
+ $curNode = $currentWordPosition[0];
+ $offset = $currentWordPosition[1];
+ $words = $currentWordPosition[2];
+
+ $curNode->nodeValue = substr(
+ $curNode->nodeValue,
+ 0,
+ $words[$offset][1] + strlen($words[$offset][0])
+ );
+
+ self::removeProceedingNodes($curNode, $container);
+
+ if (!empty($ellipsis)) {
+ self::insertEllipsis($curNode, $ellipsis);
+ }
+
+ $truncated = true;
+
+ break;
+ }
+
+ }
+
+ // Return original HTML if not truncated.
+ if ($truncated) {
+ $html = self::getCleanedHtml($doc, $container);
+ }
+
+ return $html;
+ }
+
+ /**
+ * Safely truncates HTML by a given number of letters.
+ * @param string $html Input HTML.
+ * @param int $limit Limit to how many letters we preserve.
+ * @param string $ellipsis String to use as ellipsis (if any).
+ * @return string Safe truncated HTML.
+ */
+ public static function truncateLetters($html, $limit = 0, $ellipsis = '')
+ {
+ if ($limit <= 0) {
+ return $html;
+ }
+
+ $doc = self::htmlToDomDocument($html);
+ $container = $doc->getElementsByTagName('div')->item(0);
+ $container = $container->parentNode->removeChild($container);
+
+ // Iterate over letters.
+ $letters = new DOMLettersIterator($container);
+ $truncated = false;
+ foreach ($letters as $letter) {
+
+ // If we have exceeded the limit, we want to delete the remainder of this document.
+ if ($letters->key() >= $limit) {
+
+ $currentText = $letters->currentTextPosition();
+ $currentText[0]->nodeValue = mb_substr($currentText[0]->nodeValue, 0, $currentText[1] + 1);
+ self::removeProceedingNodes($currentText[0], $container);
+
+ if (!empty($ellipsis)) {
+ self::insertEllipsis($currentText[0], $ellipsis);
+ }
+
+ $truncated = true;
+
+ break;
+ }
+ }
+
+ // Return original HTML if not truncated.
+ if ($truncated) {
+ $html = self::getCleanedHtml($doc, $container);
+ }
+
+ return $html;
+ }
+
+ /**
+ * Builds a DOMDocument object from a string containing HTML.
+ * @param string $html HTML to load
+ * @returns DOMDocument Returns a DOMDocument object.
+ */
+ public static function htmlToDomDocument($html)
+ {
+ if (!$html) {
+ $html = '';
+ }
+
+ // Transform multibyte entities which otherwise display incorrectly.
+ $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
+
+ // Internal errors enabled as HTML5 not fully supported.
+ libxml_use_internal_errors(true);
+
+ // Instantiate new DOMDocument object, and then load in UTF-8 HTML.
+ $dom = new DOMDocument();
+ $dom->encoding = 'UTF-8';
+ $dom->loadHTML("$html
");
+
+ return $dom;
+ }
+
+ /**
+ * Removes all nodes after the current node.
+ * @param DOMNode|DOMElement $domNode
+ * @param DOMNode|DOMElement $topNode
+ * @return void
+ */
+ private static function removeProceedingNodes($domNode, $topNode)
+ {
+ $nextNode = $domNode->nextSibling;
+
+ if ($nextNode !== null) {
+ self::removeProceedingNodes($nextNode, $topNode);
+ $domNode->parentNode->removeChild($nextNode);
+ } else {
+ //scan upwards till we find a sibling
+ $curNode = $domNode->parentNode;
+ while ($curNode !== $topNode) {
+ if ($curNode->nextSibling !== null) {
+ $curNode = $curNode->nextSibling;
+ self::removeProceedingNodes($curNode, $topNode);
+ $curNode->parentNode->removeChild($curNode);
+ break;
+ }
+ $curNode = $curNode->parentNode;
+ }
+ }
+ }
+
+ /**
+ * Clean extra code
+ *
+ * @param DOMDocument $doc
+ * @param $container
+ * @return string
+ */
+ private static function getCleanedHTML(DOMDocument $doc, $container)
+ {
+ while ($doc->firstChild) {
+ $doc->removeChild($doc->firstChild);
+ }
+
+ while ($container->firstChild ) {
+ $doc->appendChild($container->firstChild);
+ }
+
+ $html = trim($doc->saveHTML());
+ return $html;
+ }
+
+ /**
+ * Inserts an ellipsis
+ * @param DOMNode|DOMElement $domNode Element to insert after.
+ * @param string $ellipsis Text used to suffix our document.
+ * @return void
+ */
+ private static function insertEllipsis($domNode, $ellipsis)
+ {
+ $avoid = array('a', 'strong', 'em', 'h1', 'h2', 'h3', 'h4', 'h5'); //html tags to avoid appending the ellipsis to
+
+ if ($domNode->parentNode->parentNode !== null && in_array($domNode->parentNode->nodeName, $avoid, true)) {
+ // Append as text node to parent instead
+ $textNode = new DOMText($ellipsis);
+
+ if ($domNode->parentNode->parentNode->nextSibling) {
+ $domNode->parentNode->parentNode->insertBefore($textNode, $domNode->parentNode->parentNode->nextSibling);
+ } else {
+ $domNode->parentNode->parentNode->appendChild($textNode);
+ }
+
+ } else {
+ // Append to current node
+ $domNode->nodeValue = rtrim($domNode->nodeValue) . $ellipsis;
+ }
+ }
+
+ /**
+ *
+ */
+ public function truncate(
+ $text,
+ $length = 100,
+ $ending = '...',
+ $exact = false,
+ $considerHtml = true
+ ) {
+ if ($considerHtml) {
+ // if the plain text is shorter than the maximum length, return the whole text
+ if (strlen(preg_replace('/<.*?>/', '', $text)) <= $length) {
+ return $text;
+ }
+ // splits all html-tags to scanable lines
+ preg_match_all('/(<.+?>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER);
+ $total_length = strlen($ending);
+ $open_tags = array();
+ $truncate = '';
+ foreach ($lines as $line_matchings) {
+ // if there is any html-tag in this line, handle it and add it (uncounted) to the output
+ if (!empty($line_matchings[1])) {
+ // if it's an "empty element" with or without xhtml-conform closing slash
+ if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) {
+ // do nothing
+ // if tag is a closing tag
+ } else if (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
+ // delete tag from $open_tags list
+ $pos = array_search($tag_matchings[1], $open_tags);
+ if ($pos !== false) {
+ unset($open_tags[$pos]);
+ }
+ // if tag is an opening tag
+ } else if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) {
+ // add tag to the beginning of $open_tags list
+ array_unshift($open_tags, strtolower($tag_matchings[1]));
+ }
+ // add html-tag to $truncate'd text
+ $truncate .= $line_matchings[1];
+ }
+ // calculate the length of the plain text part of the line; handle entities as one character
+ $content_length = strlen(preg_replace('/&[0-9a-z]{2,8};|[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
+ if ($total_length+$content_length> $length) {
+ // the number of characters which are left
+ $left = $length - $total_length;
+ $entities_length = 0;
+ // search for html entities
+ if (preg_match_all('/&[0-9a-z]{2,8};|[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE)) {
+ // calculate the real length of all entities in the legal range
+ foreach ($entities[0] as $entity) {
+ if ($entity[1]+1-$entities_length <= $left) {
+ $left--;
+ $entities_length += strlen($entity[0]);
+ } else {
+ // no more characters left
+ break;
+ }
+ }
+ }
+ $truncate .= substr($line_matchings[2], 0, $left+$entities_length);
+ // maximum lenght is reached, so get off the loop
+ break;
+ } else {
+ $truncate .= $line_matchings[2];
+ $total_length += $content_length;
+ }
+ // if the maximum length is reached, get off the loop
+ if($total_length>= $length) {
+ break;
+ }
+ }
+ } else {
+ if (strlen($text) <= $length) {
+ return $text;
+ } else {
+ $truncate = substr($text, 0, $length - strlen($ending));
+ }
+ }
+ // if the words shouldn't be cut in the middle...
+ if (!$exact) {
+ // ...search the last occurance of a space...
+ $spacepos = strrpos($truncate, ' ');
+ if (isset($spacepos)) {
+ // ...and cut the text in this position
+ $truncate = substr($truncate, 0, $spacepos);
+ }
+ }
+ // add the defined ending to the text
+ $truncate .= $ending;
+ if($considerHtml) {
+ // close all unclosed html-tags
+ foreach ($open_tags as $tag) {
+ $truncate .= '' . $tag . '>';
+ }
+ }
+ return $truncate;
+ }
+
+}
diff --git a/system/src/Grav/Common/Helpers/YamlLinter.php b/system/src/Grav/Common/Helpers/YamlLinter.php
new file mode 100644
index 0000000..b7e608d
--- /dev/null
+++ b/system/src/Grav/Common/Helpers/YamlLinter.php
@@ -0,0 +1,89 @@
+get('system.pages.theme');
+ $theme_path = 'themes://' . $current_theme . '/blueprints';
+
+ $locator->addPath('blueprints', '', [$theme_path]);
+ return static::recurseFolder('blueprints://');
+ }
+
+ public static function recurseFolder($path, $extensions = 'md|yaml')
+ {
+ $lint_errors = [];
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
+ if ($locator->isStream($path)) {
+ $directory = $locator->getRecursiveIterator($path, $flags);
+ } else {
+ $directory = new \RecursiveDirectoryIterator($path, $flags);
+ }
+ $recursive = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);
+ $iterator = new \RegexIterator($recursive, '/^.+\.'.$extensions.'$/i');
+
+ /** @var \RecursiveDirectoryIterator $file */
+ foreach ($iterator as $filepath => $file) {
+ try {
+ Yaml::parse(static::extractYaml($filepath));
+ } catch (\Exception $e) {
+ $lint_errors[str_replace(GRAV_ROOT, '', $filepath)] = $e->getMessage();
+ }
+ }
+
+ return $lint_errors;
+ }
+
+ protected static function extractYaml($path)
+ {
+ $extension = pathinfo($path, PATHINFO_EXTENSION);
+ if ($extension === 'md') {
+ $file = MarkdownFile::instance($path);
+ $contents = $file->frontmatter();
+ } else {
+ $contents = file_get_contents($path);
+ }
+ return $contents;
+ }
+
+}
diff --git a/system/src/Grav/Common/Inflector.php b/system/src/Grav/Common/Inflector.php
new file mode 100644
index 0000000..eca93c1
--- /dev/null
+++ b/system/src/Grav/Common/Inflector.php
@@ -0,0 +1,330 @@
+translate('GRAV.INFLECTOR_PLURALS', null, true) ?: [];
+ static::$singular = $language->translate('GRAV.INFLECTOR_SINGULAR', null, true) ?: [];
+ static::$uncountable = $language->translate('GRAV.INFLECTOR_UNCOUNTABLE', null, true) ?: [];
+ static::$irregular = $language->translate('GRAV.INFLECTOR_IRREGULAR', null, true) ?: [];
+ static::$ordinals = $language->translate('GRAV.INFLECTOR_ORDINALS', null, true) ?: [];
+ }
+ }
+
+ /**
+ * Pluralizes English nouns.
+ *
+ * @param string $word English noun to pluralize
+ * @param int $count The count
+ *
+ * @return string Plural noun
+ */
+ public static function pluralize($word, $count = 2)
+ {
+ static::init();
+
+ if ((int)$count === 1) {
+ return $word;
+ }
+
+ $lowercased_word = strtolower($word);
+
+ foreach (static::$uncountable as $_uncountable) {
+ if (substr($lowercased_word, -1 * strlen($_uncountable)) === $_uncountable) {
+ return $word;
+ }
+ }
+
+ foreach (static::$irregular as $_plural => $_singular) {
+ if (preg_match('/(' . $_plural . ')$/i', $word, $arr)) {
+ return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
+ }
+ }
+
+ foreach (static::$plural as $rule => $replacement) {
+ if (preg_match($rule, $word)) {
+ return preg_replace($rule, $replacement, $word);
+ }
+ }
+
+ return false;
+
+ }
+
+ /**
+ * Singularizes English nouns.
+ *
+ * @param string $word English noun to singularize
+ * @param int $count
+ *
+ * @return string Singular noun.
+ */
+ public static function singularize($word, $count = 1)
+ {
+ static::init();
+
+ if ((int)$count !== 1) {
+ return $word;
+ }
+
+ $lowercased_word = strtolower($word);
+ foreach (static::$uncountable as $_uncountable) {
+ if (substr($lowercased_word, -1 * strlen($_uncountable)) === $_uncountable) {
+ return $word;
+ }
+ }
+
+ foreach (static::$irregular as $_plural => $_singular) {
+ if (preg_match('/(' . $_singular . ')$/i', $word, $arr)) {
+ return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
+ }
+ }
+
+ foreach (static::$singular as $rule => $replacement) {
+ if (preg_match($rule, $word)) {
+ return preg_replace($rule, $replacement, $word);
+ }
+ }
+
+ return $word;
+ }
+
+ /**
+ * Converts an underscored or CamelCase word into a English
+ * sentence.
+ *
+ * The titleize public function converts text like "WelcomePage",
+ * "welcome_page" or "welcome page" to this "Welcome
+ * Page".
+ * If second parameter is set to 'first' it will only
+ * capitalize the first character of the title.
+ *
+ * @param string $word Word to format as tile
+ * @param string $uppercase If set to 'first' it will only uppercase the
+ * first character. Otherwise it will uppercase all
+ * the words in the title.
+ *
+ * @return string Text formatted as title
+ */
+ public static function titleize($word, $uppercase = '')
+ {
+ $uppercase = $uppercase === 'first' ? 'ucfirst' : 'ucwords';
+
+ return $uppercase(static::humanize(static::underscorize($word)));
+ }
+
+ /**
+ * Returns given word as CamelCased
+ *
+ * Converts a word like "send_email" to "SendEmail". It
+ * will remove non alphanumeric character from the word, so
+ * "who's online" will be converted to "WhoSOnline"
+ *
+ * @see variablize
+ *
+ * @param string $word Word to convert to camel case
+ *
+ * @return string UpperCamelCasedWord
+ */
+ public static function camelize($word)
+ {
+ return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
+ }
+
+ /**
+ * Converts a word "into_it_s_underscored_version"
+ *
+ * Convert any "CamelCased" or "ordinary Word" into an
+ * "underscored_word".
+ *
+ * This can be really useful for creating friendly URLs.
+ *
+ * @param string $word Word to underscore
+ *
+ * @return string Underscored word
+ */
+ public static function underscorize($word)
+ {
+ $regex1 = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1_\2', $word);
+ $regex2 = preg_replace('/([a-zd])([A-Z])/', '\1_\2', $regex1);
+ $regex3 = preg_replace('/[^A-Z^a-z^0-9]+/', '_', $regex2);
+
+ return strtolower($regex3);
+ }
+
+ /**
+ * Converts a word "into-it-s-hyphenated-version"
+ *
+ * Convert any "CamelCased" or "ordinary Word" into an
+ * "hyphenated-word".
+ *
+ * This can be really useful for creating friendly URLs.
+ *
+ * @param string $word Word to hyphenate
+ *
+ * @return string hyphenized word
+ */
+ public static function hyphenize($word)
+ {
+ $regex1 = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1-\2', $word);
+ $regex2 = preg_replace('/([a-z])([A-Z])/', '\1-\2', $regex1);
+ $regex3 = preg_replace('/([0-9])([A-Z])/', '\1-\2', $regex2);
+ $regex4 = preg_replace('/[^A-Z^a-z^0-9]+/', '-', $regex3);
+
+ $regex4 = trim($regex4, '-');
+
+ return strtolower($regex4);
+ }
+
+ /**
+ * Returns a human-readable string from $word
+ *
+ * Returns a human-readable string from $word, by replacing
+ * underscores with a space, and by upper-casing the initial
+ * character by default.
+ *
+ * If you need to uppercase all the words you just have to
+ * pass 'all' as a second parameter.
+ *
+ * @param string $word String to "humanize"
+ * @param string $uppercase If set to 'all' it will uppercase all the words
+ * instead of just the first one.
+ *
+ * @return string Human-readable word
+ */
+ public static function humanize($word, $uppercase = '')
+ {
+ $uppercase = $uppercase === 'all' ? 'ucwords' : 'ucfirst';
+
+ return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
+ }
+
+ /**
+ * Same as camelize but first char is underscored
+ *
+ * Converts a word like "send_email" to "sendEmail". It
+ * will remove non alphanumeric character from the word, so
+ * "who's online" will be converted to "whoSOnline"
+ *
+ * @see camelize
+ *
+ * @param string $word Word to lowerCamelCase
+ *
+ * @return string Returns a lowerCamelCasedWord
+ */
+ public static function variablize($word)
+ {
+ $word = static::camelize($word);
+
+ return strtolower($word[0]) . substr($word, 1);
+ }
+
+ /**
+ * Converts a class name to its table name according to rails
+ * naming conventions.
+ *
+ * Converts "Person" to "people"
+ *
+ * @see classify
+ *
+ * @param string $class_name Class name for getting related table_name.
+ *
+ * @return string plural_table_name
+ */
+ public static function tableize($class_name)
+ {
+ return static::pluralize(static::underscorize($class_name));
+ }
+
+ /**
+ * Converts a table name to its class name according to rails
+ * naming conventions.
+ *
+ * Converts "people" to "Person"
+ *
+ * @see tableize
+ *
+ * @param string $table_name Table name for getting related ClassName.
+ *
+ * @return string SingularClassName
+ */
+ public static function classify($table_name)
+ {
+ return static::camelize(static::singularize($table_name));
+ }
+
+ /**
+ * Converts number to its ordinal English form.
+ *
+ * This method converts 13 to 13th, 2 to 2nd ...
+ *
+ * @param int $number Number to get its ordinal value
+ *
+ * @return string Ordinal representation of given string.
+ */
+ public static function ordinalize($number)
+ {
+ static::init();
+
+ if (\in_array($number % 100, range(11, 13), true)) {
+ return $number . static::$ordinals['default'];
+ }
+
+ switch ($number % 10) {
+ case 1:
+ return $number . static::$ordinals['first'];
+ case 2:
+ return $number . static::$ordinals['second'];
+ case 3:
+ return $number . static::$ordinals['third'];
+ default:
+ return $number . static::$ordinals['default'];
+ }
+ }
+
+ /**
+ * Converts a number of days to a number of months
+ *
+ * @param int $days
+ *
+ * @return int
+ */
+ public static function monthize($days)
+ {
+ $now = new \DateTime();
+ $end = new \DateTime();
+
+ $duration = new \DateInterval("P{$days}D");
+
+ $diff = $end->add($duration)->diff($now);
+
+ // handle years
+ if ($diff->y > 0) {
+ $diff->m += 12 * $diff->y;
+ }
+
+ return $diff->m;
+ }
+}
diff --git a/system/src/Grav/Common/Iterator.php b/system/src/Grav/Common/Iterator.php
new file mode 100644
index 0000000..5f6dc7e
--- /dev/null
+++ b/system/src/Grav/Common/Iterator.php
@@ -0,0 +1,265 @@
+items[$key] ?? null;
+ }
+
+ /**
+ * Clone the iterator.
+ */
+ public function __clone()
+ {
+ foreach ($this as $key => $value) {
+ if (\is_object($value)) {
+ $this->{$key} = clone $this->{$key};
+ }
+ }
+ }
+
+ /**
+ * Convents iterator to a comma separated list.
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return implode(',', $this->items);
+ }
+
+ /**
+ * Remove item from the list.
+ *
+ * @param string $key
+ */
+ public function remove($key)
+ {
+ $this->offsetUnset($key);
+ }
+
+ /**
+ * Return previous item.
+ *
+ * @return mixed
+ */
+ public function prev()
+ {
+ return prev($this->items);
+ }
+
+ /**
+ * Return nth item.
+ *
+ * @param int $key
+ *
+ * @return mixed|bool
+ */
+ public function nth($key)
+ {
+ $items = array_keys($this->items);
+
+ return isset($items[$key]) ? $this->offsetGet($items[$key]) : false;
+ }
+
+ /**
+ * Get the first item
+ *
+ * @return mixed
+ */
+ public function first()
+ {
+ $items = array_keys($this->items);
+
+ return $this->offsetGet(array_shift($items));
+ }
+
+ /**
+ * Get the last item
+ *
+ * @return mixed
+ */
+ public function last()
+ {
+ $items = array_keys($this->items);
+
+ return $this->offsetGet(array_pop($items));
+ }
+
+ /**
+ * Reverse the Iterator
+ *
+ * @return $this
+ */
+ public function reverse()
+ {
+ $this->items = array_reverse($this->items);
+
+ return $this;
+ }
+
+ /**
+ * @param mixed $needle Searched value.
+ *
+ * @return string|bool Key if found, otherwise false.
+ */
+ public function indexOf($needle)
+ {
+ foreach (array_values($this->items) as $key => $value) {
+ if ($value === $needle) {
+ return $key;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Shuffle items.
+ *
+ * @return $this
+ */
+ public function shuffle()
+ {
+ $keys = array_keys($this->items);
+ shuffle($keys);
+
+ $new = [];
+ foreach ($keys as $key) {
+ $new[$key] = $this->items[$key];
+ }
+
+ $this->items = $new;
+
+ return $this;
+ }
+
+ /**
+ * Slice the list.
+ *
+ * @param int $offset
+ * @param int $length
+ *
+ * @return $this
+ */
+ public function slice($offset, $length = null)
+ {
+ $this->items = \array_slice($this->items, $offset, $length);
+
+ return $this;
+ }
+
+ /**
+ * Pick one or more random entries.
+ *
+ * @param int $num Specifies how many entries should be picked.
+ *
+ * @return $this
+ */
+ public function random($num = 1)
+ {
+ $count = \count($this->items);
+ if ($num > $count) {
+ $num = $count;
+ }
+
+ $this->items = array_intersect_key($this->items, array_flip((array)array_rand($this->items, $num)));
+
+ return $this;
+ }
+
+ /**
+ * Append new elements to the list.
+ *
+ * @param array|Iterator $items Items to be appended. Existing keys will be overridden with the new values.
+ *
+ * @return $this
+ */
+ public function append($items)
+ {
+ if ($items instanceof static) {
+ $items = $items->toArray();
+ }
+ $this->items = array_merge($this->items, (array)$items);
+
+ return $this;
+ }
+
+ /**
+ * Filter elements from the list
+ *
+ * @param callable|null $callback A function the receives ($value, $key) and must return a boolean to indicate
+ * filter status
+ *
+ * @return $this
+ */
+ public function filter(callable $callback = null)
+ {
+ foreach ($this->items as $key => $value) {
+ if (
+ (!$callback && !(bool)$value) ||
+ ($callback && !$callback($value, $key))
+ ) {
+ unset($this->items[$key]);
+ }
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * Sorts elements from the list and returns a copy of the list in the proper order
+ *
+ * @param callable|null $callback
+ *
+ * @param bool $desc
+ *
+ * @return $this|array
+ * @internal param bool $asc
+ *
+ */
+ public function sort(callable $callback = null, $desc = false)
+ {
+ if (!$callback || !\is_callable($callback)) {
+ return $this;
+ }
+
+ $items = $this->items;
+ uasort($items, $callback);
+
+ return !$desc ? $items : array_reverse($items, true);
+ }
+}
diff --git a/system/src/Grav/Common/Language/Language.php b/system/src/Grav/Common/Language/Language.php
new file mode 100644
index 0000000..a625146
--- /dev/null
+++ b/system/src/Grav/Common/Language/Language.php
@@ -0,0 +1,537 @@
+grav = $grav;
+ $this->config = $grav['config'];
+ $this->languages = $this->config->get('system.languages.supported', []);
+ $this->init();
+ }
+
+ /**
+ * Initialize the default and enabled languages
+ */
+ public function init()
+ {
+ $default = $this->config->get('system.languages.default_lang');
+ if (isset($default) && $this->validate($default)) {
+ $this->default = $default;
+ } else {
+ $this->default = reset($this->languages);
+ }
+
+ $this->page_extensions = null;
+
+ if (empty($this->languages)) {
+ $this->enabled = false;
+ }
+ }
+
+ /**
+ * Ensure that languages are enabled
+ *
+ * @return bool
+ */
+ public function enabled()
+ {
+ return $this->enabled;
+ }
+
+ /**
+ * Gets the array of supported languages
+ *
+ * @return array
+ */
+ public function getLanguages()
+ {
+ return $this->languages;
+ }
+
+ /**
+ * Sets the current supported languages manually
+ *
+ * @param array $langs
+ */
+ public function setLanguages($langs)
+ {
+ $this->languages = $langs;
+ $this->init();
+ }
+
+ /**
+ * Gets a pipe-separated string of available languages
+ *
+ * @return string
+ */
+ public function getAvailable()
+ {
+ $languagesArray = $this->languages; //Make local copy
+
+ $languagesArray = array_map(function($value) {
+ return preg_quote($value);
+ }, $languagesArray);
+
+ sort($languagesArray);
+
+ return implode('|', array_reverse($languagesArray));
+ }
+
+ /**
+ * Gets language, active if set, else default
+ *
+ * @return string
+ */
+ public function getLanguage()
+ {
+ return $this->active ?: $this->default;
+ }
+
+ /**
+ * Gets current default language
+ *
+ * @return mixed
+ */
+ public function getDefault()
+ {
+ return $this->default;
+ }
+
+ /**
+ * Sets default language manually
+ *
+ * @param string $lang
+ *
+ * @return bool
+ */
+ public function setDefault($lang)
+ {
+ if ($this->validate($lang)) {
+ $this->default = $lang;
+
+ return $lang;
+ }
+
+ return false;
+ }
+
+ /**
+ * Gets current active language
+ *
+ * @return string
+ */
+ public function getActive()
+ {
+ return $this->active;
+ }
+
+ /**
+ * Sets active language manually
+ *
+ * @param string $lang
+ *
+ * @return string|bool
+ */
+ public function setActive($lang)
+ {
+ if ($this->validate($lang)) {
+ $this->active = $lang;
+
+ return $lang;
+ }
+
+ return false;
+ }
+
+ /**
+ * Sets the active language based on the first part of the URL
+ *
+ * @param string $uri
+ *
+ * @return string
+ */
+ public function setActiveFromUri($uri)
+ {
+ $regex = '/(^\/(' . $this->getAvailable() . '))(?:\/|\?|$)/i';
+
+ // if languages set
+ if ($this->enabled()) {
+ // Try setting language from prefix of URL (/en/blah/blah).
+ if (preg_match($regex, $uri, $matches)) {
+ $this->lang_in_url = true;
+ $this->active = $matches[2];
+ $uri = preg_replace("/\\" . $matches[1] . '/', '', $uri, 1);
+
+ // Store in session if language is different.
+ if (isset($this->grav['session']) && $this->grav['session']->isStarted()
+ && $this->config->get('system.languages.session_store_active', true)
+ && $this->grav['session']->active_language != $this->active
+ ) {
+ $this->grav['session']->active_language = $this->active;
+ }
+ } else {
+ // Try getting language from the session, else no active.
+ if (isset($this->grav['session']) && $this->grav['session']->isStarted() &&
+ $this->config->get('system.languages.session_store_active', true)) {
+ $this->active = $this->grav['session']->active_language ?: null;
+ }
+ // if still null, try from http_accept_language header
+ if ($this->active === null &&
+ $this->config->get('system.languages.http_accept_language') &&
+ $accept = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? false) {
+
+ $negotiator = new LanguageNegotiator();
+ $best_language = $negotiator->getBest($accept, $this->languages);
+
+ if ($best_language instanceof AcceptLanguage) {
+ $this->active = $best_language->getType();
+ } else {
+ $this->active = $this->getDefault();
+ }
+
+ }
+ }
+ }
+
+ return $uri;
+ }
+
+ /**
+ * Get a URL prefix based on configuration
+ *
+ * @param string|null $lang
+ * @return string
+ */
+ public function getLanguageURLPrefix($lang = null)
+ {
+ // if active lang is not passed in, use current active
+ if (!$lang) {
+ $lang = $this->getLanguage();
+ }
+
+ return $this->isIncludeDefaultLanguage($lang) ? '/' . $lang : '';
+ }
+
+ /**
+ * Test to see if language is default and language should be included in the URL
+ *
+ * @param string|null $lang
+ * @return bool
+ */
+ public function isIncludeDefaultLanguage($lang = null)
+ {
+ // if active lang is not passed in, use current active
+ if (!$lang) {
+ $lang = $this->getLanguage();
+ }
+
+ return !($this->default === $lang && $this->config->get('system.languages.include_default_lang') === false);
+ }
+
+ /**
+ * Simple getter to tell if a language was found in the URL
+ *
+ * @return bool
+ */
+ public function isLanguageInUrl()
+ {
+ return (bool) $this->lang_in_url;
+ }
+
+
+ /**
+ * Gets an array of valid extensions with active first, then fallback extensions
+ *
+ * @param string|null $file_ext
+ *
+ * @return array
+ */
+ public function getFallbackPageExtensions($file_ext = null)
+ {
+ if (empty($this->page_extensions)) {
+ if (!$file_ext) {
+ $file_ext = CONTENT_EXT;
+ }
+
+ if ($this->enabled()) {
+ $valid_lang_extensions = [];
+ foreach ($this->languages as $lang) {
+ $valid_lang_extensions[] = '.' . $lang . $file_ext;
+ }
+
+ if ($this->active) {
+ $active_extension = '.' . $this->active . $file_ext;
+ $key = \array_search($active_extension, $valid_lang_extensions, true);
+
+ // Default behavior is to find any language other than active
+ if ($this->config->get('system.languages.pages_fallback_only')) {
+ $slice = \array_slice($valid_lang_extensions, 0, $key+1);
+ $valid_lang_extensions = array_reverse($slice);
+ } else {
+ unset($valid_lang_extensions[$key]);
+ array_unshift($valid_lang_extensions, $active_extension);
+ }
+ }
+ $valid_lang_extensions[] = $file_ext;
+ $this->page_extensions = $valid_lang_extensions;
+ } else {
+ $this->page_extensions = (array)$file_ext;
+ }
+ }
+
+ return $this->page_extensions;
+ }
+
+ /**
+ * Resets the page_extensions value.
+ *
+ * Useful to re-initialize the pages and change site language at runtime, example:
+ *
+ * ```
+ * $this->grav['language']->setActive('it');
+ * $this->grav['language']->resetFallbackPageExtensions();
+ * $this->grav['pages']->init();
+ * ```
+ */
+ public function resetFallbackPageExtensions()
+ {
+ $this->page_extensions = null;
+ }
+
+ /**
+ * Gets an array of languages with active first, then fallback languages
+ *
+ * @return array
+ */
+ public function getFallbackLanguages()
+ {
+ if (empty($this->fallback_languages)) {
+ if ($this->enabled()) {
+ $fallback_languages = $this->languages;
+
+ if ($this->active) {
+ $active_extension = $this->active;
+ $key = \array_search($active_extension, $fallback_languages, true);
+ unset($fallback_languages[$key]);
+ array_unshift($fallback_languages, $active_extension);
+ }
+ $this->fallback_languages = $fallback_languages;
+ }
+ // always add english in case a translation doesn't exist
+ $this->fallback_languages[] = 'en';
+ }
+
+ return $this->fallback_languages;
+ }
+
+ /**
+ * Ensures the language is valid and supported
+ *
+ * @param string $lang
+ *
+ * @return bool
+ */
+ public function validate($lang)
+ {
+ return \in_array($lang, $this->languages, true);
+ }
+
+ /**
+ * Translate a key and possibly arguments into a string using current lang and fallbacks
+ *
+ * @param string|array $args The first argument is the lookup key value
+ * Other arguments can be passed and replaced in the translation with sprintf syntax
+ * @param array $languages
+ * @param bool $array_support
+ * @param bool $html_out
+ *
+ * @return string
+ */
+ public function translate($args, array $languages = null, $array_support = false, $html_out = false)
+ {
+ if (\is_array($args)) {
+ $lookup = array_shift($args);
+ } else {
+ $lookup = $args;
+ $args = [];
+ }
+
+ if ($this->config->get('system.languages.translations', true)) {
+ if ($this->enabled() && $lookup) {
+ if (empty($languages)) {
+ if ($this->config->get('system.languages.translations_fallback', true)) {
+ $languages = $this->getFallbackLanguages();
+ } else {
+ $languages = (array)$this->getLanguage();
+ }
+ }
+ } else {
+ $languages = ['en'];
+ }
+
+ foreach ((array)$languages as $lang) {
+ $translation = $this->getTranslation($lang, $lookup, $array_support);
+
+ if ($translation) {
+ if (\count($args) >= 1) {
+ return vsprintf($translation, $args);
+ }
+
+ return $translation;
+ }
+ }
+ }
+
+ if ($html_out) {
+ return '' . $lookup . ' ';
+ }
+
+ return $lookup;
+ }
+
+ /**
+ * Translate Array
+ *
+ * @param string $key
+ * @param string $index
+ * @param array|null $languages
+ * @param bool $html_out
+ *
+ * @return string
+ */
+ public function translateArray($key, $index, $languages = null, $html_out = false)
+ {
+ if ($this->config->get('system.languages.translations', true)) {
+ if ($this->enabled() && $key) {
+ if (empty($languages)) {
+ if ($this->config->get('system.languages.translations_fallback', true)) {
+ $languages = $this->getFallbackLanguages();
+ } else {
+ $languages = (array)$this->getDefault();
+ }
+ }
+ } else {
+ $languages = ['en'];
+ }
+
+ foreach ((array)$languages as $lang) {
+ $translation_array = (array)Grav::instance()['languages']->get($lang . '.' . $key, null);
+ if ($translation_array && array_key_exists($index, $translation_array)) {
+ return $translation_array[$index];
+ }
+ }
+ }
+
+ if ($html_out) {
+ return '' . $key . '[' . $index . '] ';
+ }
+
+ return $key . '[' . $index . ']';
+ }
+
+ /**
+ * Lookup the translation text for a given lang and key
+ *
+ * @param string $lang lang code
+ * @param string $key key to lookup with
+ * @param bool $array_support
+ *
+ * @return string
+ */
+ public function getTranslation($lang, $key, $array_support = false)
+ {
+ $translation = Grav::instance()['languages']->get($lang . '.' . $key, null);
+ if (!$array_support && is_array($translation)) {
+ return (string)array_shift($translation);
+ }
+
+ return $translation;
+ }
+
+ /**
+ * Get the browser accepted languages
+ *
+ * @param array $accept_langs
+ * @return array
+ * @deprecated 1.6 No longer used - using content negotiation.
+ */
+ public function getBrowserLanguages($accept_langs = [])
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, no longer used', E_USER_DEPRECATED);
+
+ if (empty($this->http_accept_language)) {
+ if (empty($accept_langs) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
+ $accept_langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
+ } else {
+ return $accept_langs;
+ }
+
+ $langs = [];
+
+ foreach (explode(',', $accept_langs) as $k => $pref) {
+ // split $pref again by ';q='
+ // and decorate the language entries by inverted position
+ if (false !== ($i = strpos($pref, ';q='))) {
+ $langs[substr($pref, 0, $i)] = [(float)substr($pref, $i + 3), -$k];
+ } else {
+ $langs[$pref] = [1, -$k];
+ }
+ }
+ arsort($langs);
+
+ // no need to undecorate, because we're only interested in the keys
+ $this->http_accept_language = array_keys($langs);
+ }
+ return $this->http_accept_language;
+ }
+
+ /**
+ * Accessible wrapper to LanguageCodes
+ *
+ * @param string $code
+ * @param string $type
+ * @return bool
+ */
+ public function getLanguageCode($code, $type = 'name')
+ {
+ return LanguageCodes::get($code, $type);
+ }
+
+}
diff --git a/system/src/Grav/Common/Language/LanguageCodes.php b/system/src/Grav/Common/Language/LanguageCodes.php
new file mode 100644
index 0000000..780df7c
--- /dev/null
+++ b/system/src/Grav/Common/Language/LanguageCodes.php
@@ -0,0 +1,205 @@
+ [ 'name' => 'Afrikaans', 'nativeName' => 'Afrikaans' ],
+ 'ak' => [ 'name' => 'Akan', 'nativeName' => 'Akan' ], // unverified native name
+ 'ast' => [ 'name' => 'Asturian', 'nativeName' => 'Asturianu' ],
+ 'ar' => [ 'name' => 'Arabic', 'nativeName' => 'عربي', 'orientation' => 'rtl'],
+ 'as' => [ 'name' => 'Assamese', 'nativeName' => 'অসমীয়া' ],
+ 'be' => [ 'name' => 'Belarusian', 'nativeName' => 'Беларуская' ],
+ 'bg' => [ 'name' => 'Bulgarian', 'nativeName' => 'Български' ],
+ 'bn' => [ 'name' => 'Bengali', 'nativeName' => 'বাংলা' ],
+ 'bn-BD' => [ 'name' => 'Bengali (Bangladesh)', 'nativeName' => 'বাংলা (বাংলাদেশ)' ],
+ 'bn-IN' => [ 'name' => 'Bengali (India)', 'nativeName' => 'বাংলা (ভারত)' ],
+ 'br' => [ 'name' => 'Breton', 'nativeName' => 'Brezhoneg' ],
+ 'bs' => [ 'name' => 'Bosnian', 'nativeName' => 'Bosanski' ],
+ 'ca' => [ 'name' => 'Catalan', 'nativeName' => 'Català' ],
+ 'ca-valencia'=> [ 'name' => 'Catalan (Valencian)', 'nativeName' => 'Català (valencià)' ], // not iso-639-1. a=l10n-drivers
+ 'cs' => [ 'name' => 'Czech', 'nativeName' => 'Čeština' ],
+ 'cy' => [ 'name' => 'Welsh', 'nativeName' => 'Cymraeg' ],
+ 'da' => [ 'name' => 'Danish', 'nativeName' => 'Dansk' ],
+ 'de' => [ 'name' => 'German', 'nativeName' => 'Deutsch' ],
+ 'de-AT' => [ 'name' => 'German (Austria)', 'nativeName' => 'Deutsch (Österreich)' ],
+ 'de-CH' => [ 'name' => 'German (Switzerland)', 'nativeName' => 'Deutsch (Schweiz)' ],
+ 'de-DE' => [ 'name' => 'German (Germany)', 'nativeName' => 'Deutsch (Deutschland)' ],
+ 'dsb' => [ 'name' => 'Lower Sorbian', 'nativeName' => 'Dolnoserbšćina' ], // iso-639-2
+ 'el' => [ 'name' => 'Greek', 'nativeName' => 'Ελληνικά' ],
+ 'en' => [ 'name' => 'English', 'nativeName' => 'English' ],
+ 'en-AU' => [ 'name' => 'English (Australian)', 'nativeName' => 'English (Australian)' ],
+ 'en-CA' => [ 'name' => 'English (Canadian)', 'nativeName' => 'English (Canadian)' ],
+ 'en-GB' => [ 'name' => 'English (British)', 'nativeName' => 'English (British)' ],
+ 'en-NZ' => [ 'name' => 'English (New Zealand)', 'nativeName' => 'English (New Zealand)' ],
+ 'en-US' => [ 'name' => 'English (US)', 'nativeName' => 'English (US)' ],
+ 'en-ZA' => [ 'name' => 'English (South African)', 'nativeName' => 'English (South African)' ],
+ 'eo' => [ 'name' => 'Esperanto', 'nativeName' => 'Esperanto' ],
+ 'es' => [ 'name' => 'Spanish', 'nativeName' => 'Español' ],
+ 'es-AR' => [ 'name' => 'Spanish (Argentina)', 'nativeName' => 'Español (de Argentina)' ],
+ 'es-CL' => [ 'name' => 'Spanish (Chile)', 'nativeName' => 'Español (de Chile)' ],
+ 'es-ES' => [ 'name' => 'Spanish (Spain)', 'nativeName' => 'Español (de España)' ],
+ 'es-MX' => [ 'name' => 'Spanish (Mexico)', 'nativeName' => 'Español (de México)' ],
+ 'et' => [ 'name' => 'Estonian', 'nativeName' => 'Eesti keel' ],
+ 'eu' => [ 'name' => 'Basque', 'nativeName' => 'Euskara' ],
+ 'fa' => [ 'name' => 'Persian', 'nativeName' => 'فارسی' , 'orientation' => 'rtl' ],
+ 'fi' => [ 'name' => 'Finnish', 'nativeName' => 'Suomi' ],
+ 'fj-FJ' => [ 'name' => 'Fijian', 'nativeName' => 'Vosa vaka-Viti' ],
+ 'fr' => [ 'name' => 'French', 'nativeName' => 'Français' ],
+ 'fr-CA' => [ 'name' => 'French (Canada)', 'nativeName' => 'Français (Canada)' ],
+ 'fr-FR' => [ 'name' => 'French (France)', 'nativeName' => 'Français (France)' ],
+ 'fur' => [ 'name' => 'Friulian', 'nativeName' => 'Furlan' ],
+ 'fur-IT' => [ 'name' => 'Friulian', 'nativeName' => 'Furlan' ],
+ 'fy' => [ 'name' => 'Frisian', 'nativeName' => 'Frysk' ],
+ 'fy-NL' => [ 'name' => 'Frisian', 'nativeName' => 'Frysk' ],
+ 'ga' => [ 'name' => 'Irish', 'nativeName' => 'Gaeilge' ],
+ 'ga-IE' => [ 'name' => 'Irish (Ireland)', 'nativeName' => 'Gaeilge (Éire)' ],
+ 'gd' => [ 'name' => 'Gaelic (Scotland)', 'nativeName' => 'Gàidhlig' ],
+ 'gl' => [ 'name' => 'Galician', 'nativeName' => 'Galego' ],
+ 'gu' => [ 'name' => 'Gujarati', 'nativeName' => 'ગુજરાતી' ],
+ 'gu-IN' => [ 'name' => 'Gujarati', 'nativeName' => 'ગુજરાતી' ],
+ 'he' => [ 'name' => 'Hebrew', 'nativeName' => 'עברית', 'orientation' => 'rtl' ],
+ 'hi' => [ 'name' => 'Hindi', 'nativeName' => 'हिन्दी' ],
+ 'hi-IN' => [ 'name' => 'Hindi (India)', 'nativeName' => 'हिन्दी (भारत)' ],
+ 'hr' => [ 'name' => 'Croatian', 'nativeName' => 'Hrvatski' ],
+ 'hsb' => [ 'name' => 'Upper Sorbian', 'nativeName' => 'Hornjoserbsce' ],
+ 'hu' => [ 'name' => 'Hungarian', 'nativeName' => 'Magyar' ],
+ 'hy' => [ 'name' => 'Armenian', 'nativeName' => 'Հայերեն' ],
+ 'hy-AM' => [ 'name' => 'Armenian', 'nativeName' => 'Հայերեն' ],
+ 'id' => [ 'name' => 'Indonesian', 'nativeName' => 'Bahasa Indonesia' ],
+ 'is' => [ 'name' => 'Icelandic', 'nativeName' => 'íslenska' ],
+ 'it' => [ 'name' => 'Italian', 'nativeName' => 'Italiano' ],
+ 'ja' => [ 'name' => 'Japanese', 'nativeName' => '日本語' ],
+ 'ja-JP' => [ 'name' => 'Japanese', 'nativeName' => '日本語' ], // not iso-639-1
+ 'ka' => [ 'name' => 'Georgian', 'nativeName' => 'ქართული' ],
+ 'kk' => [ 'name' => 'Kazakh', 'nativeName' => 'Қазақ' ],
+ 'kn' => [ 'name' => 'Kannada', 'nativeName' => 'ಕನ್ನಡ' ],
+ 'ko' => [ 'name' => 'Korean', 'nativeName' => '한국어' ],
+ 'ku' => [ 'name' => 'Kurdish', 'nativeName' => 'Kurdî' ],
+ 'la' => [ 'name' => 'Latin', 'nativeName' => 'Latina' ],
+ 'lb' => [ 'name' => 'Luxembourgish', 'nativeName' => 'Lëtzebuergesch' ],
+ 'lg' => [ 'name' => 'Luganda', 'nativeName' => 'Luganda' ],
+ 'lt' => [ 'name' => 'Lithuanian', 'nativeName' => 'Lietuvių kalba' ],
+ 'lv' => [ 'name' => 'Latvian', 'nativeName' => 'Latviešu' ],
+ 'mai' => [ 'name' => 'Maithili', 'nativeName' => 'मैथिली মৈথিলী' ],
+ 'mg' => [ 'name' => 'Malagasy', 'nativeName' => 'Malagasy' ],
+ 'mi' => [ 'name' => 'Maori (Aotearoa)', 'nativeName' => 'Māori (Aotearoa)' ],
+ 'mk' => [ 'name' => 'Macedonian', 'nativeName' => 'Македонски' ],
+ 'ml' => [ 'name' => 'Malayalam', 'nativeName' => 'മലയാളം' ],
+ 'mn' => [ 'name' => 'Mongolian', 'nativeName' => 'Монгол' ],
+ 'mr' => [ 'name' => 'Marathi', 'nativeName' => 'मराठी' ],
+ 'no' => [ 'name' => 'Norwegian', 'nativeName' => 'Norsk' ],
+ 'nb' => [ 'name' => 'Norwegian', 'nativeName' => 'Norsk' ],
+ 'nb-NO' => [ 'name' => 'Norwegian (Bokmål)', 'nativeName' => 'Norsk bokmål' ],
+ 'ne-NP' => [ 'name' => 'Nepali', 'nativeName' => 'नेपाली' ],
+ 'nn-NO' => [ 'name' => 'Norwegian (Nynorsk)', 'nativeName' => 'Norsk nynorsk' ],
+ 'nl' => [ 'name' => 'Dutch', 'nativeName' => 'Nederlands' ],
+ 'nr' => [ 'name' => 'Ndebele, South', 'nativeName' => 'IsiNdebele' ],
+ 'nso' => [ 'name' => 'Northern Sotho', 'nativeName' => 'Sepedi' ],
+ 'oc' => [ 'name' => 'Occitan (Lengadocian)', 'nativeName' => 'Occitan (lengadocian)' ],
+ 'or' => [ 'name' => 'Oriya', 'nativeName' => 'ଓଡ଼ିଆ' ],
+ 'pa' => [ 'name' => 'Punjabi', 'nativeName' => 'ਪੰਜਾਬੀ' ],
+ 'pa-IN' => [ 'name' => 'Punjabi', 'nativeName' => 'ਪੰਜਾਬੀ' ],
+ 'pl' => [ 'name' => 'Polish', 'nativeName' => 'Polski' ],
+ 'pt' => [ 'name' => 'Portuguese', 'nativeName' => 'Português' ],
+ 'pt-BR' => [ 'name' => 'Portuguese (Brazilian)', 'nativeName' => 'Português (do Brasil)' ],
+ 'pt-PT' => [ 'name' => 'Portuguese (Portugal)', 'nativeName' => 'Português (Europeu)' ],
+ 'ro' => [ 'name' => 'Romanian', 'nativeName' => 'Română' ],
+ 'rm' => [ 'name' => 'Romansh', 'nativeName' => 'Rumantsch' ],
+ 'ru' => [ 'name' => 'Russian', 'nativeName' => 'Русский' ],
+ 'rw' => [ 'name' => 'Kinyarwanda', 'nativeName' => 'Ikinyarwanda' ],
+ 'si' => [ 'name' => 'Sinhala', 'nativeName' => 'සිංහල' ],
+ 'sk' => [ 'name' => 'Slovak', 'nativeName' => 'Slovenčina' ],
+ 'sl' => [ 'name' => 'Slovenian', 'nativeName' => 'Slovensko' ],
+ 'son' => [ 'name' => 'Songhai', 'nativeName' => 'Soŋay' ],
+ 'sq' => [ 'name' => 'Albanian', 'nativeName' => 'Shqip' ],
+ 'sr' => [ 'name' => 'Serbian', 'nativeName' => 'Српски' ],
+ 'sr-Latn' => [ 'name' => 'Serbian', 'nativeName' => 'Srpski' ], // follows RFC 4646
+ 'ss' => [ 'name' => 'Siswati', 'nativeName' => 'siSwati' ],
+ 'st' => [ 'name' => 'Southern Sotho', 'nativeName' => 'Sesotho' ],
+ 'sv' => [ 'name' => 'Swedish', 'nativeName' => 'Svenska' ],
+ 'sv-SE' => [ 'name' => 'Swedish', 'nativeName' => 'Svenska' ],
+ 'ta' => [ 'name' => 'Tamil', 'nativeName' => 'தமிழ்' ],
+ 'ta-IN' => [ 'name' => 'Tamil (India)', 'nativeName' => 'தமிழ் (இந்தியா)' ],
+ 'ta-LK' => [ 'name' => 'Tamil (Sri Lanka)', 'nativeName' => 'தமிழ் (இலங்கை)' ],
+ 'te' => [ 'name' => 'Telugu', 'nativeName' => 'తెలుగు' ],
+ 'th' => [ 'name' => 'Thai', 'nativeName' => 'ไทย' ],
+ 'tlh' => [ 'name' => 'Klingon', 'nativeName' => 'Klingon' ],
+ 'tn' => [ 'name' => 'Tswana', 'nativeName' => 'Setswana' ],
+ 'tr' => [ 'name' => 'Turkish', 'nativeName' => 'Türkçe' ],
+ 'ts' => [ 'name' => 'Tsonga', 'nativeName' => 'Xitsonga' ],
+ 'tt' => [ 'name' => 'Tatar', 'nativeName' => 'Tatarça' ],
+ 'tt-RU' => [ 'name' => 'Tatar', 'nativeName' => 'Tatarça' ],
+ 'uk' => [ 'name' => 'Ukrainian', 'nativeName' => 'Українська' ],
+ 'ur' => [ 'name' => 'Urdu', 'nativeName' => 'اُردو', 'orientation' => 'rtl' ],
+ 've' => [ 'name' => 'Venda', 'nativeName' => 'Tshivenḓa' ],
+ 'vi' => [ 'name' => 'Vietnamese', 'nativeName' => 'Tiếng Việt' ],
+ 'wo' => [ 'name' => 'Wolof', 'nativeName' => 'Wolof' ],
+ 'xh' => [ 'name' => 'Xhosa', 'nativeName' => 'isiXhosa' ],
+ 'zh' => [ 'name' => 'Chinese (Simplified)', 'nativeName' => '中文 (简体)' ],
+ 'zh-CN' => [ 'name' => 'Chinese (Simplified)', 'nativeName' => '中文 (简体)' ],
+ 'zh-TW' => [ 'name' => 'Chinese (Traditional)', 'nativeName' => '正體中文 (繁體)' ],
+ 'zu' => [ 'name' => 'Zulu', 'nativeName' => 'isiZulu' ]
+ ];
+
+ public static function getName($code)
+ {
+ return static::get($code, 'name');
+ }
+
+ public static function getNativeName($code)
+ {
+ if (isset(static::$codes[$code])) {
+ return static::get($code, 'nativeName');
+ }
+
+ if (preg_match('/[a-zA-Z]{2}-[a-zA-Z]{2}/', $code)) {
+ return static::get(substr($code, 0, 2), 'nativeName') . ' (' . substr($code, -2) . ')';
+ }
+
+ return $code;
+ }
+
+ public static function getOrientation($code)
+ {
+ if (isset(static::$codes[$code])) {
+ if (isset(static::$codes[$code]['orientation'])) {
+ return static::get($code, 'orientation');
+ }
+ }
+ return 'ltr';
+ }
+
+ public static function isRtl($code)
+ {
+ return static::getOrientation($code) === 'rtl';
+ }
+
+ public static function getNames(array $keys)
+ {
+ $results = [];
+ foreach ($keys as $key) {
+ if (isset(static::$codes[$key])) {
+ $results[$key] = static::$codes[$key];
+ }
+ }
+ return $results;
+ }
+
+ public static function get($code, $type)
+ {
+ if (isset(static::$codes[$code][$type])) {
+ return static::$codes[$code][$type];
+ }
+
+ return false;
+ }
+}
diff --git a/system/src/Grav/Common/Markdown/Parsedown.php b/system/src/Grav/Common/Markdown/Parsedown.php
new file mode 100644
index 0000000..8b8565f
--- /dev/null
+++ b/system/src/Grav/Common/Markdown/Parsedown.php
@@ -0,0 +1,40 @@
+ $defaults];
+ }
+ $excerpts = new Excerpts($excerpts, $defaults);
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '($page, $defaults) is deprecated since Grav 1.6.10, use new ' . __CLASS__ . '(new ' . Excerpts::class . '($page, [\'markdown\' => $defaults])) instead.', E_USER_DEPRECATED);
+ }
+
+ $this->init($excerpts, $defaults);
+ }
+
+}
diff --git a/system/src/Grav/Common/Markdown/ParsedownExtra.php b/system/src/Grav/Common/Markdown/ParsedownExtra.php
new file mode 100644
index 0000000..70c8596
--- /dev/null
+++ b/system/src/Grav/Common/Markdown/ParsedownExtra.php
@@ -0,0 +1,42 @@
+ $defaults];
+ }
+ $excerpts = new Excerpts($excerpts, $defaults);
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '($page, $defaults) is deprecated since Grav 1.6.10, use new ' . __CLASS__ . '(new ' . Excerpts::class . '($page, [\'markdown\' => $defaults])) instead.', E_USER_DEPRECATED);
+ }
+
+ parent::__construct();
+
+ $this->init($excerpts, $defaults);
+ }
+}
diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php
new file mode 100644
index 0000000..aa76cdf
--- /dev/null
+++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php
@@ -0,0 +1,277 @@
+ $defaults];
+ }
+ $this->excerpts = new Excerpts($excerpts, $defaults);
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '($page, $defaults) is deprecated since Grav 1.6.10, use ->init(new ' . Excerpts::class . '($page, [\'markdown\' => $defaults])) instead.', E_USER_DEPRECATED);
+ } else {
+ $this->excerpts = $excerpts;
+ }
+
+ $this->BlockTypes['{'][] = 'TwigTag';
+ $this->special_chars = ['>' => 'gt', '<' => 'lt', '"' => 'quot'];
+
+ $defaults = $this->excerpts->getConfig();
+
+ if (isset($defaults['markdown']['auto_line_breaks'])) {
+ $this->setBreaksEnabled($defaults['markdown']['auto_line_breaks']);
+ }
+ if (isset($defaults['markdown']['auto_url_links'])) {
+ $this->setUrlsLinked($defaults['markdown']['auto_url_links']);
+ }
+ if (isset($defaults['markdown']['escape_markup'])) {
+ $this->setMarkupEscaped($defaults['markdown']['escape_markup']);
+ }
+ if (isset($defaults['markdown']['special_chars'])) {
+ $this->setSpecialChars($defaults['markdown']['special_chars']);
+ }
+
+ $this->excerpts->fireInitializedEvent($this);
+ }
+
+ /**
+ * @return Excerpts
+ */
+ public function getExcerpts()
+ {
+ return $this->excerpts;
+ }
+
+ /**
+ * Be able to define a new Block type or override an existing one
+ *
+ * @param string $type
+ * @param string $tag
+ * @param bool $continuable
+ * @param bool $completable
+ * @param int|null $index
+ */
+ public function addBlockType($type, $tag, $continuable = false, $completable = false, $index = null)
+ {
+ $block = &$this->unmarkedBlockTypes;
+ if ($type) {
+ if (!isset($this->BlockTypes[$type])) {
+ $this->BlockTypes[$type] = [];
+ }
+ $block = &$this->BlockTypes[$type];
+ }
+
+ if (null === $index) {
+ $block[] = $tag;
+ } else {
+ array_splice($block, $index, 0, [$tag]);
+ }
+
+ if ($continuable) {
+ $this->continuable_blocks[] = $tag;
+ }
+ if ($completable) {
+ $this->completable_blocks[] = $tag;
+ }
+ }
+
+ /**
+ * Be able to define a new Inline type or override an existing one
+ *
+ * @param string $type
+ * @param string $tag
+ * @param int|null $index
+ */
+ public function addInlineType($type, $tag, $index = null)
+ {
+ if (null === $index || !isset($this->InlineTypes[$type])) {
+ $this->InlineTypes[$type] [] = $tag;
+ } else {
+ array_splice($this->InlineTypes[$type], $index, 0, [$tag]);
+ }
+
+ if (strpos($this->inlineMarkerList, $type) === false) {
+ $this->inlineMarkerList .= $type;
+ }
+ }
+
+ /**
+ * Overrides the default behavior to allow for plugin-provided blocks to be continuable
+ *
+ * @param string $Type
+ *
+ * @return bool
+ */
+ protected function isBlockContinuable($Type)
+ {
+ $continuable = \in_array($Type, $this->continuable_blocks, true)
+ || method_exists($this, 'block' . $Type . 'Continue');
+
+ return $continuable;
+ }
+
+ /**
+ * Overrides the default behavior to allow for plugin-provided blocks to be completable
+ *
+ * @param string $Type
+ *
+ * @return bool
+ */
+ protected function isBlockCompletable($Type)
+ {
+ $completable = \in_array($Type, $this->completable_blocks, true)
+ || method_exists($this, 'block' . $Type . 'Complete');
+
+ return $completable;
+ }
+
+
+ /**
+ * Make the element function publicly accessible, Medium uses this to render from Twig
+ *
+ * @param array $Element
+ *
+ * @return string markup
+ */
+ public function elementToHtml(array $Element)
+ {
+ return $this->element($Element);
+ }
+
+ /**
+ * Setter for special chars
+ *
+ * @param array $special_chars
+ *
+ * @return $this
+ */
+ public function setSpecialChars($special_chars)
+ {
+ $this->special_chars = $special_chars;
+
+ return $this;
+ }
+
+ /**
+ * Ensure Twig tags are treated as block level items with no
tags
+ *
+ * @param array $line
+ * @return array|null
+ */
+ protected function blockTwigTag($line)
+ {
+ if (preg_match('/(?:{{|{%|{#)(.*)(?:}}|%}|#})/', $line['body'], $matches)) {
+ return ['markup' => $line['body']];
+ }
+
+ return null;
+ }
+
+ protected function inlineSpecialCharacter($excerpt)
+ {
+ if ($excerpt['text'][0] === '&' && !preg_match('/^?\w+;/', $excerpt['text'])) {
+ return [
+ 'markup' => '&',
+ 'extent' => 1,
+ ];
+ }
+
+ if (isset($this->special_chars[$excerpt['text'][0]])) {
+ return [
+ 'markup' => '&' . $this->special_chars[$excerpt['text'][0]] . ';',
+ 'extent' => 1,
+ ];
+ }
+
+ return null;
+ }
+
+ protected function inlineImage($excerpt)
+ {
+ if (preg_match($this->twig_link_regex, $excerpt['text'], $matches)) {
+ $excerpt['text'] = str_replace($matches[1], '/', $excerpt['text']);
+ $excerpt = parent::inlineImage($excerpt);
+ $excerpt['element']['attributes']['src'] = $matches[1];
+ $excerpt['extent'] = $excerpt['extent'] + strlen($matches[1]) - 1;
+
+ return $excerpt;
+ }
+
+ $excerpt['type'] = 'image';
+ $excerpt = parent::inlineImage($excerpt);
+
+ // if this is an image process it
+ if (isset($excerpt['element']['attributes']['src'])) {
+ $excerpt = $this->excerpts->processImageExcerpt($excerpt);
+ }
+
+ return $excerpt;
+ }
+
+ protected function inlineLink($excerpt)
+ {
+ $type = $excerpt['type'] ?? 'link';
+
+ // do some trickery to get around Parsedown requirement for valid URL if its Twig in there
+ if (preg_match($this->twig_link_regex, $excerpt['text'], $matches)) {
+ $excerpt['text'] = str_replace($matches[1], '/', $excerpt['text']);
+ $excerpt = parent::inlineLink($excerpt);
+ $excerpt['element']['attributes']['href'] = $matches[1];
+ $excerpt['extent'] = $excerpt['extent'] + strlen($matches[1]) - 1;
+
+ return $excerpt;
+ }
+
+ $excerpt = parent::inlineLink($excerpt);
+
+ // if this is a link
+ if (isset($excerpt['element']['attributes']['href'])) {
+ $excerpt = $this->excerpts->processLinkExcerpt($excerpt, $type);
+ }
+
+ return $excerpt;
+ }
+
+ /**
+ * For extending this class via plugins
+ */
+ public function __call($method, $args)
+ {
+ if (isset($this->{$method}) === true) {
+ $func = $this->{$method};
+
+ return \call_user_func_array($func, $args);
+ }
+
+ return null;
+ }
+}
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php
new file mode 100644
index 0000000..9f91663
--- /dev/null
+++ b/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php
@@ -0,0 +1,23 @@
+getMediaFolder();
+
+ if (strpos($folder, '://')) {
+ return $folder;
+ }
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ $user = $locator->findResource('user://');
+ if (strpos($folder, $user) === 0) {
+ return 'user://' . substr($folder, \strlen($user)+1);
+ }
+
+ return null;
+ }
+
+ /**
+ * Gets the associated media collection.
+ *
+ * @return MediaCollectionInterface Representation of associated media.
+ */
+ public function getMedia()
+ {
+ if ($this->media === null) {
+ $cache = $this->getMediaCache();
+
+ // Use cached media if possible.
+ $cacheKey = md5('media' . $this->getCacheKey());
+ if (!$media = $cache->get($cacheKey)) {
+ $media = new Media($this->getMediaFolder(), $this->getMediaOrder());
+ $cache->set($cacheKey, $media);
+ }
+ $this->media = $media;
+ }
+
+ return $this->media;
+ }
+
+ /**
+ * Sets the associated media collection.
+ *
+ * @param MediaCollectionInterface $media Representation of associated media.
+ * @return $this
+ */
+ protected function setMedia(MediaCollectionInterface $media)
+ {
+ $cache = $this->getMediaCache();
+ $cacheKey = md5('media' . $this->getCacheKey());
+ $cache->set($cacheKey, $media);
+
+ $this->media = $media;
+
+ return $this;
+ }
+
+ /**
+ * Clear media cache.
+ */
+ protected function clearMediaCache()
+ {
+ $cache = $this->getMediaCache();
+ $cacheKey = md5('media' . $this->getCacheKey());
+ $cache->delete($cacheKey);
+
+ $this->media = null;
+ }
+
+ /**
+ * @return CacheInterface
+ */
+ protected function getMediaCache()
+ {
+ /** @var Cache $cache */
+ $cache = Grav::instance()['cache'];
+
+ return $cache->getSimpleCache();
+ }
+
+ /**
+ * @return string
+ */
+ abstract protected function getCacheKey(): string;
+}
diff --git a/system/src/Grav/Common/Page/Collection.php b/system/src/Grav/Common/Page/Collection.php
new file mode 100644
index 0000000..51de16b
--- /dev/null
+++ b/system/src/Grav/Common/Page/Collection.php
@@ -0,0 +1,630 @@
+params = $params;
+ $this->pages = $pages ? $pages : Grav::instance()->offsetGet('pages');
+ }
+
+ /**
+ * Get the collection params
+ *
+ * @return array
+ */
+ public function params()
+ {
+ return $this->params;
+ }
+
+ /**
+ * Add a single page to a collection
+ *
+ * @param PageInterface $page
+ *
+ * @return $this
+ */
+ public function addPage(PageInterface $page)
+ {
+ $this->items[$page->path()] = ['slug' => $page->slug()];
+
+ return $this;
+ }
+
+ /**
+ * Add a page with path and slug
+ *
+ * @param string $path
+ * @param string $slug
+ * @return $this
+ */
+ public function add($path, $slug)
+ {
+ $this->items[$path] = ['slug' => $slug];
+
+ return $this;
+ }
+
+ /**
+ *
+ * Create a copy of this collection
+ *
+ * @return static
+ */
+ public function copy()
+ {
+ return new static($this->items, $this->params, $this->pages);
+ }
+
+ /**
+ *
+ * Merge another collection with the current collection
+ *
+ * @param Collection $collection
+ * @return $this
+ */
+ public function merge(Collection $collection)
+ {
+ foreach($collection as $page) {
+ $this->addPage($page);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Intersect another collection with the current collection
+ *
+ * @param Collection $collection
+ * @return $this
+ */
+ public function intersect(Collection $collection)
+ {
+ $array1 = $this->items;
+ $array2 = $collection->toArray();
+
+ $this->items = array_uintersect($array1, $array2, function($val1, $val2) {
+ return strcmp($val1['slug'], $val2['slug']);
+ });
+
+ return $this;
+ }
+
+ /**
+ * Set parameters to the Collection
+ *
+ * @param array $params
+ *
+ * @return $this
+ */
+ public function setParams(array $params)
+ {
+ $this->params = array_merge($this->params, $params);
+
+ return $this;
+ }
+
+ /**
+ * Returns current page.
+ *
+ * @return PageInterface
+ */
+ public function current()
+ {
+ $current = parent::key();
+
+ return $this->pages->get($current);
+ }
+
+ /**
+ * Returns current slug.
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ $current = parent::current();
+
+ return $current['slug'];
+ }
+
+ /**
+ * Returns the value at specified offset.
+ *
+ * @param mixed $offset The offset to retrieve.
+ *
+ * @return mixed Can return all value types.
+ */
+ public function offsetGet($offset)
+ {
+ return $this->pages->get($offset) ?: null;
+ }
+
+ /**
+ * Split collection into array of smaller collections.
+ *
+ * @param int $size
+ * @return array|Collection[]
+ */
+ public function batch($size)
+ {
+ $chunks = array_chunk($this->items, $size, true);
+
+ $list = [];
+ foreach ($chunks as $chunk) {
+ $list[] = new static($chunk, $this->params, $this->pages);
+ }
+
+ return $list;
+ }
+
+ /**
+ * Remove item from the list.
+ *
+ * @param PageInterface|string|null $key
+ *
+ * @return $this
+ * @throws \InvalidArgumentException
+ */
+ public function remove($key = null)
+ {
+ if ($key instanceof PageInterface) {
+ $key = $key->path();
+ } elseif (null === $key) {
+ $key = (string)key($this->items);
+ }
+ if (!\is_string($key)) {
+ throw new \InvalidArgumentException('Invalid argument $key.');
+ }
+
+ parent::remove($key);
+
+ return $this;
+ }
+
+ /**
+ * Reorder collection.
+ *
+ * @param string $by
+ * @param string $dir
+ * @param array $manual
+ * @param string $sort_flags
+ *
+ * @return $this
+ */
+ public function order($by, $dir = 'asc', $manual = null, $sort_flags = null)
+ {
+ $this->items = $this->pages->sortCollection($this, $by, $dir, $manual, $sort_flags);
+
+ return $this;
+ }
+
+ /**
+ * Check to see if this item is the first in the collection.
+ *
+ * @param string $path
+ *
+ * @return bool True if item is first.
+ */
+ public function isFirst($path)
+ {
+ return $this->items && $path === array_keys($this->items)[0];
+ }
+
+ /**
+ * Check to see if this item is the last in the collection.
+ *
+ * @param string $path
+ *
+ * @return bool True if item is last.
+ */
+ public function isLast($path)
+ {
+ return $this->items && $path === array_keys($this->items)[\count($this->items) - 1];
+ }
+
+ /**
+ * Gets the previous sibling based on current position.
+ *
+ * @param string $path
+ *
+ * @return PageInterface The previous item.
+ */
+ public function prevSibling($path)
+ {
+ return $this->adjacentSibling($path, -1);
+ }
+
+ /**
+ * Gets the next sibling based on current position.
+ *
+ * @param string $path
+ *
+ * @return PageInterface The next item.
+ */
+ public function nextSibling($path)
+ {
+ return $this->adjacentSibling($path, 1);
+ }
+
+ /**
+ * Returns the adjacent sibling based on a direction.
+ *
+ * @param string $path
+ * @param int $direction either -1 or +1
+ *
+ * @return PageInterface|Collection The sibling item.
+ */
+ public function adjacentSibling($path, $direction = 1)
+ {
+ $values = array_keys($this->items);
+ $keys = array_flip($values);
+
+ if (array_key_exists($path, $keys)) {
+ $index = $keys[$path] - $direction;
+
+ return isset($values[$index]) ? $this->offsetGet($values[$index]) : $this;
+ }
+
+ return $this;
+
+ }
+
+ /**
+ * Returns the item in the current position.
+ *
+ * @param string $path the path the item
+ *
+ * @return int the index of the current page.
+ */
+ public function currentPosition($path)
+ {
+ return \array_search($path, \array_keys($this->items), true);
+ }
+
+ /**
+ * Returns the items between a set of date ranges of either the page date field (default) or
+ * an arbitrary datetime page field where end date is optional
+ * Dates can be passed in as text that strtotime() can process
+ * http://php.net/manual/en/function.strtotime.php
+ *
+ * @param string $startDate
+ * @param bool $endDate
+ * @param string|null $field
+ *
+ * @return $this
+ * @throws \Exception
+ */
+ public function dateRange($startDate, $endDate = false, $field = null)
+ {
+ $start = Utils::date2timestamp($startDate);
+ $end = $endDate ? Utils::date2timestamp($endDate) : false;
+
+ $date_range = [];
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+ if ($page !== null) {
+ $date = $field ? strtotime($page->value($field)) : $page->date();
+
+ if ($date >= $start && (!$end || $date <= $end)) {
+ $date_range[$path] = $slug;
+ }
+ }
+ }
+
+ $this->items = $date_range;
+
+ return $this;
+ }
+
+ /**
+ * Creates new collection with only visible pages
+ *
+ * @return Collection The collection with only visible pages
+ */
+ public function visible()
+ {
+ $visible = [];
+
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+ if ($page !== null && $page->visible()) {
+ $visible[$path] = $slug;
+ }
+ }
+ $this->items = $visible;
+
+ return $this;
+ }
+
+ /**
+ * Creates new collection with only non-visible pages
+ *
+ * @return Collection The collection with only non-visible pages
+ */
+ public function nonVisible()
+ {
+ $visible = [];
+
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+ if ($page !== null && !$page->visible()) {
+ $visible[$path] = $slug;
+ }
+ }
+ $this->items = $visible;
+
+ return $this;
+ }
+
+ /**
+ * Creates new collection with only modular pages
+ *
+ * @return Collection The collection with only modular pages
+ */
+ public function modular()
+ {
+ $modular = [];
+
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+ if ($page !== null && $page->modular()) {
+ $modular[$path] = $slug;
+ }
+ }
+ $this->items = $modular;
+
+ return $this;
+ }
+
+ /**
+ * Creates new collection with only non-modular pages
+ *
+ * @return Collection The collection with only non-modular pages
+ */
+ public function nonModular()
+ {
+ $modular = [];
+
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+ if ($page !== null && !$page->modular()) {
+ $modular[$path] = $slug;
+ }
+ }
+ $this->items = $modular;
+
+ return $this;
+ }
+
+ /**
+ * Creates new collection with only published pages
+ *
+ * @return Collection The collection with only published pages
+ */
+ public function published()
+ {
+ $published = [];
+
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+ if ($page !== null && $page->published()) {
+ $published[$path] = $slug;
+ }
+ }
+ $this->items = $published;
+
+ return $this;
+ }
+
+ /**
+ * Creates new collection with only non-published pages
+ *
+ * @return Collection The collection with only non-published pages
+ */
+ public function nonPublished()
+ {
+ $published = [];
+
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+ if ($page !== null && !$page->published()) {
+ $published[$path] = $slug;
+ }
+ }
+ $this->items = $published;
+
+ return $this;
+ }
+
+ /**
+ * Creates new collection with only routable pages
+ *
+ * @return Collection The collection with only routable pages
+ */
+ public function routable()
+ {
+ $routable = [];
+
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+
+ if ($page !== null && $page->routable()) {
+ $routable[$path] = $slug;
+ }
+ }
+
+ $this->items = $routable;
+
+ return $this;
+ }
+
+ /**
+ * Creates new collection with only non-routable pages
+ *
+ * @return Collection The collection with only non-routable pages
+ */
+ public function nonRoutable()
+ {
+ $routable = [];
+
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+ if ($page !== null && !$page->routable()) {
+ $routable[$path] = $slug;
+ }
+ }
+ $this->items = $routable;
+
+ return $this;
+ }
+
+ /**
+ * Creates new collection with only pages of the specified type
+ *
+ * @param string $type
+ *
+ * @return Collection The collection
+ */
+ public function ofType($type)
+ {
+ $items = [];
+
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+ if ($page !== null && $page->template() === $type) {
+ $items[$path] = $slug;
+ }
+ }
+
+ $this->items = $items;
+
+ return $this;
+ }
+
+ /**
+ * Creates new collection with only pages of one of the specified types
+ *
+ * @param string[] $types
+ *
+ * @return Collection The collection
+ */
+ public function ofOneOfTheseTypes($types)
+ {
+ $items = [];
+
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+ if ($page !== null && \in_array($page->template(), $types, true)) {
+ $items[$path] = $slug;
+ }
+ }
+
+ $this->items = $items;
+
+ return $this;
+ }
+
+ /**
+ * Creates new collection with only pages of one of the specified access levels
+ *
+ * @param array $accessLevels
+ *
+ * @return Collection The collection
+ */
+ public function ofOneOfTheseAccessLevels($accessLevels)
+ {
+ $items = [];
+
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+
+ if ($page !== null && isset($page->header()->access)) {
+ if (\is_array($page->header()->access)) {
+ //Multiple values for access
+ $valid = false;
+
+ foreach ($page->header()->access as $index => $accessLevel) {
+ if (\is_array($accessLevel)) {
+ foreach ($accessLevel as $innerIndex => $innerAccessLevel) {
+ if (\in_array($innerAccessLevel, $accessLevels)) {
+ $valid = true;
+ }
+ }
+ } else {
+ if (\in_array($index, $accessLevels)) {
+ $valid = true;
+ }
+ }
+ }
+ if ($valid) {
+ $items[$path] = $slug;
+ }
+ } else {
+ //Single value for access
+ if (\in_array($page->header()->access, $accessLevels)) {
+ $items[$path] = $slug;
+ }
+ }
+
+ }
+ }
+
+ $this->items = $items;
+
+ return $this;
+ }
+
+ /**
+ * Get the extended version of this Collection with each page keyed by route
+ *
+ * @return array
+ * @throws \Exception
+ */
+ public function toExtendedArray()
+ {
+ $items = [];
+ foreach ($this->items as $path => $slug) {
+ $page = $this->pages->get($path);
+
+ if ($page !== null) {
+ $items[$page->route()] = $page->toArray();
+ }
+ }
+ return $items;
+ }
+}
diff --git a/system/src/Grav/Common/Page/Header.php b/system/src/Grav/Common/Page/Header.php
new file mode 100644
index 0000000..e3854ae
--- /dev/null
+++ b/system/src/Grav/Common/Page/Header.php
@@ -0,0 +1,18 @@
+true) for example
+ *
+ * @param array $var an Array of name value pairs where the name is the process and value is true or false
+ *
+ * @return array an Array of name value pairs where the name is the process and value is true or false
+ */
+ public function process($var = null);
+
+ /**
+ * Gets and Sets the slug for the Page. The slug is used in the URL routing. If not set it uses
+ * the parent folder from the path
+ *
+ * @param string $var the slug, e.g. 'my-blog'
+ *
+ * @return string the slug
+ */
+ public function slug($var = null);
+
+ /**
+ * Get/set order number of this page.
+ *
+ * @param int $var
+ *
+ * @return int|bool
+ */
+ public function order($var = null);
+
+ /**
+ * Gets and sets the identifier for this Page object.
+ *
+ * @param string $var the identifier
+ *
+ * @return string the identifier
+ */
+ public function id($var = null);
+
+ /**
+ * Gets and sets the modified timestamp.
+ *
+ * @param int $var modified unix timestamp
+ *
+ * @return int modified unix timestamp
+ */
+ public function modified($var = null);
+
+ /**
+ * Gets and sets the option to show the last_modified header for the page.
+ *
+ * @param boolean $var show last_modified header
+ *
+ * @return boolean show last_modified header
+ */
+ public function lastModified($var = null);
+
+ /**
+ * Get/set the folder.
+ *
+ * @param string $var Optional path
+ *
+ * @return string|null
+ */
+ public function folder($var = null);
+
+ /**
+ * Gets and sets the date for this Page object. This is typically passed in via the page headers
+ *
+ * @param string $var string representation of a date
+ *
+ * @return int unix timestamp representation of the date
+ */
+ public function date($var = null);
+
+ /**
+ * Gets and sets the date format for this Page object. This is typically passed in via the page headers
+ * using typical PHP date string structure - http://php.net/manual/en/function.date.php
+ *
+ * @param string $var string representation of a date format
+ *
+ * @return string string representation of a date format
+ */
+ public function dateformat($var = null);
+
+ /**
+ * Gets and sets the taxonomy array which defines which taxonomies this page identifies itself with.
+ *
+ * @param array $var an array of taxonomies
+ *
+ * @return array an array of taxonomies
+ */
+ public function taxonomy($var = null);
+
+ /**
+ * Gets the configured state of the processing method.
+ *
+ * @param string $process the process, eg "twig" or "markdown"
+ *
+ * @return bool whether or not the processing method is enabled for this Page
+ */
+ public function shouldProcess($process);
+
+ /**
+ * Returns whether or not this Page object has a .md file associated with it or if its just a directory.
+ *
+ * @return bool True if its a page with a .md file associated
+ */
+ public function isPage();
+
+ /**
+ * Returns whether or not this Page object is a directory or a page.
+ *
+ * @return bool True if its a directory
+ */
+ public function isDir();
+
+ /**
+ * Returns whether the page exists in the filesystem.
+ *
+ * @return bool
+ */
+ public function exists();
+}
diff --git a/system/src/Grav/Common/Page/Interfaces/PageInterface.php b/system/src/Grav/Common/Page/Interfaces/PageInterface.php
new file mode 100644
index 0000000..24bf50c
--- /dev/null
+++ b/system/src/Grav/Common/Page/Interfaces/PageInterface.php
@@ -0,0 +1,19 @@
+save() in order to perform the move.
+ *
+ * @param PageInterface $parent New parent page.
+ *
+ * @return $this
+ */
+ public function move(PageInterface $parent);
+
+ /**
+ * Prepare a copy from the page. Copies also everything that's under the current page.
+ *
+ * Returns a new Page object for the copy.
+ * You need to call $this->save() in order to perform the move.
+ *
+ * @param PageInterface $parent New parent page.
+ *
+ * @return $this
+ */
+ public function copy(PageInterface $parent);
+
+ /**
+ * Get blueprints for the page.
+ *
+ * @return Blueprint
+ */
+ public function blueprints();
+
+ /**
+ * Get the blueprint name for this page. Use the blueprint form field if set
+ *
+ * @return string
+ */
+ public function blueprintName();
+
+ /**
+ * Validate page header.
+ *
+ * @throws Exception
+ */
+ public function validate();
+
+ /**
+ * Filter page header from illegal contents.
+ */
+ public function filter();
+
+ /**
+ * Get unknown header variables.
+ *
+ * @return array
+ */
+ public function extra();
+
+ /**
+ * Convert page to an array.
+ *
+ * @return array
+ */
+ public function toArray();
+
+ /**
+ * Convert page to YAML encoded string.
+ *
+ * @return string
+ */
+ public function toYaml();
+
+ /**
+ * Convert page to JSON encoded string.
+ *
+ * @return string
+ */
+ public function toJson();
+
+ /**
+ * Returns normalized list of name => form pairs.
+ *
+ * @return array
+ */
+ public function forms();
+
+ /**
+ * @param array $new
+ */
+ public function addForms(array $new);
+
+ /**
+ * Gets and sets the name field. If no name field is set, it will return 'default.md'.
+ *
+ * @param string $var The name of this page.
+ *
+ * @return string The name of this page.
+ */
+ public function name($var = null);
+
+ /**
+ * Returns child page type.
+ *
+ * @return string
+ */
+ public function childType();
+
+ /**
+ * Gets and sets the template field. This is used to find the correct Twig template file to render.
+ * If no field is set, it will return the name without the .md extension
+ *
+ * @param string $var the template name
+ *
+ * @return string the template name
+ */
+ public function template($var = null);
+
+ /**
+ * Allows a page to override the output render format, usually the extension provided
+ * in the URL. (e.g. `html`, `json`, `xml`, etc).
+ *
+ * @param null $var
+ *
+ * @return null
+ */
+ public function templateFormat($var = null);
+
+ /**
+ * Gets and sets the extension field.
+ *
+ * @param null $var
+ *
+ * @return null|string
+ */
+ public function extension($var = null);
+
+ /**
+ * Gets and sets the expires field. If not set will return the default
+ *
+ * @param int $var The new expires value.
+ *
+ * @return int The expires value
+ */
+ public function expires($var = null);
+
+ /**
+ * Gets and sets the cache-control property. If not set it will return the default value (null)
+ * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control for more details on valid options
+ *
+ * @param null $var
+ * @return null
+ */
+ public function cacheControl($var = null);
+
+ public function ssl($var = null);
+
+ /**
+ * Returns the state of the debugger override etting for this page
+ *
+ * @return mixed
+ */
+ public function debugger();
+
+ /**
+ * Function to merge page metadata tags and build an array of Metadata objects
+ * that can then be rendered in the page.
+ *
+ * @param array $var an Array of metadata values to set
+ *
+ * @return array an Array of metadata values for the page
+ */
+ public function metadata($var = null);
+
+ /**
+ * Gets and sets the option to show the etag header for the page.
+ *
+ * @param bool $var show etag header
+ *
+ * @return bool show etag header
+ */
+ public function eTag($var = null);
+
+ /**
+ * Gets and sets the path to the .md file for this Page object.
+ *
+ * @param string $var the file path
+ *
+ * @return string|null the file path
+ */
+ public function filePath($var = null);
+
+ /**
+ * Gets the relative path to the .md file
+ *
+ * @return string The relative file path
+ */
+ public function filePathClean();
+
+ /**
+ * Gets and sets the order by which any sub-pages should be sorted.
+ *
+ * @param string $var the order, either "asc" or "desc"
+ *
+ * @return string the order, either "asc" or "desc"
+ * @deprecated 1.6
+ */
+ public function orderDir($var = null);
+
+ /**
+ * Gets and sets the order by which the sub-pages should be sorted.
+ *
+ * default - is the order based on the file system, ie 01.Home before 02.Advark
+ * title - is the order based on the title set in the pages
+ * date - is the order based on the date set in the pages
+ * folder - is the order based on the name of the folder with any numerics omitted
+ *
+ * @param string $var supported options include "default", "title", "date", and "folder"
+ *
+ * @return string supported options include "default", "title", "date", and "folder"
+ * @deprecated 1.6
+ */
+ public function orderBy($var = null);
+
+ /**
+ * Gets the manual order set in the header.
+ *
+ * @param string $var supported options include "default", "title", "date", and "folder"
+ *
+ * @return array
+ * @deprecated 1.6
+ */
+ public function orderManual($var = null);
+
+ /**
+ * Gets and sets the maxCount field which describes how many sub-pages should be displayed if the
+ * sub_pages header property is set for this page object.
+ *
+ * @param int $var the maximum number of sub-pages
+ *
+ * @return int the maximum number of sub-pages
+ * @deprecated 1.6
+ */
+ public function maxCount($var = null);
+
+ /**
+ * Gets and sets the modular var that helps identify this page is a modular child
+ *
+ * @param bool $var true if modular_twig
+ *
+ * @return bool true if modular_twig
+ */
+ public function modular($var = null);
+
+ /**
+ * Gets and sets the modular_twig var that helps identify this page as a modular child page that will need
+ * twig processing handled differently from a regular page.
+ *
+ * @param bool $var true if modular_twig
+ *
+ * @return bool true if modular_twig
+ */
+ public function modularTwig($var = null);
+
+ /**
+ * Returns children of this page.
+ *
+ * @return \Grav\Common\Page\Collection
+ */
+ public function children();
+
+ /**
+ * Check to see if this item is the first in an array of sub-pages.
+ *
+ * @return bool True if item is first.
+ */
+ public function isFirst();
+
+ /**
+ * Check to see if this item is the last in an array of sub-pages.
+ *
+ * @return bool True if item is last
+ */
+ public function isLast();
+
+ /**
+ * Gets the previous sibling based on current position.
+ *
+ * @return PageInterface the previous Page item
+ */
+ public function prevSibling();
+
+ /**
+ * Gets the next sibling based on current position.
+ *
+ * @return PageInterface the next Page item
+ */
+ public function nextSibling();
+
+ /**
+ * Returns the adjacent sibling based on a direction.
+ *
+ * @param int $direction either -1 or +1
+ *
+ * @return PageInterface|bool the sibling page
+ */
+ public function adjacentSibling($direction = 1);
+
+ /**
+ * Helper method to return an ancestor page.
+ *
+ * @param bool $lookup Name of the parent folder
+ *
+ * @return PageInterface page you were looking for if it exists
+ */
+ public function ancestor($lookup = null);
+
+ /**
+ * Helper method to return an ancestor page to inherit from. The current
+ * page object is returned.
+ *
+ * @param string $field Name of the parent folder
+ *
+ * @return PageInterface
+ */
+ public function inherited($field);
+
+ /**
+ * Helper method to return an ancestor field only to inherit from. The
+ * first occurrence of an ancestor field will be returned if at all.
+ *
+ * @param string $field Name of the parent folder
+ *
+ * @return array
+ */
+ public function inheritedField($field);
+
+ /**
+ * Helper method to return a page.
+ *
+ * @param string $url the url of the page
+ * @param bool $all
+ *
+ * @return PageInterface page you were looking for if it exists
+ */
+ public function find($url, $all = false);
+
+ /**
+ * Get a collection of pages in the current context.
+ *
+ * @param string|array $params
+ * @param bool $pagination
+ *
+ * @return Collection
+ * @throws \InvalidArgumentException
+ */
+ public function collection($params = 'content', $pagination = true);
+
+ /**
+ * @param string|array $value
+ * @param bool $only_published
+ * @return mixed
+ * @internal
+ */
+ public function evaluate($value, $only_published = true);
+
+ /**
+ * Returns whether or not the current folder exists
+ *
+ * @return bool
+ */
+ public function folderExists();
+
+ /**
+ * Gets the Page Unmodified (original) version of the page.
+ *
+ * @return PageInterface The original version of the page.
+ */
+ public function getOriginal();
+
+ /**
+ * Gets the action.
+ *
+ * @return string The Action string.
+ */
+ public function getAction();
+}
diff --git a/system/src/Grav/Common/Page/Interfaces/PageRoutableInterface.php b/system/src/Grav/Common/Page/Interfaces/PageRoutableInterface.php
new file mode 100644
index 0000000..c3afeab
--- /dev/null
+++ b/system/src/Grav/Common/Page/Interfaces/PageRoutableInterface.php
@@ -0,0 +1,188 @@
+page = $page ?? Grav::instance()['page'] ?? null;
+
+ // Add defaults to the configuration.
+ if (null === $config || !isset($config['markdown'], $config['images'])) {
+ $c = Grav::instance()['config'];
+ $config = $config ?? [];
+ $config += [
+ 'markdown' => $c->get('system.pages.markdown', []),
+ 'images' => $c->get('system.images', [])
+ ];
+ }
+
+ $this->config = $config;
+ }
+
+ public function getPage(): PageInterface
+ {
+ return $this->page;
+ }
+
+ public function getConfig(): array
+ {
+ return $this->config;
+ }
+
+ public function fireInitializedEvent($markdown): void
+ {
+ $grav = Grav::instance();
+
+ $grav->fireEvent('onMarkdownInitialized', new Event(['markdown' => $markdown, 'page' => $this->page]));
+ }
+
+ /**
+ * Process a Link excerpt
+ *
+ * @param array $excerpt
+ * @param string $type
+ * @return array
+ */
+ public function processLinkExcerpt(array $excerpt, string $type = 'link'): array
+ {
+ $url = htmlspecialchars_decode(rawurldecode($excerpt['element']['attributes']['href']));
+
+ $url_parts = $this->parseUrl($url);
+
+ // If there is a query, then parse it and build action calls.
+ if (isset($url_parts['query'])) {
+ $actions = array_reduce(
+ explode('&', $url_parts['query']),
+ static function ($carry, $item) {
+ $parts = explode('=', $item, 2);
+ $value = isset($parts[1]) ? rawurldecode($parts[1]) : true;
+ $carry[$parts[0]] = $value;
+
+ return $carry;
+ },
+ []
+ );
+
+ // Valid attributes supported.
+ $valid_attributes = Grav::instance()['config']->get('system.pages.markdown.valid_link_attributes');
+
+ // Unless told to not process, go through actions.
+ if (array_key_exists('noprocess', $actions)) {
+ unset($actions['noprocess']);
+ } else {
+ // Loop through actions for the image and call them.
+ foreach ($actions as $attrib => $value) {
+ $key = $attrib;
+
+ if (in_array($attrib, $valid_attributes, true)) {
+ // support both class and classes.
+ if ($attrib === 'classes') {
+ $attrib = 'class';
+ }
+ $excerpt['element']['attributes'][$attrib] = str_replace(',', ' ', $value);
+ unset($actions[$key]);
+ }
+ }
+ }
+
+ $url_parts['query'] = http_build_query($actions, null, '&', PHP_QUERY_RFC3986);
+ }
+
+ // If no query elements left, unset query.
+ if (empty($url_parts['query'])) {
+ unset ($url_parts['query']);
+ }
+
+ // Set path to / if not set.
+ if (empty($url_parts['path'])) {
+ $url_parts['path'] = '';
+ }
+
+ // If scheme isn't http(s)..
+ if (!empty($url_parts['scheme']) && !in_array($url_parts['scheme'], ['http', 'https'])) {
+ // Handle custom streams.
+ if ($type !== 'image' && !empty($url_parts['stream']) && !empty($url_parts['path'])) {
+ $grav = Grav::instance();
+ $url_parts['path'] = $grav['base_url_relative'] . '/' . $this->resolveStream("{$url_parts['scheme']}://{$url_parts['path']}");
+ unset($url_parts['stream'], $url_parts['scheme']);
+ }
+
+ $excerpt['element']['attributes']['href'] = Uri::buildUrl($url_parts);
+
+ return $excerpt;
+ }
+
+ // Handle paths and such.
+ $url_parts = Uri::convertUrl($this->page, $url_parts, $type);
+
+ // Build the URL from the component parts and set it on the element.
+ $excerpt['element']['attributes']['href'] = Uri::buildUrl($url_parts);
+
+ return $excerpt;
+ }
+
+ /**
+ * Process an image excerpt
+ *
+ * @param array $excerpt
+ * @return array
+ */
+ public function processImageExcerpt(array $excerpt): array
+ {
+ $url = htmlspecialchars_decode(urldecode($excerpt['element']['attributes']['src']));
+ $url_parts = $this->parseUrl($url);
+
+ $media = null;
+ $filename = null;
+
+ if (!empty($url_parts['stream'])) {
+ $filename = $url_parts['scheme'] . '://' . ($url_parts['path'] ?? '');
+
+ $media = $this->page->getMedia();
+
+ } else {
+ $grav = Grav::instance();
+
+ // File is also local if scheme is http(s) and host matches.
+ $local_file = isset($url_parts['path'])
+ && (empty($url_parts['scheme']) || in_array($url_parts['scheme'], ['http', 'https'], true))
+ && (empty($url_parts['host']) || $url_parts['host'] === $grav['uri']->host());
+
+ if ($local_file) {
+ $filename = basename($url_parts['path']);
+ $folder = dirname($url_parts['path']);
+
+ // Get the local path to page media if possible.
+ if ($this->page && $folder === $this->page->url(false, false, false)) {
+ // Get the media objects for this page.
+ $media = $this->page->getMedia();
+ } else {
+ // see if this is an external page to this one
+ $base_url = rtrim($grav['base_url_relative'] . $grav['pages']->base(), '/');
+ $page_route = '/' . ltrim(str_replace($base_url, '', $folder), '/');
+
+ /** @var PageInterface $ext_page */
+ $ext_page = $grav['pages']->dispatch($page_route, true);
+ if ($ext_page) {
+ $media = $ext_page->getMedia();
+ } else {
+ $grav->fireEvent('onMediaLocate', new Event(['route' => $page_route, 'media' => &$media]));
+ }
+ }
+ }
+ }
+
+ // If there is a media file that matches the path referenced..
+ if ($media && $filename && isset($media[$filename])) {
+ // Get the medium object.
+ /** @var Medium $medium */
+ $medium = $media[$filename];
+
+ // Process operations
+ $medium = $this->processMediaActions($medium, $url_parts);
+ $element_excerpt = $excerpt['element']['attributes'];
+
+ $alt = $element_excerpt['alt'] ?? '';
+ $title = $element_excerpt['title'] ?? '';
+ $class = $element_excerpt['class'] ?? '';
+ $id = $element_excerpt['id'] ?? '';
+
+ $excerpt['element'] = $medium->parsedownElement($title, $alt, $class, $id, true);
+
+ } else {
+ // Not a current page media file, see if it needs converting to relative.
+ $excerpt['element']['attributes']['src'] = Uri::buildUrl($url_parts);
+ }
+
+ return $excerpt;
+ }
+
+ /**
+ * Process media actions
+ *
+ * @param Medium $medium
+ * @param string|array $url
+ * @return Medium|Link
+ */
+ public function processMediaActions($medium, $url)
+ {
+ $url_parts = is_string($url) ? $this->parseUrl($url) : $url;
+ $actions = [];
+
+
+ // if there is a query, then parse it and build action calls
+ if (isset($url_parts['query'])) {
+ $actions = array_reduce(
+ explode('&', $url_parts['query']),
+ static function ($carry, $item) {
+ $parts = explode('=', $item, 2);
+ $value = $parts[1] ?? null;
+ $carry[] = ['method' => $parts[0], 'params' => $value];
+
+ return $carry;
+ },
+ []
+ );
+ }
+
+ $config = $this->getConfig();
+ if (!empty($config['images']['auto_fix_orientation'])) {
+ $actions[] = ['method' => 'fixOrientation', 'params' => ''];
+ }
+
+ $defaults = $config['images']['defaults'] ?? [];
+ if (count($defaults)) {
+ foreach ($defaults as $method => $params) {
+ $actions[] = [
+ 'method' => $method,
+ 'params' => $params,
+ ];
+ }
+ }
+
+ // loop through actions for the image and call them
+ foreach ($actions as $action) {
+ $matches = [];
+
+ if (preg_match('/\[(.*)\]/', $action['params'], $matches)) {
+ $args = [explode(',', $matches[1])];
+ } else {
+ $args = explode(',', $action['params']);
+ }
+
+ $medium = call_user_func_array([$medium, $action['method']], $args);
+ }
+
+ if (isset($url_parts['fragment'])) {
+ $medium->urlHash($url_parts['fragment']);
+ }
+
+ return $medium;
+ }
+
+ /**
+ * Variation of parse_url() which works also with local streams.
+ *
+ * @param string $url
+ * @return array|bool
+ */
+ protected function parseUrl(string $url)
+ {
+ $url_parts = Utils::multibyteParseUrl($url);
+
+ if (isset($url_parts['scheme'])) {
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+
+ // Special handling for the streams.
+ if ($locator->schemeExists($url_parts['scheme'])) {
+ if (isset($url_parts['host'])) {
+ // Merge host and path into a path.
+ $url_parts['path'] = $url_parts['host'] . (isset($url_parts['path']) ? '/' . $url_parts['path'] : '');
+ unset($url_parts['host']);
+ }
+
+ $url_parts['stream'] = true;
+ }
+ }
+
+ return $url_parts;
+ }
+
+ /**
+ * @param string $url
+ * @return bool|string
+ */
+ protected function resolveStream(string $url)
+ {
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+
+ if ($locator->isStream($url)) {
+ return $locator->findResource($url, false) ?: $locator->findResource($url, false, true);
+ }
+
+ return $url;
+ }
+}
diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php
new file mode 100644
index 0000000..88b2ced
--- /dev/null
+++ b/system/src/Grav/Common/Page/Media.php
@@ -0,0 +1,222 @@
+setPath($path);
+ $this->media_order = $media_order;
+
+ $this->__wakeup();
+ if ($load) {
+ $this->init();
+ }
+ }
+
+ /**
+ * Initialize static variables on unserialize.
+ */
+ public function __wakeup()
+ {
+ if (!isset(static::$global)) {
+ // Add fallback to global media.
+ static::$global = new GlobalMedia();
+ }
+ }
+
+ /**
+ * @param mixed $offset
+ *
+ * @return bool
+ */
+ public function offsetExists($offset)
+ {
+ return parent::offsetExists($offset) ?: isset(static::$global[$offset]);
+ }
+
+ /**
+ * @param mixed $offset
+ *
+ * @return mixed
+ */
+ public function offsetGet($offset)
+ {
+ return parent::offsetGet($offset) ?: static::$global[$offset];
+ }
+
+ /**
+ * Initialize class.
+ */
+ protected function init()
+ {
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ $config = Grav::instance()['config'];
+ $locator = Grav::instance()['locator'];
+ $exif_reader = isset(Grav::instance()['exif']) ? Grav::instance()['exif']->getReader() : false;
+ $media_types = array_keys(Grav::instance()['config']->get('media.types'));
+
+ // Handle special cases where page doesn't exist in filesystem.
+ if (!is_dir($this->getPath())) {
+ return;
+ }
+
+ $iterator = new \FilesystemIterator($this->getPath(), \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::SKIP_DOTS);
+
+ $media = [];
+
+ /** @var \DirectoryIterator $info */
+ foreach ($iterator as $path => $info) {
+ // Ignore folders and Markdown files.
+ if (!$info->isFile() || $info->getExtension() === 'md' || strpos($info->getFilename(), '.') === 0) {
+ continue;
+ }
+
+ // Find out what type we're dealing with
+ list($basename, $ext, $type, $extra) = $this->getFileParts($info->getFilename());
+
+ if (!\in_array(strtolower($ext), $media_types, true)) {
+ continue;
+ }
+
+ if ($type === 'alternative') {
+ $media["{$basename}.{$ext}"][$type][$extra] = ['file' => $path, 'size' => $info->getSize()];
+ } else {
+ $media["{$basename}.{$ext}"][$type] = ['file' => $path, 'size' => $info->getSize()];
+ }
+ }
+
+ foreach ($media as $name => $types) {
+ // First prepare the alternatives in case there is no base medium
+ if (!empty($types['alternative'])) {
+ foreach ($types['alternative'] as $ratio => &$alt) {
+ $alt['file'] = MediumFactory::fromFile($alt['file']);
+
+ if (!$alt['file']) {
+ unset($types['alternative'][$ratio]);
+ } else {
+ $alt['file']->set('size', $alt['size']);
+ }
+ }
+ }
+
+ $file_path = null;
+
+ // Create the base medium
+ if (empty($types['base'])) {
+ if (!isset($types['alternative'])) {
+ continue;
+ }
+
+ $max = max(array_keys($types['alternative']));
+ $medium = $types['alternative'][$max]['file'];
+ $file_path = $medium->path();
+ $medium = MediumFactory::scaledFromMedium($medium, $max, 1)['file'];
+ } else {
+ $medium = MediumFactory::fromFile($types['base']['file']);
+ $medium && $medium->set('size', $types['base']['size']);
+ $file_path = $medium->path();
+ }
+
+ if (empty($medium)) {
+ continue;
+ }
+
+ // metadata file
+ $meta_path = $file_path . '.meta.yaml';
+
+ if (file_exists($meta_path)) {
+ $types['meta']['file'] = $meta_path;
+ } elseif ($file_path && $exif_reader && $medium->get('mime') === 'image/jpeg' && empty($types['meta']) && $config->get('system.media.auto_metadata_exif')) {
+
+ $meta = $exif_reader->read($file_path);
+
+ if ($meta) {
+ $meta_data = $meta->getData();
+ $meta_trimmed = array_diff_key($meta_data, array_flip($this->standard_exif));
+ if ($meta_trimmed) {
+ if ($locator->isStream($meta_path)) {
+ $file = File::instance($locator->findResource($meta_path, true, true));
+ } else {
+ $file = File::instance($meta_path);
+ }
+ $file->save(Yaml::dump($meta_trimmed));
+ $types['meta']['file'] = $meta_path;
+ }
+ }
+ }
+
+ if (!empty($types['meta'])) {
+ $medium->addMetaFile($types['meta']['file']);
+ }
+
+ if (!empty($types['thumb'])) {
+ // We will not turn it into medium yet because user might never request the thumbnail
+ // not wasting any resources on that, maybe we should do this for medium in general?
+ $medium->set('thumbnails.page', $types['thumb']['file']);
+ }
+
+ // Build missing alternatives
+ if (!empty($types['alternative'])) {
+ $alternatives = $types['alternative'];
+ $max = max(array_keys($alternatives));
+
+ for ($i=$max; $i > 1; $i--) {
+ if (isset($alternatives[$i])) {
+ continue;
+ }
+
+ $types['alternative'][$i] = MediumFactory::scaledFromMedium($alternatives[$max]['file'], $max, $i);
+ }
+
+ foreach ($types['alternative'] as $altMedium) {
+ if ($altMedium['file'] != $medium) {
+ $altWidth = $altMedium['file']->get('width');
+ $medWidth = $medium->get('width');
+ if ($altWidth && $medWidth) {
+ $ratio = $altWidth / $medWidth;
+ $medium->addAlternative($ratio, $altMedium['file']);
+ }
+ }
+ }
+ }
+
+ $this->add($name, $medium);
+ }
+ }
+
+ /**
+ * @return string
+ * @deprecated 1.6 Use $this->getPath() instead.
+ */
+ public function path()
+ {
+ return $this->getPath();
+ }
+}
diff --git a/system/src/Grav/Common/Page/Medium/AbstractMedia.php b/system/src/Grav/Common/Page/Medium/AbstractMedia.php
new file mode 100644
index 0000000..f67cd65
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/AbstractMedia.php
@@ -0,0 +1,244 @@
+path;
+ }
+
+ public function setPath(?string $path)
+ {
+ $this->path = $path;
+ }
+
+ /**
+ * Get medium by filename.
+ *
+ * @param string $filename
+ * @return Medium|null
+ */
+ public function get($filename)
+ {
+ return $this->offsetGet($filename);
+ }
+
+ /**
+ * Call object as function to get medium by filename.
+ *
+ * @param string $filename
+ * @return mixed
+ */
+ public function __invoke($filename)
+ {
+ return $this->offsetGet($filename);
+ }
+
+ /**
+ * Set file modification timestamps (query params) for all the media files.
+ *
+ * @param string|int|null $timestamp
+ * @return $this
+ */
+ public function setTimestamps($timestamp = null)
+ {
+ /** @var Medium $instance */
+ foreach ($this->items as $instance) {
+ $instance->setTimestamp($timestamp);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get a list of all media.
+ *
+ * @return MediaObjectInterface[]
+ */
+ public function all()
+ {
+ $this->items = $this->orderMedia($this->items);
+
+ return $this->items;
+ }
+
+ /**
+ * Get a list of all image media.
+ *
+ * @return MediaObjectInterface[]
+ */
+ public function images()
+ {
+ $this->images = $this->orderMedia($this->images);
+
+ return $this->images;
+ }
+
+ /**
+ * Get a list of all video media.
+ *
+ * @return MediaObjectInterface[]
+ */
+ public function videos()
+ {
+ $this->videos = $this->orderMedia($this->videos);
+
+ return $this->videos;
+ }
+
+ /**
+ * Get a list of all audio media.
+ *
+ * @return MediaObjectInterface[]
+ */
+ public function audios()
+ {
+ $this->audios = $this->orderMedia($this->audios);
+
+ return $this->audios;
+ }
+
+ /**
+ * Get a list of all file media.
+ *
+ * @return MediaObjectInterface[]
+ */
+ public function files()
+ {
+ $this->files = $this->orderMedia($this->files);
+
+ return $this->files;
+ }
+
+ /**
+ * @param string $name
+ * @param MediaObjectInterface $file
+ */
+ public function add($name, $file)
+ {
+ if (!$file) {
+ return;
+ }
+ $this->offsetSet($name, $file);
+ switch ($file->type) {
+ case 'image':
+ $this->images[$name] = $file;
+ break;
+ case 'video':
+ $this->videos[$name] = $file;
+ break;
+ case 'audio':
+ $this->audios[$name] = $file;
+ break;
+ default:
+ $this->files[$name] = $file;
+ }
+ }
+
+ /**
+ * Order the media based on the page's media_order
+ *
+ * @param array $media
+ * @return array
+ */
+ protected function orderMedia($media)
+ {
+ if (null === $this->media_order) {
+ /** @var Page $page */
+ $page = Grav::instance()['pages']->get($this->getPath());
+
+ if ($page && isset($page->header()->media_order)) {
+ $this->media_order = array_map('trim', explode(',', $page->header()->media_order));
+ }
+ }
+
+ if (!empty($this->media_order) && is_array($this->media_order)) {
+ $media = Utils::sortArrayByArray($media, $this->media_order);
+ } else {
+ ksort($media, SORT_NATURAL | SORT_FLAG_CASE);
+ }
+
+ return $media;
+ }
+
+ /**
+ * Get filename, extension and meta part.
+ *
+ * @param string $filename
+ * @return array
+ */
+ protected function getFileParts($filename)
+ {
+ if (preg_match('/(.*)@(\d+)x\.(.*)$/', $filename, $matches)) {
+ $name = $matches[1];
+ $extension = $matches[3];
+ $extra = (int) $matches[2];
+ $type = 'alternative';
+
+ if ($extra === 1) {
+ $type = 'base';
+ $extra = null;
+ }
+ } else {
+ $fileParts = explode('.', $filename);
+
+ $name = array_shift($fileParts);
+ $extension = null;
+ $extra = null;
+ $type = 'base';
+
+ while (($part = array_shift($fileParts)) !== null) {
+ if ($part !== 'meta' && $part !== 'thumb') {
+ if (null !== $extension) {
+ $name .= '.' . $extension;
+ }
+ $extension = $part;
+ } else {
+ $type = $part;
+ $extra = '.' . $part . '.' . implode('.', $fileParts);
+ break;
+ }
+ }
+ }
+
+ return array($name, $extension, $type, $extra);
+ }
+}
diff --git a/system/src/Grav/Common/Page/Medium/AudioMedium.php b/system/src/Grav/Common/Page/Medium/AudioMedium.php
new file mode 100644
index 0000000..74ef746
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/AudioMedium.php
@@ -0,0 +1,148 @@
+url($reset);
+
+ return [
+ 'name' => 'audio',
+ 'text' => 'Your browser does not support the audio tag.',
+ 'attributes' => $attributes
+ ];
+ }
+
+ /**
+ * Allows to set or remove the HTML5 default controls
+ *
+ * @param bool $display
+ * @return $this
+ */
+ public function controls($display = true)
+ {
+ if($display) {
+ $this->attributes['controls'] = true;
+ } else {
+ unset($this->attributes['controls']);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Allows to set the preload behaviour
+ *
+ * @param string $preload
+ * @return $this
+ */
+ public function preload($preload)
+ {
+ $validPreloadAttrs = ['auto', 'metadata', 'none'];
+
+ if (\in_array($preload, $validPreloadAttrs, true)) {
+ $this->attributes['preload'] = $preload;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Allows to set the controlsList behaviour
+ * Separate multiple values with a hyphen
+ *
+ * @param string $controlsList
+ * @return $this
+ */
+ public function controlsList($controlsList)
+ {
+ $controlsList = str_replace('-', ' ', $controlsList);
+ $this->attributes['controlsList'] = $controlsList;
+
+ return $this;
+ }
+
+ /**
+ * Allows to set the muted attribute
+ *
+ * @param bool $status
+ * @return $this
+ */
+ public function muted($status = false)
+ {
+ if($status) {
+ $this->attributes['muted'] = true;
+ } else {
+ unset($this->attributes['muted']);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Allows to set the loop attribute
+ *
+ * @param bool $status
+ * @return $this
+ */
+ public function loop($status = false)
+ {
+ if($status) {
+ $this->attributes['loop'] = true;
+ } else {
+ unset($this->attributes['loop']);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Allows to set the autoplay attribute
+ *
+ * @param bool $status
+ * @return $this
+ */
+ public function autoplay($status = false)
+ {
+ if($status) {
+ $this->attributes['autoplay'] = true;
+ } else {
+ unset($this->attributes['autoplay']);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * Reset medium.
+ *
+ * @return $this
+ */
+ public function reset()
+ {
+ parent::reset();
+
+ $this->attributes['controls'] = true;
+
+ return $this;
+ }
+}
diff --git a/system/src/Grav/Common/Page/Medium/GlobalMedia.php b/system/src/Grav/Common/Page/Medium/GlobalMedia.php
new file mode 100644
index 0000000..9fb30e9
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/GlobalMedia.php
@@ -0,0 +1,128 @@
+resolveStream($offset));
+ }
+
+ /**
+ * @param mixed $offset
+ *
+ * @return mixed
+ */
+ public function offsetGet($offset)
+ {
+ return parent::offsetGet($offset) ?: $this->addMedium($offset);
+ }
+
+ /**
+ * @param string $filename
+ * @return string|null
+ */
+ protected function resolveStream($filename)
+ {
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+
+ return $locator->isStream($filename) ? ($locator->findResource($filename) ?: null) : null;
+ }
+
+ /**
+ * @param string $stream
+ * @return Medium|null
+ */
+ protected function addMedium($stream)
+ {
+ $filename = $this->resolveStream($stream);
+ if (!$filename) {
+ return null;
+ }
+
+ $path = dirname($filename);
+ list($basename, $ext,, $extra) = $this->getFileParts(basename($filename));
+ $medium = MediumFactory::fromFile($filename);
+
+ if (empty($medium)) {
+ return null;
+ }
+
+ $medium->set('size', filesize($filename));
+ $scale = (int) ($extra ?: 1);
+
+ if ($scale !== 1) {
+ $altMedium = $medium;
+
+ // Create scaled down regular sized image.
+ $medium = MediumFactory::scaledFromMedium($altMedium, $scale, 1)['file'];
+
+ if (empty($medium)) {
+ return null;
+ }
+
+ // Add original sized image as alternative.
+ $medium->addAlternative($scale, $altMedium['file']);
+
+ // Locate or generate smaller retina images.
+ for ($i = $scale-1; $i > 1; $i--) {
+ $altFilename = "{$path}/{$basename}@{$i}x.{$ext}";
+
+ if (file_exists($altFilename)) {
+ $scaled = MediumFactory::fromFile($altFilename);
+ } else {
+ $scaled = MediumFactory::scaledFromMedium($altMedium, $scale, $i)['file'];
+ }
+
+ if ($scaled) {
+ $medium->addAlternative($i, $scaled);
+ }
+ }
+ }
+
+ $meta = "{$path}/{$basename}.{$ext}.yaml";
+ if (file_exists($meta)) {
+ $medium->addMetaFile($meta);
+ }
+ $meta = "{$path}/{$basename}.{$ext}.meta.yaml";
+ if (file_exists($meta)) {
+ $medium->addMetaFile($meta);
+ }
+
+ $thumb = "{$path}/{$basename}.thumb.{$ext}";
+ if (file_exists($thumb)) {
+ $medium->set('thumbnails.page', $thumb);
+ }
+
+ $this->add($stream, $medium);
+
+ return $medium;
+ }
+}
diff --git a/system/src/Grav/Common/Page/Medium/ImageFile.php b/system/src/Grav/Common/Page/Medium/ImageFile.php
new file mode 100644
index 0000000..d56c342
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/ImageFile.php
@@ -0,0 +1,145 @@
+getAdapter()->deinit();
+ }
+
+ /**
+ * Clear previously applied operations
+ */
+ public function clearOperations()
+ {
+ $this->operations = [];
+ }
+
+ /**
+ * This is the same as the Gregwar Image class except this one fires a Grav Event on creation of new cached file
+ *
+ * @param string $type the image type
+ * @param int $quality the quality (for JPEG)
+ * @param bool $actual
+ * @param array $extras
+ *
+ * @return string
+ */
+ public function cacheFile($type = 'jpg', $quality = 80, $actual = false, $extras = [])
+ {
+ if ($type === 'guess') {
+ $type = $this->guessType();
+ }
+
+ if (!$this->forceCache && !count($this->operations) && $type === $this->guessType()) {
+ return $this->getFilename($this->getFilePath());
+ }
+
+ // Computes the hash
+ $this->hash = $this->getHash($type, $quality, $extras);
+
+ // Seo friendly image names
+ $seofriendly = Grav::instance()['config']->get('system.images.seofriendly', false);
+
+ if ($seofriendly) {
+ $mini_hash = substr($this->hash, 0, 4) . substr($this->hash, -4);
+ $cacheFile = "{$this->prettyName}-{$mini_hash}";
+ } else {
+ $cacheFile = "{$this->hash}-{$this->prettyName}";
+ }
+
+ $cacheFile .= '.' . $type;
+
+ // If the files does not exists, save it
+ $image = $this;
+
+ // Target file should be younger than all the current image
+ // dependencies
+ $conditions = array(
+ 'younger-than' => $this->getDependencies()
+ );
+
+ // The generating function
+ $generate = function ($target) use ($image, $type, $quality) {
+ $result = $image->save($target, $type, $quality);
+
+ if ($result !== $target) {
+ throw new GenerationError($result);
+ }
+
+ Grav::instance()->fireEvent('onImageMediumSaved', new Event(['image' => $target]));
+ };
+
+ // Asking the cache for the cacheFile
+ try {
+ $perms = Grav::instance()['config']->get('system.images.cache_perms', '0755');
+ $perms = octdec($perms);
+ $file = $this->getCacheSystem()->setDirectoryMode($perms)->getOrCreateFile($cacheFile, $conditions, $generate, $actual);
+ } catch (GenerationError $e) {
+ $file = $e->getNewFile();
+ }
+
+ // Nulling the resource
+ $this->getAdapter()->setSource(new Source\File($file));
+ $this->getAdapter()->deinit();
+
+ if ($actual) {
+ return $file;
+ }
+
+ return $this->getFilename($file);
+ }
+
+ /**
+ * Gets the hash.
+ * @param string $type
+ * @param int $quality
+ * @param [] $extras
+ * @return null
+ */
+ public function getHash($type = 'guess', $quality = 80, $extras = [])
+ {
+ if (null === $this->hash) {
+ $this->generateHash($type, $quality, $extras);
+ }
+
+ return $this->hash;
+ }
+
+ /**
+ * Generates the hash.
+ * @param string $type
+ * @param int $quality
+ * @param array $extras
+ */
+ public function generateHash($type = 'guess', $quality = 80, $extras = [])
+ {
+ $inputInfos = $this->source->getInfos();
+
+ $datas = array(
+ $inputInfos,
+ $this->serializeOperations(),
+ $type,
+ $quality,
+ $extras
+ );
+
+ $this->hash = sha1(serialize($datas));
+ }
+
+}
diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php
new file mode 100644
index 0000000..13c142a
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php
@@ -0,0 +1,668 @@
+ [0, 1],
+ 'forceResize' => [0, 1],
+ 'cropResize' => [0, 1],
+ 'crop' => [0, 1, 2, 3],
+ 'zoomCrop' => [0, 1]
+ ];
+
+ /**
+ * @var string
+ */
+ protected $sizes = '100vw';
+
+ /**
+ * Construct.
+ *
+ * @param array $items
+ * @param Blueprint $blueprint
+ */
+ public function __construct($items = [], Blueprint $blueprint = null)
+ {
+ parent::__construct($items, $blueprint);
+
+ $config = Grav::instance()['config'];
+
+ $path = $this->get('filepath');
+ if (!$path || !file_exists($path) || !filesize($path)) {
+ return;
+ }
+
+ $image_info = getimagesize($path);
+
+ $this->def('width', $image_info[0]);
+ $this->def('height', $image_info[1]);
+ $this->def('mime', $image_info['mime']);
+ $this->def('debug', $config->get('system.images.debug'));
+
+ $this->set('thumbnails.media', $this->get('filepath'));
+
+ $this->default_quality = $config->get('system.images.default_image_quality', 85);
+
+ $this->reset();
+
+ if ($config->get('system.images.cache_all', false)) {
+ $this->cache();
+ }
+ }
+
+ public function __destruct()
+ {
+ unset($this->image);
+ }
+
+ public function __clone()
+ {
+ $this->image = $this->image ? clone $this->image : null;
+
+ parent::__clone();
+ }
+
+ /**
+ * Add meta file for the medium.
+ *
+ * @param string $filepath
+ * @return $this
+ */
+ public function addMetaFile($filepath)
+ {
+ parent::addMetaFile($filepath);
+
+ // Apply filters in meta file
+ $this->reset();
+
+ return $this;
+ }
+
+ /**
+ * Clear out the alternatives
+ */
+ public function clearAlternatives()
+ {
+ $this->alternatives = [];
+ }
+
+ /**
+ * Return PATH to image.
+ *
+ * @param bool $reset
+ * @return string path to image
+ */
+ public function path($reset = true)
+ {
+ $output = $this->saveImage();
+
+ if ($reset) {
+ $this->reset();
+ }
+
+ return $output;
+ }
+
+ /**
+ * Return URL to image.
+ *
+ * @param bool $reset
+ * @return string
+ */
+ public function url($reset = true)
+ {
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ $image_path = $locator->findResource('cache://images', true) ?: $locator->findResource('cache://images', true, true);
+ $saved_image_path = $this->saveImage();
+
+ $output = preg_replace('|^' . preg_quote(GRAV_ROOT, '|') . '|', '', $saved_image_path);
+
+ if ($locator->isStream($output)) {
+ $output = $locator->findResource($output, false);
+ }
+
+ if (Utils::startsWith($output, $image_path)) {
+ $image_dir = $locator->findResource('cache://images', false);
+ $output = '/' . $image_dir . preg_replace('|^' . preg_quote($image_path, '|') . '|', '', $output);
+ }
+
+ if ($reset) {
+ $this->reset();
+ }
+
+ return trim(Grav::instance()['base_url'] . '/' . $this->urlQuerystring($output), '\\');
+ }
+
+ /**
+ * Simply processes with no extra methods. Useful for triggering events.
+ *
+ * @return $this
+ */
+ public function cache()
+ {
+ if (!$this->image) {
+ $this->image();
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * Return srcset string for this Medium and its alternatives.
+ *
+ * @param bool $reset
+ * @return string
+ */
+ public function srcset($reset = true)
+ {
+ if (empty($this->alternatives)) {
+ if ($reset) {
+ $this->reset();
+ }
+
+ return '';
+ }
+
+ $srcset = [];
+ foreach ($this->alternatives as $ratio => $medium) {
+ $srcset[] = $medium->url($reset) . ' ' . $medium->get('width') . 'w';
+ }
+ $srcset[] = str_replace(' ', '%20', $this->url($reset)) . ' ' . $this->get('width') . 'w';
+
+ return implode(', ', $srcset);
+ }
+
+ /**
+ * Allows the ability to override the image's pretty name stored in cache
+ *
+ * @param string $name
+ */
+ public function setImagePrettyName($name)
+ {
+ $this->set('prettyname', $name);
+ if ($this->image) {
+ $this->image->setPrettyName($name);
+ }
+ }
+
+ public function getImagePrettyName()
+ {
+ if ($this->get('prettyname')) {
+ return $this->get('prettyname');
+ }
+
+ $basename = $this->get('basename');
+ if (preg_match('/[a-z0-9]{40}-(.*)/', $basename, $matches)) {
+ $basename = $matches[1];
+ }
+ return $basename;
+ }
+
+ /**
+ * Generate alternative image widths, using either an array of integers, or
+ * a min width, a max width, and a step parameter to fill out the necessary
+ * widths. Existing image alternatives won't be overwritten.
+ *
+ * @param int|int[] $min_width
+ * @param int $max_width
+ * @param int $step
+ * @return $this
+ */
+ public function derivatives($min_width, $max_width = 2500, $step = 200)
+ {
+ if (!empty($this->alternatives)) {
+ $max = max(array_keys($this->alternatives));
+ $base = $this->alternatives[$max];
+ } else {
+ $base = $this;
+ }
+
+ $widths = [];
+
+ if (func_num_args() === 1) {
+ foreach ((array) func_get_arg(0) as $width) {
+ if ($width < $base->get('width')) {
+ $widths[] = $width;
+ }
+ }
+ } else {
+ $max_width = min($max_width, $base->get('width'));
+
+ for ($width = $min_width; $width < $max_width; $width = $width + $step) {
+ $widths[] = $width;
+ }
+ }
+
+ foreach ($widths as $width) {
+ // Only generate image alternatives that don't already exist
+ if (array_key_exists((int) $width, $this->alternatives)) {
+ continue;
+ }
+
+ $derivative = MediumFactory::fromFile($base->get('filepath'));
+
+ // It's possible that MediumFactory::fromFile returns null if the
+ // original image file no longer exists and this class instance was
+ // retrieved from the page cache
+ if (null !== $derivative) {
+ $index = 2;
+ $alt_widths = array_keys($this->alternatives);
+ sort($alt_widths);
+
+ foreach ($alt_widths as $i => $key) {
+ if ($width > $key) {
+ $index += max($i, 1);
+ }
+ }
+
+ $basename = preg_replace('/(@\d+x){0,1}$/', "@{$width}w", $base->get('basename'), 1);
+ $derivative->setImagePrettyName($basename);
+
+ $ratio = $base->get('width') / $width;
+ $height = $derivative->get('height') / $ratio;
+
+ $derivative->resize($width, $height);
+ $derivative->set('width', $width);
+ $derivative->set('height', $height);
+
+ $this->addAlternative($ratio, $derivative);
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Parsedown element for source display mode
+ *
+ * @param array $attributes
+ * @param bool $reset
+ * @return array
+ */
+ public function sourceParsedownElement(array $attributes, $reset = true)
+ {
+ empty($attributes['src']) && $attributes['src'] = $this->url(false);
+
+ $srcset = $this->srcset($reset);
+ if ($srcset) {
+ empty($attributes['srcset']) && $attributes['srcset'] = $srcset;
+ $attributes['sizes'] = $this->sizes();
+ }
+
+ return ['name' => 'img', 'attributes' => $attributes];
+ }
+
+ /**
+ * Reset image.
+ *
+ * @return $this
+ */
+ public function reset()
+ {
+ parent::reset();
+
+ if ($this->image) {
+ $this->image();
+ $this->medium_querystring = [];
+ $this->filter();
+ $this->clearAlternatives();
+ }
+
+ $this->format = 'guess';
+ $this->quality = $this->default_quality;
+
+ $this->debug_watermarked = false;
+
+ return $this;
+ }
+
+ /**
+ * Turn the current Medium into a Link
+ *
+ * @param bool $reset
+ * @param array $attributes
+ * @return Link
+ */
+ public function link($reset = true, array $attributes = [])
+ {
+ $attributes['href'] = $this->url(false);
+ $srcset = $this->srcset(false);
+ if ($srcset) {
+ $attributes['data-srcset'] = $srcset;
+ }
+
+ return parent::link($reset, $attributes);
+ }
+
+ /**
+ * Turn the current Medium into a Link with lightbox enabled
+ *
+ * @param int $width
+ * @param int $height
+ * @param bool $reset
+ * @return Link
+ */
+ public function lightbox($width = null, $height = null, $reset = true)
+ {
+ if ($this->mode !== 'source') {
+ $this->display('source');
+ }
+
+ if ($width && $height) {
+ $this->__call('cropResize', [$width, $height]);
+ }
+
+ return parent::lightbox($width, $height, $reset);
+ }
+
+ /**
+ * Sets or gets the quality of the image
+ *
+ * @param int $quality 0-100 quality
+ * @return int|$this
+ */
+ public function quality($quality = null)
+ {
+ if ($quality) {
+ if (!$this->image) {
+ $this->image();
+ }
+
+ $this->quality = $quality;
+
+ return $this;
+ }
+
+ return $this->quality;
+ }
+
+ /**
+ * Sets image output format.
+ *
+ * @param string $format
+ * @return $this
+ */
+ public function format($format)
+ {
+ if (!$this->image) {
+ $this->image();
+ }
+
+ $this->format = $format;
+
+ return $this;
+ }
+
+ /**
+ * Set or get sizes parameter for srcset media action
+ *
+ * @param string $sizes
+ * @return string
+ */
+ public function sizes($sizes = null)
+ {
+
+ if ($sizes) {
+ $this->sizes = $sizes;
+
+ return $this;
+ }
+
+ return empty($this->sizes) ? '100vw' : $this->sizes;
+ }
+
+ /**
+ * Allows to set the width attribute from Markdown or Twig
+ * Examples: 
+ * 
+ * 
+ * 
+ * {{ page.media['myimg.png'].width().height().html }}
+ * {{ page.media['myimg.png'].resize(100,200).width(100).height(200).html }}
+ *
+ * @param mixed $value A value or 'auto' or empty to use the width of the image
+ * @return $this
+ */
+ public function width($value = 'auto')
+ {
+ if (!$value || $value === 'auto') {
+ $this->attributes['width'] = $this->get('width');
+ } else {
+ $this->attributes['width'] = $value;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Allows to set the height attribute from Markdown or Twig
+ * Examples: 
+ * 
+ * 
+ * 
+ * {{ page.media['myimg.png'].width().height().html }}
+ * {{ page.media['myimg.png'].resize(100,200).width(100).height(200).html }}
+ *
+ * @param mixed $value A value or 'auto' or empty to use the height of the image
+ * @return $this
+ */
+ public function height($value = 'auto')
+ {
+ if (!$value || $value === 'auto') {
+ $this->attributes['height'] = $this->get('height');
+ } else {
+ $this->attributes['height'] = $value;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Handle this commonly used variant
+ */
+ public function cropZoom()
+ {
+ $this->__call('zoomCrop', func_get_args());
+ return $this;
+ }
+
+ /**
+ * Forward the call to the image processing method.
+ *
+ * @param string $method
+ * @param mixed $args
+ * @return $this|mixed
+ */
+ public function __call($method, $args)
+ {
+ if (!\in_array($method, self::$magic_actions, true)) {
+ return parent::__call($method, $args);
+ }
+
+ // Always initialize image.
+ if (!$this->image) {
+ $this->image();
+ }
+
+ try {
+ call_user_func_array([$this->image, $method], $args);
+
+ foreach ($this->alternatives as $medium) {
+ if (!$medium->image) {
+ $medium->image();
+ }
+
+ $args_copy = $args;
+
+ // regular image: resize 400x400 -> 200x200
+ // --> @2x: resize 800x800->400x400
+ if (isset(self::$magic_resize_actions[$method])) {
+ foreach (self::$magic_resize_actions[$method] as $param) {
+ if (isset($args_copy[$param])) {
+ $args_copy[$param] *= $medium->get('ratio');
+ }
+ }
+ }
+
+ call_user_func_array([$medium, $method], $args_copy);
+ }
+ } catch (\BadFunctionCallException $e) {
+ }
+
+ return $this;
+ }
+
+ /**
+ * Gets medium image, resets image manipulation operations.
+ *
+ * @return $this
+ */
+ protected function image()
+ {
+ $locator = Grav::instance()['locator'];
+
+ $file = $this->get('filepath');
+
+ // Use existing cache folder or if it doesn't exist, create it.
+ $cacheDir = $locator->findResource('cache://images', true) ?: $locator->findResource('cache://images', true, true);
+
+ // Make sure we free previous image.
+ unset($this->image);
+
+ $this->image = ImageFile::open($file)
+ ->setCacheDir($cacheDir)
+ ->setActualCacheDir($cacheDir)
+ ->setPrettyName($this->getImagePrettyName());
+
+ return $this;
+ }
+
+ /**
+ * Save the image with cache.
+ *
+ * @return string
+ */
+ protected function saveImage()
+ {
+ if (!$this->image) {
+ return parent::path(false);
+ }
+
+ $this->filter();
+
+ if (isset($this->result)) {
+ return $this->result;
+ }
+
+ if (!$this->debug_watermarked && $this->get('debug')) {
+ $ratio = $this->get('ratio');
+ if (!$ratio) {
+ $ratio = 1;
+ }
+
+ $locator = Grav::instance()['locator'];
+ $overlay = $locator->findResource("system://assets/responsive-overlays/{$ratio}x.png") ?: $locator->findResource('system://assets/responsive-overlays/unknown.png');
+ $this->image->merge(ImageFile::open($overlay));
+ }
+
+ return $this->image->cacheFile($this->format, $this->quality, false, [$this->get('width'), $this->get('height'), $this->get('modified')]);
+ }
+
+ /**
+ * Filter image by using user defined filter parameters.
+ *
+ * @param string $filter Filter to be used.
+ */
+ public function filter($filter = 'image.filters.default')
+ {
+ $filters = (array) $this->get($filter, []);
+ foreach ($filters as $params) {
+ $params = (array) $params;
+ $method = array_shift($params);
+ $this->__call($method, $params);
+ }
+ }
+
+ /**
+ * Return the image higher quality version
+ *
+ * @return ImageMedium the alternative version with higher quality
+ */
+ public function higherQualityAlternative()
+ {
+ if ($this->alternatives) {
+ $max = reset($this->alternatives);
+ foreach($this->alternatives as $alternative)
+ {
+ if($alternative->quality() > $max->quality())
+ {
+ $max = $alternative;
+ }
+ }
+
+ return $max;
+ }
+
+ return $this;
+ }
+
+}
diff --git a/system/src/Grav/Common/Page/Medium/Link.php b/system/src/Grav/Common/Page/Medium/Link.php
new file mode 100644
index 0000000..6978635
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/Link.php
@@ -0,0 +1,71 @@
+attributes = $attributes;
+ $this->source = $medium->reset()->thumbnail('auto')->display('thumbnail');
+ $this->source->linked = true;
+ }
+
+ /**
+ * Get an element (is array) that can be rendered by the Parsedown engine
+ *
+ * @param string $title
+ * @param string $alt
+ * @param string $class
+ * @param string $id
+ * @param bool $reset
+ * @return array
+ */
+ public function parsedownElement($title = null, $alt = null, $class = null, $id = null, $reset = true)
+ {
+ $innerElement = $this->source->parsedownElement($title, $alt, $class, $id, $reset);
+
+ return [
+ 'name' => 'a',
+ 'attributes' => $this->attributes,
+ 'handler' => is_string($innerElement) ? 'line' : 'element',
+ 'text' => $innerElement
+ ];
+ }
+
+ /**
+ * Forward the call to the source element
+ *
+ * @param string $method
+ * @param mixed $args
+ * @return mixed
+ */
+ public function __call($method, $args)
+ {
+ $this->source = call_user_func_array(array($this->source, $method), $args);
+
+ // Don't start nesting links, if user has multiple link calls in his
+ // actions, we will drop the previous links.
+ return $this->source instanceof Link ? $this->source : $this;
+ }
+}
diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php
new file mode 100644
index 0000000..bf0bb1f
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/Medium.php
@@ -0,0 +1,679 @@
+get('system.media.enable_media_timestamp', true)) {
+ $this->timestamp = Grav::instance()['cache']->getKey();
+ }
+
+ $this->def('mime', 'application/octet-stream');
+ $this->reset();
+ }
+
+ public function __clone()
+ {
+ // Allows future compatibility as parent::__clone() works.
+ }
+
+ /**
+ * Create a copy of this media object
+ *
+ * @return Medium
+ */
+ public function copy()
+ {
+ return clone $this;
+ }
+
+ /**
+ * Return just metadata from the Medium object
+ *
+ * @return Data
+ */
+ public function meta()
+ {
+ return new Data($this->items);
+ }
+
+ /**
+ * Check if this medium exists or not
+ *
+ * @return bool
+ */
+ public function exists()
+ {
+ $path = $this->get('filepath');
+ if (file_exists($path)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Get file modification time for the medium.
+ *
+ * @return int|null
+ */
+ public function modified()
+ {
+ $path = $this->get('filepath');
+
+ if (!file_exists($path)) {
+ return null;
+ }
+
+ return filemtime($path) ?: null;
+ }
+
+ /**
+ * @return int
+ */
+ public function size()
+ {
+ $path = $this->get('filepath');
+
+ if (!file_exists($path)) {
+ return 0;
+ }
+
+ return filesize($path) ?: 0;
+ }
+
+ /**
+ * Set querystring to file modification timestamp (or value provided as a parameter).
+ *
+ * @param string|int|null $timestamp
+ * @return $this
+ */
+ public function setTimestamp($timestamp = null)
+ {
+ $this->timestamp = (string)($timestamp ?? $this->modified());
+
+ return $this;
+ }
+
+ /**
+ * Returns an array containing just the metadata
+ *
+ * @return array
+ */
+ public function metadata()
+ {
+ return $this->metadata;
+ }
+
+ /**
+ * Add meta file for the medium.
+ *
+ * @param string $filepath
+ */
+ public function addMetaFile($filepath)
+ {
+ $this->metadata = (array)CompiledYamlFile::instance($filepath)->content();
+ $this->merge($this->metadata);
+ }
+
+ /**
+ * Add alternative Medium to this Medium.
+ *
+ * @param int|float $ratio
+ * @param Medium $alternative
+ */
+ public function addAlternative($ratio, Medium $alternative)
+ {
+ if (!is_numeric($ratio) || $ratio === 0) {
+ return;
+ }
+
+ $alternative->set('ratio', $ratio);
+ $width = $alternative->get('width');
+
+ $this->alternatives[$width] = $alternative;
+ }
+
+ /**
+ * Return string representation of the object (html).
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->html();
+ }
+
+ /**
+ * Return PATH to file.
+ *
+ * @param bool $reset
+ * @return string path to file
+ */
+ public function path($reset = true)
+ {
+ if ($reset) {
+ $this->reset();
+ }
+
+ return $this->get('filepath');
+ }
+
+ /**
+ * Return the relative path to file
+ *
+ * @param bool $reset
+ * @return mixed
+ */
+ public function relativePath($reset = true)
+ {
+ $output = preg_replace('|^' . preg_quote(GRAV_ROOT, '|') . '|', '', $this->get('filepath'));
+
+ $locator = Grav::instance()['locator'];
+ if ($locator->isStream($output)) {
+ $output = $locator->findResource($output, false);
+ }
+
+ if ($reset) {
+ $this->reset();
+ }
+
+ return str_replace(GRAV_ROOT, '', $output);
+ }
+
+ /**
+ * Return URL to file.
+ *
+ * @param bool $reset
+ * @return string
+ */
+ public function url($reset = true)
+ {
+ $output = preg_replace('|^' . preg_quote(GRAV_ROOT, '|') . '|', '', $this->get('filepath'));
+
+ $locator = Grav::instance()['locator'];
+ if ($locator->isStream($output)) {
+ $output = $locator->findResource($output, false);
+ }
+
+ if ($reset) {
+ $this->reset();
+ }
+
+ return trim(Grav::instance()['base_url'] . '/' . $this->urlQuerystring($output), '\\');
+ }
+
+ /**
+ * Get/set querystring for the file's url
+ *
+ * @param string $querystring
+ * @param bool $withQuestionmark
+ * @return string
+ */
+ public function querystring($querystring = null, $withQuestionmark = true)
+ {
+ if (null !== $querystring) {
+ $this->medium_querystring[] = ltrim($querystring, '?&');
+ foreach ($this->alternatives as $alt) {
+ $alt->querystring($querystring, $withQuestionmark);
+ }
+ }
+
+ if (empty($this->medium_querystring)) {
+ return '';
+ }
+
+ // join the strings
+ $querystring = implode('&', $this->medium_querystring);
+ // explode all strings
+ $query_parts = explode('&', $querystring);
+ // Join them again now ensure the elements are unique
+ $querystring = implode('&', array_unique($query_parts));
+
+ return $withQuestionmark ? ('?' . $querystring) : $querystring;
+ }
+
+ /**
+ * Get the URL with full querystring
+ *
+ * @param string $url
+ * @return string
+ */
+ public function urlQuerystring($url)
+ {
+ $querystring = $this->querystring();
+ if (isset($this->timestamp) && !Utils::contains($querystring, $this->timestamp)) {
+ $querystring = empty($querystring) ? ('?' . $this->timestamp) : ($querystring . '&' . $this->timestamp);
+ }
+
+ return ltrim($url . $querystring . $this->urlHash(), '/');
+ }
+
+ /**
+ * Get/set hash for the file's url
+ *
+ * @param string $hash
+ * @param bool $withHash
+ * @return string
+ */
+ public function urlHash($hash = null, $withHash = true)
+ {
+ if ($hash) {
+ $this->set('urlHash', ltrim($hash, '#'));
+ }
+
+ $hash = $this->get('urlHash', '');
+
+ return $withHash && !empty($hash) ? '#' . $hash : $hash;
+ }
+
+ /**
+ * Get an element (is array) that can be rendered by the Parsedown engine
+ *
+ * @param string $title
+ * @param string $alt
+ * @param string $class
+ * @param string $id
+ * @param bool $reset
+ * @return array
+ */
+ public function parsedownElement($title = null, $alt = null, $class = null, $id = null, $reset = true)
+ {
+ $attributes = $this->attributes;
+
+ $style = '';
+ foreach ($this->styleAttributes as $key => $value) {
+ if (is_numeric($key)) // Special case for inline style attributes, refer to style() method
+ $style .= $value;
+ else
+ $style .= $key . ': ' . $value . ';';
+ }
+ if ($style) {
+ $attributes['style'] = $style;
+ }
+
+ if (empty($attributes['title'])) {
+ if (!empty($title)) {
+ $attributes['title'] = $title;
+ } elseif (!empty($this->items['title'])) {
+ $attributes['title'] = $this->items['title'];
+ }
+ }
+
+ if (empty($attributes['alt'])) {
+ if (!empty($alt)) {
+ $attributes['alt'] = $alt;
+ } elseif (!empty($this->items['alt'])) {
+ $attributes['alt'] = $this->items['alt'];
+ } elseif (!empty($this->items['alt_text'])) {
+ $attributes['alt'] = $this->items['alt_text'];
+ } else {
+ $attributes['alt'] = '';
+ }
+ }
+
+ if (empty($attributes['class'])) {
+ if (!empty($class)) {
+ $attributes['class'] = $class;
+ } elseif (!empty($this->items['class'])) {
+ $attributes['class'] = $this->items['class'];
+ }
+ }
+
+ if (empty($attributes['id'])) {
+ if (!empty($id)) {
+ $attributes['id'] = $id;
+ } elseif (!empty($this->items['id'])) {
+ $attributes['id'] = $this->items['id'];
+ }
+ }
+
+ switch ($this->mode) {
+ case 'text':
+ $element = $this->textParsedownElement($attributes, false);
+ break;
+ case 'thumbnail':
+ $element = $this->getThumbnail()->sourceParsedownElement($attributes, false);
+ break;
+ case 'source':
+ $element = $this->sourceParsedownElement($attributes, false);
+ break;
+ default:
+ $element = [];
+ }
+
+ if ($reset) {
+ $this->reset();
+ }
+
+ $this->display('source');
+
+ return $element;
+ }
+
+ /**
+ * Parsedown element for source display mode
+ *
+ * @param array $attributes
+ * @param bool $reset
+ * @return array
+ */
+ protected function sourceParsedownElement(array $attributes, $reset = true)
+ {
+ return $this->textParsedownElement($attributes, $reset);
+ }
+
+ /**
+ * Parsedown element for text display mode
+ *
+ * @param array $attributes
+ * @param bool $reset
+ * @return array
+ */
+ protected function textParsedownElement(array $attributes, $reset = true)
+ {
+ $text = empty($attributes['title']) ? empty($attributes['alt']) ? $this->get('filename') : $attributes['alt'] : $attributes['title'];
+
+ $element = [
+ 'name' => 'p',
+ 'attributes' => $attributes,
+ 'text' => $text
+ ];
+
+ if ($reset) {
+ $this->reset();
+ }
+
+ return $element;
+ }
+
+ /**
+ * Reset medium.
+ *
+ * @return $this
+ */
+ public function reset()
+ {
+ $this->attributes = [];
+ return $this;
+ }
+
+ /**
+ * Switch display mode.
+ *
+ * @param string $mode
+ *
+ * @return $this
+ */
+ public function display($mode = 'source')
+ {
+ if ($this->mode === $mode) {
+ return $this;
+ }
+
+
+ $this->mode = $mode;
+
+ return $mode === 'thumbnail' ? ($this->getThumbnail() ? $this->getThumbnail()->reset() : null) : $this->reset();
+ }
+
+ /**
+ * Helper method to determine if this media item has a thumbnail or not
+ *
+ * @param string $type;
+ *
+ * @return bool
+ */
+ public function thumbnailExists($type = 'page')
+ {
+ $thumbs = $this->get('thumbnails');
+ if (isset($thumbs[$type])) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Switch thumbnail.
+ *
+ * @param string $type
+ *
+ * @return $this
+ */
+ public function thumbnail($type = 'auto')
+ {
+ if ($type !== 'auto' && !\in_array($type, $this->thumbnailTypes, true)) {
+ return $this;
+ }
+
+ if ($this->thumbnailType !== $type) {
+ $this->_thumbnail = null;
+ }
+
+ $this->thumbnailType = $type;
+
+ return $this;
+ }
+
+
+ /**
+ * Turn the current Medium into a Link
+ *
+ * @param bool $reset
+ * @param array $attributes
+ * @return Link
+ */
+ public function link($reset = true, array $attributes = [])
+ {
+ if ($this->mode !== 'source') {
+ $this->display('source');
+ }
+
+ foreach ($this->attributes as $key => $value) {
+ empty($attributes['data-' . $key]) && $attributes['data-' . $key] = $value;
+ }
+
+ empty($attributes['href']) && $attributes['href'] = $this->url();
+
+ return new Link($attributes, $this);
+ }
+
+ /**
+ * Turn the current Medium into a Link with lightbox enabled
+ *
+ * @param int $width
+ * @param int $height
+ * @param bool $reset
+ * @return Link
+ */
+ public function lightbox($width = null, $height = null, $reset = true)
+ {
+ $attributes = ['rel' => 'lightbox'];
+
+ if ($width && $height) {
+ $attributes['data-width'] = $width;
+ $attributes['data-height'] = $height;
+ }
+
+ return $this->link($reset, $attributes);
+ }
+
+ /**
+ * Add a class to the element from Markdown or Twig
+ * Example:  or 
+ *
+ * @return $this
+ */
+ public function classes()
+ {
+ $classes = func_get_args();
+ if (!empty($classes)) {
+ $this->attributes['class'] = implode(',', $classes);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Add an id to the element from Markdown or Twig
+ * Example: 
+ *
+ * @param string $id
+ * @return $this
+ */
+ public function id($id)
+ {
+ if (is_string($id)) {
+ $this->attributes['id'] = trim($id);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Allows to add an inline style attribute from Markdown or Twig
+ * Example: 
+ *
+ * @param string $style
+ * @return $this
+ */
+ public function style($style)
+ {
+ $this->styleAttributes[] = rtrim($style, ';') . ';';
+ return $this;
+ }
+
+ /**
+ * Allow any action to be called on this medium from twig or markdown
+ *
+ * @param string $method
+ * @param mixed $args
+ * @return $this
+ */
+ public function __call($method, $args)
+ {
+ $qs = $method;
+ if (\count($args) > 1 || (\count($args) === 1 && !empty($args[0]))) {
+ $qs .= '=' . implode(',', array_map(function ($a) {
+ if (is_array($a)) {
+ $a = '[' . implode(',', $a) . ']';
+ }
+ return rawurlencode($a);
+ }, $args));
+ }
+
+ if (!empty($qs)) {
+ $this->querystring($this->querystring(null, false) . '&' . $qs);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get the thumbnail Medium object
+ *
+ * @return ThumbnailImageMedium
+ */
+ protected function getThumbnail()
+ {
+ if (!$this->_thumbnail) {
+ $types = $this->thumbnailTypes;
+
+ if ($this->thumbnailType !== 'auto') {
+ array_unshift($types, $this->thumbnailType);
+ }
+
+ foreach ($types as $type) {
+ $thumb = $this->get('thumbnails.' . $type, false);
+
+ if ($thumb) {
+ $thumb = $thumb instanceof ThumbnailImageMedium ? $thumb : MediumFactory::fromFile($thumb, ['type' => 'thumbnail']);
+ $thumb->parent = $this;
+ }
+
+ if ($thumb) {
+ $this->_thumbnail = $thumb;
+ break;
+ }
+ }
+ }
+
+ return $this->_thumbnail;
+ }
+
+}
diff --git a/system/src/Grav/Common/Page/Medium/MediumFactory.php b/system/src/Grav/Common/Page/Medium/MediumFactory.php
new file mode 100644
index 0000000..dc372d8
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/MediumFactory.php
@@ -0,0 +1,192 @@
+get('media.types.' . strtolower($ext));
+ if (!\is_array($media_params)) {
+ return null;
+ }
+
+ $params += $media_params;
+
+ // Add default settings for undefined variables.
+ $params += (array)$config->get('media.types.defaults');
+ $params += [
+ 'type' => 'file',
+ 'thumb' => 'media/thumb.png',
+ 'mime' => 'application/octet-stream',
+ 'filepath' => $file,
+ 'filename' => $filename,
+ 'basename' => $basename,
+ 'extension' => $ext,
+ 'path' => $path,
+ 'modified' => filemtime($file),
+ 'thumbnails' => []
+ ];
+
+ $locator = Grav::instance()['locator'];
+
+ $file = $locator->findResource("image://{$params['thumb']}");
+ if ($file) {
+ $params['thumbnails']['default'] = $file;
+ }
+
+ return static::fromArray($params);
+ }
+
+ /**
+ * Create Medium from an uploaded file
+ *
+ * @param FormFlashFile $uploadedFile
+ * @param array $params
+ * @return Medium
+ */
+ public static function fromUploadedFile(FormFlashFile $uploadedFile, array $params = [])
+ {
+ $parts = pathinfo($uploadedFile->getClientFilename());
+ $filename = $parts['basename'];
+ $ext = $parts['extension'];
+ $basename = $parts['filename'];
+ $file = $uploadedFile->getTmpFile();
+ $path = dirname($file);
+
+ $config = Grav::instance()['config'];
+
+ $media_params = $config->get('media.types.' . strtolower($ext));
+ if (!\is_array($media_params)) {
+ return null;
+ }
+
+ $params += $media_params;
+
+ // Add default settings for undefined variables.
+ $params += (array)$config->get('media.types.defaults');
+ $params += [
+ 'type' => 'file',
+ 'thumb' => 'media/thumb.png',
+ 'mime' => 'application/octet-stream',
+ 'filepath' => $file,
+ 'filename' => $filename,
+ 'basename' => $basename,
+ 'extension' => $ext,
+ 'path' => $path,
+ 'modified' => filemtime($file),
+ 'thumbnails' => []
+ ];
+
+ $locator = Grav::instance()['locator'];
+
+ $file = $locator->findResource("image://{$params['thumb']}");
+ if ($file) {
+ $params['thumbnails']['default'] = $file;
+ }
+
+ return static::fromArray($params);
+ }
+
+ /**
+ * Create Medium from array of parameters
+ *
+ * @param array $items
+ * @param Blueprint|null $blueprint
+ * @return Medium
+ */
+ public static function fromArray(array $items = [], Blueprint $blueprint = null)
+ {
+ $type = $items['type'] ?? null;
+
+ switch ($type) {
+ case 'image':
+ return new ImageMedium($items, $blueprint);
+ case 'thumbnail':
+ return new ThumbnailImageMedium($items, $blueprint);
+ case 'animated':
+ case 'vector':
+ return new StaticImageMedium($items, $blueprint);
+ case 'video':
+ return new VideoMedium($items, $blueprint);
+ case 'audio':
+ return new AudioMedium($items, $blueprint);
+ default:
+ return new Medium($items, $blueprint);
+ }
+ }
+
+ /**
+ * Create a new ImageMedium by scaling another ImageMedium object.
+ *
+ * @param ImageMedium $medium
+ * @param int $from
+ * @param int $to
+ * @return Medium|array
+ */
+ public static function scaledFromMedium($medium, $from, $to)
+ {
+ if (! $medium instanceof ImageMedium) {
+ return $medium;
+ }
+
+ if ($to > $from) {
+ return $medium;
+ }
+
+ $ratio = $to / $from;
+ $width = $medium->get('width') * $ratio;
+ $height = $medium->get('height') * $ratio;
+
+ $prev_basename = $medium->get('basename');
+ $basename = str_replace('@'.$from.'x', '@'.$to.'x', $prev_basename);
+
+ $debug = $medium->get('debug');
+ $medium->set('debug', false);
+ $medium->setImagePrettyName($basename);
+
+ $file = $medium->resize($width, $height)->path();
+
+ $medium->set('debug', $debug);
+ $medium->setImagePrettyName($prev_basename);
+
+ $size = filesize($file);
+
+ $medium = self::fromFile($file);
+ if ($medium) {
+ $medium->set('size', $size);
+ }
+
+ return ['file' => $medium, 'size' => $size];
+ }
+}
diff --git a/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php b/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php
new file mode 100644
index 0000000..c6d75bc
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php
@@ -0,0 +1,42 @@
+parsedownElement($title, $alt, $class, $id, $reset);
+
+ if (!$this->parsedown) {
+ $this->parsedown = new Parsedown(new Excerpts());
+ }
+
+ return $this->parsedown->elementToHtml($element);
+ }
+}
diff --git a/system/src/Grav/Common/Page/Medium/RenderableInterface.php b/system/src/Grav/Common/Page/Medium/RenderableInterface.php
new file mode 100644
index 0000000..50a6e67
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/RenderableInterface.php
@@ -0,0 +1,36 @@
+url($reset);
+
+ return ['name' => 'img', 'attributes' => $attributes];
+ }
+}
diff --git a/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php b/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php
new file mode 100644
index 0000000..8d6d43f
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php
@@ -0,0 +1,28 @@
+styleAttributes['width'] = $width . 'px';
+ $this->styleAttributes['height'] = $height . 'px';
+
+ return $this;
+ }
+}
diff --git a/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php b/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php
new file mode 100644
index 0000000..380baee
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php
@@ -0,0 +1,132 @@
+bubble('parsedownElement', [$title, $alt, $class, $id, $reset]);
+ }
+
+ /**
+ * Return HTML markup from the medium.
+ *
+ * @param string $title
+ * @param string $alt
+ * @param string $class
+ * @param string $id
+ * @param bool $reset
+ * @return string
+ */
+ public function html($title = null, $alt = null, $class = null, $id = null, $reset = true)
+ {
+ return $this->bubble('html', [$title, $alt, $class, $id, $reset]);
+ }
+
+ /**
+ * Switch display mode.
+ *
+ * @param string $mode
+ *
+ * @return $this
+ */
+ public function display($mode = 'source')
+ {
+ return $this->bubble('display', [$mode], false);
+ }
+
+ /**
+ * Switch thumbnail.
+ *
+ * @param string $type
+ *
+ * @return $this
+ */
+ public function thumbnail($type = 'auto')
+ {
+ $this->bubble('thumbnail', [$type], false);
+
+ return $this->bubble('getThumbnail', [], false);
+ }
+
+ /**
+ * Turn the current Medium into a Link
+ *
+ * @param bool $reset
+ * @param array $attributes
+ * @return Link
+ */
+ public function link($reset = true, array $attributes = [])
+ {
+ return $this->bubble('link', [$reset, $attributes], false);
+ }
+
+ /**
+ * Turn the current Medium into a Link with lightbox enabled
+ *
+ * @param int $width
+ * @param int $height
+ * @param bool $reset
+ * @return Link
+ */
+ public function lightbox($width = null, $height = null, $reset = true)
+ {
+ return $this->bubble('lightbox', [$width, $height, $reset], false);
+ }
+
+ /**
+ * Bubble a function call up to either the superclass function or the parent Medium instance
+ *
+ * @param string $method
+ * @param array $arguments
+ * @param bool $testLinked
+ * @return Medium
+ */
+ protected function bubble($method, array $arguments = [], $testLinked = true)
+ {
+ if (!$testLinked || $this->linked) {
+ return $this->parent ? call_user_func_array(array($this->parent, $method), $arguments) : $this;
+ }
+
+ return call_user_func_array(array($this, 'parent::' . $method), $arguments);
+ }
+}
diff --git a/system/src/Grav/Common/Page/Medium/VideoMedium.php b/system/src/Grav/Common/Page/Medium/VideoMedium.php
new file mode 100644
index 0000000..c0b488a
--- /dev/null
+++ b/system/src/Grav/Common/Page/Medium/VideoMedium.php
@@ -0,0 +1,162 @@
+url($reset);
+
+ return [
+ 'name' => 'video',
+ 'text' => 'Your browser does not support the video tag.',
+ 'attributes' => $attributes
+ ];
+ }
+
+ /**
+ * Allows to set or remove the HTML5 default controls
+ *
+ * @param bool $display
+ * @return $this
+ */
+ public function controls($display = true)
+ {
+ if($display) {
+ $this->attributes['controls'] = true;
+ } else {
+ unset($this->attributes['controls']);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Allows to set the video's poster image
+ *
+ * @param string $urlImage
+ * @return $this
+ */
+ public function poster($urlImage)
+ {
+ $this->attributes['poster'] = $urlImage;
+
+ return $this;
+ }
+
+ /**
+ * Allows to set the loop attribute
+ *
+ * @param bool $status
+ * @return $this
+ */
+ public function loop($status = false)
+ {
+ if($status) {
+ $this->attributes['loop'] = true;
+ } else {
+ unset($this->attributes['loop']);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Allows to set the autoplay attribute
+ *
+ * @param bool $status
+ * @return $this
+ */
+ public function autoplay($status = false)
+ {
+ if ($status) {
+ $this->attributes['autoplay'] = '';
+ } else {
+ unset($this->attributes['autoplay']);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Allows ability to set the preload option
+ *
+ * @param null $status
+ * @return $this
+ */
+ public function preload($status = null)
+ {
+ if ($status) {
+ $this->attributes['preload'] = $status;
+ } else {
+ unset($this->attributes['preload']);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Allows to set the playsinline attribute
+ *
+ * @param bool $status
+ * @return $this
+ */
+ public function playsinline($status = false)
+ {
+ if($status) {
+ $this->attributes['playsinline'] = true;
+ } else {
+ unset($this->attributes['playsinline']);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Allows to set the muted attribute
+ *
+ * @param bool $status
+ * @return $this
+ */
+ public function muted($status = false)
+ {
+ if($status) {
+ $this->attributes['muted'] = true;
+ } else {
+ unset($this->attributes['muted']);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Reset medium.
+ *
+ * @return $this
+ */
+ public function reset()
+ {
+ parent::reset();
+
+ $this->attributes['controls'] = true;
+
+ return $this;
+ }
+}
diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php
new file mode 100644
index 0000000..b33d514
--- /dev/null
+++ b/system/src/Grav/Common/Page/Page.php
@@ -0,0 +1,3183 @@
+taxonomy = [];
+ $this->process = $config->get('system.pages.process');
+ $this->published = true;
+ }
+
+ /**
+ * Initializes the page instance variables based on a file
+ *
+ * @param \SplFileInfo $file The file information for the .md file that the page represents
+ * @param string $extension
+ *
+ * @return $this
+ */
+ public function init(\SplFileInfo $file, $extension = null)
+ {
+ $config = Grav::instance()['config'];
+
+ // some extension logic
+ if (empty($extension)) {
+ $this->extension('.' . $file->getExtension());
+ } else {
+ $this->extension($extension);
+ }
+
+ // extract page language from page extension
+ $language = trim(basename($this->extension(), 'md'), '.') ?: null;
+ $this->language($language);
+
+ $this->hide_home_route = $config->get('system.home.hide_in_urls', false);
+ $this->home_route = $this->adjustRouteCase($config->get('system.home.alias'));
+ $this->filePath($file->getPathname());
+ $this->modified($file->getMTime());
+ $this->id($this->modified() . md5($this->filePath()));
+ $this->routable(true);
+ $this->header();
+ $this->date();
+ $this->metadata();
+ $this->url();
+ $this->visible();
+ $this->modularTwig(strpos($this->slug(), '_') === 0);
+ $this->setPublishState();
+ $this->published();
+ $this->urlExtension();
+
+
+ return $this;
+ }
+
+ protected function processFrontmatter()
+ {
+ // Quick check for twig output tags in frontmatter if enabled
+ $process_fields = (array)$this->header();
+ if (Utils::contains(json_encode(array_values($process_fields)), '{{')) {
+ $ignored_fields = [];
+ foreach ((array)Grav::instance()['config']->get('system.pages.frontmatter.ignore_fields') as $field) {
+ if (isset($process_fields[$field])) {
+ $ignored_fields[$field] = $process_fields[$field];
+ unset($process_fields[$field]);
+ }
+ }
+ $text_header = Grav::instance()['twig']->processString(json_encode($process_fields, JSON_UNESCAPED_UNICODE), ['page' => $this]);
+ $this->header((object)(json_decode($text_header, true) + $ignored_fields));
+ }
+ }
+
+ /**
+ * Return an array with the routes of other translated languages
+ *
+ * @param bool $onlyPublished only return published translations
+ *
+ * @return array the page translated languages
+ */
+ public function translatedLanguages($onlyPublished = false)
+ {
+ $filename = substr($this->name, 0, -(strlen($this->extension())));
+ $config = Grav::instance()['config'];
+ $languages = $config->get('system.languages.supported', []);
+ $translatedLanguages = [];
+
+ foreach ($languages as $language) {
+ $path = $this->path . DS . $this->folder . DS . $filename . '.' . $language . '.md';
+ if (file_exists($path)) {
+ $aPage = new Page();
+ $aPage->init(new \SplFileInfo($path), $language . '.md');
+
+ $route = $aPage->header()->routes['default'] ?? $aPage->rawRoute();
+ if (!$route) {
+ $route = $aPage->route();
+ }
+
+ if ($onlyPublished && !$aPage->published()) {
+ continue;
+ }
+
+ $translatedLanguages[$language] = $route;
+ }
+ }
+
+ return $translatedLanguages;
+ }
+
+ /**
+ * Return an array listing untranslated languages available
+ *
+ * @param bool $includeUnpublished also list unpublished translations
+ *
+ * @return array the page untranslated languages
+ */
+ public function untranslatedLanguages($includeUnpublished = false)
+ {
+ $filename = substr($this->name, 0, -strlen($this->extension()));
+ $config = Grav::instance()['config'];
+ $languages = $config->get('system.languages.supported', []);
+ $untranslatedLanguages = [];
+
+ foreach ($languages as $language) {
+ $path = $this->path . DS . $this->folder . DS . $filename . '.' . $language . '.md';
+ if (file_exists($path)) {
+ $aPage = new Page();
+ $aPage->init(new \SplFileInfo($path), $language . '.md');
+ if ($includeUnpublished && !$aPage->published()) {
+ $untranslatedLanguages[] = $language;
+ }
+ } else {
+ $untranslatedLanguages[] = $language;
+ }
+ }
+
+ return $untranslatedLanguages;
+ }
+
+ /**
+ * Gets and Sets the raw data
+ *
+ * @param string $var Raw content string
+ *
+ * @return string Raw content string
+ */
+ public function raw($var = null)
+ {
+ $file = $this->file();
+
+ if ($var) {
+ // First update file object.
+ if ($file) {
+ $file->raw($var);
+ }
+
+ // Reset header and content.
+ $this->modified = time();
+ $this->id($this->modified() . md5($this->filePath()));
+ $this->header = null;
+ $this->content = null;
+ $this->summary = null;
+ }
+
+ return $file ? $file->raw() : '';
+ }
+
+ /**
+ * Gets and Sets the page frontmatter
+ *
+ * @param string|null $var
+ *
+ * @return string
+ */
+ public function frontmatter($var = null)
+ {
+
+ if ($var) {
+ $this->frontmatter = (string)$var;
+
+ // Update also file object.
+ $file = $this->file();
+ if ($file) {
+ $file->frontmatter((string)$var);
+ }
+
+ // Force content re-processing.
+ $this->id(time() . md5($this->filePath()));
+ }
+ if (!$this->frontmatter) {
+ $this->header();
+ }
+
+ return $this->frontmatter;
+ }
+
+ /**
+ * Gets and Sets the header based on the YAML configuration at the top of the .md file
+ *
+ * @param object|array $var a YAML object representing the configuration for the file
+ *
+ * @return object the current YAML configuration
+ */
+ public function header($var = null)
+ {
+ if ($var) {
+ $this->header = (object)$var;
+
+ // Update also file object.
+ $file = $this->file();
+ if ($file) {
+ $file->header((array)$var);
+ }
+
+ // Force content re-processing.
+ $this->id(time() . md5($this->filePath()));
+ }
+ if (!$this->header) {
+ $file = $this->file();
+ if ($file) {
+ try {
+ $this->raw_content = $file->markdown();
+ $this->frontmatter = $file->frontmatter();
+ $this->header = (object)$file->header();
+
+ if (!Utils::isAdminPlugin()) {
+ // If there's a `frontmatter.yaml` file merge that in with the page header
+ // note page's own frontmatter has precedence and will overwrite any defaults
+ $frontmatterFile = CompiledYamlFile::instance($this->path . '/' . $this->folder . '/frontmatter.yaml');
+ if ($frontmatterFile->exists()) {
+ $frontmatter_data = (array)$frontmatterFile->content();
+ $this->header = (object)array_replace_recursive($frontmatter_data,
+ (array)$this->header);
+ $frontmatterFile->free();
+ }
+ // Process frontmatter with Twig if enabled
+ if (Grav::instance()['config']->get('system.pages.frontmatter.process_twig') === true) {
+ $this->processFrontmatter();
+ }
+ }
+ } catch (\Exception $e) {
+ $file->raw(Grav::instance()['language']->translate([
+ 'GRAV.FRONTMATTER_ERROR_PAGE',
+ $this->slug(),
+ $file->filename(),
+ $e->getMessage(),
+ $file->raw()
+ ]));
+ $this->raw_content = $file->markdown();
+ $this->frontmatter = $file->frontmatter();
+ $this->header = (object)$file->header();
+ }
+ $var = true;
+ }
+
+
+ }
+
+ if ($var) {
+ if (isset($this->header->slug)) {
+ $this->slug($this->header->slug);
+ }
+ if (isset($this->header->routes)) {
+ $this->routes = (array)$this->header->routes;
+ }
+ if (isset($this->header->title)) {
+ $this->title = trim($this->header->title);
+ }
+ if (isset($this->header->language)) {
+ $this->language = trim($this->header->language);
+ }
+ if (isset($this->header->template)) {
+ $this->template = trim($this->header->template);
+ }
+ if (isset($this->header->menu)) {
+ $this->menu = trim($this->header->menu);
+ }
+ if (isset($this->header->routable)) {
+ $this->routable = (bool)$this->header->routable;
+ }
+ if (isset($this->header->visible)) {
+ $this->visible = (bool)$this->header->visible;
+ }
+ if (isset($this->header->redirect)) {
+ $this->redirect = trim($this->header->redirect);
+ }
+ if (isset($this->header->external_url)) {
+ $this->external_url = trim($this->header->external_url);
+ }
+ if (isset($this->header->order_dir)) {
+ $this->order_dir = trim($this->header->order_dir);
+ }
+ if (isset($this->header->order_by)) {
+ $this->order_by = trim($this->header->order_by);
+ }
+ if (isset($this->header->order_manual)) {
+ $this->order_manual = (array)$this->header->order_manual;
+ }
+ if (isset($this->header->dateformat)) {
+ $this->dateformat($this->header->dateformat);
+ }
+ if (isset($this->header->date)) {
+ $this->date($this->header->date);
+ }
+ if (isset($this->header->markdown_extra)) {
+ $this->markdown_extra = (bool)$this->header->markdown_extra;
+ }
+ if (isset($this->header->taxonomy)) {
+ $this->taxonomy($this->header->taxonomy);
+ }
+ if (isset($this->header->max_count)) {
+ $this->max_count = (int)$this->header->max_count;
+ }
+ if (isset($this->header->process)) {
+ foreach ((array)$this->header->process as $process => $status) {
+ $this->process[$process] = (bool)$status;
+ }
+ }
+ if (isset($this->header->published)) {
+ $this->published = (bool)$this->header->published;
+ }
+ if (isset($this->header->publish_date)) {
+ $this->publishDate($this->header->publish_date);
+ }
+ if (isset($this->header->unpublish_date)) {
+ $this->unpublishDate($this->header->unpublish_date);
+ }
+ if (isset($this->header->expires)) {
+ $this->expires = (int)$this->header->expires;
+ }
+ if (isset($this->header->cache_control)) {
+ $this->cache_control = $this->header->cache_control;
+ }
+ if (isset($this->header->etag)) {
+ $this->etag = (bool)$this->header->etag;
+ }
+ if (isset($this->header->last_modified)) {
+ $this->last_modified = (bool)$this->header->last_modified;
+ }
+ if (isset($this->header->ssl)) {
+ $this->ssl = (bool)$this->header->ssl;
+ }
+ if (isset($this->header->template_format)) {
+ $this->template_format = $this->header->template_format;
+ }
+ if (isset($this->header->debugger)) {
+ $this->debugger = (bool)$this->header->debugger;
+ }
+ if (isset($this->header->append_url_extension)) {
+ $this->url_extension = $this->header->append_url_extension;
+ }
+ }
+
+ return $this->header;
+ }
+
+ /**
+ * Get page language
+ *
+ * @param string $var
+ *
+ * @return mixed
+ */
+ public function language($var = null)
+ {
+ if ($var !== null) {
+ $this->language = $var;
+ }
+
+ return $this->language;
+ }
+
+ /**
+ * Modify a header value directly
+ *
+ * @param string $key
+ * @param mixed $value
+ */
+ public function modifyHeader($key, $value)
+ {
+ $this->header->{$key} = $value;
+ }
+
+ /**
+ * @return int
+ */
+ public function httpResponseCode()
+ {
+ return (int)($this->header()->http_response_code ?? 200);
+ }
+
+ public function httpHeaders()
+ {
+ $headers = [];
+
+ $grav = Grav::instance();
+ $format = $this->templateFormat();
+ $cache_control = $this->cacheControl();
+ $expires = $this->expires();
+
+ // Set Content-Type header
+ $headers['Content-Type'] = Utils::getMimeByExtension($format, 'text/html');
+
+ // Calculate Expires Headers if set to > 0
+ if ($expires > 0) {
+ $expires_date = gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT';
+ if (!$cache_control) {
+ $headers['Cache-Control'] = 'max-age=' . $expires;
+ }
+ $headers['Expires'] = $expires_date;
+ }
+
+ // Set Cache-Control header
+ if ($cache_control) {
+ $headers['Cache-Control'] = strtolower($cache_control);
+ }
+
+ // Set Last-Modified header
+ if ($this->lastModified()) {
+ $last_modified_date = gmdate('D, d M Y H:i:s', $this->modified()) . ' GMT';
+ $headers['Last-Modified'] = $last_modified_date;
+ }
+
+ // Ask Grav to calculate ETag from the final content.
+ if ($this->eTag()) {
+ $headers['ETag'] = '1';
+ }
+
+ // Set Vary: Accept-Encoding header
+ if ($grav['config']->get('system.pages.vary_accept_encoding', false)) {
+ $headers['Vary'] = 'Accept-Encoding';
+ }
+
+ return $headers;
+ }
+
+ /**
+ * Get the summary.
+ *
+ * @param int $size Max summary size.
+ *
+ * @param bool $textOnly Only count text size.
+ *
+ * @return string
+ */
+ public function summary($size = null, $textOnly = false)
+ {
+ $config = (array)Grav::instance()['config']->get('site.summary');
+ if (isset($this->header->summary)) {
+ $config = array_merge($config, $this->header->summary);
+ }
+
+ // Return summary based on settings in site config file
+ if (!$config['enabled']) {
+ return $this->content();
+ }
+
+ // Set up variables to process summary from page or from custom summary
+ if ($this->summary === null) {
+ $content = $textOnly ? strip_tags($this->content()) : $this->content();
+ $summary_size = $this->summary_size;
+ } else {
+ $content = strip_tags($this->summary);
+ // Use mb_strwidth to deal with the 2 character widths characters
+ $summary_size = mb_strwidth($content, 'utf-8');
+ }
+
+ // Return calculated summary based on summary divider's position
+ $format = $config['format'];
+ // Return entire page content on wrong/ unknown format
+ if (!in_array($format, ['short', 'long'])) {
+ return $content;
+ }
+ if (($format === 'short') && isset($summary_size)) {
+ // Use mb_strimwidth to slice the string
+ if (mb_strwidth($content, 'utf8') > $summary_size) {
+ return mb_substr($content, 0, $summary_size);
+ }
+
+ return $content;
+ }
+
+ // Get summary size from site config's file
+ if ($size === null) {
+ $size = $config['size'];
+ }
+
+ // If the size is zero, return the entire page content
+ if ($size === 0) {
+ return $content;
+ // Return calculated summary based on defaults
+ }
+ if (!is_numeric($size) || ($size < 0)) {
+ $size = 300;
+ }
+
+ // Only return string but not html, wrap whatever html tag you want when using
+ if ($textOnly) {
+ if (mb_strwidth($content, 'utf-8') <= $size) {
+ return $content;
+ }
+
+ return mb_strimwidth($content, 0, $size, '…', 'UTF-8');
+ }
+
+ $summary = Utils::truncateHtml($content, $size);
+
+ return html_entity_decode($summary, ENT_COMPAT | ENT_HTML401, 'UTF-8');
+ }
+
+ /**
+ * Sets the summary of the page
+ *
+ * @param string $summary Summary
+ */
+ public function setSummary($summary)
+ {
+ $this->summary = $summary;
+ }
+
+ /**
+ * Gets and Sets the content based on content portion of the .md file
+ *
+ * @param string $var Content
+ *
+ * @return string Content
+ */
+ public function content($var = null)
+ {
+ if ($var !== null) {
+ $this->raw_content = $var;
+
+ // Update file object.
+ $file = $this->file();
+ if ($file) {
+ $file->markdown($var);
+ }
+
+ // Force re-processing.
+ $this->id(time() . md5($this->filePath()));
+ $this->content = null;
+ }
+ // If no content, process it
+ if ($this->content === null) {
+ // Get media
+ $this->media();
+
+ /** @var Config $config */
+ $config = Grav::instance()['config'];
+
+ // Load cached content
+ /** @var Cache $cache */
+ $cache = Grav::instance()['cache'];
+ $cache_id = md5('page' . $this->getCacheKey());
+ $content_obj = $cache->fetch($cache_id);
+
+ if (is_array($content_obj)) {
+ $this->content = $content_obj['content'];
+ $this->content_meta = $content_obj['content_meta'];
+ } else {
+ $this->content = $content_obj;
+ }
+
+
+ $process_markdown = $this->shouldProcess('markdown');
+ $process_twig = $this->shouldProcess('twig') || $this->modularTwig();
+
+ $cache_enable = $this->header->cache_enable ?? $config->get('system.cache.enabled',
+ true);
+ $twig_first = $this->header->twig_first ?? $config->get('system.pages.twig_first',
+ true);
+
+ // never cache twig means it's always run after content
+ $never_cache_twig = $this->header->never_cache_twig ?? $config->get('system.pages.never_cache_twig',
+ false);
+
+ // if no cached-content run everything
+ if ($never_cache_twig) {
+ if ($this->content === false || $cache_enable === false) {
+ $this->content = $this->raw_content;
+ Grav::instance()->fireEvent('onPageContentRaw', new Event(['page' => $this]));
+
+ if ($process_markdown) {
+ $this->processMarkdown();
+ }
+
+ // Content Processed but not cached yet
+ Grav::instance()->fireEvent('onPageContentProcessed', new Event(['page' => $this]));
+
+ if ($cache_enable) {
+ $this->cachePageContent();
+ }
+ }
+
+ if ($process_twig) {
+ $this->processTwig();
+ }
+
+ } else {
+ if ($this->content === false || $cache_enable === false) {
+ $this->content = $this->raw_content;
+ Grav::instance()->fireEvent('onPageContentRaw', new Event(['page' => $this]));
+
+ if ($twig_first) {
+ if ($process_twig) {
+ $this->processTwig();
+ }
+ if ($process_markdown) {
+ $this->processMarkdown();
+ }
+
+ // Content Processed but not cached yet
+ Grav::instance()->fireEvent('onPageContentProcessed', new Event(['page' => $this]));
+
+ } else {
+ if ($process_markdown) {
+ $this->processMarkdown();
+ }
+
+ // Content Processed but not cached yet
+ Grav::instance()->fireEvent('onPageContentProcessed', new Event(['page' => $this]));
+
+ if ($process_twig) {
+ $this->processTwig();
+ }
+ }
+
+ if ($cache_enable) {
+ $this->cachePageContent();
+ }
+ }
+ }
+
+ // Handle summary divider
+ $delimiter = $config->get('site.summary.delimiter', '===');
+ $divider_pos = mb_strpos($this->content, "{$delimiter}
");
+ if ($divider_pos !== false) {
+ $this->summary_size = $divider_pos;
+ $this->content = str_replace("{$delimiter}
", '', $this->content);
+ }
+
+ // Fire event when Page::content() is called
+ Grav::instance()->fireEvent('onPageContent', new Event(['page' => $this]));
+ }
+
+ return $this->content;
+ }
+
+ /**
+ * Get the contentMeta array and initialize content first if it's not already
+ *
+ * @return mixed
+ */
+ public function contentMeta()
+ {
+ if ($this->content === null) {
+ $this->content();
+ }
+
+ return $this->getContentMeta();
+ }
+
+ /**
+ * Add an entry to the page's contentMeta array
+ *
+ * @param string $name
+ * @param string $value
+ */
+ public function addContentMeta($name, $value)
+ {
+ $this->content_meta[$name] = $value;
+ }
+
+ /**
+ * Return the whole contentMeta array as it currently stands
+ *
+ * @param string|null $name
+ *
+ * @return string
+ */
+ public function getContentMeta($name = null)
+ {
+ if ($name) {
+ if (isset($this->content_meta[$name])) {
+ return $this->content_meta[$name];
+ }
+
+ return null;
+ }
+
+ return $this->content_meta;
+ }
+
+ /**
+ * Sets the whole content meta array in one shot
+ *
+ * @param array $content_meta
+ *
+ * @return array
+ */
+ public function setContentMeta($content_meta)
+ {
+ return $this->content_meta = $content_meta;
+ }
+
+ /**
+ * Process the Markdown content. Uses Parsedown or Parsedown Extra depending on configuration
+ */
+ protected function processMarkdown()
+ {
+ /** @var Config $config */
+ $config = Grav::instance()['config'];
+
+ $markdownDefaults = (array)$config->get('system.pages.markdown');
+ if (isset($this->header()->markdown)) {
+ $markdownDefaults = array_merge($markdownDefaults, $this->header()->markdown);
+ }
+
+ // pages.markdown_extra is deprecated, but still check it...
+ if (!isset($markdownDefaults['extra']) && (isset($this->markdown_extra) || $config->get('system.pages.markdown_extra') !== null)) {
+ user_error('Configuration option \'system.pages.markdown_extra\' is deprecated since Grav 1.5, use \'system.pages.markdown.extra\' instead', E_USER_DEPRECATED);
+
+ $markdownDefaults['extra'] = $this->markdown_extra ?: $config->get('system.pages.markdown_extra');
+ }
+
+ $extra = $markdownDefaults['extra'] ?? false;
+ $defaults = [
+ 'markdown' => $markdownDefaults,
+ 'images' => $config->get('system.images', [])
+ ];
+
+ $excerpts = new Excerpts($this, $defaults);
+
+ // Initialize the preferred variant of Parsedown
+ if ($extra) {
+ $parsedown = new ParsedownExtra($excerpts);
+ } else {
+ $parsedown = new Parsedown($excerpts);
+ }
+
+ $this->content = $parsedown->text($this->content);
+ }
+
+
+ /**
+ * Process the Twig page content.
+ */
+ private function processTwig()
+ {
+ $twig = Grav::instance()['twig'];
+ $this->content = $twig->processPage($this, $this->content);
+ }
+
+ /**
+ * Fires the onPageContentProcessed event, and caches the page content using a unique ID for the page
+ */
+ public function cachePageContent()
+ {
+ $cache = Grav::instance()['cache'];
+ $cache_id = md5('page' . $this->getCacheKey());
+ $cache->save($cache_id, ['content' => $this->content, 'content_meta' => $this->content_meta]);
+ }
+
+ /**
+ * Needed by the onPageContentProcessed event to get the raw page content
+ *
+ * @return string the current page content
+ */
+ public function getRawContent()
+ {
+ return $this->content;
+ }
+
+ /**
+ * Needed by the onPageContentProcessed event to set the raw page content
+ *
+ * @param string $content
+ */
+ public function setRawContent($content)
+ {
+ $this->content = $content ?? '';
+ }
+
+ /**
+ * Get value from a page variable (used mostly for creating edit forms).
+ *
+ * @param string $name Variable name.
+ * @param mixed $default
+ *
+ * @return mixed
+ */
+ public function value($name, $default = null)
+ {
+ if ($name === 'content') {
+ return $this->raw_content;
+ }
+ if ($name === 'route') {
+ $parent = $this->parent();
+
+ return $parent ? $parent->rawRoute() : '';
+ }
+ if ($name === 'order') {
+ $order = $this->order();
+
+ return $order ? (int)$this->order() : '';
+ }
+ if ($name === 'ordering') {
+ return (bool)$this->order();
+ }
+ if ($name === 'folder') {
+ return preg_replace(PAGE_ORDER_PREFIX_REGEX, '', $this->folder);
+ }
+ if ($name === 'slug') {
+ return $this->slug();
+ }
+ if ($name === 'name') {
+ $language = $this->language() ? '.' . $this->language() : '';
+ $name_val = str_replace($language . '.md', '', $this->name());
+ if ($this->modular()) {
+ return 'modular/' . $name_val;
+ }
+
+ return $name_val;
+ }
+ if ($name === 'media') {
+ return $this->media()->all();
+ }
+ if ($name === 'media.file') {
+ return $this->media()->files();
+ }
+ if ($name === 'media.video') {
+ return $this->media()->videos();
+ }
+ if ($name === 'media.image') {
+ return $this->media()->images();
+ }
+ if ($name === 'media.audio') {
+ return $this->media()->audios();
+ }
+
+ $path = explode('.', $name);
+ $scope = array_shift($path);
+
+ if ($name === 'frontmatter') {
+ return $this->frontmatter;
+ }
+
+ if ($scope === 'header') {
+ $current = $this->header();
+ foreach ($path as $field) {
+ if (is_object($current) && isset($current->{$field})) {
+ $current = $current->{$field};
+ } elseif (is_array($current) && isset($current[$field])) {
+ $current = $current[$field];
+ } else {
+ return $default;
+ }
+ }
+
+ return $current;
+ }
+
+ return $default;
+ }
+
+ /**
+ * Gets and Sets the Page raw content
+ *
+ * @param string|null $var
+ *
+ * @return string
+ */
+ public function rawMarkdown($var = null)
+ {
+ if ($var !== null) {
+ $this->raw_content = $var;
+ }
+
+ return $this->raw_content;
+ }
+
+ /**
+ * Get file object to the page.
+ *
+ * @return MarkdownFile|null
+ */
+ public function file()
+ {
+ if ($this->name) {
+ return MarkdownFile::instance($this->filePath());
+ }
+
+ return null;
+ }
+
+ /**
+ * Save page if there's a file assigned to it.
+ *
+ * @param bool|mixed $reorder Internal use.
+ */
+ public function save($reorder = true)
+ {
+ // Perform move, copy [or reordering] if needed.
+ $this->doRelocation();
+
+ $file = $this->file();
+ if ($file) {
+ $file->filename($this->filePath());
+ $file->header((array)$this->header());
+ $file->markdown($this->raw_content);
+ $file->save();
+ }
+
+ // Perform reorder if required
+ if ($reorder && is_array($reorder)) {
+ $this->doReorder($reorder);
+ }
+
+ $this->_original = null;
+ }
+
+ /**
+ * Prepare move page to new location. Moves also everything that's under the current page.
+ *
+ * You need to call $this->save() in order to perform the move.
+ *
+ * @param PageInterface $parent New parent page.
+ *
+ * @return $this
+ */
+ public function move(PageInterface $parent)
+ {
+ if (!$this->_original) {
+ $clone = clone $this;
+ $this->_original = $clone;
+ }
+
+ $this->_action = 'move';
+
+ if ($this->route() === $parent->route()) {
+ throw new \RuntimeException('Failed: Cannot set page parent to self');
+ }
+ if (Utils::startsWith($parent->rawRoute(), $this->rawRoute())) {
+ throw new \RuntimeException('Failed: Cannot set page parent to a child of current page');
+ }
+
+ $this->parent($parent);
+ $this->id(time() . md5($this->filePath()));
+
+ if ($parent->path()) {
+ $this->path($parent->path() . '/' . $this->folder());
+ }
+
+ if ($parent->route()) {
+ $this->route($parent->route() . '/' . $this->slug());
+ } else {
+ $this->route(Grav::instance()['pages']->root()->route() . '/' . $this->slug());
+ }
+
+ $this->raw_route = null;
+
+ return $this;
+ }
+
+ /**
+ * Prepare a copy from the page. Copies also everything that's under the current page.
+ *
+ * Returns a new Page object for the copy.
+ * You need to call $this->save() in order to perform the move.
+ *
+ * @param PageInterface $parent New parent page.
+ *
+ * @return $this
+ */
+ public function copy(PageInterface $parent)
+ {
+ $this->move($parent);
+ $this->_action = 'copy';
+
+ return $this;
+ }
+
+ /**
+ * Get blueprints for the page.
+ *
+ * @return Blueprint
+ */
+ public function blueprints()
+ {
+ $grav = Grav::instance();
+
+ /** @var Pages $pages */
+ $pages = $grav['pages'];
+
+ $blueprint = $pages->blueprints($this->blueprintName());
+ $fields = $blueprint->fields();
+ $edit_mode = isset($grav['admin']) ? $grav['config']->get('plugins.admin.edit_mode') : null;
+
+ // override if you only want 'normal' mode
+ if (empty($fields) && ($edit_mode === 'auto' || $edit_mode === 'normal')) {
+ $blueprint = $pages->blueprints('default');
+ }
+
+ // override if you only want 'expert' mode
+ if (!empty($fields) && $edit_mode === 'expert') {
+ $blueprint = $pages->blueprints('');
+ }
+
+ return $blueprint;
+ }
+
+ /**
+ * Get the blueprint name for this page. Use the blueprint form field if set
+ *
+ * @return string
+ */
+ public function blueprintName()
+ {
+ $blueprint_name = filter_input(INPUT_POST, 'blueprint', FILTER_SANITIZE_STRING) ?: $this->template();
+
+ return $blueprint_name;
+ }
+
+ /**
+ * Validate page header.
+ *
+ * @throws \Exception
+ */
+ public function validate()
+ {
+ $blueprints = $this->blueprints();
+ $blueprints->validate($this->toArray());
+ }
+
+ /**
+ * Filter page header from illegal contents.
+ */
+ public function filter()
+ {
+ $blueprints = $this->blueprints();
+ $values = $blueprints->filter($this->toArray());
+ if ($values && isset($values['header'])) {
+ $this->header($values['header']);
+ }
+ }
+
+ /**
+ * Get unknown header variables.
+ *
+ * @return array
+ */
+ public function extra()
+ {
+ $blueprints = $this->blueprints();
+
+ return $blueprints->extra($this->toArray()['header'], 'header.');
+ }
+
+ /**
+ * Convert page to an array.
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ return [
+ 'header' => (array)$this->header(),
+ 'content' => (string)$this->value('content')
+ ];
+ }
+
+ /**
+ * Convert page to YAML encoded string.
+ *
+ * @return string
+ */
+ public function toYaml()
+ {
+ return Yaml::dump($this->toArray(), 20);
+ }
+
+ /**
+ * Convert page to JSON encoded string.
+ *
+ * @return string
+ */
+ public function toJson()
+ {
+ return json_encode($this->toArray());
+ }
+
+ /**
+ * @return string
+ */
+ public function getCacheKey(): string
+ {
+ return $this->id();
+ }
+
+ /**
+ * Returns normalized list of name => form pairs.
+ *
+ * @return array
+ */
+ public function forms()
+ {
+ if (null === $this->forms) {
+ $header = $this->header();
+
+ // Call event to allow filling the page header form dynamically (e.g. use case: Comments plugin)
+ $grav = Grav::instance();
+ $grav->fireEvent('onFormPageHeaderProcessed', new Event(['page' => $this, 'header' => $header]));
+
+ $rules = $header->rules ?? null;
+ if (!\is_array($rules)) {
+ $rules = [];
+ }
+
+ $forms = [];
+
+ // First grab page.header.form
+ $form = $this->normalizeForm($header->form ?? null, null, $rules);
+ if ($form) {
+ $forms[$form['name']] = $form;
+ }
+
+ // Append page.header.forms (override singular form if it clashes)
+ $headerForms = $header->forms ?? null;
+ if (\is_array($headerForms)) {
+ foreach ($headerForms as $name => $form) {
+ $form = $this->normalizeForm($form, $name, $rules);
+ if ($form) {
+ $forms[$form['name']] = $form;
+ }
+ }
+ }
+
+ $this->forms = $forms;
+ }
+
+ return $this->forms;
+ }
+
+ /**
+ * @param array $new
+ */
+ public function addForms(array $new)
+ {
+ // Initialize forms.
+ $this->forms();
+
+ foreach ($new as $form) {
+ $form = $this->normalizeForm($form);
+ if ($form) {
+ $this->forms[$form['name']] = $form;
+ }
+ }
+ }
+
+ protected function normalizeForm($form, $name = null, array $rules = [])
+ {
+ if (!\is_array($form)) {
+ return null;
+ }
+
+ // Ignore numeric indexes on name.
+ if (!$name || (string)(int)$name === (string)$name) {
+ $name = null;
+ }
+
+ $name = $name ?? $form['name'] ?? $this->slug();
+
+ $formRules = $form['rules'] ?? null;
+ if (!\is_array($formRules)) {
+ $formRules = [];
+ }
+
+ return ['name' => $name, 'rules' => $rules + $formRules] + $form;
+ }
+
+ /**
+ * Gets and sets the associated media as found in the page folder.
+ *
+ * @param Media $var Representation of associated media.
+ *
+ * @return Media Representation of associated media.
+ */
+ public function media($var = null)
+ {
+ if ($var) {
+ $this->setMedia($var);
+ }
+
+ return $this->getMedia();
+ }
+
+ /**
+ * Get filesystem path to the associated media.
+ *
+ * @return string|null
+ */
+ public function getMediaFolder()
+ {
+ return $this->path();
+ }
+
+ /**
+ * Get display order for the associated media.
+ *
+ * @return array Empty array means default ordering.
+ */
+ public function getMediaOrder()
+ {
+ $header = $this->header();
+
+ return isset($header->media_order) ? array_map('trim', explode(',', (string)$header->media_order)) : [];
+ }
+
+ /**
+ * Gets and sets the name field. If no name field is set, it will return 'default.md'.
+ *
+ * @param string $var The name of this page.
+ *
+ * @return string The name of this page.
+ */
+ public function name($var = null)
+ {
+ if ($var !== null) {
+ $this->name = $var;
+ }
+
+ return $this->name ?: 'default.md';
+ }
+
+ /**
+ * Returns child page type.
+ *
+ * @return string
+ */
+ public function childType()
+ {
+ return isset($this->header->child_type) ? (string)$this->header->child_type : '';
+ }
+
+ /**
+ * Gets and sets the template field. This is used to find the correct Twig template file to render.
+ * If no field is set, it will return the name without the .md extension
+ *
+ * @param string $var the template name
+ *
+ * @return string the template name
+ */
+ public function template($var = null)
+ {
+ if ($var !== null) {
+ $this->template = $var;
+ }
+ if (empty($this->template)) {
+ $this->template = ($this->modular() ? 'modular/' : '') . str_replace($this->extension(), '', $this->name());
+ }
+
+ return $this->template;
+ }
+
+ /**
+ * Allows a page to override the output render format, usually the extension provided
+ * in the URL. (e.g. `html`, `json`, `xml`, etc).
+ *
+ * @param null $var
+ *
+ * @return null
+ */
+ public function templateFormat($var = null)
+ {
+ if ($var !== null) {
+ $this->template_format = $var;
+ return $this->template_format;
+ }
+
+ if (isset($this->template_format)) {
+ return $this->template_format;
+ }
+
+ // Set from URL extension set on page
+ $page_extension = trim($this->header->append_url_extension ?? '' , '.');
+ if (!empty($page_extension)) {
+ $this->template_format = $page_extension;
+
+ return $this->template_format;
+ }
+
+ // Set from uri extension
+ $uri_extension = Grav::instance()['uri']->extension();
+ if (is_string($uri_extension)) {
+ $this->template_format = $uri_extension;
+
+ return $this->template_format;
+ }
+
+ // Use content negotiation via the `accept:` header
+ $http_accept = $_SERVER['HTTP_ACCEPT'] ?? null;
+ if (is_string($http_accept)) {
+ $negotiator = new Negotiator();
+
+ $supported_types = Utils::getSupportPageTypes(['html', 'json']);
+ $priorities = Utils::getMimeTypes($supported_types);
+
+ $media_type = $negotiator->getBest($http_accept, $priorities);
+ $mimetype = $media_type instanceof Accept ? $media_type->getValue() : '';
+
+ $this->template_format = Utils::getExtensionByMime($mimetype);
+
+ return $this->template_format;
+ }
+
+ // Last chance set a default type
+ $this->template_format = 'html';
+ return $this->template_format;
+ }
+
+ /**
+ * Gets and sets the extension field.
+ *
+ * @param null $var
+ *
+ * @return null|string
+ */
+ public function extension($var = null)
+ {
+ if ($var !== null) {
+ $this->extension = $var;
+ }
+ if (empty($this->extension)) {
+ $this->extension = '.' . pathinfo($this->name(), PATHINFO_EXTENSION);
+ }
+
+ return $this->extension;
+ }
+
+ /**
+ * Returns the page extension, got from the page `url_extension` config and falls back to the
+ * system config `system.pages.append_url_extension`.
+ *
+ * @return string The extension of this page. For example `.html`
+ */
+ public function urlExtension()
+ {
+ if ($this->home()) {
+ return '';
+ }
+
+ // if not set in the page get the value from system config
+ if (null === $this->url_extension) {
+ $this->url_extension = Grav::instance()['config']->get('system.pages.append_url_extension', '');
+ }
+
+ return $this->url_extension;
+ }
+
+ /**
+ * Gets and sets the expires field. If not set will return the default
+ *
+ * @param int $var The new expires value.
+ *
+ * @return int The expires value
+ */
+ public function expires($var = null)
+ {
+ if ($var !== null) {
+ $this->expires = $var;
+ }
+
+ return $this->expires ?? Grav::instance()['config']->get('system.pages.expires');
+ }
+
+ /**
+ * Gets and sets the cache-control property. If not set it will return the default value (null)
+ * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control for more details on valid options
+ *
+ * @param null $var
+ * @return null
+ */
+ public function cacheControl($var = null)
+ {
+ if ($var !== null) {
+ $this->cache_control = $var;
+ }
+
+ return $this->cache_control ?? Grav::instance()['config']->get('system.pages.cache_control');
+ }
+
+ /**
+ * Gets and sets the title for this Page. If no title is set, it will use the slug() to get a name
+ *
+ * @param string $var the title of the Page
+ *
+ * @return string the title of the Page
+ */
+ public function title($var = null)
+ {
+ if ($var !== null) {
+ $this->title = $var;
+ }
+ if (empty($this->title)) {
+ $this->title = ucfirst($this->slug());
+ }
+
+ return $this->title;
+ }
+
+ /**
+ * Gets and sets the menu name for this Page. This is the text that can be used specifically for navigation.
+ * If no menu field is set, it will use the title()
+ *
+ * @param string $var the menu field for the page
+ *
+ * @return string the menu field for the page
+ */
+ public function menu($var = null)
+ {
+ if ($var !== null) {
+ $this->menu = $var;
+ }
+ if (empty($this->menu)) {
+ $this->menu = $this->title();
+ }
+
+ return $this->menu;
+ }
+
+ /**
+ * Gets and Sets whether or not this Page is visible for navigation
+ *
+ * @param bool $var true if the page is visible
+ *
+ * @return bool true if the page is visible
+ */
+ public function visible($var = null)
+ {
+ if ($var !== null) {
+ $this->visible = (bool)$var;
+ }
+
+ if ($this->visible === null) {
+ // Set item visibility in menu if folder is different from slug
+ // eg folder = 01.Home and slug = Home
+ if (preg_match(PAGE_ORDER_PREFIX_REGEX, $this->folder)) {
+ $this->visible = true;
+ } else {
+ $this->visible = false;
+ }
+ }
+
+ return $this->visible;
+ }
+
+ /**
+ * Gets and Sets whether or not this Page is considered published
+ *
+ * @param bool $var true if the page is published
+ *
+ * @return bool true if the page is published
+ */
+ public function published($var = null)
+ {
+ if ($var !== null) {
+ $this->published = (bool)$var;
+ }
+
+ // If not published, should not be visible in menus either
+ if ($this->published === false) {
+ $this->visible = false;
+ }
+
+ return $this->published;
+ }
+
+ /**
+ * Gets and Sets the Page publish date
+ *
+ * @param string $var string representation of a date
+ *
+ * @return int unix timestamp representation of the date
+ */
+ public function publishDate($var = null)
+ {
+ if ($var !== null) {
+ $this->publish_date = Utils::date2timestamp($var, $this->dateformat);
+ }
+
+ return $this->publish_date;
+ }
+
+ /**
+ * Gets and Sets the Page unpublish date
+ *
+ * @param string $var string representation of a date
+ *
+ * @return int|null unix timestamp representation of the date
+ */
+ public function unpublishDate($var = null)
+ {
+ if ($var !== null) {
+ $this->unpublish_date = Utils::date2timestamp($var, $this->dateformat);
+ }
+
+ return $this->unpublish_date;
+ }
+
+ /**
+ * Gets and Sets whether or not this Page is routable, ie you can reach it
+ * via a URL.
+ * The page must be *routable* and *published*
+ *
+ * @param bool $var true if the page is routable
+ *
+ * @return bool true if the page is routable
+ */
+ public function routable($var = null)
+ {
+ if ($var !== null) {
+ $this->routable = (bool)$var;
+ }
+
+ return $this->routable && $this->published();
+ }
+
+ public function ssl($var = null)
+ {
+ if ($var !== null) {
+ $this->ssl = (bool)$var;
+ }
+
+ return $this->ssl;
+ }
+
+ /**
+ * Gets and Sets the process setup for this Page. This is multi-dimensional array that consists of
+ * a simple array of arrays with the form array("markdown"=>true) for example
+ *
+ * @param array $var an Array of name value pairs where the name is the process and value is true or false
+ *
+ * @return array an Array of name value pairs where the name is the process and value is true or false
+ */
+ public function process($var = null)
+ {
+ if ($var !== null) {
+ $this->process = (array)$var;
+ }
+
+ return $this->process;
+ }
+
+ /**
+ * Returns the state of the debugger override etting for this page
+ *
+ * @return mixed
+ */
+ public function debugger()
+ {
+ return !(isset($this->debugger) && $this->debugger === false);
+ }
+
+ /**
+ * Function to merge page metadata tags and build an array of Metadata objects
+ * that can then be rendered in the page.
+ *
+ * @param array $var an Array of metadata values to set
+ *
+ * @return array an Array of metadata values for the page
+ */
+ public function metadata($var = null)
+ {
+ if ($var !== null) {
+ $this->metadata = (array)$var;
+ }
+
+ // if not metadata yet, process it.
+ if (null === $this->metadata) {
+ $header_tag_http_equivs = ['content-type', 'default-style', 'refresh', 'x-ua-compatible'];
+
+ $this->metadata = [];
+
+ $metadata = [];
+ // Set the Generator tag
+ $metadata['generator'] = 'GravCMS';
+
+ // Get initial metadata for the page
+ $metadata = array_merge($metadata, Grav::instance()['config']->get('site.metadata', []));
+
+ if (isset($this->header->metadata) && is_array($this->header->metadata)) {
+ // Merge any site.metadata settings in with page metadata
+ $metadata = array_merge($metadata, $this->header->metadata);
+ }
+
+ // Build an array of meta objects..
+ foreach ((array)$metadata as $key => $value) {
+ // Lowercase the key
+ $key = strtolower($key);
+ // If this is a property type metadata: "og", "twitter", "facebook" etc
+ // Backward compatibility for nested arrays in metas
+ if (is_array($value)) {
+ foreach ($value as $property => $prop_value) {
+ $prop_key = $key . ':' . $property;
+ $this->metadata[$prop_key] = [
+ 'name' => $prop_key,
+ 'property' => $prop_key,
+ 'content' => htmlspecialchars($prop_value, ENT_QUOTES, 'UTF-8')
+ ];
+ }
+ } else {
+ // If it this is a standard meta data type
+ if ($value) {
+ if (\in_array($key, $header_tag_http_equivs, true)) {
+ $this->metadata[$key] = [
+ 'http_equiv' => $key,
+ 'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
+ ];
+ } elseif ($key === 'charset') {
+ $this->metadata[$key] = ['charset' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')];
+ } else {
+ // if it's a social metadata with separator, render as property
+ $separator = strpos($key, ':');
+ $hasSeparator = $separator && $separator < strlen($key) - 1;
+ $entry = [
+ 'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
+ ];
+
+ if ($hasSeparator && !Utils::startsWith($key, 'twitter')) {
+ $entry['property'] = $key;
+ } else {
+ $entry['name'] = $key;
+ }
+
+ $this->metadata[$key] = $entry;
+ }
+ }
+ }
+ }
+ }
+
+ return $this->metadata;
+ }
+
+ /**
+ * Reset the metadata and pull from header again
+ */
+ public function resetMetadata()
+ {
+ $this->metadata = null;
+ }
+
+ /**
+ * Gets and Sets the slug for the Page. The slug is used in the URL routing. If not set it uses
+ * the parent folder from the path
+ *
+ * @param string $var the slug, e.g. 'my-blog'
+ *
+ * @return string the slug
+ */
+ public function slug($var = null)
+ {
+ if ($var !== null && $var !== '') {
+ $this->slug = $var;
+ }
+
+ if (empty($this->slug)) {
+ $this->slug = $this->adjustRouteCase(preg_replace(PAGE_ORDER_PREFIX_REGEX, '', $this->folder)) ?: null;
+ }
+
+ return $this->slug;
+ }
+
+ /**
+ * Get/set order number of this page.
+ *
+ * @param int $var
+ *
+ * @return int|bool
+ */
+ public function order($var = null)
+ {
+ if ($var !== null) {
+ $order = $var ? sprintf('%02d.', (int)$var) : '';
+ $this->folder($order . preg_replace(PAGE_ORDER_PREFIX_REGEX, '', $this->folder));
+
+ return $order;
+ }
+
+ preg_match(PAGE_ORDER_PREFIX_REGEX, $this->folder, $order);
+
+ return $order[0] ?? false;
+ }
+
+ /**
+ * Gets the URL for a page - alias of url().
+ *
+ * @param bool $include_host
+ *
+ * @return string the permalink
+ */
+ public function link($include_host = false)
+ {
+ return $this->url($include_host);
+ }
+
+ /**
+ * Gets the URL with host information, aka Permalink.
+ * @return string The permalink.
+ */
+ public function permalink()
+ {
+ return $this->url(true, false, true, true);
+ }
+
+ /**
+ * Returns the canonical URL for a page
+ *
+ * @param bool $include_lang
+ *
+ * @return string
+ */
+ public function canonical($include_lang = true)
+ {
+ return $this->url(true, true, $include_lang);
+ }
+
+ /**
+ * Gets the url for the Page.
+ *
+ * @param bool $include_host Defaults false, but true would include http://yourhost.com
+ * @param bool $canonical True to return the canonical URL
+ * @param bool $include_base Include base url on multisite as well as language code
+ * @param bool $raw_route
+ *
+ * @return string The url.
+ */
+ public function url($include_host = false, $canonical = false, $include_base = true, $raw_route = false)
+ {
+ // Override any URL when external_url is set
+ if (isset($this->external_url)) {
+ return $this->external_url;
+ }
+
+ $grav = Grav::instance();
+
+ /** @var Pages $pages */
+ $pages = $grav['pages'];
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ // get base route (multi-site base and language)
+ $route = $include_base ? $pages->baseRoute() : '';
+
+ // add full route if configured to do so
+ if (!$include_host && $config->get('system.absolute_urls', false)) {
+ $include_host = true;
+ }
+
+ if ($canonical) {
+ $route .= $this->routeCanonical();
+ } elseif ($raw_route) {
+ $route .= $this->rawRoute();
+ } else {
+ $route .= $this->route();
+ }
+
+ /** @var Uri $uri */
+ $uri = $grav['uri'];
+ $url = $uri->rootUrl($include_host) . '/' . trim($route, '/') . $this->urlExtension();
+
+ // trim trailing / if not root
+ if ($url !== '/') {
+ $url = rtrim($url, '/');
+ }
+
+ return Uri::filterPath($url);
+ }
+
+ /**
+ * Gets the route for the page based on the route headers if available, else from
+ * the parents route and the current Page's slug.
+ *
+ * @param string $var Set new default route.
+ *
+ * @return string The route for the Page.
+ */
+ public function route($var = null)
+ {
+ if ($var !== null) {
+ $this->route = $var;
+ }
+
+ if (empty($this->route)) {
+ $baseRoute = null;
+
+ // calculate route based on parent slugs
+ $parent = $this->parent();
+ if (isset($parent)) {
+ if ($this->hide_home_route && $parent->route() === $this->home_route) {
+ $baseRoute = '';
+ } else {
+ $baseRoute = (string)$parent->route();
+ }
+ }
+
+ $this->route = isset($baseRoute) ? $baseRoute . '/' . $this->slug() : null;
+
+ if (!empty($this->routes) && isset($this->routes['default'])) {
+ $this->routes['aliases'][] = $this->route;
+ $this->route = $this->routes['default'];
+
+ return $this->route;
+ }
+ }
+
+ return $this->route;
+ }
+
+ /**
+ * Helper method to clear the route out so it regenerates next time you use it
+ */
+ public function unsetRouteSlug()
+ {
+ unset($this->route, $this->slug);
+ }
+
+ /**
+ * Gets and Sets the page raw route
+ *
+ * @param null $var
+ *
+ * @return null|string
+ */
+ public function rawRoute($var = null)
+ {
+ if ($var !== null) {
+ $this->raw_route = $var;
+ }
+
+ if (empty($this->raw_route)) {
+ $parent = $this->parent();
+ $baseRoute = $parent ? (string)$parent->rawRoute() : null;
+
+ $slug = $this->adjustRouteCase(preg_replace(PAGE_ORDER_PREFIX_REGEX, '', $this->folder));
+
+ $this->raw_route = isset($baseRoute) ? $baseRoute . '/' . $slug : null;
+ }
+
+ return $this->raw_route;
+ }
+
+ /**
+ * Gets the route aliases for the page based on page headers.
+ *
+ * @param array $var list of route aliases
+ *
+ * @return array The route aliases for the Page.
+ */
+ public function routeAliases($var = null)
+ {
+ if ($var !== null) {
+ $this->routes['aliases'] = (array)$var;
+ }
+
+ if (!empty($this->routes) && isset($this->routes['aliases'])) {
+ return $this->routes['aliases'];
+ }
+
+ return [];
+ }
+
+ /**
+ * Gets the canonical route for this page if its set. If provided it will use
+ * that value, else if it's `true` it will use the default route.
+ *
+ * @param null $var
+ *
+ * @return bool|string
+ */
+ public function routeCanonical($var = null)
+ {
+ if ($var !== null) {
+ $this->routes['canonical'] = $var;
+ }
+
+ if (!empty($this->routes) && isset($this->routes['canonical'])) {
+ return $this->routes['canonical'];
+ }
+
+ return $this->route();
+ }
+
+ /**
+ * Gets and sets the identifier for this Page object.
+ *
+ * @param string $var the identifier
+ *
+ * @return string the identifier
+ */
+ public function id($var = null)
+ {
+ if (null === $this->id) {
+ // We need to set unique id to avoid potential cache conflicts between pages.
+ $var = time() . md5($this->filePath());
+ }
+ if ($var !== null) {
+ // store unique per language
+ $active_lang = Grav::instance()['language']->getLanguage() ?: '';
+ $id = $active_lang . $var;
+ $this->id = $id;
+ }
+
+ return $this->id;
+ }
+
+ /**
+ * Gets and sets the modified timestamp.
+ *
+ * @param int $var modified unix timestamp
+ *
+ * @return int modified unix timestamp
+ */
+ public function modified($var = null)
+ {
+ if ($var !== null) {
+ $this->modified = $var;
+ }
+
+ return $this->modified;
+ }
+
+ /**
+ * Gets the redirect set in the header.
+ *
+ * @param string $var redirect url
+ *
+ * @return string
+ */
+ public function redirect($var = null)
+ {
+ if ($var !== null) {
+ $this->redirect = $var;
+ }
+
+ return $this->redirect;
+ }
+
+ /**
+ * Gets and sets the option to show the etag header for the page.
+ *
+ * @param bool $var show etag header
+ *
+ * @return bool show etag header
+ */
+ public function eTag($var = null)
+ {
+ if ($var !== null) {
+ $this->etag = $var;
+ }
+ if (!isset($this->etag)) {
+ $this->etag = (bool)Grav::instance()['config']->get('system.pages.etag');
+ }
+
+ return $this->etag;
+ }
+
+ /**
+ * Gets and sets the option to show the last_modified header for the page.
+ *
+ * @param bool $var show last_modified header
+ *
+ * @return bool show last_modified header
+ */
+ public function lastModified($var = null)
+ {
+ if ($var !== null) {
+ $this->last_modified = $var;
+ }
+ if (!isset($this->last_modified)) {
+ $this->last_modified = (bool)Grav::instance()['config']->get('system.pages.last_modified');
+ }
+
+ return $this->last_modified;
+ }
+
+ /**
+ * Gets and sets the path to the .md file for this Page object.
+ *
+ * @param string $var the file path
+ *
+ * @return string|null the file path
+ */
+ public function filePath($var = null)
+ {
+ if ($var !== null) {
+ // Filename of the page.
+ $this->name = basename($var);
+ // Folder of the page.
+ $this->folder = basename(dirname($var));
+ // Path to the page.
+ $this->path = dirname($var, 2);
+ }
+
+ return $this->path . '/' . $this->folder . '/' . ($this->name ?: '');
+ }
+
+ /**
+ * Gets the relative path to the .md file
+ *
+ * @return string The relative file path
+ */
+ public function filePathClean()
+ {
+ return str_replace(ROOT_DIR, '', $this->filePath());
+ }
+
+ /**
+ * Returns the clean path to the page file
+ */
+ public function relativePagePath()
+ {
+ return str_replace('/' . $this->name(), '', $this->filePathClean());
+ }
+
+ /**
+ * Gets and sets the path to the folder where the .md for this Page object resides.
+ * This is equivalent to the filePath but without the filename.
+ *
+ * @param string $var the path
+ *
+ * @return string|null the path
+ */
+ public function path($var = null)
+ {
+ if ($var !== null) {
+ // Folder of the page.
+ $this->folder = basename($var);
+ // Path to the page.
+ $this->path = dirname($var);
+ }
+
+ return $this->path ? $this->path . '/' . $this->folder : null;
+ }
+
+ /**
+ * Get/set the folder.
+ *
+ * @param string $var Optional path
+ *
+ * @return string|null
+ */
+ public function folder($var = null)
+ {
+ if ($var !== null) {
+ $this->folder = $var;
+ }
+
+ return $this->folder;
+ }
+
+ /**
+ * Gets and sets the date for this Page object. This is typically passed in via the page headers
+ *
+ * @param string $var string representation of a date
+ *
+ * @return int unix timestamp representation of the date
+ */
+ public function date($var = null)
+ {
+ if ($var !== null) {
+ $this->date = Utils::date2timestamp($var, $this->dateformat);
+ }
+
+ if (!$this->date) {
+ $this->date = $this->modified;
+ }
+
+ return $this->date;
+ }
+
+ /**
+ * Gets and sets the date format for this Page object. This is typically passed in via the page headers
+ * using typical PHP date string structure - http://php.net/manual/en/function.date.php
+ *
+ * @param string $var string representation of a date format
+ *
+ * @return string string representation of a date format
+ */
+ public function dateformat($var = null)
+ {
+ if ($var !== null) {
+ $this->dateformat = $var;
+ }
+
+ return $this->dateformat;
+ }
+
+ /**
+ * Gets and sets the order by which any sub-pages should be sorted.
+ *
+ * @param string $var the order, either "asc" or "desc"
+ *
+ * @return string the order, either "asc" or "desc"
+ * @deprecated 1.6
+ */
+ public function orderDir($var = null)
+ {
+ //user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);
+
+ if ($var !== null) {
+ $this->order_dir = $var;
+ }
+
+ if (empty($this->order_dir)) {
+ $this->order_dir = 'asc';
+ }
+
+ return $this->order_dir;
+ }
+
+ /**
+ * Gets and sets the order by which the sub-pages should be sorted.
+ *
+ * default - is the order based on the file system, ie 01.Home before 02.Advark
+ * title - is the order based on the title set in the pages
+ * date - is the order based on the date set in the pages
+ * folder - is the order based on the name of the folder with any numerics omitted
+ *
+ * @param string $var supported options include "default", "title", "date", and "folder"
+ *
+ * @return string supported options include "default", "title", "date", and "folder"
+ * @deprecated 1.6
+ */
+ public function orderBy($var = null)
+ {
+ //user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);
+
+ if ($var !== null) {
+ $this->order_by = $var;
+ }
+
+ return $this->order_by;
+ }
+
+ /**
+ * Gets the manual order set in the header.
+ *
+ * @param string $var supported options include "default", "title", "date", and "folder"
+ *
+ * @return array
+ * @deprecated 1.6
+ */
+ public function orderManual($var = null)
+ {
+ //user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);
+
+ if ($var !== null) {
+ $this->order_manual = $var;
+ }
+
+ return (array)$this->order_manual;
+ }
+
+ /**
+ * Gets and sets the maxCount field which describes how many sub-pages should be displayed if the
+ * sub_pages header property is set for this page object.
+ *
+ * @param int $var the maximum number of sub-pages
+ *
+ * @return int the maximum number of sub-pages
+ * @deprecated 1.6
+ */
+ public function maxCount($var = null)
+ {
+ //user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);
+
+ if ($var !== null) {
+ $this->max_count = (int)$var;
+ }
+ if (empty($this->max_count)) {
+ /** @var Config $config */
+ $config = Grav::instance()['config'];
+ $this->max_count = (int)$config->get('system.pages.list.count');
+ }
+
+ return $this->max_count;
+ }
+
+ /**
+ * Gets and sets the taxonomy array which defines which taxonomies this page identifies itself with.
+ *
+ * @param array $var an array of taxonomies
+ *
+ * @return array an array of taxonomies
+ */
+ public function taxonomy($var = null)
+ {
+ if ($var !== null) {
+ // make sure first level are arrays
+ array_walk($var, function(&$value) {
+ $value = (array) $value;
+ });
+ // make sure all values are strings
+ array_walk_recursive($var, function(&$value) {
+ $value = (string) $value;
+ });
+ $this->taxonomy = $var;
+ }
+
+ return $this->taxonomy;
+ }
+
+ /**
+ * Gets and sets the modular var that helps identify this page is a modular child
+ *
+ * @param bool $var true if modular_twig
+ *
+ * @return bool true if modular_twig
+ */
+ public function modular($var = null)
+ {
+ return $this->modularTwig($var);
+ }
+
+ /**
+ * Gets and sets the modular_twig var that helps identify this page as a modular child page that will need
+ * twig processing handled differently from a regular page.
+ *
+ * @param bool $var true if modular_twig
+ *
+ * @return bool true if modular_twig
+ */
+ public function modularTwig($var = null)
+ {
+ if ($var !== null) {
+ $this->modular_twig = (bool)$var;
+ if ($var) {
+ $this->visible(false);
+ // some routable logic
+ if (empty($this->header->routable)) {
+ $this->routable = false;
+ }
+ }
+ }
+
+ return $this->modular_twig;
+ }
+
+ /**
+ * Gets the configured state of the processing method.
+ *
+ * @param string $process the process, eg "twig" or "markdown"
+ *
+ * @return bool whether or not the processing method is enabled for this Page
+ */
+ public function shouldProcess($process)
+ {
+ return (bool)($this->process[$process] ?? false);
+ }
+
+ /**
+ * Gets and Sets the parent object for this page
+ *
+ * @param PageInterface $var the parent page object
+ *
+ * @return PageInterface|null the parent page object if it exists.
+ */
+ public function parent(PageInterface $var = null)
+ {
+ if ($var) {
+ $this->parent = $var->path();
+
+ return $var;
+ }
+
+ /** @var Pages $pages */
+ $pages = Grav::instance()['pages'];
+
+ return $pages->get($this->parent);
+ }
+
+ /**
+ * Gets the top parent object for this page
+ *
+ * @return PageInterface|null the top parent page object if it exists.
+ */
+ public function topParent()
+ {
+ $topParent = $this->parent();
+
+ if (!$topParent) {
+ return null;
+ }
+
+ while (true) {
+ $theParent = $topParent->parent();
+ if ($theParent !== null && $theParent->parent() !== null) {
+ $topParent = $theParent;
+ } else {
+ break;
+ }
+ }
+
+ return $topParent;
+ }
+
+ /**
+ * Returns children of this page.
+ *
+ * @return Collection
+ */
+ public function children()
+ {
+ /** @var Pages $pages */
+ $pages = Grav::instance()['pages'];
+
+ return $pages->children($this->path());
+ }
+
+
+ /**
+ * Check to see if this item is the first in an array of sub-pages.
+ *
+ * @return bool True if item is first.
+ */
+ public function isFirst()
+ {
+ $parent = $this->parent();
+ $collection = $parent ? $parent->collection('content', false) : null;
+ if ($collection instanceof Collection) {
+ return $collection->isFirst($this->path());
+ }
+
+ return true;
+ }
+
+ /**
+ * Check to see if this item is the last in an array of sub-pages.
+ *
+ * @return bool True if item is last
+ */
+ public function isLast()
+ {
+ $parent = $this->parent();
+ $collection = $parent ? $parent->collection('content', false) : null;
+ if ($collection instanceof Collection) {
+ return $collection->isLast($this->path());
+ }
+
+ return true;
+ }
+
+ /**
+ * Gets the previous sibling based on current position.
+ *
+ * @return PageInterface the previous Page item
+ */
+ public function prevSibling()
+ {
+ return $this->adjacentSibling(-1);
+ }
+
+ /**
+ * Gets the next sibling based on current position.
+ *
+ * @return PageInterface the next Page item
+ */
+ public function nextSibling()
+ {
+ return $this->adjacentSibling(1);
+ }
+
+ /**
+ * Returns the adjacent sibling based on a direction.
+ *
+ * @param int $direction either -1 or +1
+ *
+ * @return PageInterface|bool the sibling page
+ */
+ public function adjacentSibling($direction = 1)
+ {
+ $parent = $this->parent();
+ $collection = $parent ? $parent->collection('content', false) : null;
+ if ($collection instanceof Collection) {
+ return $collection->adjacentSibling($this->path(), $direction);
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns the item in the current position.
+ *
+ * @return int the index of the current page.
+ */
+ public function currentPosition()
+ {
+ $parent = $this->parent();
+ $collection = $parent ? $parent->collection('content', false) : null;
+ if ($collection instanceof Collection) {
+ return $collection->currentPosition($this->path());
+ }
+
+ return 1;
+ }
+
+ /**
+ * Returns whether or not this page is the currently active page requested via the URL.
+ *
+ * @return bool True if it is active
+ */
+ public function active()
+ {
+ $uri_path = rtrim(urldecode(Grav::instance()['uri']->path()), '/') ?: '/';
+ $routes = Grav::instance()['pages']->routes();
+
+ return isset($routes[$uri_path]) && $routes[$uri_path] === $this->path();
+ }
+
+ /**
+ * Returns whether or not this URI's URL contains the URL of the active page.
+ * Or in other words, is this page's URL in the current URL
+ *
+ * @return bool True if active child exists
+ */
+ public function activeChild()
+ {
+ $uri = Grav::instance()['uri'];
+ $pages = Grav::instance()['pages'];
+ $uri_path = rtrim(urldecode($uri->path()), '/');
+ $routes = Grav::instance()['pages']->routes();
+
+ if (isset($routes[$uri_path])) {
+ /** @var PageInterface $child_page */
+ $child_page = $pages->dispatch($uri->route())->parent();
+ if ($child_page) {
+ while (!$child_page->root()) {
+ if ($this->path() === $child_page->path()) {
+ return true;
+ }
+ $child_page = $child_page->parent();
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns whether or not this page is the currently configured home page.
+ *
+ * @return bool True if it is the homepage
+ */
+ public function home()
+ {
+ $home = Grav::instance()['config']->get('system.home.alias');
+
+ return $this->route() === $home || $this->rawRoute() === $home;
+ }
+
+ /**
+ * Returns whether or not this page is the root node of the pages tree.
+ *
+ * @return bool True if it is the root
+ */
+ public function root()
+ {
+ return !$this->parent && !$this->name && !$this->visible;
+ }
+
+ /**
+ * Helper method to return an ancestor page.
+ *
+ * @param bool $lookup Name of the parent folder
+ *
+ * @return PageInterface page you were looking for if it exists
+ */
+ public function ancestor($lookup = null)
+ {
+ /** @var Pages $pages */
+ $pages = Grav::instance()['pages'];
+
+ return $pages->ancestor($this->route, $lookup);
+ }
+
+ /**
+ * Helper method to return an ancestor page to inherit from. The current
+ * page object is returned.
+ *
+ * @param string $field Name of the parent folder
+ *
+ * @return PageInterface
+ */
+ public function inherited($field)
+ {
+ list($inherited, $currentParams) = $this->getInheritedParams($field);
+
+ $this->modifyHeader($field, $currentParams);
+
+ return $inherited;
+ }
+
+ /**
+ * Helper method to return an ancestor field only to inherit from. The
+ * first occurrence of an ancestor field will be returned if at all.
+ *
+ * @param string $field Name of the parent folder
+ *
+ * @return array
+ */
+ public function inheritedField($field)
+ {
+ list($inherited, $currentParams) = $this->getInheritedParams($field);
+
+ return $currentParams;
+ }
+
+ /**
+ * Method that contains shared logic for inherited() and inheritedField()
+ *
+ * @param string $field Name of the parent folder
+ *
+ * @return array
+ */
+ protected function getInheritedParams($field)
+ {
+ $pages = Grav::instance()['pages'];
+
+ /** @var Pages $pages */
+ $inherited = $pages->inherited($this->route, $field);
+ $inheritedParams = $inherited ? (array)$inherited->value('header.' . $field) : [];
+ $currentParams = (array)$this->value('header.' . $field);
+ if ($inheritedParams && is_array($inheritedParams)) {
+ $currentParams = array_replace_recursive($inheritedParams, $currentParams);
+ }
+
+ return [$inherited, $currentParams];
+ }
+
+ /**
+ * Helper method to return a page.
+ *
+ * @param string $url the url of the page
+ * @param bool $all
+ *
+ * @return PageInterface page you were looking for if it exists
+ */
+ public function find($url, $all = false)
+ {
+ /** @var Pages $pages */
+ $pages = Grav::instance()['pages'];
+
+ return $pages->find($url, $all);
+ }
+
+ /**
+ * Get a collection of pages in the current context.
+ *
+ * @param string|array $params
+ * @param bool $pagination
+ *
+ * @return Collection
+ * @throws \InvalidArgumentException
+ */
+ public function collection($params = 'content', $pagination = true)
+ {
+ if (is_string($params)) {
+ $params = (array)$this->value('header.' . $params);
+ } elseif (!is_array($params)) {
+ throw new \InvalidArgumentException('Argument should be either header variable name or array of parameters');
+ }
+
+ if (!isset($params['items'])) {
+ return new Collection();
+ }
+
+ // See if require published filter is set and use that, if assume published=true
+ $only_published = true;
+ if (isset($params['filter']['published']) && $params['filter']['published']) {
+ $only_published = false;
+ } elseif (isset($params['filter']['non-published']) && $params['filter']['non-published']) {
+ $only_published = false;
+ }
+
+ $collection = $this->evaluate($params['items'], $only_published);
+ if (!$collection instanceof Collection) {
+ $collection = new Collection();
+ }
+ $collection->setParams($params);
+
+ /** @var Uri $uri */
+ $uri = Grav::instance()['uri'];
+ /** @var Config $config */
+ $config = Grav::instance()['config'];
+
+ $process_taxonomy = $params['url_taxonomy_filters'] ?? $config->get('system.pages.url_taxonomy_filters');
+
+ if ($process_taxonomy) {
+ foreach ((array)$config->get('site.taxonomies') as $taxonomy) {
+ if ($uri->param(rawurlencode($taxonomy))) {
+ $items = explode(',', $uri->param($taxonomy));
+ $collection->setParams(['taxonomies' => [$taxonomy => $items]]);
+
+ foreach ($collection as $page) {
+ // Don't filter modular pages
+ if ($page->modular()) {
+ continue;
+ }
+ foreach ($items as $item) {
+ $item = rawurldecode($item);
+ if (empty($page->taxonomy[$taxonomy]) || !\in_array(htmlspecialchars_decode($item, ENT_QUOTES), $page->taxonomy[$taxonomy], true)
+ ) {
+ $collection->remove($page->path());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // If a filter or filters are set, filter the collection...
+ if (isset($params['filter'])) {
+
+ // remove any inclusive sets from filer:
+ $sets = ['published', 'visible', 'modular', 'routable'];
+ foreach ($sets as $type) {
+ $var = "non-{$type}";
+ if (isset($params['filter'][$type], $params['filter'][$var]) && $params['filter'][$type] && $params['filter'][$var]) {
+ unset ($params['filter'][$type], $params['filter'][$var]);
+ }
+ }
+
+ foreach ((array)$params['filter'] as $type => $filter) {
+ switch ($type) {
+ case 'published':
+ if ((bool) $filter) {
+ $collection->published();
+ }
+ break;
+ case 'non-published':
+ if ((bool) $filter) {
+ $collection->nonPublished();
+ }
+ break;
+ case 'visible':
+ if ((bool) $filter) {
+ $collection->visible();
+ }
+ break;
+ case 'non-visible':
+ if ((bool) $filter) {
+ $collection->nonVisible();
+ }
+ break;
+ case 'modular':
+ if ((bool) $filter) {
+ $collection->modular();
+ }
+ break;
+ case 'non-modular':
+ if ((bool) $filter) {
+ $collection->nonModular();
+ }
+ break;
+ case 'routable':
+ if ((bool) $filter) {
+ $collection->routable();
+ }
+ break;
+ case 'non-routable':
+ if ((bool) $filter) {
+ $collection->nonRoutable();
+ }
+ break;
+ case 'type':
+ $collection->ofType($filter);
+ break;
+ case 'types':
+ $collection->ofOneOfTheseTypes($filter);
+ break;
+ case 'access':
+ $collection->ofOneOfTheseAccessLevels($filter);
+ break;
+ }
+ }
+ }
+
+ if (isset($params['dateRange'])) {
+ $start = $params['dateRange']['start'] ?? 0;
+ $end = $params['dateRange']['end'] ?? false;
+ $field = $params['dateRange']['field'] ?? false;
+ $collection->dateRange($start, $end, $field);
+ }
+
+ if (isset($params['order'])) {
+ $by = $params['order']['by'] ?? 'default';
+ $dir = $params['order']['dir'] ?? 'asc';
+ $custom = $params['order']['custom'] ?? null;
+ $sort_flags = $params['order']['sort_flags'] ?? null;
+
+ if (is_array($sort_flags)) {
+ $sort_flags = array_map('constant', $sort_flags); //transform strings to constant value
+ $sort_flags = array_reduce($sort_flags, function ($a, $b) {
+ return $a | $b;
+ }, 0); //merge constant values using bit or
+ }
+
+ $collection->order($by, $dir, $custom, $sort_flags);
+ }
+
+ /** @var Grav $grav */
+ $grav = Grav::instance();
+
+ // New Custom event to handle things like pagination.
+ $grav->fireEvent('onCollectionProcessed', new Event(['collection' => $collection]));
+
+ // Slice and dice the collection if pagination is required
+ if ($pagination) {
+ $params = $collection->params();
+
+ $limit = (int)($params['limit'] ?? 0);
+ $start = !empty($params['pagination']) ? ($uri->currentPage() - 1) * $limit : 0;
+
+ if ($limit && $collection->count() > $limit) {
+ $collection->slice($start, $limit);
+ }
+ }
+
+ return $collection;
+ }
+
+ /**
+ * @param string|array $value
+ * @param bool $only_published
+ * @return mixed
+ */
+ public function evaluate($value, $only_published = true)
+ {
+ // Parse command.
+ if (is_string($value)) {
+ // Format: @command.param
+ $cmd = $value;
+ $params = [];
+ } elseif (is_array($value) && count($value) == 1 && !is_int(key($value))) {
+ // Format: @command.param: { attr1: value1, attr2: value2 }
+ $cmd = (string)key($value);
+ $params = (array)current($value);
+ } else {
+ $result = [];
+ foreach ((array)$value as $key => $val) {
+ if (is_int($key)) {
+ $result = $result + $this->evaluate($val, $only_published)->toArray();
+ } else {
+ $result = $result + $this->evaluate([$key => $val], $only_published)->toArray();
+ }
+
+ }
+
+ return new Collection($result);
+ }
+
+ /** @var Pages $pages */
+ $pages = Grav::instance()['pages'];
+
+ $parts = explode('.', $cmd);
+ $current = array_shift($parts);
+
+ /** @var Collection $results */
+ $results = new Collection();
+
+ switch ($current) {
+ case 'self@':
+ case '@self':
+ if (!empty($parts)) {
+ switch ($parts[0]) {
+ case 'modular':
+ // @self.modular: false (alternative to @self.children)
+ if (!empty($params) && $params[0] === false) {
+ $results = $this->children()->nonModular();
+ break;
+ }
+ $results = $this->children()->modular();
+ break;
+ case 'children':
+ $results = $this->children()->nonModular();
+ break;
+ case 'all':
+ $results = $this->children();
+ break;
+ case 'parent':
+ $collection = new Collection();
+ $results = $collection->addPage($this->parent());
+ break;
+ case 'siblings':
+ if (!$this->parent()) {
+ return new Collection();
+ }
+ $results = $this->parent()->children()->remove($this->path());
+ break;
+ case 'descendants':
+ $results = $pages->all($this)->remove($this->path())->nonModular();
+ break;
+ }
+ }
+
+
+ break;
+
+ case 'page@':
+ case '@page':
+ $page = null;
+
+ if (!empty($params)) {
+ $page = $this->find($params[0]);
+ }
+
+ // safety check in case page is not found
+ if (!isset($page)) {
+ return $results;
+ }
+
+ // Handle a @page.descendants
+ if (!empty($parts)) {
+ switch ($parts[0]) {
+ case 'modular':
+ $results = new Collection();
+ foreach ($page->children() as $child) {
+ $results = $results->addPage($child);
+ }
+ $results->modular();
+ break;
+ case 'page':
+ case 'self':
+ $results = new Collection();
+ $results = $results->addPage($page);
+ break;
+
+ case 'descendants':
+ $results = $pages->all($page)->remove($page->path())->nonModular();
+ break;
+
+ case 'children':
+ $results = $page->children()->nonModular();
+ break;
+ }
+ } else {
+ $results = $page->children()->nonModular();
+ }
+
+ break;
+
+ case 'root@':
+ case '@root':
+ if (!empty($parts) && $parts[0] === 'descendants') {
+ $results = $pages->all($pages->root())->nonModular();
+ } else {
+ $results = $pages->root()->children()->nonModular();
+ }
+ break;
+
+ case 'taxonomy@':
+ case '@taxonomy':
+ // Gets a collection of pages by using one of the following formats:
+ // @taxonomy.category: blog
+ // @taxonomy.category: [ blog, featured ]
+ // @taxonomy: { category: [ blog, featured ], level: 1 }
+
+ /** @var Taxonomy $taxonomy_map */
+ $taxonomy_map = Grav::instance()['taxonomy'];
+
+ if (!empty($parts)) {
+ $params = [implode('.', $parts) => $params];
+ }
+ $results = $taxonomy_map->findTaxonomy($params);
+ break;
+ }
+
+ if ($only_published) {
+ $results = $results->published();
+ }
+
+ return $results;
+ }
+
+ /**
+ * Returns whether or not this Page object has a .md file associated with it or if its just a directory.
+ *
+ * @return bool True if its a page with a .md file associated
+ */
+ public function isPage()
+ {
+ if ($this->name) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns whether or not this Page object is a directory or a page.
+ *
+ * @return bool True if its a directory
+ */
+ public function isDir()
+ {
+ return !$this->isPage();
+ }
+
+ /**
+ * Returns whether the page exists in the filesystem.
+ *
+ * @return bool
+ */
+ public function exists()
+ {
+ $file = $this->file();
+
+ return $file && $file->exists();
+ }
+
+ /**
+ * Returns whether or not the current folder exists
+ *
+ * @return bool
+ */
+ public function folderExists()
+ {
+ return file_exists($this->path());
+ }
+
+ /**
+ * Cleans the path.
+ *
+ * @param string $path the path
+ *
+ * @return string the path
+ */
+ protected function cleanPath($path)
+ {
+ $lastchunk = strrchr($path, DS);
+ if (strpos($lastchunk, ':') !== false) {
+ $path = str_replace($lastchunk, '', $path);
+ }
+
+ return $path;
+ }
+
+ /**
+ * Reorders all siblings according to a defined order
+ *
+ * @param array|null $new_order
+ */
+ protected function doReorder($new_order)
+ {
+ if (!$this->_original) {
+ return;
+ }
+
+ $pages = Grav::instance()['pages'];
+ $pages->init();
+
+ $this->_original->path($this->path());
+
+ $parent = $this->parent();
+ $siblings = $parent ? $parent->children() : null;
+
+ if ($siblings) {
+ $siblings->order('slug', 'asc', $new_order);
+
+ $counter = 0;
+
+ // Reorder all moved pages.
+ foreach ($siblings as $slug => $page) {
+ $order = (int)trim($page->order(), '.');
+ $counter++;
+
+ if ($order) {
+ if ($page->path() === $this->path() && $this->folderExists()) {
+ // Handle current page; we do want to change ordering number, but nothing else.
+ $this->order($counter);
+ $this->save(false);
+ } else {
+ // Handle all the other pages.
+ $page = $pages->get($page->path());
+ if ($page && $page->folderExists() && !$page->_action) {
+ $page = $page->move($this->parent());
+ $page->order($counter);
+ $page->save(false);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Moves or copies the page in filesystem.
+ *
+ * @internal
+ *
+ * @throws \Exception
+ */
+ protected function doRelocation()
+ {
+ if (!$this->_original) {
+ return;
+ }
+
+ if (is_dir($this->_original->path())) {
+ if ($this->_action === 'move') {
+ Folder::move($this->_original->path(), $this->path());
+ } elseif ($this->_action === 'copy') {
+ Folder::copy($this->_original->path(), $this->path());
+ }
+ }
+
+ if ($this->name() !== $this->_original->name()) {
+ $path = $this->path();
+ if (is_file($path . '/' . $this->_original->name())) {
+ rename($path . '/' . $this->_original->name(), $path . '/' . $this->name());
+ }
+ }
+
+ }
+
+ protected function setPublishState()
+ {
+ // Handle publishing dates if no explicit published option set
+ if (Grav::instance()['config']->get('system.pages.publish_dates') && !isset($this->header->published)) {
+ // unpublish if required, if not clear cache right before page should be unpublished
+ if ($this->unpublishDate()) {
+ if ($this->unpublishDate() < time()) {
+ $this->published(false);
+ } else {
+ $this->published();
+ Grav::instance()['cache']->setLifeTime($this->unpublishDate());
+ }
+ }
+ // publish if required, if not clear cache right before page is published
+ if ($this->publishDate() && $this->publishDate() > time()) {
+ $this->published(false);
+ Grav::instance()['cache']->setLifeTime($this->publishDate());
+ }
+ }
+ }
+
+ protected function adjustRouteCase($route)
+ {
+ $case_insensitive = Grav::instance()['config']->get('system.force_lowercase_urls');
+
+ return $case_insensitive ? mb_strtolower($route) : $route;
+ }
+
+ /**
+ * Gets the Page Unmodified (original) version of the page.
+ *
+ * @return PageInterface The original version of the page.
+ */
+ public function getOriginal()
+ {
+ return $this->_original;
+ }
+
+ /**
+ * Gets the action.
+ *
+ * @return string The Action string.
+ */
+ public function getAction()
+ {
+ return $this->_action;
+ }
+}
diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php
new file mode 100644
index 0000000..513a7ba
--- /dev/null
+++ b/system/src/Grav/Common/Page/Pages.php
@@ -0,0 +1,1443 @@
+grav = $c;
+ }
+
+ /**
+ * Get or set base path for the pages.
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+ public function base($path = null)
+ {
+ if ($path !== null) {
+ $path = trim($path, '/');
+ $this->base = $path ? '/' . $path : null;
+ $this->baseRoute = [];
+ }
+
+ return $this->base;
+ }
+
+ /**
+ *
+ * Get base route for Grav pages.
+ *
+ * @param string $lang Optional language code for multilingual routes.
+ *
+ * @return string
+ */
+ public function baseRoute($lang = null)
+ {
+ $key = $lang ?: $this->active_lang ?: 'default';
+
+ if (!isset($this->baseRoute[$key])) {
+ /** @var Language $language */
+ $language = $this->grav['language'];
+
+ $path_base = rtrim($this->base(), '/');
+ $path_lang = $language->enabled() ? $language->getLanguageURLPrefix($lang) : '';
+
+ $this->baseRoute[$key] = $path_base . $path_lang;
+ }
+
+ return $this->baseRoute[$key];
+ }
+
+ /**
+ *
+ * Get route for Grav site.
+ *
+ * @param string $route Optional route to the page.
+ * @param string $lang Optional language code for multilingual links.
+ *
+ * @return string
+ */
+ public function route($route = '/', $lang = null)
+ {
+ if (!$route || $route === '/') {
+ return $this->baseRoute($lang) ?: '/';
+ }
+
+ return $this->baseRoute($lang) . $route;
+ }
+
+ /**
+ *
+ * Get base URL for Grav pages.
+ *
+ * @param string $lang Optional language code for multilingual links.
+ * @param bool|null $absolute If true, return absolute url, if false, return relative url. Otherwise return default.
+ *
+ * @return string
+ */
+ public function baseUrl($lang = null, $absolute = null)
+ {
+ if ($absolute === null) {
+ $type = 'base_url';
+ } elseif ($absolute) {
+ $type = 'base_url_absolute';
+ } else {
+ $type = 'base_url_relative';
+ }
+
+ return $this->grav[$type] . $this->baseRoute($lang);
+ }
+
+ /**
+ *
+ * Get home URL for Grav site.
+ *
+ * @param string $lang Optional language code for multilingual links.
+ * @param bool $absolute If true, return absolute url, if false, return relative url. Otherwise return default.
+ *
+ * @return string
+ */
+ public function homeUrl($lang = null, $absolute = null)
+ {
+ return $this->baseUrl($lang, $absolute) ?: '/';
+ }
+
+ /**
+ *
+ * Get URL for Grav site.
+ *
+ * @param string $route Optional route to the page.
+ * @param string $lang Optional language code for multilingual links.
+ * @param bool $absolute If true, return absolute url, if false, return relative url. Otherwise return default.
+ *
+ * @return string
+ */
+ public function url($route = '/', $lang = null, $absolute = null)
+ {
+ if (!$route || $route === '/') {
+ return $this->homeUrl($lang, $absolute);
+ }
+
+ return $this->baseUrl($lang, $absolute) . Uri::filterPath($route);
+ }
+
+ public function setCheckMethod($method)
+ {
+ $this->check_method = strtolower($method);
+ }
+
+ /**
+ * Reset pages (used in search indexing etc).
+ */
+ public function reset()
+ {
+ $this->initialized = false;
+
+ $this->init();
+ }
+
+ /**
+ * Class initialization. Must be called before using this class.
+ */
+ public function init()
+ {
+ if ($this->initialized) {
+ return;
+ }
+
+ $config = $this->grav['config'];
+ $this->ignore_files = $config->get('system.pages.ignore_files');
+ $this->ignore_folders = $config->get('system.pages.ignore_folders');
+ $this->ignore_hidden = $config->get('system.pages.ignore_hidden');
+
+ $this->instances = [];
+ $this->children = [];
+ $this->routes = [];
+
+ if (!$this->check_method) {
+ $this->setCheckMethod($config->get('system.cache.check.method', 'file'));
+ }
+
+ $this->buildPages();
+ }
+
+ /**
+ * Get or set last modification time.
+ *
+ * @param int $modified
+ *
+ * @return int|null
+ */
+ public function lastModified($modified = null)
+ {
+ if ($modified && $modified > $this->last_modified) {
+ $this->last_modified = $modified;
+ }
+
+ return $this->last_modified;
+ }
+
+ /**
+ * Returns a list of all pages.
+ *
+ * @return array|PageInterface[]
+ */
+ public function instances()
+ {
+ return $this->instances;
+ }
+
+ /**
+ * Returns a list of all routes.
+ *
+ * @return array
+ */
+ public function routes()
+ {
+ return $this->routes;
+ }
+
+ /**
+ * Adds a page and assigns a route to it.
+ *
+ * @param PageInterface $page Page to be added.
+ * @param string $route Optional route (uses route from the object if not set).
+ */
+ public function addPage(PageInterface $page, $route = null)
+ {
+ if (!isset($this->instances[$page->path()])) {
+ $this->instances[$page->path()] = $page;
+ }
+ $route = $page->route($route);
+ if ($page->parent()) {
+ $this->children[$page->parent()->path()][$page->path()] = ['slug' => $page->slug()];
+ }
+ $this->routes[$route] = $page->path();
+
+ $this->grav->fireEvent('onPageProcessed', new Event(['page' => $page]));
+ }
+
+ /**
+ * Sort sub-pages in a page.
+ *
+ * @param PageInterface $page
+ * @param string $order_by
+ * @param string $order_dir
+ *
+ * @return array
+ */
+ public function sort(PageInterface $page, $order_by = null, $order_dir = null, $sort_flags = null)
+ {
+ if ($order_by === null) {
+ $order_by = $page->orderBy();
+ }
+ if ($order_dir === null) {
+ $order_dir = $page->orderDir();
+ }
+
+ $path = $page->path();
+ $children = $this->children[$path] ?? [];
+
+ if (!$children) {
+ return $children;
+ }
+
+ if (!isset($this->sort[$path][$order_by])) {
+ $this->buildSort($path, $children, $order_by, $page->orderManual(), $sort_flags);
+ }
+
+ $sort = $this->sort[$path][$order_by];
+
+ if ($order_dir !== 'asc') {
+ $sort = array_reverse($sort);
+ }
+
+ return $sort;
+ }
+
+ /**
+ * @param Collection $collection
+ * @param string|int $orderBy
+ * @param string $orderDir
+ * @param array|null $orderManual
+ * @param int|null $sort_flags
+ *
+ * @return array
+ * @internal
+ */
+ public function sortCollection(Collection $collection, $orderBy, $orderDir = 'asc', $orderManual = null, $sort_flags = null)
+ {
+ $items = $collection->toArray();
+ if (!$items) {
+ return [];
+ }
+
+ $lookup = md5(json_encode($items) . json_encode($orderManual) . $orderBy . $orderDir);
+ if (!isset($this->sort[$lookup][$orderBy])) {
+ $this->buildSort($lookup, $items, $orderBy, $orderManual, $sort_flags);
+ }
+
+ $sort = $this->sort[$lookup][$orderBy];
+
+ if ($orderDir !== 'asc') {
+ $sort = array_reverse($sort);
+ }
+
+ return $sort;
+
+ }
+
+ /**
+ * Get a page instance.
+ *
+ * @param string $path The filesystem full path of the page
+ *
+ * @return PageInterface
+ * @throws \Exception
+ */
+ public function get($path)
+ {
+ return $this->instances[(string)$path] ?? null;
+ }
+
+ /**
+ * Get children of the path.
+ *
+ * @param string $path
+ *
+ * @return Collection
+ */
+ public function children($path)
+ {
+ $children = $this->children[(string)$path] ?? [];
+
+ return new Collection($children, [], $this);
+ }
+
+ /**
+ * Get a page ancestor.
+ *
+ * @param string $route The relative URL of the page
+ * @param string $path The relative path of the ancestor folder
+ *
+ * @return PageInterface|null
+ */
+ public function ancestor($route, $path = null)
+ {
+ if ($path !== null) {
+ $page = $this->dispatch($route, true);
+
+ if ($page && $page->path() === $path) {
+ return $page;
+ }
+
+ $parent = $page ? $page->parent() : null;
+ if ($parent && !$parent->root()) {
+ return $this->ancestor($parent->route(), $path);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Get a page ancestor trait.
+ *
+ * @param string $route The relative route of the page
+ * @param string $field The field name of the ancestor to query for
+ *
+ * @return PageInterface|null
+ */
+ public function inherited($route, $field = null)
+ {
+ if ($field !== null) {
+
+ $page = $this->dispatch($route, true);
+
+ $parent = $page ? $page->parent() : null;
+ if ($parent && $parent->value('header.' . $field) !== null) {
+ return $parent;
+ }
+ if ($parent && !$parent->root()) {
+ return $this->inherited($parent->route(), $field);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * alias method to return find a page.
+ *
+ * @param string $route The relative URL of the page
+ * @param bool $all
+ *
+ * @return PageInterface|null
+ */
+ public function find($route, $all = false)
+ {
+ return $this->dispatch($route, $all, false);
+ }
+
+ /**
+ * Dispatch URI to a page.
+ *
+ * @param string $route The relative URL of the page
+ * @param bool $all
+ *
+ * @param bool $redirect
+ * @return PageInterface|null
+ * @throws \Exception
+ */
+ public function dispatch($route, $all = false, $redirect = true)
+ {
+ $route = urldecode($route);
+
+ // Fetch page if there's a defined route to it.
+ $page = isset($this->routes[$route]) ? $this->get($this->routes[$route]) : null;
+ // Try without trailing slash
+ if (!$page && Utils::endsWith($route, '/')) {
+ $page = isset($this->routes[rtrim($route, '/')]) ? $this->get($this->routes[rtrim($route, '/')]) : null;
+ }
+
+ // Are we in the admin? this is important!
+ $not_admin = !isset($this->grav['admin']);
+
+ // If the page cannot be reached, look into site wide redirects, routes + wildcards
+ if (!$all && $not_admin) {
+
+ // If the page is a simple redirect, just do it.
+ if ($redirect && $page && $page->redirect()) {
+ $this->grav->redirectLangSafe($page->redirect());
+ }
+
+ // fall back and check site based redirects
+ if (!$page || ($page && !$page->routable())) {
+ /** @var Config $config */
+ $config = $this->grav['config'];
+
+ // See if route matches one in the site configuration
+ $site_route = $config->get("site.routes.{$route}");
+ if ($site_route) {
+ $page = $this->dispatch($site_route, $all);
+ } else {
+
+ /** @var Uri $uri */
+ $uri = $this->grav['uri'];
+ /** @var \Grav\Framework\Uri\Uri $source_url */
+ $source_url = $uri->uri(false);
+
+ // Try Regex style redirects
+ $site_redirects = $config->get('site.redirects');
+ if (is_array($site_redirects)) {
+ foreach ((array)$site_redirects as $pattern => $replace) {
+ $pattern = '#^' . str_replace('/', '\/', ltrim($pattern, '^')) . '#';
+ try {
+ $found = preg_replace($pattern, $replace, $source_url);
+ if ($found !== $source_url) {
+ $this->grav->redirectLangSafe($found);
+ }
+ } catch (ErrorException $e) {
+ $this->grav['log']->error('site.redirects: ' . $pattern . '-> ' . $e->getMessage());
+ }
+ }
+ }
+
+ // Try Regex style routes
+ $site_routes = $config->get('site.routes');
+ if (is_array($site_routes)) {
+ foreach ((array)$site_routes as $pattern => $replace) {
+ $pattern = '#^' . str_replace('/', '\/', ltrim($pattern, '^')) . '#';
+ try {
+ $found = preg_replace($pattern, $replace, $source_url);
+ if ($found !== $source_url) {
+ $page = $this->dispatch($found, $all);
+ }
+ } catch (ErrorException $e) {
+ $this->grav['log']->error('site.routes: ' . $pattern . '-> ' . $e->getMessage());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return $page;
+ }
+
+ /**
+ * Get root page.
+ *
+ * @return PageInterface
+ */
+ public function root()
+ {
+ /** @var UniformResourceLocator $locator */
+ $locator = $this->grav['locator'];
+
+ return $this->instances[rtrim($locator->findResource('page://'), DS)];
+ }
+
+ /**
+ * Get a blueprint for a page type.
+ *
+ * @param string $type
+ *
+ * @return Blueprint
+ */
+ public function blueprints($type)
+ {
+ if ($this->blueprints === null) {
+ $this->blueprints = new Blueprints(self::getTypes());
+ }
+
+ try {
+ $blueprint = $this->blueprints->get($type);
+ } catch (\RuntimeException $e) {
+ $blueprint = $this->blueprints->get('default');
+ }
+
+ if (empty($blueprint->initialized)) {
+ $blueprint->initialized = true;
+ $this->grav->fireEvent('onBlueprintCreated', new Event(['blueprint' => $blueprint, 'type' => $type]));
+ }
+
+ return $blueprint;
+ }
+
+ /**
+ * Get all pages
+ *
+ * @param PageInterface $current
+ *
+ * @return \Grav\Common\Page\Collection
+ */
+ public function all(PageInterface $current = null)
+ {
+ $all = new Collection();
+
+ /** @var PageInterface $current */
+ $current = $current ?: $this->root();
+
+ if (!$current->root()) {
+ $all[$current->path()] = ['slug' => $current->slug()];
+ }
+
+ foreach ($current->children() as $next) {
+ $all->append($this->all($next));
+ }
+
+ return $all;
+ }
+
+ /**
+ * Get available parents raw routes.
+ *
+ * @return array
+ */
+ public static function parentsRawRoutes()
+ {
+ $rawRoutes = true;
+
+ return self::getParents($rawRoutes);
+ }
+
+ /**
+ * Get available parents routes
+ *
+ * @param bool $rawRoutes get the raw route or the normal route
+ *
+ * @return array
+ */
+ private static function getParents($rawRoutes)
+ {
+ $grav = Grav::instance();
+
+ /** @var Pages $pages */
+ $pages = $grav['pages'];
+
+ $parents = $pages->getList(null, 0, $rawRoutes);
+
+ if (isset($grav['admin'])) {
+ // Remove current route from parents
+
+ /** @var Admin $admin */
+ $admin = $grav['admin'];
+
+ $page = $admin->getPage($admin->route);
+ $page_route = $page->route();
+ if (isset($parents[$page_route])) {
+ unset($parents[$page_route]);
+ }
+
+ }
+
+ return $parents;
+ }
+
+ /**
+ * Get list of route/title of all pages.
+ *
+ * @param PageInterface $current
+ * @param int $level
+ * @param bool $rawRoutes
+ *
+ * @param bool $showAll
+ * @param bool $showFullpath
+ * @param bool $showSlug
+ * @param bool $showModular
+ * @param bool $limitLevels
+ * @return array
+ */
+ public function getList(PageInterface $current = null, $level = 0, $rawRoutes = false, $showAll = true, $showFullpath = false, $showSlug = false, $showModular = false, $limitLevels = false)
+ {
+ if (!$current) {
+ if ($level) {
+ throw new \RuntimeException('Internal error');
+ }
+
+ $current = $this->root();
+ }
+
+ $list = [];
+
+ if (!$current->root()) {
+ if ($rawRoutes) {
+ $route = $current->rawRoute();
+ } else {
+ $route = $current->route();
+ }
+
+ if ($showFullpath) {
+ $option = $current->route();
+ } else {
+ $extra = $showSlug ? '(' . $current->slug() . ') ' : '';
+ $option = str_repeat('—-', $level). '▸ ' . $extra . $current->title();
+
+
+ }
+
+ $list[$route] = $option;
+
+
+ }
+
+ if ($limitLevels === false || ($level+1 < $limitLevels)) {
+ foreach ($current->children() as $next) {
+ if ($showAll || $next->routable() || ($next->modular() && $showModular)) {
+ $list = array_merge($list, $this->getList($next, $level + 1, $rawRoutes, $showAll, $showFullpath, $showSlug, $showModular, $limitLevels));
+ }
+ }
+ }
+
+ return $list;
+ }
+
+ /**
+ * Get available page types.
+ *
+ * @return Types
+ */
+ public static function getTypes()
+ {
+ if (!self::$types) {
+ $grav = Grav::instance();
+
+ $scanBlueprintsAndTemplates = function () use ($grav) {
+ // Scan blueprints
+ $event = new Event();
+ $event->types = self::$types;
+ $grav->fireEvent('onGetPageBlueprints', $event);
+
+ self::$types->scanBlueprints('theme://blueprints/');
+
+ // Scan templates
+ $event = new Event();
+ $event->types = self::$types;
+ $grav->fireEvent('onGetPageTemplates', $event);
+
+ self::$types->scanTemplates('theme://templates/');
+ };
+
+ if ($grav['config']->get('system.cache.enabled')) {
+ /** @var Cache $cache */
+ $cache = $grav['cache'];
+
+ // Use cached types if possible.
+ $types_cache_id = md5('types');
+ self::$types = $cache->fetch($types_cache_id);
+
+ if (!self::$types) {
+ self::$types = new Types();
+ $scanBlueprintsAndTemplates();
+ $cache->save($types_cache_id, self::$types);
+ }
+
+ } else {
+ self::$types = new Types();
+ $scanBlueprintsAndTemplates();
+ }
+
+ // Register custom paths to the locator.
+ $locator = $grav['locator'];
+ foreach (self::$types as $type => $paths) {
+ foreach ($paths as $k => $path) {
+ if (strpos($path, 'blueprints://') === 0) {
+ unset($paths[$k]);
+ }
+ }
+ if ($paths) {
+ $locator->addPath('blueprints', "pages/$type.yaml", $paths);
+ }
+ }
+ }
+
+ return self::$types;
+ }
+
+ /**
+ * Get available page types.
+ *
+ * @return array
+ */
+ public static function types()
+ {
+ $types = self::getTypes();
+
+ return $types->pageSelect();
+ }
+
+ /**
+ * Get available page types.
+ *
+ * @return array
+ */
+ public static function modularTypes()
+ {
+ $types = self::getTypes();
+
+ return $types->modularSelect();
+ }
+
+ /**
+ * Get template types based on page type (standard or modular)
+ *
+ * @return array
+ */
+ public static function pageTypes()
+ {
+ if (isset(Grav::instance()['admin'])) {
+ /** @var Admin $admin */
+ $admin = Grav::instance()['admin'];
+
+ /** @var PageInterface $page */
+ $page = $admin->getPage($admin->route);
+
+ if ($page && $page->modular()) {
+ return static::modularTypes();
+ }
+
+ return static::types();
+ }
+
+ return [];
+ }
+
+ /**
+ * Get access levels of the site pages
+ *
+ * @return array
+ */
+ public function accessLevels()
+ {
+ $accessLevels = [];
+ foreach ($this->all() as $page) {
+ if (isset($page->header()->access)) {
+ if (\is_array($page->header()->access)) {
+ foreach ($page->header()->access as $index => $accessLevel) {
+ if (\is_array($accessLevel)) {
+ foreach ($accessLevel as $innerIndex => $innerAccessLevel) {
+ $accessLevels[] = $innerIndex;
+ }
+ } else {
+ $accessLevels[] = $index;
+ }
+ }
+ } else {
+ $accessLevels[] = $page->header()->access;
+ }
+ }
+ }
+
+ return array_unique($accessLevels);
+ }
+
+ /**
+ * Get available parents routes
+ *
+ * @return array
+ */
+ public static function parents()
+ {
+ $rawRoutes = false;
+
+ return self::getParents($rawRoutes);
+ }
+
+
+
+ /**
+ * Gets the home route
+ *
+ * @return string
+ */
+ public static function getHomeRoute()
+ {
+ if (empty(self::$home_route)) {
+ $grav = Grav::instance();
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ /** @var Language $language */
+ $language = $grav['language'];
+
+ $home = $config->get('system.home.alias');
+
+ if ($language->enabled()) {
+ $home_aliases = $config->get('system.home.aliases');
+ if ($home_aliases) {
+ $active = $language->getActive();
+ $default = $language->getDefault();
+
+ try {
+ if ($active) {
+ $home = $home_aliases[$active];
+ } else {
+ $home = $home_aliases[$default];
+ }
+ } catch (ErrorException $e) {
+ $home = $home_aliases[$default];
+ }
+
+ }
+ }
+
+ self::$home_route = trim($home, '/');
+ }
+
+ return self::$home_route;
+ }
+
+ /**
+ * Needed for testing where we change the home route via config
+ */
+ public static function resetHomeRoute()
+ {
+ self::$home_route = null;
+ return self::getHomeRoute();
+ }
+
+ /**
+ * Builds pages.
+ *
+ * @internal
+ */
+ protected function buildPages()
+ {
+ $this->sort = [];
+
+ /** @var Config $config */
+ $config = $this->grav['config'];
+
+ /** @var Language $language */
+ $language = $this->grav['language'];
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $this->grav['locator'];
+
+ $pages_dir = $locator->findResource('page://');
+
+ // Set active language
+ $this->active_lang = $language->getActive();
+
+ if ($config->get('system.cache.enabled')) {
+ /** @var Cache $cache */
+ $cache = $this->grav['cache'];
+ /** @var Taxonomy $taxonomy */
+ $taxonomy = $this->grav['taxonomy'];
+
+ // how should we check for last modified? Default is by file
+ switch ($this->check_method) {
+ case 'none':
+ case 'off':
+ $hash = 0;
+ break;
+ case 'folder':
+ $hash = Folder::lastModifiedFolder($pages_dir);
+ break;
+ case 'hash':
+ $hash = Folder::hashAllFiles($pages_dir);
+ break;
+ default:
+ $hash = Folder::lastModifiedFile($pages_dir);
+ }
+
+ $this->pages_cache_id = md5($pages_dir . $hash . $language->getActive() . $config->checksum());
+
+ $cached = $cache->fetch($this->pages_cache_id);
+ if ($cached) {
+ $this->grav['debugger']->addMessage('Page cache hit.');
+
+ list($this->instances, $this->routes, $this->children, $taxonomy_map, $this->sort) = $cached;
+
+ // If pages was found in cache, set the taxonomy
+ $taxonomy->taxonomy($taxonomy_map);
+ } else {
+ $this->grav['debugger']->addMessage('Page cache missed, rebuilding pages..');
+
+ // recurse pages and cache result
+ $this->resetPages($pages_dir);
+ }
+ } else {
+ $this->recurse($pages_dir);
+ $this->buildRoutes();
+ }
+ }
+
+ /**
+ * Accessible method to manually reset the pages cache
+ *
+ * @param string $pages_dir
+ */
+ public function resetPages($pages_dir)
+ {
+ $this->recurse($pages_dir);
+ $this->buildRoutes();
+
+ // cache if needed
+ if ($this->grav['config']->get('system.cache.enabled')) {
+ /** @var Cache $cache */
+ $cache = $this->grav['cache'];
+ /** @var Taxonomy $taxonomy */
+ $taxonomy = $this->grav['taxonomy'];
+
+ // save pages, routes, taxonomy, and sort to cache
+ $cache->save($this->pages_cache_id, [$this->instances, $this->routes, $this->children, $taxonomy->taxonomy(), $this->sort]);
+ }
+ }
+
+ /**
+ * Recursive function to load & build page relationships.
+ *
+ * @param string $directory
+ * @param PageInterface|null $parent
+ *
+ * @return PageInterface
+ * @throws \RuntimeException
+ * @internal
+ */
+ protected function recurse($directory, PageInterface $parent = null)
+ {
+ $directory = rtrim($directory, DS);
+ $page = new Page;
+
+ /** @var Config $config */
+ $config = $this->grav['config'];
+
+ /** @var Language $language */
+ $language = $this->grav['language'];
+
+ // Stuff to do at root page
+ // Fire event for memory and time consuming plugins...
+ if ($parent === null && $config->get('system.pages.events.page')) {
+ $this->grav->fireEvent('onBuildPagesInitialized');
+ }
+
+ $page->path($directory);
+ if ($parent) {
+ $page->parent($parent);
+ }
+
+ $page->orderDir($config->get('system.pages.order.dir'));
+ $page->orderBy($config->get('system.pages.order.by'));
+
+ // Add into instances
+ if (!isset($this->instances[$page->path()])) {
+ $this->instances[$page->path()] = $page;
+ if ($parent && $page->path()) {
+ $this->children[$parent->path()][$page->path()] = ['slug' => $page->slug()];
+ }
+ } else {
+ throw new \RuntimeException('Fatal error when creating page instances.');
+ }
+
+ // Build regular expression for all the allowed page extensions.
+ $page_extensions = $language->getFallbackPageExtensions();
+ $regex = '/^[^\.]*(' . implode('|', array_map(
+ function ($str) {
+ return preg_quote($str, '/');
+ },
+ $page_extensions
+ )) . ')$/';
+
+ $folders = [];
+ $page_found = null;
+ $page_extension = '.md';
+ $last_modified = 0;
+
+ $iterator = new \FilesystemIterator($directory);
+ /** @var \FilesystemIterator $file */
+ foreach ($iterator as $file) {
+ $filename = $file->getFilename();
+
+ // Ignore all hidden files if set.
+ if ($this->ignore_hidden && $filename && strpos($filename, '.') === 0) {
+ continue;
+ }
+
+ // Handle folders later.
+ if ($file->isDir()) {
+ // But ignore all folders in ignore list.
+ if (!\in_array($filename, $this->ignore_folders, true)) {
+ $folders[] = $file;
+ }
+ continue;
+ }
+
+ // Ignore all files in ignore list.
+ if (\in_array($filename, $this->ignore_files, true)) {
+ continue;
+ }
+
+ // Update last modified date to match the last updated file in the folder.
+ $modified = $file->getMTime();
+ if ($modified > $last_modified) {
+ $last_modified = $modified;
+ }
+
+ // Page is the one that matches to $page_extensions list with the lowest index number.
+ if (preg_match($regex, $filename, $matches, PREG_OFFSET_CAPTURE)) {
+ $ext = $matches[1][0];
+
+ if ($page_found === null || array_search($ext, $page_extensions, true) < array_search($page_extension, $page_extensions, true)) {
+ $page_found = $file;
+ $page_extension = $ext;
+ }
+ }
+ }
+
+ $content_exists = false;
+ if ($parent && $page_found) {
+ $page->init($page_found, $page_extension);
+
+ $content_exists = true;
+
+ if ($config->get('system.pages.events.page')) {
+ $this->grav->fireEvent('onPageProcessed', new Event(['page' => $page]));
+ }
+ }
+
+ // Now handle all the folders under the page.
+ /** @var \FilesystemIterator $file */
+ foreach ($folders as $file) {
+ $filename = $file->getFilename();
+
+ // if folder contains separator, continue
+ if (Utils::contains($file->getFilename(), $config->get('system.param_sep', ':'))) {
+ continue;
+ }
+
+ if (!$page->path()) {
+ $page->path($file->getPath());
+ }
+
+ $path = $directory . DS . $filename;
+ $child = $this->recurse($path, $page);
+
+ if (Utils::startsWith($filename, '_')) {
+ $child->routable(false);
+ }
+
+ $this->children[$page->path()][$child->path()] = ['slug' => $child->slug()];
+
+ if ($config->get('system.pages.events.page')) {
+ $this->grav->fireEvent('onFolderProcessed', new Event(['page' => $page]));
+ }
+ }
+
+
+ if (!$content_exists) {
+ // Set routability to false if no page found
+ $page->routable(false);
+
+ // Hide empty folders if option set
+ if ($config->get('system.pages.hide_empty_folders')) {
+ $page->visible(false);
+ }
+ }
+
+ // Override the modified time if modular
+ if ($page->template() === 'modular') {
+ foreach ($page->collection() as $child) {
+ $modified = $child->modified();
+
+ if ($modified > $last_modified) {
+ $last_modified = $modified;
+ }
+ }
+ }
+
+ // Override the modified and ID so that it takes the latest change into account
+ $page->modified($last_modified);
+ $page->id($last_modified . md5($page->filePath()));
+
+ // Sort based on Defaults or Page Overridden sort order
+ $this->children[$page->path()] = $this->sort($page);
+
+ return $page;
+ }
+
+ /**
+ * @internal
+ */
+ protected function buildRoutes()
+ {
+ /** @var Taxonomy $taxonomy */
+ $taxonomy = $this->grav['taxonomy'];
+
+ // Get the home route
+ $home = self::resetHomeRoute();
+
+ // Build routes and taxonomy map.
+ /** @var PageInterface $page */
+ foreach ($this->instances as $page) {
+ if (!$page->root()) {
+ // process taxonomy
+ $taxonomy->addTaxonomy($page);
+
+ $route = $page->route();
+ $raw_route = $page->rawRoute();
+ $page_path = $page->path();
+
+ // add regular route
+ $this->routes[$route] = $page_path;
+
+ // add raw route
+ if ($raw_route !== $route) {
+ $this->routes[$raw_route] = $page_path;
+ }
+
+ // add canonical route
+ $route_canonical = $page->routeCanonical();
+ if ($route_canonical && ($route !== $route_canonical)) {
+ $this->routes[$route_canonical] = $page_path;
+ }
+
+ // add aliases to routes list if they are provided
+ $route_aliases = $page->routeAliases();
+ if ($route_aliases) {
+ foreach ($route_aliases as $alias) {
+ $this->routes[$alias] = $page_path;
+ }
+ }
+ }
+ }
+
+ // Alias and set default route to home page.
+ $homeRoute = '/' . $home;
+ if ($home && isset($this->routes[$homeRoute])) {
+ $this->routes['/'] = $this->routes[$homeRoute];
+ $this->get($this->routes[$homeRoute])->route('/');
+ }
+ }
+
+ /**
+ * @param string $path
+ * @param array $pages
+ * @param string $order_by
+ * @param array|null $manual
+ * @param int|null $sort_flags
+ *
+ * @throws \RuntimeException
+ * @internal
+ */
+ protected function buildSort($path, array $pages, $order_by = 'default', $manual = null, $sort_flags = null)
+ {
+ $list = [];
+ $header_default = null;
+ $header_query = [];
+
+ // do this header query work only once
+ if (strpos($order_by, 'header.') === 0) {
+ $query = explode('|', str_replace('header.', '', $order_by), 2);
+ $header_query = array_shift($query) ?? '';
+ $header_default = array_shift($query);
+ }
+
+ foreach ($pages as $key => $info) {
+ $child = $this->instances[$key] ?? null;
+ if (!$child) {
+ throw new \RuntimeException("Page does not exist: {$key}");
+ }
+
+ switch ($order_by) {
+ case 'title':
+ $list[$key] = $child->title();
+ break;
+ case 'date':
+ $list[$key] = $child->date();
+ $sort_flags = SORT_REGULAR;
+ break;
+ case 'modified':
+ $list[$key] = $child->modified();
+ $sort_flags = SORT_REGULAR;
+ break;
+ case 'publish_date':
+ $list[$key] = $child->publishDate();
+ $sort_flags = SORT_REGULAR;
+ break;
+ case 'unpublish_date':
+ $list[$key] = $child->unpublishDate();
+ $sort_flags = SORT_REGULAR;
+ break;
+ case 'slug':
+ $list[$key] = $child->slug();
+ break;
+ case 'basename':
+ $list[$key] = basename($key);
+ break;
+ case 'folder':
+ $list[$key] = $child->folder();
+ break;
+ case 'manual':
+ case 'default':
+ default:
+ if (is_string($header_query)) {
+ $child_header = $child->header();
+ if (!$child_header instanceof Header) {
+ $child_header = new Header((array)$child_header);
+ }
+ $header_value = $child_header->get($header_query);
+ if (is_array($header_value)) {
+ $list[$key] = implode(',', $header_value);
+ } elseif ($header_value) {
+ $list[$key] = $header_value;
+ } else {
+ $list[$key] = $header_default ?: $key;
+ }
+ $sort_flags = $sort_flags ?: SORT_REGULAR;
+ break;
+ }
+ $list[$key] = $key;
+ $sort_flags = $sort_flags ?: SORT_REGULAR;
+ }
+ }
+
+ if (!$sort_flags) {
+ $sort_flags = SORT_NATURAL | SORT_FLAG_CASE;
+ }
+
+ // handle special case when order_by is random
+ if ($order_by === 'random') {
+ $list = $this->arrayShuffle($list);
+ } else {
+ // else just sort the list according to specified key
+ if (extension_loaded('intl') && $this->grav['config']->get('system.intl_enabled')) {
+ $locale = setlocale(LC_COLLATE, 0); //`setlocale` with a 0 param returns the current locale set
+ $col = Collator::create($locale);
+ if ($col) {
+ if (($sort_flags & SORT_NATURAL) === SORT_NATURAL) {
+ $list = preg_replace_callback('~([0-9]+)\.~', function($number) {
+ return sprintf('%032d.', $number[0]);
+ }, $list);
+
+ $list_vals = array_values($list);
+ if (is_numeric(array_shift($list_vals))) {
+ $sort_flags = Collator::SORT_REGULAR;
+ } else {
+ $sort_flags = Collator::SORT_STRING;
+ }
+ }
+
+ $col->asort($list, $sort_flags);
+ } else {
+ asort($list, $sort_flags);
+ }
+ } else {
+ asort($list, $sort_flags);
+ }
+ }
+
+
+ // Move manually ordered items into the beginning of the list. Order of the unlisted items does not change.
+ if (is_array($manual) && !empty($manual)) {
+ $new_list = [];
+ $i = count($manual);
+
+ foreach ($list as $key => $dummy) {
+ $info = $pages[$key];
+ $order = \array_search($info['slug'], $manual, true);
+ if ($order === false) {
+ $order = $i++;
+ }
+ $new_list[$key] = (int)$order;
+ }
+
+ $list = $new_list;
+
+ // Apply manual ordering to the list.
+ asort($list);
+ }
+
+ foreach ($list as $key => $sort) {
+ $info = $pages[$key];
+ $this->sort[$path][$order_by][$key] = $info;
+ }
+ }
+
+ /**
+ * Shuffles an associative array
+ *
+ * @param array $list
+ *
+ * @return array
+ */
+ protected function arrayShuffle($list)
+ {
+ $keys = array_keys($list);
+ shuffle($keys);
+
+ $new = [];
+ foreach ($keys as $key) {
+ $new[$key] = $list[$key];
+ }
+
+ return $new;
+ }
+
+ /**
+ * Get the Pages cache ID
+ *
+ * this is particularly useful to know if pages have changed and you want
+ * to sync another cache with pages cache - works best in `onPagesInitialized()`
+ *
+ * @return mixed
+ */
+ public function getPagesCacheId()
+ {
+ return $this->pages_cache_id;
+ }
+}
diff --git a/system/src/Grav/Common/Page/Types.php b/system/src/Grav/Common/Page/Types.php
new file mode 100644
index 0000000..03e3f6e
--- /dev/null
+++ b/system/src/Grav/Common/Page/Types.php
@@ -0,0 +1,141 @@
+items[$type])) {
+ $this->items[$type] = [];
+ } elseif (!$blueprint) {
+ return;
+ }
+
+ if (!$blueprint && $this->systemBlueprints) {
+ $blueprint = $this->systemBlueprints[$type] ?? $this->systemBlueprints['default'];
+ }
+
+ if ($blueprint) {
+ array_unshift($this->items[$type], $blueprint);
+ }
+ }
+
+ public function scanBlueprints($uri)
+ {
+ if (!\is_string($uri)) {
+ throw new \InvalidArgumentException('First parameter must be URI');
+ }
+
+ if (!$this->systemBlueprints) {
+ $this->systemBlueprints = $this->findBlueprints('blueprints://pages');
+
+ // Register default by default.
+ $this->register('default');
+
+ $this->register('external');
+ }
+
+ foreach ($this->findBlueprints($uri) as $type => $blueprint) {
+ $this->register($type, $blueprint);
+ }
+ }
+
+ public function scanTemplates($uri)
+ {
+ if (!\is_string($uri)) {
+ throw new \InvalidArgumentException('First parameter must be URI');
+ }
+
+ $options = [
+ 'compare' => 'Filename',
+ 'pattern' => '|\.html\.twig$|',
+ 'filters' => [
+ 'value' => '|\.html\.twig$|'
+ ],
+ 'value' => 'Filename',
+ 'recursive' => false
+ ];
+
+ foreach (Folder::all($uri, $options) as $type) {
+ $this->register($type);
+ }
+
+ $modular_uri = rtrim($uri, '/') . '/modular';
+ if (is_dir($modular_uri)) {
+ foreach (Folder::all($modular_uri, $options) as $type) {
+ $this->register('modular/' . $type);
+ }
+ }
+ }
+
+ public function pageSelect()
+ {
+ $list = [];
+ foreach ($this->items as $name => $file) {
+ if (strpos($name, '/')) {
+ continue;
+ }
+ $list[$name] = ucfirst(str_replace('_', ' ', $name));
+ }
+ ksort($list);
+
+ return $list;
+ }
+
+ public function modularSelect()
+ {
+ $list = [];
+ foreach ($this->items as $name => $file) {
+ if (strpos($name, 'modular/') !== 0) {
+ continue;
+ }
+ $list[$name] = ucfirst(trim(str_replace('_', ' ', basename($name))));
+ }
+ ksort($list);
+
+ return $list;
+ }
+
+ private function findBlueprints($uri)
+ {
+ $options = [
+ 'compare' => 'Filename',
+ 'pattern' => '|\.yaml$|',
+ 'filters' => [
+ 'key' => '|\.yaml$|'
+ ],
+ 'key' => 'SubPathName',
+ 'value' => 'PathName',
+ ];
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ if ($locator->isStream($uri)) {
+ $options['value'] = 'Url';
+ }
+
+ return Folder::all($uri, $options);
+ }
+}
diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php
new file mode 100644
index 0000000..727fd95
--- /dev/null
+++ b/system/src/Grav/Common/Plugin.php
@@ -0,0 +1,390 @@
+name = $name;
+ $this->grav = $grav;
+ if ($config) {
+ $this->setConfig($config);
+ }
+ }
+
+ /**
+ * @param Config $config
+ * @return $this
+ */
+ public function setConfig(Config $config)
+ {
+ $this->config = $config;
+
+ return $this;
+ }
+
+ /**
+ * Get configuration of the plugin.
+ *
+ * @return array
+ */
+ public function config()
+ {
+ return $this->config["plugins.{$this->name}"];
+ }
+
+ /**
+ * Determine if plugin is running under the admin
+ *
+ * @return bool
+ */
+ public function isAdmin()
+ {
+ return Utils::isAdminPlugin();
+ }
+
+ /**
+ * Determine if plugin is running under the CLI
+ *
+ * @return bool
+ */
+ public function isCli()
+ {
+ return \defined('GRAV_CLI');
+ }
+
+ /**
+ * Determine if this route is in Admin and active for the plugin
+ *
+ * @param string $plugin_route
+ * @return bool
+ */
+ protected function isPluginActiveAdmin($plugin_route)
+ {
+ $should_run = false;
+
+ $uri = $this->grav['uri'];
+
+ if (strpos($uri->path(), $this->config->get('plugins.admin.route') . '/' . $plugin_route) === false) {
+ $should_run = false;
+ } elseif (isset($uri->paths()[1]) && $uri->paths()[1] === $plugin_route) {
+ $should_run = true;
+ }
+
+ return $should_run;
+ }
+
+ /**
+ * @param array $events
+ */
+ protected function enable(array $events)
+ {
+ /** @var EventDispatcher $dispatcher */
+ $dispatcher = $this->grav['events'];
+
+ foreach ($events as $eventName => $params) {
+ if (\is_string($params)) {
+ $dispatcher->addListener($eventName, [$this, $params]);
+ } elseif (\is_string($params[0])) {
+ $dispatcher->addListener($eventName, [$this, $params[0]], $this->getPriority($params, $eventName));
+ } else {
+ foreach ($params as $listener) {
+ $dispatcher->addListener($eventName, [$this, $listener[0]], $this->getPriority($listener, $eventName));
+ }
+ }
+ }
+ }
+
+ /**
+ * @param array $params
+ * @param string $eventName
+ */
+ private function getPriority($params, $eventName)
+ {
+ $grav = Grav::instance();
+ $override = implode('.', ["priorities", $this->name, $eventName, $params[0]]);
+ if ($grav['config']->get($override) !== null)
+ {
+ return $grav['config']->get($override);
+ } elseif (isset($params[1])) {
+ return $params[1];
+ }
+ return 0;
+ }
+
+ /**
+ * @param array $events
+ */
+ protected function disable(array $events)
+ {
+ /** @var EventDispatcher $dispatcher */
+ $dispatcher = $this->grav['events'];
+
+ foreach ($events as $eventName => $params) {
+ if (\is_string($params)) {
+ $dispatcher->removeListener($eventName, [$this, $params]);
+ } elseif (\is_string($params[0])) {
+ $dispatcher->removeListener($eventName, [$this, $params[0]]);
+ } else {
+ foreach ($params as $listener) {
+ $dispatcher->removeListener($eventName, [$this, $listener[0]]);
+ }
+ }
+ }
+ }
+
+ /**
+ * Whether or not an offset exists.
+ *
+ * @param string $offset An offset to check for.
+ * @return bool Returns TRUE on success or FALSE on failure.
+ */
+ public function offsetExists($offset)
+ {
+ $this->loadBlueprint();
+
+ if ($offset === 'title') {
+ $offset = 'name';
+ }
+ return isset($this->blueprint[$offset]);
+ }
+
+ /**
+ * Returns the value at specified offset.
+ *
+ * @param string $offset The offset to retrieve.
+ * @return mixed Can return all value types.
+ */
+ public function offsetGet($offset)
+ {
+ $this->loadBlueprint();
+
+ if ($offset === 'title') {
+ $offset = 'name';
+ }
+ return $this->blueprint[$offset] ?? null;
+ }
+
+ /**
+ * Assigns a value to the specified offset.
+ *
+ * @param string $offset The offset to assign the value to.
+ * @param mixed $value The value to set.
+ * @throws \LogicException
+ */
+ public function offsetSet($offset, $value)
+ {
+ throw new \LogicException(__CLASS__ . ' blueprints cannot be modified.');
+ }
+
+ /**
+ * Unsets an offset.
+ *
+ * @param string $offset The offset to unset.
+ * @throws \LogicException
+ */
+ public function offsetUnset($offset)
+ {
+ throw new \LogicException(__CLASS__ . ' blueprints cannot be modified.');
+ }
+
+ /**
+ * This function will search a string for markdown links in a specific format. The link value can be
+ * optionally compared against via the $internal_regex and operated on by the callback $function
+ * provided.
+ *
+ * format: [plugin:myplugin_name](function_data)
+ *
+ * @param string $content The string to perform operations upon
+ * @param callable $function The anonymous callback function
+ * @param string $internal_regex Optional internal regex to extra data from
+ *
+ * @return string
+ */
+ protected function parseLinks($content, $function, $internal_regex = '(.*)')
+ {
+ $regex = '/\[plugin:(?:' . $this->name . ')\]\(' . $internal_regex . '\)/i';
+
+ return preg_replace_callback($regex, $function, $content);
+ }
+
+ /**
+ * Merge global and page configurations.
+ *
+ * @param PageInterface $page The page to merge the configurations with the
+ * plugin settings.
+ * @param mixed $deep false = shallow|true = recursive|merge = recursive+unique
+ * @param array $params Array of additional configuration options to
+ * merge with the plugin settings.
+ * @param string $type Is this 'plugins' or 'themes'
+ *
+ * @return Data
+ */
+ protected function mergeConfig(PageInterface $page, $deep = false, $params = [], $type = 'plugins')
+ {
+ $class_name = $this->name;
+ $class_name_merged = $class_name . '.merged';
+ $defaults = $this->config->get($type . '.' . $class_name, []);
+ $page_header = $page->header();
+ $header = [];
+
+ if (!isset($page_header->{$class_name_merged}) && isset($page_header->{$class_name})) {
+ // Get default plugin configurations and retrieve page header configuration
+ $config = $page_header->{$class_name};
+ if (\is_bool($config)) {
+ // Overwrite enabled option with boolean value in page header
+ $config = ['enabled' => $config];
+ }
+ // Merge page header settings using deep or shallow merging technique
+ $header = $this->mergeArrays($deep, $defaults, $config);
+
+ // Create new config object and set it on the page object so it's cached for next time
+ $page->modifyHeader($class_name_merged, new Data($header));
+ } elseif (isset($page_header->{$class_name_merged})) {
+ $merged = $page_header->{$class_name_merged};
+ $header = $merged->toArray();
+ }
+ if (empty($header)) {
+ $header = $defaults;
+ }
+ // Merge additional parameter with configuration options
+ $header = $this->mergeArrays($deep, $header, $params);
+
+ // Return configurations as a new data config class
+ return new Data($header);
+ }
+
+ /**
+ * Merge arrays based on deepness
+ *
+ * @param string|bool $deep
+ * @param array $array1
+ * @param array $array2
+ * @return array
+ */
+ private function mergeArrays($deep, $array1, $array2)
+ {
+ if ($deep === 'merge') {
+ return Utils::arrayMergeRecursiveUnique($array1, $array2);
+ }
+ if ($deep === true) {
+ return array_replace_recursive($array1, $array2);
+ }
+
+ return array_merge($array1, $array2);
+ }
+
+ /**
+ * Persists to disk the plugin parameters currently stored in the Grav Config object
+ *
+ * @param string $plugin_name The name of the plugin whose config it should store.
+ *
+ * @return bool
+ */
+ public static function saveConfig($plugin_name)
+ {
+ if (!$plugin_name) {
+ return false;
+ }
+
+ $grav = Grav::instance();
+ $locator = $grav['locator'];
+ $filename = 'config://plugins/' . $plugin_name . '.yaml';
+ $file = YamlFile::instance($locator->findResource($filename, true, true));
+ $content = $grav['config']->get('plugins.' . $plugin_name);
+ $file->save($content);
+ $file->free();
+
+ return true;
+ }
+
+ /**
+ * Simpler getter for the plugin blueprint
+ *
+ * @return Blueprint
+ */
+ public function getBlueprint()
+ {
+ if (!$this->blueprint) {
+ $this->loadBlueprint();
+ }
+ return $this->blueprint;
+ }
+
+ /**
+ * Load blueprints.
+ */
+ protected function loadBlueprint()
+ {
+ if (!$this->blueprint) {
+ $grav = Grav::instance();
+ $plugins = $grav['plugins'];
+ $this->blueprint = $plugins->get($this->name)->blueprints();
+ }
+ }
+}
diff --git a/system/src/Grav/Common/Plugins.php b/system/src/Grav/Common/Plugins.php
new file mode 100644
index 0000000..358727f
--- /dev/null
+++ b/system/src/Grav/Common/Plugins.php
@@ -0,0 +1,228 @@
+getIterator('plugins://');
+
+ $plugins = [];
+ foreach($iterator as $directory) {
+ if (!$directory->isDir()) {
+ continue;
+ }
+ $plugins[] = $directory->getFilename();
+ }
+
+ natsort($plugins);
+
+ foreach ($plugins as $plugin) {
+ $this->add($this->loadPlugin($plugin));
+ }
+ }
+
+ /**
+ * @return $this
+ */
+ public function setup()
+ {
+ $blueprints = [];
+ $formFields = [];
+
+ /** @var Plugin $plugin */
+ foreach ($this->items as $plugin) {
+ if (isset($plugin->features['blueprints'])) {
+ $blueprints["plugin://{$plugin->name}/blueprints"] = $plugin->features['blueprints'];
+ }
+ if (method_exists($plugin, 'getFormFieldTypes')) {
+ $formFields[get_class($plugin)] = isset($plugin->features['formfields']) ? $plugin->features['formfields'] : 0;
+ }
+ }
+
+ if ($blueprints) {
+ // Order by priority.
+ arsort($blueprints);
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ $locator->addPath('blueprints', '', array_keys($blueprints), 'system/blueprints');
+ }
+
+ if ($formFields) {
+ // Order by priority.
+ arsort($formFields);
+
+ $list = [];
+ foreach ($formFields as $className => $priority) {
+ $plugin = $this->items[$className];
+ $list += $plugin->getFormFieldTypes();
+ }
+
+ $this->formFieldTypes = $list;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Registers all plugins.
+ *
+ * @return Plugin[] array of Plugin objects
+ * @throws \RuntimeException
+ */
+ public function init()
+ {
+ $grav = Grav::instance();
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ /** @var EventDispatcher $events */
+ $events = $grav['events'];
+
+ foreach ($this->items as $instance) {
+ // Register only enabled plugins.
+ if ($config["plugins.{$instance->name}.enabled"] && $instance instanceof Plugin) {
+ $instance->setConfig($config);
+ $events->addSubscriber($instance);
+ }
+ }
+
+ return $this->items;
+ }
+
+ /**
+ * Add a plugin
+ *
+ * @param Plugin $plugin
+ */
+ public function add($plugin)
+ {
+ if (is_object($plugin)) {
+ $this->items[get_class($plugin)] = $plugin;
+ }
+ }
+
+ /**
+ * Return list of all plugin data with their blueprints.
+ *
+ * @return array
+ */
+ public static function all()
+ {
+ $grav = Grav::instance();
+ $plugins = $grav['plugins'];
+ $list = [];
+
+ foreach ($plugins as $instance) {
+ $name = $instance->name;
+
+ try {
+ $result = self::get($name);
+ } catch (\Exception $e) {
+ $exception = new \RuntimeException(sprintf('Plugin %s: %s', $name, $e->getMessage()), $e->getCode(), $e);
+
+ /** @var Debugger $debugger */
+ $debugger = $grav['debugger'];
+ $debugger->addMessage("Plugin {$name} cannot be loaded, please check Exceptions tab", 'error');
+ $debugger->addException($exception);
+
+ continue;
+ }
+
+ if ($result) {
+ $list[$name] = $result;
+ }
+ }
+
+ return $list;
+ }
+
+ /**
+ * Get a plugin by name
+ *
+ * @param string $name
+ *
+ * @return Data|null
+ */
+ public static function get($name)
+ {
+ $blueprints = new Blueprints('plugins://');
+ $blueprint = $blueprints->get("{$name}/blueprints");
+
+ // Load default configuration.
+ $file = CompiledYamlFile::instance("plugins://{$name}/{$name}" . YAML_EXT);
+
+ // ensure this is a valid plugin
+ if (!$file->exists()) {
+ return null;
+ }
+
+ $obj = new Data((array)$file->content(), $blueprint);
+
+ // Override with user configuration.
+ $obj->merge(Grav::instance()['config']->get('plugins.' . $name) ?: []);
+
+ // Save configuration always to user/config.
+ $file = CompiledYamlFile::instance("config://plugins/{$name}.yaml");
+ $obj->file($file);
+
+ return $obj;
+ }
+
+ protected function loadPlugin($name)
+ {
+ $grav = Grav::instance();
+ $locator = $grav['locator'];
+
+ $file = $locator->findResource('plugins://' . $name . DS . $name . PLUGIN_EXT);
+
+ if (is_file($file)) {
+ // Local variables available in the file: $grav, $config, $name, $file
+ $class = include_once $file;
+
+ $pluginClassFormat = [
+ 'Grav\\Plugin\\' . ucfirst($name). 'Plugin',
+ 'Grav\\Plugin\\' . Inflector::camelize($name) . 'Plugin'
+ ];
+
+ foreach ($pluginClassFormat as $pluginClass) {
+ if (class_exists($pluginClass)) {
+ $class = new $pluginClass($name, $grav);
+ break;
+ }
+ }
+ } else {
+ $grav['log']->addWarning(
+ sprintf("Plugin '%s' enabled but not found! Try clearing cache with `bin/grav clear-cache`", $name)
+ );
+ return null;
+ }
+
+ return $class;
+ }
+
+}
diff --git a/system/src/Grav/Common/Processors/AssetsProcessor.php b/system/src/Grav/Common/Processors/AssetsProcessor.php
new file mode 100644
index 0000000..8b46401
--- /dev/null
+++ b/system/src/Grav/Common/Processors/AssetsProcessor.php
@@ -0,0 +1,30 @@
+startTimer();
+ $this->container['assets']->init();
+ $this->container->fireEvent('onAssetsInitialized');
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/BackupsProcessor.php b/system/src/Grav/Common/Processors/BackupsProcessor.php
new file mode 100644
index 0000000..d2a822c
--- /dev/null
+++ b/system/src/Grav/Common/Processors/BackupsProcessor.php
@@ -0,0 +1,30 @@
+startTimer();
+ $backups = $this->container['backups'];
+ $backups->init();
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/ConfigurationProcessor.php b/system/src/Grav/Common/Processors/ConfigurationProcessor.php
new file mode 100644
index 0000000..83ceb84
--- /dev/null
+++ b/system/src/Grav/Common/Processors/ConfigurationProcessor.php
@@ -0,0 +1,30 @@
+startTimer();
+ $this->container['config']->init();
+ $this->container['plugins']->setup();
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php b/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php
new file mode 100644
index 0000000..11a39e8
--- /dev/null
+++ b/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php
@@ -0,0 +1,31 @@
+startTimer();
+ $this->container['debugger']->addAssets();
+ $this->stopTimer();
+
+ return $handler->handle($request);
+
+ }
+}
diff --git a/system/src/Grav/Common/Processors/DebuggerProcessor.php b/system/src/Grav/Common/Processors/DebuggerProcessor.php
new file mode 100644
index 0000000..892af55
--- /dev/null
+++ b/system/src/Grav/Common/Processors/DebuggerProcessor.php
@@ -0,0 +1,29 @@
+startTimer();
+ $this->container['debugger']->init();
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/ErrorsProcessor.php b/system/src/Grav/Common/Processors/ErrorsProcessor.php
new file mode 100644
index 0000000..b0ef6ca
--- /dev/null
+++ b/system/src/Grav/Common/Processors/ErrorsProcessor.php
@@ -0,0 +1,29 @@
+startTimer();
+ $this->container['errors']->resetHandlers();
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php b/system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php
new file mode 100644
index 0000000..fd97e9e
--- /dev/null
+++ b/system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php
@@ -0,0 +1,78 @@
+offsetGet('request');
+ }
+
+ /**
+ * @return Route
+ */
+ public function getRoute(): Route
+ {
+ return $this->getRequest()->getAttribute('route');
+ }
+
+ /**
+ * @return RequestHandler
+ */
+ public function getHandler(): RequestHandler
+ {
+ return $this->offsetGet('handler');
+ }
+
+ /**
+ * @return ResponseInterface|null
+ */
+ public function getResponse(): ?ResponseInterface
+ {
+ return $this->offsetGet('response');
+ }
+
+ /**
+ * @param ResponseInterface $response
+ * @return $this
+ */
+ public function setResponse(ResponseInterface $response): self
+ {
+ $this->offsetSet('response', $response);
+ $this->stopPropagation();
+
+ return $this;
+ }
+
+ /**
+ * @param string $name
+ * @param MiddlewareInterface $middleware
+ * @return RequestHandlerEvent
+ */
+ public function addMiddleware(string $name, MiddlewareInterface $middleware): self
+ {
+ /** @var RequestHandler $handler */
+ $handler = $this['handler'];
+ $handler->addMiddleware($name, $middleware);
+
+ return $this;
+ }
+}
diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php
new file mode 100644
index 0000000..eca7c54
--- /dev/null
+++ b/system/src/Grav/Common/Processors/InitializeProcessor.php
@@ -0,0 +1,128 @@
+processCli();
+ }
+ }
+
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
+ {
+ $this->startTimer();
+
+ /** @var Config $config */
+ $config = $this->container['config'];
+ $config->debug();
+
+ // Use output buffering to prevent headers from being sent too early.
+ ob_start();
+ if ($config->get('system.cache.gzip') && !@ob_start('ob_gzhandler')) {
+ // Enable zip/deflate with a fallback in case of if browser does not support compressing.
+ ob_start();
+ }
+
+ // Initialize the timezone.
+ $timezone = $config->get('system.timezone');
+ if ($timezone) {
+ date_default_timezone_set($timezone);
+ }
+
+ // FIXME: Initialize session should happen later after plugins have been loaded. This is a workaround to fix session issues in AWS.
+ if (isset($this->container['session']) && $config->get('system.session.initialize', true)) {
+ // TODO: remove in 2.0.
+ $this->container['accounts'];
+
+ try {
+ $this->container['session']->init();
+ } catch (SessionException $e) {
+ $this->container['session']->init();
+ $message = 'Session corruption detected, restarting session...';
+ $this->addMessage($message);
+ $this->container['messages']->add($message, 'error');
+ }
+ }
+
+ /** @var Uri $uri */
+ $uri = $this->container['uri'];
+ $uri->init();
+
+ // Redirect pages with trailing slash if configured to do so.
+ $path = $uri->path() ?: '/';
+ if ($path !== '/'
+ && $config->get('system.pages.redirect_trailing_slash', false)
+ && Utils::endsWith($path, '/')) {
+
+ $redirect = (string) $uri::getCurrentRoute()->toString();
+ $this->container->redirect($redirect);
+ }
+
+ $this->container->setLocale();
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+
+ public function processCli(): void
+ {
+ // Load configuration.
+ $this->container['config']->init();
+ $this->container['plugins']->setup();
+
+ // Disable debugger.
+ $this->container['debugger']->enabled(false);
+
+ // Set timezone, locale.
+ /** @var Config $config */
+ $config = $this->container['config'];
+ $timezone = $config->get('system.timezone');
+ if ($timezone) {
+ date_default_timezone_set($timezone);
+ }
+ $this->container->setLocale();
+
+ // Load plugins.
+ $this->container['plugins']->init();
+
+ // Initialize URI.
+ /** @var Uri $uri */
+ $uri = $this->container['uri'];
+ $uri->init();
+
+ // Load accounts.
+ // TODO: remove in 2.0.
+ $this->container['accounts'];
+ }
+}
diff --git a/system/src/Grav/Common/Processors/LoggerProcessor.php b/system/src/Grav/Common/Processors/LoggerProcessor.php
new file mode 100644
index 0000000..af3c169
--- /dev/null
+++ b/system/src/Grav/Common/Processors/LoggerProcessor.php
@@ -0,0 +1,50 @@
+startTimer();
+
+ $grav = $this->container;
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ switch ($config->get('system.log.handler', 'file')) {
+ case 'syslog':
+ $log = $grav['log'];
+ $log->popHandler();
+
+ $facility = $config->get('system.log.syslog.facility', 'local6');
+ $logHandler = new SyslogHandler('grav', $facility);
+ $formatter = new LineFormatter("%channel%.%level_name%: %message% %extra%");
+ $logHandler->setFormatter($formatter);
+
+ $log->pushHandler($logHandler);
+ break;
+ }
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/PagesProcessor.php b/system/src/Grav/Common/Processors/PagesProcessor.php
new file mode 100644
index 0000000..ede22e5
--- /dev/null
+++ b/system/src/Grav/Common/Processors/PagesProcessor.php
@@ -0,0 +1,71 @@
+startTimer();
+
+ // Dump Cache state
+ $this->container['debugger']->addMessage($this->container['cache']->getCacheStatus());
+
+ $this->container['pages']->init();
+ $this->container->fireEvent('onPagesInitialized', new Event(['pages' => $this->container['pages']]));
+ $this->container->fireEvent('onPageInitialized', new Event(['page' => $this->container['page']]));
+
+ /** @var PageInterface $page */
+ $page = $this->container['page'];
+
+ if (!$page->routable()) {
+ // If no page found, fire event
+ $event = new Event(['page' => $page]);
+ $event->page = null;
+ $event = $this->container->fireEvent('onPageNotFound', $event);
+
+ if (isset($event->page)) {
+ unset ($this->container['page']);
+ $this->container['page'] = $page = $event->page;
+ } else {
+ throw new \RuntimeException('Page Not Found', 404);
+ }
+
+ $this->addMessage("Routed to page {$page->rawRoute()} (type: {$page->template()}) [Not Found fallback]");
+ } else {
+ $this->addMessage("Routed to page {$page->rawRoute()} (type: {$page->template()})");
+
+ $task = $this->container['task'];
+ $action = $this->container['action'];
+ if ($task) {
+ $event = new Event(['task' => $task, 'page' => $page]);
+ $this->container->fireEvent('onPageTask', $event);
+ $this->container->fireEvent('onPageTask.' . $task, $event);
+ } elseif ($action) {
+ $event = new Event(['action' => $action, 'page' => $page]);
+ $this->container->fireEvent('onPageAction', $event);
+ $this->container->fireEvent('onPageAction.' . $action, $event);
+ }
+ }
+
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/PluginsProcessor.php b/system/src/Grav/Common/Processors/PluginsProcessor.php
new file mode 100644
index 0000000..9d2943b
--- /dev/null
+++ b/system/src/Grav/Common/Processors/PluginsProcessor.php
@@ -0,0 +1,32 @@
+startTimer();
+ // TODO: remove in 2.0.
+ $this->container['accounts'];
+ $this->container['plugins']->init();
+ $this->container->fireEvent('onPluginsInitialized');
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/ProcessorBase.php b/system/src/Grav/Common/Processors/ProcessorBase.php
new file mode 100644
index 0000000..5ce7bfd
--- /dev/null
+++ b/system/src/Grav/Common/Processors/ProcessorBase.php
@@ -0,0 +1,48 @@
+container = $container;
+ }
+
+ protected function startTimer($id = null, $title = null)
+ {
+ /** @var Debugger $debugger */
+ $debugger = $this->container['debugger'];
+ $debugger->startTimer($id ?? $this->id, $title ?? $this->title);
+ }
+
+ protected function stopTimer($id = null)
+ {
+ /** @var Debugger $debugger */
+ $debugger = $this->container['debugger'];
+ $debugger->stopTimer($id ?? $this->id);
+ }
+
+ protected function addMessage($message, $label = 'info', $isString = true)
+ {
+ /** @var Debugger $debugger */
+ $debugger = $this->container['debugger'];
+ $debugger->addMessage($message, $label, $isString);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/ProcessorInterface.php b/system/src/Grav/Common/Processors/ProcessorInterface.php
new file mode 100644
index 0000000..a8e4aaa
--- /dev/null
+++ b/system/src/Grav/Common/Processors/ProcessorInterface.php
@@ -0,0 +1,16 @@
+startTimer();
+
+ $container = $this->container;
+ $output = $container['output'];
+
+ if ($output instanceof ResponseInterface) {
+ return $output;
+ }
+
+ ob_start();
+
+ // Use internal Grav output.
+ $container->output = $output;
+ $container->fireEvent('onOutputGenerated');
+
+ echo $container->output;
+
+ // remove any output
+ $container->output = '';
+
+ $this->container->fireEvent('onOutputRendered');
+
+ $html = ob_get_clean();
+
+ /** @var PageInterface $page */
+ $page = $this->container['page'];
+ $this->stopTimer();
+
+ return new Response($page->httpResponseCode(), $page->httpHeaders(), $html);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/RequestProcessor.php b/system/src/Grav/Common/Processors/RequestProcessor.php
new file mode 100644
index 0000000..97564e6
--- /dev/null
+++ b/system/src/Grav/Common/Processors/RequestProcessor.php
@@ -0,0 +1,54 @@
+startTimer();
+
+ $header = $request->getHeaderLine('Content-Type');
+ $type = trim(strstr($header, ';', true) ?: $header);
+ if ($type === 'application/json') {
+ $request = $request->withParsedBody(json_decode($request->getBody()->getContents(), true));
+ }
+
+ $uri = $request->getUri();
+ $ext = mb_strtolower(pathinfo($uri->getPath(), PATHINFO_EXTENSION));
+
+ $request = $request
+ ->withAttribute('grav', $this->container)
+ ->withAttribute('time', $_SERVER['REQUEST_TIME_FLOAT'] ?? GRAV_REQUEST_TIME)
+ ->withAttribute('route', Uri::getCurrentRoute()->withExtension($ext))
+ ->withAttribute('referrer', $this->container['uri']->referrer());
+
+ $event = new RequestHandlerEvent(['request' => $request, 'handler' => $handler]);
+ /** @var RequestHandlerEvent $event */
+ $event = $this->container->fireEvent('onRequestHandlerInit', $event);
+ $response = $event->getResponse();
+ $this->stopTimer();
+
+ if ($response) {
+ return $response;
+ }
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/SchedulerProcessor.php b/system/src/Grav/Common/Processors/SchedulerProcessor.php
new file mode 100644
index 0000000..64f3fba
--- /dev/null
+++ b/system/src/Grav/Common/Processors/SchedulerProcessor.php
@@ -0,0 +1,31 @@
+startTimer();
+ $scheduler = $this->container['scheduler'];
+ $this->container->fireEvent('onSchedulerInitialized', new Event(['scheduler' => $scheduler]));
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/TasksProcessor.php b/system/src/Grav/Common/Processors/TasksProcessor.php
new file mode 100644
index 0000000..aaf5cdf
--- /dev/null
+++ b/system/src/Grav/Common/Processors/TasksProcessor.php
@@ -0,0 +1,61 @@
+startTimer();
+
+ $task = $this->container['task'];
+ $action = $this->container['action'];
+ if ($task || $action) {
+ $attributes = $request->getAttribute('controller');
+
+ $controllerClass = $attributes['class'] ?? null;
+ if ($controllerClass) {
+ /** @var RequestHandlerInterface $controller */
+ $controller = new $controllerClass($attributes['path'] ?? '', $attributes['params'] ?? []);
+ try {
+ $response = $controller->handle($request);
+
+ if ($response->getStatusCode() === 418) {
+ $response = $handler->handle($request);
+ }
+
+ $this->stopTimer();
+
+ return $response;
+
+ } catch (NotFoundException $e) {
+ // Task not found: Let it pass through.
+ }
+ }
+
+ if ($task) {
+ $this->container->fireEvent('onTask.' . $task);
+ } elseif ($action) {
+ $this->container->fireEvent('onAction.' . $action);
+ }
+ }
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/ThemesProcessor.php b/system/src/Grav/Common/Processors/ThemesProcessor.php
new file mode 100644
index 0000000..d1c6ae5
--- /dev/null
+++ b/system/src/Grav/Common/Processors/ThemesProcessor.php
@@ -0,0 +1,29 @@
+startTimer();
+ $this->container['themes']->init();
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Processors/TwigProcessor.php b/system/src/Grav/Common/Processors/TwigProcessor.php
new file mode 100644
index 0000000..4ed247d
--- /dev/null
+++ b/system/src/Grav/Common/Processors/TwigProcessor.php
@@ -0,0 +1,29 @@
+startTimer();
+ $this->container['twig']->init();
+ $this->stopTimer();
+
+ return $handler->handle($request);
+ }
+}
diff --git a/system/src/Grav/Common/Scheduler/Cron.php b/system/src/Grav/Common/Scheduler/Cron.php
new file mode 100644
index 0000000..1838b07
--- /dev/null
+++ b/system/src/Grav/Common/Scheduler/Cron.php
@@ -0,0 +1,595 @@
+ modified for Grav integration
+ * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
+ * @license MIT License; see LICENSE file for details.
+ */
+
+namespace Grav\Common\Scheduler;
+
+/*
+ * Usage examples :
+ * ----------------
+ *
+ * $cron = new Cron('10-30/5 12 * * *');
+ *
+ * var_dump($cron->getMinutes());
+ * // array(5) {
+ * // [0]=> int(10)
+ * // [1]=> int(15)
+ * // [2]=> int(20)
+ * // [3]=> int(25)
+ * // [4]=> int(30)
+ * // }
+ *
+ * var_dump($cron->getText('fr'));
+ * // string(32) "Chaque jour à 12:10,15,20,25,30"
+ *
+ * var_dump($cron->getText('en'));
+ * // string(30) "Every day at 12:10,15,20,25,30"
+ *
+ * var_dump($cron->getType());
+ * // string(3) "day"
+ *
+ * var_dump($cron->getCronHours());
+ * // string(2) "12"
+ *
+ * var_dump($cron->matchExact(new \DateTime('2012-07-01 13:25:10')));
+ * // bool(false)
+ *
+ * var_dump($cron->matchExact(new \DateTime('2012-07-01 12:15:20')));
+ * // bool(true)
+ *
+ * var_dump($cron->matchWithMargin(new \DateTime('2012-07-01 12:32:50'), -3, 5));
+ * // bool(true)
+ */
+class Cron
+{
+ public const TYPE_UNDEFINED = '';
+ public const TYPE_MINUTE = 'minute';
+ public const TYPE_HOUR = 'hour';
+ public const TYPE_DAY = 'day';
+ public const TYPE_WEEK = 'week';
+ public const TYPE_MONTH = 'month';
+ public const TYPE_YEAR = 'year';
+ /**
+ *
+ * @var array
+ */
+ protected $texts = [
+ 'fr' => [
+ 'empty' => '-tout-',
+ 'name_minute' => 'minute',
+ 'name_hour' => 'heure',
+ 'name_day' => 'jour',
+ 'name_week' => 'semaine',
+ 'name_month' => 'mois',
+ 'name_year' => 'année',
+ 'text_period' => 'Chaque %s',
+ 'text_mins' => 'à %s minutes',
+ 'text_time' => 'à %02s:%02s',
+ 'text_dow' => 'le %s',
+ 'text_month' => 'de %s',
+ 'text_dom' => 'le %s',
+ 'weekdays' => ['lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche'],
+ 'months' => ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
+ ],
+ 'en' => [
+ 'empty' => '-all-',
+ 'name_minute' => 'minute',
+ 'name_hour' => 'hour',
+ 'name_day' => 'day',
+ 'name_week' => 'week',
+ 'name_month' => 'month',
+ 'name_year' => 'year',
+ 'text_period' => 'Every %s',
+ 'text_mins' => 'at %s minutes past the hour',
+ 'text_time' => 'at %02s:%02s',
+ 'text_dow' => 'on %s',
+ 'text_month' => 'of %s',
+ 'text_dom' => 'on the %s',
+ 'weekdays' => ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'],
+ 'months' => ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'],
+ ],
+ ];
+
+ /**
+ * min hour dom month dow
+ * @var string
+ */
+ protected $cron = '';
+ /**
+ *
+ * @var array
+ */
+ protected $minutes = [];
+ /**
+ *
+ * @var array
+ */
+ protected $hours = [];
+ /**
+ *
+ * @var array
+ */
+ protected $months = [];
+ /**
+ * 0-7 : sunday, monday, ... saturday, sunday
+ * @var array
+ */
+ protected $dow = [];
+ /**
+ *
+ * @var array
+ */
+ protected $dom = [];
+
+ /**
+ *
+ * @param string|null $cron
+ */
+ public function __construct($cron = null)
+ {
+ if (null !== $cron) {
+ $this->setCron($cron);
+ }
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function getCron()
+ {
+ return implode(' ', [
+ $this->getCronMinutes(),
+ $this->getCronHours(),
+ $this->getCronDaysOfMonth(),
+ $this->getCronMonths(),
+ $this->getCronDaysOfWeek(),
+ ]);
+ }
+
+ /**
+ *
+ * @param string $lang 'fr' or 'en'
+ * @return string
+ */
+ public function getText($lang)
+ {
+ // check lang
+ if (!isset($this->texts[$lang])) {
+ return $this->getCron();
+ }
+
+ $texts = $this->texts[$lang];
+ // check type
+
+ $type = $this->getType();
+ if ($type === self::TYPE_UNDEFINED) {
+ return $this->getCron();
+ }
+
+ // init
+ $elements = [];
+ $elements[] = sprintf($texts['text_period'], $texts['name_' . $type]);
+
+ // hour
+ if ($type === self::TYPE_HOUR) {
+ $elements[] = sprintf($texts['text_mins'], $this->getCronMinutes());
+ }
+
+ // week
+ if ($type === self::TYPE_WEEK) {
+ $dow = $this->getCronDaysOfWeek();
+ foreach ($texts['weekdays'] as $i => $wd) {
+ $dow = str_replace((string) ($i + 1), $wd, $dow);
+ }
+ $elements[] = sprintf($texts['text_dow'], $dow);
+ }
+
+ // month + year
+ if (\in_array($type, [self::TYPE_MONTH, self::TYPE_YEAR], true)) {
+ $elements[] = sprintf($texts['text_dom'], $this->getCronDaysOfMonth());
+ }
+
+ // year
+ if ($type === self::TYPE_YEAR) {
+ $months = $this->getCronMonths();
+ for ($i = count($texts['months']) - 1; $i >= 0; $i--) {
+ $months = str_replace((string) ($i + 1), $texts['months'][$i], $months);
+ }
+ $elements[] = sprintf($texts['text_month'], $months);
+ }
+
+ // day + week + month + year
+ if (\in_array($type, [self::TYPE_DAY, self::TYPE_WEEK, self::TYPE_MONTH, self::TYPE_YEAR], true)) {
+ $elements[] = sprintf($texts['text_time'], $this->getCronHours(), $this->getCronMinutes());
+ }
+
+ return str_replace('*', $texts['empty'], implode(' ', $elements));
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ $mask = preg_replace('/[^\* ]/', '-', $this->getCron());
+ $mask = preg_replace('/-+/', '-', $mask);
+ $mask = preg_replace('/[^-\*]/', '', $mask);
+
+ if ($mask === '*****') {
+ return self::TYPE_MINUTE;
+ }
+
+ if ($mask === '-****') {
+ return self::TYPE_HOUR;
+ }
+
+ if (substr($mask, -3) === '***') {
+ return self::TYPE_DAY;
+ }
+
+ if (substr($mask, -3) === '-**') {
+ return self::TYPE_MONTH;
+ }
+
+ if (substr($mask, -3) === '**-') {
+ return self::TYPE_WEEK;
+ }
+
+ if (substr($mask, -2) === '-*') {
+ return self::TYPE_YEAR;
+ }
+
+ return self::TYPE_UNDEFINED;
+ }
+
+ /**
+ *
+ * @param string $cron
+ * @return Cron
+ */
+ public function setCron($cron)
+ {
+ // sanitize
+ $cron = trim($cron);
+ $cron = preg_replace('/\s+/', ' ', $cron);
+ // explode
+ $elements = explode(' ', $cron);
+ if (\count($elements) !== 5) {
+ throw new \RuntimeException('Bad number of elements');
+ }
+
+ $this->cron = $cron;
+ $this->setMinutes($elements[0]);
+ $this->setHours($elements[1]);
+ $this->setDaysOfMonth($elements[2]);
+ $this->setMonths($elements[3]);
+ $this->setDaysOfWeek($elements[4]);
+
+ return $this;
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function getCronMinutes()
+ {
+ return $this->arrayToCron($this->minutes);
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function getCronHours()
+ {
+ return $this->arrayToCron($this->hours);
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function getCronDaysOfMonth()
+ {
+ return $this->arrayToCron($this->dom);
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function getCronMonths()
+ {
+ return $this->arrayToCron($this->months);
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function getCronDaysOfWeek()
+ {
+ return $this->arrayToCron($this->dow);
+ }
+
+ /**
+ *
+ * @return array
+ */
+ public function getMinutes()
+ {
+ return $this->minutes;
+ }
+
+ /**
+ *
+ * @return array
+ */
+ public function getHours()
+ {
+ return $this->hours;
+ }
+
+ /**
+ *
+ * @return array
+ */
+ public function getDaysOfMonth()
+ {
+ return $this->dom;
+ }
+
+ /**
+ *
+ * @return array
+ */
+ public function getMonths()
+ {
+ return $this->months;
+ }
+
+ /**
+ *
+ * @return array
+ */
+ public function getDaysOfWeek()
+ {
+ return $this->dow;
+ }
+
+ /**
+ *
+ * @param string|array $minutes
+ * @return Cron
+ */
+ public function setMinutes($minutes)
+ {
+ $this->minutes = $this->cronToArray($minutes, 0, 59);
+
+ return $this;
+ }
+
+ /**
+ *
+ * @param string|array $hours
+ * @return Cron
+ */
+ public function setHours($hours)
+ {
+ $this->hours = $this->cronToArray($hours, 0, 23);
+
+ return $this;
+ }
+
+ /**
+ *
+ * @param string|array $months
+ * @return Cron
+ */
+ public function setMonths($months)
+ {
+ $this->months = $this->cronToArray($months, 1, 12);
+
+ return $this;
+ }
+
+ /**
+ *
+ * @param string|array $dow
+ * @return Cron
+ */
+ public function setDaysOfWeek($dow)
+ {
+ $this->dow = $this->cronToArray($dow, 0, 7);
+
+ return $this;
+ }
+
+ /**
+ *
+ * @param string|array $dom
+ * @return Cron
+ */
+ public function setDaysOfMonth($dom)
+ {
+ $this->dom = $this->cronToArray($dom, 1, 31);
+
+ return $this;
+ }
+
+ /**
+ *
+ * @param mixed $date
+ * @param int $min
+ * @param int $hour
+ * @param int $day
+ * @param int $month
+ * @param int $weekday
+ * @return \DateTime
+ */
+ protected function parseDate($date, &$min, &$hour, &$day, &$month, &$weekday)
+ {
+ if (is_numeric($date) && (int)$date == $date) {
+ $date = new \DateTime('@' . $date);
+ }
+ elseif (is_string($date)) {
+ $date = new \DateTime('@' . strtotime($date));
+ }
+ if ($date instanceof \DateTime) {
+ $min = (int)$date->format('i');
+ $hour = (int)$date->format('H');
+ $day = (int)$date->format('d');
+ $month = (int)$date->format('m');
+ $weekday = (int)$date->format('w'); // 0-6
+ }
+ else {
+ throw new \RuntimeException('Date format not supported');
+ }
+
+ return new \DateTime($date->format('Y-m-d H:i:sP'));
+ }
+
+ /**
+ *
+ * @param int|string|\DateTime $date
+ */
+ public function matchExact($date)
+ {
+ $date = $this->parseDate($date, $min, $hour, $day, $month, $weekday);
+
+ return
+ (empty($this->minutes) || \in_array($min, $this->minutes, true)) &&
+ (empty($this->hours) || \in_array($hour, $this->hours, true)) &&
+ (empty($this->dom) || \in_array($day, $this->dom, true)) &&
+ (empty($this->months) || \in_array($month, $this->months, true)) &&
+ (empty($this->dow) || \in_array($weekday, $this->dow, true) || ($weekday == 0 && \in_array(7, $this->dow, true)) || ($weekday == 7 && \in_array(0, $this->dow, true))
+ );
+ }
+
+ /**
+ *
+ * @param int|string|\DateTime $date
+ * @param int $minuteBefore
+ * @param int $minuteAfter
+ */
+ public function matchWithMargin($date, $minuteBefore = 0, $minuteAfter = 0)
+ {
+ if ($minuteBefore > 0) {
+ throw new \RuntimeException('MinuteBefore parameter cannot be positive !');
+ }
+ if ($minuteAfter < 0) {
+ throw new \RuntimeException('MinuteAfter parameter cannot be negative !');
+ }
+
+ $date = $this->parseDate($date, $min, $hour, $day, $month, $weekday);
+ $interval = new \DateInterval('PT1M'); // 1 min
+ if ($minuteBefore !== 0) {
+ $date->sub(new \DateInterval('PT' . abs($minuteBefore) . 'M'));
+ }
+ $n = $minuteAfter - $minuteBefore + 1;
+ for ($i = 0; $i < $n; $i++) {
+ if ($this->matchExact($date)) {
+ return true;
+ }
+ $date->add($interval);
+ }
+
+ return false;
+ }
+
+ /**
+ *
+ * @param array $array
+ * @return string
+ */
+ protected function arrayToCron($array)
+ {
+ $n = \count($array);
+ if (!\is_array($array) || $n === 0) {
+ return '*';
+ }
+
+ $cron = [$array[0]];
+ $s = $c = $array[0];
+ for ($i = 1; $i < $n; $i++) {
+ if ($array[$i] == $c + 1) {
+ $c = $array[$i];
+ $cron[\count($cron) - 1] = $s . '-' . $c;
+ }
+ else {
+ $s = $c = $array[$i];
+ $cron[] = $c;
+ }
+ }
+
+ return implode(',', $cron);
+ }
+
+ /**
+ *
+ * @param array|string $string
+ * @param int $min
+ * @param int $max
+ * @return array
+ */
+ protected function cronToArray($string, $min, $max)
+ {
+ $array = [];
+ if (\is_array($string)) {
+ foreach ($string as $val) {
+ if (is_numeric($val) && (int)$val == $val && $val >= $min && $val <= $max) {
+ $array[] = (int)$val;
+ }
+ }
+ } elseif ($string !== '*') {
+ while ($string !== '') {
+ // test "*/n" expression
+ if (preg_match('/^\*\/([0-9]+),?/', $string, $m)) {
+ for ($i = max(0, $min); $i <= min(59, $max); $i += $m[1]) {
+ $array[] = (int)$i;
+ }
+ $string = substr($string, strlen($m[0]));
+ continue;
+ }
+ // test "a-b/n" expression
+ if (preg_match('/^([0-9]+)-([0-9]+)\/([0-9]+),?/', $string, $m)) {
+ for ($i = max($m[1], $min); $i <= min($m[2], $max); $i += $m[3]) {
+ $array[] = (int)$i;
+ }
+ $string = substr($string, strlen($m[0]));
+ continue;
+ }
+ // test "a-b" expression
+ if (preg_match('/^([0-9]+)-([0-9]+),?/', $string, $m)) {
+ for ($i = max($m[1], $min); $i <= min($m[2], $max); $i++) {
+ $array[] = (int)$i;
+ }
+ $string = substr($string, strlen($m[0]));
+ continue;
+ }
+ // test "c" expression
+ if (preg_match('/^([0-9]+),?/', $string, $m)) {
+ if ($m[1] >= $min && $m[1] <= $max) {
+ $array[] = (int)$m[1];
+ }
+ $string = substr($string, strlen($m[0]));
+ continue;
+ }
+
+ // something goes wrong in the expression
+ return [];
+ }
+ }
+ sort($array);
+
+ return $array;
+ }
+}
diff --git a/system/src/Grav/Common/Scheduler/IntervalTrait.php b/system/src/Grav/Common/Scheduler/IntervalTrait.php
new file mode 100644
index 0000000..b382c9d
--- /dev/null
+++ b/system/src/Grav/Common/Scheduler/IntervalTrait.php
@@ -0,0 +1,399 @@
+at = $expression;
+ $this->executionTime = CronExpression::factory($expression);
+
+ return $this;
+ }
+
+ /**
+ * Set the execution time to every minute.
+ *
+ * @return self
+ */
+ public function everyMinute()
+ {
+ return $this->at('* * * * *');
+ }
+
+ /**
+ * Set the execution time to every hour.
+ *
+ * @param int|string $minute
+ * @return self
+ */
+ public function hourly($minute = 0)
+ {
+ $c = $this->validateCronSequence($minute);
+
+ return $this->at("{$c['minute']} * * * *");
+ }
+
+ /**
+ * Set the execution time to once a day.
+ *
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function daily($hour = 0, $minute = 0)
+ {
+ if (\is_string($hour)) {
+ $parts = explode(':', $hour);
+ $hour = $parts[0];
+ $minute = $parts[1] ?? '0';
+ }
+ $c = $this->validateCronSequence($minute, $hour);
+
+ return $this->at("{$c['minute']} {$c['hour']} * * *");
+ }
+
+ /**
+ * Set the execution time to once a week.
+ *
+ * @param int|string $weekday
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function weekly($weekday = 0, $hour = 0, $minute = 0)
+ {
+ if (\is_string($hour)) {
+ $parts = explode(':', $hour);
+ $hour = $parts[0];
+ $minute = $parts[1] ?? '0';
+ }
+ $c = $this->validateCronSequence($minute, $hour, null, null, $weekday);
+
+ return $this->at("{$c['minute']} {$c['hour']} * * {$c['weekday']}");
+ }
+
+ /**
+ * Set the execution time to once a month.
+ *
+ * @param int|string $month
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function monthly($month = '*', $day = 1, $hour = 0, $minute = 0)
+ {
+ if (\is_string($hour)) {
+ $parts = explode(':', $hour);
+ $hour = $parts[0];
+ $minute = $parts[1] ?? '0';
+ }
+ $c = $this->validateCronSequence($minute, $hour, $day, $month);
+
+ return $this->at("{$c['minute']} {$c['hour']} {$c['day']} {$c['month']} *");
+ }
+
+ /**
+ * Set the execution time to every Sunday.
+ *
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function sunday($hour = 0, $minute = 0)
+ {
+ return $this->weekly(0, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every Monday.
+ *
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function monday($hour = 0, $minute = 0)
+ {
+ return $this->weekly(1, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every Tuesday.
+ *
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function tuesday($hour = 0, $minute = 0)
+ {
+ return $this->weekly(2, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every Wednesday.
+ *
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function wednesday($hour = 0, $minute = 0)
+ {
+ return $this->weekly(3, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every Thursday.
+ *
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function thursday($hour = 0, $minute = 0)
+ {
+ return $this->weekly(4, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every Friday.
+ *
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function friday($hour = 0, $minute = 0)
+ {
+ return $this->weekly(5, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every Saturday.
+ *
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function saturday($hour = 0, $minute = 0)
+ {
+ return $this->weekly(6, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every January.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function january($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(1, $day, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every February.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function february($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(2, $day, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every March.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function march($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(3, $day, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every April.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function april($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(4, $day, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every May.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function may($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(5, $day, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every June.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function june($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(6, $day, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every July.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function july($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(7, $day, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every August.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function august($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(8, $day, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every September.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function september($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(9, $day, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every October.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function october($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(10, $day, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every November.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function november($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(11, $day, $hour, $minute);
+ }
+
+ /**
+ * Set the execution time to every December.
+ *
+ * @param int|string $day
+ * @param int|string $hour
+ * @param int|string $minute
+ * @return self
+ */
+ public function december($day = 1, $hour = 0, $minute = 0)
+ {
+ return $this->monthly(12, $day, $hour, $minute);
+ }
+
+ /**
+ * Validate sequence of cron expression.
+ *
+ * @param int|string $minute
+ * @param int|string $hour
+ * @param int|string $day
+ * @param int|string $month
+ * @param int|string $weekday
+ * @return array
+ */
+ private function validateCronSequence($minute = null, $hour = null, $day = null, $month = null, $weekday = null)
+ {
+ return [
+ 'minute' => $this->validateCronRange($minute, 0, 59),
+ 'hour' => $this->validateCronRange($hour, 0, 23),
+ 'day' => $this->validateCronRange($day, 1, 31),
+ 'month' => $this->validateCronRange($month, 1, 12),
+ 'weekday' => $this->validateCronRange($weekday, 0, 6),
+ ];
+ }
+
+ /**
+ * Validate sequence of cron expression.
+ *
+ * @param int|string $value
+ * @param int $min
+ * @param int $max
+ * @return mixed
+ */
+ private function validateCronRange($value, $min, $max)
+ {
+ if ($value === null || $value === '*') {
+ return '*';
+ }
+
+ if (! is_numeric($value) ||
+ ! ($value >= $min && $value <= $max)
+ ) {
+ throw new \InvalidArgumentException(
+ "Invalid value: it should be '*' or between {$min} and {$max}."
+ );
+ }
+
+ return $value;
+ }
+}
+
diff --git a/system/src/Grav/Common/Scheduler/Job.php b/system/src/Grav/Common/Scheduler/Job.php
new file mode 100644
index 0000000..6250f1d
--- /dev/null
+++ b/system/src/Grav/Common/Scheduler/Job.php
@@ -0,0 +1,522 @@
+id = Grav::instance()['inflector']->hyphenize($id);
+ } else {
+ if (is_string($command)) {
+ $this->id = md5($command);
+ } else {
+ /* @var object $command */
+ $this->id = spl_object_hash($command);
+ }
+ }
+ $this->creationTime = new \DateTime('now');
+ // initialize the directory path for lock files
+ $this->tempDir = sys_get_temp_dir();
+ $this->command = $command;
+ $this->args = $args;
+ // Set enabled state
+ $status = Grav::instance()['config']->get('scheduler.status');
+ $this->enabled = !(isset($status[$id]) && $status[$id] === 'disabled');
+ }
+
+ /**
+ * Get the command
+ *
+ * @return string
+ */
+ public function getCommand()
+ {
+ return $this->command;
+ }
+
+ /**
+ * Get the cron 'at' syntax for this job
+ *
+ * @return string
+ */
+ public function getAt()
+ {
+ return $this->at;
+ }
+
+ /**
+ * Get the status of this job
+ *
+ * @return bool
+ */
+ public function getEnabled()
+ {
+ return $this->enabled;
+ }
+
+ /**
+ * Get optional arguments
+ *
+ * @return string|null
+ */
+ public function getArguments()
+ {
+ if (\is_string($this->args)) {
+ return $this->args;
+ }
+
+ return null;
+ }
+
+ public function getCronExpression()
+ {
+ return CronExpression::factory($this->at);
+ }
+
+ /**
+ * Get the status of the last run for this job
+ *
+ * @return bool
+ */
+ public function isSuccessful()
+ {
+ return $this->successful;
+ }
+
+ /**
+ * Get the Job id.
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Check if the Job is due to run.
+ * It accepts as input a DateTime used to check if
+ * the job is due. Defaults to job creation time.
+ * It also default the execution time if not previously defined.
+ *
+ * @param \DateTime $date
+ * @return bool
+ */
+ public function isDue(\DateTime $date = null)
+ {
+ // The execution time is being defaulted if not defined
+ if (!$this->executionTime) {
+ $this->at('* * * * *');
+ }
+
+ $date = $date ?? $this->creationTime;
+
+ return $this->executionTime->isDue($date);
+ }
+
+ /**
+ * Check if the Job is overlapping.
+ *
+ * @return bool
+ */
+ public function isOverlapping()
+ {
+ return $this->lockFile &&
+ file_exists($this->lockFile) &&
+ call_user_func($this->whenOverlapping, filemtime($this->lockFile)) === false;
+ }
+
+ /**
+ * Force the Job to run in foreground.
+ *
+ * @return $this
+ */
+ public function inForeground()
+ {
+ $this->runInBackground = false;
+
+ return $this;
+ }
+
+ /**
+ * Sets/Gets an option backlink
+ *
+ * @param string $link
+ *
+ * @return null|string
+ */
+ public function backlink($link = null)
+ {
+ if ($link) {
+ $this->backlink = $link;
+ }
+ return $this->backlink;
+ }
+
+
+ /**
+ * Check if the Job can run in background.
+ *
+ * @return bool
+ */
+ public function runInBackground()
+ {
+ return !(is_callable($this->command) || $this->runInBackground === false);
+ }
+
+ /**
+ * This will prevent the Job from overlapping.
+ * It prevents another instance of the same Job of
+ * being executed if the previous is still running.
+ * The job id is used as a filename for the lock file.
+ *
+ * @param string $tempDir The directory path for the lock files
+ * @param callable $whenOverlapping A callback to ignore job overlapping
+ * @return self
+ */
+ public function onlyOne($tempDir = null, callable $whenOverlapping = null)
+ {
+ if ($tempDir === null || !is_dir($tempDir)) {
+ $tempDir = $this->tempDir;
+ }
+ $this->lockFile = implode('/', [
+ trim($tempDir),
+ trim($this->id) . '.lock',
+ ]);
+ if ($whenOverlapping) {
+ $this->whenOverlapping = $whenOverlapping;
+ } else {
+ $this->whenOverlapping = function () {
+ return false;
+ };
+ }
+
+ return $this;
+ }
+
+ /**
+ * Configure the job.
+ *
+ * @param array $config
+ * @return self
+ */
+ public function configure(array $config = [])
+ {
+ // Check if config has defined a tempDir
+ if (isset($config['tempDir']) && is_dir($config['tempDir'])) {
+ $this->tempDir = $config['tempDir'];
+ }
+
+ return $this;
+ }
+
+ /**
+ * Truth test to define if the job should run if due.
+ *
+ * @param callable $fn
+ * @return self
+ */
+ public function when(callable $fn)
+ {
+ $this->truthTest = $fn();
+
+ return $this;
+ }
+
+ /**
+ * Run the job.
+ *
+ * @return bool
+ */
+ public function run()
+ {
+ // If the truthTest failed, don't run
+ if ($this->truthTest !== true) {
+ return false;
+ }
+
+ // If overlapping, don't run
+ if ($this->isOverlapping()) {
+ return false;
+ }
+
+ // Write lock file if necessary
+ $this->createLockFile();
+
+ // Call before if required
+ if (is_callable($this->before)) {
+ call_user_func($this->before);
+ }
+
+ // If command is callable...
+ if (is_callable($this->command)) {
+ $this->output = $this->exec();
+ } else {
+ $args = \is_string($this->args) ? $this->args : implode(' ', $this->args);
+ $command = $this->command . ' ' . $args;
+ $process = new Process($command);
+
+ $this->process = $process;
+
+ if ($this->runInBackground()) {
+ $process->start();
+ } else {
+ $process->run();
+ $this->finalize();
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Finish up processing the job
+ *
+ * @return void
+ */
+ public function finalize()
+ {
+ /** @var Process $process */
+ $process = $this->process;
+
+ if ($process) {
+ $process->wait();
+
+ if ($process->isSuccessful()) {
+ $this->successful = true;
+ $this->output = $process->getOutput();
+ } else {
+ $this->successful = false;
+ $this->output = $process->getErrorOutput();
+ }
+
+ $this->postRun();
+
+ unset($this->process);
+ }
+ }
+
+ /**
+ * Things to run after job has run
+ */
+ private function postRun()
+ {
+ if (count($this->outputTo) > 0) {
+ foreach ($this->outputTo as $file) {
+ $output_mode = $this->outputMode === 'append' ? FILE_APPEND | LOCK_EX : LOCK_EX;
+ file_put_contents($file, $this->output, $output_mode);
+ }
+ }
+
+ // Send output to email
+ $this->emailOutput();
+
+ // Call any callback defined
+ if (is_callable($this->after)) {
+ call_user_func($this->after, $this->output, $this->returnCode);
+ }
+
+ $this->removeLockFile();
+ }
+
+ /**
+ * Create the job lock file.
+ *
+ * @param mixed $content
+ * @return void
+ */
+ private function createLockFile($content = null)
+ {
+ if ($this->lockFile) {
+ if ($content === null || !\is_string($content)) {
+ $content = $this->getId();
+ }
+ file_put_contents($this->lockFile, $content);
+ }
+ }
+
+ /**
+ * Remove the job lock file.
+ *
+ * @return void
+ */
+ private function removeLockFile()
+ {
+ if ($this->lockFile && file_exists($this->lockFile)) {
+ unlink($this->lockFile);
+ }
+ }
+
+ /**
+ * Execute a callable job.
+ *
+ * @throws \RuntimeException
+ * @return string
+ */
+ private function exec()
+ {
+ $return_data = '';
+ ob_start();
+ try {
+ $return_data = call_user_func_array($this->command, $this->args);
+ $this->successful = true;
+ } catch (\RuntimeException $e) {
+ $this->successful = false;
+ }
+ $this->output = ob_get_clean() . (is_string($return_data) ? $return_data : '');
+
+ $this->postRun();
+ }
+
+ /**
+ * Set the file/s where to write the output of the job.
+ *
+ * @param string|array $filename
+ * @param bool $append
+ * @return self
+ */
+ public function output($filename, $append = false)
+ {
+ $this->outputTo = is_array($filename) ? $filename : [$filename];
+ $this->outputMode = $append === false ? 'overwrite' : 'append';
+
+ return $this;
+ }
+
+ /**
+ * Get the job output.
+ *
+ * @return mixed
+ */
+ public function getOutput()
+ {
+ return $this->output;
+ }
+
+ /**
+ * Set the emails where the output should be sent to.
+ * The Job should be set to write output to a file
+ * for this to work.
+ *
+ * @param string|array $email
+ * @return self
+ */
+ public function email($email)
+ {
+ if (!is_string($email) && !is_array($email)) {
+ throw new \InvalidArgumentException('The email can be only string or array');
+ }
+
+ $this->emailTo = is_array($email) ? $email : [$email];
+ // Force the job to run in foreground
+ $this->inForeground();
+
+ return $this;
+ }
+
+ /**
+ * Email the output of the job, if any.
+ *
+ * @return bool
+ */
+ private function emailOutput()
+ {
+ if (!count($this->outputTo) || !count($this->emailTo)) {
+ return false;
+ }
+
+ if (is_callable('Grav\Plugin\Email\Utils::sendEmail')) {
+ $subject ='Grav Scheduled Job [' . $this->getId() . ']';
+ $content = "Output from Job ID: {$this->getId()} \nCommand: {$this->getCommand()} \n".$this->getOutput()."\n ";
+ $to = $this->emailTo;
+
+ \Grav\Plugin\Email\Utils::sendEmail($subject, $content, $to);
+ }
+
+ return true;
+ }
+
+ /**
+ * Set function to be called before job execution
+ * Job object is injected as a parameter to callable function.
+ *
+ * @param callable $fn
+ * @return self
+ */
+ public function before(callable $fn)
+ {
+ $this->before = $fn;
+
+ return $this;
+ }
+
+ /**
+ * Set a function to be called after job execution.
+ * By default this will force the job to run in foreground
+ * because the output is injected as a parameter of this
+ * function, but it could be avoided by passing true as a
+ * second parameter. The job will run in background if it
+ * meets all the other criteria.
+ *
+ * @param callable $fn
+ * @param bool $runInBackground
+ * @return self
+ */
+ public function then(callable $fn, $runInBackground = false)
+ {
+ $this->after = $fn;
+ // Force the job to run in foreground
+ if ($runInBackground === false) {
+ $this->inForeground();
+ }
+
+ return $this;
+ }
+}
+
diff --git a/system/src/Grav/Common/Scheduler/Scheduler.php b/system/src/Grav/Common/Scheduler/Scheduler.php
new file mode 100644
index 0000000..df5602e
--- /dev/null
+++ b/system/src/Grav/Common/Scheduler/Scheduler.php
@@ -0,0 +1,361 @@
+get('scheduler.defaults', []);
+ $this->config = $config;
+
+ $this->status_path = Grav::instance()['locator']->findResource('user-data://scheduler', true, true);
+ if (!file_exists($this->status_path)) {
+ Folder::create($this->status_path);
+ }
+
+ }
+
+ /**
+ * Load saved jobs from config/scheduler.yaml file
+ */
+ public function loadSavedJobs()
+ {
+ $this->saved_jobs = [];
+ $saved_jobs = (array) Grav::instance()['config']->get('scheduler.custom_jobs', []);
+
+ foreach ($saved_jobs as $id => $j) {
+ $args = $j['args'] ?? [];
+ $id = Grav::instance()['inflector']->hyphenize($id);
+ $job = $this->addCommand($j['command'], $args, $id);
+
+ if (isset($j['at'])) {
+ $job->at($j['at']);
+ }
+
+ if (isset($j['output'])) {
+ $mode = isset($j['output_mode']) && $j['output_mode'] === 'append' ? true : false;
+ $job->output($j['output'], $mode);
+ }
+
+ if (isset($j['email'])) {
+ $job->email($j['email']);
+ }
+
+ // store in saved_jobs
+ $this->saved_jobs[] = $job;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get the queued jobs as background/foreground
+ *
+ * @param bool $all
+ * @return array
+ */
+ public function getQueuedJobs($all = false)
+ {
+ $background = [];
+ $foreground = [];
+ foreach ($this->jobs as $job) {
+ if ($all || $job->getEnabled()) {
+ if ($job->runInBackground()) {
+ $background[] = $job;
+ } else {
+ $foreground[] = $job;
+ }
+ }
+
+ }
+ return [$background, $foreground];
+ }
+
+ /**
+ * Get all jobs if they are disabled or not as one array
+ *
+ * @return array
+ */
+ public function getAllJobs()
+ {
+ list($background, $foreground) = $this->loadSavedJobs()->getQueuedJobs(true);
+
+ return array_merge($background, $foreground);
+ }
+
+ /**
+ * Queues a PHP function execution.
+ *
+ * @param callable $fn The function to execute
+ * @param array $args Optional arguments to pass to the php script
+ * @param string $id Optional custom identifier
+ * @return Job
+ */
+ public function addFunction(callable $fn, $args = [], $id = null)
+ {
+ $job = new Job($fn, $args, $id);
+ $this->queueJob($job->configure($this->config));
+
+ return $job;
+ }
+
+ /**
+ * Queue a raw shell command.
+ *
+ * @param string $command The command to execute
+ * @param array $args Optional arguments to pass to the command
+ * @param string $id Optional custom identifier
+ * @return Job
+ */
+ public function addCommand($command, $args = [], $id = null)
+ {
+ $job = new Job($command, $args, $id);
+ $this->queueJob($job->configure($this->config));
+
+ return $job;
+ }
+
+ /**
+ * Run the scheduler.
+ *
+ * @param \DateTime|null $runTime Optional, run at specific moment
+ */
+ public function run(\DateTime $runTime = null)
+ {
+ $this->loadSavedJobs();
+
+ list($background, $foreground) = $this->getQueuedJobs(false);
+ $alljobs = array_merge($background, $foreground);
+
+ if (null === $runTime) {
+ $runTime = new \DateTime('now');
+ }
+
+ // Star processing jobs
+ foreach ($alljobs as $job) {
+ if ($job->isDue($runTime)) {
+ $job->run();
+ $this->jobs_run[] = $job;
+ }
+ }
+
+ // Finish handling any background jobs
+ foreach($background as $job) {
+ $job->finalize();
+ }
+
+ // Store states
+ $this->saveJobStates();
+ }
+
+ /**
+ * Reset all collected data of last run.
+ *
+ * Call before run() if you call run() multiple times.
+ */
+ public function resetRun()
+ {
+ // Reset collected data of last run
+ $this->executed_jobs = [];
+ $this->failed_jobs = [];
+ $this->output_schedule = [];
+
+ return $this;
+ }
+
+ /**
+ * Get the scheduler verbose output.
+ *
+ * @param string $type Allowed: text, html, array
+ * @return mixed The return depends on the requested $type
+ */
+ public function getVerboseOutput($type = 'text')
+ {
+ switch ($type) {
+ case 'text':
+ return implode("\n", $this->output_schedule);
+ case 'html':
+ return implode(' ', $this->output_schedule);
+ case 'array':
+ return $this->output_schedule;
+ default:
+ throw new \InvalidArgumentException('Invalid output type');
+ }
+ }
+
+ /**
+ * Remove all queued Jobs.
+ */
+ public function clearJobs()
+ {
+ $this->jobs = [];
+
+ return $this;
+ }
+
+ /**
+ * Helper to get the full Cron command
+ *
+ * @return string
+ */
+ public function getCronCommand()
+ {
+ $phpBinaryFinder = new PhpExecutableFinder();
+ $php = $phpBinaryFinder->find();
+ $command = 'cd ' . str_replace(' ', '\ ', GRAV_ROOT) . ';' . $php . ' bin/grav scheduler';
+
+ return "(crontab -l; echo \"* * * * * {$command} 1>> /dev/null 2>&1\") | crontab -";
+ }
+
+ /**
+ * Helper to determine if cron job is setup
+ *
+ * @return int
+ */
+ public function isCrontabSetup()
+ {
+ $process = new Process('crontab -l');
+ $process->run();
+
+ if ($process->isSuccessful()) {
+ $output = $process->getOutput();
+
+ return preg_match('$bin\/grav schedule$', $output) ? 1 : 0;
+ }
+
+ $error = $process->getErrorOutput();
+
+ return Utils::startsWith($error, 'crontab: no crontab') ? 0 : 2;
+ }
+
+ /**
+ * Get the Job states file
+ *
+ * @return \RocketTheme\Toolbox\File\FileInterface|YamlFile
+ */
+ public function getJobStates()
+ {
+ return YamlFile::instance($this->status_path . '/status.yaml');
+ }
+
+ /**
+ * Save job states to statys file
+ */
+ private function saveJobStates()
+ {
+ $now = time();
+ $new_states = [];
+
+ foreach ($this->jobs_run as $job) {
+ if ($job->isSuccessful()) {
+ $new_states[$job->getId()] = ['state' => 'success', 'last-run' => $now];
+ $this->pushExecutedJob($job);
+ } else {
+ $new_states[$job->getId()] = ['state' => 'failure', 'last-run' => $now, 'error' => $job->getOutput()];
+ $this->pushFailedJob($job);
+ }
+ }
+
+ $saved_states = $this->getJobStates();
+ $saved_states->save(array_merge($saved_states->content(), $new_states));
+ }
+
+ /**
+ * Queue a job for execution in the correct queue.
+ *
+ * @param Job $job
+ * @return void
+ */
+ private function queueJob(Job $job)
+ {
+ $this->jobs[] = $job;
+
+ // Store jobs
+ }
+
+ /**
+ * Add an entry to the scheduler verbose output array.
+ *
+ * @param string $string
+ * @return void
+ */
+ private function addSchedulerVerboseOutput($string)
+ {
+ $now = '[' . (new \DateTime('now'))->format('c') . '] ';
+ $this->output_schedule[] = $now . $string;
+ // Print to stdoutput in light gray
+ // echo "\033[37m{$string}\033[0m\n";
+ }
+
+ /**
+ * Push a succesfully executed job.
+ *
+ * @param Job $job
+ * @return Job
+ */
+ private function pushExecutedJob(Job $job)
+ {
+ $this->executed_jobs[] = $job;
+ $command = $job->getCommand();
+ $args = $job->getArguments();
+ // If callable, log the string Closure
+ if (is_callable($command)) {
+ $command = \is_string($command) ? $command : 'Closure';
+ }
+ $this->addSchedulerVerboseOutput("Success : {$command} {$args} ");
+
+ return $job;
+ }
+
+ /**
+ * Push a failed job.
+ *
+ * @param Job $job
+ * @return Job
+ */
+ private function pushFailedJob(Job $job)
+ {
+ $this->failed_jobs[] = $job;
+ $command = $job->getCommand();
+ // If callable, log the string Closure
+ if (is_callable($command)) {
+ $command = \is_string($command) ? $command : 'Closure';
+ }
+ $output = trim($job->getOutput());
+ $this->addSchedulerVerboseOutput("Error : {$command} → {$output} ");
+
+ return $job;
+ }
+}
diff --git a/system/src/Grav/Common/Security.php b/system/src/Grav/Common/Security.php
new file mode 100644
index 0000000..0f61097
--- /dev/null
+++ b/system/src/Grav/Common/Security.php
@@ -0,0 +1,165 @@
+routes();
+
+ // Remove duplicate for homepage
+ unset($routes['/']);
+
+ $list = [];
+
+ // This needs Symfony 4.1 to work
+ $status && $status([
+ 'type' => 'count',
+ 'steps' => count($routes),
+ ]);
+
+ foreach ($routes as $path) {
+
+ $status && $status([
+ 'type' => 'progress',
+ ]);
+
+ try {
+ $page = $pages->get($path);
+
+ // call the content to load/cache it
+ $header = (array) $page->header();
+ $content = $page->value('content');
+
+ $data = ['header' => $header, 'content' => $content];
+ $results = Security::detectXssFromArray($data);
+
+ if (!empty($results)) {
+ if ($route) {
+ $list[$page->route()] = $results;
+ } else {
+ $list[$page->filePathClean()] = $results;
+ }
+
+ }
+
+ } catch (\Exception $e) {
+ continue;
+ }
+ }
+
+ return $list;
+ }
+
+ /**
+ * @param array $array Array such as $_POST or $_GET
+ * @param string $prefix Prefix for returned values.
+ * @return array Returns flatten list of potentially dangerous input values, such as 'data.content'.
+ */
+ public static function detectXssFromArray(array $array, $prefix = '')
+ {
+ $list = [];
+
+ foreach ($array as $key => $value) {
+ if (\is_array($value)) {
+ $list[] = static::detectXssFromArray($value, $prefix . $key . '.');
+ }
+ if ($result = static::detectXss($value)) {
+ $list[] = [$prefix . $key => $result];
+ }
+ }
+
+ if (!empty($list)) {
+ return array_merge(...$list);
+ }
+
+ return $list;
+ }
+
+ /**
+ * Determine if string potentially has a XSS attack. This simple function does not catch all XSS and it is likely to
+ * return false positives because of it tags all potentially dangerous HTML tags and attributes without looking into
+ * their content.
+ *
+ * @param string $string The string to run XSS detection logic on
+ * @return bool|string Type of XSS vector if the given `$string` may contain XSS, false otherwise.
+ *
+ * Copies the code from: https://github.com/symphonycms/xssfilter/blob/master/extension.driver.php#L138
+ */
+ public static function detectXss($string)
+ {
+ // Skip any null or non string values
+ if (null === $string || !\is_string($string) || empty($string)) {
+ return false;
+ }
+
+ // Keep a copy of the original string before cleaning up
+ $orig = $string;
+
+ // URL decode
+ $string = urldecode($string);
+
+ // Convert Hexadecimals
+ $string = (string)preg_replace_callback('!(|\\\)[xX]([0-9a-fA-F]+);?!u', function($m) {
+ return \chr(hexdec($m[2]));
+ }, $string);
+
+ // Clean up entities
+ $string = preg_replace('!(+[0-9]+)!u','$1;', $string);
+
+ // Decode entities
+ $string = html_entity_decode($string, ENT_NOQUOTES, 'UTF-8');
+
+ // Strip whitespace characters
+ $string = preg_replace('!\s!u','', $string);
+
+ $config = Grav::instance()['config'];
+
+ $dangerous_tags = array_map('preg_quote', array_map("trim", $config->get('security.xss_dangerous_tags')));
+ $invalid_protocols = array_map('preg_quote', array_map("trim", $config->get('security.xss_invalid_protocols')));
+ $enabled_rules = $config->get('security.xss_enabled');
+
+ // Set the patterns we'll test against
+ $patterns = [
+ // Match any attribute starting with "on" or xmlns
+ 'on_events' => '#(<[^>]+[[a-z\x00-\x20\"\'\/])(\son|\sxmlns)[a-z].*=>?#iUu',
+
+ // Match javascript:, livescript:, vbscript:, mocha:, feed: and data: protocols
+ 'invalid_protocols' => '#(' . implode('|', $invalid_protocols) . '):.*?#iUu',
+
+ // Match -moz-bindings
+ 'moz_binding' => '#-moz-binding[a-z\x00-\x20]*:#u',
+
+ // Match style attributes
+ 'html_inline_styles' => '#(<[^>]+[a-z\x00-\x20\"\'\/])(style=[^>]*(url\:|x\:expression).*)>?#iUu',
+
+ // Match potentially dangerous tags
+ 'dangerous_tags' => '#*(' . implode('|', $dangerous_tags) . ')[^>]*>?#ui'
+ ];
+
+
+ // Iterate over rules and return label if fail
+ foreach ((array) $patterns as $name => $regex) {
+ if ($enabled_rules[$name] === true) {
+
+ if (preg_match($regex, $string) || preg_match($regex, $orig)) {
+ return $name;
+ }
+
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/system/src/Grav/Common/Service/AccountsServiceProvider.php b/system/src/Grav/Common/Service/AccountsServiceProvider.php
new file mode 100644
index 0000000..e0778be
--- /dev/null
+++ b/system/src/Grav/Common/Service/AccountsServiceProvider.php
@@ -0,0 +1,129 @@
+get('system.accounts.type', 'data'));
+ if ($type === 'flex') {
+ /** @var Debugger $debugger */
+ $debugger = $container['debugger'];
+ $debugger->addMessage('User Accounts: Flex Directory');
+ return $this->flexAccounts($container);
+ }
+
+ return $this->dataAccounts($container);
+ };
+
+ $container['users'] = $container->factory(function (Container $container) {
+ user_error('Grav::instance()[\'users\'] is deprecated since Grav 1.6, use Grav::instance()[\'accounts\'] instead', E_USER_DEPRECATED);
+
+ return $container['accounts'];
+ });
+ }
+
+ protected function dataAccounts(Container $container)
+ {
+ if (!defined('GRAV_USER_INSTANCE')) {
+ define('GRAV_USER_INSTANCE', 'DATA');
+ }
+
+ // Use User class for backwards compatibility.
+ return new DataUser\UserCollection(User::class);
+ }
+
+ protected function flexAccounts(Container $container)
+ {
+ if (!defined('GRAV_USER_INSTANCE')) {
+ define('GRAV_USER_INSTANCE', 'FLEX');
+ }
+
+ /** @var Config $config */
+ $config = $container['config'];
+
+ $options = [
+ 'enabled' => true,
+ 'data' => [
+ 'object' => User::class, // Use User class for backwards compatibility.
+ 'collection' => FlexUser\UserCollection::class,
+ 'index' => FlexUser\UserIndex::class,
+ 'storage' => $this->getFlexStorage($config->get('system.accounts.storage', 'file')),
+ 'search' => [
+ 'options' => [
+ 'contains' => 1
+ ],
+ 'fields' => [
+ 'key',
+ 'email'
+ ]
+ ]
+ ]
+ ] + ($config->get('plugins.flex-objects.object') ?: []);
+
+ $directory = new FlexDirectory('accounts', 'blueprints://user/accounts.yaml', $options);
+
+ /** @var EventDispatcher $dispatcher */
+ $dispatcher = $container['events'];
+ $dispatcher->addListener('onFlexInit', function (Event $event) use ($directory) {
+ /** @var Flex $flex */
+ $flex = $event['flex'];
+ $flex->addDirectory($directory);
+ });
+
+ return $directory->getIndex();
+ }
+
+ protected function getFlexStorage($config)
+ {
+ if (\is_array($config)) {
+ return $config;
+ }
+
+ if ($config === 'folder') {
+ return [
+ 'class' => FlexUser\Storage\UserFolderStorage::class,
+ 'options' => [
+ 'formatter' => ['class' => YamlFormatter::class],
+ 'folder' => 'account://',
+ 'pattern' => '{FOLDER}/{KEY:2}/{KEY}/user.yaml',
+ 'key' => 'username',
+ 'indexed' => true
+ ],
+ ];
+ }
+
+ return [
+ 'class' => FlexUser\Storage\UserFileStorage::class,
+ 'options' => [
+ 'formatter' => ['class' => YamlFormatter::class],
+ 'folder' => 'account://',
+ 'pattern' => '{FOLDER}/{KEY}.yaml',
+ 'key' => 'storage_key',
+ 'indexed' => true
+ ],
+ ];
+ }
+}
diff --git a/system/src/Grav/Common/Service/AssetsServiceProvider.php b/system/src/Grav/Common/Service/AssetsServiceProvider.php
new file mode 100644
index 0000000..004da9c
--- /dev/null
+++ b/system/src/Grav/Common/Service/AssetsServiceProvider.php
@@ -0,0 +1,24 @@
+setup();
+
+ return $backups;
+ };
+ }
+}
diff --git a/system/src/Grav/Common/Service/ConfigServiceProvider.php b/system/src/Grav/Common/Service/ConfigServiceProvider.php
new file mode 100644
index 0000000..c874441
--- /dev/null
+++ b/system/src/Grav/Common/Service/ConfigServiceProvider.php
@@ -0,0 +1,172 @@
+init();
+
+ return $setup;
+ };
+
+ $container['blueprints'] = function ($c) {
+ return static::blueprints($c);
+ };
+
+ $container['config'] = function ($c) {
+ $config = static::load($c);
+
+ // After configuration has been loaded, we can disable YAML compatibility if strict mode has been enabled.
+ if (!$config->get('system.strict_mode.yaml_compat', true)) {
+ YamlFile::globalSettings(['compat' => false, 'native' => true]);
+ }
+
+ return $config;
+ };
+
+ $container['languages'] = function ($c) {
+ return static::languages($c);
+ };
+
+ $container['language'] = function ($c) {
+ return new Language($c);
+ };
+ }
+
+ public static function blueprints(Container $container)
+ {
+ /** Setup $setup */
+ $setup = $container['setup'];
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $container['locator'];
+
+ $cache = $locator->findResource('cache://compiled/blueprints', true, true);
+
+ $files = [];
+ $paths = $locator->findResources('blueprints://config');
+ $files += (new ConfigFileFinder)->locateFiles($paths);
+ $paths = $locator->findResources('plugins://');
+ $files += (new ConfigFileFinder)->setBase('plugins')->locateInFolders($paths, 'blueprints');
+
+ $blueprints = new CompiledBlueprints($cache, $files, GRAV_ROOT);
+
+ return $blueprints->name("master-{$setup->environment}")->load();
+ }
+
+ /**
+ * @param Container $container
+ * @return Config
+ */
+ public static function load(Container $container)
+ {
+ /** Setup $setup */
+ $setup = $container['setup'];
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $container['locator'];
+
+ $cache = $locator->findResource('cache://compiled/config', true, true);
+
+ $files = [];
+ $paths = $locator->findResources('config://');
+ $files += (new ConfigFileFinder)->locateFiles($paths);
+ $paths = $locator->findResources('plugins://');
+ $files += (new ConfigFileFinder)->setBase('plugins')->locateInFolders($paths);
+
+ $compiled = new CompiledConfig($cache, $files, GRAV_ROOT);
+ $compiled->setBlueprints(function() use ($container) {
+ return $container['blueprints'];
+ });
+
+ $config = $compiled->name("master-{$setup->environment}")->load();
+ $config->environment = $setup->environment;
+
+ return $config;
+ }
+
+ public static function languages(Container $container)
+ {
+ /** @var Setup $setup */
+ $setup = $container['setup'];
+
+ /** @var Config $config */
+ $config = $container['config'];
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $container['locator'];
+
+ $cache = $locator->findResource('cache://compiled/languages', true, true);
+ $files = [];
+
+ // Process languages only if enabled in configuration.
+ if ($config->get('system.languages.translations', true)) {
+ $paths = $locator->findResources('languages://');
+ $files += (new ConfigFileFinder)->locateFiles($paths);
+ $paths = $locator->findResources('plugins://');
+ $files += (new ConfigFileFinder)->setBase('plugins')->locateInFolders($paths, 'languages');
+ $paths = static::pluginFolderPaths($paths, 'languages');
+ $files += (new ConfigFileFinder)->locateFiles($paths);
+ }
+
+ $languages = new CompiledLanguages($cache, $files, GRAV_ROOT);
+
+ return $languages->name("master-{$setup->environment}")->load();
+ }
+
+ /**
+ * Find specific paths in plugins
+ *
+ * @param array $plugins
+ * @param string $folder_path
+ * @return array
+ */
+ private static function pluginFolderPaths($plugins, $folder_path)
+ {
+ $paths = [];
+
+ foreach ($plugins as $path) {
+ $iterator = new \DirectoryIterator($path);
+
+ /** @var \DirectoryIterator $directory */
+ foreach ($iterator as $directory) {
+ if (!$directory->isDir() || $directory->isDot()) {
+ continue;
+ }
+
+ // Path to the languages folder
+ $lang_path = $directory->getPathName() . '/' . $folder_path;
+
+ // If this folder exists, add it to the list of paths
+ if (file_exists($lang_path)) {
+ $paths []= $lang_path;
+ }
+ }
+ }
+ return $paths;
+ }
+
+}
diff --git a/system/src/Grav/Common/Service/ErrorServiceProvider.php b/system/src/Grav/Common/Service/ErrorServiceProvider.php
new file mode 100644
index 0000000..fce69ff
--- /dev/null
+++ b/system/src/Grav/Common/Service/ErrorServiceProvider.php
@@ -0,0 +1,22 @@
+findResource('log://grav.log', true, true);
+ $log->pushHandler(new StreamHandler($log_file, Logger::DEBUG));
+
+ return $log;
+ };
+ }
+}
diff --git a/system/src/Grav/Common/Service/OutputServiceProvider.php b/system/src/Grav/Common/Service/OutputServiceProvider.php
new file mode 100644
index 0000000..a9b2877
--- /dev/null
+++ b/system/src/Grav/Common/Service/OutputServiceProvider.php
@@ -0,0 +1,31 @@
+processSite($page->templateFormat());
+ };
+ }
+}
diff --git a/system/src/Grav/Common/Service/PagesServiceProvider.php b/system/src/Grav/Common/Service/PagesServiceProvider.php
new file mode 100644
index 0000000..f425b6d
--- /dev/null
+++ b/system/src/Grav/Common/Service/PagesServiceProvider.php
@@ -0,0 +1,117 @@
+findResource('system://pages/notfound.md');
+ $page = new Page();
+ $page->init(new \SplFileInfo($path));
+ $page->routable(false);
+
+ return $page;
+ };
+
+ return;
+ }
+
+ $container['page'] = function ($c) {
+ /** @var Grav $c */
+
+ /** @var Pages $pages */
+ $pages = $c['pages'];
+
+ /** @var Config $config */
+ $config = $c['config'];
+
+ /** @var Uri $uri */
+ $uri = $c['uri'];
+
+ $path = $uri->path() ?: '/'; // Don't trim to support trailing slash default routes
+ $page = $pages->dispatch($path);
+
+ // Redirection tests
+ if ($page) {
+ // some debugger override logic
+ if ($page->debugger() === false) {
+ $c['debugger']->enabled(false);
+ }
+
+ if ($config->get('system.force_ssl')) {
+ if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
+ $url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+ $c->redirect($url);
+ }
+ }
+
+ $url = $pages->route($page->route());
+
+ if ($uri->params()) {
+ if ($url === '/') { //Avoid double slash
+ $url = $uri->params();
+ } else {
+ $url .= $uri->params();
+ }
+ }
+ if ($uri->query()) {
+ $url .= '?' . $uri->query();
+ }
+ if ($uri->fragment()) {
+ $url .= '#' . $uri->fragment();
+ }
+
+ /** @var Language $language */
+ $language = $c['language'];
+
+ // Language-specific redirection scenarios
+ if ($language->enabled() && ($language->isLanguageInUrl() xor $language->isIncludeDefaultLanguage())) {
+ $c->redirect($url);
+ }
+ // Default route test and redirect
+ if ($config->get('system.pages.redirect_default_route') && $page->route() !== $path) {
+ $c->redirect($url);
+ }
+ }
+
+ // if page is not found, try some fallback stuff
+ if (!$page || !$page->routable()) {
+
+ // Try fallback URL stuff...
+ $page = $c->fallbackUrl($path);
+
+ if (!$page) {
+ $path = $c['locator']->findResource('system://pages/notfound.md');
+ $page = new Page();
+ $page->init(new \SplFileInfo($path));
+ $page->routable(false);
+ }
+ }
+
+ return $page;
+ };
+ }
+}
diff --git a/system/src/Grav/Common/Service/RequestServiceProvider.php b/system/src/Grav/Common/Service/RequestServiceProvider.php
new file mode 100644
index 0000000..6410ef7
--- /dev/null
+++ b/system/src/Grav/Common/Service/RequestServiceProvider.php
@@ -0,0 +1,38 @@
+fromGlobals();
+ };
+
+ $container['route'] = $container->factory(function() {
+ return clone Uri::getCurrentRoute();
+ });
+ }
+}
diff --git a/system/src/Grav/Common/Service/SchedulerServiceProvider.php b/system/src/Grav/Common/Service/SchedulerServiceProvider.php
new file mode 100644
index 0000000..1df4bbc
--- /dev/null
+++ b/system/src/Grav/Common/Service/SchedulerServiceProvider.php
@@ -0,0 +1,24 @@
+get('system.session.enabled', false);
+ $cookie_secure = (bool)$config->get('system.session.secure', false);
+ $cookie_httponly = (bool)$config->get('system.session.httponly', true);
+ $cookie_lifetime = (int)$config->get('system.session.timeout', 1800);
+ $cookie_path = $config->get('system.session.path');
+ if (null === $cookie_path) {
+ $cookie_path = '/' . trim(Uri::filterPath($uri->rootUrl(false)), '/');
+ }
+ // Session cookie path requires trailing slash.
+ $cookie_path = rtrim($cookie_path, '/') . '/';
+
+ $cookie_domain = $uri->host();
+ if ($cookie_domain === 'localhost') {
+ $cookie_domain = '';
+ }
+
+ // Activate admin if we're inside the admin path.
+ $is_admin = false;
+ if ($config->get('plugins.admin.enabled')) {
+ $admin_base = '/' . trim($config->get('plugins.admin.route'), '/');
+
+ // Uri::route() is not processed yet, let's quickly get what we need.
+ $current_route = str_replace(Uri::filterPath($uri->rootUrl(false)), '', parse_url($uri->url(true), PHP_URL_PATH));
+
+ // Test to see if path starts with a supported language + admin base
+ $lang = Utils::pathPrefixedByLangCode($current_route);
+ $lang_admin_base = '/' . $lang . $admin_base;
+
+ // Check no language, simple language prefix (en) and region specific language prefix (en-US).
+ if (Utils::startsWith($current_route, $admin_base) || Utils::startsWith($current_route, $lang_admin_base)) {
+ $cookie_lifetime = $config->get('plugins.admin.session.timeout', 1800);
+ $enabled = $is_admin = true;
+ }
+ }
+
+ // Fix for HUGE session timeouts.
+ if ($cookie_lifetime > 99999999999) {
+ $cookie_lifetime = 9999999999;
+ }
+
+ $session_prefix = $c['inflector']->hyphenize($config->get('system.session.name', 'grav-site'));
+ $session_uniqueness = $config->get('system.session.uniqueness', 'path') === 'path' ? substr(md5(GRAV_ROOT), 0, 7) : md5($config->get('security.salt'));
+
+ $session_name = $session_prefix . '-' . $session_uniqueness;
+
+ if ($is_admin && $config->get('system.session.split', true)) {
+ $session_name .= '-admin';
+ }
+
+ // Define session service.
+ $options = [
+ 'name' => $session_name,
+ 'cookie_lifetime' => $cookie_lifetime,
+ 'cookie_path' => $cookie_path,
+ 'cookie_domain' => $cookie_domain,
+ 'cookie_secure' => $cookie_secure,
+ 'cookie_httponly' => $cookie_httponly
+ ] + (array) $config->get('system.session.options');
+
+ $session = new Session($options);
+ $session->setAutoStart($enabled);
+
+ return $session;
+ };
+
+ // Define session message service.
+ $container['messages'] = function ($c) {
+ if (!isset($c['session']) || !$c['session']->isStarted()) {
+ /** @var Debugger $debugger */
+ $debugger = $c['debugger'];
+ $debugger->addMessage('Inactive session: session messages may disappear', 'warming');
+
+ return new Message;
+ }
+
+ /** @var Session $session */
+ $session = $c['session'];
+
+ if (!isset($session->messages)) {
+ $session->messages = new Message;
+ }
+
+ return $session->messages;
+ };
+ }
+}
diff --git a/system/src/Grav/Common/Service/StreamsServiceProvider.php b/system/src/Grav/Common/Service/StreamsServiceProvider.php
new file mode 100644
index 0000000..3bbbea1
--- /dev/null
+++ b/system/src/Grav/Common/Service/StreamsServiceProvider.php
@@ -0,0 +1,48 @@
+initializeLocator($locator);
+
+ return $locator;
+ };
+
+ $container['streams'] = function(Container $container) {
+ /** @var Setup $setup */
+ $setup = $container['setup'];
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $container['locator'];
+
+ // Set locator to both streams.
+ Stream::setLocator($locator);
+ ReadOnlyStream::setLocator($locator);
+
+ return new StreamBuilder($setup->getStreams());
+ };
+ }
+}
diff --git a/system/src/Grav/Common/Service/TaskServiceProvider.php b/system/src/Grav/Common/Service/TaskServiceProvider.php
new file mode 100644
index 0000000..c22121a
--- /dev/null
+++ b/system/src/Grav/Common/Service/TaskServiceProvider.php
@@ -0,0 +1,38 @@
+param('task');
+ if (null !== $task) {
+ $task = filter_var($task, FILTER_SANITIZE_STRING);
+ }
+
+ return $task ?: null;
+ };
+
+ $container['action'] = function (Grav $c) {
+ $action = $_POST['action'] ?? $c['uri']->param('action');
+ if (null !== $action) {
+ $action = filter_var($action, FILTER_SANITIZE_STRING);
+ }
+
+ return $action ?: null;
+ };
+ }
+}
diff --git a/system/src/Grav/Common/Session.php b/system/src/Grav/Common/Session.php
new file mode 100644
index 0000000..cd9b2c1
--- /dev/null
+++ b/system/src/Grav/Common/Session.php
@@ -0,0 +1,166 @@
+getInstance() method instead.
+ */
+ public static function instance()
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use ->getInstance() method instead', E_USER_DEPRECATED);
+
+ return static::getInstance();
+ }
+
+ /**
+ * Initialize session.
+ *
+ * Code in this function has been moved into SessionServiceProvider class.
+ */
+ public function init()
+ {
+ if ($this->autoStart && !$this->isStarted()) {
+ $this->start();
+
+ $this->autoStart = false;
+ }
+ }
+
+ /**
+ * @param bool $auto
+ * @return $this
+ */
+ public function setAutoStart($auto)
+ {
+ $this->autoStart = (bool)$auto;
+
+ return $this;
+ }
+
+ /**
+ * Returns attributes.
+ *
+ * @return array Attributes
+ * @deprecated 1.5 Use ->getAll() method instead.
+ */
+ public function all()
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use ->getAll() method instead', E_USER_DEPRECATED);
+
+ return $this->getAll();
+ }
+
+ /**
+ * Checks if the session was started.
+ *
+ * @return Boolean
+ * @deprecated 1.5 Use ->isStarted() method instead.
+ */
+ public function started()
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use ->isStarted() method instead', E_USER_DEPRECATED);
+
+ return $this->isStarted();
+ }
+
+ /**
+ * Store something in session temporarily.
+ *
+ * @param string $name
+ * @param mixed $object
+ * @return $this
+ */
+ public function setFlashObject($name, $object)
+ {
+ $this->__set($name, serialize($object));
+
+ return $this;
+ }
+
+ /**
+ * Return object and remove it from session.
+ *
+ * @param string $name
+ * @return mixed
+ */
+ public function getFlashObject($name)
+ {
+ $serialized = $this->__get($name);
+
+ $object = \is_string($serialized) ? unserialize($serialized, ['allowed_classes' => true]) : $serialized;
+
+ $this->__unset($name);
+
+ if ($name === 'files-upload') {
+ $grav = Grav::instance();
+
+ // Make sure that Forms 3.0+ has been installed.
+ if (null === $object && isset($grav['forms'])) {
+ user_error(
+ __CLASS__ . '::' . __FUNCTION__ . '(\'files-upload\') is deprecated since Grav 1.6, use $form->getFlash()->getLegacyFiles() instead',
+ E_USER_DEPRECATED
+ );
+
+ /** @var Uri $uri */
+ $uri = $grav['uri'];
+ /** @var Grav\Plugin\Form\Forms $form */
+ $form = $grav['forms']->getActiveForm();
+
+ $sessionField = base64_encode($uri->url);
+
+ /** @var FormFlash $flash */
+ $flash = $form ? $form->getFlash() : null;
+ $object = $flash ? [$sessionField => $flash->getLegacyFiles()] : null;
+ }
+ }
+
+ return $object;
+ }
+
+ /**
+ * Store something in cookie temporarily.
+ *
+ * @param string $name
+ * @param mixed $object
+ * @param int $time
+ * @return $this
+ */
+ public function setFlashCookieObject($name, $object, $time = 60)
+ {
+ setcookie($name, json_encode($object), time() + $time, '/');
+
+ return $this;
+ }
+
+ /**
+ * Return object and remove it from the cookie.
+ *
+ * @param string $name
+ * @return mixed|null
+ */
+ public function getFlashCookieObject($name)
+ {
+ if (isset($_COOKIE[$name])) {
+ $object = json_decode($_COOKIE[$name]);
+ setcookie($name, '', time() - 3600, '/');
+ return $object;
+ }
+
+ return null;
+ }
+}
diff --git a/system/src/Grav/Common/Taxonomy.php b/system/src/Grav/Common/Taxonomy.php
new file mode 100644
index 0000000..e323647
--- /dev/null
+++ b/system/src/Grav/Common/Taxonomy.php
@@ -0,0 +1,144 @@
+taxonomy_map = [];
+ $this->grav = $grav;
+ }
+
+ /**
+ * Takes an individual page and processes the taxonomies configured in its header. It
+ * then adds those taxonomies to the map
+ *
+ * @param PageInterface $page the page to process
+ * @param array $page_taxonomy
+ */
+ public function addTaxonomy(PageInterface $page, $page_taxonomy = null)
+ {
+ if (!$page_taxonomy) {
+ $page_taxonomy = $page->taxonomy();
+ }
+
+ if (empty($page_taxonomy) || !$page->published()) {
+ return;
+ }
+
+ /** @var Config $config */
+ $config = $this->grav['config'];
+ if ($config->get('site.taxonomies')) {
+ foreach ((array)$config->get('site.taxonomies') as $taxonomy) {
+ if (isset($page_taxonomy[$taxonomy])) {
+ foreach ((array)$page_taxonomy[$taxonomy] as $item) {
+ $this->taxonomy_map[$taxonomy][(string)$item][$page->path()] = ['slug' => $page->slug()];
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns a new Page object with the sub-pages containing all the values set for a
+ * particular taxonomy.
+ *
+ * @param array $taxonomies taxonomies to search, eg ['tag'=>['animal','cat']]
+ * @param string $operator can be 'or' or 'and' (defaults to 'and')
+ *
+ * @return Collection Collection object set to contain matches found in the taxonomy map
+ */
+ public function findTaxonomy($taxonomies, $operator = 'and')
+ {
+ $matches = [];
+ $results = [];
+
+ foreach ((array)$taxonomies as $taxonomy => $items) {
+ foreach ((array)$items as $item) {
+ if (isset($this->taxonomy_map[$taxonomy][$item])) {
+ $matches[] = $this->taxonomy_map[$taxonomy][$item];
+ } else {
+ $matches[] = [];
+ }
+ }
+ }
+
+ if (strtolower($operator) === 'or') {
+ foreach ($matches as $match) {
+ $results = array_merge($results, $match);
+ }
+ } else {
+ $results = $matches ? array_pop($matches) : [];
+ foreach ($matches as $match) {
+ $results = array_intersect_key($results, $match);
+ }
+ }
+
+ return new Collection($results, ['taxonomies' => $taxonomies]);
+ }
+
+ /**
+ * Gets and Sets the taxonomy map
+ *
+ * @param array $var the taxonomy map
+ *
+ * @return array the taxonomy map
+ */
+ public function taxonomy($var = null)
+ {
+ if ($var) {
+ $this->taxonomy_map = $var;
+ }
+
+ return $this->taxonomy_map;
+ }
+
+ /**
+ * Gets item keys per taxonomy
+ *
+ * @param string $taxonomy taxonomy name
+ *
+ * @return array keys of this taxonomy
+ */
+ public function getTaxonomyItemKeys($taxonomy)
+ {
+ return isset($this->taxonomy_map[$taxonomy]) ? array_keys($this->taxonomy_map[$taxonomy]) : [];
+ }
+}
diff --git a/system/src/Grav/Common/Theme.php b/system/src/Grav/Common/Theme.php
new file mode 100644
index 0000000..dbc589f
--- /dev/null
+++ b/system/src/Grav/Common/Theme.php
@@ -0,0 +1,96 @@
+config["themes.{$this->name}"];
+ }
+
+ /**
+ * Persists to disk the theme parameters currently stored in the Grav Config object
+ *
+ * @param string $theme_name The name of the theme whose config it should store.
+ *
+ * @return true
+ */
+ public static function saveConfig($theme_name)
+ {
+ if (!$theme_name) {
+ return false;
+ }
+
+ $grav = Grav::instance();
+ $locator = $grav['locator'];
+ $filename = 'config://themes/' . $theme_name . '.yaml';
+ $file = YamlFile::instance($locator->findResource($filename, true, true));
+ $content = $grav['config']->get('themes.' . $theme_name);
+ $file->save($content);
+ $file->free();
+
+ return true;
+ }
+
+ /**
+ * Override the mergeConfig method to work for themes
+ */
+ protected function mergeConfig(PageInterface $page, $deep = 'merge', $params = [], $type = 'themes')
+ {
+ return parent::mergeConfig($page, $deep, $params, $type);
+ }
+
+ /**
+ * Simpler getter for the theme blueprint
+ *
+ * @return mixed
+ */
+ public function getBlueprint()
+ {
+ if (!$this->blueprint) {
+ $this->loadBlueprint();
+ }
+ return $this->blueprint;
+ }
+
+ /**
+ * Load blueprints.
+ */
+ protected function loadBlueprint()
+ {
+ if (!$this->blueprint) {
+ $grav = Grav::instance();
+ $themes = $grav['themes'];
+ $this->blueprint = $themes->get($this->name)->blueprints();
+ }
+ }
+}
diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php
new file mode 100644
index 0000000..6720d46
--- /dev/null
+++ b/system/src/Grav/Common/Themes.php
@@ -0,0 +1,371 @@
+grav = $grav;
+ $this->config = $grav['config'];
+
+ // Register instance as autoloader for theme inheritance
+ spl_autoload_register([$this, 'autoloadTheme']);
+ }
+
+ public function init()
+ {
+ /** @var Themes $themes */
+ $themes = $this->grav['themes'];
+ $themes->configure();
+
+ $this->initTheme();
+ }
+
+ public function initTheme()
+ {
+ if ($this->inited === false) {
+ /** @var Themes $themes */
+ $themes = $this->grav['themes'];
+
+ try {
+ $instance = $themes->load();
+ } catch (\InvalidArgumentException $e) {
+ throw new \RuntimeException($this->current() . ' theme could not be found');
+ }
+
+ if ($instance instanceof EventSubscriberInterface) {
+ /** @var EventDispatcher $events */
+ $events = $this->grav['events'];
+
+ $events->addSubscriber($instance);
+ }
+
+ $this->grav['theme'] = $instance;
+
+ $this->grav->fireEvent('onThemeInitialized');
+
+ $this->inited = true;
+ }
+ }
+
+ /**
+ * Return list of all theme data with their blueprints.
+ *
+ * @return array
+ */
+ public function all()
+ {
+ $list = [];
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $this->grav['locator'];
+
+ $iterator = $locator->getIterator('themes://');
+
+ /** @var \DirectoryIterator $directory */
+ foreach ($iterator as $directory) {
+ if (!$directory->isDir() || $directory->isDot()) {
+ continue;
+ }
+
+ $theme = $directory->getFilename();
+
+ try {
+ $result = $this->get($theme);
+ } catch (\Exception $e) {
+ $exception = new \RuntimeException(sprintf('Theme %s: %s', $theme, $e->getMessage()), $e->getCode(), $e);
+
+ /** @var Debugger $debugger */
+ $debugger = $this->grav['debugger'];
+ $debugger->addMessage("Theme {$theme} cannot be loaded, please check Exceptions tab", 'error');
+ $debugger->addException($exception);
+
+ continue;
+ }
+
+ if ($result) {
+ $list[$theme] = $result;
+ }
+ }
+ ksort($list);
+
+ return $list;
+ }
+
+ /**
+ * Get theme configuration or throw exception if it cannot be found.
+ *
+ * @param string $name
+ *
+ * @return Data
+ * @throws \RuntimeException
+ */
+ public function get($name)
+ {
+ if (!$name) {
+ throw new \RuntimeException('Theme name not provided.');
+ }
+
+ $blueprints = new Blueprints('themes://');
+ $blueprint = $blueprints->get("{$name}/blueprints");
+
+ // Load default configuration.
+ $file = CompiledYamlFile::instance("themes://{$name}/{$name}" . YAML_EXT);
+
+ // ensure this is a valid theme
+ if (!$file->exists()) {
+ return null;
+ }
+
+ // Find thumbnail.
+ $thumb = "themes://{$name}/thumbnail.jpg";
+ $path = $this->grav['locator']->findResource($thumb, false);
+
+ if ($path) {
+ $blueprint->set('thumbnail', $this->grav['base_url'] . '/' . $path);
+ }
+
+ $obj = new Data((array)$file->content(), $blueprint);
+
+ // Override with user configuration.
+ $obj->merge($this->config->get('themes.' . $name) ?: []);
+
+ // Save configuration always to user/config.
+ $file = CompiledYamlFile::instance("config://themes/{$name}" . YAML_EXT);
+ $obj->file($file);
+
+ return $obj;
+ }
+
+ /**
+ * Return name of the current theme.
+ *
+ * @return string
+ */
+ public function current()
+ {
+ return (string)$this->config->get('system.pages.theme');
+ }
+
+ /**
+ * Load current theme.
+ *
+ * @return Theme
+ */
+ public function load()
+ {
+ // NOTE: ALL THE LOCAL VARIABLES ARE USED INSIDE INCLUDED FILE, DO NOT REMOVE THEM!
+ $grav = $this->grav;
+ $config = $this->config;
+ $name = $this->current();
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $grav['locator'];
+ $file = $locator('theme://theme.php') ?: $locator("theme://{$name}.php");
+
+ $inflector = $grav['inflector'];
+
+ if ($file) {
+ // Local variables available in the file: $grav, $config, $name, $file
+ $class = include $file;
+
+ if (!is_object($class)) {
+ $themeClassFormat = [
+ 'Grav\\Theme\\' . ucfirst($name),
+ 'Grav\\Theme\\' . $inflector->camelize($name)
+ ];
+
+ foreach ($themeClassFormat as $themeClass) {
+ if (class_exists($themeClass)) {
+ $class = new $themeClass($grav, $config, $name);
+ break;
+ }
+ }
+ }
+ } elseif (!$locator('theme://') && !defined('GRAV_CLI')) {
+ exit("Theme '$name' does not exist, unable to display page.");
+ }
+
+ $this->config->set('theme', $config->get('themes.' . $name));
+
+ if (empty($class)) {
+ $class = new Theme($grav, $config, $name);
+ }
+
+ return $class;
+ }
+
+ /**
+ * Configure and prepare streams for current template.
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function configure()
+ {
+ $name = $this->current();
+ $config = $this->config;
+
+ $this->loadConfiguration($name, $config);
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $this->grav['locator'];
+
+ $registered = stream_get_wrappers();
+
+ $schemes = $config->get("themes.{$name}.streams.schemes", []);
+ $schemes += [
+ 'theme' => [
+ 'type' => 'ReadOnlyStream',
+ 'paths' => $locator->findResources("themes://{$name}", false)
+ ]
+ ];
+
+ foreach ($schemes as $scheme => $config) {
+ if (isset($config['paths'])) {
+ $locator->addPath($scheme, '', $config['paths']);
+ }
+ if (isset($config['prefixes'])) {
+ foreach ($config['prefixes'] as $prefix => $paths) {
+ $locator->addPath($scheme, $prefix, $paths);
+ }
+ }
+
+ if (\in_array($scheme, $registered, true)) {
+ stream_wrapper_unregister($scheme);
+ }
+ $type = !empty($config['type']) ? $config['type'] : 'ReadOnlyStream';
+ if ($type[0] !== '\\') {
+ $type = '\\RocketTheme\\Toolbox\\StreamWrapper\\' . $type;
+ }
+
+ if (!stream_wrapper_register($scheme, $type)) {
+ throw new \InvalidArgumentException("Stream '{$type}' could not be initialized.");
+ }
+ }
+
+ // Load languages after streams has been properly initialized
+ $this->loadLanguages($this->config);
+ }
+
+ /**
+ * Load theme configuration.
+ *
+ * @param string $name Theme name
+ * @param Config $config Configuration class
+ */
+ protected function loadConfiguration($name, Config $config)
+ {
+ $themeConfig = CompiledYamlFile::instance("themes://{$name}/{$name}" . YAML_EXT)->content();
+ $config->joinDefaults("themes.{$name}", $themeConfig);
+ }
+
+ /**
+ * Load theme languages.
+ *
+ * @param Config $config Configuration class
+ */
+ protected function loadLanguages(Config $config)
+ {
+ /** @var UniformResourceLocator $locator */
+ $locator = $this->grav['locator'];
+
+ if ($config->get('system.languages.translations', true)) {
+ $language_file = $locator->findResource('theme://languages' . YAML_EXT);
+ if ($language_file) {
+ $language = CompiledYamlFile::instance($language_file)->content();
+ $this->grav['languages']->mergeRecursive($language);
+ }
+ $languages_folder = $locator->findResource('theme://languages');
+ if (file_exists($languages_folder)) {
+ $languages = [];
+ $iterator = new \DirectoryIterator($languages_folder);
+
+ /** @var \DirectoryIterator $directory */
+ foreach ($iterator as $file) {
+ if ($file->getExtension() !== 'yaml') {
+ continue;
+ }
+ $languages[$file->getBasename('.yaml')] = CompiledYamlFile::instance($file->getPathname())->content();
+ }
+ $this->grav['languages']->mergeRecursive($languages);
+ }
+ }
+ }
+
+ /**
+ * Autoload theme classes for inheritance
+ *
+ * @param string $class Class name
+ *
+ * @return mixed false FALSE if unable to load $class; Class name if
+ * $class is successfully loaded
+ */
+ protected function autoloadTheme($class)
+ {
+ $prefix = 'Grav\\Theme\\';
+ if (false !== strpos($class, $prefix)) {
+ // Remove prefix from class
+ $class = substr($class, strlen($prefix));
+ $locator = $this->grav['locator'];
+
+ // First try lowercase version of the classname.
+ $path = strtolower($class);
+ $file = $locator("themes://{$path}/theme.php") ?: $locator("themes://{$path}/{$path}.php");
+
+ if ($file) {
+ return include_once $file;
+ }
+
+ // Replace namespace tokens to directory separators
+ $path = $this->grav['inflector']->hyphenize($class);
+ $file = $locator("themes://{$path}/theme.php") ?: $locator("themes://{$path}/{$path}.php");
+
+ // Load class
+ if ($file) {
+ return include_once $file;
+ }
+
+ // Try Old style theme classes
+ $path = strtolower(preg_replace('#\\\|_(?!.+\\\)#', '/', $class));
+ $file = $locator("themes://{$path}/theme.php") ?: $locator("themes://{$path}/{$path}.php");
+
+ // Load class
+ if ($file) {
+ return include_once $file;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeCache.php b/system/src/Grav/Common/Twig/Node/TwigNodeCache.php
new file mode 100644
index 0000000..b0bb919
--- /dev/null
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeCache.php
@@ -0,0 +1,56 @@
+ $body), array( 'key' => $key, 'lifetime' => $lifetime), $lineno, $tag);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function compile(Compiler $compiler)
+ {
+ $boo = $this->getAttribute('key');
+ $compiler
+ ->addDebugInfo($this)
+ ->write("\$cache = \\Grav\\Common\\Grav::instance()['cache'];\n")
+ ->write("\$key = \"twigcache-\" . \"" . $this->getAttribute('key') . "\";\n")
+ ->write("\$lifetime = " . $this->getAttribute('lifetime') . ";\n")
+ ->write("\$cache_body = \$cache->fetch(\$key);\n")
+ ->write("if (\$cache_body === false) {\n")
+ ->indent()
+ ->write("ob_start();\n")
+ ->indent()
+ ->subcompile($this->getNode('body'))
+ ->outdent()
+ ->write("\n")
+ ->write("\$cache_body = ob_get_clean();\n")
+ ->write("\$cache->save(\$key, \$cache_body, \$lifetime);\n")
+ ->outdent()
+ ->write("}\n")
+ ->write("echo \$cache_body;\n")
+ ;
+ }
+}
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php b/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php
new file mode 100644
index 0000000..7bb2bfc
--- /dev/null
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php
@@ -0,0 +1,46 @@
+ $body], [], $lineno, $tag);
+ }
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write('ob_start();' . PHP_EOL)
+ ->subcompile($this->getNode('body'))
+ ->write('$content = ob_get_clean();' . PHP_EOL)
+ ->write('preg_match("/^\s*/", $content, $matches);' . PHP_EOL)
+ ->write('$lines = explode("\n", $content);' . PHP_EOL)
+ ->write('$content = preg_replace(\'/^\' . $matches[0]. \'/\', "", $lines);' . PHP_EOL)
+ ->write('$content = join("\n", $content);' . PHP_EOL)
+ ->write('echo $this->env->getExtension(\'Grav\Common\Twig\TwigExtension\')->markdownFunction($context, $content);' . PHP_EOL);
+ }
+}
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeRender.php b/system/src/Grav/Common/Twig/Node/TwigNodeRender.php
new file mode 100644
index 0000000..753adf0
--- /dev/null
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeRender.php
@@ -0,0 +1,78 @@
+ $object, 'layout' => $layout, 'context' => $context], [], $lineno, $tag);
+ }
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Compiler $compiler A Twig_Compiler instance
+ * @throws \LogicException
+ */
+ public function compile(Compiler $compiler)
+ {
+ $compiler->addDebugInfo($this);
+ $compiler->write('$object = ')->subcompile($this->getNode('object'))->raw(';' . PHP_EOL);
+
+ $layout = $this->getNode('layout');
+ if ($layout) {
+ $compiler->write('$layout = ')->subcompile($layout)->raw(';' . PHP_EOL);
+ } else {
+ $compiler->write('$layout = null;' . PHP_EOL);
+ }
+
+ $context = $this->getNode('context');
+ if ($context) {
+ $compiler->write('$attributes = ')->subcompile($context)->raw(';' . PHP_EOL);
+ } else {
+ $compiler->write('$attributes = null;' . PHP_EOL);
+ }
+
+ $compiler
+ ->write('$html = $object->render($layout, $attributes ?? []);' . PHP_EOL)
+ ->write('$block = $context[\'block\'] ?? null;' . PHP_EOL)
+ ->write('if ($block instanceof \Grav\Framework\ContentBlock\ContentBlock && $html instanceof \Grav\Framework\ContentBlock\ContentBlock) {' . PHP_EOL)
+ ->indent()
+ ->write('$block->addBlock($html);' . PHP_EOL)
+ ->write('echo $html->getToken();' . PHP_EOL)
+ ->outdent()
+ ->write('} else {' . PHP_EOL)
+ ->indent()
+ ->write('echo (string)$html;' . PHP_EOL)
+ ->outdent()
+ ->write('}' . PHP_EOL)
+ ;
+ }
+}
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeScript.php b/system/src/Grav/Common/Twig/Node/TwigNodeScript.php
new file mode 100644
index 0000000..4f6f776
--- /dev/null
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeScript.php
@@ -0,0 +1,101 @@
+ $body, 'file' => $file, 'group' => $group, 'priority' => $priority, 'attributes' => $attributes], [], $lineno, $tag);
+ }
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Compiler $compiler A Twig_Compiler instance
+ * @throws \LogicException
+ */
+ public function compile(Compiler $compiler)
+ {
+ $compiler->addDebugInfo($this);
+
+ $compiler->write("\$assets = \\Grav\\Common\\Grav::instance()['assets'];\n");
+
+ if ($this->getNode('attributes') !== null) {
+ $compiler
+ ->write('$attributes = ')
+ ->subcompile($this->getNode('attributes'))
+ ->raw(";\n")
+ ->write("if (!is_array(\$attributes)) {\n")
+ ->indent()
+ ->write("throw new UnexpectedValueException('{% {$this->tagName} with x %}: x is not an array');\n")
+ ->outdent()
+ ->write("}\n");
+ } else {
+ $compiler->write('$attributes = [];' . "\n");
+ }
+
+ if ($this->getNode('group') !== null) {
+ $compiler
+ ->write("\$attributes['group'] = ")
+ ->subcompile($this->getNode('group'))
+ ->raw(";\n")
+ ->write("if (!is_string(\$attributes['group'])) {\n")
+ ->indent()
+ ->write("throw new UnexpectedValueException('{% {$this->tagName} in x %}: x is not a string');\n")
+ ->outdent()
+ ->write("}\n");
+ }
+
+ if ($this->getNode('priority') !== null) {
+ $compiler
+ ->write("\$attributes['priority'] = (int)(")
+ ->subcompile($this->getNode('priority'))
+ ->raw(");\n");
+ }
+
+ if ($this->getNode('file') !== null) {
+ $compiler
+ ->write('$assets->addJs(')
+ ->subcompile($this->getNode('file'))
+ ->raw(", \$attributes);\n");
+ } else {
+ $compiler
+ ->write("ob_start();\n")
+ ->subcompile($this->getNode('body'))
+ ->write('$content = ob_get_clean();' . "\n")
+ ->write("\$assets->addInlineJs(\$content, \$attributes);\n");
+ }
+ }
+}
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php b/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php
new file mode 100644
index 0000000..22f3302
--- /dev/null
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php
@@ -0,0 +1,101 @@
+ $body, 'file' => $file, 'group' => $group, 'priority' => $priority, 'attributes' => $attributes], [], $lineno, $tag);
+ }
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Compiler $compiler A Twig_Compiler instance
+ * @throws \LogicException
+ */
+ public function compile(Compiler $compiler)
+ {
+ $compiler->addDebugInfo($this);
+
+ $compiler->write("\$assets = \\Grav\\Common\\Grav::instance()['assets'];\n");
+
+ if ($this->getNode('attributes') !== null) {
+ $compiler
+ ->write('$attributes = ')
+ ->subcompile($this->getNode('attributes'))
+ ->raw(";\n")
+ ->write("if (!is_array(\$attributes)) {\n")
+ ->indent()
+ ->write("throw new UnexpectedValueException('{% {$this->tagName} with x %}: x is not an array');\n")
+ ->outdent()
+ ->write("}\n");
+ } else {
+ $compiler->write('$attributes = [];' . "\n");
+ }
+
+ if ($this->getNode('group') !== null) {
+ $compiler
+ ->write("\$attributes['group'] = ")
+ ->subcompile($this->getNode('group'))
+ ->raw(";\n")
+ ->write("if (!is_string(\$attributes['group'])) {\n")
+ ->indent()
+ ->write("throw new UnexpectedValueException('{% {$this->tagName} in x %}: x is not a string');\n")
+ ->outdent()
+ ->write("}\n");
+ }
+
+ if ($this->getNode('priority') !== null) {
+ $compiler
+ ->write("\$attributes['priority'] = (int)(")
+ ->subcompile($this->getNode('priority'))
+ ->raw(");\n");
+ }
+
+ if ($this->getNode('file') !== null) {
+ $compiler
+ ->write('$assets->addCss(')
+ ->subcompile($this->getNode('file'))
+ ->raw(", \$attributes);\n");
+ } else {
+ $compiler
+ ->write("ob_start();\n")
+ ->subcompile($this->getNode('body'))
+ ->write('$content = ob_get_clean();' . "\n")
+ ->write("\$assets->addInlineCss(\$content, \$attributes);\n");
+ }
+ }
+}
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php b/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php
new file mode 100644
index 0000000..f29ed6d
--- /dev/null
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php
@@ -0,0 +1,85 @@
+ $value, 'cases' => $cases, 'default' => $default), array(), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write('switch (')
+ ->subcompile($this->getNode('value'))
+ ->raw(") {\n")
+ ->indent();
+
+ foreach ($this->getNode('cases') as $case) {
+ if (!$case->hasNode('body')) {
+ continue;
+ }
+
+ foreach ($case->getNode('values') as $value) {
+ $compiler
+ ->write('case ')
+ ->subcompile($value)
+ ->raw(":\n");
+ }
+
+ $compiler
+ ->write("{\n")
+ ->indent()
+ ->subcompile($case->getNode('body'))
+ ->write("break;\n")
+ ->outdent()
+ ->write("}\n");
+ }
+
+ if ($this->hasNode('default') && $this->getNode('default') !== null) {
+ $compiler
+ ->write("default:\n")
+ ->write("{\n")
+ ->indent()
+ ->subcompile($this->getNode('default'))
+ ->outdent()
+ ->write("}\n");
+ }
+
+ $compiler
+ ->outdent()
+ ->write("}\n");
+ }
+}
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php b/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php
new file mode 100644
index 0000000..5bb5899
--- /dev/null
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php
@@ -0,0 +1,51 @@
+ $message], ['code' => $code], $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Compiler $compiler A Twig_Compiler instance
+ * @throws \LogicException
+ */
+ public function compile(Compiler $compiler)
+ {
+ $compiler->addDebugInfo($this);
+
+ $compiler
+ ->write('throw new \RuntimeException(')
+ ->subcompile($this->getNode('message'))
+ ->write(', ')
+ ->write($this->getAttribute('code') ?: 500)
+ ->write(");\n");
+ }
+}
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php b/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php
new file mode 100644
index 0000000..4028e74
--- /dev/null
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php
@@ -0,0 +1,68 @@
+ $try, 'catch' => $catch], [], $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Compiler $compiler A Twig_Compiler instance
+ * @throws \LogicException
+ */
+ public function compile(Compiler $compiler)
+ {
+ $compiler->addDebugInfo($this);
+
+ $compiler
+ ->write('try {')
+ ;
+
+ $compiler
+ ->indent()
+ ->subcompile($this->getNode('try'))
+ ;
+
+ if ($this->hasNode('catch') && null !== $this->getNode('catch')) {
+ $compiler
+ ->outdent()
+ ->write('} catch (\Exception $e) {' . "\n")
+ ->indent()
+ ->write('if (isset($context[\'grav\'][\'debugger\'])) $context[\'grav\'][\'debugger\']->addException($e);' . "\n")
+ ->write('$context[\'e\'] = $e;' . "\n")
+ ->subcompile($this->getNode('catch'))
+ ;
+ }
+
+ $compiler
+ ->outdent()
+ ->write("}\n");
+ }
+}
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php
new file mode 100644
index 0000000..3f56f14
--- /dev/null
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php
@@ -0,0 +1,68 @@
+getLine();
+ $stream = $this->parser->getStream();
+ $key = $this->parser->getVarName() . $lineno;
+ $lifetime = Grav::instance()['cache']->getLifetime();
+
+ // Check for optional lifetime override
+ if (!$stream->test(Token::BLOCK_END_TYPE)) {
+ $lifetime_expr = $this->parser->getExpressionParser()->parseExpression();
+ $lifetime = $lifetime_expr->getAttribute('value');
+ }
+
+ $stream->expect(Token::BLOCK_END_TYPE);
+ $body = $this->parser->subparse(array($this, 'decideCacheEnd'), true);
+ $stream->expect(Token::BLOCK_END_TYPE);
+
+ return new TwigNodeCache($key, $lifetime, $body, $lineno, $this->getTag());
+ }
+
+ /**
+ * Decide if current token marks end of cache block.
+ *
+ * @param Token $token
+ * @return bool
+ */
+ public function decideCacheEnd(Token $token)
+ {
+ return $token->test('endcache');
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public function getTag()
+ {
+ return 'cache';
+ }
+}
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php
new file mode 100644
index 0000000..7a1d139
--- /dev/null
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php
@@ -0,0 +1,56 @@
+getLine();
+ $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
+ $body = $this->parser->subparse(array($this, 'decideMarkdownEnd'), true);
+ $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
+ return new TwigNodeMarkdown($body, $lineno, $this->getTag());
+ }
+ /**
+ * Decide if current token marks end of Markdown block.
+ *
+ * @param Token $token
+ * @return bool
+ */
+ public function decideMarkdownEnd(Token $token)
+ {
+ return $token->test('endmarkdown');
+ }
+ /**
+ * {@inheritdoc}
+ */
+ public function getTag()
+ {
+ return 'markdown';
+ }
+}
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php
new file mode 100644
index 0000000..811705d
--- /dev/null
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php
@@ -0,0 +1,75 @@
+getLine();
+
+ [$object, $layout, $context] = $this->parseArguments($token);
+
+ return new TwigNodeRender($object, $layout, $context, $lineno, $this->getTag());
+ }
+
+ /**
+ * @param Token $token
+ * @return array
+ */
+ protected function parseArguments(Token $token)
+ {
+ $stream = $this->parser->getStream();
+
+ $object = $this->parser->getExpressionParser()->parseExpression();
+
+ $layout = null;
+ if ($stream->nextIf(Token::NAME_TYPE, 'layout')) {
+ $stream->expect(Token::PUNCTUATION_TYPE, ':');
+ $layout = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $context = null;
+ if ($stream->nextIf(Token::NAME_TYPE, 'with')) {
+ $context = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $stream->expect(Token::BLOCK_END_TYPE);
+
+ return [$object, $layout, $context];
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'render';
+ }
+}
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php
new file mode 100644
index 0000000..bb04707
--- /dev/null
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php
@@ -0,0 +1,104 @@
+getLine();
+ $stream = $this->parser->getStream();
+
+ list($file, $group, $priority, $attributes) = $this->parseArguments($token);
+
+ $content = null;
+ if ($file === null) {
+ $content = $this->parser->subparse([$this, 'decideBlockEnd'], true);
+ $stream->expect(Token::BLOCK_END_TYPE);
+ }
+
+ return new TwigNodeScript($content, $file, $group, $priority, $attributes, $lineno, $this->getTag());
+ }
+
+ /**
+ * @param Token $token
+ * @return array
+ */
+ protected function parseArguments(Token $token)
+ {
+ $stream = $this->parser->getStream();
+
+ $file = null;
+ if (!$stream->test(Token::NAME_TYPE) && !$stream->test(Token::OPERATOR_TYPE) && !$stream->test(Token::BLOCK_END_TYPE)) {
+ $file = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $group = null;
+ if ($stream->nextIf(Token::OPERATOR_TYPE, 'in')) {
+ $group = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $priority = null;
+ if ($stream->nextIf(Token::NAME_TYPE, 'priority')) {
+ $stream->expect(Token::PUNCTUATION_TYPE, ':');
+ $priority = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $attributes = null;
+ if ($stream->nextIf(Token::NAME_TYPE, 'with')) {
+ $attributes = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $stream->expect(Token::BLOCK_END_TYPE);
+
+ return [$file, $group, $priority, $attributes];
+ }
+
+ /**
+ * @param Token $token
+ * @return bool
+ */
+ public function decideBlockEnd(Token $token)
+ {
+ return $token->test('endscript');
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'script';
+ }
+}
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php
new file mode 100644
index 0000000..5a5beb6
--- /dev/null
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php
@@ -0,0 +1,103 @@
+getLine();
+ $stream = $this->parser->getStream();
+
+ list ($file, $group, $priority, $attributes) = $this->parseArguments($token);
+
+ $content = null;
+ if (!$file) {
+ $content = $this->parser->subparse([$this, 'decideBlockEnd'], true);
+ $stream->expect(Token::BLOCK_END_TYPE);
+ }
+
+ return new TwigNodeStyle($content, $file, $group, $priority, $attributes, $lineno, $this->getTag());
+ }
+
+ /**
+ * @param Token $token
+ * @return array
+ */
+ protected function parseArguments(Token $token)
+ {
+ $stream = $this->parser->getStream();
+
+ $file = null;
+ if (!$stream->test(Token::NAME_TYPE) && !$stream->test(Token::OPERATOR_TYPE) && !$stream->test(Token::BLOCK_END_TYPE)) {
+ $file = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $group = null;
+ if ($stream->nextIf(Token::OPERATOR_TYPE, 'in')) {
+ $group = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $priority = null;
+ if ($stream->nextIf(Token::NAME_TYPE, 'priority')) {
+ $stream->expect(Token::PUNCTUATION_TYPE, ':');
+ $priority = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $attributes = null;
+ if ($stream->nextIf(Token::NAME_TYPE, 'with')) {
+ $attributes = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $stream->expect(Token::BLOCK_END_TYPE);
+
+ return [$file, $group, $priority, $attributes];
+ }
+
+ /**
+ * @param Token $token
+ * @return bool
+ */
+ public function decideBlockEnd(Token $token)
+ {
+ return $token->test('endstyle');
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'style';
+ }
+}
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php
new file mode 100644
index 0000000..7bd3ba9
--- /dev/null
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php
@@ -0,0 +1,130 @@
+getLine();
+ $stream = $this->parser->getStream();
+
+ $name = $this->parser->getExpressionParser()->parseExpression();
+ $stream->expect(Token::BLOCK_END_TYPE);
+
+ // There can be some whitespace between the {% switch %} and first {% case %} tag.
+ while ($stream->getCurrent()->getType() === Token::TEXT_TYPE && trim($stream->getCurrent()->getValue()) === '') {
+ $stream->next();
+ }
+
+ $stream->expect(Token::BLOCK_START_TYPE);
+
+ $expressionParser = $this->parser->getExpressionParser();
+
+ $default = null;
+ $cases = [];
+ $end = false;
+
+ while (!$end) {
+ $next = $stream->next();
+
+ switch ($next->getValue()) {
+ case 'case':
+ $values = [];
+
+ while (true) {
+ $values[] = $expressionParser->parsePrimaryExpression();
+ // Multiple allowed values?
+ if ($stream->test(Token::OPERATOR_TYPE, 'or')) {
+ $stream->next();
+ } else {
+ break;
+ }
+ }
+
+ $stream->expect(Token::BLOCK_END_TYPE);
+ $body = $this->parser->subparse(array($this, 'decideIfFork'));
+ $cases[] = new Node([
+ 'values' => new Node($values),
+ 'body' => $body
+ ]);
+ break;
+
+ case 'default':
+ $stream->expect(Token::BLOCK_END_TYPE);
+ $default = $this->parser->subparse(array($this, 'decideIfEnd'));
+ break;
+
+ case 'endswitch':
+ $end = true;
+ break;
+
+ default:
+ throw new SyntaxError(sprintf('Unexpected end of template. Twig was looking for the following tags "case", "default", or "endswitch" to close the "switch" block started at line %d)', $lineno), -1);
+ }
+ }
+
+ $stream->expect(Token::BLOCK_END_TYPE);
+
+ return new TwigNodeSwitch($name, new Node($cases), $default, $lineno, $this->getTag());
+ }
+
+ /**
+ * Decide if current token marks switch logic.
+ *
+ * @param Token $token
+ * @return bool
+ */
+ public function decideIfFork(Token $token)
+ {
+ return $token->test(array('case', 'default', 'endswitch'));
+ }
+
+ /**
+ * Decide if current token marks end of swtich block.
+ *
+ * @param Token $token
+ * @return bool
+ */
+ public function decideIfEnd(Token $token)
+ {
+ return $token->test(array('endswitch'));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getTag()
+ {
+ return 'switch';
+ }
+}
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php
new file mode 100644
index 0000000..c0d6de9
--- /dev/null
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php
@@ -0,0 +1,54 @@
+
+ * {% throw 404 'Not Found' %}
+ *
+ */
+class TwigTokenParserThrow extends AbstractTokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Token $token A Twig_Token instance
+ *
+ * @return Node A Twig_Node instance
+ */
+ public function parse(Token $token)
+ {
+ $lineno = $token->getLine();
+ $stream = $this->parser->getStream();
+
+ $code = $stream->expect(Token::NUMBER_TYPE)->getValue();
+ $message = $this->parser->getExpressionParser()->parseExpression();
+ $stream->expect(Token::BLOCK_END_TYPE);
+
+ return new TwigNodeThrow($code, $message, $lineno, $this->getTag());
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'throw';
+ }
+}
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php
new file mode 100644
index 0000000..95adef3
--- /dev/null
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php
@@ -0,0 +1,72 @@
+
+ * {% try %}
+ * {{ user.get('name') }}
+ * {% catch %}
+ * {{ e.message }}
+ * {% endcatch %}
+ *
+ */
+class TwigTokenParserTryCatch extends AbstractTokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Token $token A Twig_Token instance
+ *
+ * @return Node A Twig_Node instance
+ */
+ public function parse(Token $token)
+ {
+ $lineno = $token->getLine();
+ $stream = $this->parser->getStream();
+
+ $stream->expect(Token::BLOCK_END_TYPE);
+ $try = $this->parser->subparse([$this, 'decideCatch']);
+ $stream->next();
+ $stream->expect(Token::BLOCK_END_TYPE);
+ $catch = $this->parser->subparse([$this, 'decideEnd']);
+ $stream->next();
+ $stream->expect(Token::BLOCK_END_TYPE);
+
+ return new TwigNodeTryCatch($try, $catch, $lineno, $this->getTag());
+ }
+
+ public function decideCatch(Token $token)
+ {
+ return $token->test(array('catch'));
+ }
+
+ public function decideEnd(Token $token)
+ {
+ return $token->test(array('endtry')) || $token->test(array('endcatch'));
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'try';
+ }
+}
diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php
new file mode 100644
index 0000000..5c9008f
--- /dev/null
+++ b/system/src/Grav/Common/Twig/Twig.php
@@ -0,0 +1,454 @@
+grav = $grav;
+ $this->twig_paths = [];
+ }
+
+ /**
+ * Twig initialization that sets the twig loader chain, then the environment, then extensions
+ * and also the base set of twig vars
+ */
+ public function init()
+ {
+ if (null === $this->twig) {
+ /** @var Config $config */
+ $config = $this->grav['config'];
+ /** @var UniformResourceLocator $locator */
+ $locator = $this->grav['locator'];
+ /** @var Language $language */
+ $language = $this->grav['language'];
+
+ $active_language = $language->getActive();
+
+ // handle language templates if available
+ if ($language->enabled()) {
+ $lang_templates = $locator->findResource('theme://templates/' . ($active_language ? $active_language : $language->getDefault()));
+ if ($lang_templates) {
+ $this->twig_paths[] = $lang_templates;
+ }
+ }
+
+ $this->twig_paths = array_merge($this->twig_paths, $locator->findResources('theme://templates'));
+
+ $this->grav->fireEvent('onTwigTemplatePaths');
+
+ // Add Grav core templates location
+ $core_templates = array_merge($locator->findResources('system://templates'), $locator->findResources('system://templates/testing'));
+ $this->twig_paths = array_merge($this->twig_paths, $core_templates);
+
+ $this->loader = new \Twig_Loader_Filesystem($this->twig_paths);
+
+ // Register all other prefixes as namespaces in twig
+ foreach ($locator->getPaths('theme') as $prefix => $_) {
+ if ($prefix === '') {
+ continue;
+ }
+
+ $twig_paths = [];
+
+ // handle language templates if available
+ if ($language->enabled()) {
+ $lang_templates = $locator->findResource('theme://'.$prefix.'templates/' . ($active_language ? $active_language : $language->getDefault()));
+ if ($lang_templates) {
+ $twig_paths[] = $lang_templates;
+ }
+ }
+
+ $twig_paths = array_merge($twig_paths, $locator->findResources('theme://'.$prefix.'templates'));
+
+ $namespace = trim($prefix, '/');
+ $this->loader->setPaths($twig_paths, $namespace);
+ }
+
+ $this->grav->fireEvent('onTwigLoader');
+
+ $this->loaderArray = new \Twig_Loader_Array([]);
+ $loader_chain = new \Twig_Loader_Chain([$this->loaderArray, $this->loader]);
+
+ $params = $config->get('system.twig');
+ if (!empty($params['cache'])) {
+ $cachePath = $locator->findResource('cache://twig', true, true);
+ $params['cache'] = new \Twig_Cache_Filesystem($cachePath, \Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION);
+ }
+
+ if (!$config->get('system.strict_mode.twig_compat', true)) {
+ // Force autoescape on for all files if in strict mode.
+ $params['autoescape'] = 'html';
+ } elseif (!empty($this->autoescape)) {
+ $params['autoescape'] = $this->autoescape ? 'html' : false;
+ }
+
+ if (empty($params['autoescape'])) {
+ user_error('Grav 2.0 will have Twig auto-escaping forced on (can be emulated by turning off \'system.strict_mode.twig_compat\' setting in your configuration)', E_USER_DEPRECATED);
+ }
+
+ $this->twig = new TwigEnvironment($loader_chain, $params);
+
+ if ($config->get('system.twig.undefined_functions')) {
+ $this->twig->registerUndefinedFunctionCallback(function ($name) {
+ if (function_exists($name)) {
+ return new \Twig_SimpleFunction($name, $name);
+ }
+
+ return new \Twig_SimpleFunction($name, function () {
+ });
+ });
+ }
+
+ if ($config->get('system.twig.undefined_filters')) {
+ $this->twig->registerUndefinedFilterCallback(function ($name) {
+ if (function_exists($name)) {
+ return new \Twig_SimpleFilter($name, $name);
+ }
+
+ return new \Twig_SimpleFilter($name, function () {
+ });
+ });
+ }
+
+ $this->grav->fireEvent('onTwigInitialized');
+
+ // set default date format if set in config
+ if ($config->get('system.pages.dateformat.long')) {
+ /** @var \Twig_Extension_Core $extension */
+ $extension = $this->twig->getExtension('Twig_Extension_Core');
+ $extension->setDateFormat($config->get('system.pages.dateformat.long'));
+ }
+ // enable the debug extension if required
+ if ($config->get('system.twig.debug')) {
+ $this->twig->addExtension(new \Twig_Extension_Debug());
+ }
+ $this->twig->addExtension(new TwigExtension());
+ $this->twig->addExtension(new DeferredExtension());
+
+ $this->grav->fireEvent('onTwigExtensions');
+
+ /** @var Pages $pages */
+ $pages = $this->grav['pages'];
+
+ // Set some standard variables for twig
+ $this->twig_vars += [
+ 'config' => $config,
+ 'system' => $config->get('system'),
+ 'theme' => $config->get('theme'),
+ 'site' => $config->get('site'),
+ 'uri' => $this->grav['uri'],
+ 'assets' => $this->grav['assets'],
+ 'taxonomy' => $this->grav['taxonomy'],
+ 'browser' => $this->grav['browser'],
+ 'base_dir' => rtrim(ROOT_DIR, '/'),
+ 'home_url' => $pages->homeUrl($active_language),
+ 'base_url' => $pages->baseUrl($active_language),
+ 'base_url_absolute' => $pages->baseUrl($active_language, true),
+ 'base_url_relative' => $pages->baseUrl($active_language, false),
+ 'base_url_simple' => $this->grav['base_url'],
+ 'theme_dir' => $locator->findResource('theme://'),
+ 'theme_url' => $this->grav['base_url'] . '/' . $locator->findResource('theme://', false),
+ 'html_lang' => $this->grav['language']->getActive() ?: $config->get('site.default_lang', 'en'),
+ 'language_codes' => new LanguageCodes,
+ ];
+ }
+
+ return $this;
+ }
+
+ /**
+ * @return \Twig_Environment
+ */
+ public function twig()
+ {
+ return $this->twig;
+ }
+
+ /**
+ * @return \Twig_Loader_Filesystem
+ */
+ public function loader()
+ {
+ return $this->loader;
+ }
+
+ /**
+ * Adds or overrides a template.
+ *
+ * @param string $name The template name
+ * @param string $template The template source
+ */
+ public function setTemplate($name, $template)
+ {
+ $this->loaderArray->setTemplate($name, $template);
+ }
+
+ /**
+ * Twig process that renders a page item. It supports two variations:
+ * 1) Handles modular pages by rendering a specific page based on its modular twig template
+ * 2) Renders individual page items for twig processing before the site rendering
+ *
+ * @param PageInterface $item The page item to render
+ * @param string $content Optional content override
+ *
+ * @return string The rendered output
+ * @throws \Twig_Error_Loader
+ */
+ public function processPage(PageInterface $item, $content = null)
+ {
+ $content = $content ?? $item->content();
+
+ // override the twig header vars for local resolution
+ $this->grav->fireEvent('onTwigPageVariables', new Event(['page' => $item]));
+ $twig_vars = $this->twig_vars;
+
+ $twig_vars['page'] = $item;
+ $twig_vars['media'] = $item->media();
+ $twig_vars['header'] = $item->header();
+
+ $local_twig = clone $this->twig;
+
+ $output = '';
+ try {
+ // Process Modular Twig
+ if ($item->modularTwig()) {
+ $twig_vars['content'] = $content;
+ $extension = $item->templateFormat();
+ $extension = $extension ? ".{$extension}.twig" : TEMPLATE_EXT;
+ $template = $item->template() . $extension;
+ $output = $content = $local_twig->render($template, $twig_vars);
+ }
+
+ // Process in-page Twig
+ if ($item->shouldProcess('twig')) {
+ $name = '@Page:' . $item->path();
+ $this->setTemplate($name, $content);
+ $output = $local_twig->render($name, $twig_vars);
+ }
+
+ } catch (\Twig_Error_Loader $e) {
+ throw new \RuntimeException($e->getRawMessage(), 404, $e);
+ }
+
+ return $output;
+ }
+
+ /**
+ * Process a Twig template directly by using a template name
+ * and optional array of variables
+ *
+ * @param string $template template to render with
+ * @param array $vars Optional variables
+ *
+ * @return string
+ */
+ public function processTemplate($template, $vars = [])
+ {
+ // override the twig header vars for local resolution
+ $this->grav->fireEvent('onTwigTemplateVariables');
+ $vars += $this->twig_vars;
+
+ try {
+ $output = $this->twig->render($template, $vars);
+ } catch (\Twig_Error_Loader $e) {
+ throw new \RuntimeException($e->getRawMessage(), 404, $e);
+ }
+
+ return $output;
+
+ }
+
+
+ /**
+ * Process a Twig template directly by using a Twig string
+ * and optional array of variables
+ *
+ * @param string $string string to render.
+ * @param array $vars Optional variables
+ *
+ * @return string
+ */
+ public function processString($string, array $vars = [])
+ {
+ // override the twig header vars for local resolution
+ $this->grav->fireEvent('onTwigStringVariables');
+ $vars += $this->twig_vars;
+
+ $name = '@Var:' . $string;
+ $this->setTemplate($name, $string);
+
+ try {
+ $output = $this->twig->render($name, $vars);
+ } catch (\Twig_Error_Loader $e) {
+ throw new \RuntimeException($e->getRawMessage(), 404, $e);
+ }
+
+ return $output;
+ }
+
+ /**
+ * Twig process that renders the site layout. This is the main twig process that renders the overall
+ * page and handles all the layout for the site display.
+ *
+ * @param string $format Output format (defaults to HTML).
+ *
+ * @return string the rendered output
+ * @throws \RuntimeException
+ */
+ public function processSite($format = null, array $vars = [])
+ {
+ // set the page now its been processed
+ $this->grav->fireEvent('onTwigSiteVariables');
+ $pages = $this->grav['pages'];
+ $page = $this->grav['page'];
+ $content = $page->content();
+
+ $twig_vars = $this->twig_vars;
+
+ $twig_vars['theme'] = $this->grav['config']->get('theme');
+ $twig_vars['pages'] = $pages->root();
+ $twig_vars['page'] = $page;
+ $twig_vars['header'] = $page->header();
+ $twig_vars['media'] = $page->media();
+ $twig_vars['content'] = $content;
+ $ext = '.' . ($format ?: 'html') . TWIG_EXT;
+
+ // determine if params are set, if so disable twig cache
+ $params = $this->grav['uri']->params(null, true);
+ if (!empty($params)) {
+ $this->twig->setCache(false);
+ }
+
+ // Get Twig template layout
+ $template = $this->template($page->template() . $ext);
+
+ try {
+ $output = $this->twig->render($template, $vars + $twig_vars);
+ } catch (\Twig_Error_Loader $e) {
+ $error_msg = $e->getMessage();
+ // Try html version of this template if initial template was NOT html
+ if ($ext !== '.html' . TWIG_EXT) {
+ try {
+ $page->templateFormat('html');
+ $output = $this->twig->render($page->template() . '.html' . TWIG_EXT, $vars + $twig_vars);
+ } catch (\Twig_Error_Loader $e) {
+ throw new \RuntimeException($error_msg, 400, $e);
+ }
+ } else {
+ throw new \RuntimeException($error_msg, 400, $e);
+ }
+ }
+
+ return $output;
+ }
+
+ /**
+ * Wraps the Twig_Loader_Filesystem addPath method (should be used only in `onTwigLoader()` event
+ * @param string $template_path
+ * @param string $namespace
+ */
+ public function addPath($template_path, $namespace = '__main__')
+ {
+ $this->loader->addPath($template_path, $namespace);
+ }
+
+ /**
+ * Wraps the Twig_Loader_Filesystem prependPath method (should be used only in `onTwigLoader()` event
+ * @param string $template_path
+ * @param string $namespace
+ */
+ public function prependPath($template_path, $namespace = '__main__')
+ {
+ $this->loader->prependPath($template_path, $namespace);
+ }
+
+ /**
+ * Simple helper method to get the twig template if it has already been set, else return
+ * the one being passed in
+ *
+ * @param string $template the template name
+ *
+ * @return string the template name
+ */
+ public function template($template)
+ {
+ return $this->template ?? $template;
+ }
+
+ /**
+ * Overrides the autoescape setting
+ *
+ * @param bool $state
+ * @deprecated 1.5 Auto-escape should always be turned on to protect against XSS issues (can be disabled per template file).
+ */
+ public function setAutoescape($state)
+ {
+ if (!$state) {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '(false) is deprecated since Grav 1.5', E_USER_DEPRECATED);
+ }
+
+ $this->autoescape = (bool) $state;
+ }
+}
diff --git a/system/src/Grav/Common/Twig/TwigEnvironment.php b/system/src/Grav/Common/Twig/TwigEnvironment.php
new file mode 100644
index 0000000..54ef24f
--- /dev/null
+++ b/system/src/Grav/Common/Twig/TwigEnvironment.php
@@ -0,0 +1,15 @@
+grav = Grav::instance();
+ $this->debugger = $this->grav['debugger'] ?? null;
+ $this->config = $this->grav['config'];
+ }
+
+ /**
+ * Register some standard globals
+ *
+ * @return array
+ */
+ public function getGlobals()
+ {
+ return [
+ 'grav' => $this->grav,
+ ];
+ }
+
+ /**
+ * Return a list of all filters.
+ *
+ * @return array
+ */
+ public function getFilters()
+ {
+ return [
+ new \Twig_SimpleFilter('*ize', [$this, 'inflectorFilter']),
+ new \Twig_SimpleFilter('absolute_url', [$this, 'absoluteUrlFilter']),
+ new \Twig_SimpleFilter('contains', [$this, 'containsFilter']),
+ new \Twig_SimpleFilter('chunk_split', [$this, 'chunkSplitFilter']),
+ new \Twig_SimpleFilter('nicenumber', [$this, 'niceNumberFunc']),
+ new \Twig_SimpleFilter('nicefilesize', [$this, 'niceFilesizeFunc']),
+ new \Twig_SimpleFilter('nicetime', [$this, 'nicetimeFunc']),
+ new \Twig_SimpleFilter('defined', [$this, 'definedDefaultFilter']),
+ new \Twig_SimpleFilter('ends_with', [$this, 'endsWithFilter']),
+ new \Twig_SimpleFilter('fieldName', [$this, 'fieldNameFilter']),
+ new \Twig_SimpleFilter('ksort', [$this, 'ksortFilter']),
+ new \Twig_SimpleFilter('ltrim', [$this, 'ltrimFilter']),
+ new \Twig_SimpleFilter('markdown', [$this, 'markdownFunction'], ['needs_context' => true, 'is_safe' => ['html']]),
+ new \Twig_SimpleFilter('md5', [$this, 'md5Filter']),
+ new \Twig_SimpleFilter('base32_encode', [$this, 'base32EncodeFilter']),
+ new \Twig_SimpleFilter('base32_decode', [$this, 'base32DecodeFilter']),
+ new \Twig_SimpleFilter('base64_encode', [$this, 'base64EncodeFilter']),
+ new \Twig_SimpleFilter('base64_decode', [$this, 'base64DecodeFilter']),
+ new \Twig_SimpleFilter('randomize', [$this, 'randomizeFilter']),
+ new \Twig_SimpleFilter('modulus', [$this, 'modulusFilter']),
+ new \Twig_SimpleFilter('rtrim', [$this, 'rtrimFilter']),
+ new \Twig_SimpleFilter('pad', [$this, 'padFilter']),
+ new \Twig_SimpleFilter('regex_replace', [$this, 'regexReplace']),
+ new \Twig_SimpleFilter('safe_email', [$this, 'safeEmailFilter']),
+ new \Twig_SimpleFilter('safe_truncate', ['\Grav\Common\Utils', 'safeTruncate']),
+ new \Twig_SimpleFilter('safe_truncate_html', ['\Grav\Common\Utils', 'safeTruncateHTML']),
+ new \Twig_SimpleFilter('sort_by_key', [$this, 'sortByKeyFilter']),
+ new \Twig_SimpleFilter('starts_with', [$this, 'startsWithFilter']),
+ new \Twig_SimpleFilter('truncate', ['\Grav\Common\Utils', 'truncate']),
+ new \Twig_SimpleFilter('truncate_html', ['\Grav\Common\Utils', 'truncateHTML']),
+ new \Twig_SimpleFilter('json_decode', [$this, 'jsonDecodeFilter']),
+ new \Twig_SimpleFilter('array_unique', 'array_unique'),
+ new \Twig_SimpleFilter('basename', 'basename'),
+ new \Twig_SimpleFilter('dirname', 'dirname'),
+ new \Twig_SimpleFilter('print_r', 'print_r'),
+ new \Twig_SimpleFilter('yaml_encode', [$this, 'yamlEncodeFilter']),
+ new \Twig_SimpleFilter('yaml_decode', [$this, 'yamlDecodeFilter']),
+ new \Twig_SimpleFilter('nicecron', [$this, 'niceCronFilter']),
+
+ // Translations
+ new \Twig_SimpleFilter('t', [$this, 'translate'], ['needs_environment' => true]),
+ new \Twig_SimpleFilter('tl', [$this, 'translateLanguage']),
+ new \Twig_SimpleFilter('ta', [$this, 'translateArray']),
+
+ // Casting values
+ new \Twig_SimpleFilter('string', [$this, 'stringFilter']),
+ new \Twig_SimpleFilter('int', [$this, 'intFilter'], ['is_safe' => ['all']]),
+ new \Twig_SimpleFilter('bool', [$this, 'boolFilter']),
+ new \Twig_SimpleFilter('float', [$this, 'floatFilter'], ['is_safe' => ['all']]),
+ new \Twig_SimpleFilter('array', [$this, 'arrayFilter']),
+
+ // Object Types
+ new \Twig_SimpleFilter('get_type', [$this, 'getTypeFunc']),
+ new \Twig_SimpleFilter('of_type', [$this, 'ofTypeFunc'])
+ ];
+ }
+
+ /**
+ * Return a list of all functions.
+ *
+ * @return array
+ */
+ public function getFunctions()
+ {
+ return [
+ new \Twig_SimpleFunction('array', [$this, 'arrayFilter']),
+ new \Twig_SimpleFunction('array_key_value', [$this, 'arrayKeyValueFunc']),
+ new \Twig_SimpleFunction('array_key_exists', 'array_key_exists'),
+ new \Twig_SimpleFunction('array_unique', 'array_unique'),
+ new \Twig_SimpleFunction('array_intersect', [$this, 'arrayIntersectFunc']),
+ new \Twig_SimpleFunction('authorize', [$this, 'authorize']),
+ new \Twig_SimpleFunction('debug', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
+ new \Twig_SimpleFunction('dump', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
+ new \Twig_SimpleFunction('vardump', [$this, 'vardumpFunc']),
+ new \Twig_SimpleFunction('print_r', 'print_r'),
+ new \Twig_SimpleFunction('http_response_code', 'http_response_code'),
+ new \Twig_SimpleFunction('evaluate', [$this, 'evaluateStringFunc'], ['needs_context' => true]),
+ new \Twig_SimpleFunction('evaluate_twig', [$this, 'evaluateTwigFunc'], ['needs_context' => true]),
+ new \Twig_SimpleFunction('gist', [$this, 'gistFunc']),
+ new \Twig_SimpleFunction('nonce_field', [$this, 'nonceFieldFunc']),
+ new \Twig_SimpleFunction('pathinfo', 'pathinfo'),
+ new \Twig_SimpleFunction('random_string', [$this, 'randomStringFunc']),
+ new \Twig_SimpleFunction('repeat', [$this, 'repeatFunc']),
+ new \Twig_SimpleFunction('regex_replace', [$this, 'regexReplace']),
+ new \Twig_SimpleFunction('regex_filter', [$this, 'regexFilter']),
+ new \Twig_SimpleFunction('string', [$this, 'stringFunc']),
+ new \Twig_SimpleFunction('url', [$this, 'urlFunc']),
+ new \Twig_SimpleFunction('json_decode', [$this, 'jsonDecodeFilter']),
+ new \Twig_SimpleFunction('get_cookie', [$this, 'getCookie']),
+ new \Twig_SimpleFunction('redirect_me', [$this, 'redirectFunc']),
+ new \Twig_SimpleFunction('range', [$this, 'rangeFunc']),
+ new \Twig_SimpleFunction('isajaxrequest', [$this, 'isAjaxFunc']),
+ new \Twig_SimpleFunction('exif', [$this, 'exifFunc']),
+ new \Twig_SimpleFunction('media_directory', [$this, 'mediaDirFunc']),
+ new \Twig_SimpleFunction('body_class', [$this, 'bodyClassFunc']),
+ new \Twig_SimpleFunction('theme_var', [$this, 'themeVarFunc'], ['needs_context' => true]),
+ new \Twig_SimpleFunction('header_var', [$this, 'pageHeaderVarFunc'], ['needs_context' => true]),
+ new \Twig_SimpleFunction('read_file', [$this, 'readFileFunc']),
+ new \Twig_SimpleFunction('nicenumber', [$this, 'niceNumberFunc']),
+ new \Twig_SimpleFunction('nicefilesize', [$this, 'niceFilesizeFunc']),
+ new \Twig_SimpleFunction('nicetime', [$this, 'nicetimeFunc']),
+ new \Twig_SimpleFunction('cron', [$this, 'cronFunc']),
+ new \Twig_SimpleFunction('svg_image', [$this, 'svgImageFunction']),
+ new \Twig_SimpleFunction('xss', [$this, 'xssFunc']),
+
+
+ // Translations
+ new \Twig_SimpleFunction('t', [$this, 'translate'], ['needs_environment' => true]),
+ new \Twig_SimpleFunction('tl', [$this, 'translateLanguage']),
+ new \Twig_SimpleFunction('ta', [$this, 'translateArray']),
+
+ // Object Types
+ new \Twig_SimpleFunction('get_type', [$this, 'getTypeFunc']),
+ new \Twig_SimpleFunction('of_type', [$this, 'ofTypeFunc'])
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ public function getTokenParsers()
+ {
+ return [
+ new TwigTokenParserRender(),
+ new TwigTokenParserThrow(),
+ new TwigTokenParserTryCatch(),
+ new TwigTokenParserScript(),
+ new TwigTokenParserStyle(),
+ new TwigTokenParserMarkdown(),
+ new TwigTokenParserSwitch(),
+ new TwigTokenParserCache(),
+ ];
+ }
+
+ /**
+ * Filters field name by changing dot notation into array notation.
+ *
+ * @param string $str
+ *
+ * @return string
+ */
+ public function fieldNameFilter($str)
+ {
+ $path = explode('.', rtrim($str, '.'));
+
+ return array_shift($path) . ($path ? '[' . implode('][', $path) . ']' : '');
+ }
+
+ /**
+ * Protects email address.
+ *
+ * @param string $str
+ *
+ * @return string
+ */
+ public function safeEmailFilter($str)
+ {
+ $email = '';
+ for ($i = 0, $len = strlen($str); $i < $len; $i++) {
+ $j = random_int(0, 1);
+
+ $email .= $j === 0 ? '' . ord($str[$i]) . ';' : $str[$i];
+ }
+
+ return str_replace('@', '@', $email);
+ }
+
+ /**
+ * Returns array in a random order.
+ *
+ * @param array $original
+ * @param int $offset Can be used to return only slice of the array.
+ *
+ * @return array
+ */
+ public function randomizeFilter($original, $offset = 0)
+ {
+ if (!\is_array($original)) {
+ return $original;
+ }
+
+ if ($original instanceof \Traversable) {
+ $original = iterator_to_array($original, false);
+ }
+
+ $sorted = [];
+ $random = array_slice($original, $offset);
+ shuffle($random);
+
+ $sizeOf = \count($original);
+ for ($x = 0; $x < $sizeOf; $x++) {
+ if ($x < $offset) {
+ $sorted[] = $original[$x];
+ } else {
+ $sorted[] = array_shift($random);
+ }
+ }
+
+ return $sorted;
+ }
+
+ /**
+ * Returns the modulus of an integer
+ *
+ * @param string|int $number
+ * @param int $divider
+ * @param array $items array of items to select from to return
+ *
+ * @return int
+ */
+ public function modulusFilter($number, $divider, $items = null)
+ {
+ if (\is_string($number)) {
+ $number = strlen($number);
+ }
+
+ $remainder = $number % $divider;
+
+ if (\is_array($items)) {
+ return $items[$remainder] ?? $items[0];
+ }
+
+ return $remainder;
+ }
+
+ /**
+ * Inflector supports following notations:
+ *
+ * `{{ 'person'|pluralize }} => people`
+ * `{{ 'shoes'|singularize }} => shoe`
+ * `{{ 'welcome page'|titleize }} => "Welcome Page"`
+ * `{{ 'send_email'|camelize }} => SendEmail`
+ * `{{ 'CamelCased'|underscorize }} => camel_cased`
+ * `{{ 'Something Text'|hyphenize }} => something-text`
+ * `{{ 'something_text_to_read'|humanize }} => "Something text to read"`
+ * `{{ '181'|monthize }} => 5`
+ * `{{ '10'|ordinalize }} => 10th`
+ *
+ * @param string $action
+ * @param string $data
+ * @param int $count
+ *
+ * @return string
+ */
+ public function inflectorFilter($action, $data, $count = null)
+ {
+ $action .= 'ize';
+
+ $inflector = $this->grav['inflector'];
+
+ if (\in_array(
+ $action,
+ ['titleize', 'camelize', 'underscorize', 'hyphenize', 'humanize', 'ordinalize', 'monthize'],
+ true
+ )) {
+ return $inflector->{$action}($data);
+ }
+
+ if (\in_array($action, ['pluralize', 'singularize'], true)) {
+ return $count ? $inflector->{$action}($data, $count) : $inflector->{$action}($data);
+ }
+
+ return $data;
+ }
+
+ /**
+ * Return MD5 hash from the input.
+ *
+ * @param string $str
+ *
+ * @return string
+ */
+ public function md5Filter($str)
+ {
+ return md5($str);
+ }
+
+ /**
+ * Return Base32 encoded string
+ *
+ * @param string $str
+ * @return string
+ */
+ public function base32EncodeFilter($str)
+ {
+ return Base32::encode($str);
+ }
+
+ /**
+ * Return Base32 decoded string
+ *
+ * @param string $str
+ * @return bool|string
+ */
+ public function base32DecodeFilter($str)
+ {
+ return Base32::decode($str);
+ }
+
+ /**
+ * Return Base64 encoded string
+ *
+ * @param string $str
+ * @return string
+ */
+ public function base64EncodeFilter($str)
+ {
+ return base64_encode($str);
+ }
+
+ /**
+ * Return Base64 decoded string
+ *
+ * @param string $str
+ * @return bool|string
+ */
+ public function base64DecodeFilter($str)
+ {
+ return base64_decode($str);
+ }
+
+
+ /**
+ * Sorts a collection by key
+ *
+ * @param array $input
+ * @param string $filter
+ * @param int $direction
+ * @param int $sort_flags
+ *
+ * @return array
+ */
+ public function sortByKeyFilter($input, $filter, $direction = SORT_ASC, $sort_flags = SORT_REGULAR)
+ {
+ return Utils::sortArrayByKey($input, $filter, $direction, $sort_flags);
+ }
+
+ /**
+ * Return ksorted collection.
+ *
+ * @param array $array
+ *
+ * @return array
+ */
+ public function ksortFilter($array)
+ {
+ if (null === $array) {
+ $array = [];
+ }
+ ksort($array);
+
+ return $array;
+ }
+
+ /**
+ * Wrapper for chunk_split() function
+ *
+ * @param string $value
+ * @param int $chars
+ * @param string $split
+ * @return string
+ */
+ public function chunkSplitFilter($value, $chars, $split = '-')
+ {
+ return chunk_split($value, $chars, $split);
+ }
+
+ /**
+ * determine if a string contains another
+ *
+ * @param string $haystack
+ * @param string $needle
+ *
+ * @return bool
+ */
+ public function containsFilter($haystack, $needle)
+ {
+ if (empty($needle)) {
+ return $haystack;
+ }
+
+ return (strpos($haystack, (string) $needle) !== false);
+ }
+
+ /**
+ * Gets a human readable output for cron syntax
+ *
+ * @param $at
+ * @return string
+ */
+ public function niceCronFilter($at)
+ {
+ $cron = new Cron($at);
+ return $cron->getText('en');
+ }
+
+ /**
+ * Get Cron object for a crontab 'at' format
+ *
+ * @param string $at
+ * @return CronExpression
+ */
+ public function cronFunc($at)
+ {
+ return CronExpression::factory($at);
+ }
+
+ /**
+ * displays a facebook style 'time ago' formatted date/time
+ *
+ * @param string $date
+ * @param bool $long_strings
+ *
+ * @param bool $show_tense
+ * @return bool
+ */
+ public function nicetimeFunc($date, $long_strings = true, $show_tense = true)
+ {
+ if (empty($date)) {
+ return $this->grav['language']->translate('GRAV.NICETIME.NO_DATE_PROVIDED', null, true);
+ }
+
+ if ($long_strings) {
+ $periods = [
+ 'NICETIME.SECOND',
+ 'NICETIME.MINUTE',
+ 'NICETIME.HOUR',
+ 'NICETIME.DAY',
+ 'NICETIME.WEEK',
+ 'NICETIME.MONTH',
+ 'NICETIME.YEAR',
+ 'NICETIME.DECADE'
+ ];
+ } else {
+ $periods = [
+ 'NICETIME.SEC',
+ 'NICETIME.MIN',
+ 'NICETIME.HR',
+ 'NICETIME.DAY',
+ 'NICETIME.WK',
+ 'NICETIME.MO',
+ 'NICETIME.YR',
+ 'NICETIME.DEC'
+ ];
+ }
+
+ $lengths = ['60', '60', '24', '7', '4.35', '12', '10'];
+
+ $now = time();
+
+ // check if unix timestamp
+ if ((string)(int)$date === (string)$date) {
+ $unix_date = $date;
+ } else {
+ $unix_date = strtotime($date);
+ }
+
+ // check validity of date
+ if (empty($unix_date)) {
+ return $this->grav['language']->translate('GRAV.NICETIME.BAD_DATE', null, true);
+ }
+
+ // is it future date or past date
+ if ($now > $unix_date) {
+ $difference = $now - $unix_date;
+ $tense = $this->grav['language']->translate('GRAV.NICETIME.AGO', null, true);
+
+ } elseif ($now == $unix_date) {
+ $difference = $now - $unix_date;
+ $tense = $this->grav['language']->translate('GRAV.NICETIME.JUST_NOW', null, false);
+
+ } else {
+ $difference = $unix_date - $now;
+ $tense = $this->grav['language']->translate('GRAV.NICETIME.FROM_NOW', null, true);
+ }
+
+ for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) {
+ $difference /= $lengths[$j];
+ }
+
+ $difference = round($difference);
+
+ if ($difference != 1) {
+ $periods[$j] .= '_PLURAL';
+ }
+
+ if ($this->grav['language']->getTranslation($this->grav['language']->getLanguage(),
+ $periods[$j] . '_MORE_THAN_TWO')
+ ) {
+ if ($difference > 2) {
+ $periods[$j] .= '_MORE_THAN_TWO';
+ }
+ }
+
+ $periods[$j] = $this->grav['language']->translate('GRAV.'.$periods[$j], null, true);
+
+ if ($now == $unix_date) {
+ return $tense;
+ }
+
+ $time = "{$difference} {$periods[$j]}";
+ $time .= $show_tense ? " {$tense}" : '';
+
+ return $time;
+ }
+
+ /**
+ * Allow quick check of a string for XSS Vulnerabilities
+ *
+ * @param string|array $data
+ * @return bool|string|array
+ */
+ public function xssFunc($data)
+ {
+ if (!\is_array($data)) {
+ return Security::detectXss($data);
+ }
+
+ $results = Security::detectXssFromArray($data);
+ $results_parts = array_map(function($value, $key) {
+ return $key.': \''.$value . '\'';
+ }, array_values($results), array_keys($results));
+
+ return implode(', ', $results_parts);
+ }
+
+ /**
+ * @param string $string
+ *
+ * @return mixed
+ */
+ public function absoluteUrlFilter($string)
+ {
+ $url = $this->grav['uri']->base();
+ $string = preg_replace('/((?:href|src) *= *[\'"](?!(http|ftp)))/i', "$1$url", $string);
+
+ return $string;
+
+ }
+
+ /**
+ * @param string $string
+ *
+ * @param array $context
+ * @param bool $block Block or Line processing
+ * @return mixed|string
+ */
+ public function markdownFunction($context, $string, $block = true)
+ {
+ $page = $context['page'] ?? null;
+ return Utils::processMarkdown($string, $block, $page);
+ }
+
+ /**
+ * @param string $haystack
+ * @param string $needle
+ *
+ * @return bool
+ */
+ public function startsWithFilter($haystack, $needle)
+ {
+ return Utils::startsWith($haystack, $needle);
+ }
+
+ /**
+ * @param string $haystack
+ * @param string $needle
+ *
+ * @return bool
+ */
+ public function endsWithFilter($haystack, $needle)
+ {
+ return Utils::endsWith($haystack, $needle);
+ }
+
+ /**
+ * @param mixed $value
+ * @param null $default
+ *
+ * @return null
+ */
+ public function definedDefaultFilter($value, $default = null)
+ {
+ return null !== $value ? $value : $default;
+ }
+
+ /**
+ * @param string $value
+ * @param null $chars
+ *
+ * @return string
+ */
+ public function rtrimFilter($value, $chars = null)
+ {
+ return rtrim($value, $chars);
+ }
+
+ /**
+ * @param string $value
+ * @param null $chars
+ *
+ * @return string
+ */
+ public function ltrimFilter($value, $chars = null)
+ {
+ return ltrim($value, $chars);
+ }
+
+ /**
+ * Casts input to string.
+ *
+ * @param mixed $input
+ * @return string
+ */
+ public function stringFilter($input)
+ {
+ return (string) $input;
+ }
+
+
+ /**
+ * Casts input to int.
+ *
+ * @param mixed $input
+ * @return int
+ */
+ public function intFilter($input)
+ {
+ return (int) $input;
+ }
+
+ /**
+ * Casts input to bool.
+ *
+ * @param mixed $input
+ * @return bool
+ */
+ public function boolFilter($input)
+ {
+ return (bool) $input;
+ }
+
+ /**
+ * Casts input to float.
+ *
+ * @param mixed $input
+ * @return float
+ */
+ public function floatFilter($input)
+ {
+ return (float) $input;
+ }
+
+ /**
+ * Casts input to array.
+ *
+ * @param mixed $input
+ * @return array
+ */
+ public function arrayFilter($input)
+ {
+ return (array) $input;
+ }
+
+ /**
+ * @return string
+ */
+ public function translate(\Twig_Environment $twig)
+ {
+ // shift off the environment
+ $args = func_get_args();
+ array_shift($args);
+
+ // If admin and tu filter provided, use it
+ if (isset($this->grav['admin'])) {
+ $numargs = count($args);
+ $lang = null;
+
+ if (($numargs === 3 && is_array($args[1])) || ($numargs === 2 && !is_array($args[1]))) {
+ $lang = array_pop($args);
+ } elseif ($numargs === 2 && is_array($args[1])) {
+ $subs = array_pop($args);
+ $args = array_merge($args, $subs);
+ }
+
+ return $this->grav['admin']->translate($args, $lang);
+ }
+
+ // else use the default grav translate functionality
+ return $this->grav['language']->translate($args);
+ }
+
+ /**
+ * Translate Strings
+ *
+ * @param string|array $args
+ * @param array|null $languages
+ * @param bool $array_support
+ * @param bool $html_out
+ * @return string
+ */
+ public function translateLanguage($args, array $languages = null, $array_support = false, $html_out = false)
+ {
+ /** @var Language $language */
+ $language = $this->grav['language'];
+
+ return $language->translate($args, $languages, $array_support, $html_out);
+ }
+
+ /**
+ * @param string $key
+ * @param string $index
+ * @param array|null $lang
+ * @return string
+ */
+ public function translateArray($key, $index, $lang = null)
+ {
+ /** @var Language $language */
+ $language = $this->grav['language'];
+
+ return $language->translateArray($key, $index, $lang);
+ }
+
+ /**
+ * Repeat given string x times.
+ *
+ * @param string $input
+ * @param int $multiplier
+ *
+ * @return string
+ */
+ public function repeatFunc($input, $multiplier)
+ {
+ return str_repeat($input, $multiplier);
+ }
+
+ /**
+ * Return URL to the resource.
+ *
+ * @example {{ url('theme://images/logo.png')|default('http://www.placehold.it/150x100/f4f4f4') }}
+ *
+ * @param string $input Resource to be located.
+ * @param bool $domain True to include domain name.
+ *
+ * @return string|null Returns url to the resource or null if resource was not found.
+ */
+ public function urlFunc($input, $domain = false)
+ {
+ return Utils::url($input, $domain);
+ }
+
+ /**
+ * This function will evaluate Twig $twig through the $environment, and return its results.
+ *
+ * @param array $context
+ * @param string $twig
+ * @return mixed
+ */
+ public function evaluateTwigFunc($context, $twig ) {
+
+ $loader = new \Twig_Loader_Filesystem('.');
+ $env = new \Twig_Environment($loader);
+
+ $template = $env->createTemplate($twig);
+
+ return $template->render($context);
+ }
+
+ /**
+ * This function will evaluate a $string through the $environment, and return its results.
+ *
+ * @param array $context
+ * @param string $string
+ * @return mixed
+ */
+ public function evaluateStringFunc($context, $string )
+ {
+ return $this->evaluateTwigFunc($context, "{{ $string }}");
+ }
+
+
+ /**
+ * Based on Twig_Extension_Debug / twig_var_dump
+ * (c) 2011 Fabien Potencier
+ *
+ * @param \Twig_Environment $env
+ * @param string $context
+ */
+ public function dump(\Twig_Environment $env, $context)
+ {
+ if (!$env->isDebug() || !$this->debugger) {
+ return;
+ }
+
+ $count = func_num_args();
+ if (2 === $count) {
+ $data = [];
+ foreach ($context as $key => $value) {
+ if (is_object($value)) {
+ if (method_exists($value, 'toArray')) {
+ $data[$key] = $value->toArray();
+ } else {
+ $data[$key] = "Object (" . get_class($value) . ")";
+ }
+ } else {
+ $data[$key] = $value;
+ }
+ }
+ $this->debugger->addMessage($data, 'debug');
+ } else {
+ for ($i = 2; $i < $count; $i++) {
+ $this->debugger->addMessage(func_get_arg($i), 'debug');
+ }
+ }
+ }
+
+ /**
+ * Output a Gist
+ *
+ * @param string $id
+ * @param string|bool $file
+ *
+ * @return string
+ */
+ public function gistFunc($id, $file = false)
+ {
+ $url = 'https://gist.github.com/' . $id . '.js';
+ if ($file) {
+ $url .= '?file=' . $file;
+ }
+ return '';
+ }
+
+ /**
+ * Generate a random string
+ *
+ * @param int $count
+ *
+ * @return string
+ */
+ public function randomStringFunc($count = 5)
+ {
+ return Utils::generateRandomString($count);
+ }
+
+ /**
+ * Pad a string to a certain length with another string
+ *
+ * @param string $input
+ * @param int $pad_length
+ * @param string $pad_string
+ * @param int $pad_type
+ *
+ * @return string
+ */
+ public static function padFilter($input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT)
+ {
+ return str_pad($input, (int)$pad_length, $pad_string, $pad_type);
+ }
+
+ /**
+ * Workaround for twig associative array initialization
+ * Returns a key => val array
+ *
+ * @param string $key key of item
+ * @param string $val value of item
+ * @param array $current_array optional array to add to
+ *
+ * @return array
+ */
+ public function arrayKeyValueFunc($key, $val, $current_array = null)
+ {
+ if (empty($current_array)) {
+ return array($key => $val);
+ }
+
+ $current_array[$key] = $val;
+
+ return $current_array;
+ }
+
+ /**
+ * Wrapper for array_intersect() method
+ *
+ * @param array $array1
+ * @param array $array2
+ * @return array
+ */
+ public function arrayIntersectFunc($array1, $array2)
+ {
+ if ($array1 instanceof Collection && $array2 instanceof Collection) {
+ return $array1->intersect($array2);
+ }
+
+ return array_intersect($array1, $array2);
+ }
+
+ /**
+ * Returns a string from a value. If the value is array, return it json encoded
+ *
+ * @param array|string $value
+ *
+ * @return string
+ */
+ public function stringFunc($value)
+ {
+ if (is_array($value)) { //format the array as a string
+ return json_encode($value);
+ }
+
+ return $value;
+ }
+
+ /**
+ * Translate a string
+ *
+ * @return string
+ */
+ public function translateFunc()
+ {
+ return $this->grav['language']->translate(func_get_args());
+ }
+
+ /**
+ * Authorize an action. Returns true if the user is logged in and
+ * has the right to execute $action.
+ *
+ * @param string|array $action An action or a list of actions. Each
+ * entry can be a string like 'group.action'
+ * or without dot notation an associative
+ * array.
+ * @return bool Returns TRUE if the user is authorized to
+ * perform the action, FALSE otherwise.
+ */
+ public function authorize($action)
+ {
+ /** @var UserInterface|null $user */
+ $user = $this->grav['user'] ?? null;
+
+ if (!$user || !$user->authenticated || (isset($user->authorized) && !$user->authorized)) {
+ return false;
+ }
+
+ $action = (array) $action;
+ foreach ($action as $key => $perms) {
+ $prefix = is_int($key) ? '' : $key . '.';
+ $perms = $prefix ? (array) $perms : [$perms => true];
+ foreach ($perms as $action2 => $authenticated) {
+ if ($user->authorize($prefix . $action2)) {
+ return $authenticated;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Used to add a nonce to a form. Call {{ nonce_field('action') }} specifying a string representing the action.
+ *
+ * For maximum protection, ensure that the string representing the action is as specific as possible
+ *
+ * @param string $action the action
+ * @param string $nonceParamName a custom nonce param name
+ *
+ * @return string the nonce input field
+ */
+ public function nonceFieldFunc($action, $nonceParamName = 'nonce')
+ {
+ $string = ' ';
+
+ return $string;
+ }
+
+ /**
+ * Decodes string from JSON.
+ *
+ * @param string $str
+ * @param bool $assoc
+ * @param int $depth
+ * @param int $options
+ * @return array
+ */
+ public function jsonDecodeFilter($str, $assoc = false, $depth = 512, $options = 0)
+ {
+ return json_decode(html_entity_decode($str, ENT_COMPAT | ENT_HTML401, 'UTF-8'), $assoc, $depth, $options);
+ }
+
+ /**
+ * Used to retrieve a cookie value
+ *
+ * @param string $key The cookie name to retrieve
+ *
+ * @return mixed
+ */
+ public function getCookie($key)
+ {
+ return filter_input(INPUT_COOKIE, $key, FILTER_SANITIZE_STRING);
+ }
+
+ /**
+ * Twig wrapper for PHP's preg_replace method
+ *
+ * @param mixed $subject the content to perform the replacement on
+ * @param mixed $pattern the regex pattern to use for matches
+ * @param mixed $replace the replacement value either as a string or an array of replacements
+ * @param int $limit the maximum possible replacements for each pattern in each subject
+ *
+ * @return string|string[]|null the resulting content
+ */
+ public function regexReplace($subject, $pattern, $replace, $limit = -1)
+ {
+ return preg_replace($pattern, $replace, $subject, $limit);
+ }
+
+ /**
+ * Twig wrapper for PHP's preg_grep method
+ *
+ * @param array $array
+ * @param string $regex
+ * @param int $flags
+ * @return array
+ */
+ public function regexFilter($array, $regex, $flags = 0)
+ {
+ return preg_grep($regex, $array, $flags);
+ }
+
+ /**
+ * redirect browser from twig
+ *
+ * @param string $url the url to redirect to
+ * @param int $statusCode statusCode, default 303
+ */
+ public function redirectFunc($url, $statusCode = 303)
+ {
+ header('Location: ' . $url, true, $statusCode);
+ exit();
+ }
+
+ /**
+ * Generates an array containing a range of elements, optionally stepped
+ *
+ * @param int $start Minimum number, default 0
+ * @param int $end Maximum number, default `getrandmax()`
+ * @param int $step Increment between elements in the sequence, default 1
+ *
+ * @return array
+ */
+ public function rangeFunc($start = 0, $end = 100, $step = 1)
+ {
+ return range($start, $end, $step);
+ }
+
+ /**
+ * Check if HTTP_X_REQUESTED_WITH has been set to xmlhttprequest,
+ * in which case we may unsafely assume ajax. Non critical use only.
+ *
+ * @return bool True if HTTP_X_REQUESTED_WITH exists and has been set to xmlhttprequest
+ */
+ public function isAjaxFunc()
+ {
+ return (
+ !empty($_SERVER['HTTP_X_REQUESTED_WITH'])
+ && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
+ }
+
+ /**
+ * Get the Exif data for a file
+ *
+ * @param string $image
+ * @param bool $raw
+ * @return mixed
+ */
+ public function exifFunc($image, $raw = false)
+ {
+ if (isset($this->grav['exif'])) {
+ /** @var UniformResourceLocator $locator */
+ $locator = $this->grav['locator'];
+
+ if ($locator->isStream($image)) {
+ $image = $locator->findResource($image);
+ }
+
+ $exif_reader = $this->grav['exif']->getReader();
+
+ if ($image && file_exists($image) && $this->config->get('system.media.auto_metadata_exif') && $exif_reader) {
+
+ $exif_data = $exif_reader->read($image);
+
+ if ($exif_data) {
+ if ($raw) {
+ return $exif_data->getRawData();
+ }
+
+ return $exif_data->getData();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Simple function to read a file based on a filepath and output it
+ *
+ * @param string $filepath
+ * @return bool|string
+ */
+ public function readFileFunc($filepath)
+ {
+ /** @var UniformResourceLocator $locator */
+ $locator = $this->grav['locator'];
+
+ if ($locator->isStream($filepath)) {
+ $filepath = $locator->findResource($filepath);
+ }
+
+ if ($filepath && file_exists($filepath)) {
+ return file_get_contents($filepath);
+ }
+
+ return false;
+ }
+
+ /**
+ * Process a folder as Media and return a media object
+ *
+ * @param string $media_dir
+ * @return Media|null
+ */
+ public function mediaDirFunc($media_dir)
+ {
+ /** @var UniformResourceLocator $locator */
+ $locator = $this->grav['locator'];
+
+ if ($locator->isStream($media_dir)) {
+ $media_dir = $locator->findResource($media_dir);
+ }
+
+ if ($media_dir && file_exists($media_dir)) {
+ return new Media($media_dir);
+ }
+
+ return null;
+ }
+
+ /**
+ * Dump a variable to the browser
+ *
+ * @param mixed $var
+ */
+ public function vardumpFunc($var)
+ {
+ var_dump($var);
+ }
+
+ /**
+ * Returns a nicer more readable filesize based on bytes
+ *
+ * @param int $bytes
+ * @return string
+ */
+ public function niceFilesizeFunc($bytes)
+ {
+ return Utils::prettySize($bytes);
+ }
+
+ /**
+ * Returns a nicer more readable number
+ *
+ * @param int|float|string $n
+ * @return string|bool
+ */
+ public function niceNumberFunc($n)
+ {
+ if (!\is_float($n) && !\is_int($n)) {
+ if (!\is_string($n) || $n === '') {
+ return false;
+ }
+
+ // Strip any thousand formatting and find the first number.
+ $list = array_filter(preg_split("/\D+/", str_replace(',', '', $n)));
+ $n = reset($list);
+
+ if (!\is_numeric($n)) {
+ return false;
+ }
+
+ $n = (float)$n;
+ }
+
+ // now filter it;
+ if ($n > 1000000000000) {
+ return round($n/1000000000000, 2).' t';
+ }
+ if ($n > 1000000000) {
+ return round($n/1000000000, 2).' b';
+ }
+ if ($n > 1000000) {
+ return round($n/1000000, 2).' m';
+ }
+ if ($n > 1000) {
+ return round($n/1000, 2).' k';
+ }
+
+ return number_format($n);
+ }
+
+ /**
+ * Get a theme variable
+ * Will try to get the variable for the current page, if not found, it tries it's parent page on up to root.
+ * If still not found, will use the theme's configuration value,
+ * If still not found, will use the $default value passed in
+ *
+ * @param $context Twig Context
+ * @param string $var variable to be found (using dot notation)
+ * @param null $default the default value to be used as last resort
+ * @param null $page an optional page to use for the current page
+ * @param bool $exists toggle to simply return the page where the variable is set, else null
+ * @return string
+ */
+ public function themeVarFunc($context, $var, $default = null, $page = null, $exists = false)
+ {
+ $page = $page ?? $context['page'] ?? Grav::instance()['page'] ?? null;
+
+ // Try to find var in the page headers
+ if ($page instanceof PageInterface && $page->exists()) {
+ // Loop over pages and look for header vars
+ while ($page && !$page->root()) {
+ $header = new Data((array)$page->header());
+ $value = $header->get($var);
+ if (isset($value)) {
+ if ($exists) {
+ return $page;
+ } else {
+ return $value;
+ }
+
+ }
+ $page = $page->parent();
+ }
+ }
+
+ if ($exists) {
+ return false;
+ } else {
+ return Grav::instance()['config']->get('theme.' . $var, $default);
+ }
+ }
+
+ /**
+ * Look for a page header variable in an array of pages working its way through until a value is found
+ *
+ * @param $context
+ * @param string $var the variable to look for in the page header
+ * @param string|string[]|null $pages array of pages to check (current page upwards if not null)
+ * @param bool $exists if true, return the page where the var is found, not the value
+ * @return mixed
+ * @deprecated 1.7 Use themeVarFunc() instead
+ */
+ public function pageHeaderVarFunc($context, $var, $pages = null)
+ {
+ if (is_array($pages)) {
+ $page = array_shift($pages);
+ } else {
+ $page = null;
+ }
+ return $this->themeVarFunc($context, $var, null, $page);
+ }
+
+ /**
+ * takes an array of classes, and if they are not set on body_classes
+ * look to see if they are set in theme config
+ *
+ * @param string|string[] $classes
+ * @return string
+ */
+ public function bodyClassFunc($classes)
+ {
+
+ $header = $this->grav['page']->header();
+ $body_classes = $header->body_classes ?? '';
+
+ foreach ((array)$classes as $class) {
+ if (!empty($body_classes) && Utils::contains($body_classes, $class)) {
+ continue;
+ }
+
+ $val = $this->config->get('theme.' . $class, false) ? $class : false;
+ $body_classes .= $val ? ' ' . $val : '';
+ }
+
+ return $body_classes;
+ }
+
+ /**
+ * Dump/Encode data into YAML format
+ *
+ * @param array $data
+ * @param int $inline integer number of levels of inline syntax
+ * @return string
+ */
+ public function yamlEncodeFilter($data, $inline = 10)
+ {
+ return Yaml::dump($data, $inline);
+ }
+
+ /**
+ * Decode/Parse data from YAML format
+ *
+ * @param string $data
+ * @return array
+ */
+ public function yamlDecodeFilter($data)
+ {
+ return Yaml::parse($data);
+ }
+
+ /**
+ * Function/Filter to return the type of variable
+ *
+ * @param mixed $var
+ * @return string
+ */
+ public function getTypeFunc($var)
+ {
+ return gettype($var);
+ }
+
+ /**
+ * Function/Filter to test type of variable
+ *
+ * @param mixed $var
+ * @param string|null $typeTest
+ * @param string|null $className
+ * @return bool
+ */
+ public function ofTypeFunc($var, $typeTest=null, $className=null)
+ {
+
+ switch ($typeTest)
+ {
+ default:
+ return false;
+ break;
+
+ case 'array':
+ return is_array($var);
+ break;
+
+ case 'bool':
+ return is_bool($var);
+ break;
+
+ case 'class':
+ return is_object($var) === true && get_class($var) === $className;
+ break;
+
+ case 'float':
+ return is_float($var);
+ break;
+
+ case 'int':
+ return is_int($var);
+ break;
+
+ case 'numeric':
+ return is_numeric($var);
+ break;
+
+ case 'object':
+ return is_object($var);
+ break;
+
+ case 'scalar':
+ return is_scalar($var);
+ break;
+
+ case 'string':
+ return is_string($var);
+ break;
+ }
+ }
+
+ /**
+ * Returns the content of an SVG image and adds extra classes as needed
+ *
+ * @param $path
+ * @param $classes
+ * @return string|string[]|null
+ */
+ public static function svgImageFunction($path, $classes)
+ {
+ $path = Utils::fullPath($path);
+
+ if (file_exists($path)) {
+ $svg = file_get_contents($path);
+ $classes = " inline-block $classes";
+ $matched = false;
+
+ //Look for existing class
+ $svg = preg_replace_callback('/^/', function($matches) use ($classes, &$matched) {
+ if (isset($matches[2])) {
+ $new_classes = $matches[2] . $classes;
+ $matched = true;
+ return str_replace($matches[1], "class=\"$new_classes\"", $matches[0]);
+ }
+ }, $svg
+ );
+
+ // no matches found just add the class
+ if (!$matched) {
+ $classes = trim($classes);
+ $svg = str_replace('get('system.twig.umask_fix', false);
+ }
+
+ if (self::$umask) {
+ $dir = dirname($file);
+ if (!is_dir($dir)) {
+ $old = umask(0002);
+ Folder::create($dir);
+ umask($old);
+ }
+ parent::writeCacheFile($file, $content);
+ chmod($file, 0775);
+ } else {
+ parent::writeCacheFile($file, $content);
+ }
+ }
+}
diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php
new file mode 100644
index 0000000..32c6e41
--- /dev/null
+++ b/system/src/Grav/Common/Uri.php
@@ -0,0 +1,1435 @@
+createFromString($env);
+ } else {
+ $this->createFromEnvironment(\is_array($env) ? $env : $_SERVER);
+ }
+ }
+
+ /**
+ * Initialize the URI class with a url passed via parameter.
+ * Used for testing purposes.
+ *
+ * @param string $url the URL to use in the class
+ *
+ * @return $this
+ */
+ public function initializeWithUrl($url = '')
+ {
+ if ($url) {
+ $this->createFromString($url);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Initialize the URI class by providing url and root_path arguments
+ *
+ * @param string $url
+ * @param string $root_path
+ *
+ * @return $this
+ */
+ public function initializeWithUrlAndRootPath($url, $root_path)
+ {
+ $this->initializeWithUrl($url);
+ $this->root_path = $root_path;
+
+ return $this;
+ }
+
+ /**
+ * Validate a hostname
+ *
+ * @param string $hostname The hostname
+ *
+ * @return boolean
+ */
+ public function validateHostname($hostname)
+ {
+ return (bool)preg_match(static::HOSTNAME_REGEX, $hostname);
+ }
+
+ /**
+ * Initializes the URI object based on the url set on the object
+ */
+ public function init()
+ {
+ $grav = Grav::instance();
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ /** @var Language $language */
+ $language = $grav['language'];
+
+ // add the port to the base for non-standard ports
+ if ($this->port !== null && $config->get('system.reverse_proxy_setup') === false) {
+ $this->base .= ':' . (string)$this->port;
+ }
+
+ // Handle custom base
+ $custom_base = rtrim($grav['config']->get('system.custom_base_url'), '/');
+
+ if ($custom_base) {
+ $custom_parts = parse_url($custom_base);
+ $orig_root_path = $this->root_path;
+ $this->root_path = isset($custom_parts['path']) ? rtrim($custom_parts['path'], '/') : '';
+ if (isset($custom_parts['scheme'])) {
+ $this->base = $custom_parts['scheme'] . '://' . $custom_parts['host'];
+ $this->root = $custom_base;
+ } else {
+ $this->root = $this->base . $this->root_path;
+ }
+ $this->uri = Utils::replaceFirstOccurrence($orig_root_path, $this->root_path, $this->uri);
+ } else {
+ $this->root = $this->base . $this->root_path;
+ }
+
+ $this->url = $this->base . $this->uri;
+
+ $uri = Utils::replaceFirstOccurrence(static::filterPath($this->root), '', $this->url);
+
+ // remove the setup.php based base if set:
+ $setup_base = $grav['pages']->base();
+ if ($setup_base) {
+ $uri = preg_replace('|^' . preg_quote($setup_base, '|') . '|', '', $uri);
+ }
+
+ // process params
+ $uri = $this->processParams($uri, $config->get('system.param_sep'));
+
+ // set active language
+ $uri = $language->setActiveFromUri($uri);
+
+ // split the URL and params
+ $bits = parse_url($uri);
+
+ //process fragment
+ if (isset($bits['fragment'])) {
+ $this->fragment = $bits['fragment'];
+ }
+
+ // Get the path. If there's no path, make sure pathinfo() still returns dirname variable
+ $path = $bits['path'] ?? '/';
+
+ // remove the extension if there is one set
+ $parts = pathinfo($path);
+
+ // set the original basename
+ $this->basename = $parts['basename'];
+
+ // set the extension
+ if (isset($parts['extension'])) {
+ $this->extension = $parts['extension'];
+ }
+
+ // Strip the file extension for valid page types
+ if ($this->isValidExtension($this->extension)) {
+ $path = Utils::replaceLastOccurrence(".{$this->extension}", '', $path);
+ }
+
+ // set the new url
+ $this->url = $this->root . $path;
+ $this->path = static::cleanPath($path);
+ $this->content_path = trim(Utils::replaceFirstOccurrence($this->base, '', $this->path), '/');
+ if ($this->content_path !== '') {
+ $this->paths = explode('/', $this->content_path);
+ }
+
+ // Set some Grav stuff
+ $grav['base_url_absolute'] = $config->get('system.custom_base_url') ?: $this->rootUrl(true);
+ $grav['base_url_relative'] = $this->rootUrl(false);
+ $grav['base_url'] = $config->get('system.absolute_urls') ? $grav['base_url_absolute'] : $grav['base_url_relative'];
+
+ RouteFactory::setRoot($this->root_path);
+ RouteFactory::setLanguage($language->getLanguageURLPrefix());
+ }
+
+ /**
+ * Return URI path.
+ *
+ * @param string $id
+ *
+ * @return string|string[]
+ */
+ public function paths($id = null)
+ {
+ if ($id !== null) {
+ return $this->paths[$id];
+ }
+
+ return $this->paths;
+ }
+
+ /**
+ * Return route to the current URI. By default route doesn't include base path.
+ *
+ * @param bool $absolute True to include full path.
+ * @param bool $domain True to include domain. Works only if first parameter is also true.
+ *
+ * @return string
+ */
+ public function route($absolute = false, $domain = false)
+ {
+ return ($absolute ? $this->rootUrl($domain) : '') . '/' . implode('/', $this->paths);
+ }
+
+ /**
+ * Return full query string or a single query attribute.
+ *
+ * @param string $id Optional attribute. Get a single query attribute if set
+ * @param bool $raw If true and $id is not set, return the full query array. Otherwise return the query string
+ *
+ * @return string|array Returns an array if $id = null and $raw = true
+ */
+ public function query($id = null, $raw = false)
+ {
+ if ($id !== null) {
+ return $this->queries[$id] ?? null;
+ }
+
+ if ($raw) {
+ return $this->queries;
+ }
+
+ if (!$this->queries) {
+ return '';
+ }
+
+ return http_build_query($this->queries);
+ }
+
+ /**
+ * Return all or a single query parameter as a URI compatible string.
+ *
+ * @param string $id Optional parameter name.
+ * @param boolean $array return the array format or not
+ *
+ * @return null|string|array
+ */
+ public function params($id = null, $array = false)
+ {
+ $config = Grav::instance()['config'];
+ $sep = $config->get('system.param_sep');
+
+ $params = null;
+ if ($id === null) {
+ if ($array) {
+ return $this->params;
+ }
+ $output = [];
+ foreach ($this->params as $key => $value) {
+ $output[] = "{$key}{$sep}{$value}";
+ $params = '/' . implode('/', $output);
+ }
+ } elseif (isset($this->params[$id])) {
+ if ($array) {
+ return $this->params[$id];
+ }
+ $params = "/{$id}{$sep}{$this->params[$id]}";
+ }
+
+ return $params;
+ }
+
+ /**
+ * Get URI parameter.
+ *
+ * @param string $id
+ *
+ * @return bool|string
+ */
+ public function param($id)
+ {
+ if (isset($this->params[$id])) {
+ return html_entity_decode(rawurldecode($this->params[$id]), ENT_COMPAT | ENT_HTML401, 'UTF-8');
+ }
+
+ return false;
+ }
+
+ /**
+ * Gets the Fragment portion of a URI (eg #target)
+ *
+ * @param string $fragment
+ *
+ * @return string|null
+ */
+ public function fragment($fragment = null)
+ {
+ if ($fragment !== null) {
+ $this->fragment = $fragment;
+ }
+ return $this->fragment;
+ }
+
+ /**
+ * Return URL.
+ *
+ * @param bool $include_host Include hostname.
+ *
+ * @return string
+ */
+ public function url($include_host = false)
+ {
+ if ($include_host) {
+ return $this->url;
+ }
+
+ $url = Utils::replaceFirstOccurrence($this->base, '', rtrim($this->url, '/'));
+
+ return $url ?: '/';
+ }
+
+ /**
+ * Return the Path
+ *
+ * @return String The path of the URI
+ */
+ public function path()
+ {
+ return $this->path;
+ }
+
+ /**
+ * Return the Extension of the URI
+ *
+ * @param string|null $default
+ *
+ * @return string The extension of the URI
+ */
+ public function extension($default = null)
+ {
+ if (!$this->extension) {
+ $this->extension = $default;
+ }
+
+ return $this->extension;
+ }
+
+ public function method()
+ {
+ $method = isset($_SERVER['REQUEST_METHOD']) ? strtoupper($_SERVER['REQUEST_METHOD']) : 'GET';
+
+ if ($method === 'POST' && isset($_SERVER['X-HTTP-METHOD-OVERRIDE'])) {
+ $method = strtoupper($_SERVER['X-HTTP-METHOD-OVERRIDE']);
+ }
+
+ return $method;
+ }
+
+ /**
+ * Return the scheme of the URI
+ *
+ * @param bool $raw
+ * @return string The scheme of the URI
+ */
+ public function scheme($raw = false)
+ {
+ if (!$raw) {
+ $scheme = '';
+ if ($this->scheme) {
+ $scheme = $this->scheme . '://';
+ } elseif ($this->host) {
+ $scheme = '//';
+ }
+
+ return $scheme;
+ }
+
+ return $this->scheme;
+ }
+
+
+ /**
+ * Return the host of the URI
+ *
+ * @return string|null The host of the URI
+ */
+ public function host()
+ {
+ return $this->host;
+ }
+
+ /**
+ * Return the port number if it can be figured out
+ *
+ * @param bool $raw
+ * @return int|null
+ */
+ public function port($raw = false)
+ {
+ $port = $this->port;
+ // If not in raw mode and port is not set, figure it out from scheme.
+ if (!$raw && $port === null) {
+ if ($this->scheme === 'http') {
+ $this->port = 80;
+ } elseif ($this->scheme === 'https') {
+ $this->port = 443;
+ }
+ }
+
+ return $this->port;
+ }
+
+ /**
+ * Return user
+ *
+ * @return string|null
+ */
+ public function user()
+ {
+ return $this->user;
+ }
+
+ /**
+ * Return password
+ *
+ * @return string|null
+ */
+ public function password()
+ {
+ return $this->password;
+ }
+
+ /**
+ * Gets the environment name
+ *
+ * @return String
+ */
+ public function environment()
+ {
+ return $this->env;
+ }
+
+
+ /**
+ * Return the basename of the URI
+ *
+ * @return String The basename of the URI
+ */
+ public function basename()
+ {
+ return $this->basename;
+ }
+
+ /**
+ * Return the full uri
+ *
+ * @param bool $include_root
+ * @return mixed
+ */
+ public function uri($include_root = true)
+ {
+ if ($include_root) {
+ return $this->uri;
+ }
+
+ return Utils::replaceFirstOccurrence($this->root_path, '', $this->uri);
+ }
+
+ /**
+ * Return the base of the URI
+ *
+ * @return String The base of the URI
+ */
+ public function base()
+ {
+ return $this->base;
+ }
+
+ /**
+ * Return the base relative URL including the language prefix
+ * or the base relative url if multi-language is not enabled
+ *
+ * @return String The base of the URI
+ */
+ public function baseIncludingLanguage()
+ {
+ $grav = Grav::instance();
+
+ /** @var Pages $pages */
+ $pages = $grav['pages'];
+
+ return $pages->baseUrl(null, false);
+ }
+
+ /**
+ * Return root URL to the site.
+ *
+ * @param bool $include_host Include hostname.
+ *
+ * @return mixed
+ */
+ public function rootUrl($include_host = false)
+ {
+ if ($include_host) {
+ return $this->root;
+ }
+
+ return Utils::replaceFirstOccurrence($this->base, '', $this->root);
+ }
+
+ /**
+ * Return current page number.
+ *
+ * @return int
+ */
+ public function currentPage()
+ {
+ $page = (int)($this->params['page'] ?? 1);
+
+ return max(1, $page);
+ }
+
+ /**
+ * Return relative path to the referrer defaulting to current or given page.
+ *
+ * @param string $default
+ * @param string $attributes
+ *
+ * @return string
+ */
+ public function referrer($default = null, $attributes = null)
+ {
+ $referrer = $_SERVER['HTTP_REFERER'] ?? null;
+
+ // Check that referrer came from our site.
+ $root = $this->rootUrl(true);
+ if ($referrer) {
+ // Referrer should always have host set and it should come from the same base address.
+ if (stripos($referrer, $root) !== 0) {
+ $referrer = null;
+ }
+ }
+
+ if (!$referrer) {
+ $referrer = $default ?: $this->route(true, true);
+ }
+
+ if ($attributes) {
+ $referrer .= $attributes;
+ }
+
+ // Return relative path.
+ return substr($referrer, strlen($root));
+ }
+
+ public function __toString()
+ {
+ return static::buildUrl($this->toArray());
+ }
+
+ public function toOriginalString()
+ {
+ return static::buildUrl($this->toArray(true));
+ }
+
+ public function toArray($full = false)
+ {
+ if ($full === true) {
+ $root_path = $this->root_path ?? '';
+ $extension = isset($this->extension) && $this->isValidExtension($this->extension) ? '.' . $this->extension : '';
+ $path = $root_path . $this->path . $extension;
+ } else {
+ $path = $this->path;
+ }
+
+ return [
+ 'scheme' => $this->scheme,
+ 'host' => $this->host,
+ 'port' => $this->port,
+ 'user' => $this->user,
+ 'pass' => $this->password,
+ 'path' => $path,
+ 'params' => $this->params,
+ 'query' => $this->query,
+ 'fragment' => $this->fragment
+ ];
+ }
+
+ /**
+ * Calculate the parameter regex based on the param_sep setting
+ *
+ * @return string
+ */
+ public static function paramsRegex()
+ {
+ return '/\/([^\:\#\/\?]*' . Grav::instance()['config']->get('system.param_sep') . '[^\:\#\/\?]*)/';
+ }
+
+ /**
+ * Return the IP address of the current user
+ *
+ * @return string ip address
+ */
+ public static function ip()
+ {
+ if (getenv('HTTP_CLIENT_IP')) {
+ $ip = getenv('HTTP_CLIENT_IP');
+ } elseif (getenv('HTTP_X_FORWARDED_FOR') && Grav::instance()['config']->get('system.http_x_forwarded.ip')) {
+ $ip = getenv('HTTP_X_FORWARDED_FOR');
+ } elseif (getenv('HTTP_X_FORWARDED') && Grav::instance()['config']->get('system.http_x_forwarded.ip')) {
+ $ip = getenv('HTTP_X_FORWARDED');
+ } elseif (getenv('HTTP_FORWARDED_FOR')) {
+ $ip = getenv('HTTP_FORWARDED_FOR');
+ } elseif (getenv('HTTP_FORWARDED')) {
+ $ip = getenv('HTTP_FORWARDED');
+ } elseif (getenv('REMOTE_ADDR')){
+ $ip = getenv('REMOTE_ADDR');
+ } else {
+ $ip = 'UNKNOWN';
+ }
+
+ return $ip;
+ }
+
+ /**
+ * Returns current Uri.
+ *
+ * @return \Grav\Framework\Uri\Uri
+ */
+ public static function getCurrentUri()
+ {
+ if (!static::$currentUri) {
+ static::$currentUri = UriFactory::createFromEnvironment($_SERVER);
+ }
+
+ return static::$currentUri;
+ }
+
+ /**
+ * Returns current route.
+ *
+ * @return \Grav\Framework\Route\Route
+ */
+ public static function getCurrentRoute()
+ {
+ if (!static::$currentRoute) {
+ $uri = Grav::instance()['uri'];
+ static::$currentRoute = RouteFactory::createFromParts($uri->toArray());
+ }
+
+ return static::$currentRoute;
+ }
+
+ /**
+ * Is this an external URL? if it starts with `http` then yes, else false
+ *
+ * @param string $url the URL in question
+ *
+ * @return boolean is eternal state
+ */
+ public static function isExternal($url)
+ {
+ return (0 === strpos($url, 'http://') || 0 === strpos($url, 'https://') || 0 === strpos($url, '//'));
+ }
+
+ /**
+ * The opposite of built-in PHP method parse_url()
+ *
+ * @param array $parsed_url
+ *
+ * @return string
+ */
+ public static function buildUrl($parsed_url)
+ {
+ $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . ':' : '';
+ $authority = isset($parsed_url['host']) ? '//' : '';
+ $host = $parsed_url['host'] ?? '';
+ $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
+ $user = $parsed_url['user'] ?? '';
+ $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
+ $pass = ($user || $pass) ? "{$pass}@" : '';
+ $path = $parsed_url['path'] ?? '';
+ $path = !empty($parsed_url['params']) ? rtrim($path, '/') . static::buildParams($parsed_url['params']) : $path;
+ $query = !empty($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
+ $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
+
+ return "{$scheme}{$authority}{$user}{$pass}{$host}{$port}{$path}{$query}{$fragment}";
+ }
+
+ /**
+ * @param array $params
+ * @return string
+ */
+ public static function buildParams(array $params)
+ {
+ if (!$params) {
+ return '';
+ }
+
+ $grav = Grav::instance();
+ $sep = $grav['config']->get('system.param_sep');
+
+ $output = [];
+ foreach ($params as $key => $value) {
+ $output[] = "{$key}{$sep}{$value}";
+ }
+
+ return '/' . implode('/', $output);
+ }
+
+ /**
+ * Converts links from absolute '/' or relative (../..) to a Grav friendly format
+ *
+ * @param PageInterface $page the current page to use as reference
+ * @param string|array $url the URL as it was written in the markdown
+ * @param string $type the type of URL, image | link
+ * @param bool $absolute if null, will use system default, if true will use absolute links internally
+ * @param bool $route_only only return the route, not full URL path
+ * @return string|array the more friendly formatted url
+ */
+ public static function convertUrl(PageInterface $page, $url, $type = 'link', $absolute = false, $route_only = false)
+ {
+ $grav = Grav::instance();
+
+ $uri = $grav['uri'];
+
+ // Link processing should prepend language
+ $language = $grav['language'];
+ $language_append = '';
+ if ($type === 'link' && $language->enabled()) {
+ $language_append = $language->getLanguageURLPrefix();
+ }
+
+ // Handle Excerpt style $url array
+ $url_path = is_array($url) ? $url['path'] : $url;
+
+ $external = false;
+ $base = $grav['base_url_relative'];
+ $base_url = rtrim($base . $grav['pages']->base(), '/') . $language_append;
+ $pages_dir = $grav['locator']->findResource('page://');
+
+ // if absolute and starts with a base_url move on
+ if (isset($url['scheme']) && Utils::startsWith($url['scheme'], 'http')) {
+ $external = true;
+ } elseif ($url_path === '' && isset($url['fragment'])) {
+ $external = true;
+ } elseif ($url_path === '/' || ($base_url !== '' && Utils::startsWith($url_path, $base_url))) {
+ $url_path = $base_url . $url_path;
+ } else {
+
+ // see if page is relative to this or absolute
+ if (Utils::startsWith($url_path, '/')) {
+ $normalized_url = Utils::normalizePath($base_url . $url_path);
+ $normalized_path = Utils::normalizePath($pages_dir . $url_path);
+ } else {
+ $page_route = ($page->home() && !empty($url_path)) ? $page->rawRoute() : $page->route();
+ $normalized_url = $base_url . Utils::normalizePath(rtrim($page_route, '/') . '/' . $url_path);
+ $normalized_path = Utils::normalizePath($page->path() . '/' . $url_path);
+ }
+
+ // special check to see if path checking is required.
+ $just_path = Utils::replaceFirstOccurrence($normalized_url, '', $normalized_path);
+ if ($normalized_url === '/' || $just_path === $page->path()) {
+ $url_path = $normalized_url;
+ } else {
+ $url_bits = static::parseUrl($normalized_path);
+ $full_path = $url_bits['path'];
+ $raw_full_path = rawurldecode($full_path);
+
+ if (file_exists($raw_full_path)) {
+ $full_path = $raw_full_path;
+ } elseif (!file_exists($full_path)) {
+ $full_path = false;
+ }
+
+ if ($full_path) {
+ $path_info = pathinfo($full_path);
+ $page_path = $path_info['dirname'];
+ $filename = '';
+
+ if ($url_path === '..') {
+ $page_path = $full_path;
+ } else {
+ // save the filename if a file is part of the path
+ if (is_file($full_path)) {
+ if ($path_info['extension'] !== 'md') {
+ $filename = '/' . $path_info['basename'];
+ }
+ } else {
+ $page_path = $full_path;
+ }
+ }
+
+ // get page instances and try to find one that fits
+ $instances = $grav['pages']->instances();
+ if (isset($instances[$page_path])) {
+ /** @var PageInterface $target */
+ $target = $instances[$page_path];
+ $url_bits['path'] = $base_url . rtrim($target->route(), '/') . $filename;
+
+ $url_path = Uri::buildUrl($url_bits);
+ } else {
+ $url_path = $normalized_url;
+ }
+ } else {
+ $url_path = $normalized_url;
+ }
+ }
+ }
+
+ // handle absolute URLs
+ if (\is_array($url) && !$external && ($absolute === true || $grav['config']->get('system.absolute_urls', false))) {
+
+ $url['scheme'] = $uri->scheme(true);
+ $url['host'] = $uri->host();
+ $url['port'] = $uri->port(true);
+
+ // check if page exists for this route, and if so, check if it has SSL enabled
+ $pages = $grav['pages'];
+ $routes = $pages->routes();
+
+ // if this is an image, get the proper path
+ $url_bits = pathinfo($url_path);
+ if (isset($url_bits['extension'])) {
+ $target_path = $url_bits['dirname'];
+ } else {
+ $target_path = $url_path;
+ }
+
+ // strip base from this path
+ $target_path = Utils::replaceFirstOccurrence($uri->rootUrl(), '', $target_path);
+
+ // set to / if root
+ if (empty($target_path)) {
+ $target_path = '/';
+ }
+
+ // look to see if this page exists and has ssl enabled
+ if (isset($routes[$target_path])) {
+ $target_page = $pages->get($routes[$target_path]);
+ if ($target_page) {
+ $ssl_enabled = $target_page->ssl();
+ if ($ssl_enabled !== null) {
+ if ($ssl_enabled) {
+ $url['scheme'] = 'https';
+ } else {
+ $url['scheme'] = 'http';
+ }
+ }
+ }
+ }
+ }
+
+ // Handle route only
+ if ($route_only) {
+ $url_path = Utils::replaceFirstOccurrence(static::filterPath($base_url), '', $url_path);
+ }
+
+ // transform back to string/array as needed
+ if (is_array($url)) {
+ $url['path'] = $url_path;
+ } else {
+ $url = $url_path;
+ }
+
+ return $url;
+ }
+
+ public static function parseUrl($url)
+ {
+ $grav = Grav::instance();
+
+ $encodedUrl = preg_replace_callback(
+ '%[^:/@?&=#]+%usD',
+ function ($matches) { return rawurlencode($matches[0]); },
+ $url
+ );
+
+ $parts = parse_url($encodedUrl);
+
+ if (false === $parts) {
+ return false;
+ }
+
+ foreach($parts as $name => $value) {
+ $parts[$name] = rawurldecode($value);
+ }
+
+ if (!isset($parts['path'])) {
+ $parts['path'] = '';
+ }
+
+ list($stripped_path, $params) = static::extractParams($parts['path'], $grav['config']->get('system.param_sep'));
+
+ if (!empty($params)) {
+ $parts['path'] = $stripped_path;
+ $parts['params'] = $params;
+ }
+
+ return $parts;
+ }
+
+ public static function extractParams($uri, $delimiter)
+ {
+ $params = [];
+
+ if (strpos($uri, $delimiter) !== false) {
+ preg_match_all(static::paramsRegex(), $uri, $matches, PREG_SET_ORDER);
+
+ foreach ($matches as $match) {
+ $param = explode($delimiter, $match[1]);
+ if (\count($param) === 2) {
+ $plain_var = filter_var(rawurldecode($param[1]), FILTER_SANITIZE_STRING);
+ $params[$param[0]] = $plain_var;
+ $uri = str_replace($match[0], '', $uri);
+ }
+ }
+ }
+
+ return [$uri, $params];
+ }
+
+ /**
+ * Converts links from absolute '/' or relative (../..) to a Grav friendly format
+ *
+ * @param PageInterface $page the current page to use as reference
+ * @param string $markdown_url the URL as it was written in the markdown
+ * @param string $type the type of URL, image | link
+ * @param null $relative if null, will use system default, if true will use relative links internally
+ *
+ * @return string the more friendly formatted url
+ */
+ public static function convertUrlOld(PageInterface $page, $markdown_url, $type = 'link', $relative = null)
+ {
+ $grav = Grav::instance();
+
+ $language = $grav['language'];
+
+ // Link processing should prepend language
+ $language_append = '';
+ if ($type === 'link' && $language->enabled()) {
+ $language_append = $language->getLanguageURLPrefix();
+ }
+ $pages_dir = $grav['locator']->findResource('page://');
+ if ($relative === null) {
+ $base = $grav['base_url'];
+ } else {
+ $base = $relative ? $grav['base_url_relative'] : $grav['base_url_absolute'];
+ }
+
+ $base_url = rtrim($base . $grav['pages']->base(), '/') . $language_append;
+
+ // if absolute and starts with a base_url move on
+ if (pathinfo($markdown_url, PATHINFO_DIRNAME) === '.' && $page->url() === '/') {
+ return '/' . $markdown_url;
+ }
+ // no path to convert
+ if ($base_url !== '' && Utils::startsWith($markdown_url, $base_url)) {
+ return $markdown_url;
+ }
+ // if contains only a fragment
+ if (Utils::startsWith($markdown_url, '#')) {
+ return $markdown_url;
+ }
+
+ $target = null;
+ // see if page is relative to this or absolute
+ if (Utils::startsWith($markdown_url, '/')) {
+ $normalized_url = Utils::normalizePath($base_url . $markdown_url);
+ $normalized_path = Utils::normalizePath($pages_dir . $markdown_url);
+ } else {
+ $normalized_url = $base_url . Utils::normalizePath($page->route() . '/' . $markdown_url);
+ $normalized_path = Utils::normalizePath($page->path() . '/' . $markdown_url);
+ }
+
+ // special check to see if path checking is required.
+ $just_path = Utils::replaceFirstOccurrence($normalized_url, '', $normalized_path);
+ if ($just_path === $page->path()) {
+ return $normalized_url;
+ }
+
+ $url_bits = parse_url($normalized_path);
+ $full_path = $url_bits['path'];
+
+ if (file_exists($full_path)) {
+ // do nothing
+ } elseif (file_exists(rawurldecode($full_path))) {
+ $full_path = rawurldecode($full_path);
+ } else {
+ return $normalized_url;
+ }
+
+ $path_info = pathinfo($full_path);
+ $page_path = $path_info['dirname'];
+ $filename = '';
+
+ if ($markdown_url === '..') {
+ $page_path = $full_path;
+ } else {
+ // save the filename if a file is part of the path
+ if (is_file($full_path)) {
+ if ($path_info['extension'] !== 'md') {
+ $filename = '/' . $path_info['basename'];
+ }
+ } else {
+ $page_path = $full_path;
+ }
+ }
+
+ // get page instances and try to find one that fits
+ $instances = $grav['pages']->instances();
+ if (isset($instances[$page_path])) {
+ /** @var PageInterface $target */
+ $target = $instances[$page_path];
+ $url_bits['path'] = $base_url . rtrim($target->route(), '/') . $filename;
+
+ return static::buildUrl($url_bits);
+ }
+
+ return $normalized_url;
+ }
+
+ /**
+ * Adds the nonce to a URL for a specific action
+ *
+ * @param string $url the url
+ * @param string $action the action
+ * @param string $nonceParamName the param name to use
+ *
+ * @return string the url with the nonce
+ */
+ public static function addNonce($url, $action, $nonceParamName = 'nonce')
+ {
+ $fake = $url && strpos($url, '/') === 0;
+
+ if ($fake) {
+ $url = 'http://domain.com' . $url;
+ }
+ $uri = new static($url);
+ $parts = $uri->toArray();
+ $nonce = Utils::getNonce($action);
+ $parts['params'] = ($parts['params'] ?? []) + [$nonceParamName => $nonce];
+
+ if ($fake) {
+ unset($parts['scheme'], $parts['host']);
+ }
+
+ return static::buildUrl($parts);
+ }
+
+ /**
+ * Is the passed in URL a valid URL?
+ *
+ * @param string $url
+ * @return bool
+ */
+ public static function isValidUrl($url)
+ {
+ $regex = '/^(?:(https?|ftp|telnet):)?\/\/((?:[a-z0-9@:.-]|%[0-9A-F]{2}){3,})(?::(\d+))?((?:\/(?:[a-z0-9-._~!$&\'\(\)\*\+\,\;\=\:\@]|%[0-9A-F]{2})*)*)(?:\?((?:[a-z0-9-._~!$&\'\(\)\*\+\,\;\=\:\/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&\'\(\)\*\+\,\;\=\:\/?@]|%[0-9A-F]{2})*))?/';
+ if (preg_match($regex, $url)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Removes extra double slashes and fixes back-slashes
+ *
+ * @param string $path
+ * @return mixed|string
+ */
+ public static function cleanPath($path)
+ {
+ $regex = '/(\/)\/+/';
+ $path = str_replace(['\\', '/ /'], '/', $path);
+ $path = preg_replace($regex,'$1',$path);
+
+ return $path;
+ }
+
+ /**
+ * Filters the user info string.
+ *
+ * @param string $info The raw user or password.
+ * @return string The percent-encoded user or password string.
+ */
+ public static function filterUserInfo($info)
+ {
+ return $info !== null ? UriPartsFilter::filterUserInfo($info) : '';
+ }
+
+ /**
+ * Filter Uri path.
+ *
+ * This method percent-encodes all reserved
+ * characters in the provided path string. This method
+ * will NOT double-encode characters that are already
+ * percent-encoded.
+ *
+ * @param string $path The raw uri path.
+ * @return string The RFC 3986 percent-encoded uri path.
+ * @link http://www.faqs.org/rfcs/rfc3986.html
+ */
+ public static function filterPath($path)
+ {
+ return $path !== null ? UriPartsFilter::filterPath($path) : '';
+ }
+
+ /**
+ * Filters the query string or fragment of a URI.
+ *
+ * @param string $query The raw uri query string.
+ * @return string The percent-encoded query string.
+ */
+ public static function filterQuery($query)
+ {
+ return $query !== null ? UriPartsFilter::filterQueryOrFragment($query) : '';
+ }
+
+ /**
+ * @param array $env
+ */
+ protected function createFromEnvironment(array $env)
+ {
+ // Build scheme.
+ if (isset($env['HTTP_X_FORWARDED_PROTO']) && Grav::instance()['config']->get('system.http_x_forwarded.protocol')) {
+ $this->scheme = $env['HTTP_X_FORWARDED_PROTO'];
+ } elseif (isset($env['X-FORWARDED-PROTO'])) {
+ $this->scheme = $env['X-FORWARDED-PROTO'];
+ } elseif (isset($env['HTTP_CLOUDFRONT_FORWARDED_PROTO'])) {
+ $this->scheme = $env['HTTP_CLOUDFRONT_FORWARDED_PROTO'];
+ } elseif (isset($env['REQUEST_SCHEME']) && empty($env['HTTPS'])) {
+ $this->scheme = $env['REQUEST_SCHEME'];
+ } else {
+ $https = $env['HTTPS'] ?? '';
+ $this->scheme = (empty($https) || strtolower($https) === 'off') ? 'http' : 'https';
+ }
+
+ // Build user and password.
+ $this->user = $env['PHP_AUTH_USER'] ?? null;
+ $this->password = $env['PHP_AUTH_PW'] ?? null;
+
+ // Build host.
+ if (isset($env['HTTP_X_FORWARDED_HOST']) && Grav::instance()['config']->get('system.http_x_forwarded.host')) {
+ $hostname = $env['HTTP_X_FORWARDED_HOST'];
+ } else if (isset($env['HTTP_HOST'])) {
+ $hostname = $env['HTTP_HOST'];
+ } elseif (isset($env['SERVER_NAME'])) {
+ $hostname = $env['SERVER_NAME'];
+ } else {
+ $hostname = 'localhost';
+ }
+ // Remove port from HTTP_HOST generated $hostname
+ $hostname = Utils::substrToString($hostname, ':');
+ // Validate the hostname
+ $this->host = $this->validateHostname($hostname) ? $hostname : 'unknown';
+
+ // Build port.
+ if (isset($env['HTTP_X_FORWARDED_PORT']) && Grav::instance()['config']->get('system.http_x_forwarded.port')) {
+ $this->port = (int)$env['HTTP_X_FORWARDED_PORT'];
+ } elseif (isset($env['X-FORWARDED-PORT'])) {
+ $this->port = (int)$env['X-FORWARDED-PORT'];
+ } elseif (isset($env['HTTP_CLOUDFRONT_FORWARDED_PROTO'])) {
+ // Since AWS Cloudfront does not provide a forwarded port header,
+ // we have to build the port using the scheme.
+ $this->port = $this->port();
+ } elseif (isset($env['SERVER_PORT'])) {
+ $this->port = (int)$env['SERVER_PORT'];
+ } else {
+ $this->port = null;
+ }
+
+ if ($this->hasStandardPort()) {
+ $this->port = null;
+ }
+
+ // Build path.
+ $request_uri = $env['REQUEST_URI'] ?? '';
+ $this->path = rawurldecode(parse_url('http://example.com' . $request_uri, PHP_URL_PATH));
+
+ // Build query string.
+ $this->query = $env['QUERY_STRING'] ?? '';
+ if ($this->query === '') {
+ $this->query = parse_url('http://example.com' . $request_uri, PHP_URL_QUERY);
+ }
+
+ // Support ngnix routes.
+ if (strpos($this->query, '_url=') === 0) {
+ parse_str($this->query, $query);
+ unset($query['_url']);
+ $this->query = http_build_query($query);
+ }
+
+ // Build fragment.
+ $this->fragment = null;
+
+ // Filter userinfo, path and query string.
+ $this->user = $this->user !== null ? static::filterUserInfo($this->user) : null;
+ $this->password = $this->password !== null ? static::filterUserInfo($this->password) : null;
+ $this->path = empty($this->path) ? '/' : static::filterPath($this->path);
+ $this->query = static::filterQuery($this->query);
+
+ $this->reset();
+ }
+
+ /**
+ * Does this Uri use a standard port?
+ *
+ * @return bool
+ */
+ protected function hasStandardPort()
+ {
+ return ($this->port === 80 || $this->port === 443);
+ }
+
+ /**
+ * @param string $url
+ */
+ protected function createFromString($url)
+ {
+ // Set Uri parts.
+ $parts = parse_url($url);
+ if ($parts === false) {
+ throw new \RuntimeException('Malformed URL: ' . $url);
+ }
+ $this->scheme = $parts['scheme'] ?? null;
+ $this->user = $parts['user'] ?? null;
+ $this->password = $parts['pass'] ?? null;
+ $this->host = $parts['host'] ?? null;
+ $this->port = isset($parts['port']) ? (int)$parts['port'] : null;
+ $this->path = $parts['path'] ?? '';
+ $this->query = $parts['query'] ?? '';
+ $this->fragment = $parts['fragment'] ?? null;
+
+ // Validate the hostname
+ if ($this->host) {
+ $this->host = $this->validateHostname($this->host) ? $this->host : 'unknown';
+ }
+ // Filter userinfo, path, query string and fragment.
+ $this->user = $this->user !== null ? static::filterUserInfo($this->user) : null;
+ $this->password = $this->password !== null ? static::filterUserInfo($this->password) : null;
+ $this->path = empty($this->path) ? '/' : static::filterPath($this->path);
+ $this->query = static::filterQuery($this->query);
+ $this->fragment = $this->fragment !== null ? static::filterQuery($this->fragment) : null;
+
+ $this->reset();
+ }
+
+ protected function reset()
+ {
+ // resets
+ parse_str($this->query, $this->queries);
+ $this->extension = null;
+ $this->basename = null;
+ $this->paths = [];
+ $this->params = [];
+ $this->env = $this->buildEnvironment();
+ $this->uri = $this->path . (!empty($this->query) ? '?' . $this->query : '');
+
+ $this->base = $this->buildBaseUrl();
+ $this->root_path = $this->buildRootPath();
+ $this->root = $this->base . $this->root_path;
+ $this->url = $this->base . $this->uri;
+ }
+
+ /**
+ * Get post from either $_POST or JSON response object
+ * By default returns all data, or can return a single item
+ *
+ * @param string $element
+ * @param string $filter_type
+ * @return array|mixed|null
+ */
+ public function post($element = null, $filter_type = null)
+ {
+ if (!$this->post) {
+ $content_type = $this->getContentType();
+ if ($content_type === 'application/json') {
+ $json = file_get_contents('php://input');
+ $this->post = json_decode($json, true);
+ } elseif (!empty($_POST)) {
+ $this->post = (array)$_POST;
+ }
+
+ $event = new Event(['post' => &$this->post]);
+ Grav::instance()->fireEvent('onHttpPostFilter', $event);
+ }
+
+ if ($this->post && null !== $element) {
+ $item = Utils::getDotNotation($this->post, $element);
+ if ($filter_type) {
+ $item = filter_var($item, $filter_type);
+ }
+ return $item;
+ }
+
+ return $this->post;
+ }
+
+ /**
+ * Get content type from request
+ *
+ * @param bool $short
+ * @return null|string
+ */
+ public function getContentType($short = true)
+ {
+ if (isset($_SERVER['CONTENT_TYPE'])) {
+ $content_type = $_SERVER['CONTENT_TYPE'];
+ if ($short) {
+ return Utils::substrToString($content_type,';');
+ }
+ return $content_type;
+ }
+ return null;
+ }
+
+ /**
+ * Check if this is a valid Grav extension
+ *
+ * @param $extension
+ * @return bool
+ */
+ public function isValidExtension($extension)
+ {
+ $valid_page_types = implode('|', Utils::getSupportPageTypes());
+
+ // Strip the file extension for valid page types
+ if (preg_match('/(' . $valid_page_types . ')/', $extension)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Allow overriding of any element (be careful!)
+ *
+ * @param $data
+ * @return Uri
+ */
+ public function setUriProperties($data)
+ {
+ foreach (get_object_vars($this) as $property => $default) {
+ if (!array_key_exists($property, $data)) continue;
+ $this->{$property} = $data[$property]; // assign value to object
+ }
+ return $this;
+ }
+
+ /**
+ * Get the base URI with port if needed
+ *
+ * @return string
+ */
+ private function buildBaseUrl()
+ {
+ return $this->scheme() . $this->host;
+ }
+
+ /**
+ * Get the Grav Root Path
+ *
+ * @return string
+ */
+ private function buildRootPath()
+ {
+ // In Windows script path uses backslash, convert it:
+ $scriptPath = str_replace('\\', '/', $_SERVER['PHP_SELF']);
+ $rootPath = str_replace(' ', '%20', rtrim(substr($scriptPath, 0, strpos($scriptPath, 'index.php')), '/'));
+
+ return $rootPath;
+ }
+
+ private function buildEnvironment()
+ {
+ // check for localhost variations
+ if ($this->host === '127.0.0.1' || $this->host === '::1') {
+ return 'localhost';
+ }
+
+ return $this->host ?: 'unknown';
+ }
+
+ /**
+ * Process any params based in this URL, supports any valid delimiter
+ *
+ * @param string $uri
+ * @param string $delimiter
+ *
+ * @return string
+ */
+ private function processParams($uri, $delimiter = ':')
+ {
+ if (strpos($uri, $delimiter) !== false) {
+ preg_match_all(static::paramsRegex(), $uri, $matches, PREG_SET_ORDER);
+
+ foreach ($matches as $match) {
+ $param = explode($delimiter, $match[1]);
+ if (count($param) === 2) {
+ $plain_var = filter_var($param[1], FILTER_SANITIZE_STRING);
+ $this->params[$param[0]] = $plain_var;
+ $uri = str_replace($match[0], '', $uri);
+ }
+ }
+ }
+ return $uri;
+ }
+}
diff --git a/system/src/Grav/Common/User/Authentication.php b/system/src/Grav/Common/User/Authentication.php
new file mode 100644
index 0000000..2447732
--- /dev/null
+++ b/system/src/Grav/Common/User/Authentication.php
@@ -0,0 +1,55 @@
+get('user/account');
+ }
+
+ parent::__construct($items, $blueprints);
+ }
+
+ /**
+ * @param string $offset
+ * @return bool
+ */
+ public function offsetExists($offset)
+ {
+ $value = parent::offsetExists($offset);
+
+ // Handle special case where user was logged in before 'authorized' was added to the user object.
+ if (false === $value && $offset === 'authorized') {
+ $value = $this->offsetExists('authenticated');
+ }
+
+ return $value;
+ }
+
+ /**
+ * @param string $offset
+ * @return mixed
+ */
+ public function offsetGet($offset)
+ {
+ $value = parent::offsetGet($offset);
+
+ // Handle special case where user was logged in before 'authorized' was added to the user object.
+ if (null === $value && $offset === 'authorized') {
+ $value = $this->offsetGet('authenticated');
+ $this->offsetSet($offset, $value);
+ }
+
+ return $value;
+ }
+
+ public function isValid(): bool
+ {
+ return $this->items !== null;
+ }
+
+ /**
+ * Update object with data
+ *
+ * @param array $data
+ * @param array $files
+ * @return $this
+ */
+ public function update(array $data, array $files = [])
+ {
+ // Note: $this->merge() would cause infinite loop as it calls this method.
+ parent::merge($data);
+
+ return $this;
+ }
+
+ /**
+ * Save user without the username
+ */
+ public function save()
+ {
+ /** @var CompiledYamlFile $file */
+ $file = $this->file();
+ if (!$file || !$file->filename()) {
+ user_error(__CLASS__ . ': calling \$user = new ' . __CLASS__ . "() is deprecated since Grav 1.6, use \$grav['accounts']->load(\$username) or \$grav['accounts']->load('') instead", E_USER_DEPRECATED);
+ }
+
+ if ($file) {
+ $username = $this->get('username');
+
+ if (!$file->filename()) {
+ $locator = Grav::instance()['locator'];
+ $file->filename($locator->findResource('account://' . mb_strtolower($username) . YAML_EXT, true, true));
+ }
+
+ // if plain text password, hash it and remove plain text
+ $password = $this->get('password');
+ if ($password) {
+ $this->set('hashed_password', Authentication::create($password));
+ $this->undef('password');
+ }
+
+ $data = $this->items;
+ unset($data['username'], $data['authenticated'], $data['authorized']);
+
+ $file->save($data);
+ }
+ }
+
+ public function getMedia()
+ {
+ if (null === $this->_media) {
+ // Media object should only contain avatar, nothing else.
+ $media = new Media($this->getMediaFolder(), $this->getMediaOrder(), false);
+
+ $path = $this->getAvatarFile();
+ if ($path && is_file($path)) {
+ $medium = MediumFactory::fromFile($path);
+ if ($medium) {
+ $media->add(basename($path), $medium);
+ }
+ }
+
+ $this->_media = $media;
+ }
+
+ return $this->_media;
+ }
+
+ public function getMediaFolder()
+ {
+ return $this->blueprints()->fields()['avatar']['destination'] ?? 'user://accounts/avatars';
+ }
+
+ public function getMediaOrder()
+ {
+ return [];
+ }
+
+ /**
+ * Serialize user.
+ */
+ public function __sleep()
+ {
+ return [
+ 'items',
+ 'storage'
+ ];
+ }
+
+ /**
+ * Unserialize user.
+ */
+ public function __wakeup()
+ {
+ $this->gettersVariable = 'items';
+ $this->nestedSeparator = '.';
+
+ if (null === $this->items) {
+ $this->items = [];
+ }
+
+ // Always set blueprints.
+ if (null === $this->blueprints) {
+ $this->blueprints = (new Blueprints)->get('user/account');
+ }
+ }
+
+ /**
+ * Merge two configurations together.
+ *
+ * @param array $data
+ * @return $this
+ * @deprecated 1.6 Use `->update($data)` instead (same but with data validation & filtering, file upload support).
+ */
+ public function merge(array $data)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use ->update($data) method instead', E_USER_DEPRECATED);
+
+ return $this->update($data);
+ }
+
+ /**
+ * Return media object for the User's avatar.
+ *
+ * @return ImageMedium|null
+ * @deprecated 1.6 Use ->getAvatarImage() method instead.
+ */
+ public function getAvatarMedia()
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use getAvatarImage() method instead', E_USER_DEPRECATED);
+
+ return $this->getAvatarImage();
+ }
+
+ /**
+ * Return the User's avatar URL
+ *
+ * @return string
+ * @deprecated 1.6 Use ->getAvatarUrl() method instead.
+ */
+ public function avatarUrl()
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use getAvatarUrl() method instead', E_USER_DEPRECATED);
+
+ return $this->getAvatarUrl();
+ }
+
+ /**
+ * Checks user authorization to the action.
+ * Ensures backwards compatibility
+ *
+ * @param string $action
+ *
+ * @return bool
+ * @deprecated 1.5 Use ->authorize() method instead.
+ */
+ public function authorise($action)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use authorize() method instead', E_USER_DEPRECATED);
+
+ return $this->authorize($action);
+ }
+
+ /**
+ * Implements Countable interface.
+ *
+ * @return int
+ * @deprecated 1.6 Method makes no sense for user account.
+ */
+ public function count()
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);
+
+ return parent::count();
+ }
+
+ protected function getAvatarFile(): ?string
+ {
+ $avatars = $this->get('avatar');
+ if (\is_array($avatars) && $avatars) {
+ $avatar = array_shift($avatars);
+ return $avatar['path'] ?? null;
+ }
+
+ return null;
+ }
+}
diff --git a/system/src/Grav/Common/User/DataUser/UserCollection.php b/system/src/Grav/Common/User/DataUser/UserCollection.php
new file mode 100644
index 0000000..800322a
--- /dev/null
+++ b/system/src/Grav/Common/User/DataUser/UserCollection.php
@@ -0,0 +1,130 @@
+className = $className;
+ }
+
+ /**
+ * Load user account.
+ *
+ * Always creates user object. To check if user exists, use $this->exists().
+ *
+ * @param string $username
+ * @return UserInterface
+ */
+ public function load($username): UserInterface
+ {
+ $grav = Grav::instance();
+ /** @var UniformResourceLocator $locator */
+ $locator = $grav['locator'];
+
+ // force lowercase of username
+ $username = mb_strtolower($username);
+
+ $filename = 'account://' . $username . YAML_EXT;
+ $path = $locator->findResource($filename) ?: $locator->findResource($filename, true, true);
+ $file = CompiledYamlFile::instance($path);
+ $content = (array)$file->content() + ['username' => $username, 'state' => 'enabled'];
+
+ $userClass = $this->className;
+ $callable = function() {
+ $blueprints = new Blueprints;
+
+ return $blueprints->get('user/account');
+ };
+
+ /** @var UserInterface $user */
+ $user = new $userClass($content, $callable);
+ $user->file($file);
+
+ return $user;
+ }
+
+ /**
+ * Find a user by username, email, etc
+ *
+ * @param string $query the query to search for
+ * @param array $fields the fields to search
+ * @return UserInterface
+ */
+ public function find($query, $fields = ['username', 'email']): UserInterface
+ {
+ $fields = (array)$fields;
+
+ $account_dir = Grav::instance()['locator']->findResource('account://');
+ $files = $account_dir ? array_diff(scandir($account_dir), ['.', '..']) : [];
+
+ // Try with username first, you never know!
+ if (in_array('username', $fields, true)) {
+ $user = $this->load($query);
+ unset($fields[array_search('username', $fields, true)]);
+ } else {
+ $user = $this->load('');
+ }
+
+ // If not found, try the fields
+ if (!$user->exists()) {
+ foreach ($files as $file) {
+ if (Utils::endsWith($file, YAML_EXT)) {
+ $find_user = $this->load(trim(pathinfo($file, PATHINFO_FILENAME)));
+ foreach ($fields as $field) {
+ if ($find_user[$field] === $query) {
+ return $find_user;
+ }
+ }
+ }
+ }
+ }
+ return $user;
+ }
+
+ /**
+ * Remove user account.
+ *
+ * @param string $username
+ *
+ * @return bool True if the action was performed
+ */
+ public function delete($username): bool
+ {
+ $file_path = Grav::instance()['locator']->findResource('account://' . $username . YAML_EXT);
+
+ return $file_path && unlink($file_path);
+ }
+
+ public function count(): int
+ {
+ // check for existence of a user account
+ $account_dir = $file_path = Grav::instance()['locator']->findResource('account://');
+ $accounts = glob($account_dir . '/*.yaml') ?: [];
+
+ return count($accounts);
+ }
+}
diff --git a/system/src/Grav/Common/User/FlexUser/Storage/UserFileStorage.php b/system/src/Grav/Common/User/FlexUser/Storage/UserFileStorage.php
new file mode 100644
index 0000000..3156fc4
--- /dev/null
+++ b/system/src/Grav/Common/User/FlexUser/Storage/UserFileStorage.php
@@ -0,0 +1,16 @@
+ false,
+ 'find' => false,
+ 'remove' => false,
+ 'get' => true,
+ 'set' => false,
+ 'undef' => false,
+ 'def' => false,
+ ] + parent::getCachedMethods();
+ }
+
+ public function __construct(array $elements, $key, FlexDirectory $directory, bool $validate = false)
+ {
+ // User can only be authenticated via login.
+ unset($elements['authenticated'], $elements['authorized']);
+
+ parent::__construct($elements, $key, $directory, $validate);
+
+ // Define username and state if they aren't set.
+ $this->defProperty('username', $key);
+ $this->defProperty('state', 'enabled');
+ }
+
+ /**
+ * Get value by using dot notation for nested arrays/objects.
+ *
+ * @example $value = $this->get('this.is.my.nested.variable');
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $default Default value (or null).
+ * @param string $separator Separator, defaults to '.'
+ * @return mixed Value.
+ */
+ public function get($name, $default = null, $separator = null)
+ {
+ return $this->getNestedProperty($name, $default, $separator);
+ }
+
+ /**
+ * Set value by using dot notation for nested arrays/objects.
+ *
+ * @example $data->set('this.is.my.nested.variable', $value);
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $value New value.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function set($name, $value, $separator = null)
+ {
+ $this->setNestedProperty($name, $value, $separator);
+
+ return $this;
+ }
+
+ /**
+ * Unset value by using dot notation for nested arrays/objects.
+ *
+ * @example $data->undef('this.is.my.nested.variable');
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function undef($name, $separator = null)
+ {
+ $this->unsetNestedProperty($name, $separator);
+
+ return $this;
+ }
+
+ /**
+ * Set default value by using dot notation for nested arrays/objects.
+ *
+ * @example $data->def('this.is.my.nested.variable', 'default');
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $default Default value (or null).
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function def($name, $default = null, $separator = null)
+ {
+ $this->defNestedProperty($name, $default, $separator);
+
+ return $this;
+ }
+
+ /**
+ * Get value from a page variable (used mostly for creating edit forms).
+ *
+ * @param string $name Variable name.
+ * @param mixed $default
+ * @param string|null $separator
+ * @return mixed
+ */
+ public function getFormValue(string $name, $default = null, string $separator = null)
+ {
+ $value = parent::getFormValue($name, null, $separator);
+
+ if ($name === 'avatar') {
+ return $this->parseFileProperty($value);
+ }
+
+ if (null === $value) {
+ if ($name === 'media_order') {
+ return implode(',', $this->getMediaOrder());
+ }
+ }
+
+ return $value ?? $default;
+ }
+
+ /**
+ * @param string $property
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getProperty($property, $default = null)
+ {
+ $value = parent::getProperty($property, $default);
+
+ if ($property === 'avatar') {
+ $value = $this->parseFileProperty($value);
+ }
+
+ return $value;
+ }
+
+ /**
+ * Convert object into an array.
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ $array = $this->jsonSerialize();
+ $array['avatar'] = $this->parseFileProperty($array['avatar'] ?? null);
+
+ return $array;
+ }
+
+ /**
+ * Convert object into YAML string.
+ *
+ * @param int $inline The level where you switch to inline YAML.
+ * @param int $indent The amount of spaces to use for indentation of nested nodes.
+ *
+ * @return string A YAML string representing the object.
+ */
+ public function toYaml($inline = 5, $indent = 2)
+ {
+ $yaml = new YamlFormatter(['inline' => $inline, 'indent' => $indent]);
+
+ return $yaml->encode($this->toArray());
+ }
+
+ /**
+ * Convert object into JSON string.
+ *
+ * @return string
+ */
+ public function toJson()
+ {
+ $json = new JsonFormatter();
+
+ return $json->encode($this->toArray());
+ }
+
+ /**
+ * Join nested values together by using blueprints.
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $value Value to be joined.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ * @throws \RuntimeException
+ */
+ public function join($name, $value, $separator = null)
+ {
+ $separator = $separator ?? '.';
+ $old = $this->get($name, null, $separator);
+ if ($old !== null) {
+ if (!\is_array($old)) {
+ throw new \RuntimeException('Value ' . $old);
+ }
+
+ if (\is_object($value)) {
+ $value = (array) $value;
+ } elseif (!\is_array($value)) {
+ throw new \RuntimeException('Value ' . $value);
+ }
+
+ $value = $this->getBlueprint()->mergeData($old, $value, $name, $separator);
+ }
+
+ $this->set($name, $value, $separator);
+
+ return $this;
+ }
+
+ /**
+ * Get nested structure containing default values defined in the blueprints.
+ *
+ * Fields without default value are ignored in the list.
+
+ * @return array
+ */
+ public function getDefaults()
+ {
+ return $this->getBlueprint()->getDefaults();
+ }
+
+ /**
+ * Set default values by using blueprints.
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $value Value to be joined.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function joinDefaults($name, $value, $separator = null)
+ {
+ if (\is_object($value)) {
+ $value = (array) $value;
+ }
+
+ $old = $this->get($name, null, $separator);
+ if ($old !== null) {
+ $value = $this->getBlueprint()->mergeData($value, $old, $name, $separator);
+ }
+
+ $this->setNestedProperty($name, $value, $separator);
+
+ return $this;
+ }
+
+ /**
+ * Get value from the configuration and join it with given data.
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param array|object $value Value to be joined.
+ * @param string $separator Separator, defaults to '.'
+ * @return array
+ * @throws \RuntimeException
+ */
+ public function getJoined($name, $value, $separator = null)
+ {
+ if (\is_object($value)) {
+ $value = (array) $value;
+ } elseif (!\is_array($value)) {
+ throw new \RuntimeException('Value ' . $value);
+ }
+
+ $old = $this->get($name, null, $separator);
+
+ if ($old === null) {
+ // No value set; no need to join data.
+ return $value;
+ }
+
+ if (!\is_array($old)) {
+ throw new \RuntimeException('Value ' . $old);
+ }
+
+ // Return joined data.
+ return $this->getBlueprint()->mergeData($old, $value, $name, $separator);
+ }
+
+ /**
+ * Set default values to the configuration if variables were not set.
+ *
+ * @param array $data
+ * @return $this
+ */
+ public function setDefaults(array $data)
+ {
+ $this->setElements($this->getBlueprint()->mergeData($data, $this->toArray()));
+
+ return $this;
+ }
+
+ /**
+ * Validate by blueprints.
+ *
+ * @return $this
+ * @throws \Exception
+ */
+ public function validate()
+ {
+ $this->getBlueprint()->validate($this->toArray());
+
+ return $this;
+ }
+
+ /**
+ * Filter all items by using blueprints.
+ * @return $this
+ */
+ public function filter()
+ {
+ $this->setElements($this->getBlueprint()->filter($this->toArray()));
+
+ return $this;
+ }
+
+ /**
+ * Get extra items which haven't been defined in blueprints.
+ *
+ * @return array
+ */
+ public function extra()
+ {
+ return $this->getBlueprint()->extra($this->toArray());
+ }
+
+ /**
+ * @param string $name
+ * @return Blueprint
+ */
+ public function getBlueprint(string $name = '')
+ {
+ $blueprint = clone parent::getBlueprint($name);
+
+ $blueprint->addDynamicHandler('flex', function (array &$field, $property, array &$call) {
+ $params = (array)$call['params'];
+ $method = array_shift($params);
+
+ if (method_exists($this, $method)) {
+ $value = $this->{$method}(...$params);
+ if (\is_array($value) && isset($field[$property]) && \is_array($field[$property])) {
+ $field[$property] = array_merge_recursive($field[$property], $value);
+ } else {
+ $field[$property] = $value;
+ }
+ }
+ });
+
+ return $blueprint->init();
+ }
+
+ /**
+ * Return unmodified data as raw string.
+ *
+ * NOTE: This function only returns data which has been saved to the storage.
+ *
+ * @return string
+ */
+ public function raw()
+ {
+ $file = $this->file();
+
+ return $file ? $file->raw() : '';
+ }
+
+ /**
+ * Set or get the data storage.
+ *
+ * @param FileInterface $storage Optionally enter a new storage.
+ * @return FileInterface
+ */
+ public function file(FileInterface $storage = null)
+ {
+ if (null !== $storage) {
+ $this->_storage = $storage;
+ }
+
+ return $this->_storage;
+ }
+
+ public function isValid(): bool
+ {
+ return $this->getProperty('state') !== null;
+ }
+
+ /**
+ * Save user without the username
+ */
+ public function save()
+ {
+ // TODO: We may want to handle this in the storage layer in the future.
+ $key = $this->getStorageKey();
+ if (!$key || strpos($key, '@@')) {
+ $storage = $this->getFlexDirectory()->getStorage();
+ if ($storage instanceof FileStorage) {
+ $this->setStorageKey($this->getKey());
+ }
+ }
+
+ $password = $this->getProperty('password');
+ if (null !== $password) {
+ $this->unsetProperty('password');
+ $this->unsetProperty('password1');
+ $this->unsetProperty('password2');
+ $this->setProperty('hashed_password', Authentication::create($password));
+ }
+
+ return parent::save();
+ }
+
+ public function isAuthorized(string $action, string $scope = null, UserInterface $user = null): bool
+ {
+ if (null === $user) {
+ /** @var UserInterface $user */
+ $user = Grav::instance()['user'] ?? null;
+ }
+
+ if ($user instanceof User && $user->getStorageKey() === $this->getStorageKey()) {
+ return true;
+ }
+
+ return parent::isAuthorized($action, $scope, $user);
+ }
+
+ /**
+ * @return array
+ */
+ public function prepareStorage(): array
+ {
+ $elements = parent::prepareStorage();
+
+ // Do not save authorization information.
+ unset($elements['authenticated'], $elements['authorized']);
+
+ return $elements;
+ }
+
+ /**
+ * Merge two configurations together.
+ *
+ * @param array $data
+ * @return $this
+ * @deprecated 1.6 Use `->update($data)` instead (same but with data validation & filtering, file upload support).
+ */
+ public function merge(array $data)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use ->update($data) method instead', E_USER_DEPRECATED);
+
+ $this->setElements($this->getBlueprint()->mergeData($this->toArray(), $data));
+
+ return $this;
+ }
+
+ /**
+ * Return media object for the User's avatar.
+ *
+ * @return ImageMedium|null
+ * @deprecated 1.6 Use ->getAvatarImage() method instead.
+ */
+ public function getAvatarMedia()
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use ->getAvatarImage() method instead', E_USER_DEPRECATED);
+
+ return $this->getAvatarImage();
+ }
+
+ /**
+ * Return the User's avatar URL
+ *
+ * @return string
+ * @deprecated 1.6 Use ->getAvatarUrl() method instead.
+ */
+ public function avatarUrl()
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use ->getAvatarUrl() method instead', E_USER_DEPRECATED);
+
+ return $this->getAvatarUrl();
+ }
+
+ /**
+ * Checks user authorization to the action.
+ * Ensures backwards compatibility
+ *
+ * @param string $action
+ * @return bool
+ * @deprecated 1.5 Use ->authorize() method instead.
+ */
+ public function authorise($action)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use ->authorize() method instead', E_USER_DEPRECATED);
+
+ return $this->authorize($action);
+ }
+
+ /**
+ * Implements Countable interface.
+ *
+ * @return int
+ * @deprecated 1.6 Method makes no sense for user account.
+ */
+ public function count()
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);
+
+ return \count($this->jsonSerialize());
+ }
+
+ /**
+ * Gets the associated media collection (original images).
+ *
+ * @return MediaCollectionInterface Representation of associated media.
+ */
+ protected function getOriginalMedia()
+ {
+ return (new Media($this->getMediaFolder() . '/original', $this->getMediaOrder()))->setTimestamps();
+ }
+
+ /**
+ * @param array $files
+ */
+ protected function setUpdatedMedia(array $files): void
+ {
+ $list = [];
+ $list_original = [];
+ foreach ($files as $field => $group) {
+ foreach ($group as $filename => $file) {
+ if (strpos($field, '/original')) {
+ // Special handling for original images.
+ $list_original[$filename] = $file;
+ continue;
+ }
+
+ $list[$filename] = $file;
+
+ if ($file) {
+ /** @var FormFlashFile $file */
+ $data = $file->jsonSerialize();
+ $path = $file->getClientFilename();
+ unset($data['tmp_name'], $data['path']);
+
+ $this->setNestedProperty("{$field}\n{$path}", $data, "\n");
+ } else {
+ $this->unsetNestedProperty("{$field}\n{$filename}", "\n");
+ }
+ }
+ }
+
+ $this->_uploads = $list;
+ $this->_uploads_original = $list_original;
+ }
+
+ protected function saveUpdatedMedia(): void
+ {
+ // Upload/delete original sized images.
+ /** @var FormFlashFile $file */
+ foreach ($this->_uploads_original ?? [] as $name => $file) {
+ $name = 'original/' . $name;
+ if ($file) {
+ $this->uploadMediaFile($file, $name);
+ } else {
+ $this->deleteMediaFile($name);
+ }
+ }
+
+ /**
+ * @var string $filename
+ * @var UploadedFileInterface $file
+ */
+ foreach ($this->getUpdatedMedia() as $filename => $file) {
+ if ($file) {
+ $this->uploadMediaFile($file, $filename);
+ } else {
+ $this->deleteMediaFile($filename);
+ }
+ }
+
+ $this->setUpdatedMedia([]);
+ }
+
+ /**
+ * @param array $value
+ * @return array
+ */
+ protected function parseFileProperty($value)
+ {
+ if (!\is_array($value)) {
+ return $value;
+ }
+
+ $originalMedia = $this->getOriginalMedia();
+ $resizedMedia = $this->getMedia();
+
+ $list = [];
+ foreach ($value as $filename => $info) {
+ if (!\is_array($info)) {
+ continue;
+ }
+
+ /** @var Medium $thumbFile */
+ $thumbFile = $resizedMedia[$filename];
+ /** @var Medium $imageFile */
+ $imageFile = $originalMedia[$filename] ?? $thumbFile;
+ if ($thumbFile) {
+ $list[$filename] = [
+ 'name' => $filename,
+ 'type' => $info['type'],
+ 'size' => $info['size'],
+ 'image_url' => $imageFile->url(),
+ 'thumb_url' => $thumbFile->url(),
+ 'cropData' => (object)($imageFile->metadata()['upload']['crop'] ?? [])
+ ];
+ }
+ }
+
+ return $list;
+ }
+
+ /**
+ * @return array
+ */
+ protected function doSerialize(): array
+ {
+ return [
+ 'type' => 'accounts',
+ 'key' => $this->getKey(),
+ 'elements' => $this->jsonSerialize(),
+ 'storage' => $this->getStorage()
+ ];
+ }
+
+ /**
+ * @param array $serialized
+ */
+ protected function doUnserialize(array $serialized): void
+ {
+ $grav = Grav::instance();
+
+ /** @var UserCollection $accounts */
+ $accounts = $grav['accounts'];
+
+ $directory = $accounts->getFlexDirectory();
+ if (!$directory) {
+ throw new \InvalidArgumentException('Internal error');
+ }
+
+ $this->setFlexDirectory($directory);
+ $this->setStorage($serialized['storage']);
+ $this->setKey($serialized['key']);
+ $this->setElements($serialized['elements']);
+ }
+}
diff --git a/system/src/Grav/Common/User/FlexUser/UserCollection.php b/system/src/Grav/Common/User/FlexUser/UserCollection.php
new file mode 100644
index 0000000..0f7a1d1
--- /dev/null
+++ b/system/src/Grav/Common/User/FlexUser/UserCollection.php
@@ -0,0 +1,100 @@
+exists().
+ *
+ * @param string $username
+ * @return User
+ */
+ public function load($username): UserInterface
+ {
+ if ($username !== '') {
+ $key = mb_strtolower($username);
+ $user = $this->get($key);
+ if ($user) {
+ return $user;
+ }
+ } else {
+ $key = '';
+ }
+
+ $directory = $this->getFlexDirectory();
+
+ /** @var User $object */
+ $object = $directory->createObject(
+ [
+ 'username' => $username,
+ 'state' => 'enabled'
+ ],
+ $key
+ );
+
+ return $object;
+ }
+
+ /**
+ * Find a user by username, email, etc
+ *
+ * @param string $query the query to search for
+ * @param array $fields the fields to search
+ * @return User
+ */
+ public function find($query, $fields = ['username', 'email']): UserInterface
+ {
+ foreach ((array)$fields as $field) {
+ if ($field === 'key') {
+ $user = $this->get($query);
+ } elseif ($field === 'storage_key') {
+ $user = $this->withKeyField('storage_key')->get($query);
+ } elseif ($field === 'flex_key') {
+ $user = $this->withKeyField('flex_key')->get($query);
+ } elseif ($field === 'username') {
+ $user = $this->get(mb_strtolower($query));
+ } else {
+ $user = parent::find($query, $field);
+ }
+ if ($user) {
+ return $user;
+ }
+ }
+
+ return $this->load('');
+ }
+
+ /**
+ * Delete user account.
+ *
+ * @param string $username
+ *
+ * @return bool True if user account was found and was deleted.
+ */
+ public function delete($username): bool
+ {
+ $user = $this->load($username);
+
+ $exists = $user->exists();
+ if ($exists) {
+ $user->delete();
+ }
+
+ return $exists;
+ }
+}
diff --git a/system/src/Grav/Common/User/FlexUser/UserIndex.php b/system/src/Grav/Common/User/FlexUser/UserIndex.php
new file mode 100644
index 0000000..f95f51b
--- /dev/null
+++ b/system/src/Grav/Common/User/FlexUser/UserIndex.php
@@ -0,0 +1,133 @@
+exists().
+ *
+ * @param string $username
+ *
+ * @return User
+ */
+ public function load($username): UserInterface
+ {
+ if ($username !== '') {
+ $key = mb_strtolower($username);
+ $user = $this->get($key);
+ if ($user) {
+ return $user;
+ }
+ } else {
+ $key = '';
+ }
+
+ $directory = $this->getFlexDirectory();
+
+ /** @var User $object */
+ $object = $directory->createObject(
+ [
+ 'username' => $username,
+ 'state' => 'enabled'
+ ],
+ $key
+ );
+
+ return $object;
+ }
+
+ /**
+ * Find a user by username, email, etc
+ *
+ * @param string $query the query to search for
+ * @param array $fields the fields to search
+ * @return User
+ */
+ public function find($query, $fields = ['username', 'email']): UserInterface
+ {
+ foreach ((array)$fields as $field) {
+ if ($field === 'key') {
+ $user = $this->get($query);
+ } elseif ($field === 'storage_key') {
+ $user = $this->withKeyField('storage_key')->get($query);
+ } elseif ($field === 'flex_key') {
+ $user = $this->withKeyField('flex_key')->get($query);
+ } elseif ($field === 'email') {
+ $user = $this->withKeyField('email')->get($query);
+ } elseif ($field === 'username') {
+ $user = $this->get(mb_strtolower($query));
+ } else {
+ $user = $this->__call('find', [$query, $field]);
+ }
+ if ($user) {
+ return $user;
+ }
+ }
+
+ return $this->load('');
+ }
+
+ protected static function updateIndexData(array &$entry, array $data)
+ {
+ $entry['key'] = mb_strtolower($entry['key']);
+ $entry['email'] = isset($data['email']) ? mb_strtolower($data['email']) : null;
+ }
+
+ protected static function getIndexFile(FlexStorageInterface $storage)
+ {
+ // Load saved index file.
+ $grav = Grav::instance();
+ $locator = $grav['locator'];
+ $filename = $locator->findResource('user-data://flex/indexes/accounts.yaml', true, true);
+
+ return CompiledYamlFile::instance($filename);
+ }
+
+ protected static function onChanges(array $entries, array $added, array $updated, array $removed)
+ {
+ $message = sprintf('Flex: User index updated, %d objects (%d added, %d updated, %d removed).', \count($entries), \count($added), \count($updated), \count($removed));
+
+ $grav = Grav::instance();
+
+ /** @var Logger $logger */
+ $logger = $grav['log'];
+ $logger->addDebug($message);
+
+ /** @var Debugger $debugger */
+ $debugger = $grav['debugger'];
+ $debugger->addMessage($message, 'debug');
+ }
+}
diff --git a/system/src/Grav/Common/User/Group.php b/system/src/Grav/Common/User/Group.php
new file mode 100644
index 0000000..9815c0e
--- /dev/null
+++ b/system/src/Grav/Common/User/Group.php
@@ -0,0 +1,155 @@
+get('groups', []);
+ }
+
+ /**
+ * Get the groups list
+ *
+ * @return array
+ */
+ public static function groupNames()
+ {
+ $groups = [];
+
+ foreach(static::groups() as $groupname => $group) {
+ $groups[$groupname] = $group['readableName'] ?? $groupname;
+ }
+
+ return $groups;
+ }
+
+ /**
+ * Checks if a group exists
+ *
+ * @param string $groupname
+ *
+ * @return bool
+ */
+ public static function groupExists($groupname)
+ {
+ return isset(self::groups()[$groupname]);
+ }
+
+ /**
+ * Get a group by name
+ *
+ * @param string $groupname
+ *
+ * @return object
+ */
+ public static function load($groupname)
+ {
+ $groups = self::groups();
+
+ $content = $groups[$groupname] ?? [];
+ $content += ['groupname' => $groupname];
+
+ $blueprints = new Blueprints();
+ $blueprint = $blueprints->get('user/group');
+
+ return new Group($content, $blueprint);
+ }
+
+ /**
+ * Save a group
+ */
+ public function save()
+ {
+ $grav = Grav::instance();
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ $blueprints = new Blueprints();
+ $blueprint = $blueprints->get('user/group');
+
+ $config->set("groups.{$this->get('groupname')}", []);
+
+ $fields = $blueprint->fields();
+ foreach ($fields as $field) {
+ if ($field['type'] === 'text') {
+ $value = $field['name'];
+ if (isset($this->items['data'][$value])) {
+ $config->set("groups.{$this->get('groupname')}.{$value}", $this->items['data'][$value]);
+ }
+ }
+ if ($field['type'] === 'array' || $field['type'] === 'permissions') {
+ $value = $field['name'];
+ $arrayValues = Utils::getDotNotation($this->items['data'], $field['name']);
+
+ if ($arrayValues) {
+ foreach ($arrayValues as $arrayIndex => $arrayValue) {
+ $config->set("groups.{$this->get('groupname')}.{$value}.{$arrayIndex}", $arrayValue);
+ }
+ }
+ }
+ }
+
+ $type = 'groups';
+ $blueprints = $this->blueprints();
+
+ $filename = CompiledYamlFile::instance($grav['locator']->findResource("config://{$type}.yaml"));
+
+ $obj = new Data($config->get($type), $blueprints);
+ $obj->file($filename);
+ $obj->save();
+ }
+
+ /**
+ * Remove a group
+ *
+ * @param string $groupname
+ *
+ * @return bool True if the action was performed
+ */
+ public static function remove($groupname)
+ {
+ $grav = Grav::instance();
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ $blueprints = new Blueprints();
+ $blueprint = $blueprints->get('user/group');
+
+ $type = 'groups';
+
+ $groups = $config->get($type);
+ unset($groups[$groupname]);
+ $config->set($type, $groups);
+
+ $filename = CompiledYamlFile::instance($grav['locator']->findResource("config://{$type}.yaml"));
+
+ $obj = new Data($groups, $blueprint);
+ $obj->file($filename);
+ $obj->save();
+
+ return true;
+ }
+}
diff --git a/system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php b/system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php
new file mode 100644
index 0000000..37b9009
--- /dev/null
+++ b/system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php
@@ -0,0 +1,40 @@
+exists().
+ *
+ * @param string $username
+ * @return UserInterface
+ */
+ public function load($username): UserInterface;
+
+ /**
+ * Find a user by username, email, etc
+ *
+ * @param string $query the query to search for
+ * @param array $fields the fields to search
+ * @return UserInterface
+ */
+ public function find($query, $fields = ['username', 'email']): UserInterface;
+
+ /**
+ * Delete user account.
+ *
+ * @param string $username
+ * @return bool True if user account was found and was deleted.
+ */
+ public function delete($username): bool;
+}
diff --git a/system/src/Grav/Common/User/Interfaces/UserInterface.php b/system/src/Grav/Common/User/Interfaces/UserInterface.php
new file mode 100644
index 0000000..0fba676
--- /dev/null
+++ b/system/src/Grav/Common/User/Interfaces/UserInterface.php
@@ -0,0 +1,198 @@
+get('this.is.my.nested.variable');
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $default Default value (or null).
+ * @param string $separator Separator, defaults to '.'
+ * @return mixed Value.
+ */
+ public function get($name, $default = null, $separator = null);
+
+ /**
+ * Set value by using dot notation for nested arrays/objects.
+ *
+ * @example $data->set('this.is.my.nested.variable', $value);
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $value New value.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function set($name, $value, $separator = null);
+
+ /**
+ * Unset value by using dot notation for nested arrays/objects.
+ *
+ * @example $data->undef('this.is.my.nested.variable');
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function undef($name, $separator = null);
+
+ /**
+ * Set default value by using dot notation for nested arrays/objects.
+ *
+ * @example $data->def('this.is.my.nested.variable', 'default');
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $default Default value (or null).
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function def($name, $default = null, $separator = null);
+
+ /**
+ * Join nested values together by using blueprints.
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $value Value to be joined.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ * @throws \RuntimeException
+ */
+ public function join($name, $value, $separator = '.');
+
+ /**
+ * Get nested structure containing default values defined in the blueprints.
+ *
+ * Fields without default value are ignored in the list.
+
+ * @return array
+ */
+ public function getDefaults();
+
+ /**
+ * Set default values by using blueprints.
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param mixed $value Value to be joined.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function joinDefaults($name, $value, $separator = '.');
+
+ /**
+ * Get value from the configuration and join it with given data.
+ *
+ * @param string $name Dot separated path to the requested value.
+ * @param array|object $value Value to be joined.
+ * @param string $separator Separator, defaults to '.'
+ * @return array
+ * @throws \RuntimeException
+ */
+ public function getJoined($name, $value, $separator = '.');
+
+ /**
+ * Set default values to the configuration if variables were not set.
+ *
+ * @param array $data
+ * @return $this
+ */
+ public function setDefaults(array $data);
+
+ /**
+ * Update object with data
+ *
+ * @param array $data
+ * @param array $files
+ * @return $this
+ */
+ public function update(array $data, array $files = []);
+
+ /**
+ * Returns whether the data already exists in the storage.
+ *
+ * NOTE: This method does not check if the data is current.
+ *
+ * @return bool
+ */
+ public function exists();
+
+ /**
+ * Return unmodified data as raw string.
+ *
+ * NOTE: This function only returns data which has been saved to the storage.
+ *
+ * @return string
+ */
+ public function raw();
+
+ /**
+ * Authenticate user.
+ *
+ * If user password needs to be updated, new information will be saved.
+ *
+ * @param string $password Plaintext password.
+ *
+ * @return bool
+ */
+ public function authenticate(string $password): bool;
+
+ /**
+ * Checks user authorization to the action.
+ *
+ * @param string $action
+ * @param string|null $scope
+ * @return bool
+ */
+ public function authorize(string $action, string $scope = null): bool;
+
+ /**
+ * Return media object for the User's avatar.
+ *
+ * Note: if there's no local avatar image for the user, you should call getAvatarUrl() to get the external avatar URL.
+ *
+ * @return ImageMedium|null
+ */
+ public function getAvatarImage(): ?ImageMedium;
+
+ /**
+ * Return the User's avatar URL.
+ *
+ * @return string
+ */
+ public function getAvatarUrl(): string;
+}
diff --git a/system/src/Grav/Common/User/Traits/UserTrait.php b/system/src/Grav/Common/User/Traits/UserTrait.php
new file mode 100644
index 0000000..f711cc9
--- /dev/null
+++ b/system/src/Grav/Common/User/Traits/UserTrait.php
@@ -0,0 +1,171 @@
+get('hashed_password');
+
+ $isHashed = null !== $hash;
+ if (!$isHashed) {
+ // If there is no hashed password, fake verify with default hash.
+ $hash = Grav::instance()['config']->get('system.security.default_hash');
+ }
+
+ // Always execute verify() to protect us from timing attacks, but make the test to fail if hashed password wasn't set.
+ $result = Authentication::verify($password, $hash) && $isHashed;
+
+ $plaintext_password = $this->get('password');
+ if (null !== $plaintext_password) {
+ // Plain-text password is still stored, check if it matches.
+ if ($password !== $plaintext_password) {
+ return false;
+ }
+
+ // Force hash update to get rid of plaintext password.
+ $result = 2;
+ }
+
+ if ($result === 2) {
+ // Password needs to be updated, save the user.
+ $this->set('password', $password);
+ $this->undef('hashed_password');
+ $this->save();
+ }
+
+ return (bool)$result;
+ }
+
+ /**
+ * Checks user authorization to the action.
+ *
+ * @param string $action
+ * @param string|null $scope
+ * @return bool
+ */
+ public function authorize(string $action, string $scope = null): bool
+ {
+ if (!$this->get('authenticated')) {
+ return false;
+ }
+
+ if ($this->get('state', 'enabled') !== 'enabled') {
+ return false;
+ }
+
+ if (null !== $scope) {
+ $action = $scope . '.' . $action;
+ }
+
+ $config = Grav::instance()['config'];
+ $authorized = false;
+
+ //Check group access level
+ $groups = (array)$this->get('groups');
+ foreach ($groups as $group) {
+ $permission = $config->get("groups.{$group}.access.{$action}");
+ $authorized = Utils::isPositive($permission);
+ if ($authorized === true) {
+ break;
+ }
+ }
+
+ //Check user access level
+ $access = $this->get('access');
+ if ($access && Utils::getDotNotation($access, $action) !== null) {
+ $permission = $this->get("access.{$action}");
+ $authorized = Utils::isPositive($permission);
+ }
+
+ return $authorized;
+ }
+
+ /**
+ * Return media object for the User's avatar.
+ *
+ * Note: if there's no local avatar image for the user, you should call getAvatarUrl() to get the external avatar URL.
+ *
+ * @return ImageMedium|null
+ */
+ public function getAvatarImage(): ?ImageMedium
+ {
+ $avatars = $this->get('avatar');
+ if (\is_array($avatars) && $avatars) {
+ $avatar = array_shift($avatars);
+
+ $media = $this->getMedia();
+ $name = $avatar['name'] ?? null;
+
+ $image = $name ? $media[$name] : null;
+ if ($image instanceof ImageMedium) {
+ return $image;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Return the User's avatar URL
+ *
+ * @return string
+ */
+ public function getAvatarUrl(): string
+ {
+ // Try to locate avatar image.
+ $avatar = $this->getAvatarImage();
+ if ($avatar) {
+ return $avatar->url();
+ }
+
+ // Try if avatar is a sting (URL).
+ $avatar = $this->get('avatar');
+ if (\is_string($avatar)) {
+ return $avatar;
+ }
+
+ // Try looking for provider.
+ $provider = $this->get('provider');
+ $provider_options = $this->get($provider);
+ if (\is_array($provider_options)) {
+ if (isset($provider_options['avatar_url']) && \is_string($provider_options['avatar_url'])) {
+ return $provider_options['avatar_url'];
+ }
+ if (isset($provider_options['avatar']) && \is_string($provider_options['avatar'])) {
+ return $provider_options['avatar'];
+ }
+ }
+
+ $email = $this->get('email');
+
+ // By default fall back to gravatar image.
+ return $email ? 'https://www.gravatar.com/avatar/' . md5(strtolower(trim($email))) : '';
+ }
+
+ abstract public function get($name, $default = null, $separator = null);
+ abstract public function set($name, $value, $separator = null);
+ abstract public function undef($name, $separator = null);
+ abstract public function save();
+}
diff --git a/system/src/Grav/Common/User/User.php b/system/src/Grav/Common/User/User.php
new file mode 100644
index 0000000..ba1dbdc
--- /dev/null
+++ b/system/src/Grav/Common/User/User.php
@@ -0,0 +1,146 @@
+exists().
+ *
+ * @param string $username
+ *
+ * @return UserInterface
+ * @deprecated 1.6 Use $grav['accounts']->load(...) instead.
+ */
+ public static function load($username)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use $grav[\'accounts\']->' . __FUNCTION__ . '() instead', E_USER_DEPRECATED);
+
+ return static::getCollection()->load($username);
+ }
+
+ /**
+ * Find a user by username, email, etc
+ *
+ * Always creates user object. To check if user exists, use $this->exists().
+ *
+ * @param string $query the query to search for
+ * @param array $fields the fields to search
+ * @return UserInterface
+ * @deprecated 1.6 Use $grav['accounts']->find(...) instead.
+ */
+ public static function find($query, $fields = ['username', 'email'])
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use $grav[\'accounts\']->' . __FUNCTION__ . '() instead', E_USER_DEPRECATED);
+
+ return static::getCollection()->find($query, $fields);
+ }
+
+ /**
+ * Remove user account.
+ *
+ * @param string $username
+ * @return bool True if the action was performed
+ * @deprecated 1.6 Use $grav['accounts']->delete(...) instead.
+ */
+ public static function remove($username)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use $grav[\'accounts\']->delete() instead', E_USER_DEPRECATED);
+
+ return static::getCollection()->delete($username);
+ }
+
+ /**
+ * @return UserCollectionInterface
+ */
+ protected static function getCollection()
+ {
+ return Grav::instance()['accounts'];
+ }
+ }
+} else {
+ /**
+ * @deprecated 1.6 Use $grav['accounts'] instead of static calls. In type hints, use UserInterface.
+ */
+ class User extends DataUser\User
+ {
+ /**
+ * Load user account.
+ *
+ * Always creates user object. To check if user exists, use $this->exists().
+ *
+ * @param string $username
+ *
+ * @return UserInterface
+ * @deprecated 1.6 Use $grav['accounts']->load(...) instead.
+ */
+ public static function load($username)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use $grav[\'accounts\']->' . __FUNCTION__ . '() instead', E_USER_DEPRECATED);
+
+ return static::getCollection()->load($username);
+ }
+
+ /**
+ * Find a user by username, email, etc
+ *
+ * Always creates user object. To check if user exists, use $this->exists().
+ *
+ * @param string $query the query to search for
+ * @param array $fields the fields to search
+ * @return UserInterface
+ * @deprecated 1.6 Use $grav['accounts']->find(...) instead.
+ */
+ public static function find($query, $fields = ['username', 'email'])
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use $grav[\'accounts\']->' . __FUNCTION__ . '() instead', E_USER_DEPRECATED);
+
+ return static::getCollection()->find($query, $fields);
+ }
+
+ /**
+ * Remove user account.
+ *
+ * @param string $username
+ * @return bool True if the action was performed
+ * @deprecated 1.6 Use $grav['accounts']->delete(...) instead.
+ */
+ public static function remove($username)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use $grav[\'accounts\']->delete() instead', E_USER_DEPRECATED);
+
+ return static::getCollection()->delete($username);
+ }
+
+ /**
+ * @return UserCollectionInterface
+ */
+ protected static function getCollection()
+ {
+ return Grav::instance()['accounts'];
+ }
+ }
+}
diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php
new file mode 100644
index 0000000..8a6d987
--- /dev/null
+++ b/system/src/Grav/Common/Utils.php
@@ -0,0 +1,1641 @@
+schemeExists($scheme)) {
+ // If scheme does not exists as a stream, assume it's external.
+ return str_replace(' ', '%20', $input);
+ }
+
+ // Attempt to find the resource (because of parse_url() we need to put host back to path).
+ $resource = $locator->findResource("{$scheme}://{$host}{$path}", false);
+
+ if ($resource === false) {
+ if (!$fail_gracefully) {
+ return false;
+ }
+
+ // Return location where the file would be if it was saved.
+ $resource = $locator->findResource("{$scheme}://{$host}{$path}", false, true);
+ }
+
+ } elseif ($host || $port) {
+ // If URL doesn't have scheme but has host or port, it is external.
+ return str_replace(' ', '%20', $input);
+ }
+
+ if (!empty($resource)) {
+ // Add query string back.
+ if (isset($parts['query'])) {
+ $resource .= '?' . $parts['query'];
+ }
+
+ // Add fragment back.
+ if (isset($parts['fragment'])) {
+ $resource .= '#' . $parts['fragment'];
+ }
+ }
+
+ } else {
+ // Not a valid URL (can still be a stream).
+ $resource = $locator->findResource($input, false);
+ }
+
+ } else {
+ $root = $uri->rootUrl();
+
+ if (static::startsWith($input, $root)) {
+ $input = static::replaceFirstOccurrence($root, '', $input);
+ }
+
+ $input = ltrim($input, '/');
+
+ $resource = $input;
+ }
+
+ if (!$fail_gracefully && $resource === false) {
+ return false;
+ }
+
+ $domain = $domain ?: $grav['config']->get('system.absolute_urls', false);
+
+ return rtrim($uri->rootUrl($domain), '/') . '/' . ($resource ?? '');
+ }
+
+ /**
+ * Helper method to find the full path to a file, be it a stream, a relative path, or
+ * already a full path
+ *
+ * @param $path
+ * @return string
+ */
+ public static function fullPath($path)
+ {
+ $locator = Grav::instance()['locator'];
+
+ if ($locator->isStream($path)) {
+ $path = $locator->findResource($path, true);
+ } elseif (!Utils::startsWith($path, GRAV_ROOT)) {
+ $base_url = Grav::instance()['base_url'];
+ $path = GRAV_ROOT . '/' . ltrim(Utils::replaceFirstOccurrence($base_url, '', $path), '/');
+ }
+
+ return $path;
+ }
+
+
+ /**
+ * Check if the $haystack string starts with the substring $needle
+ *
+ * @param string $haystack
+ * @param string|string[] $needle
+ * @param bool $case_sensitive
+ *
+ * @return bool
+ */
+ public static function startsWith($haystack, $needle, $case_sensitive = true)
+ {
+ $status = false;
+
+ $compare_func = $case_sensitive ? 'mb_strpos' : 'mb_stripos';
+
+ foreach ((array)$needle as $each_needle) {
+ $status = $each_needle === '' || $compare_func($haystack, $each_needle) === 0;
+ if ($status) {
+ break;
+ }
+ }
+
+ return $status;
+ }
+
+ /**
+ * Check if the $haystack string ends with the substring $needle
+ *
+ * @param string $haystack
+ * @param string|string[] $needle
+ * @param bool $case_sensitive
+ *
+ * @return bool
+ */
+ public static function endsWith($haystack, $needle, $case_sensitive = true)
+ {
+ $status = false;
+
+ $compare_func = $case_sensitive ? 'mb_strrpos' : 'mb_strripos';
+
+ foreach ((array)$needle as $each_needle) {
+ $expectedPosition = mb_strlen($haystack) - mb_strlen($each_needle);
+ $status = $each_needle === '' || $compare_func($haystack, $each_needle, 0) === $expectedPosition;
+ if ($status) {
+ break;
+ }
+ }
+
+ return $status;
+ }
+
+ /**
+ * Check if the $haystack string contains the substring $needle
+ *
+ * @param string $haystack
+ * @param string|string[] $needle
+ * @param bool $case_sensitive
+ *
+ * @return bool
+ */
+ public static function contains($haystack, $needle, $case_sensitive = true)
+ {
+ $status = false;
+
+ $compare_func = $case_sensitive ? 'mb_strpos' : 'mb_stripos';
+
+ foreach ((array)$needle as $each_needle) {
+ $status = $each_needle === '' || $compare_func($haystack, $each_needle) !== false;
+ if ($status) {
+ break;
+ }
+ }
+
+ return $status;
+ }
+
+ /**
+ * Function that can match wildcards
+ *
+ * match_wildcard('foo*', $test), // TRUE
+ * match_wildcard('bar*', $test), // FALSE
+ * match_wildcard('*bar*', $test), // TRUE
+ * match_wildcard('**blob**', $test), // TRUE
+ * match_wildcard('*a?d*', $test), // TRUE
+ * match_wildcard('*etc**', $test) // TRUE
+ *
+ * @param string $wildcard_pattern
+ * @param string $haystack
+ * @return false|int
+ */
+ public static function matchWildcard($wildcard_pattern, $haystack) {
+ $regex = str_replace(
+ array("\*", "\?"), // wildcard chars
+ array('.*','.'), // regexp chars
+ preg_quote($wildcard_pattern, '/')
+ );
+
+ return preg_match('/^'.$regex.'$/is', $haystack);
+ }
+
+ /**
+ * Returns the substring of a string up to a specified needle. if not found, return the whole haystack
+ *
+ * @param string $haystack
+ * @param string $needle
+ * @param bool $case_sensitive
+ *
+ * @return string
+ */
+ public static function substrToString($haystack, $needle, $case_sensitive = true)
+ {
+ $compare_func = $case_sensitive ? 'mb_strpos' : 'mb_stripos';
+
+ if (static::contains($haystack, $needle, $case_sensitive)) {
+ return mb_substr($haystack, 0, $compare_func($haystack, $needle, $case_sensitive));
+ }
+
+ return $haystack;
+ }
+
+ /**
+ * Utility method to replace only the first occurrence in a string
+ *
+ * @param string $search
+ * @param string $replace
+ * @param string $subject
+ *
+ * @return string
+ */
+ public static function replaceFirstOccurrence($search, $replace, $subject)
+ {
+ if (!$search) {
+ return $subject;
+ }
+
+ $pos = mb_strpos($subject, $search);
+ if ($pos !== false) {
+ $subject = static::mb_substr_replace($subject, $replace, $pos, mb_strlen($search));
+ }
+
+
+ return $subject;
+ }
+
+ /**
+ * Utility method to replace only the last occurrence in a string
+ *
+ * @param string $search
+ * @param string $replace
+ * @param string $subject
+ * @return string
+ */
+ public static function replaceLastOccurrence($search, $replace, $subject)
+ {
+ $pos = strrpos($subject, $search);
+
+ if($pos !== false)
+ {
+ $subject = static::mb_substr_replace($subject, $replace, $pos, mb_strlen($search));
+ }
+
+ return $subject;
+ }
+
+ /**
+ * Multibyte compatible substr_replace
+ *
+ * @param string $original
+ * @param string $replacement
+ * @param int $position
+ * @param int $length
+ * @return string
+ */
+ public static function mb_substr_replace($original, $replacement, $position, $length)
+ {
+ $startString = mb_substr($original, 0, $position, "UTF-8");
+ $endString = mb_substr($original, $position + $length, mb_strlen($original), "UTF-8");
+
+ return $startString . $replacement . $endString;
+ }
+
+ /**
+ * Merge two objects into one.
+ *
+ * @param object $obj1
+ * @param object $obj2
+ *
+ * @return object
+ */
+ public static function mergeObjects($obj1, $obj2)
+ {
+ return (object)array_merge((array)$obj1, (array)$obj2);
+ }
+
+ /**
+ * Lowercase an entire array. Useful when combined with `in_array()`
+ *
+ * @param array $a
+ * @return array|false
+ */
+ public static function arrayLower(Array $a)
+ {
+ return array_map('mb_strtolower', $a);
+ }
+
+ /**
+ * Simple function to remove item/s in an array by value
+ *
+ * @param $search array
+ * @param $value string|array
+ * @return array
+ */
+ public static function arrayRemoveValue(Array $search, $value)
+ {
+ foreach ((array) $value as $val) {
+ $key = array_search($val, $search);
+ if ($key !== false) {
+ unset($search[$key]);
+ }
+ }
+ return $search;
+ }
+
+ /**
+ * Recursive Merge with uniqueness
+ *
+ * @param array $array1
+ * @param array $array2
+ * @return array
+ */
+ public static function arrayMergeRecursiveUnique($array1, $array2)
+ {
+ if (empty($array1)) {
+ // Optimize the base case
+ return $array2;
+ }
+
+ foreach ($array2 as $key => $value) {
+ if (is_array($value) && isset($array1[$key]) && is_array($array1[$key])) {
+ $value = static::arrayMergeRecursiveUnique($array1[$key], $value);
+ }
+ $array1[$key] = $value;
+ }
+
+ return $array1;
+ }
+
+ /**
+ * Returns an array with the differences between $array1 and $array2
+ *
+ * @param array $array1
+ * @param array $array2
+ * @return array
+ */
+ public static function arrayDiffMultidimensional($array1, $array2)
+ {
+ $result = array();
+ foreach ($array1 as $key => $value) {
+ if (!is_array($array2) || !array_key_exists($key, $array2)) {
+ $result[$key] = $value;
+ continue;
+ }
+ if (is_array($value)) {
+ $recursiveArrayDiff = static::ArrayDiffMultidimensional($value, $array2[$key]);
+ if (count($recursiveArrayDiff)) {
+ $result[$key] = $recursiveArrayDiff;
+ }
+ continue;
+ }
+ if ($value != $array2[$key]) {
+ $result[$key] = $value;
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Array combine but supports different array lengths
+ *
+ * @param array $arr1
+ * @param array $arr2
+ * @return array|false
+ */
+ public static function arrayCombine($arr1, $arr2)
+ {
+ $count = min(count($arr1), count($arr2));
+
+ return array_combine(array_slice($arr1, 0, $count), array_slice($arr2, 0, $count));
+ }
+
+ /**
+ * Array is associative or not
+ *
+ * @param array $arr
+ * @return bool
+ */
+ public static function arrayIsAssociative($arr)
+ {
+ if ([] === $arr) {
+ return false;
+ }
+
+ return array_keys($arr) !== range(0, count($arr) - 1);
+ }
+
+ /**
+ * Return the Grav date formats allowed
+ *
+ * @return array
+ */
+ public static function dateFormats()
+ {
+ $now = new \DateTime();
+
+ $date_formats = [
+ 'd-m-Y H:i' => 'd-m-Y H:i (e.g. '.$now->format('d-m-Y H:i').')',
+ 'Y-m-d H:i' => 'Y-m-d H:i (e.g. '.$now->format('Y-m-d H:i').')',
+ 'm/d/Y h:i a' => 'm/d/Y h:i a (e.g. '.$now->format('m/d/Y h:i a').')',
+ 'H:i d-m-Y' => 'H:i d-m-Y (e.g. '.$now->format('H:i d-m-Y').')',
+ 'h:i a m/d/Y' => 'h:i a m/d/Y (e.g. '.$now->format('h:i a m/d/Y').')',
+ ];
+ $default_format = Grav::instance()['config']->get('system.pages.dateformat.default');
+ if ($default_format) {
+ $date_formats = array_merge([$default_format => $default_format.' (e.g. '.$now->format($default_format).')'], $date_formats);
+ }
+
+ return $date_formats;
+ }
+
+ /**
+ * Get current date/time
+ *
+ * @param string|null $default_format
+ * @return string
+ * @throws \Exception
+ */
+ public static function dateNow($default_format = null)
+ {
+ $now = new \DateTime();
+
+ if (is_null($default_format)) {
+ $default_format = Grav::instance()['config']->get('system.pages.dateformat.default');
+ }
+
+ return $now->format($default_format);
+ }
+
+ /**
+ * Truncate text by number of characters but can cut off words.
+ *
+ * @param string $string
+ * @param int $limit Max number of characters.
+ * @param bool $up_to_break truncate up to breakpoint after char count
+ * @param string $break Break point.
+ * @param string $pad Appended padding to the end of the string.
+ *
+ * @return string
+ */
+ public static function truncate($string, $limit = 150, $up_to_break = false, $break = ' ', $pad = '…')
+ {
+ // return with no change if string is shorter than $limit
+ if (mb_strlen($string) <= $limit) {
+ return $string;
+ }
+
+ // is $break present between $limit and the end of the string?
+ if ($up_to_break && false !== ($breakpoint = mb_strpos($string, $break, $limit))) {
+ if ($breakpoint < mb_strlen($string) - 1) {
+ $string = mb_substr($string, 0, $breakpoint) . $pad;
+ }
+ } else {
+ $string = mb_substr($string, 0, $limit) . $pad;
+ }
+
+ return $string;
+ }
+
+ /**
+ * Truncate text by number of characters in a "word-safe" manor.
+ *
+ * @param string $string
+ * @param int $limit
+ *
+ * @return string
+ */
+ public static function safeTruncate($string, $limit = 150)
+ {
+ return static::truncate($string, $limit, true);
+ }
+
+
+ /**
+ * Truncate HTML by number of characters. not "word-safe"!
+ *
+ * @param string $text
+ * @param int $length in characters
+ * @param string $ellipsis
+ *
+ * @return string
+ */
+ public static function truncateHtml($text, $length = 100, $ellipsis = '...')
+ {
+ return Truncator::truncateLetters($text, $length, $ellipsis);
+ }
+
+ /**
+ * Truncate HTML by number of characters in a "word-safe" manor.
+ *
+ * @param string $text
+ * @param int $length in words
+ * @param string $ellipsis
+ *
+ * @return string
+ */
+ public static function safeTruncateHtml($text, $length = 25, $ellipsis = '...')
+ {
+ return Truncator::truncateWords($text, $length, $ellipsis);
+ }
+
+ /**
+ * Generate a random string of a given length
+ *
+ * @param int $length
+ *
+ * @return string
+ */
+ public static function generateRandomString($length = 5)
+ {
+ return substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, $length);
+ }
+
+ /**
+ * Provides the ability to download a file to the browser
+ *
+ * @param string $file the full path to the file to be downloaded
+ * @param bool $force_download as opposed to letting browser choose if to download or render
+ * @param int $sec Throttling, try 0.1 for some speed throttling of downloads
+ * @param int $bytes Size of chunks to send in bytes. Default is 1024
+ * @throws \Exception
+ */
+ public static function download($file, $force_download = true, $sec = 0, $bytes = 1024)
+ {
+ if (file_exists($file)) {
+ // fire download event
+ Grav::instance()->fireEvent('onBeforeDownload', new Event(['file' => $file]));
+
+ $file_parts = pathinfo($file);
+ $mimetype = static::getMimeByExtension($file_parts['extension']);
+ $size = filesize($file); // File size
+
+ // clean all buffers
+ while (ob_get_level()) {
+ ob_end_clean();
+ }
+
+ // required for IE, otherwise Content-Disposition may be ignored
+ if (ini_get('zlib.output_compression')) {
+ ini_set('zlib.output_compression', 'Off');
+ }
+
+ header('Content-Type: ' . $mimetype);
+ header('Accept-Ranges: bytes');
+
+ if ($force_download) {
+ // output the regular HTTP headers
+ header('Content-Disposition: attachment; filename="' . $file_parts['basename'] . '"');
+ }
+
+ // multipart-download and download resuming support
+ if (isset($_SERVER['HTTP_RANGE'])) {
+ list($a, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
+ list($range) = explode(',', $range, 2);
+ list($range, $range_end) = explode('-', $range);
+ $range = (int)$range;
+ if (!$range_end) {
+ $range_end = $size - 1;
+ } else {
+ $range_end = (int)$range_end;
+ }
+ $new_length = $range_end - $range + 1;
+ header('HTTP/1.1 206 Partial Content');
+ header("Content-Length: {$new_length}");
+ header("Content-Range: bytes {$range}-{$range_end}/{$size}");
+ } else {
+ $range = 0;
+ $new_length = $size;
+ header('Content-Length: ' . $size);
+
+ if (Grav::instance()['config']->get('system.cache.enabled')) {
+ $expires = Grav::instance()['config']->get('system.pages.expires');
+ if ($expires > 0) {
+ $expires_date = gmdate('D, d M Y H:i:s T', time() + $expires);
+ header('Cache-Control: max-age=' . $expires);
+ header('Expires: ' . $expires_date);
+ header('Pragma: cache');
+ }
+ header('Last-Modified: ' . gmdate('D, d M Y H:i:s T', filemtime($file)));
+
+ // Return 304 Not Modified if the file is already cached in the browser
+ if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
+ strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= filemtime($file))
+ {
+ header('HTTP/1.1 304 Not Modified');
+ exit();
+ }
+ }
+ }
+
+ /* output the file itself */
+ $chunksize = $bytes * 8; //you may want to change this
+ $bytes_send = 0;
+
+ $fp = @fopen($file, 'rb');
+ if ($fp) {
+ if ($range) {
+ fseek($fp, $range);
+ }
+ while (!feof($fp) && (!connection_aborted()) && ($bytes_send < $new_length) ) {
+ $buffer = fread($fp, $chunksize);
+ echo($buffer); //echo($buffer); // is also possible
+ flush();
+ usleep($sec * 1000000);
+ $bytes_send += strlen($buffer);
+ }
+ fclose($fp);
+ } else {
+ throw new \RuntimeException('Error - can not open file.');
+ }
+
+ exit;
+ }
+ }
+
+ /**
+ * Return the mimetype based on filename extension
+ *
+ * @param string $extension Extension of file (eg "txt")
+ * @param string $default
+ *
+ * @return string
+ */
+ public static function getMimeByExtension($extension, $default = 'application/octet-stream')
+ {
+ $extension = strtolower($extension);
+
+ // look for some standard types
+ switch ($extension) {
+ case null:
+ return $default;
+ case 'json':
+ return 'application/json';
+ case 'html':
+ return 'text/html';
+ case 'atom':
+ return 'application/atom+xml';
+ case 'rss':
+ return 'application/rss+xml';
+ case 'xml':
+ return 'application/xml';
+ }
+
+ $media_types = Grav::instance()['config']->get('media.types');
+
+ if (isset($media_types[$extension])) {
+ if (isset($media_types[$extension]['mime'])) {
+ return $media_types[$extension]['mime'];
+ }
+ }
+
+ return $default;
+ }
+
+ /**
+ * Get all the mimetypes for an array of extensions
+ *
+ * @param array $extensions
+ * @return array
+ */
+ public static function getMimeTypes(array $extensions)
+ {
+ $mimetypes = [];
+ foreach ($extensions as $extension) {
+ $mimetype = static::getMimeByExtension($extension, false);
+ if ($mimetype && !in_array($mimetype, $mimetypes)) {
+ $mimetypes[] = $mimetype;
+ }
+ }
+ return $mimetypes;
+ }
+
+
+ /**
+ * Return the mimetype based on filename extension
+ *
+ * @param string $mime mime type (eg "text/html")
+ * @param string $default default value
+ *
+ * @return string
+ */
+ public static function getExtensionByMime($mime, $default = 'html')
+ {
+ $mime = strtolower($mime);
+
+ // look for some standard mime types
+ switch ($mime) {
+ case '*/*':
+ case 'text/*':
+ case 'text/html':
+ return 'html';
+ case 'application/json':
+ return 'json';
+ case 'application/atom+xml':
+ return 'atom';
+ case 'application/rss+xml':
+ return 'rss';
+ case 'application/xml':
+ return 'xml';
+ }
+
+ $media_types = (array)Grav::instance()['config']->get('media.types');
+
+ foreach ($media_types as $extension => $type) {
+ if ($extension === 'defaults') {
+ continue;
+ }
+ if (isset($type['mime']) && $type['mime'] === $mime) {
+ return $extension;
+ }
+ }
+
+ return $default;
+ }
+
+ /**
+ * Get all the extensions for an array of mimetypes
+ *
+ * @param array $mimetypes
+ * @return array
+ */
+ public static function getExtensions(array $mimetypes)
+ {
+ $extensions = [];
+ foreach ($mimetypes as $mimetype) {
+ $extension = static::getExtensionByMime($mimetype, false);
+ if ($extension && !\in_array($extension, $extensions, true)) {
+ $extensions[] = $extension;
+ }
+ }
+
+ return $extensions;
+ }
+
+ /**
+ * Return the mimetype based on filename
+ *
+ * @param string $filename Filename or path to file
+ * @param string $default default value
+ *
+ * @return string
+ */
+ public static function getMimeByFilename($filename, $default = 'application/octet-stream')
+ {
+ return static::getMimeByExtension(pathinfo($filename, PATHINFO_EXTENSION), $default);
+ }
+
+ /**
+ * Return the mimetype based on existing local file
+ *
+ * @param string $filename Path to the file
+ *
+ * @return string|bool
+ */
+ public static function getMimeByLocalFile($filename, $default = 'application/octet-stream')
+ {
+ $type = false;
+
+ // For local files we can detect type by the file content.
+ if (!stream_is_local($filename) || !file_exists($filename)) {
+ return false;
+ }
+
+ // Prefer using finfo if it exists.
+ if (\extension_loaded('fileinfo')) {
+ $finfo = finfo_open(FILEINFO_SYMLINK | FILEINFO_MIME_TYPE);
+ $type = finfo_file($finfo, $filename);
+ finfo_close($finfo);
+ } else {
+ // Fall back to use getimagesize() if it is available (not recommended, but better than nothing)
+ $info = @getimagesize($filename);
+ if ($info) {
+ $type = $info['mime'];
+ }
+ }
+
+ return $type ?: static::getMimeByFilename($filename, $default);
+ }
+
+
+ /**
+ * Returns true if filename is considered safe.
+ *
+ * @param string $filename
+ * @return bool
+ */
+ public static function checkFilename($filename)
+ {
+ $dangerous_extensions = Grav::instance()['config']->get('security.uploads_dangerous_extensions', []);
+ array_walk($dangerous_extensions, function(&$val) {
+ $val = '.' . $val;
+ });
+
+ $extension = '.' . pathinfo($filename, PATHINFO_EXTENSION);
+
+ return !(
+ // Empty filenames are not allowed.
+ !$filename
+ // Filename should not contain horizontal/vertical tabs, newlines, nils or back/forward slashes.
+ || strtr($filename, "\t\v\n\r\0\\/", '_______') !== $filename
+ // Filename should not start or end with dot or space.
+ || trim($filename, '. ') !== $filename
+ // Filename should not contain .php in it.
+ || static::contains($extension, $dangerous_extensions)
+ );
+ }
+
+ /**
+ * Normalize path by processing relative `.` and `..` syntax and merging path
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+ public static function normalizePath($path)
+ {
+ // Resolve any streams
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ if ($locator->isStream($path)) {
+ $path = $locator->findResource($path);
+ }
+
+ // Set root properly for any URLs
+ $root = '';
+ preg_match(self::ROOTURL_REGEX, $path, $matches);
+ if ($matches) {
+ $root = $matches[1];
+ $path = $matches[2];
+ }
+
+ // Strip off leading / to ensure explode is accurate
+ if (Utils::startsWith($path,'/')) {
+ $root .= '/';
+ $path = ltrim($path, '/');
+ }
+
+ // If there are any relative paths (..) handle those
+ if (Utils::contains($path, '..')) {
+ $segments = explode('/', trim($path, '/'));
+ $ret = [];
+ foreach ($segments as $segment) {
+ if (($segment === '.') || $segment === '') {
+ continue;
+ }
+ if ($segment === '..') {
+ array_pop($ret);
+ } else {
+ $ret[] = $segment;
+ }
+ }
+ $path = implode('/', $ret);
+ }
+
+ // Stick everything back together
+ $normalized = $root . $path;
+ return $normalized;
+ }
+
+ /**
+ * Check whether a function is disabled in the PHP settings
+ *
+ * @param string $function the name of the function to check
+ *
+ * @return bool
+ */
+ public static function isFunctionDisabled($function)
+ {
+ return \in_array($function, explode(',', ini_get('disable_functions')), true);
+ }
+
+ /**
+ * Get the formatted timezones list
+ *
+ * @return array
+ */
+ public static function timezones()
+ {
+ $timezones = \DateTimeZone::listIdentifiers(\DateTimeZone::ALL);
+ $offsets = [];
+ $testDate = new \DateTime();
+
+ foreach ($timezones as $zone) {
+ $tz = new \DateTimeZone($zone);
+ $offsets[$zone] = $tz->getOffset($testDate);
+ }
+
+ asort($offsets);
+
+ $timezone_list = [];
+ foreach ($offsets as $timezone => $offset) {
+ $offset_prefix = $offset < 0 ? '-' : '+';
+ $offset_formatted = gmdate('H:i', abs($offset));
+
+ $pretty_offset = "UTC${offset_prefix}${offset_formatted}";
+
+ $timezone_list[$timezone] = "(${pretty_offset}) ".str_replace('_', ' ', $timezone);
+ }
+
+ return $timezone_list;
+ }
+
+ /**
+ * Recursively filter an array, filtering values by processing them through the $fn function argument
+ *
+ * @param array $source the Array to filter
+ * @param callable $fn the function to pass through each array item
+ *
+ * @return array
+ */
+ public static function arrayFilterRecursive(Array $source, $fn)
+ {
+ $result = [];
+ foreach ($source as $key => $value) {
+ if (is_array($value)) {
+ $result[$key] = static::arrayFilterRecursive($value, $fn);
+ continue;
+ }
+ if ($fn($key, $value)) {
+ $result[$key] = $value; // KEEP
+ continue;
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Flatten an array
+ *
+ * @param array $array
+ * @return array
+ */
+ public static function arrayFlatten($array)
+ {
+ $flatten = array();
+ foreach ($array as $key => $inner) {
+ if (is_array($inner)) {
+ foreach ($inner as $inner_key => $value) {
+ $flatten[$inner_key] = $value;
+ }
+ } else {
+ $flatten[$key] = $inner;
+ }
+ }
+
+ return $flatten;
+ }
+
+ /**
+ * Flatten a multi-dimensional associative array into dot notation
+ *
+ * @param array $array
+ * @param string $prepend
+ * @return array
+ */
+ public static function arrayFlattenDotNotation($array, $prepend = '')
+ {
+ $results = array();
+ foreach ($array as $key => $value) {
+ if (is_array($value)) {
+ $results = array_merge($results, static::arrayFlattenDotNotation($value, $prepend.$key.'.'));
+ } else {
+ $results[$prepend.$key] = $value;
+ }
+ }
+
+ return $results;
+ }
+
+ /**
+ * Opposite of flatten, convert flat dot notation array to multi dimensional array
+ *
+ * @param array $array
+ * @param string $separator
+ * @return array
+ */
+ public static function arrayUnflattenDotNotation($array, $separator = '.')
+ {
+ $newArray = [];
+ foreach ($array as $key => $value) {
+ $dots = explode($separator, $key);
+ if (\count($dots) > 1) {
+ $last = &$newArray[$dots[0]];
+ foreach ($dots as $k => $dot) {
+ if ($k === 0) {
+ continue;
+ }
+ $last = &$last[$dot];
+ }
+ $last = $value;
+ } else {
+ $newArray[$key] = $value;
+ }
+ }
+
+ return $newArray;
+ }
+
+ /**
+ * Checks if the passed path contains the language code prefix
+ *
+ * @param string $string The path
+ *
+ * @return bool|string Either false or the language
+ *
+ */
+ public static function pathPrefixedByLangCode($string)
+ {
+ $languages_enabled = Grav::instance()['config']->get('system.languages.supported', []);
+ $parts = explode('/', trim($string, '/'));
+
+ if (count($parts) > 0 && in_array($parts[0], $languages_enabled)) {
+ return $parts[0];
+ }
+
+ return false;
+ }
+
+ /**
+ * Get the timestamp of a date
+ *
+ * @param string $date a String expressed in the system.pages.dateformat.default format, with fallback to a
+ * strtotime argument
+ * @param string $format a date format to use if possible
+ * @return int the timestamp
+ */
+ public static function date2timestamp($date, $format = null)
+ {
+ $config = Grav::instance()['config'];
+ $dateformat = $format ?: $config->get('system.pages.dateformat.default');
+
+ // try to use DateTime and default format
+ if ($dateformat) {
+ $datetime = \DateTime::createFromFormat($dateformat, $date);
+ } else {
+ $datetime = new \DateTime($date);
+ }
+
+ // fallback to strtotime() if DateTime approach failed
+ if ($datetime !== false) {
+ return $datetime->getTimestamp();
+ }
+
+ return strtotime($date);
+ }
+
+ /**
+ * @param array $array
+ * @param string $path
+ * @param null $default
+ * @return mixed
+ *
+ * @deprecated 1.5 Use ->getDotNotation() method instead.
+ */
+ public static function resolve(array $array, $path, $default = null)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use ->getDotNotation() method instead', E_USER_DEPRECATED);
+
+ return static::getDotNotation($array, $path, $default);
+ }
+
+ /**
+ * Checks if a value is positive
+ *
+ * @param string $value
+ *
+ * @return boolean
+ */
+ public static function isPositive($value)
+ {
+ return in_array($value, [true, 1, '1', 'yes', 'on', 'true'], true);
+ }
+
+ /**
+ * Generates a nonce string to be hashed. Called by self::getNonce()
+ * We removed the IP portion in this version because it causes too many inconsistencies
+ * with reverse proxy setups.
+ *
+ * @param string $action
+ * @param bool $previousTick if true, generates the token for the previous tick (the previous 12 hours)
+ *
+ * @return string the nonce string
+ */
+ private static function generateNonceString($action, $previousTick = false)
+ {
+ $grav = Grav::instance();
+
+ $username = isset($grav['user']) ? $grav['user']->username : '';
+ $token = session_id();
+ $i = self::nonceTick();
+
+ if ($previousTick) {
+ $i--;
+ }
+
+ return ($i . '|' . $action . '|' . $username . '|' . $token . '|' . $grav['config']->get('security.salt'));
+ }
+
+ /**
+ * Get the time-dependent variable for nonce creation.
+ *
+ * Now a tick lasts a day. Once the day is passed, the nonce is not valid any more. Find a better way
+ * to ensure nonces issued near the end of the day do not expire in that small amount of time
+ *
+ * @return int the time part of the nonce. Changes once every 24 hours
+ */
+ private static function nonceTick()
+ {
+ $secondsInHalfADay = 60 * 60 * 12;
+
+ return (int)ceil(time() / $secondsInHalfADay);
+ }
+
+ /**
+ * Creates a hashed nonce tied to the passed action. Tied to the current user and time. The nonce for a given
+ * action is the same for 12 hours.
+ *
+ * @param string $action the action the nonce is tied to (e.g. save-user-admin or move-page-homepage)
+ * @param bool $previousTick if true, generates the token for the previous tick (the previous 12 hours)
+ *
+ * @return string the nonce
+ */
+ public static function getNonce($action, $previousTick = false)
+ {
+ // Don't regenerate this again if not needed
+ if (isset(static::$nonces[$action][$previousTick])) {
+ return static::$nonces[$action][$previousTick];
+ }
+ $nonce = md5(self::generateNonceString($action, $previousTick));
+ static::$nonces[$action][$previousTick] = $nonce;
+
+ return static::$nonces[$action][$previousTick];
+ }
+
+ /**
+ * Verify the passed nonce for the give action
+ *
+ * @param string|string[] $nonce the nonce to verify
+ * @param string $action the action to verify the nonce to
+ *
+ * @return boolean verified or not
+ */
+ public static function verifyNonce($nonce, $action)
+ {
+ //Safety check for multiple nonces
+ if (is_array($nonce)) {
+ $nonce = array_shift($nonce);
+ }
+
+ //Nonce generated 0-12 hours ago
+ if ($nonce === self::getNonce($action)) {
+ return true;
+ }
+
+ //Nonce generated 12-24 hours ago
+ $previousTick = true;
+
+ return $nonce === self::getNonce($action, $previousTick);
+ }
+
+ /**
+ * Simple helper method to get whether or not the admin plugin is active
+ *
+ * @return bool
+ */
+ public static function isAdminPlugin()
+ {
+ if (isset(Grav::instance()['admin'])) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Get a portion of an array (passed by reference) with dot-notation key
+ *
+ * @param array $array
+ * @param string|int $key
+ * @param null $default
+ * @return mixed
+ */
+ public static function getDotNotation($array, $key, $default = null)
+ {
+ if (null === $key) {
+ return $array;
+ }
+
+ if (isset($array[$key])) {
+ return $array[$key];
+ }
+
+ foreach (explode('.', $key) as $segment) {
+ if (!is_array($array) || !array_key_exists($segment, $array)) {
+ return $default;
+ }
+
+ $array = $array[$segment];
+ }
+
+ return $array;
+ }
+
+ /**
+ * Set portion of array (passed by reference) for a dot-notation key
+ * and set the value
+ *
+ * @param array $array
+ * @param string|int $key
+ * @param mixed $value
+ * @param bool $merge
+ *
+ * @return mixed
+ */
+ public static function setDotNotation(&$array, $key, $value, $merge = false)
+ {
+ if (null === $key) {
+ return $array = $value;
+ }
+
+ $keys = explode('.', $key);
+
+ while (count($keys) > 1) {
+ $key = array_shift($keys);
+
+ if ( ! isset($array[$key]) || ! is_array($array[$key]))
+ {
+ $array[$key] = array();
+ }
+
+ $array =& $array[$key];
+ }
+
+ $key = array_shift($keys);
+
+ if (!$merge || !isset($array[$key])) {
+ $array[$key] = $value;
+ } else {
+ $array[$key] = array_merge($array[$key], $value);
+ }
+
+ return $array;
+ }
+
+ /**
+ * Utility method to determine if the current OS is Windows
+ *
+ * @return bool
+ */
+ public static function isWindows()
+ {
+ return strncasecmp(PHP_OS, 'WIN', 3) === 0;
+ }
+
+ /**
+ * Utility to determine if the server running PHP is Apache
+ *
+ * @return bool
+ */
+ public static function isApache() {
+ return isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false;
+ }
+
+ /**
+ * Sort a multidimensional array by another array of ordered keys
+ *
+ * @param array $array
+ * @param array $orderArray
+ * @return array
+ */
+ public static function sortArrayByArray(array $array, array $orderArray)
+ {
+ $ordered = array();
+ foreach ($orderArray as $key) {
+ if (array_key_exists($key, $array)) {
+ $ordered[$key] = $array[$key];
+ unset($array[$key]);
+ }
+ }
+ return $ordered + $array;
+ }
+
+ /**
+ * Sort an array by a key value in the array
+ *
+ * @param mixed $array
+ * @param string|int $array_key
+ * @param int $direction
+ * @param int $sort_flags
+ * @return array
+ */
+ public static function sortArrayByKey($array, $array_key, $direction = SORT_DESC, $sort_flags = SORT_REGULAR)
+ {
+ $output = [];
+
+ if (!is_array($array) || !$array) {
+ return $output;
+ }
+
+ foreach ($array as $key => $row) {
+ $output[$key] = $row[$array_key];
+ }
+
+ array_multisort($output, $direction, $sort_flags, $array);
+
+ return $array;
+ }
+
+ /**
+ * Get path based on a token
+ *
+ * @param string $path
+ * @param PageInterface|null $page
+ * @return string
+ * @throws \RuntimeException
+ */
+ public static function getPagePathFromToken($path, PageInterface $page = null)
+ {
+ $path_parts = pathinfo($path);
+ $grav = Grav::instance();
+
+ $basename = '';
+ if (isset($path_parts['extension'])) {
+ $basename = '/' . $path_parts['basename'];
+ $path = rtrim($path_parts['dirname'], ':');
+ }
+
+ $regex = '/(@self|self@)|((?:@page|page@):(?:.*))|((?:@theme|theme@):(?:.*))/';
+ preg_match($regex, $path, $matches);
+
+ if ($matches) {
+ if ($matches[1]) {
+ if (null === $page) {
+ throw new \RuntimeException('Page not available for this self@ reference');
+ }
+ } elseif ($matches[2]) {
+ // page@
+ $parts = explode(':', $path);
+ $route = $parts[1];
+ $page = $grav['page']->find($route);
+ } elseif ($matches[3]) {
+ // theme@
+ $parts = explode(':', $path);
+ $route = $parts[1];
+ $theme = str_replace(ROOT_DIR, '', $grav['locator']->findResource("theme://"));
+
+ return $theme . $route . $basename;
+ }
+ } else {
+ return $path . $basename;
+ }
+
+ if (!$page) {
+ throw new \RuntimeException('Page route not found: ' . $path);
+ }
+
+ $path = str_replace($matches[0], rtrim($page->relativePagePath(), '/'), $path);
+
+ return $path . $basename;
+ }
+
+ public static function getUploadLimit()
+ {
+ static $max_size = -1;
+
+ if ($max_size < 0) {
+ $post_max_size = static::parseSize(ini_get('post_max_size'));
+ if ($post_max_size > 0) {
+ $max_size = $post_max_size;
+ } else {
+ $max_size = 0;
+ }
+
+ $upload_max = static::parseSize(ini_get('upload_max_filesize'));
+ if ($upload_max > 0 && $upload_max < $max_size) {
+ $max_size = $upload_max;
+ }
+ }
+
+ return $max_size;
+ }
+
+ /**
+ * Convert bytes to the unit specified by the $to parameter.
+ *
+ * @param int $bytes The filesize in Bytes.
+ * @param string $to The unit type to convert to. Accepts K, M, or G for Kilobytes, Megabytes, or Gigabytes, respectively.
+ * @param int $decimal_places The number of decimal places to return.
+ *
+ * @return int Returns only the number of units, not the type letter. Returns 0 if the $to unit type is out of scope.
+ *
+ */
+ public static function convertSize($bytes, $to, $decimal_places = 1)
+ {
+ $formulas = array(
+ 'K' => number_format($bytes / 1024, $decimal_places),
+ 'M' => number_format($bytes / 1048576, $decimal_places),
+ 'G' => number_format($bytes / 1073741824, $decimal_places)
+ );
+ return $formulas[$to] ?? 0;
+ }
+
+ /**
+ * Return a pretty size based on bytes
+ *
+ * @param int $bytes
+ * @param int $precision
+ * @return string
+ */
+ public static function prettySize($bytes, $precision = 2)
+ {
+ $units = array('B', 'KB', 'MB', 'GB', 'TB');
+
+ $bytes = max($bytes, 0);
+ $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
+ $pow = min($pow, count($units) - 1);
+
+ // Uncomment one of the following alternatives
+ $bytes /= 1024 ** $pow;
+ // $bytes /= (1 << (10 * $pow));
+
+ return round($bytes, $precision) . ' ' . $units[$pow];
+ }
+
+ /**
+ * Parse a readable file size and return a value in bytes
+ *
+ * @param string|int $size
+ * @return int
+ */
+ public static function parseSize($size)
+ {
+ $unit = preg_replace('/[^bkmgtpezy]/i', '', $size);
+ $size = preg_replace('/[^0-9\.]/', '', $size);
+
+ if ($unit) {
+ $size = $size * pow(1024, stripos('bkmgtpezy', $unit[0]));
+ }
+
+ return (int) abs(round($size));
+ }
+
+ /**
+ * Multibyte-safe Parse URL function
+ *
+ * @param string $url
+ * @return array
+ * @throws \InvalidArgumentException
+ */
+ public static function multibyteParseUrl($url)
+ {
+ $enc_url = preg_replace_callback(
+ '%[^:/@?&=#]+%usD',
+ function ($matches) {
+ return urlencode($matches[0]);
+ },
+ $url
+ );
+
+ $parts = parse_url($enc_url);
+
+ if($parts === false) {
+ throw new \InvalidArgumentException('Malformed URL: ' . $url);
+ }
+
+ foreach($parts as $name => $value) {
+ $parts[$name] = urldecode($value);
+ }
+
+ return $parts;
+ }
+
+ /**
+ * Process a string as markdown
+ *
+ * @param string $string
+ *
+ * @param bool $block Block or Line processing
+ * @param null $page
+ * @return string
+ * @throws \Exception
+ */
+ public static function processMarkdown($string, $block = true, $page = null)
+ {
+ $grav = Grav::instance();
+ $page = $page ?? $grav['page'] ?? null;
+ $defaults = [
+ 'markdown' => $grav['config']->get('system.pages.markdown', []),
+ 'images' => $grav['config']->get('system.images', [])
+ ];
+ $extra = $defaults['markdown']['extra'] ?? false;
+
+ $excerpts = new Excerpts($page, $defaults);
+
+ // Initialize the preferred variant of Parsedown
+ if ($extra) {
+ $parsedown = new ParsedownExtra($excerpts);
+ } else {
+ $parsedown = new Parsedown($excerpts);
+ }
+
+ if ($block) {
+ $string = $parsedown->text($string);
+ } else {
+ $string = $parsedown->line($string);
+ }
+
+ return $string;
+ }
+
+ /**
+ * Find the subnet of an ip with CIDR prefix size
+ *
+ * @param string $ip
+ * @param int $prefix
+ *
+ * @return string
+ */
+ public static function getSubnet($ip, $prefix = 64)
+ {
+ if (!filter_var($ip, FILTER_VALIDATE_IP)) {
+ return $ip;
+ }
+
+ // Packed representation of IP
+ $ip = inet_pton($ip);
+
+ // Maximum netmask length = same as packed address
+ $len = 8*strlen($ip);
+ if ($prefix > $len) $prefix = $len;
+
+ $mask = str_repeat('f', $prefix>>2);
+
+ switch($prefix & 3)
+ {
+ case 3: $mask .= 'e'; break;
+ case 2: $mask .= 'c'; break;
+ case 1: $mask .= '8'; break;
+ }
+ $mask = str_pad($mask, $len>>2, '0');
+
+ // Packed representation of netmask
+ $mask = pack('H*', $mask);
+ // Bitwise - Take all bits that are both 1 to generate subnet
+ $subnet = inet_ntop($ip & $mask);
+
+ return $subnet;
+ }
+
+ /**
+ * Wrapper to ensure html, htm in the front of the supported page types
+ *
+ * @param array|null $defaults
+ * @return array|mixed
+ */
+ public static function getSupportPageTypes(array $defaults = null)
+ {
+ $types = Grav::instance()['config']->get('system.pages.types', $defaults);
+
+ // remove html/htm
+ $types = static::arrayRemoveValue($types, ['html', 'htm']);
+
+ // put them back at the front
+ $types = array_merge(['html', 'htm'], $types);
+
+ return $types;
+ }
+}
diff --git a/system/src/Grav/Common/Yaml.php b/system/src/Grav/Common/Yaml.php
new file mode 100644
index 0000000..ad6d81b
--- /dev/null
+++ b/system/src/Grav/Common/Yaml.php
@@ -0,0 +1,48 @@
+decode($data);
+ }
+
+ public static function dump($data, $inline = null, $indent = null)
+ {
+ if (null === static::$yaml) {
+ static::init();
+ }
+
+ return static::$yaml->encode($data, $inline, $indent);
+ }
+
+ private static function init()
+ {
+ $config = [
+ 'inline' => 5,
+ 'indent' => 2,
+ 'native' => true,
+ 'compat' => true
+ ];
+
+ static::$yaml = new YamlFormatter($config);
+ }
+}
diff --git a/system/src/Grav/Console/Cli/BackupCommand.php b/system/src/Grav/Console/Cli/BackupCommand.php
new file mode 100644
index 0000000..54a26cf
--- /dev/null
+++ b/system/src/Grav/Console/Cli/BackupCommand.php
@@ -0,0 +1,120 @@
+setName('backup')
+ ->addArgument(
+ 'id',
+ InputArgument::OPTIONAL,
+ 'The ID of the backup profile to perform without prompting'
+
+ )
+ ->setDescription('Creates a backup of the Grav instance')
+ ->setHelp('The backup creates a zipped backup.');
+
+ $this->source = getcwd();
+ }
+
+ protected function serve()
+ {
+ $this->progress = new ProgressBar($this->output);
+ $this->progress->setFormat('Archiving %current% files [%bar% ] %percent:3s%% %elapsed:6s% %message% ');
+ $this->progress->setBarWidth(100);
+
+ Grav::instance()['config']->init();
+
+ $io = new SymfonyStyle($this->input, $this->output);
+ $io->title('Grav Backup');
+
+ /** @var Backups $backups */
+ $backups = Grav::instance()['backups'];
+ $backups_list = $backups->getBackupProfiles();
+ $backups_names = $backups->getBackupNames();
+
+ $id = null;
+
+ $inline_id = $this->input->getArgument('id');
+ if (null !== $inline_id && is_numeric($inline_id)) {
+ $id = $inline_id;
+ }
+
+ if (null === $id) {
+ if (\count($backups_list) > 1) {
+ $helper = $this->getHelper('question');
+ $question = new ChoiceQuestion(
+ 'Choose a backup?',
+ $backups_names,
+ 0
+ );
+ $question->setErrorMessage('Option %s is invalid.');
+ $backup_name = $helper->ask($this->input, $this->output, $question);
+ $id = array_search($backup_name, $backups_names, true);
+
+ $io->newLine();
+ $io->note('Selected backup: ' . $backup_name);
+ } else {
+ $id = 0;
+ }
+ }
+
+ $backup = $backups->backup($id, [$this, 'outputProgress']);
+
+ $io->newline(2);
+ $io->success('Backup Successfully Created: ' . $backup);
+ }
+
+ /**
+ * @param array $args
+ */
+ public function outputProgress($args)
+ {
+ switch ($args['type']) {
+ case 'count':
+ $steps = $args['steps'];
+ $freq = (int)($steps > 100 ? round($steps / 100) : $steps);
+ $this->progress->setMaxSteps($steps);
+ $this->progress->setRedrawFrequency($freq);
+ $this->progress->setMessage('Adding files...');
+ break;
+ case 'message':
+ $this->progress->setMessage($args['message']);
+ $this->progress->display();
+ break;
+ case 'progress':
+ if (isset($args['complete']) && $args['complete']) {
+ $this->progress->finish();
+ } else {
+ $this->progress->advance();
+ }
+ break;
+ }
+ }
+
+}
+
diff --git a/system/src/Grav/Console/Cli/CleanCommand.php b/system/src/Grav/Console/Cli/CleanCommand.php
new file mode 100644
index 0000000..a905973
--- /dev/null
+++ b/system/src/Grav/Console/Cli/CleanCommand.php
@@ -0,0 +1,323 @@
+setName('clean')
+ ->setDescription('Handles cleaning chores for Grav distribution')
+ ->setHelp('The clean clean extraneous folders and data');
+ }
+
+ /**
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $this->setupConsole($input, $output);
+
+ $this->cleanPaths();
+ }
+
+ private function cleanPaths()
+ {
+ $this->output->writeln('');
+ $this->output->writeln('DELETING ');
+ $anything = false;
+ foreach ($this->paths_to_remove as $path) {
+ $path = ROOT_DIR . $path;
+ if (is_dir($path) && @Folder::delete($path)) {
+ $anything = true;
+ $this->output->writeln('dir: ' . $path);
+ } elseif (is_file($path) && @unlink($path)) {
+ $anything = true;
+ $this->output->writeln('file: ' . $path);
+ }
+ }
+ if (!$anything) {
+ $this->output->writeln('');
+ $this->output->writeln('Nothing to clean... ');
+ }
+ }
+
+ /**
+ * Set colors style definition for the formatter.
+ *
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ */
+ public function setupConsole(InputInterface $input, OutputInterface $output)
+ {
+ $this->input = $input;
+ $this->output = $output;
+
+ $this->output->getFormatter()->setStyle('normal', new OutputFormatterStyle('white'));
+ $this->output->getFormatter()->setStyle('yellow', new OutputFormatterStyle('yellow', null, ['bold']));
+ $this->output->getFormatter()->setStyle('red', new OutputFormatterStyle('red', null, ['bold']));
+ $this->output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan', null, ['bold']));
+ $this->output->getFormatter()->setStyle('green', new OutputFormatterStyle('green', null, ['bold']));
+ $this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta', null, ['bold']));
+ $this->output->getFormatter()->setStyle('white', new OutputFormatterStyle('white', null, ['bold']));
+ }
+
+}
diff --git a/system/src/Grav/Console/Cli/ClearCacheCommand.php b/system/src/Grav/Console/Cli/ClearCacheCommand.php
new file mode 100644
index 0000000..8ef6f4f
--- /dev/null
+++ b/system/src/Grav/Console/Cli/ClearCacheCommand.php
@@ -0,0 +1,80 @@
+setName('cache')
+ ->setAliases(['clearcache', 'cache-clear'])
+ ->setDescription('Clears Grav cache')
+ ->addOption('invalidate', null, InputOption::VALUE_NONE, 'Invalidate cache, but do not remove any files')
+ ->addOption('purge', null, InputOption::VALUE_NONE, 'If set purge old caches')
+ ->addOption('all', null, InputOption::VALUE_NONE, 'If set will remove all including compiled, twig, doctrine caches')
+ ->addOption('assets-only', null, InputOption::VALUE_NONE, 'If set will remove only assets/*')
+ ->addOption('images-only', null, InputOption::VALUE_NONE, 'If set will remove only images/*')
+ ->addOption('cache-only', null, InputOption::VALUE_NONE, 'If set will remove only cache/*')
+ ->addOption('tmp-only', null, InputOption::VALUE_NONE, 'If set will remove only tmp/*')
+
+ ->setHelp('The cache command allows you to interact with Grav cache');
+ }
+
+ protected function serve()
+ {
+ $this->cleanPaths();
+ }
+
+ /**
+ * loops over the array of paths and deletes the files/folders
+ */
+ private function cleanPaths()
+ {
+ $this->output->writeln('');
+
+
+ if ($this->input->getOption('purge')) {
+ $this->output->writeln('Purging old cache ');
+ $this->output->writeln('');
+
+ $msg = Cache::purgeJob();
+ $this->output->writeln($msg);
+ } else {
+ $this->output->writeln('Clearing cache ');
+ $this->output->writeln('');
+
+ if ($this->input->getOption('all')) {
+ $remove = 'all';
+ } elseif ($this->input->getOption('assets-only')) {
+ $remove = 'assets-only';
+ } elseif ($this->input->getOption('images-only')) {
+ $remove = 'images-only';
+ } elseif ($this->input->getOption('cache-only')) {
+ $remove = 'cache-only';
+ } elseif ($this->input->getOption('tmp-only')) {
+ $remove = 'tmp-only';
+ } elseif ($this->input->getOption('invalidate')) {
+ $remove = 'invalidate';
+ } else {
+ $remove = 'standard';
+ }
+
+ foreach (Cache::clearCache($remove) as $result) {
+ $this->output->writeln($result);
+ }
+ }
+ }
+}
+
diff --git a/system/src/Grav/Console/Cli/ComposerCommand.php b/system/src/Grav/Console/Cli/ComposerCommand.php
new file mode 100644
index 0000000..ffb4e99
--- /dev/null
+++ b/system/src/Grav/Console/Cli/ComposerCommand.php
@@ -0,0 +1,50 @@
+setName("composer")
+ ->addOption(
+ 'install',
+ 'i',
+ InputOption::VALUE_NONE,
+ 'install the dependencies'
+ )
+ ->addOption(
+ 'update',
+ 'u',
+ InputOption::VALUE_NONE,
+ 'update the dependencies'
+ )
+ ->setDescription("Updates the composer vendor dependencies needed by Grav.")
+ ->setHelp('The composer command updates the composer vendor dependencies needed by Grav');
+ }
+
+ protected function serve()
+ {
+ $action = $this->input->getOption('install') ? 'install' : ($this->input->getOption('update') ? 'update' : 'install');
+
+ if ($this->input->getOption('install')) {
+ $action = 'install';
+ }
+
+ // Updates composer first
+ $this->output->writeln("\nInstalling vendor dependencies");
+ $this->output->writeln($this->composerUpdate(GRAV_ROOT, $action));
+ }
+
+}
diff --git a/system/src/Grav/Console/Cli/InstallCommand.php b/system/src/Grav/Console/Cli/InstallCommand.php
new file mode 100644
index 0000000..05f281e
--- /dev/null
+++ b/system/src/Grav/Console/Cli/InstallCommand.php
@@ -0,0 +1,176 @@
+setName('install')
+ ->addOption(
+ 'symlink',
+ 's',
+ InputOption::VALUE_NONE,
+ 'Symlink the required bits'
+ )
+ ->addArgument(
+ 'destination',
+ InputArgument::OPTIONAL,
+ 'Where to install the required bits (default to current project)'
+ )
+ ->setDescription('Installs the dependencies needed by Grav. Optionally can create symbolic links')
+ ->setHelp('The install command installs the dependencies needed by Grav. Optionally can create symbolic links');
+ }
+
+ protected function serve()
+ {
+ $dependencies_file = '.dependencies';
+ $this->destination = $this->input->getArgument('destination') ?: ROOT_DIR;
+
+ // fix trailing slash
+ $this->destination = rtrim($this->destination, DS) . DS;
+ $this->user_path = $this->destination . USER_PATH;
+ if ($local_config_file = $this->loadLocalConfig()) {
+ $this->output->writeln('Read local config from ' . $local_config_file . ' ');
+ }
+
+ // Look for dependencies file in ROOT and USER dir
+ if (file_exists($this->user_path . $dependencies_file)) {
+ $file = YamlFile::instance($this->user_path . $dependencies_file);
+ } elseif (file_exists($this->destination . $dependencies_file)) {
+ $file = YamlFile::instance($this->destination . $dependencies_file);
+ } else {
+ $this->output->writeln('ERROR Missing .dependencies file in user/ folder');
+ if ($this->input->getArgument('destination')) {
+ $this->output->writeln('HINT Are you trying to install a plugin or a theme? Make sure you use bin/gpm install , not bin/grav install . This command is only used to install Grav skeletons.');
+ } else {
+ $this->output->writeln('HINT Are you trying to install Grav? Grav is already installed. You need to run this command only if you download a skeleton from GitHub directly.');
+ }
+
+ return;
+ }
+
+ $this->config = $file->content();
+ $file->free();
+
+ // If yaml config, process
+ if ($this->config) {
+ if (!$this->input->getOption('symlink')) {
+ // Updates composer first
+ $this->output->writeln("\nInstalling vendor dependencies");
+ $this->output->writeln($this->composerUpdate(GRAV_ROOT, 'install'));
+
+ $this->gitclone();
+ } else {
+ $this->symlink();
+ }
+ } else {
+ $this->output->writeln('ERROR invalid YAML in ' . $dependencies_file);
+ }
+
+
+ }
+
+ /**
+ * Clones from Git
+ */
+ private function gitclone()
+ {
+ $this->output->writeln('');
+ $this->output->writeln('Cloning Bits ');
+ $this->output->writeln('============');
+ $this->output->writeln('');
+
+ foreach ($this->config['git'] as $repo => $data) {
+ $this->destination = rtrim($this->destination, DS);
+ $path = $this->destination . DS . $data['path'];
+ if (!file_exists($path)) {
+ exec('cd "' . $this->destination . '" && git clone -b ' . $data['branch'] . ' --depth 1 ' . $data['url'] . ' ' . $data['path'], $output, $return);
+
+ if (!$return) {
+ $this->output->writeln('SUCCESS cloned ' . $data['url'] . ' -> ' . $path . ' ');
+ } else {
+ $this->output->writeln('ERROR cloning ' . $data['url']);
+
+ }
+
+ $this->output->writeln('');
+ } else {
+ $this->output->writeln('' . $path . ' already exists, skipping... ');
+ $this->output->writeln('');
+ }
+
+ }
+ }
+
+ /**
+ * Symlinks
+ */
+ private function symlink()
+ {
+ $this->output->writeln('');
+ $this->output->writeln('Symlinking Bits ');
+ $this->output->writeln('===============');
+ $this->output->writeln('');
+
+ if (!$this->local_config) {
+ $this->output->writeln('No local configuration available, aborting... ');
+ $this->output->writeln('');
+ return;
+ }
+
+ exec('cd ' . $this->destination);
+ foreach ($this->config['links'] as $repo => $data) {
+ $repos = (array) $this->local_config[$data['scm'] . '_repos'];
+ $from = false;
+ $to = $this->destination . $data['path'];
+
+ foreach ($repos as $repo) {
+ $path = $repo . $data['src'];
+ if (file_exists($path)) {
+ $from = $path;
+ continue;
+ }
+ }
+
+ if (!$from) {
+ $this->output->writeln('source for ' . $data['src'] . ' does not exists, skipping... ');
+ $this->output->writeln('');
+ } else {
+ if (!file_exists($to)) {
+ symlink($from, $to);
+ $this->output->writeln('SUCCESS symlinked ' . $data['src'] . ' -> ' . $data['path'] . ' ');
+ $this->output->writeln('');
+ } else {
+ $this->output->writeln('destination: ' . $to . ' already exists, skipping... ');
+ $this->output->writeln('');
+ }
+ }
+ }
+ }
+}
diff --git a/system/src/Grav/Console/Cli/LogViewerCommand.php b/system/src/Grav/Console/Cli/LogViewerCommand.php
new file mode 100644
index 0000000..f9e93a3
--- /dev/null
+++ b/system/src/Grav/Console/Cli/LogViewerCommand.php
@@ -0,0 +1,85 @@
+setName('logviewer')
+ ->addOption(
+ 'file',
+ 'f',
+ InputOption::VALUE_OPTIONAL,
+ 'custom log file location (default = grav.log)'
+ )
+ ->addOption(
+ 'lines',
+ 'l',
+ InputOption::VALUE_OPTIONAL,
+ 'number of lines (default = 10)'
+ )
+ ->setDescription('Display the last few entries of Grav log')
+ ->setHelp("Display the last few entries of Grav log");
+ }
+
+ protected function serve()
+ {
+ $grav = Grav::instance();
+ $grav->setup();
+
+ $file = $this->input->getOption('file') ?? 'grav.log';
+ $lines = $this->input->getOption('lines') ?? 20;
+ $verbose = $this->input->getOption('verbose', false);
+
+ $io = new SymfonyStyle($this->input, $this->output);
+
+ $io->title('Log Viewer');
+
+ $io->writeln(sprintf('viewing last %s entries in %s ', $lines, $file));
+ $io->newLine();
+
+ $viewer = new LogViewer();
+
+ $logfile = $grav['locator']->findResource("log://" . $file);
+
+ if ($logfile) {
+ $rows = $viewer->objectTail($logfile, $lines, true);
+ foreach ($rows as $log) {
+ $date = $log['date'];
+ $level_color = LogViewer::levelColor($log['level']);
+
+ if ($date instanceof \DateTime) {
+ $output = "{$log['date']->format('Y-m-d h:i:s')} [<{$level_color}>{$log['level']}{$level_color}>]";
+ if ($log['trace'] && $verbose) {
+ $output .= " {$log['message']} \n";
+ foreach ((array) $log['trace'] as $index => $tracerow) {
+ $output .= "{$index} ${tracerow}\n";
+ }
+ } else {
+ $output .= " {$log['message']}";
+ }
+ $io->writeln($output);
+ }
+ }
+ } else {
+ $io->error('cannot find the log file: logs/' . $file);
+ }
+
+ }
+}
diff --git a/system/src/Grav/Console/Cli/NewProjectCommand.php b/system/src/Grav/Console/Cli/NewProjectCommand.php
new file mode 100644
index 0000000..90583f0
--- /dev/null
+++ b/system/src/Grav/Console/Cli/NewProjectCommand.php
@@ -0,0 +1,59 @@
+setName('new-project')
+ ->setAliases(['newproject'])
+ ->addArgument(
+ 'destination',
+ InputArgument::REQUIRED,
+ 'The destination directory of your new Grav project'
+ )
+ ->addOption(
+ 'symlink',
+ 's',
+ InputOption::VALUE_NONE,
+ 'Symlink the required bits'
+ )
+ ->setDescription('Creates a new Grav project with all the dependencies installed')
+ ->setHelp("The new-project command is a combination of the `setup` and `install` commands.\nCreates a new Grav instance and performs the installation of all the required dependencies.");
+ }
+
+ protected function serve()
+ {
+ $sandboxCommand = $this->getApplication()->find('sandbox');
+ $installCommand = $this->getApplication()->find('install');
+
+ $sandboxArguments = new ArrayInput([
+ 'command' => 'sandbox',
+ 'destination' => $this->input->getArgument('destination'),
+ '-s' => $this->input->getOption('symlink')
+ ]);
+
+ $installArguments = new ArrayInput([
+ 'command' => 'install',
+ 'destination' => $this->input->getArgument('destination'),
+ '-s' => $this->input->getOption('symlink')
+ ]);
+
+ $sandboxCommand->run($sandboxArguments, $this->output);
+ $installCommand->run($installArguments, $this->output);
+ }
+}
diff --git a/system/src/Grav/Console/Cli/SandboxCommand.php b/system/src/Grav/Console/Cli/SandboxCommand.php
new file mode 100644
index 0000000..f961412
--- /dev/null
+++ b/system/src/Grav/Console/Cli/SandboxCommand.php
@@ -0,0 +1,270 @@
+ '/.gitignore',
+ '/.editorconfig' => '/.editorconfig',
+ '/CHANGELOG.md' => '/CHANGELOG.md',
+ '/LICENSE.txt' => '/LICENSE.txt',
+ '/README.md' => '/README.md',
+ '/CONTRIBUTING.md' => '/CONTRIBUTING.md',
+ '/index.php' => '/index.php',
+ '/composer.json' => '/composer.json',
+ '/bin' => '/bin',
+ '/system' => '/system',
+ '/vendor' => '/vendor',
+ '/webserver-configs' => '/webserver-configs',
+ ];
+
+ /** @var string */
+ protected $default_file = "---\ntitle: HomePage\n---\n# HomePage\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque porttitor eu felis sed ornare. Sed a mauris venenatis, pulvinar velit vel, dictum enim. Phasellus ac rutrum velit. Nunc lorem purus, hendrerit sit amet augue aliquet, iaculis ultricies nisl. Suspendisse tincidunt euismod risus, quis feugiat arcu tincidunt eget. Nulla eros mi, commodo vel ipsum vel, aliquet congue odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque velit orci, laoreet at adipiscing eu, interdum quis nibh. Nunc a accumsan purus.";
+
+ protected $source;
+ protected $destination;
+
+ protected function configure()
+ {
+ $this
+ ->setName('sandbox')
+ ->setDescription('Setup of a base Grav system in your webroot, good for development, playing around or starting fresh')
+ ->addArgument(
+ 'destination',
+ InputArgument::REQUIRED,
+ 'The destination directory to symlink into'
+ )
+ ->addOption(
+ 'symlink',
+ 's',
+ InputOption::VALUE_NONE,
+ 'Symlink the base grav system'
+ )
+ ->setHelp("The sandbox command help create a development environment that can optionally use symbolic links to link the core of grav to the git cloned repository.\nGood for development, playing around or starting fresh");
+ $this->source = getcwd();
+ }
+
+ protected function serve()
+ {
+ $this->destination = $this->input->getArgument('destination');
+
+ // Symlink the Core Stuff
+ if ($this->input->getOption('symlink')) {
+ // Create Some core stuff if it doesn't exist
+ $this->createDirectories();
+
+ // Loop through the symlink mappings and create the symlinks
+ $this->symlink();
+
+ // Copy the Core STuff
+ } else {
+ // Create Some core stuff if it doesn't exist
+ $this->createDirectories();
+
+ // Loop through the symlink mappings and copy what otherwise would be symlinks
+ $this->copy();
+ }
+
+ $this->pages();
+ $this->initFiles();
+ $this->perms();
+ }
+
+ private function createDirectories()
+ {
+ $this->output->writeln('');
+ $this->output->writeln('Creating Directories ');
+ $dirs_created = false;
+
+ if (!file_exists($this->destination)) {
+ Folder::create($this->destination);
+ }
+
+ foreach ($this->directories as $dir) {
+ if (!file_exists($this->destination . $dir)) {
+ $dirs_created = true;
+ $this->output->writeln(' ' . $dir . ' ');
+ Folder::create($this->destination . $dir);
+ }
+ }
+
+ if (!$dirs_created) {
+ $this->output->writeln(' Directories already exist ');
+ }
+ }
+
+ private function copy()
+ {
+ $this->output->writeln('');
+ $this->output->writeln('Copying Files ');
+
+
+ foreach ($this->mappings as $source => $target) {
+ if ((string)(int)$source === (string)$source) {
+ $source = $target;
+ }
+
+ $from = $this->source . $source;
+ $to = $this->destination . $target;
+
+ $this->output->writeln(' ' . $source . ' -> ' . $to);
+ @Folder::rcopy($from, $to);
+ }
+ }
+
+ private function symlink()
+ {
+ $this->output->writeln('');
+ $this->output->writeln('Resetting Symbolic Links ');
+
+
+ foreach ($this->mappings as $source => $target) {
+ if ((string)(int)$source === (string)$source) {
+ $source = $target;
+ }
+
+ $from = $this->source . $source;
+ $to = $this->destination . $target;
+
+ $this->output->writeln(' ' . $source . ' -> ' . $to);
+
+ if (is_dir($to)) {
+ @Folder::delete($to);
+ } else {
+ @unlink($to);
+ }
+ symlink($from, $to);
+ }
+ }
+
+ private function initFiles()
+ {
+ $this->check();
+
+ $this->output->writeln('');
+ $this->output->writeln('File Initializing ');
+ $files_init = false;
+
+ // Copy files if they do not exist
+ foreach ($this->files as $source => $target) {
+ if ((string)(int)$source === (string)$source) {
+ $source = $target;
+ }
+
+ $from = $this->source . $source;
+ $to = $this->destination . $target;
+
+ if (!file_exists($to)) {
+ $files_init = true;
+ copy($from, $to);
+ $this->output->writeln(' ' . $target . ' -> Created');
+ }
+ }
+
+ if (!$files_init) {
+ $this->output->writeln(' Files already exist ');
+ }
+ }
+
+ private function pages()
+ {
+ $this->output->writeln('');
+ $this->output->writeln('Pages Initializing ');
+
+ // get pages files and initialize if no pages exist
+ $pages_dir = $this->destination . '/user/pages';
+ $pages_files = array_diff(scandir($pages_dir), ['..', '.']);
+
+ if (\count($pages_files) === 0) {
+ $destination = $this->source . '/user/pages';
+ Folder::rcopy($destination, $pages_dir);
+ $this->output->writeln(' ' . $destination . ' -> Created');
+
+ }
+ }
+
+ private function perms()
+ {
+ $this->output->writeln('');
+ $this->output->writeln('Permissions Initializing ');
+
+ $dir_perms = 0755;
+
+ $binaries = glob($this->destination . DS . 'bin' . DS . '*');
+
+ foreach ($binaries as $bin) {
+ chmod($bin, $dir_perms);
+ $this->output->writeln(' bin/' . basename($bin) . ' permissions reset to ' . decoct($dir_perms));
+ }
+
+ $this->output->writeln("");
+ }
+
+ private function check()
+ {
+ $success = true;
+
+ if (!file_exists($this->destination)) {
+ $this->output->writeln(' file: $this->destination does not exist!');
+ $success = false;
+ }
+
+ foreach ($this->directories as $dir) {
+ if (!file_exists($this->destination . $dir)) {
+ $this->output->writeln(' directory: ' . $dir . ' does not exist!');
+ $success = false;
+ }
+ }
+
+ foreach ($this->mappings as $target => $link) {
+ if (!file_exists($this->destination . $target)) {
+ $this->output->writeln(' mappings: ' . $target . ' does not exist!');
+ $success = false;
+ }
+ }
+
+ if (!$success) {
+ $this->output->writeln('');
+ $this->output->writeln('install should be run with --symlink|--s to symlink first ');
+ exit;
+ }
+ }
+}
diff --git a/system/src/Grav/Console/Cli/SchedulerCommand.php b/system/src/Grav/Console/Cli/SchedulerCommand.php
new file mode 100644
index 0000000..eaf45cd
--- /dev/null
+++ b/system/src/Grav/Console/Cli/SchedulerCommand.php
@@ -0,0 +1,179 @@
+setName('scheduler')
+ ->addOption(
+ 'install',
+ 'i',
+ InputOption::VALUE_NONE,
+ 'Show Install Command'
+ )
+ ->addOption(
+ 'jobs',
+ 'j',
+ InputOption::VALUE_NONE,
+ 'Show Jobs Summary'
+ )
+ ->addOption(
+ 'details',
+ 'd',
+ InputOption::VALUE_NONE,
+ 'Show Job Details'
+ )
+ ->setDescription('Run the Grav Scheduler. Best when integrated with system cron')
+ ->setHelp("Running without any options will force the Scheduler to run through it's jobs and process them");
+ }
+
+ protected function serve()
+ {
+// error_reporting(1);
+ $grav = Grav::instance();
+ $grav->setup();
+
+ $grav['uri']->init();
+ $grav['config']->init();
+ $grav['plugins']->init();
+ $grav['themes']->init();
+ $grav['backups']->init();
+
+ // Initialize Plugins
+ $grav->fireEvent('onPluginsInitialized');
+
+ /** @var Scheduler $scheduler */
+ $scheduler = $grav['scheduler'];
+ $grav->fireEvent('onSchedulerInitialized', new Event(['scheduler' => $scheduler]));
+
+ $this->setHelp('foo');
+
+ $io = new SymfonyStyle($this->input, $this->output);
+
+ if ($this->input->getOption('jobs')) {
+ // Show jobs list
+
+ $jobs = $scheduler->getAllJobs();
+ $job_states = $scheduler->getJobStates()->content();
+ $rows = [];
+
+ $table = new Table($this->output);
+ $table->setStyle('box');
+ $headers = ['Job ID', 'Command', 'Run At', 'Status', 'Last Run', 'State'];
+
+ $io->title('Scheduler Jobs Listing');
+
+ foreach ($jobs as $job) {
+ $job_status = ucfirst($job_states[$job->getId()]['state'] ?? 'ready');
+ $last_run = $job_states[$job->getId()]['last-run'] ?? 0;
+ $status = $job_status === 'Failure' ? "{$job_status} " : "{$job_status} ";
+ $state = $job->getEnabled() ? 'Enabled ' : 'Disabled ';
+ $row = [
+ $job->getId(),
+ "{$job->getCommand()} ",
+ "{$job->getAt()} ",
+ $status,
+ '' . ($last_run === 0 ? 'Never' : date('Y-m-d H:i', $last_run)) . ' ',
+ $state,
+
+ ];
+ $rows[] = $row;
+ }
+
+ if (!empty($rows)) {
+ $table->setHeaders($headers);
+ $table->setRows($rows);
+ $table->render();
+ } else {
+ $io->text('no jobs found...');
+ }
+
+ $io->newLine();
+ $io->note('For error details run "bin/grav scheduler -d"');
+ $io->newLine();
+ } elseif ($this->input->getOption('details')) {
+ $jobs = $scheduler->getAllJobs();
+ $job_states = $scheduler->getJobStates()->content();
+
+ $io->title('Job Details');
+
+ $table = new Table($this->output);
+ $table->setStyle('box');
+ $table->setHeaders(['Job ID', 'Last Run', 'Next Run', 'Errors']);
+ $rows = [];
+
+ foreach ($jobs as $job) {
+ $job_state = $job_states[$job->getId()];
+ $error = isset($job_state['error']) ? trim($job_state['error']) : false;
+
+ /** @var CronExpression $expression */
+ $expression = $job->getCronExpression();
+ $next_run = $expression->getNextRunDate();
+
+ $row = [];
+ $row[] = $job->getId();
+ if (!is_null($job_state['last-run'])) {
+ $row[] = '' . date('Y-m-d H:i', $job_state['last-run']) . ' ';
+ } else {
+ $row[] = 'Never ';
+ }
+ $row[] = '' . $next_run->format('Y-m-d H:i') . ' ';
+
+ if ($error) {
+ $row[] = "{$error} ";
+ } else {
+ $row[] = 'None ';
+ }
+ $rows[] = $row;
+ }
+
+ $table->setRows($rows);
+ $table->render();
+
+ } elseif ($this->input->getOption('install')) {
+ $io->title('Install Scheduler');
+
+ if ($scheduler->isCrontabSetup()) {
+ $io->success('All Ready! You have already set up Grav\'s Scheduler in your crontab');
+ } else {
+ $io->error('You still need to set up Grav\'s Scheduler in your crontab');
+ }
+ if (!Utils::isWindows()) {
+ $io->note('To install, run the following command from your terminal:');
+ $io->newLine();
+ $io->text(trim($scheduler->getCronCommand()));
+ } else {
+ $io->note('To install, create a scheduled task in Windows.');
+ $io->text('Learn more at https://learn.getgrav.org/advanced/scheduler');
+ }
+ } else {
+ // Run scheduler
+ $scheduler->run();
+
+ if ($this->input->getOption('verbose')) {
+ $io->title('Running Scheduled Jobs');
+ $io->text($scheduler->getVerboseOutput());
+ }
+ }
+ }
+}
diff --git a/system/src/Grav/Console/Cli/SecurityCommand.php b/system/src/Grav/Console/Cli/SecurityCommand.php
new file mode 100644
index 0000000..7f73086
--- /dev/null
+++ b/system/src/Grav/Console/Cli/SecurityCommand.php
@@ -0,0 +1,106 @@
+setName('security')
+ ->setDescription('Capable of running various Security checks')
+ ->setHelp('The security runs various security checks on your Grav site');
+
+ $this->source = getcwd();
+ }
+
+ protected function serve()
+ {
+ /** @var Grav $grav */
+ $grav = Grav::instance();
+ $grav->setup();
+
+ $grav['uri']->init();
+ $grav['config']->init();
+ $grav['debugger']->enabled(false);
+ $grav['plugins']->init();
+ $grav['themes']->init();
+
+ $grav['twig']->init();
+ $grav['pages']->init();
+
+ $this->progress = new ProgressBar($this->output, \count($grav['pages']->routes()) - 1);
+ $this->progress->setFormat('Scanning %current% pages [%bar% ] %percent:3s%% %elapsed:6s%');
+ $this->progress->setBarWidth(100);
+
+ $io = new SymfonyStyle($this->input, $this->output);
+ $io->title('Grav Security Check');
+
+ $output = Security::detectXssFromPages($grav['pages'], false, [$this, 'outputProgress']);
+
+ $io->newline(2);
+
+ if (!empty($output)) {
+
+ $counter = 1;
+ foreach ($output as $route => $results) {
+
+ $results_parts = array_map(function($value, $key) {
+ return $key.': \''.$value . '\'';
+ }, array_values($results), array_keys($results));
+
+ $io->writeln($counter++ .' - ' . $route . ' → ' . implode(', ', $results_parts) . ' ');
+ }
+
+ $io->error('Security Scan complete: ' . \count($output) . ' potential XSS issues found...');
+
+ } else {
+ $io->success('Security Scan complete: No issues found...');
+ }
+
+ $io->newline(1);
+
+ }
+
+ /**
+ * @param array $args
+ */
+ public function outputProgress($args)
+ {
+ switch ($args['type']) {
+ case 'count':
+ $steps = $args['steps'];
+ $freq = (int)($steps > 100 ? round($steps / 100) : $steps);
+ $this->progress->setMaxSteps($steps);
+ $this->progress->setRedrawFrequency($freq);
+ break;
+ case 'progress':
+ if (isset($args['complete']) && $args['complete']) {
+ $this->progress->finish();
+ } else {
+ $this->progress->advance();
+ }
+ break;
+ }
+ }
+
+}
+
diff --git a/system/src/Grav/Console/Cli/YamlLinterCommand.php b/system/src/Grav/Console/Cli/YamlLinterCommand.php
new file mode 100644
index 0000000..894f1c0
--- /dev/null
+++ b/system/src/Grav/Console/Cli/YamlLinterCommand.php
@@ -0,0 +1,82 @@
+setName('yamllinter')
+ ->addOption(
+ 'env',
+ 'e',
+ InputOption::VALUE_OPTIONAL,
+ 'The environment to trigger a specific configuration. For example: localhost, mysite.dev, www.mysite.com'
+ )
+ ->setDescription('Checks various files for YAML errors')
+ ->setHelp("Checks various files for YAML errors");
+ }
+
+ protected function serve()
+ {
+ $grav = Grav::instance();
+ $grav->setup();
+
+ $io = new SymfonyStyle($this->input, $this->output);
+
+ $io->title('Yaml Linter');
+
+ $io->section('User Configuration');
+ $errors = YamlLinter::lintConfig();
+
+ if (empty($errors)) {
+ $io->success('No YAML Linting issues with configuration');
+ } else {
+ $this->displayErrors($errors, $io);
+ }
+
+
+ $io->section('Pages Frontmatter');
+ $errors = YamlLinter::lintPages();
+
+ if (empty($errors)) {
+ $io->success('No YAML Linting issues with pages');
+ } else {
+ $this->displayErrors($errors, $io);
+ }
+
+ $io->section('Page Blueprints');
+ $errors = YamlLinter::lintBlueprints();
+
+ if (empty($errors)) {
+ $io->success('No YAML Linting issues with blueprints');
+ } else {
+ $this->displayErrors($errors, $io);
+ }
+
+ }
+
+ protected function displayErrors($errors, $io)
+ {
+ $io->error("YAML Linting issues found...");
+ foreach ($errors as $path => $error) {
+ $io->writeln("$path - $error");
+ }
+ }
+}
diff --git a/system/src/Grav/Console/ConsoleCommand.php b/system/src/Grav/Console/ConsoleCommand.php
new file mode 100644
index 0000000..c0fd9ad
--- /dev/null
+++ b/system/src/Grav/Console/ConsoleCommand.php
@@ -0,0 +1,186 @@
+setupConsole($input, $output);
+ $this->serve();
+ }
+
+ /**
+ * Override with your implementation.
+ */
+ protected function serve()
+ {
+ }
+
+ /**
+ * Initialize Grav.
+ *
+ * - Load configuration
+ * - Disable debugger
+ * - Set timezone, locale
+ * - Load plugins
+ * - Set Users type to be used in the site
+ *
+ * Safe to be called multiple times.
+ *
+ * @return $this
+ */
+ final protected function initializeGrav()
+ {
+ InitializeProcessor::initializeCli(Grav::instance());
+
+ return $this;
+ }
+
+ /**
+ * Set language to be used in CLI.
+ *
+ * @param string|null $code
+ */
+ final protected function setLanguage(string $code = null)
+ {
+ $this->initializeGrav();
+
+ $grav = Grav::instance();
+ /** @var Language $language */
+ $language = $grav['language'];
+ if ($language->enabled()) {
+ if ($code && $language->validate($code)) {
+ $language->setActive($code);
+ } else {
+ $language->setActive($language->getDefault());
+ }
+ }
+ }
+
+ /**
+ * Properly initialize plugins.
+ *
+ * - call $this->initializeGrav()
+ * - call onPluginsInitialized event
+ *
+ * Safe to be called multiple times.
+ *
+ * @return $this
+ */
+ final protected function initializePlugins()
+ {
+ if (!$this->plugins_initialized) {
+ $this->plugins_initialized = true;
+
+ $this->initializeGrav();
+
+ // Initialize plugins.
+ $grav = Grav::instance();
+ $grav->fireEvent('onPluginsInitialized');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Properly initialize themes.
+ *
+ * - call $this->initializePlugins()
+ * - initialize theme (call onThemeInitialized event)
+ *
+ * Safe to be called multiple times.
+ *
+ * @return $this
+ */
+ final protected function initializeThemes()
+ {
+ if (!$this->themes_initialized) {
+ $this->themes_initialized = true;
+
+ $this->initializePlugins();
+
+ // Initialize themes.
+ $grav = Grav::instance();
+ $grav['themes']->init();
+ }
+
+ return $this;
+ }
+
+ /**
+ * Properly initialize pages.
+ *
+ * - call $this->initializeThemes()
+ * - initialize assets (call onAssetsInitialized event)
+ * - initialize twig (calls the twig events)
+ * - initialize pages (calls onPagesInitialized event)
+ *
+ * Safe to be called multiple times.
+ *
+ * @return $this
+ */
+ final protected function initializePages()
+ {
+ if (!$this->pages_initialized) {
+ $this->pages_initialized = true;
+
+ $this->initializeThemes();
+
+ $grav = Grav::instance();
+
+ // Initialize assets.
+ $grav['assets']->init();
+ $grav->fireEvent('onAssetsInitialized');
+
+ // Initialize twig.
+ $grav['twig']->init();
+
+ // Initialize pages.
+ $pages = $grav['pages'];
+ $pages->init();
+ $grav->fireEvent('onPagesInitialized', new Event(['pages' => $pages]));
+ }
+
+ return $this;
+ }
+
+ protected function displayGPMRelease()
+ {
+ $this->output->writeln('');
+ $this->output->writeln('GPM Releases Configuration: ' . ucfirst(Grav::instance()['config']->get('system.gpm.releases')) . ' ');
+ $this->output->writeln('');
+ }
+
+}
diff --git a/system/src/Grav/Console/ConsoleTrait.php b/system/src/Grav/Console/ConsoleTrait.php
new file mode 100644
index 0000000..1901095
--- /dev/null
+++ b/system/src/Grav/Console/ConsoleTrait.php
@@ -0,0 +1,139 @@
+set('system.cache.cli_compatibility', true);
+ Grav::instance()['cache'];
+
+ $this->argv = $_SERVER['argv'][0];
+ $this->input = $input;
+ $this->output = $output;
+
+ $this->output->getFormatter()->setStyle('normal', new OutputFormatterStyle('white'));
+ $this->output->getFormatter()->setStyle('yellow', new OutputFormatterStyle('yellow', null, array('bold')));
+ $this->output->getFormatter()->setStyle('red', new OutputFormatterStyle('red', null, array('bold')));
+ $this->output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan', null, array('bold')));
+ $this->output->getFormatter()->setStyle('green', new OutputFormatterStyle('green', null, array('bold')));
+ $this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta', null, array('bold')));
+ $this->output->getFormatter()->setStyle('white', new OutputFormatterStyle('white', null, array('bold')));
+ }
+
+ /**
+ * @param string $path
+ */
+ public function isGravInstance($path)
+ {
+ if (!file_exists($path)) {
+ $this->output->writeln('');
+ $this->output->writeln("ERROR : Destination doesn't exist:");
+ $this->output->writeln(" $path ");
+ $this->output->writeln('');
+ exit;
+ }
+
+ if (!is_dir($path)) {
+ $this->output->writeln('');
+ $this->output->writeln("ERROR : Destination chosen to install is not a directory:");
+ $this->output->writeln(" $path ");
+ $this->output->writeln('');
+ exit;
+ }
+
+ if (!file_exists($path . DS . 'index.php') || !file_exists($path . DS . '.dependencies') || !file_exists($path . DS . 'system' . DS . 'config' . DS . 'system.yaml')) {
+ $this->output->writeln('');
+ $this->output->writeln('ERROR : Destination chosen to install does not appear to be a Grav instance:');
+ $this->output->writeln(" $path ");
+ $this->output->writeln('');
+ exit;
+ }
+ }
+
+ public function composerUpdate($path, $action = 'install')
+ {
+ $composer = Composer::getComposerExecutor();
+
+ return system($composer . ' --working-dir="'.$path.'" --no-interaction --no-dev --prefer-dist -o '. $action);
+ }
+
+ /**
+ * @param array $all
+ *
+ * @return int
+ * @throws \Exception
+ */
+ public function clearCache($all = [])
+ {
+ if ($all) {
+ $all = ['--all' => true];
+ }
+
+ $command = new ClearCacheCommand();
+ $input = new ArrayInput($all);
+ return $command->run($input, $this->output);
+ }
+
+ public function invalidateCache()
+ {
+ Cache::invalidateCache();
+ }
+
+ /**
+ * Load the local config file
+ *
+ * @return mixed string the local config file name. false if local config does not exist
+ */
+ public function loadLocalConfig()
+ {
+ $home_folder = getenv('HOME') ?: getenv('HOMEDRIVE') . getenv('HOMEPATH');
+ $local_config_file = $home_folder . '/.grav/config';
+
+ if (file_exists($local_config_file)) {
+ $file = YamlFile::instance($local_config_file);
+ $this->local_config = $file->content();
+ $file->free();
+ return $local_config_file;
+ }
+
+ return false;
+ }
+}
diff --git a/system/src/Grav/Console/Gpm/DirectInstallCommand.php b/system/src/Grav/Console/Gpm/DirectInstallCommand.php
new file mode 100644
index 0000000..bd27651
--- /dev/null
+++ b/system/src/Grav/Console/Gpm/DirectInstallCommand.php
@@ -0,0 +1,309 @@
+setName('direct-install')
+ ->setAliases(['directinstall'])
+ ->addArgument(
+ 'package-file',
+ InputArgument::REQUIRED,
+ 'Installable package local or remote . Can install specific version'
+ )
+ ->addOption(
+ 'all-yes',
+ 'y',
+ InputOption::VALUE_NONE,
+ 'Assumes yes (or best approach) instead of prompting'
+ )
+ ->addOption(
+ 'destination',
+ 'd',
+ InputOption::VALUE_OPTIONAL,
+ 'The destination where the package should be installed at. By default this would be where the grav instance has been launched from',
+ GRAV_ROOT
+ )
+ ->setDescription('Installs Grav, plugin, or theme directly from a file or a URL')
+ ->setHelp('The direct-install command installs Grav, plugin, or theme directly from a file or a URL');
+ }
+
+ /**
+ * @return bool
+ */
+ protected function serve()
+ {
+ // Making sure the destination is usable
+ $this->destination = realpath($this->input->getOption('destination'));
+
+ if (
+ !Installer::isGravInstance($this->destination) ||
+ !Installer::isValidDestination($this->destination, [Installer::EXISTS, Installer::IS_LINK])
+ ) {
+ $this->output->writeln('ERROR : ' . Installer::lastErrorMsg());
+ exit;
+ }
+
+
+ $this->all_yes = $this->input->getOption('all-yes');
+
+ $package_file = $this->input->getArgument('package-file');
+
+ $helper = $this->getHelper('question');
+ $question = new ConfirmationQuestion("Are you sure you want to direct-install {$package_file} [y|N] ", false);
+
+ $answer = $this->all_yes ? true : $helper->ask($this->input, $this->output, $question);
+
+ if (!$answer) {
+ $this->output->writeln('exiting...');
+ $this->output->writeln('');
+ exit;
+ }
+
+ $tmp_dir = Grav::instance()['locator']->findResource('tmp://', true, true);
+ $tmp_zip = $tmp_dir . '/Grav-' . uniqid();
+
+ $this->output->writeln('');
+ $this->output->writeln("Preparing to install {$package_file} ");
+
+
+ if (Response::isRemote($package_file)) {
+ $this->output->write(' |- Downloading package... 0%');
+ try {
+ $zip = GPM::downloadPackage($package_file, $tmp_zip);
+ } catch (\RuntimeException $e) {
+ $this->output->writeln('');
+ $this->output->writeln(" `- ERROR: {$e->getMessage()} ");
+ $this->output->writeln('');
+ exit;
+ }
+
+ if ($zip) {
+ $this->output->write("\x0D");
+ $this->output->write(' |- Downloading package... 100%');
+ $this->output->writeln('');
+ }
+ } else {
+ $this->output->write(' |- Copying package... 0%');
+ $zip = GPM::copyPackage($package_file, $tmp_zip);
+ if ($zip) {
+ $this->output->write("\x0D");
+ $this->output->write(' |- Copying package... 100%');
+ $this->output->writeln('');
+ }
+ }
+
+ if (file_exists($zip)) {
+ $tmp_source = $tmp_dir . '/Grav-' . uniqid();
+
+ $this->output->write(' |- Extracting package... ');
+ $extracted = Installer::unZip($zip, $tmp_source);
+
+ if (!$extracted) {
+ $this->output->write("\x0D");
+ $this->output->writeln(' |- Extracting package... failed ');
+ Folder::delete($tmp_source);
+ Folder::delete($tmp_zip);
+ exit;
+ }
+
+ $this->output->write("\x0D");
+ $this->output->writeln(' |- Extracting package... ok ');
+
+
+ $type = GPM::getPackageType($extracted);
+
+ if (!$type) {
+ $this->output->writeln(" '- ERROR: Not a valid Grav package ");
+ $this->output->writeln('');
+ Folder::delete($tmp_source);
+ Folder::delete($tmp_zip);
+ exit;
+ }
+
+ $blueprint = GPM::getBlueprints($extracted);
+ if ($blueprint) {
+ if (isset($blueprint['dependencies'])) {
+ $dependencies = [];
+ foreach ($blueprint['dependencies'] as $dependency) {
+ if (is_array($dependency)){
+ if (isset($dependency['name'])) {
+ $dependencies[] = $dependency['name'];
+ }
+ if (isset($dependency['github'])) {
+ $dependencies[] = $dependency['github'];
+ }
+ } else {
+ $dependencies[] = $dependency;
+ }
+ }
+ $this->output->writeln(' |- Dependencies found... [' . implode(',', $dependencies) . '] ');
+
+ $question = new ConfirmationQuestion(" | '- Dependencies will not be satisfied. Continue ? [y|N] ", false);
+ $answer = $this->all_yes ? true : $helper->ask($this->input, $this->output, $question);
+
+ if (!$answer) {
+ $this->output->writeln('exiting...');
+ $this->output->writeln('');
+ Folder::delete($tmp_source);
+ Folder::delete($tmp_zip);
+ exit;
+ }
+ }
+ }
+
+ if ($type === 'grav') {
+
+ $this->output->write(' |- Checking destination... ');
+ Installer::isValidDestination(GRAV_ROOT . '/system');
+ if (Installer::IS_LINK === Installer::lastErrorCode()) {
+ $this->output->write("\x0D");
+ $this->output->writeln(' |- Checking destination... symbolic link ');
+ $this->output->writeln(" '- ERROR: symlinks found... " . GRAV_ROOT . ' ');
+ $this->output->writeln('');
+ Folder::delete($tmp_source);
+ Folder::delete($tmp_zip);
+ exit;
+ }
+
+ $this->output->write("\x0D");
+ $this->output->writeln(' |- Checking destination... ok ');
+
+ $this->output->write(' |- Installing package... ');
+
+ static::upgradeGrav($zip, $extracted);
+ } else {
+ $name = GPM::getPackageName($extracted);
+
+ if (!$name) {
+ $this->output->writeln('ERROR: Name could not be determined. Please specify with --name|-n');
+ $this->output->writeln('');
+ Folder::delete($tmp_source);
+ Folder::delete($tmp_zip);
+ exit;
+ }
+
+ $install_path = GPM::getInstallPath($type, $name);
+ $is_update = file_exists($install_path);
+
+ $this->output->write(' |- Checking destination... ');
+
+ Installer::isValidDestination(GRAV_ROOT . DS . $install_path);
+ if (Installer::lastErrorCode() == Installer::IS_LINK) {
+ $this->output->write("\x0D");
+ $this->output->writeln(' |- Checking destination... symbolic link ');
+ $this->output->writeln(" '- ERROR: symlink found... " . GRAV_ROOT . DS . $install_path . ' ');
+ $this->output->writeln('');
+ Folder::delete($tmp_source);
+ Folder::delete($tmp_zip);
+ exit;
+
+ }
+
+ $this->output->write("\x0D");
+ $this->output->writeln(' |- Checking destination... ok ');
+
+ $this->output->write(' |- Installing package... ');
+
+ Installer::install(
+ $zip,
+ $this->destination,
+ $options = [
+ 'install_path' => $install_path,
+ 'theme' => (($type === 'theme')),
+ 'is_update' => $is_update
+ ],
+ $extracted
+ );
+ }
+
+ Folder::delete($tmp_source);
+
+ $this->output->write("\x0D");
+
+ if(Installer::lastErrorCode()) {
+ $this->output->writeln(" '- " . Installer::lastErrorMsg() . ' ');
+ $this->output->writeln('');
+ } else {
+ $this->output->writeln(' |- Installing package... ok ');
+ $this->output->writeln(" '- Success! ");
+ $this->output->writeln('');
+ }
+
+ } else {
+ $this->output->writeln(" '- ERROR: ZIP package could not be found ");
+ }
+
+ Folder::delete($tmp_zip);
+
+ // clear cache after successful upgrade
+ $this->clearCache();
+
+ return true;
+ }
+
+ private function upgradeGrav($zip, $folder, $keepFolder = false)
+ {
+ static $ignores = [
+ 'backup',
+ 'cache',
+ 'images',
+ 'logs',
+ 'tmp',
+ 'user',
+ '.htaccess',
+ 'robots.txt'
+ ];
+
+ if (!is_dir($folder)) {
+ Installer::setError('Invalid source folder');
+ }
+
+ try {
+ $script = $folder . '/system/install.php';
+ /** Install $installer */
+ if ((file_exists($script) && $install = include $script) && is_callable($install)) {
+ $install($zip);
+ } else {
+ Installer::install(
+ $zip,
+ GRAV_ROOT,
+ ['sophisticated' => true, 'overwrite' => true, 'ignore_symlinks' => true, 'ignores' => $ignores],
+ $folder,
+ $keepFolder
+ );
+
+ Cache::clearCache();
+ }
+ } catch (\Exception $e) {
+ Installer::setError($e->getMessage());
+ }
+ }
+}
diff --git a/system/src/Grav/Console/Gpm/IndexCommand.php b/system/src/Grav/Console/Gpm/IndexCommand.php
new file mode 100644
index 0000000..06d662b
--- /dev/null
+++ b/system/src/Grav/Console/Gpm/IndexCommand.php
@@ -0,0 +1,265 @@
+setName('index')
+ ->addOption(
+ 'force',
+ 'f',
+ InputOption::VALUE_NONE,
+ 'Force re-fetching the data from remote'
+ )
+ ->addOption(
+ 'filter',
+ 'F',
+ InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
+ 'Allows to limit the results based on one or multiple filters input. This can be either portion of a name/slug or a regex'
+ )
+ ->addOption(
+ 'themes-only',
+ 'T',
+ InputOption::VALUE_NONE,
+ 'Filters the results to only Themes'
+ )
+ ->addOption(
+ 'plugins-only',
+ 'P',
+ InputOption::VALUE_NONE,
+ 'Filters the results to only Plugins'
+ )
+ ->addOption(
+ 'updates-only',
+ 'U',
+ InputOption::VALUE_NONE,
+ 'Filters the results to Updatable Themes and Plugins only'
+ )
+ ->addOption(
+ 'installed-only',
+ 'I',
+ InputOption::VALUE_NONE,
+ 'Filters the results to only the Themes and Plugins you have installed'
+ )
+ ->addOption(
+ 'sort',
+ 's',
+ InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
+ 'Allows to sort (ASC) the results based on one or multiple keys. SORT can be either "name", "slug", "author", "date"',
+ ['date']
+ )
+ ->addOption(
+ 'desc',
+ 'D',
+ InputOption::VALUE_NONE,
+ 'Reverses the order of the output.'
+ )
+ ->setDescription('Lists the plugins and themes available for installation')
+ ->setHelp('The index command lists the plugins and themes available for installation')
+ ;
+ }
+
+ protected function serve()
+ {
+ $this->options = $this->input->getOptions();
+ $this->gpm = new GPM($this->options['force']);
+ $this->displayGPMRelease();
+ $this->data = $this->gpm->getRepository();
+
+ $data = $this->filter($this->data);
+
+ $climate = new CLImate;
+ $climate->extend('Grav\Console\TerminalObjects\Table');
+
+ if (!$data) {
+ $this->output->writeln('No data was found in the GPM repository stored locally.');
+ $this->output->writeln('Please try clearing cache and running the bin/gpm index -f command again');
+ $this->output->writeln('If this doesn\'t work try tweaking your GPM system settings.');
+ $this->output->writeln('');
+ $this->output->writeln('For more help go to:');
+ $this->output->writeln(' -> https://learn.getgrav.org/troubleshooting/common-problems#cannot-connect-to-the-gpm ');
+
+ die;
+ }
+
+ foreach ($data as $type => $packages) {
+ $this->output->writeln('' . strtoupper($type) . ' [ ' . \count($packages) . ' ]');
+ $packages = $this->sort($packages);
+
+ if (!empty($packages)) {
+
+ $table = [];
+ $index = 0;
+
+ foreach ($packages as $slug => $package) {
+ $row = [
+ 'Count' => $index++ + 1,
+ 'Name' => '' . Utils::truncate($package->name, 20, false, ' ', '...') . ' ',
+ 'Slug' => $slug,
+ 'Version'=> $this->version($package),
+ 'Installed' => $this->installed($package)
+ ];
+ $table[] = $row;
+ }
+
+ $climate->table($table);
+ }
+
+ $this->output->writeln('');
+ }
+
+ $this->output->writeln('You can either get more informations about a package by typing:');
+ $this->output->writeln(" {$this->argv} info ");
+ $this->output->writeln('');
+ $this->output->writeln('Or you can install a package by typing:');
+ $this->output->writeln(" {$this->argv} install ");
+ $this->output->writeln('');
+ }
+
+ /**
+ * @param Package $package
+ *
+ * @return string
+ */
+ private function version($package)
+ {
+ $list = $this->gpm->{'getUpdatable' . ucfirst($package->package_type)}();
+ $package = $list[$package->slug] ?? $package;
+ $type = ucfirst(preg_replace('/s$/', '', $package->package_type));
+ $updatable = $this->gpm->{'is' . $type . 'Updatable'}($package->slug);
+ $installed = $this->gpm->{'is' . $type . 'Installed'}($package->slug);
+ $local = $this->gpm->{'getInstalled' . $type}($package->slug);
+
+ if (!$installed || !$updatable) {
+ $version = $installed ? $local->version : $package->version;
+ return "v{$version} ";
+ }
+
+ if ($updatable) {
+ return "v{$package->version} -> v{$package->available} ";
+ }
+
+ return '';
+ }
+
+ /**
+ * @param Package $package
+ *
+ * @return string
+ */
+ private function installed($package)
+ {
+ $package = $list[$package->slug] ?? $package;
+ $type = ucfirst(preg_replace('/s$/', '', $package->package_type));
+ $method = 'is' . $type . 'Installed';
+ $installed = $this->gpm->{$method}($package->slug);
+
+ return !$installed ? 'not installed ' : 'installed ';
+ }
+
+ /**
+ * @param array $data
+ *
+ * @return mixed
+ */
+ public function filter($data)
+ {
+ // filtering and sorting
+ if ($this->options['plugins-only']) {
+ unset($data['themes']);
+ }
+ if ($this->options['themes-only']) {
+ unset($data['plugins']);
+ }
+
+ $filter = [
+ $this->options['filter'],
+ $this->options['installed-only'],
+ $this->options['updates-only'],
+ $this->options['desc']
+ ];
+
+ if (\count(array_filter($filter))) {
+ foreach ($data as $type => $packages) {
+ foreach ($packages as $slug => $package) {
+ $filter = true;
+
+ // Filtering by string
+ if ($this->options['filter']) {
+ $filter = preg_grep('/(' . implode('|', $this->options['filter']) . ')/i', [$slug, $package->name]);
+ }
+
+ // Filtering updatables only
+ if ($filter && $this->options['installed-only']) {
+ $method = ucfirst(preg_replace('/s$/', '', $package->package_type));
+ $function = 'is' . $method . 'Installed';
+ $filter = $this->gpm->{$function}($package->slug);
+ }
+
+ // Filtering updatables only
+ if ($filter && $this->options['updates-only']) {
+ $method = ucfirst(preg_replace('/s$/', '', $package->package_type));
+ $function = 'is' . $method . 'Updatable';
+ $filter = $this->gpm->{$function}($package->slug);
+ }
+
+ if (!$filter) {
+ unset($data[$type][$slug]);
+ }
+ }
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * @param Packages $packages
+ */
+ public function sort($packages)
+ {
+ foreach ($this->options['sort'] as $key) {
+ $packages = $packages->sort(function ($a, $b) use ($key) {
+ switch ($key) {
+ case 'author':
+ return strcmp($a->{$key}['name'], $b->{$key}['name']);
+ break;
+ default:
+ return strcmp($a->$key, $b->$key);
+ }
+ }, $this->options['desc'] ? true : false);
+ }
+
+ return $packages;
+ }
+}
diff --git a/system/src/Grav/Console/Gpm/InfoCommand.php b/system/src/Grav/Console/Gpm/InfoCommand.php
new file mode 100644
index 0000000..2fe1a2e
--- /dev/null
+++ b/system/src/Grav/Console/Gpm/InfoCommand.php
@@ -0,0 +1,180 @@
+setName('info')
+ ->addOption(
+ 'force',
+ 'f',
+ InputOption::VALUE_NONE,
+ 'Force fetching the new data remotely'
+ )
+ ->addOption(
+ 'all-yes',
+ 'y',
+ InputOption::VALUE_NONE,
+ 'Assumes yes (or best approach) instead of prompting'
+ )
+ ->addArgument(
+ 'package',
+ InputArgument::REQUIRED,
+ 'The package of which more informations are desired. Use the "index" command for a list of packages'
+ )
+ ->setDescription('Shows more informations about a package')
+ ->setHelp('The info shows more informations about a package');
+ }
+
+ /**
+ * @return int|null|void
+ */
+ protected function serve()
+ {
+ $this->gpm = new GPM($this->input->getOption('force'));
+
+ $this->all_yes = $this->input->getOption('all-yes');
+
+ $this->displayGPMRelease();
+
+ $foundPackage = $this->gpm->findPackage($this->input->getArgument('package'));
+
+ if (!$foundPackage) {
+ $this->output->writeln("The package '{$this->input->getArgument('package')}' was not found in the Grav repository.");
+ $this->output->writeln('');
+ $this->output->writeln('You can list all the available packages by typing:');
+ $this->output->writeln(" {$this->argv} index ");
+ $this->output->writeln('');
+ exit;
+ }
+
+ $this->output->writeln("Found package '{$this->input->getArgument('package')}' under the '" . ucfirst($foundPackage->package_type) . " ' section");
+ $this->output->writeln('');
+ $this->output->writeln("{$foundPackage->name} [{$foundPackage->slug}]");
+ $this->output->writeln(str_repeat('-', \strlen($foundPackage->name) + \strlen($foundPackage->slug) + 3));
+ $this->output->writeln('' . strip_tags($foundPackage->description_plain) . ' ');
+ $this->output->writeln('');
+
+ $packageURL = '';
+ if (isset($foundPackage->author['url'])) {
+ $packageURL = '<' . $foundPackage->author['url'] . '>';
+ }
+
+ $this->output->writeln('' . str_pad('Author',
+ 12) . ': ' . $foundPackage->author['name'] . ' <' . $foundPackage->author['email'] . '> ' . $packageURL);
+
+ foreach ([
+ 'version',
+ 'keywords',
+ 'date',
+ 'homepage',
+ 'demo',
+ 'docs',
+ 'guide',
+ 'repository',
+ 'bugs',
+ 'zipball_url',
+ 'license'
+ ] as $info) {
+ if (isset($foundPackage->{$info})) {
+ $name = ucfirst($info);
+ $data = $foundPackage->{$info};
+
+ if ($info === 'zipball_url') {
+ $name = 'Download';
+ }
+
+ if ($info === 'date') {
+ $name = 'Last Update';
+ $data = date('D, j M Y, H:i:s, P ', strtotime($data));
+ }
+
+ $name = str_pad($name, 12);
+ $this->output->writeln("{$name}: {$data}");
+ }
+ }
+
+ $type = rtrim($foundPackage->package_type, 's');
+ $updatable = $this->gpm->{'is' . $type . 'Updatable'}($foundPackage->slug);
+ $installed = $this->gpm->{'is' . $type . 'Installed'}($foundPackage->slug);
+
+ // display current version if installed and different
+ if ($installed && $updatable) {
+ $local = $this->gpm->{'getInstalled'. $type}($foundPackage->slug);
+ $this->output->writeln('');
+ $this->output->writeln("Currently installed version: {$local->version} ");
+ $this->output->writeln('');
+ }
+
+ // display changelog information
+ $questionHelper = $this->getHelper('question');
+ $question = new ConfirmationQuestion('Would you like to read the changelog? [y|N] ',
+ false);
+ $answer = $this->all_yes ? true : $questionHelper->ask($this->input, $this->output, $question);
+
+ if ($answer) {
+ $changelog = $foundPackage->changelog;
+
+ $this->output->writeln('');
+ foreach ($changelog as $version => $log) {
+ $title = $version . ' [' . $log['date'] . ']';
+ $content = preg_replace_callback('/\d\.\s\[\]\(#(.*)\)/', function ($match) {
+ return "\n" . ucfirst($match[1]) . ':';
+ }, $log['content']);
+
+ $this->output->writeln("{$title} ");
+ $this->output->writeln(str_repeat('-', \strlen($title)));
+ $this->output->writeln($content);
+ $this->output->writeln('');
+
+ $question = new ConfirmationQuestion('Press [ENTER] to continue or [q] to quit ', true);
+ $answer = $this->all_yes ? false : $questionHelper->ask($this->input, $this->output, $question);
+ if (!$answer) {
+ break;
+ }
+ $this->output->writeln('');
+ }
+ }
+
+ $this->output->writeln('');
+
+ if ($installed && $updatable) {
+ $this->output->writeln('You can update this package by typing:');
+ $this->output->writeln(" {$this->argv} update {$foundPackage->slug} ");
+ } else {
+ $this->output->writeln("You can install this package by typing:");
+ $this->output->writeln(" {$this->argv} install {$foundPackage->slug} ");
+ }
+
+ $this->output->writeln('');
+
+ }
+}
diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php
new file mode 100644
index 0000000..8d544d4
--- /dev/null
+++ b/system/src/Grav/Console/Gpm/InstallCommand.php
@@ -0,0 +1,691 @@
+setName('install')
+ ->addOption(
+ 'force',
+ 'f',
+ InputOption::VALUE_NONE,
+ 'Force re-fetching the data from remote'
+ )
+ ->addOption(
+ 'all-yes',
+ 'y',
+ InputOption::VALUE_NONE,
+ 'Assumes yes (or best approach) instead of prompting'
+ )
+ ->addOption(
+ 'destination',
+ 'd',
+ InputOption::VALUE_OPTIONAL,
+ 'The destination where the package should be installed at. By default this would be where the grav instance has been launched from',
+ GRAV_ROOT
+ )
+ ->addArgument(
+ 'package',
+ InputArgument::IS_ARRAY | InputArgument::REQUIRED,
+ 'Package(s) to install. Use "bin/gpm index" to list packages. Use "bin/gpm direct-install" to install a specific version'
+ )
+ ->setDescription('Performs the installation of plugins and themes')
+ ->setHelp('The install command allows to install plugins and themes');
+ }
+
+ /**
+ * Allows to set the GPM object, used for testing the class
+ *
+ * @param GPM $gpm
+ */
+ public function setGpm(GPM $gpm)
+ {
+ $this->gpm = $gpm;
+ }
+
+ /**
+ * @return bool
+ */
+ protected function serve()
+ {
+ $this->gpm = new GPM($this->input->getOption('force'));
+
+ $this->all_yes = $this->input->getOption('all-yes');
+
+ $this->displayGPMRelease();
+
+ $this->destination = realpath($this->input->getOption('destination'));
+
+ $packages = array_map('strtolower', $this->input->getArgument('package'));
+ $this->data = $this->gpm->findPackages($packages);
+ $this->loadLocalConfig();
+
+ if (
+ !Installer::isGravInstance($this->destination) ||
+ !Installer::isValidDestination($this->destination, [Installer::EXISTS, Installer::IS_LINK])
+ ) {
+ $this->output->writeln('ERROR : ' . Installer::lastErrorMsg());
+ exit;
+ }
+
+ $this->output->writeln('');
+
+ if (!$this->data['total']) {
+ $this->output->writeln('Nothing to install.');
+ $this->output->writeln('');
+ exit;
+ }
+
+ if (\count($this->data['not_found'])) {
+ $this->output->writeln('These packages were not found on Grav: ' . implode(' , ',
+ array_keys($this->data['not_found'])) . ' ');
+ }
+
+ unset($this->data['not_found'], $this->data['total']);
+
+ if (null !== $this->local_config) {
+ // Symlinks available, ask if Grav should use them
+ $this->use_symlinks = false;
+ $helper = $this->getHelper('question');
+ $question = new ConfirmationQuestion('Should Grav use the symlinks if available? [y|N] ', false);
+
+ $answer = $this->all_yes ? false : $helper->ask($this->input, $this->output, $question);
+
+ if ($answer) {
+ $this->use_symlinks = true;
+ }
+ }
+
+ $this->output->writeln('');
+
+ try {
+ $dependencies = $this->gpm->getDependencies($packages);
+ } catch (\Exception $e) {
+ //Error out if there are incompatible packages requirements and tell which ones, and what to do
+ //Error out if there is any error in parsing the dependencies and their versions, and tell which one is broken
+ $this->output->writeln("{$e->getMessage()} ");
+ return false;
+ }
+
+ if ($dependencies) {
+ try {
+ $this->installDependencies($dependencies, 'install', 'The following dependencies need to be installed...');
+ $this->installDependencies($dependencies, 'update', 'The following dependencies need to be updated...');
+ $this->installDependencies($dependencies, 'ignore', "The following dependencies can be updated as there is a newer version, but it's not mandatory...", false);
+ } catch (\Exception $e) {
+ $this->output->writeln('Installation aborted ');
+ return false;
+ }
+
+ $this->output->writeln('Dependencies are OK ');
+ $this->output->writeln('');
+ }
+
+
+ //We're done installing dependencies. Install the actual packages
+ foreach ($this->data as $data) {
+ foreach ($data as $package_name => $package) {
+ if (array_key_exists($package_name, $dependencies)) {
+ $this->output->writeln("Package {$package_name} already installed as dependency ");
+ } else {
+ $is_valid_destination = Installer::isValidDestination($this->destination . DS . $package->install_path);
+ if ($is_valid_destination || Installer::lastErrorCode() == Installer::NOT_FOUND) {
+ $this->processPackage($package, false);
+ } else {
+ if (Installer::lastErrorCode() == Installer::EXISTS) {
+
+ try {
+ $this->askConfirmationIfMajorVersionUpdated($package);
+ $this->gpm->checkNoOtherPackageNeedsThisDependencyInALowerVersion($package->slug, $package->available, array_keys($data));
+ } catch (\Exception $e) {
+ $this->output->writeln("{$e->getMessage()} ");
+ return false;
+ }
+
+ $helper = $this->getHelper('question');
+ $question = new ConfirmationQuestion("The package {$package_name} is already installed, overwrite? [y|N] ", false);
+ $answer = $this->all_yes ? true : $helper->ask($this->input, $this->output, $question);
+
+ if ($answer) {
+ $is_update = true;
+ $this->processPackage($package, $is_update);
+ } else {
+ $this->output->writeln("Package {$package_name} not overwritten ");
+ }
+ } else {
+ if (Installer::lastErrorCode() == Installer::IS_LINK) {
+ $this->output->writeln("Cannot overwrite existing symlink for {$package_name} ");
+ $this->output->writeln('');
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (\count($this->demo_processing) > 0) {
+ foreach ($this->demo_processing as $package) {
+ $this->installDemoContent($package);
+ }
+ }
+
+ // clear cache after successful upgrade
+ $this->clearCache();
+
+ return true;
+ }
+
+ /**
+ * If the package is updated from an older major release, show warning and ask confirmation
+ *
+ * @param Package $package
+ */
+ public function askConfirmationIfMajorVersionUpdated($package)
+ {
+ $helper = $this->getHelper('question');
+ $package_name = $package->name;
+ $new_version = $package->available ?: $this->gpm->getLatestVersionOfPackage($package->slug);
+ $old_version = $package->version;
+
+ $major_version_changed = explode('.', $new_version)[0] !== explode('.', $old_version)[0];
+
+ if ($major_version_changed) {
+ if ($this->all_yes) {
+ $this->output->writeln("The package {$package_name} will be updated to a new major version {$new_version} , from {$old_version} ");
+ return;
+ }
+
+ $question = new ConfirmationQuestion("The package {$package_name} will be updated to a new major version {$new_version} , from {$old_version} . Be sure to read what changed with the new major release. Continue? [y|N] ", false);
+
+ if (!$helper->ask($this->input, $this->output, $question)) {
+ $this->output->writeln("Package {$package_name} not updated ");
+ exit;
+ }
+ }
+ }
+
+ /**
+ * Given a $dependencies list, filters their type according to $type and
+ * shows $message prior to listing them to the user. Then asks the user a confirmation prior
+ * to installing them.
+ *
+ * @param array $dependencies The dependencies array
+ * @param string $type The type of dependency to show: install, update, ignore
+ * @param string $message A message to be shown prior to listing the dependencies
+ * @param bool $required A flag that determines if the installation is required or optional
+ *
+ * @throws \Exception
+ */
+ public function installDependencies($dependencies, $type, $message, $required = true)
+ {
+ $packages = array_filter($dependencies, function ($action) use ($type) { return $action === $type; });
+ if (\count($packages) > 0) {
+ $this->output->writeln($message);
+
+ foreach ($packages as $dependencyName => $dependencyVersion) {
+ $this->output->writeln(" |- Package {$dependencyName} ");
+ }
+
+ $this->output->writeln('');
+
+ $helper = $this->getHelper('question');
+
+ if ($type === 'install') {
+ $questionAction = 'Install';
+ } else {
+ $questionAction = 'Update';
+ }
+
+ if (\count($packages) === 1) {
+ $questionArticle = 'this';
+ } else {
+ $questionArticle = 'these';
+ }
+
+ if (\count($packages) === 1) {
+ $questionNoun = 'package';
+ } else {
+ $questionNoun = 'packages';
+ }
+
+ $question = new ConfirmationQuestion("${questionAction} {$questionArticle} {$questionNoun}? [Y|n] ", true);
+ $answer = $this->all_yes ? true : $helper->ask($this->input, $this->output, $question);
+
+ if ($answer) {
+ foreach ($packages as $dependencyName => $dependencyVersion) {
+ $package = $this->gpm->findPackage($dependencyName);
+ $this->processPackage($package, $type === 'update');
+ }
+ $this->output->writeln('');
+ } else {
+ if ($required) {
+ throw new \Exception();
+ }
+ }
+ }
+ }
+
+ /**
+ * @param Package $package
+ * @param bool $is_update True if the package is an update
+ */
+ private function processPackage($package, $is_update = false)
+ {
+ if (!$package) {
+ $this->output->writeln('Package not found on the GPM! ');
+ $this->output->writeln('');
+ return;
+ }
+
+ $symlink = false;
+ if ($this->use_symlinks) {
+ if (!isset($package->version) || $this->getSymlinkSource($package)) {
+ $symlink = true;
+ }
+ }
+
+ $symlink ? $this->processSymlink($package) : $this->processGpm($package, $is_update);
+
+ $this->processDemo($package);
+ }
+
+ /**
+ * Add package to the queue to process the demo content, if demo content exists
+ *
+ * @param Package $package
+ */
+ private function processDemo($package)
+ {
+ $demo_dir = $this->destination . DS . $package->install_path . DS . '_demo';
+ if (file_exists($demo_dir)) {
+ $this->demo_processing[] = $package;
+ }
+ }
+
+ /**
+ * Prompt to install the demo content of a package
+ *
+ * @param Package $package
+ */
+ private function installDemoContent($package)
+ {
+ $demo_dir = $this->destination . DS . $package->install_path . DS . '_demo';
+
+ if (file_exists($demo_dir)) {
+ $dest_dir = $this->destination . DS . 'user';
+ $pages_dir = $dest_dir . DS . 'pages';
+
+ // Demo content exists, prompt to install it.
+ $this->output->writeln("Attention: {$package->name} contains demo content");
+ $helper = $this->getHelper('question');
+ $question = new ConfirmationQuestion('Do you wish to install this demo content? [y|N] ', false);
+
+ $answer = $helper->ask($this->input, $this->output, $question);
+
+ if (!$answer) {
+ $this->output->writeln(" '- Skipped! ");
+ $this->output->writeln('');
+
+ return;
+ }
+
+ // if pages folder exists in demo
+ if (file_exists($demo_dir . DS . 'pages')) {
+ $pages_backup = 'pages.' . date('m-d-Y-H-i-s');
+ $question = new ConfirmationQuestion('This will backup your current `user/pages` folder to `user/' . $pages_backup . '`, continue? [y|N]', false);
+ $answer = $this->all_yes ? true : $helper->ask($this->input, $this->output, $question);
+
+ if (!$answer) {
+ $this->output->writeln(" '- Skipped! ");
+ $this->output->writeln('');
+
+ return;
+ }
+
+ // backup current pages folder
+ if (file_exists($dest_dir)) {
+ if (rename($pages_dir, $dest_dir . DS . $pages_backup)) {
+ $this->output->writeln(' |- Backing up pages... ok ');
+ } else {
+ $this->output->writeln(' |- Backing up pages... failed ');
+ }
+ }
+ }
+
+ // Confirmation received, copy over the data
+ $this->output->writeln(' |- Installing demo content... ok ');
+ Folder::rcopy($demo_dir, $dest_dir);
+ $this->output->writeln(" '- Success! ");
+ $this->output->writeln('');
+ }
+ }
+
+ /**
+ * @param Package $package
+ *
+ * @return array|bool
+ */
+ private function getGitRegexMatches($package)
+ {
+ if (isset($package->repository)) {
+ $repository = $package->repository;
+ } else {
+ return false;
+ }
+
+ preg_match(GIT_REGEX, $repository, $matches);
+
+ return $matches;
+ }
+
+ /**
+ * @param Package $package
+ *
+ * @return bool|string
+ */
+ private function getSymlinkSource($package)
+ {
+ $matches = $this->getGitRegexMatches($package);
+
+ foreach ($this->local_config as $paths) {
+ if (Utils::endsWith($matches[2], '.git')) {
+ $repo_dir = preg_replace('/\.git$/', '', $matches[2]);
+ } else {
+ $repo_dir = $matches[2];
+ }
+
+ $paths = (array) $paths;
+ foreach ($paths as $repo) {
+ $path = rtrim($repo, '/') . '/' . $repo_dir;
+ if (file_exists($path)) {
+ return $path;
+ }
+ }
+
+ }
+
+ return false;
+ }
+
+ /**
+ * @param Package $package
+ */
+ private function processSymlink($package)
+ {
+
+ exec('cd ' . $this->destination);
+
+ $to = $this->destination . DS . $package->install_path;
+ $from = $this->getSymlinkSource($package);
+
+ $this->output->writeln("Preparing to Symlink {$package->name} ");
+ $this->output->write(' |- Checking source... ');
+
+ if (file_exists($from)) {
+ $this->output->writeln('ok ');
+
+ $this->output->write(' |- Checking destination... ');
+ $checks = $this->checkDestination($package);
+
+ if (!$checks) {
+ $this->output->writeln(" '- Installation failed or aborted. ");
+ $this->output->writeln('');
+ } else {
+ if (file_exists($to)) {
+ $this->output->writeln(" '- Symlink cannot overwrite an existing package, please remove first ");
+ $this->output->writeln('');
+ } else {
+ symlink($from, $to);
+
+ // extra white spaces to clear out the buffer properly
+ $this->output->writeln(' |- Symlinking package... ok ');
+ $this->output->writeln(" '- Success! ");
+ $this->output->writeln('');
+ }
+ }
+
+ return;
+ }
+
+ $this->output->writeln('not found! ');
+ $this->output->writeln(" '- Installation failed or aborted. ");
+ }
+
+ /**
+ * @param Package $package
+ * @param bool $is_update
+ *
+ * @return bool
+ */
+ private function processGpm($package, $is_update = false)
+ {
+ $version = isset($package->available) ? $package->available : $package->version;
+ $license = Licenses::get($package->slug);
+
+ $this->output->writeln("Preparing to install {$package->name} [v{$version}]");
+
+ $this->output->write(' |- Downloading package... 0%');
+ $this->file = $this->downloadPackage($package, $license);
+
+ if (!$this->file) {
+ $this->output->writeln(" '- Installation failed or aborted. ");
+ $this->output->writeln('');
+
+ return false;
+ }
+
+ $this->output->write(' |- Checking destination... ');
+ $checks = $this->checkDestination($package);
+
+ if (!$checks) {
+ $this->output->writeln(" '- Installation failed or aborted. ");
+ $this->output->writeln('');
+ } else {
+ $this->output->write(' |- Installing package... ');
+ $installation = $this->installPackage($package, $is_update);
+ if (!$installation) {
+ $this->output->writeln(" '- Installation failed or aborted. ");
+ $this->output->writeln('');
+ } else {
+ $this->output->writeln(" '- Success! ");
+ $this->output->writeln('');
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @param Package $package
+ *
+ * @param string $license
+ *
+ * @return string
+ */
+ private function downloadPackage($package, $license = null)
+ {
+ $tmp_dir = Grav::instance()['locator']->findResource('tmp://', true, true);
+ $this->tmp = $tmp_dir . '/Grav-' . uniqid();
+ $filename = $package->slug . basename($package->zipball_url);
+ $filename = preg_replace('/[\\\\\/:"*?&<>|]+/m', '-', $filename);
+ $query = '';
+
+ if (!empty($package->premium)) {
+ $query = \json_encode(array_merge(
+ $package->premium,
+ [
+ 'slug' => $package->slug,
+ 'filename' => $package->premium['filename'],
+ 'license_key' => $license
+ ]
+ ));
+
+ $query = '?d=' . base64_encode($query);
+ }
+
+ try {
+ $output = Response::get($package->zipball_url . $query, [], [$this, 'progress']);
+ } catch (\Exception $e) {
+ $error = str_replace("\n", "\n | '- ", $e->getMessage());
+ $this->output->write("\x0D");
+ // extra white spaces to clear out the buffer properly
+ $this->output->writeln(' |- Downloading package... error ');
+ $this->output->writeln(" | '- " . $error);
+
+ return false;
+ }
+
+ Folder::create($this->tmp);
+
+ $this->output->write("\x0D");
+ $this->output->write(' |- Downloading package... 100%');
+ $this->output->writeln('');
+
+ file_put_contents($this->tmp . DS . $filename, $output);
+
+ return $this->tmp . DS . $filename;
+ }
+
+ /**
+ * @param Package $package
+ *
+ * @return bool
+ */
+ private function checkDestination($package)
+ {
+ $question_helper = $this->getHelper('question');
+
+ Installer::isValidDestination($this->destination . DS . $package->install_path);
+
+ if (Installer::lastErrorCode() == Installer::IS_LINK) {
+ $this->output->write("\x0D");
+ $this->output->writeln(' |- Checking destination... symbolic link ');
+
+ if ($this->all_yes) {
+ $this->output->writeln(" | '- Skipped automatically. ");
+
+ return false;
+ }
+
+ $question = new ConfirmationQuestion(" | '- Destination has been detected as symlink, delete symbolic link first? [y|N] ",
+ false);
+ $answer = $question_helper->ask($this->input, $this->output, $question);
+
+ if (!$answer) {
+ $this->output->writeln(" | '- You decided to not delete the symlink automatically. ");
+
+ return false;
+ }
+
+ unlink($this->destination . DS . $package->install_path);
+ }
+
+ $this->output->write("\x0D");
+ $this->output->writeln(' |- Checking destination... ok ');
+
+ return true;
+ }
+
+ /**
+ * Install a package
+ *
+ * @param Package $package
+ * @param bool $is_update True if it's an update. False if it's an install
+ *
+ * @return bool
+ */
+ private function installPackage($package, $is_update = false)
+ {
+ $type = $package->package_type;
+
+ Installer::install($this->file, $this->destination, ['install_path' => $package->install_path, 'theme' => $type === 'themes', 'is_update' => $is_update]);
+ $error_code = Installer::lastErrorCode();
+ Folder::delete($this->tmp);
+
+ if ($error_code) {
+ $this->output->write("\x0D");
+ // extra white spaces to clear out the buffer properly
+ $this->output->writeln(' |- Installing package... error ');
+ $this->output->writeln(" | '- " . Installer::lastErrorMsg());
+
+ return false;
+ }
+
+ $message = Installer::getMessage();
+ if ($message) {
+ $this->output->write("\x0D");
+ // extra white spaces to clear out the buffer properly
+ $this->output->writeln(" |- {$message}");
+ }
+
+ $this->output->write("\x0D");
+ // extra white spaces to clear out the buffer properly
+ $this->output->writeln(' |- Installing package... ok ');
+
+ return true;
+ }
+
+ /**
+ * @param array $progress
+ */
+ public function progress($progress)
+ {
+ $this->output->write("\x0D");
+ $this->output->write(' |- Downloading package... ' . str_pad($progress['percent'], 5, ' ',
+ STR_PAD_LEFT) . '%');
+ }
+}
diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
new file mode 100644
index 0000000..62c6120
--- /dev/null
+++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
@@ -0,0 +1,297 @@
+setName('self-upgrade')
+ ->setAliases(['selfupgrade', 'selfupdate'])
+ ->addOption(
+ 'force',
+ 'f',
+ InputOption::VALUE_NONE,
+ 'Force re-fetching the data from remote'
+ )
+ ->addOption(
+ 'all-yes',
+ 'y',
+ InputOption::VALUE_NONE,
+ 'Assumes yes (or best approach) instead of prompting'
+ )
+ ->addOption(
+ 'overwrite',
+ 'o',
+ InputOption::VALUE_NONE,
+ 'Option to overwrite packages if they already exist'
+ )
+ ->setDescription('Detects and performs an update of Grav itself when available')
+ ->setHelp('The update command updates Grav itself when a new version is available');
+ }
+
+ protected function serve()
+ {
+ $this->upgrader = new Upgrader($this->input->getOption('force'));
+ $this->all_yes = $this->input->getOption('all-yes');
+ $this->overwrite = $this->input->getOption('overwrite');
+
+ $this->displayGPMRelease();
+
+ $update = $this->upgrader->getAssets()['grav-update'];
+
+ $local = $this->upgrader->getLocalVersion();
+ $remote = $this->upgrader->getRemoteVersion();
+ $release = strftime('%c', strtotime($this->upgrader->getReleaseDate()));
+
+ if (!$this->upgrader->meetsRequirements()) {
+ $this->output->writeln('ATTENTION: ');
+ $this->output->writeln(' Grav has increased the minimum PHP requirement.');
+ $this->output->writeln(' You are currently running PHP ' . phpversion() . ' , but PHP ' . $this->upgrader->minPHPVersion() . ' is required.');
+ $this->output->writeln(' Additional information: http://getgrav.org/blog/changing-php-requirements ');
+ $this->output->writeln('');
+ $this->output->writeln('Selfupgrade aborted.');
+ $this->output->writeln('');
+ exit;
+ }
+
+ if (!$this->overwrite && !$this->upgrader->isUpgradable()) {
+ $this->output->writeln("You are already running the latest version of Grav (v{$local}) released on {$release}");
+ exit;
+ }
+
+ Installer::isValidDestination(GRAV_ROOT . '/system');
+ if (Installer::IS_LINK === Installer::lastErrorCode()) {
+ $this->output->writeln('ATTENTION: Grav is symlinked, cannot upgrade, aborting...');
+ $this->output->writeln('');
+ $this->output->writeln("You are currently running a symbolically linked Grav v{$local}. Latest available is v{$remote}.");
+ exit;
+ }
+
+ // not used but preloaded just in case!
+ new ArrayInput([]);
+
+ $questionHelper = $this->getHelper('question');
+
+
+ $this->output->writeln("Grav v{$remote} is now available [release date: {$release}].");
+ $this->output->writeln('You are currently using v' . GRAV_VERSION . ' .');
+
+ if (!$this->all_yes) {
+ $question = new ConfirmationQuestion('Would you like to read the changelog before proceeding? [y|N] ',
+ false);
+ $answer = $questionHelper->ask($this->input, $this->output, $question);
+
+ if ($answer) {
+ $changelog = $this->upgrader->getChangelog(GRAV_VERSION);
+
+ $this->output->writeln('');
+ foreach ($changelog as $version => $log) {
+ $title = $version . ' [' . $log['date'] . ']';
+ $content = preg_replace_callback('/\d\.\s\[\]\(#(.*)\)/', function ($match) {
+ return "\n" . ucfirst($match[1]) . ':';
+ }, $log['content']);
+
+ $this->output->writeln($title);
+ $this->output->writeln(str_repeat('-', \strlen($title)));
+ $this->output->writeln($content);
+ $this->output->writeln('');
+ }
+
+ $question = new ConfirmationQuestion('Press [ENTER] to continue.', true);
+ $questionHelper->ask($this->input, $this->output, $question);
+ }
+
+ $question = new ConfirmationQuestion('Would you like to upgrade now? [y|N] ', false);
+ $answer = $questionHelper->ask($this->input, $this->output, $question);
+
+ if (!$answer) {
+ $this->output->writeln('Aborting...');
+
+ exit;
+ }
+ }
+
+ $this->output->writeln('');
+ $this->output->writeln("Preparing to upgrade to v{$remote} ..");
+
+ $this->output->write(" |- Downloading upgrade [{$this->formatBytes($update['size'])}]... 0%");
+ $this->file = $this->download($update);
+
+ $this->output->write(' |- Installing upgrade... ');
+ $installation = $this->upgrade();
+
+ if (!$installation) {
+ $this->output->writeln(" '- Installation failed or aborted. ");
+ $this->output->writeln('');
+ } else {
+ $this->output->writeln(" '- Success! ");
+ $this->output->writeln('');
+ }
+
+ // clear cache after successful upgrade
+ $this->clearCache('all');
+ }
+
+ /**
+ * @param array $package
+ *
+ * @return string
+ */
+ private function download($package)
+ {
+ $tmp_dir = Grav::instance()['locator']->findResource('tmp://', true, true);
+ $this->tmp = $tmp_dir . '/Grav-' . uniqid('', false);
+ $output = Response::get($package['download'], [], [$this, 'progress']);
+
+ Folder::create($this->tmp);
+
+ $this->output->write("\x0D");
+ $this->output->write(" |- Downloading upgrade [{$this->formatBytes($package['size'])}]... 100%");
+ $this->output->writeln('');
+
+ file_put_contents($this->tmp . DS . $package['name'], $output);
+
+ return $this->tmp . DS . $package['name'];
+ }
+
+ /**
+ * @return bool
+ */
+ private function upgrade()
+ {
+ if ($this->file) {
+ $folder = Installer::unZip($this->file, $this->tmp . '/zip');
+ } else {
+ $folder = false;
+ }
+
+ static::upgradeGrav($this->file, $folder);
+
+ $errorCode = Installer::lastErrorCode();
+
+ if ($this->tmp) {
+ Folder::delete($this->tmp);
+ }
+
+ if ($errorCode & (Installer::ZIP_OPEN_ERROR | Installer::ZIP_EXTRACT_ERROR)) {
+ $this->output->write("\x0D");
+ // extra white spaces to clear out the buffer properly
+ $this->output->writeln(' |- Installing upgrade... error ');
+ $this->output->writeln(" | '- " . Installer::lastErrorMsg());
+
+ return false;
+ }
+
+ $this->output->write("\x0D");
+ // extra white spaces to clear out the buffer properly
+ $this->output->writeln(' |- Installing upgrade... ok ');
+
+ return true;
+ }
+
+ /**
+ * @param array $progress
+ */
+ public function progress($progress)
+ {
+ $this->output->write("\x0D");
+ $this->output->write(" |- Downloading upgrade [{$this->formatBytes($progress['filesize']) }]... " . str_pad($progress['percent'],
+ 5, ' ', STR_PAD_LEFT) . '%');
+ }
+
+ /**
+ * @param int|float $size
+ * @param int $precision
+ *
+ * @return string
+ */
+ public function formatBytes($size, $precision = 2)
+ {
+ $base = log($size) / log(1024);
+ $suffixes = array('', 'k', 'M', 'G', 'T');
+
+ return round(1024 ** ($base - floor($base)), $precision) . $suffixes[(int)floor($base)];
+ }
+
+ private function upgradeGrav($zip, $folder, $keepFolder = false)
+ {
+ static $ignores = [
+ 'backup',
+ 'cache',
+ 'images',
+ 'logs',
+ 'tmp',
+ 'user',
+ '.htaccess',
+ 'robots.txt'
+ ];
+
+ if (!is_dir($folder)) {
+ Installer::setError('Invalid source folder');
+ }
+
+ try {
+ $script = $folder . '/system/install.php';
+ /** Install $installer */
+ if ((file_exists($script) && $install = include $script) && is_callable($install)) {
+ $install($zip);
+ } else {
+ Installer::install(
+ $zip,
+ GRAV_ROOT,
+ ['sophisticated' => true, 'overwrite' => true, 'ignore_symlinks' => true, 'ignores' => $ignores],
+ $folder,
+ $keepFolder
+ );
+
+ Cache::clearCache();
+ }
+ } catch (\Exception $e) {
+ Installer::setError($e->getMessage());
+ }
+ }
+}
diff --git a/system/src/Grav/Console/Gpm/UninstallCommand.php b/system/src/Grav/Console/Gpm/UninstallCommand.php
new file mode 100644
index 0000000..99fc81a
--- /dev/null
+++ b/system/src/Grav/Console/Gpm/UninstallCommand.php
@@ -0,0 +1,295 @@
+setName('uninstall')
+ ->addOption(
+ 'all-yes',
+ 'y',
+ InputOption::VALUE_NONE,
+ 'Assumes yes (or best approach) instead of prompting'
+ )
+ ->addArgument(
+ 'package',
+ InputArgument::IS_ARRAY | InputArgument::REQUIRED,
+ 'The package(s) that are desired to be removed. Use the "index" command for a list of packages'
+ )
+ ->setDescription('Performs the uninstallation of plugins and themes')
+ ->setHelp('The uninstall command allows to uninstall plugins and themes');
+ }
+
+ protected function serve()
+ {
+ $this->gpm = new GPM();
+
+ $this->all_yes = $this->input->getOption('all-yes');
+
+ $packages = array_map('strtolower', $this->input->getArgument('package'));
+ $this->data = ['total' => 0, 'not_found' => []];
+
+ $total = 0;
+ foreach ($packages as $package) {
+ $plugin = $this->gpm->getInstalledPlugin($package);
+ $theme = $this->gpm->getInstalledTheme($package);
+ if ($plugin || $theme) {
+ $this->data[strtolower($package)] = $plugin ?: $theme;
+ $total++;
+ } else {
+ $this->data['not_found'][] = $package;
+ }
+ }
+ $this->data['total'] = $total;
+
+ $this->output->writeln('');
+
+ if (!$this->data['total']) {
+ $this->output->writeln('Nothing to uninstall.');
+ $this->output->writeln('');
+ exit;
+ }
+
+ if (count($this->data['not_found'])) {
+ $this->output->writeln('These packages were not found installed: ' . implode(' , ',
+ $this->data['not_found']) . ' ');
+ }
+
+ unset($this->data['not_found'], $this->data['total']);
+
+ foreach ($this->data as $slug => $package) {
+ $this->output->writeln("Preparing to uninstall {$package->name} [v{$package->version}]");
+
+ $this->output->write(' |- Checking destination... ');
+ $checks = $this->checkDestination($slug, $package);
+
+ if (!$checks) {
+ $this->output->writeln(" '- Installation failed or aborted. ");
+ $this->output->writeln('');
+ } else {
+ $uninstall = $this->uninstallPackage($slug, $package);
+
+ if (!$uninstall) {
+ $this->output->writeln(" '- Uninstallation failed or aborted. ");
+ } else {
+ $this->output->writeln(" '- Success! ");
+ }
+ }
+
+ }
+
+ // clear cache after successful upgrade
+ $this->clearCache();
+ }
+
+
+ /**
+ * @param string $slug
+ * @param Package $package
+ *
+ * @return bool
+ */
+ private function uninstallPackage($slug, $package, $is_dependency = false)
+ {
+ if (!$slug) {
+ return false;
+ }
+
+ //check if there are packages that have this as a dependency. Abort and show list
+ $dependent_packages = $this->gpm->getPackagesThatDependOnPackage($slug);
+ if (count($dependent_packages) > ($is_dependency ? 1 : 0)) {
+ $this->output->writeln('');
+ $this->output->writeln('');
+ $this->output->writeln('Uninstallation failed. ');
+ $this->output->writeln('');
+ if (\count($dependent_packages) > ($is_dependency ? 2 : 1)) {
+ $this->output->writeln('The installed packages ' . implode(' , ', $dependent_packages) . ' depends on this package. Please remove those first.');
+ } else {
+ $this->output->writeln('The installed package ' . implode(' , ', $dependent_packages) . ' depends on this package. Please remove it first.');
+ }
+
+ $this->output->writeln('');
+ return false;
+ }
+
+ if (isset($package->dependencies)) {
+
+ $dependencies = $package->dependencies;
+
+ if ($is_dependency) {
+ foreach ($dependencies as $key => $dependency) {
+ if (\in_array($dependency['name'], $this->dependencies, true)) {
+ unset($dependencies[$key]);
+ }
+ }
+ } else {
+ if (\count($dependencies) > 0) {
+ $this->output->writeln(' `- Dependencies found...');
+ $this->output->writeln('');
+ }
+ }
+
+ $questionHelper = $this->getHelper('question');
+
+ foreach ($dependencies as $dependency) {
+
+ $this->dependencies[] = $dependency['name'];
+
+ if (\is_array($dependency)) {
+ $dependency = $dependency['name'];
+ }
+ if ($dependency === 'grav' || $dependency === 'php') {
+ continue;
+ }
+
+ $dependencyPackage = $this->gpm->findPackage($dependency);
+
+ $dependency_exists = $this->packageExists($dependency, $dependencyPackage);
+
+ if ($dependency_exists == Installer::EXISTS) {
+ $this->output->writeln("A dependency on {$dependencyPackage->name} [v{$dependencyPackage->version}] was found");
+
+ $question = new ConfirmationQuestion(" |- Uninstall {$dependencyPackage->name} ? [y|N] ", false);
+ $answer = $this->all_yes ? true : $questionHelper->ask($this->input, $this->output, $question);
+
+ if ($answer) {
+ $uninstall = $this->uninstallPackage($dependency, $dependencyPackage, true);
+
+ if (!$uninstall) {
+ $this->output->writeln(" '- Uninstallation failed or aborted. ");
+ } else {
+ $this->output->writeln(" '- Success! ");
+
+ }
+ $this->output->writeln('');
+ } else {
+ $this->output->writeln(" '- You decided not to uninstall {$dependencyPackage->name}. ");
+ $this->output->writeln('');
+ }
+ }
+
+ }
+ }
+
+
+ $locator = Grav::instance()['locator'];
+ $path = $locator->findResource($package->package_type . '://' . $slug);
+ Installer::uninstall($path);
+ $errorCode = Installer::lastErrorCode();
+
+ if ($errorCode && $errorCode !== Installer::IS_LINK && $errorCode !== Installer::EXISTS) {
+ $this->output->writeln(" |- Uninstalling {$package->name} package... error ");
+ $this->output->writeln(" | '- " . Installer::lastErrorMsg() . ' ');
+
+ return false;
+ }
+
+ $message = Installer::getMessage();
+ if ($message) {
+ $this->output->writeln(" |- {$message}");
+ }
+
+ if (!$is_dependency && $this->dependencies) {
+ $this->output->writeln("Finishing up uninstalling {$package->name} ");
+ }
+ $this->output->writeln(" |- Uninstalling {$package->name} package... ok ");
+
+
+
+ return true;
+ }
+
+ /**
+ * @param string $slug
+ * @param Package $package
+ *
+ * @return bool
+ */
+
+ private function checkDestination($slug, $package)
+ {
+ $questionHelper = $this->getHelper('question');
+
+ $exists = $this->packageExists($slug, $package);
+
+ if ($exists == Installer::IS_LINK) {
+ $this->output->write("\x0D");
+ $this->output->writeln(' |- Checking destination... symbolic link ');
+
+ if ($this->all_yes) {
+ $this->output->writeln(" | '- Skipped automatically. ");
+
+ return false;
+ }
+
+ $question = new ConfirmationQuestion(" | '- Destination has been detected as symlink, delete symbolic link first? [y|N] ",
+ false);
+ $answer = $this->all_yes ? true : $questionHelper->ask($this->input, $this->output, $question);
+
+ if (!$answer) {
+ $this->output->writeln(" | '- You decided not to delete the symlink automatically. ");
+
+ return false;
+ }
+ }
+
+ $this->output->write("\x0D");
+ $this->output->writeln(' |- Checking destination... ok ');
+
+ return true;
+ }
+
+ /**
+ * Check if package exists
+ *
+ * @param string $slug
+ * @param Package $package
+ * @return int
+ */
+ private function packageExists($slug, $package)
+ {
+ $path = Grav::instance()['locator']->findResource($package->package_type . '://' . $slug);
+ Installer::isValidDestination($path);
+ return Installer::lastErrorCode();
+ }
+}
diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php
new file mode 100644
index 0000000..d8ea735
--- /dev/null
+++ b/system/src/Grav/Console/Gpm/UpdateCommand.php
@@ -0,0 +1,268 @@
+setName('update')
+ ->addOption(
+ 'force',
+ 'f',
+ InputOption::VALUE_NONE,
+ 'Force re-fetching the data from remote'
+ )
+ ->addOption(
+ 'destination',
+ 'd',
+ InputOption::VALUE_OPTIONAL,
+ 'The grav instance location where the updates should be applied to. By default this would be where the grav cli has been launched from',
+ GRAV_ROOT
+ )
+ ->addOption(
+ 'all-yes',
+ 'y',
+ InputOption::VALUE_NONE,
+ 'Assumes yes (or best approach) instead of prompting'
+ )
+ ->addOption(
+ 'overwrite',
+ 'o',
+ InputOption::VALUE_NONE,
+ 'Option to overwrite packages if they already exist'
+ )
+ ->addOption(
+ 'plugins',
+ 'p',
+ InputOption::VALUE_NONE,
+ 'Update only plugins'
+ )
+ ->addOption(
+ 'themes',
+ 't',
+ InputOption::VALUE_NONE,
+ 'Update only themes'
+ )
+ ->addArgument(
+ 'package',
+ InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
+ 'The package or packages that is desired to update. By default all available updates will be applied.'
+ )
+ ->setDescription('Detects and performs an update of plugins and themes when available')
+ ->setHelp('The update command updates plugins and themes when a new version is available');
+ }
+
+ protected function serve()
+ {
+ $this->upgrader = new Upgrader($this->input->getOption('force'));
+ $local = $this->upgrader->getLocalVersion();
+ $remote = $this->upgrader->getRemoteVersion();
+ if ($local !== $remote) {
+ $this->output->writeln('WARNING : A new version of Grav is available. You should update Grav before updating plugins and themes. If you continue without updating Grav, some plugins or themes may stop working.');
+ $this->output->writeln('');
+ $questionHelper = $this->getHelper('question');
+ $question = new ConfirmationQuestion('Continue with the update process? [Y|n] ', true);
+ $answer = $questionHelper->ask($this->input, $this->output, $question);
+
+ if (!$answer) {
+ $this->output->writeln('Update aborted. Exiting... ');
+ exit;
+ }
+ }
+
+ $this->gpm = new GPM($this->input->getOption('force'));
+
+ $this->all_yes = $this->input->getOption('all-yes');
+ $this->overwrite = $this->input->getOption('overwrite');
+
+ $this->displayGPMRelease();
+
+ $this->destination = realpath($this->input->getOption('destination'));
+
+ if (!Installer::isGravInstance($this->destination)) {
+ $this->output->writeln('ERROR : ' . Installer::lastErrorMsg());
+ exit;
+ }
+ if ($this->input->getOption('plugins') === false && $this->input->getOption('themes') === false) {
+ $list_type = ['plugins' => true, 'themes' => true];
+ } else {
+ $list_type['plugins'] = $this->input->getOption('plugins');
+ $list_type['themes'] = $this->input->getOption('themes');
+ }
+
+ if ($this->overwrite) {
+ $this->data = $this->gpm->getInstallable($list_type);
+ $description = ' can be overwritten';
+ } else {
+ $this->data = $this->gpm->getUpdatable($list_type);
+ $description = ' need updating';
+ }
+
+ $only_packages = array_map('strtolower', $this->input->getArgument('package'));
+
+ if (!$this->overwrite && !$this->data['total']) {
+ $this->output->writeln('Nothing to update.');
+ exit;
+ }
+
+ $this->output->write("Found {$this->gpm->countInstalled()} packages installed of which {$this->data['total']} {$description}");
+
+ $limit_to = $this->userInputPackages($only_packages);
+
+ $this->output->writeln('');
+
+ unset($this->data['total'], $limit_to['total']);
+
+
+ // updates review
+ $slugs = [];
+
+ $index = 0;
+ foreach ($this->data as $packages) {
+ foreach ($packages as $slug => $package) {
+ if (!array_key_exists($slug, $limit_to) && \count($only_packages)) {
+ continue;
+ }
+
+ if (!$package->available) {
+ $package->available = $package->version;
+ }
+
+ $this->output->writeln(
+ // index
+ str_pad($index++ + 1, 2, '0', STR_PAD_LEFT) . '. ' .
+ // name
+ '' . str_pad($package->name, 15) . ' ' .
+ // version
+ "[v{$package->version} -> v{$package->available} ]"
+ );
+ $slugs[] = $slug;
+ }
+ }
+
+ if (!$this->all_yes) {
+ // prompt to continue
+ $this->output->writeln('');
+ $questionHelper = $this->getHelper('question');
+ $question = new ConfirmationQuestion('Continue with the update process? [Y|n] ', true);
+ $answer = $questionHelper->ask($this->input, $this->output, $question);
+
+ if (!$answer) {
+ $this->output->writeln('Update aborted. Exiting... ');
+ exit;
+ }
+ }
+
+ // finally update
+ $install_command = $this->getApplication()->find('install');
+
+ $args = new ArrayInput([
+ 'command' => 'install',
+ 'package' => $slugs,
+ '-f' => $this->input->getOption('force'),
+ '-d' => $this->destination,
+ '-y' => true
+ ]);
+ $command_exec = $install_command->run($args, $this->output);
+
+ if ($command_exec != 0) {
+ $this->output->writeln('Error: An error occurred while trying to install the packages');
+ exit;
+ }
+ }
+
+ /**
+ * @param array $only_packages
+ *
+ * @return array
+ */
+ private function userInputPackages($only_packages)
+ {
+ $found = ['total' => 0];
+ $ignore = [];
+
+ if (!\count($only_packages)) {
+ $this->output->writeln('');
+ } else {
+ foreach ($only_packages as $only_package) {
+ $find = $this->gpm->findPackage($only_package);
+
+ if (!$find || (!$this->overwrite && !$this->gpm->isUpdatable($find->slug))) {
+ $name = $find->slug ?? $only_package;
+ $ignore[$name] = $name;
+ } else {
+ $found[$find->slug] = $find;
+ $found['total']++;
+ }
+ }
+
+ if ($found['total']) {
+ $list = $found;
+ unset($list['total']);
+ $list = array_keys($list);
+
+ if ($found['total'] !== $this->data['total']) {
+ $this->output->write(", only {$found['total']} will be updated");
+ }
+
+ $this->output->writeln('');
+ $this->output->writeln('Limiting updates for only ' . implode(' , ',
+ $list) . ' ');
+ }
+
+ if (\count($ignore)) {
+ $this->output->writeln('');
+ $this->output->writeln('Packages not found or not requiring updates: ' . implode(' , ',
+ $ignore) . ' ');
+
+ }
+ }
+
+ return $found;
+ }
+}
diff --git a/system/src/Grav/Console/Gpm/VersionCommand.php b/system/src/Grav/Console/Gpm/VersionCommand.php
new file mode 100644
index 0000000..becc327
--- /dev/null
+++ b/system/src/Grav/Console/Gpm/VersionCommand.php
@@ -0,0 +1,112 @@
+setName('version')
+ ->addOption(
+ 'force',
+ 'f',
+ InputOption::VALUE_NONE,
+ 'Force re-fetching the data from remote'
+ )
+ ->addArgument(
+ 'package',
+ InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
+ 'The package or packages that is desired to know the version of. By default and if not specified this would be grav'
+ )
+ ->setDescription('Shows the version of an installed package. If available also shows pending updates.')
+ ->setHelp('The version command displays the current version of a package installed and, if available, the available version of pending updates');
+ }
+
+ /**
+ * @return int|null|void
+ */
+ protected function serve()
+ {
+ $this->gpm = new GPM($this->input->getOption('force'));
+ $packages = $this->input->getArgument('package');
+
+ $installed = false;
+
+ if (!count($packages)) {
+ $packages = ['grav'];
+ }
+
+ foreach ($packages as $package) {
+ $package = strtolower($package);
+ $name = null;
+ $version = null;
+ $updatable = false;
+
+ if ($package === 'grav') {
+ $name = 'Grav';
+ $version = GRAV_VERSION;
+ $upgrader = new Upgrader();
+
+ if ($upgrader->isUpgradable()) {
+ $updatable = " [upgradable: v{$upgrader->getRemoteVersion()} ]";
+ }
+
+ } else {
+ // get currently installed version
+ $locator = \Grav\Common\Grav::instance()['locator'];
+ $blueprints_path = $locator->findResource('plugins://' . $package . DS . 'blueprints.yaml');
+ if (!file_exists($blueprints_path)) { // theme?
+ $blueprints_path = $locator->findResource('themes://' . $package . DS . 'blueprints.yaml');
+ if (!file_exists($blueprints_path)) {
+ continue;
+ }
+ }
+
+ $file = YamlFile::instance($blueprints_path);
+ $package_yaml = $file->content();
+ $file->free();
+
+ $version = $package_yaml['version'];
+
+ if (!$version) {
+ continue;
+ }
+
+ $installed = $this->gpm->findPackage($package);
+ if ($installed) {
+ $name = $installed->name;
+
+ if ($this->gpm->isUpdatable($package)) {
+ $updatable = " [updatable: v{$installed->available} ]";
+ }
+ }
+ }
+
+ $updatable = $updatable ?: '';
+
+ if ($installed || $package === 'grav') {
+ $this->output->writeln("You are running {$name} v{$version} {$updatable}");
+ } else {
+ $this->output->writeln("Package {$package} not found");
+ }
+ }
+ }
+}
diff --git a/system/src/Grav/Console/TerminalObjects/Table.php b/system/src/Grav/Console/TerminalObjects/Table.php
new file mode 100644
index 0000000..4f9df63
--- /dev/null
+++ b/system/src/Grav/Console/TerminalObjects/Table.php
@@ -0,0 +1,30 @@
+column_widths = $this->getColumnWidths();
+ $this->table_width = $this->getWidth();
+ $this->border = $this->getBorder();
+
+ $this->buildHeaderRow();
+
+ foreach ($this->data as $key => $columns) {
+ $this->rows[] = $this->buildRow($columns);
+ }
+
+ $this->rows[] = $this->border;
+
+ return $this->rows;
+ }
+}
diff --git a/system/src/Grav/Framework/Cache/AbstractCache.php b/system/src/Grav/Framework/Cache/AbstractCache.php
new file mode 100644
index 0000000..127db45
--- /dev/null
+++ b/system/src/Grav/Framework/Cache/AbstractCache.php
@@ -0,0 +1,31 @@
+init($namespace, $defaultLifetime);
+ }
+}
diff --git a/system/src/Grav/Framework/Cache/Adapter/ChainCache.php b/system/src/Grav/Framework/Cache/Adapter/ChainCache.php
new file mode 100644
index 0000000..e1eea7b
--- /dev/null
+++ b/system/src/Grav/Framework/Cache/Adapter/ChainCache.php
@@ -0,0 +1,198 @@
+caches = array_values($caches);
+ $this->count = \count($caches);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doGet($key, $miss)
+ {
+ foreach ($this->caches as $i => $cache) {
+ $value = $cache->doGet($key, $miss);
+ if ($value !== $miss) {
+ while (--$i >= 0) {
+ // Update all the previous caches with missing value.
+ $this->caches[$i]->doSet($key, $value, $this->getDefaultLifetime());
+ }
+
+ return $value;
+ }
+ }
+
+ return $miss;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doSet($key, $value, $ttl)
+ {
+ $success = true;
+ $i = $this->count;
+
+ while ($i--) {
+ $success = $this->caches[$i]->doSet($key, $value, $ttl) && $success;
+ }
+
+ return $success;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doDelete($key)
+ {
+ $success = true;
+ $i = $this->count;
+
+ while ($i--) {
+ $success = $this->caches[$i]->doDelete($key) && $success;
+ }
+
+ return $success;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doClear()
+ {
+ $success = true;
+ $i = $this->count;
+
+ while ($i--) {
+ $success = $this->caches[$i]->doClear() && $success;
+ }
+ return $success;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doGetMultiple($keys, $miss)
+ {
+ $list = [];
+ foreach ($this->caches as $i => $cache) {
+ $list[$i] = $cache->doGetMultiple($keys, $miss);
+
+ $keys = array_diff_key($keys, $list[$i]);
+
+ if (!$keys) {
+ break;
+ }
+ }
+
+ $values = [];
+ // Update all the previous caches with missing values.
+ foreach (array_reverse($list) as $i => $items) {
+ $values += $items;
+ if ($i && $values) {
+ $this->caches[$i-1]->doSetMultiple($values, $this->getDefaultLifetime());
+ }
+ }
+
+ return $values;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doSetMultiple($values, $ttl)
+ {
+ $success = true;
+ $i = $this->count;
+
+ while ($i--) {
+ $success = $this->caches[$i]->doSetMultiple($values, $ttl) && $success;
+ }
+
+ return $success;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doDeleteMultiple($keys)
+ {
+ $success = true;
+ $i = $this->count;
+
+ while ($i--) {
+ $success = $this->caches[$i]->doDeleteMultiple($keys) && $success;
+ }
+
+ return $success;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doHas($key)
+ {
+ foreach ($this->caches as $cache) {
+ if ($cache->doHas($key)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php b/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
new file mode 100644
index 0000000..45c9d07
--- /dev/null
+++ b/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
@@ -0,0 +1,116 @@
+getNamespace();
+ if ($namespace) {
+ $doctrineCache->setNamespace($namespace);
+ }
+
+ $this->driver = $doctrineCache;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doGet($key, $miss)
+ {
+ $value = $this->driver->fetch($key);
+
+ // Doctrine cache does not differentiate between no result and cached 'false'. Make sure that we do.
+ return $value !== false || $this->driver->contains($key) ? $value : $miss;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doSet($key, $value, $ttl)
+ {
+ return $this->driver->save($key, $value, (int) $ttl);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doDelete($key)
+ {
+ return $this->driver->delete($key);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doClear()
+ {
+ return $this->driver->deleteAll();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doGetMultiple($keys, $miss)
+ {
+ return $this->driver->fetchMultiple($keys);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doSetMultiple($values, $ttl)
+ {
+ return $this->driver->saveMultiple($values, (int) $ttl);
+ }
+
+ /**
+ * @inheritdoc
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ public function doDeleteMultiple($keys)
+ {
+ return $this->driver->deleteMultiple($keys);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doHas($key)
+ {
+ return $this->driver->contains($key);
+ }
+}
diff --git a/system/src/Grav/Framework/Cache/Adapter/FileCache.php b/system/src/Grav/Framework/Cache/Adapter/FileCache.php
new file mode 100644
index 0000000..a5a60fa
--- /dev/null
+++ b/system/src/Grav/Framework/Cache/Adapter/FileCache.php
@@ -0,0 +1,233 @@
+initFileCache($namespace, $folder ?? '');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doGet($key, $miss)
+ {
+ $now = time();
+ $file = $this->getFile($key);
+
+ if (!file_exists($file) || !$h = @fopen($file, 'rb')) {
+ return $miss;
+ }
+
+ if ($now >= (int) $expiresAt = fgets($h)) {
+ fclose($h);
+ @unlink($file);
+ } else {
+ $i = rawurldecode(rtrim(fgets($h)));
+ $value = stream_get_contents($h);
+ fclose($h);
+
+ if ($i === $key) {
+ return unserialize($value);
+ }
+ }
+
+ return $miss;
+ }
+
+ /**
+ * @inheritdoc
+ * @throws \Psr\SimpleCache\CacheException|InvalidArgumentException
+ */
+ public function doSet($key, $value, $ttl)
+ {
+ $expiresAt = time() + (int)$ttl;
+
+ $result = $this->write(
+ $this->getFile($key, true),
+ $expiresAt . "\n" . rawurlencode($key) . "\n" . serialize($value),
+ $expiresAt
+ );
+
+ if (!$result && !is_writable($this->directory)) {
+ throw new CacheException(sprintf('Cache directory is not writable (%s)', $this->directory));
+ }
+
+ return $result;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doDelete($key)
+ {
+ $file = $this->getFile($key);
+
+ return (!file_exists($file) || @unlink($file) || !file_exists($file));
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doClear()
+ {
+ $result = true;
+ $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS));
+
+ foreach ($iterator as $file) {
+ $result = ($file->isDir() || @unlink($file) || !file_exists($file)) && $result;
+ }
+
+ return $result;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doHas($key)
+ {
+ $file = $this->getFile($key);
+
+ return file_exists($file) && (@filemtime($file) > time() || $this->doGet($key, null));
+ }
+
+ /**
+ * @param string $key
+ * @param bool $mkdir
+ * @return string
+ */
+ protected function getFile($key, $mkdir = false)
+ {
+ $hash = str_replace('/', '-', base64_encode(hash('sha256', static::class . $key, true)));
+ $dir = $this->directory . $hash[0] . DIRECTORY_SEPARATOR . $hash[1] . DIRECTORY_SEPARATOR;
+
+ if ($mkdir) {
+ $this->mkdir($dir);
+ }
+
+ return $dir . substr($hash, 2, 20);
+ }
+
+ /**
+ * @param string $namespace
+ * @param string $directory
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ protected function initFileCache($namespace, $directory)
+ {
+ if (!isset($directory[0])) {
+ $directory = sys_get_temp_dir() . '/grav-cache';
+ } else {
+ $directory = realpath($directory) ?: $directory;
+ }
+
+ if (isset($namespace[0])) {
+ if (preg_match('#[^-+_.A-Za-z0-9]#', $namespace, $match)) {
+ throw new InvalidArgumentException(sprintf('Namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0]));
+ }
+ $directory .= DIRECTORY_SEPARATOR . $namespace;
+ }
+
+ $this->mkdir($directory);
+
+ $directory .= DIRECTORY_SEPARATOR;
+ // On Windows the whole path is limited to 258 chars
+ if ('\\' === DIRECTORY_SEPARATOR && strlen($directory) > 234) {
+ throw new InvalidArgumentException(sprintf('Cache folder is too long (%s)', $directory));
+ }
+ $this->directory = $directory;
+ }
+
+ /**
+ * @param string $file
+ * @param string $data
+ * @param int|null $expiresAt
+ * @return bool
+ */
+ private function write($file, $data, $expiresAt = null)
+ {
+ set_error_handler(__CLASS__.'::throwError');
+
+ try {
+ if ($this->tmp === null) {
+ $this->tmp = $this->directory . uniqid('', true);
+ }
+
+ file_put_contents($this->tmp, $data);
+
+ if ($expiresAt !== null) {
+ touch($this->tmp, $expiresAt);
+ }
+
+ return rename($this->tmp, $file);
+ } finally {
+ restore_error_handler();
+ }
+ }
+
+ /**
+ * @param string $dir
+ * @throws \RuntimeException
+ */
+ private function mkdir($dir)
+ {
+ // Silence error for open_basedir; should fail in mkdir instead.
+ if (@is_dir($dir)) {
+ return;
+ }
+
+ $success = @mkdir($dir, 0777, true);
+
+ if (!$success) {
+ // Take yet another look, make sure that the folder doesn't exist.
+ clearstatcache(true, $dir);
+ if (!@is_dir($dir)) {
+ throw new \RuntimeException(sprintf('Unable to create directory: %s', $dir));
+ }
+ }
+ }
+
+ /**
+ * @internal
+ * @throws \ErrorException
+ */
+ public static function throwError($type, $message, $file, $line)
+ {
+ throw new \ErrorException($message, 0, $type, $file, $line);
+ }
+
+ public function __destruct()
+ {
+ if ($this->tmp !== null && file_exists($this->tmp)) {
+ unlink($this->tmp);
+ }
+ }
+}
diff --git a/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php b/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
new file mode 100644
index 0000000..2d0fe40
--- /dev/null
+++ b/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
@@ -0,0 +1,62 @@
+cache)) {
+ return $miss;
+ }
+
+ return $this->cache[$key];
+ }
+
+ public function doSet($key, $value, $ttl)
+ {
+ $this->cache[$key] = $value;
+
+ return true;
+ }
+
+ public function doDelete($key)
+ {
+ unset($this->cache[$key]);
+
+ return true;
+ }
+
+ public function doClear()
+ {
+ $this->cache = [];
+
+ return true;
+ }
+
+ public function doHas($key)
+ {
+ return array_key_exists($key, $this->cache);
+ }
+}
diff --git a/system/src/Grav/Framework/Cache/Adapter/SessionCache.php b/system/src/Grav/Framework/Cache/Adapter/SessionCache.php
new file mode 100644
index 0000000..62c68a0
--- /dev/null
+++ b/system/src/Grav/Framework/Cache/Adapter/SessionCache.php
@@ -0,0 +1,79 @@
+doGetStored($key);
+
+ return $stored ? $stored[self::VALUE] : $miss;
+ }
+
+ public function doSet($key, $value, $ttl)
+ {
+ $stored = [self::VALUE => $value];
+ if (null !== $ttl) {
+ $stored[self::LIFETIME] = time() + $ttl;
+
+ }
+
+ $_SESSION[$this->getNamespace()][$key] = $stored;
+
+ return true;
+ }
+
+ public function doDelete($key)
+ {
+ unset($_SESSION[$this->getNamespace()][$key]);
+
+ return true;
+ }
+
+ public function doClear()
+ {
+ unset($_SESSION[$this->getNamespace()]);
+
+ return true;
+ }
+
+ public function doHas($key)
+ {
+ return $this->doGetStored($key) !== null;
+ }
+
+ public function getNamespace()
+ {
+ return 'cache-' . parent::getNamespace();
+ }
+
+ protected function doGetStored($key)
+ {
+ $stored = $_SESSION[$this->getNamespace()][$key] ?? null;
+
+ if (isset($stored[self::LIFETIME]) && $stored[self::LIFETIME] < time()) {
+ unset($_SESSION[$this->getNamespace()][$key]);
+ $stored = null;
+ }
+
+ return $stored ?: null;
+ }
+}
diff --git a/system/src/Grav/Framework/Cache/CacheInterface.php b/system/src/Grav/Framework/Cache/CacheInterface.php
new file mode 100644
index 0000000..5aefe35
--- /dev/null
+++ b/system/src/Grav/Framework/Cache/CacheInterface.php
@@ -0,0 +1,28 @@
+namespace = (string) $namespace;
+ $this->defaultLifetime = $this->convertTtl($defaultLifetime);
+ $this->miss = new \stdClass;
+ }
+
+ /**
+ * @param bool $validation
+ */
+ public function setValidation($validation)
+ {
+ $this->validation = (bool) $validation;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getNamespace()
+ {
+ return $this->namespace;
+ }
+
+ /**
+ * @return int|null
+ */
+ protected function getDefaultLifetime()
+ {
+ return $this->defaultLifetime;
+ }
+
+ /**
+ * @inheritdoc
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ public function get($key, $default = null)
+ {
+ $this->validateKey($key);
+
+ $value = $this->doGet($key, $this->miss);
+
+ return $value !== $this->miss ? $value : $default;
+ }
+
+ /**
+ * @inheritdoc
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ public function set($key, $value, $ttl = null)
+ {
+ $this->validateKey($key);
+
+ $ttl = $this->convertTtl($ttl);
+
+ // If a negative or zero TTL is provided, the item MUST be deleted from the cache.
+ return null !== $ttl && $ttl <= 0 ? $this->doDelete($key) : $this->doSet($key, $value, $ttl);
+ }
+
+ /**
+ * @inheritdoc
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ public function delete($key)
+ {
+ $this->validateKey($key);
+
+ return $this->doDelete($key);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function clear()
+ {
+ return $this->doClear();
+ }
+
+ /**
+ * @inheritdoc
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ public function getMultiple($keys, $default = null)
+ {
+ if ($keys instanceof \Traversable) {
+ $keys = iterator_to_array($keys, false);
+ } elseif (!\is_array($keys)) {
+ throw new InvalidArgumentException(
+ sprintf(
+ 'Cache keys must be array or Traversable, "%s" given',
+ \is_object($keys) ? \get_class($keys) : \gettype($keys)
+ )
+ );
+ }
+
+ if (empty($keys)) {
+ return [];
+ }
+
+ $this->validateKeys($keys);
+ $keys = array_unique($keys);
+ $keys = array_combine($keys, $keys);
+
+ $list = $this->doGetMultiple($keys, $this->miss);
+
+ // Make sure that values are returned in the same order as the keys were given.
+ $values = [];
+ foreach ($keys as $key) {
+ if (!array_key_exists($key, $list) || $list[$key] === $this->miss) {
+ $values[$key] = $default;
+ } else {
+ $values[$key] = $list[$key];
+ }
+ }
+
+ return $values;
+ }
+
+ /**
+ * @inheritdoc
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ public function setMultiple($values, $ttl = null)
+ {
+ if ($values instanceof \Traversable) {
+ $values = iterator_to_array($values, true);
+ } elseif (!is_array($values)) {
+ throw new InvalidArgumentException(
+ sprintf(
+ 'Cache values must be array or Traversable, "%s" given',
+ \is_object($values) ? \get_class($values) : \gettype($values)
+ )
+ );
+ }
+
+ $keys = array_keys($values);
+
+ if (empty($keys)) {
+ return true;
+ }
+
+ $this->validateKeys($keys);
+
+ $ttl = $this->convertTtl($ttl);
+
+ // If a negative or zero TTL is provided, the item MUST be deleted from the cache.
+ return null !== $ttl && $ttl <= 0 ? $this->doDeleteMultiple($keys) : $this->doSetMultiple($values, $ttl);
+ }
+
+ /**
+ * @inheritdoc
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ public function deleteMultiple($keys)
+ {
+ if ($keys instanceof \Traversable) {
+ $keys = iterator_to_array($keys, false);
+ } elseif (!is_array($keys)) {
+ throw new InvalidArgumentException(
+ sprintf(
+ 'Cache keys must be array or Traversable, "%s" given',
+ \is_object($keys) ? \get_class($keys) : \gettype($keys)
+ )
+ );
+ }
+
+ if (empty($keys)) {
+ return true;
+ }
+
+ $this->validateKeys($keys);
+
+ return $this->doDeleteMultiple($keys);
+ }
+
+ /**
+ * @inheritdoc
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ public function has($key)
+ {
+ $this->validateKey($key);
+
+ return $this->doHas($key);
+ }
+
+ abstract public function doGet($key, $miss);
+ abstract public function doSet($key, $value, $ttl);
+ abstract public function doDelete($key);
+ abstract public function doClear();
+
+ /**
+ * @param array $keys
+ * @param mixed $miss
+ * @return array
+ */
+ public function doGetMultiple($keys, $miss)
+ {
+ $results = [];
+
+ foreach ($keys as $key) {
+ $value = $this->doGet($key, $miss);
+ if ($value !== $miss) {
+ $results[$key] = $value;
+ }
+ }
+
+ return $results;
+ }
+
+ /**
+ * @param array $values
+ * @param int $ttl
+ * @return bool
+ */
+ public function doSetMultiple($values, $ttl)
+ {
+ $success = true;
+
+ foreach ($values as $key => $value) {
+ $success = $this->doSet($key, $value, $ttl) && $success;
+ }
+
+ return $success;
+ }
+
+ /**
+ * @param array $keys
+ * @return bool
+ */
+ public function doDeleteMultiple($keys)
+ {
+ $success = true;
+
+ foreach ($keys as $key) {
+ $success = $this->doDelete($key) && $success;
+ }
+
+ return $success;
+ }
+
+ abstract public function doHas($key);
+
+ /**
+ * @param string|mixed $key
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ protected function validateKey($key)
+ {
+ if (!\is_string($key)) {
+ throw new InvalidArgumentException(
+ sprintf(
+ 'Cache key must be string, "%s" given',
+ \is_object($key) ? \get_class($key) : \gettype($key)
+ )
+ );
+ }
+ if (!isset($key[0])) {
+ throw new InvalidArgumentException('Cache key length must be greater than zero');
+ }
+ if (\strlen($key) > 64) {
+ throw new InvalidArgumentException(
+ sprintf('Cache key length must be less than 65 characters, key had %s characters', \strlen($key))
+ );
+ }
+ if (strpbrk($key, '{}()/\@:') !== false) {
+ throw new InvalidArgumentException(
+ sprintf('Cache key "%s" contains reserved characters {}()/\@:', $key)
+ );
+ }
+ }
+
+ /**
+ * @param array $keys
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ protected function validateKeys($keys)
+ {
+ if (!$this->validation) {
+ return;
+ }
+
+ foreach ($keys as $key) {
+ $this->validateKey($key);
+ }
+ }
+
+ /**
+ * @param null|int|\DateInterval|mixed $ttl
+ * @return int|null
+ * @throws \Psr\SimpleCache\InvalidArgumentException|InvalidArgumentException
+ */
+ protected function convertTtl($ttl)
+ {
+ if ($ttl === null) {
+ return $this->getDefaultLifetime();
+ }
+
+ if (\is_int($ttl)) {
+ return $ttl;
+ }
+
+ if ($ttl instanceof \DateInterval) {
+ $ttl = (int) \DateTime::createFromFormat('U', '0')->add($ttl)->format('U');
+ }
+
+ throw new InvalidArgumentException(
+ sprintf(
+ 'Expiration date must be an integer, a DateInterval or null, "%s" given',
+ \is_object($ttl) ? \get_class($ttl) : \gettype($ttl)
+ )
+ );
+ }
+}
diff --git a/system/src/Grav/Framework/Cache/Exception/CacheException.php b/system/src/Grav/Framework/Cache/Exception/CacheException.php
new file mode 100644
index 0000000..55da2f5
--- /dev/null
+++ b/system/src/Grav/Framework/Cache/Exception/CacheException.php
@@ -0,0 +1,20 @@
+path = $path;
+ $this->flags = self::INCLUDE_FILES | self::INCLUDE_FOLDERS;
+ $this->nestingLimit = 0;
+ $this->createObjectFunction = [$this, 'createObject'];
+
+ $this->setIterator();
+ }
+
+ /**
+ * @return string
+ */
+ public function getPath()
+ {
+ return $this->path;
+ }
+
+ /**
+ * @param Criteria $criteria
+ * @return ArrayCollection
+ * @todo Implement lazy matching
+ */
+ public function matching(Criteria $criteria)
+ {
+ $expr = $criteria->getWhereExpression();
+
+ $oldFilter = $this->filterFunction;
+ if ($expr) {
+ $visitor = new ClosureExpressionVisitor();
+ $filter = $visitor->dispatch($expr);
+ $this->addFilter($filter);
+ }
+
+ $filtered = $this->doInitializeByIterator($this->iterator, $this->nestingLimit);
+ $this->filterFunction = $oldFilter;
+
+ if ($orderings = $criteria->getOrderings()) {
+ $next = null;
+ foreach (array_reverse($orderings) as $field => $ordering) {
+ $next = ClosureExpressionVisitor::sortByField($field, $ordering === Criteria::DESC ? -1 : 1, $next);
+ }
+
+ uasort($filtered, $next);
+ } else {
+ ksort($filtered);
+ }
+
+ $offset = $criteria->getFirstResult();
+ $length = $criteria->getMaxResults();
+
+ if ($offset || $length) {
+ $filtered = \array_slice($filtered, (int)$offset, $length);
+ }
+
+ return new ArrayCollection($filtered);
+ }
+
+ protected function setIterator()
+ {
+ $iteratorFlags = \RecursiveDirectoryIterator::SKIP_DOTS + \FilesystemIterator::UNIX_PATHS
+ + \FilesystemIterator::CURRENT_AS_SELF + \FilesystemIterator::FOLLOW_SYMLINKS;
+
+ if (strpos($this->path, '://')) {
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ $this->iterator = $locator->getRecursiveIterator($this->path, $iteratorFlags);
+ } else {
+ $this->iterator = new \RecursiveDirectoryIterator($this->path, $iteratorFlags);
+ }
+ }
+
+ /**
+ * @param callable $filterFunction
+ * @return $this
+ */
+ protected function addFilter(callable $filterFunction)
+ {
+ if ($this->filterFunction) {
+ $oldFilterFunction = $this->filterFunction;
+ $this->filterFunction = function ($expr) use ($oldFilterFunction, $filterFunction) {
+ return $oldFilterFunction($expr) && $filterFunction($expr);
+ };
+ } else {
+ $this->filterFunction = $filterFunction;
+ }
+
+ return $this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function doInitialize()
+ {
+ $filtered = $this->doInitializeByIterator($this->iterator, $this->nestingLimit);
+ ksort($filtered);
+
+ $this->collection = new ArrayCollection($filtered);
+ }
+
+ protected function doInitializeByIterator(\SeekableIterator $iterator, $nestingLimit)
+ {
+ $children = [];
+ $objects = [];
+ $filter = $this->filterFunction;
+ $objectFunction = $this->createObjectFunction;
+
+ /** @var \RecursiveDirectoryIterator $file */
+ foreach ($iterator as $file) {
+ // Skip files if they shouldn't be included.
+ if (!($this->flags & static::INCLUDE_FILES) && $file->isFile()) {
+ continue;
+ }
+
+ // Apply main filter.
+ if ($filter && !$filter($file)) {
+ continue;
+ }
+
+ // Include children if the recursive flag is set.
+ if (($this->flags & static::RECURSIVE) && $nestingLimit > 0 && $file->hasChildren()) {
+ $children[] = $file->getChildren();
+ }
+
+ // Skip folders if they shouldn't be included.
+ if (!($this->flags & static::INCLUDE_FOLDERS) && $file->isDir()) {
+ continue;
+ }
+
+ $object = $objectFunction($file);
+ $objects[$object->key] = $object;
+ }
+
+ if ($children) {
+ $objects += $this->doInitializeChildren($children, $nestingLimit - 1);
+ }
+
+ return $objects;
+ }
+
+ /**
+ * @param \RecursiveDirectoryIterator[] $children
+ * @return array
+ */
+ protected function doInitializeChildren(array $children, $nestingLimit)
+ {
+ $objects = [];
+
+ foreach ($children as $iterator) {
+ $objects += $this->doInitializeByIterator($iterator, $nestingLimit);
+ }
+
+ return $objects;
+ }
+
+ /**
+ * @param \RecursiveDirectoryIterator $file
+ * @return object
+ */
+ protected function createObject($file)
+ {
+ return (object) [
+ 'key' => $file->getSubPathname(),
+ 'type' => $file->isDir() ? 'folder' : 'file:' . $file->getExtension(),
+ 'url' => method_exists($file, 'getUrl') ? $file->getUrl() : null,
+ 'pathname' => $file->getPathname(),
+ 'mtime' => $file->getMTime()
+ ];
+ }
+}
diff --git a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php
new file mode 100644
index 0000000..0e4fae2
--- /dev/null
+++ b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php
@@ -0,0 +1,510 @@
+entries = $entries;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function toArray()
+ {
+ return $this->loadElements($this->entries);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function first()
+ {
+ $value = reset($this->entries);
+ $key = key($this->entries);
+
+ return $this->loadElement($key, $value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function last()
+ {
+ $value = end($this->entries);
+ $key = key($this->entries);
+
+ return $this->loadElement($key, $value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function key()
+ {
+ return key($this->entries);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function next()
+ {
+ $value = next($this->entries);
+ $key = key($this->entries);
+
+ return $this->loadElement($key, $value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function current()
+ {
+ $value = current($this->entries);
+ $key = key($this->entries);
+
+ return $this->loadElement($key, $value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function remove($key)
+ {
+ if (!array_key_exists($key, $this->entries)) {
+ return null;
+ }
+
+ $value = $this->entries[$key];
+ unset($this->entries[$key]);
+
+ return $this->loadElement($key, $value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function removeElement($element)
+ {
+ $key = $this->isAllowedElement($element) ? $element->getKey() : null;
+
+ if (!$key || !isset($this->entries[$key])) {
+ return false;
+ }
+
+ unset($this->entries[$key]);
+
+ return true;
+ }
+
+ /**
+ * Required by interface ArrayAccess.
+ *
+ * {@inheritDoc}
+ */
+ public function offsetExists($offset)
+ {
+ return $this->containsKey($offset);
+ }
+
+ /**
+ * Required by interface ArrayAccess.
+ *
+ * {@inheritDoc}
+ */
+ public function offsetGet($offset)
+ {
+ return $this->get($offset);
+ }
+
+ /**
+ * Required by interface ArrayAccess.
+ *
+ * {@inheritDoc}
+ */
+ public function offsetSet($offset, $value)
+ {
+ if (null === $offset) {
+ $this->add($value);
+ }
+
+ $this->set($offset, $value);
+ }
+
+ /**
+ * Required by interface ArrayAccess.
+ *
+ * {@inheritDoc}
+ */
+ public function offsetUnset($offset)
+ {
+ return $this->remove($offset);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function containsKey($key)
+ {
+ return isset($this->entries[$key]) || array_key_exists($key, $this->entries);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function contains($element)
+ {
+ $key = $this->isAllowedElement($element) ? $element->getKey() : null;
+
+ return $key && isset($this->entries[$key]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function exists(Closure $p)
+ {
+ return $this->loadCollection($this->entries)->exists($p);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function indexOf($element)
+ {
+ $key = $this->isAllowedElement($element) ? $element->getKey() : null;
+
+ return $key && isset($this->entries[$key]) ? $key : null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function get($key)
+ {
+ if (!isset($this->entries[$key])) {
+ return null;
+ }
+
+ return $this->loadElement($key, $this->entries[$key]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getKeys()
+ {
+ return array_keys($this->entries);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getValues()
+ {
+ return array_values($this->loadElements($this->entries));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function count()
+ {
+ return \count($this->entries);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function set($key, $value)
+ {
+ if (!$this->isAllowedElement($value)) {
+ throw new \InvalidArgumentException('Invalid argument $value');
+ }
+
+ if ($key !== $value->getKey()) {
+ $value->setKey($key);
+ }
+
+ $this->entries[$key] = $this->getElementMeta($value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function add($element)
+ {
+ if (!$this->isAllowedElement($element)) {
+ throw new \InvalidArgumentException('Invalid argument $element');
+ }
+
+ $this->entries[$element->getKey()] = $this->getElementMeta($element);
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function isEmpty()
+ {
+ return empty($this->entries);
+ }
+
+ /**
+ * Required by interface IteratorAggregate.
+ *
+ * {@inheritDoc}
+ */
+ public function getIterator()
+ {
+ return new ArrayIterator($this->loadElements());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function map(Closure $func)
+ {
+ return $this->loadCollection($this->entries)->map($func);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function filter(Closure $p)
+ {
+ return $this->loadCollection($this->entries)->filter($p);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function forAll(Closure $p)
+ {
+ return $this->loadCollection($this->entries)->forAll($p);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function partition(Closure $p)
+ {
+ return $this->loadCollection($this->entries)->partition($p);
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return __CLASS__ . '@' . spl_object_hash($this);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function clear()
+ {
+ $this->entries = [];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function slice($offset, $length = null)
+ {
+ return $this->loadElements(\array_slice($this->entries, $offset, $length, true));
+ }
+
+ /**
+ * @param int $start
+ * @param int|null $limit
+ * @return static
+ */
+ public function limit($start, $limit = null)
+ {
+ return $this->createFrom(\array_slice($this->entries, $start, $limit, true));
+ }
+
+ /**
+ * Reverse the order of the items.
+ *
+ * @return static
+ */
+ public function reverse()
+ {
+ return $this->createFrom(array_reverse($this->entries));
+ }
+
+ /**
+ * Shuffle items.
+ *
+ * @return static
+ */
+ public function shuffle()
+ {
+ $keys = $this->getKeys();
+ shuffle($keys);
+
+ return $this->createFrom(array_replace(array_flip($keys), $this->entries));
+ }
+
+ /**
+ * Select items from collection.
+ *
+ * Collection is returned in the order of $keys given to the function.
+ *
+ * @param array $keys
+ * @return static
+ */
+ public function select(array $keys)
+ {
+ $list = [];
+ foreach ($keys as $key) {
+ if (isset($this->entries[$key])) {
+ $list[$key] = $this->entries[$key];
+ }
+ }
+
+ return $this->createFrom($list);
+ }
+
+ /**
+ * Un-select items from collection.
+ *
+ * @param array $keys
+ * @return static
+ */
+ public function unselect(array $keys)
+ {
+ return $this->select(array_diff($this->getKeys(), $keys));
+ }
+
+ /**
+ * Split collection into chunks.
+ *
+ * @param int $size Size of each chunk.
+ * @return array
+ */
+ public function chunk($size)
+ {
+ return $this->loadCollection($this->entries)->chunk($size);
+ }
+
+ /**
+ * @return string
+ */
+ public function serialize()
+ {
+ return serialize(['entries' => $this->entries]);
+ }
+
+ /**
+ * @param string $serialized
+ */
+ public function unserialize($serialized)
+ {
+ $data = unserialize($serialized, ['allowed_classes' => false]);
+
+ $this->entries = $data['entries'];
+ }
+
+ /**
+ * Implements JsonSerializable interface.
+ *
+ * @return array
+ */
+ public function jsonSerialize()
+ {
+ return $this->loadCollection()->jsonSerialize();
+ }
+
+ /**
+ * Creates a new instance from the specified elements.
+ *
+ * This method is provided for derived classes to specify how a new
+ * instance should be created when constructor semantics have changed.
+ *
+ * @param array $entries Elements.
+ *
+ * @return static
+ */
+ protected function createFrom(array $entries)
+ {
+ return new static($entries);
+ }
+
+ /**
+ * @return array
+ */
+ protected function getEntries() : array
+ {
+ return $this->entries;
+ }
+
+ /**
+ * @param array $entries
+ */
+ protected function setEntries(array $entries) : void
+ {
+ $this->entries = $entries;
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ * @return mixed|null
+ */
+ abstract protected function loadElement($key, $value);
+
+ /**
+ * @param array|null $entries
+ * @return array
+ */
+ abstract protected function loadElements(array $entries = null) : array;
+
+ /**
+ * @param array|null $entries
+ * @return CollectionInterface
+ */
+ abstract protected function loadCollection(array $entries = null) : CollectionInterface;
+
+ /**
+ * @param mixed $value
+ * @return bool
+ */
+ abstract protected function isAllowedElement($value) : bool;
+
+ /**
+ * @param mixed $element
+ * @return mixed
+ */
+ abstract protected function getElementMeta($element);
+}
diff --git a/system/src/Grav/Framework/Collection/AbstractLazyCollection.php b/system/src/Grav/Framework/Collection/AbstractLazyCollection.php
new file mode 100644
index 0000000..0653caa
--- /dev/null
+++ b/system/src/Grav/Framework/Collection/AbstractLazyCollection.php
@@ -0,0 +1,81 @@
+initialize();
+ return $this->collection->reverse();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function shuffle()
+ {
+ $this->initialize();
+ return $this->collection->shuffle();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function chunk($size)
+ {
+ $this->initialize();
+ return $this->collection->chunk($size);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function select(array $keys)
+ {
+ $this->initialize();
+ return $this->collection->select($keys);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function unselect(array $keys)
+ {
+ $this->initialize();
+ return $this->collection->unselect($keys);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function jsonSerialize()
+ {
+ $this->initialize();
+ return $this->collection->jsonSerialize();
+ }
+}
diff --git a/system/src/Grav/Framework/Collection/ArrayCollection.php b/system/src/Grav/Framework/Collection/ArrayCollection.php
new file mode 100644
index 0000000..f79ab96
--- /dev/null
+++ b/system/src/Grav/Framework/Collection/ArrayCollection.php
@@ -0,0 +1,95 @@
+createFrom(array_reverse($this->toArray()));
+ }
+
+ /**
+ * Shuffle items.
+ *
+ * @return static
+ */
+ public function shuffle()
+ {
+ $keys = $this->getKeys();
+ shuffle($keys);
+
+ return $this->createFrom(array_replace(array_flip($keys), $this->toArray()));
+ }
+
+ /**
+ * Split collection into chunks.
+ *
+ * @param int $size Size of each chunk.
+ * @return array
+ */
+ public function chunk($size)
+ {
+ return array_chunk($this->toArray(), $size, true);
+ }
+
+ /**
+ * Select items from collection.
+ *
+ * Collection is returned in the order of $keys given to the function.
+ *
+ * @param array $keys
+ * @return static
+ */
+ public function select(array $keys)
+ {
+ $list = [];
+ foreach ($keys as $key) {
+ if ($this->containsKey($key)) {
+ $list[$key] = $this->get($key);
+ }
+ }
+
+ return $this->createFrom($list);
+ }
+
+ /**
+ * Un-select items from collection.
+ *
+ * @param array $keys
+ * @return static
+ */
+ public function unselect(array $keys)
+ {
+ return $this->select(array_diff($this->getKeys(), $keys));
+ }
+
+ /**
+ * Implements JsonSerializable interface.
+ *
+ * @return array
+ */
+ public function jsonSerialize()
+ {
+ return $this->toArray();
+ }
+}
diff --git a/system/src/Grav/Framework/Collection/CollectionInterface.php b/system/src/Grav/Framework/Collection/CollectionInterface.php
new file mode 100644
index 0000000..9239d4a
--- /dev/null
+++ b/system/src/Grav/Framework/Collection/CollectionInterface.php
@@ -0,0 +1,60 @@
+flags = (int)($flags ?: self::INCLUDE_FILES | self::INCLUDE_FOLDERS | self::RECURSIVE);
+
+ $this->setIterator();
+ $this->setFilter();
+ $this->setObjectBuilder();
+ $this->setNestingLimit();
+ }
+
+ /**
+ * @return int
+ */
+ public function getFlags()
+ {
+ return $this->flags;
+ }
+
+ /**
+ * @return int
+ */
+ public function getNestingLimit()
+ {
+ return $this->nestingLimit;
+ }
+
+ /**
+ * @param int $limit
+ * @return $this
+ */
+ public function setNestingLimit($limit = 99)
+ {
+ $this->nestingLimit = (int) $limit;
+
+ return $this;
+ }
+
+ /**
+ * @param callable|null $filterFunction
+ * @return $this
+ */
+ public function setFilter(callable $filterFunction = null)
+ {
+ $this->filterFunction = $filterFunction;
+
+ return $this;
+ }
+
+ /**
+ * @param callable $filterFunction
+ * @return $this
+ */
+ public function addFilter(callable $filterFunction)
+ {
+ parent::addFilter($filterFunction);
+
+ return $this;
+ }
+
+ /**
+ * @param callable|null $objectFunction
+ * @return $this
+ */
+ public function setObjectBuilder(callable $objectFunction = null)
+ {
+ $this->createObjectFunction = $objectFunction ?: [$this, 'createObject'];
+
+ return $this;
+ }
+}
diff --git a/system/src/Grav/Framework/Collection/FileCollectionInterface.php b/system/src/Grav/Framework/Collection/FileCollectionInterface.php
new file mode 100644
index 0000000..fec4129
--- /dev/null
+++ b/system/src/Grav/Framework/Collection/FileCollectionInterface.php
@@ -0,0 +1,29 @@
+setContent('my inner content');
+ * $outerBlock = ContentBlock::create();
+ * $outerBlock->setContent(sprintf('Inside my outer block I have %s.', $innerBlock->getToken()));
+ * $outerBlock->addBlock($innerBlock);
+ * echo $outerBlock;
+ *
+ * @package Grav\Framework\ContentBlock
+ */
+class ContentBlock implements ContentBlockInterface
+{
+ protected $version = 1;
+ protected $id;
+ protected $tokenTemplate = '@@BLOCK-%s@@';
+ protected $content = '';
+ protected $blocks = [];
+ protected $checksum;
+ protected $cached = true;
+
+ /**
+ * @param string $id
+ * @return static
+ */
+ public static function create($id = null)
+ {
+ return new static($id);
+ }
+
+ /**
+ * @param array $serialized
+ * @return ContentBlockInterface
+ * @throws \InvalidArgumentException
+ */
+ public static function fromArray(array $serialized)
+ {
+ try {
+ $type = $serialized['_type'] ?? null;
+ $id = $serialized['id'] ?? null;
+
+ if (!$type || !$id || !is_a($type, ContentBlockInterface::class, true)) {
+ throw new \InvalidArgumentException('Bad data');
+ }
+
+ /** @var ContentBlockInterface $instance */
+ $instance = new $type($id);
+ $instance->build($serialized);
+ } catch (\Exception $e) {
+ throw new \InvalidArgumentException(sprintf('Cannot unserialize Block: %s', $e->getMessage()), $e->getCode(), $e);
+ }
+
+ return $instance;
+ }
+
+ /**
+ * Block constructor.
+ *
+ * @param string $id
+ */
+ public function __construct($id = null)
+ {
+ $this->id = $id ? (string) $id : $this->generateId();
+ }
+
+ /**
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getToken()
+ {
+ return sprintf($this->tokenTemplate, $this->getId());
+ }
+
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ $blocks = [];
+ /**
+ * @var string $id
+ * @var ContentBlockInterface $block
+ */
+ foreach ($this->blocks as $block) {
+ $blocks[$block->getId()] = $block->toArray();
+ }
+
+ $array = [
+ '_type' => \get_class($this),
+ '_version' => $this->version,
+ 'id' => $this->id,
+ 'cached' => $this->cached
+ ];
+
+ if ($this->checksum) {
+ $array['checksum'] = $this->checksum;
+ }
+
+ if ($this->content) {
+ $array['content'] = $this->content;
+ }
+
+ if ($blocks) {
+ $array['blocks'] = $blocks;
+ }
+
+ return $array;
+ }
+
+ /**
+ * @return string
+ */
+ public function toString()
+ {
+ if (!$this->blocks) {
+ return (string) $this->content;
+ }
+
+ $tokens = [];
+ $replacements = [];
+ foreach ($this->blocks as $block) {
+ $tokens[] = $block->getToken();
+ $replacements[] = $block->toString();
+ }
+
+ return str_replace($tokens, $replacements, (string) $this->content);
+ }
+
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ try {
+ return $this->toString();
+ } catch (\Exception $e) {
+ return sprintf('Error while rendering block: %s', $e->getMessage());
+ }
+ }
+
+ /**
+ * @param array $serialized
+ * @throws \RuntimeException
+ */
+ public function build(array $serialized)
+ {
+ $this->checkVersion($serialized);
+
+ $this->id = $serialized['id'] ?? $this->generateId();
+ $this->checksum = $serialized['checksum'] ?? null;
+ $this->cached = $serialized['cached'] ?? null;
+
+ if (isset($serialized['content'])) {
+ $this->setContent($serialized['content']);
+ }
+
+ $blocks = isset($serialized['blocks']) ? (array) $serialized['blocks'] : [];
+ foreach ($blocks as $block) {
+ $this->addBlock(self::fromArray($block));
+ }
+ }
+
+ /**
+ * @return bool
+ */
+ public function isCached()
+ {
+ if (!$this->cached) {
+ return false;
+ }
+
+ foreach ($this->blocks as $block) {
+ if (!$block->isCached()) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * @return $this
+ */
+ public function disableCache()
+ {
+ $this->cached = false;
+
+ return $this;
+ }
+
+ /**
+ * @param string $checksum
+ * @return $this
+ */
+ public function setChecksum($checksum)
+ {
+ $this->checksum = $checksum;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getChecksum()
+ {
+ return $this->checksum;
+ }
+
+ /**
+ * @param string $content
+ * @return $this
+ */
+ public function setContent($content)
+ {
+ $this->content = $content;
+
+ return $this;
+ }
+
+ /**
+ * @param ContentBlockInterface $block
+ * @return $this
+ */
+ public function addBlock(ContentBlockInterface $block)
+ {
+ $this->blocks[$block->getId()] = $block;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function serialize()
+ {
+ return serialize($this->toArray());
+ }
+
+ /**
+ * @param string $serialized
+ */
+ public function unserialize($serialized)
+ {
+ $array = unserialize($serialized);
+ $this->build($array);
+ }
+
+ /**
+ * @return string
+ */
+ protected function generateId()
+ {
+ return uniqid('', true);
+ }
+
+ /**
+ * @param array $serialized
+ * @throws \RuntimeException
+ */
+ protected function checkVersion(array $serialized)
+ {
+ $version = isset($serialized['_version']) ? (int) $serialized['_version'] : 1;
+ if ($version !== $this->version) {
+ throw new \RuntimeException(sprintf('Unsupported version %s', $version));
+ }
+ }
+}
diff --git a/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php b/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
new file mode 100644
index 0000000..330901e
--- /dev/null
+++ b/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
@@ -0,0 +1,87 @@
+getAssetsFast();
+
+ $this->sortAssets($assets['styles']);
+ $this->sortAssets($assets['scripts']);
+ $this->sortAssets($assets['html']);
+
+ return $assets;
+ }
+
+ /**
+ * @return array
+ */
+ public function getFrameworks()
+ {
+ $assets = $this->getAssetsFast();
+
+ return array_keys($assets['frameworks']);
+ }
+
+ /**
+ * @param string $location
+ * @return array
+ */
+ public function getStyles($location = 'head')
+ {
+ return $this->getAssetsInLocation('styles', $location);
+ }
+
+ /**
+ * @param string $location
+ * @return array
+ */
+ public function getScripts($location = 'head')
+ {
+ return $this->getAssetsInLocation('scripts', $location);
+ }
+
+ /**
+ * @param string $location
+ * @return array
+ */
+ public function getHtml($location = 'bottom')
+ {
+ return $this->getAssetsInLocation('html', $location);
+ }
+
+ /**
+ * @return array[]
+ */
+ public function toArray()
+ {
+ $array = parent::toArray();
+
+ if ($this->frameworks) {
+ $array['frameworks'] = $this->frameworks;
+ }
+ if ($this->styles) {
+ $array['styles'] = $this->styles;
+ }
+ if ($this->scripts) {
+ $array['scripts'] = $this->scripts;
+ }
+ if ($this->html) {
+ $array['html'] = $this->html;
+ }
+
+ return $array;
+ }
+
+ /**
+ * @param array $serialized
+ * @throws \RuntimeException
+ */
+ public function build(array $serialized)
+ {
+ parent::build($serialized);
+
+ $this->frameworks = isset($serialized['frameworks']) ? (array) $serialized['frameworks'] : [];
+ $this->styles = isset($serialized['styles']) ? (array) $serialized['styles'] : [];
+ $this->scripts = isset($serialized['scripts']) ? (array) $serialized['scripts'] : [];
+ $this->html = isset($serialized['html']) ? (array) $serialized['html'] : [];
+ }
+
+ /**
+ * @param string $framework
+ * @return $this
+ */
+ public function addFramework($framework)
+ {
+ $this->frameworks[$framework] = 1;
+
+ return $this;
+ }
+
+ /**
+ * @param string|array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ *
+ * @example $block->addStyle('assets/js/my.js');
+ * @example $block->addStyle(['href' => 'assets/js/my.js', 'media' => 'screen']);
+ */
+ public function addStyle($element, $priority = 0, $location = 'head')
+ {
+ if (!\is_array($element)) {
+ $element = ['href' => (string) $element];
+ }
+ if (empty($element['href'])) {
+ return false;
+ }
+ if (!isset($this->styles[$location])) {
+ $this->styles[$location] = [];
+ }
+
+ $id = !empty($element['id']) ? ['id' => (string) $element['id']] : [];
+ $href = $element['href'];
+ $type = !empty($element['type']) ? (string) $element['type'] : 'text/css';
+ $media = !empty($element['media']) ? (string) $element['media'] : null;
+ unset(
+ $element['tag'],
+ $element['id'],
+ $element['rel'],
+ $element['content'],
+ $element['href'],
+ $element['type'],
+ $element['media']
+ );
+
+ $this->styles[$location][md5($href) . sha1($href)] = [
+ ':type' => 'file',
+ ':priority' => (int) $priority,
+ 'href' => $href,
+ 'type' => $type,
+ 'media' => $media,
+ 'element' => $element
+ ] + $id;
+
+ return true;
+ }
+
+ /**
+ * @param string|array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addInlineStyle($element, $priority = 0, $location = 'head')
+ {
+ if (!\is_array($element)) {
+ $element = ['content' => (string) $element];
+ }
+ if (empty($element['content'])) {
+ return false;
+ }
+ if (!isset($this->styles[$location])) {
+ $this->styles[$location] = [];
+ }
+
+ $content = (string) $element['content'];
+ $type = !empty($element['type']) ? (string) $element['type'] : 'text/css';
+
+ $this->styles[$location][md5($content) . sha1($content)] = [
+ ':type' => 'inline',
+ ':priority' => (int) $priority,
+ 'content' => $content,
+ 'type' => $type
+ ];
+
+ return true;
+ }
+
+ /**
+ * @param string|array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addScript($element, $priority = 0, $location = 'head')
+ {
+ if (!\is_array($element)) {
+ $element = ['src' => (string) $element];
+ }
+ if (empty($element['src'])) {
+ return false;
+ }
+ if (!isset($this->scripts[$location])) {
+ $this->scripts[$location] = [];
+ }
+
+ $src = $element['src'];
+ $type = !empty($element['type']) ? (string) $element['type'] : 'text/javascript';
+ $defer = isset($element['defer']) ? true : false;
+ $async = isset($element['async']) ? true : false;
+ $handle = !empty($element['handle']) ? (string) $element['handle'] : '';
+
+ $this->scripts[$location][md5($src) . sha1($src)] = [
+ ':type' => 'file',
+ ':priority' => (int) $priority,
+ 'src' => $src,
+ 'type' => $type,
+ 'defer' => $defer,
+ 'async' => $async,
+ 'handle' => $handle
+ ];
+
+ return true;
+ }
+
+ /**
+ * @param string|array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addInlineScript($element, $priority = 0, $location = 'head')
+ {
+ if (!\is_array($element)) {
+ $element = ['content' => (string) $element];
+ }
+ if (empty($element['content'])) {
+ return false;
+ }
+ if (!isset($this->scripts[$location])) {
+ $this->scripts[$location] = [];
+ }
+
+ $content = (string) $element['content'];
+ $type = !empty($element['type']) ? (string) $element['type'] : 'text/javascript';
+
+ $this->scripts[$location][md5($content) . sha1($content)] = [
+ ':type' => 'inline',
+ ':priority' => (int) $priority,
+ 'content' => $content,
+ 'type' => $type
+ ];
+
+ return true;
+ }
+
+ /**
+ * @param string $html
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addHtml($html, $priority = 0, $location = 'bottom')
+ {
+ if (empty($html) || !\is_string($html)) {
+ return false;
+ }
+ if (!isset($this->html[$location])) {
+ $this->html[$location] = [];
+ }
+
+ $this->html[$location][md5($html) . sha1($html)] = [
+ ':priority' => (int) $priority,
+ 'html' => $html
+ ];
+
+ return true;
+ }
+
+ /**
+ * @return array
+ */
+ protected function getAssetsFast()
+ {
+ $assets = [
+ 'frameworks' => $this->frameworks,
+ 'styles' => $this->styles,
+ 'scripts' => $this->scripts,
+ 'html' => $this->html
+ ];
+
+ foreach ($this->blocks as $block) {
+ if ($block instanceof self) {
+ $blockAssets = $block->getAssetsFast();
+ $assets['frameworks'] += $blockAssets['frameworks'];
+
+ foreach ($blockAssets['styles'] as $location => $styles) {
+ if (!isset($assets['styles'][$location])) {
+ $assets['styles'][$location] = $styles;
+ } elseif ($styles) {
+ $assets['styles'][$location] += $styles;
+ }
+ }
+
+ foreach ($blockAssets['scripts'] as $location => $scripts) {
+ if (!isset($assets['scripts'][$location])) {
+ $assets['scripts'][$location] = $scripts;
+ } elseif ($scripts) {
+ $assets['scripts'][$location] += $scripts;
+ }
+ }
+
+ foreach ($blockAssets['html'] as $location => $htmls) {
+ if (!isset($assets['html'][$location])) {
+ $assets['html'][$location] = $htmls;
+ } elseif ($htmls) {
+ $assets['html'][$location] += $htmls;
+ }
+ }
+ }
+ }
+
+ return $assets;
+ }
+
+ /**
+ * @param string $type
+ * @param string $location
+ * @return array
+ */
+ protected function getAssetsInLocation($type, $location)
+ {
+ $assets = $this->getAssetsFast();
+
+ if (empty($assets[$type][$location])) {
+ return [];
+ }
+
+ $styles = $assets[$type][$location];
+ $this->sortAssetsInLocation($styles);
+
+ return $styles;
+ }
+
+ /**
+ * @param array $items
+ */
+ protected function sortAssetsInLocation(array &$items)
+ {
+ $count = 0;
+ foreach ($items as &$item) {
+ $item[':order'] = ++$count;
+ }
+ unset($item);
+
+ uasort(
+ $items,
+ function ($a, $b) {
+ return ($a[':priority'] === $b[':priority'])
+ ? $a[':order'] - $b[':order'] : $a[':priority'] - $b[':priority'];
+ }
+ );
+ }
+
+ /**
+ * @param array $array
+ */
+ protected function sortAssets(array &$array)
+ {
+ foreach ($array as $location => &$items) {
+ $this->sortAssetsInLocation($items);
+ }
+ }
+}
diff --git a/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php b/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php
new file mode 100644
index 0000000..ee486d2
--- /dev/null
+++ b/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php
@@ -0,0 +1,95 @@
+addStyle('assets/js/my.js');
+ * @example $block->addStyle(['href' => 'assets/js/my.js', 'media' => 'screen']);
+ */
+ public function addStyle($element, $priority = 0, $location = 'head');
+
+ /**
+ * @param string|array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addInlineStyle($element, $priority = 0, $location = 'head');
+
+ /**
+ * @param string|array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addScript($element, $priority = 0, $location = 'head');
+
+
+ /**
+ * @param string|array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addInlineScript($element, $priority = 0, $location = 'head');
+
+ /**
+ * @param string $html
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addHtml($html, $priority = 0, $location = 'bottom');
+}
diff --git a/system/src/Grav/Framework/DI/Container.php b/system/src/Grav/Framework/DI/Container.php
new file mode 100644
index 0000000..c4b3ef4
--- /dev/null
+++ b/system/src/Grav/Framework/DI/Container.php
@@ -0,0 +1,27 @@
+offsetGet($id);
+ }
+
+ public function has($id): bool
+ {
+ return $this->offsetExists($id);
+ }
+}
\ No newline at end of file
diff --git a/system/src/Grav/Framework/File/AbstractFile.php b/system/src/Grav/Framework/File/AbstractFile.php
new file mode 100644
index 0000000..0411701
--- /dev/null
+++ b/system/src/Grav/Framework/File/AbstractFile.php
@@ -0,0 +1,425 @@
+filesystem = $filesystem ?? Filesystem::getInstance();
+ $this->setFilepath($filepath);
+ }
+
+ /**
+ * Unlock file when the object gets destroyed.
+ */
+ public function __destruct()
+ {
+ if ($this->isLocked()) {
+ $this->unlock();
+ }
+ }
+
+ public function __clone()
+ {
+ $this->handle = null;
+ $this->locked = false;
+ }
+
+ /**
+ * @return string
+ */
+ public function serialize(): string
+ {
+ return serialize($this->doSerialize());
+ }
+
+ /**
+ * @param string $serialized
+ */
+ public function unserialize($serialized): void
+ {
+ $this->doUnserialize(unserialize($serialized, ['allowed_classes' => false]));
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::getFilePath()
+ */
+ public function getFilePath(): string
+ {
+ return $this->filepath;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::getPath()
+ */
+ public function getPath(): string
+ {
+ if (null === $this->path) {
+ $this->setPathInfo();
+ }
+
+ return $this->path;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::getFilename()
+ */
+ public function getFilename(): string
+ {
+ if (null === $this->filename) {
+ $this->setPathInfo();
+ }
+
+ return $this->filename;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::getBasename()
+ */
+ public function getBasename(): string
+ {
+ if (null === $this->basename) {
+ $this->setPathInfo();
+ }
+
+ return $this->basename;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::getExtension()
+ */
+ public function getExtension(bool $withDot = false): string
+ {
+ if (null === $this->extension) {
+ $this->setPathInfo();
+ }
+
+ return ($withDot ? '.' : '') . $this->extension;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::exists()
+ */
+ public function exists(): bool
+ {
+ return is_file($this->filepath);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::getCreationTime()
+ */
+ public function getCreationTime(): int
+ {
+ return is_file($this->filepath) ? filectime($this->filepath) : time();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::getModificationTime()
+ */
+ public function getModificationTime(): int
+ {
+ return is_file($this->filepath) ? filemtime($this->filepath) : time();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::lock()
+ */
+ public function lock(bool $block = true): bool
+ {
+ if (!$this->handle) {
+ if (!$this->mkdir($this->getPath())) {
+ throw new \RuntimeException('Creating directory failed for ' . $this->filepath);
+ }
+ $this->handle = @fopen($this->filepath, 'cb+');
+ if (!$this->handle) {
+ $error = error_get_last();
+
+ throw new \RuntimeException("Opening file for writing failed on error {$error['message']}");
+ }
+ }
+
+ $lock = $block ? LOCK_EX : LOCK_EX | LOCK_NB;
+
+ // Some filesystems do not support file locks, only fail if another process holds the lock.
+ $this->locked = flock($this->handle, $lock, $wouldblock) || !$wouldblock;
+
+ return $this->locked;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::unlock()
+ */
+ public function unlock(): bool
+ {
+ if (!$this->handle) {
+ return false;
+ }
+
+ if ($this->locked) {
+ flock($this->handle, LOCK_UN);
+ $this->locked = false;
+ }
+
+ fclose($this->handle);
+ $this->handle = null;
+
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::isLocked()
+ */
+ public function isLocked(): bool
+ {
+ return $this->locked;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::isReadable()
+ */
+ public function isReadable(): bool
+ {
+ return is_readable($this->filepath) && is_file($this->filepath);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::isWritable()
+ */
+ public function isWritable(): bool
+ {
+ if (!file_exists($this->filepath)) {
+ return $this->isWritablePath($this->getPath());
+ }
+
+ return is_writable($this->filepath) && is_file($this->filepath);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::load()
+ */
+ public function load()
+ {
+ return file_get_contents($this->filepath);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::save()
+ */
+ public function save($data): void
+ {
+ $filepath = $this->filepath;
+ $dir = $this->getPath();
+
+ if (!$this->mkdir($dir)) {
+ throw new \RuntimeException('Creating directory failed for ' . $filepath);
+ }
+
+ try {
+ if ($this->handle) {
+ $tmp = true;
+ // As we are using non-truncating locking, make sure that the file is empty before writing.
+ if (@ftruncate($this->handle, 0) === false || @fwrite($this->handle, $data) === false) {
+ // Writing file failed, throw an error.
+ $tmp = false;
+ }
+ } else {
+ // Create file with a temporary name and rename it to make the save action atomic.
+ $tmp = $this->tempname($filepath);
+ if (@file_put_contents($tmp, $data) === false) {
+ $tmp = false;
+ } elseif (@rename($tmp, $filepath) === false) {
+ @unlink($tmp);
+ $tmp = false;
+ }
+ }
+ } catch (\Exception $e) {
+ $tmp = false;
+ }
+
+ if ($tmp === false) {
+ throw new \RuntimeException('Failed to save file ' . $filepath);
+ }
+
+ // Touch the directory as well, thus marking it modified.
+ @touch($dir);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::rename()
+ */
+ public function rename(string $path): bool
+ {
+ if ($this->exists() && !@rename($this->filepath, $path)) {
+ return false;
+ }
+
+ $this->setFilepath($path);
+
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::delete()
+ */
+ public function delete(): bool
+ {
+ return @unlink($this->filepath);
+ }
+
+ /**
+ * @param string $dir
+ * @return bool
+ * @throws \RuntimeException
+ * @internal
+ */
+ protected function mkdir(string $dir): bool
+ {
+ // Silence error for open_basedir; should fail in mkdir instead.
+ if (@is_dir($dir)) {
+ return true;
+ }
+
+ $success = @mkdir($dir, 0777, true);
+
+ if (!$success) {
+ // Take yet another look, make sure that the folder doesn't exist.
+ clearstatcache(true, $dir);
+ if (!@is_dir($dir)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * @return array
+ */
+ protected function doSerialize(): array
+ {
+ return [
+ 'filepath' => $this->filepath
+ ];
+ }
+
+ /**
+ * @param array $serialized
+ */
+ protected function doUnserialize(array $serialized): void
+ {
+ $this->setFilepath($serialized['filepath']);
+ }
+
+ /**
+ * @param string $filepath
+ */
+ protected function setFilepath(string $filepath): void
+ {
+ $this->filepath = $filepath;
+ $this->filename = null;
+ $this->basename = null;
+ $this->path = null;
+ $this->extension = null;
+ }
+
+ protected function setPathInfo(): void
+ {
+ $pathInfo = $this->filesystem->pathinfo($this->filepath);
+
+ $this->filename = $pathInfo['filename'] ?? null;
+ $this->basename = $pathInfo['basename'] ?? null;
+ $this->path = $pathInfo['dirname'] ?? null;
+ $this->extension = $pathInfo['extension'] ?? null;
+ }
+
+ /**
+ * @param string $dir
+ * @return bool
+ * @internal
+ */
+ protected function isWritablePath(string $dir): bool
+ {
+ if ($dir === '') {
+ return false;
+ }
+
+ if (!file_exists($dir)) {
+ // Recursively look up in the directory tree.
+ return $this->isWritablePath($this->filesystem->parent($dir));
+ }
+
+ return is_dir($dir) && is_writable($dir);
+ }
+
+ /**
+ * @param string $filename
+ * @param int $length
+ * @return string
+ */
+ protected function tempname(string $filename, int $length = 5)
+ {
+ do {
+ $test = $filename . substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, $length);
+ } while (file_exists($test));
+
+ return $test;
+ }
+}
diff --git a/system/src/Grav/Framework/File/CsvFile.php b/system/src/Grav/Framework/File/CsvFile.php
new file mode 100644
index 0000000..53af766
--- /dev/null
+++ b/system/src/Grav/Framework/File/CsvFile.php
@@ -0,0 +1,31 @@
+formatter = $formatter;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::load()
+ */
+ public function load()
+ {
+ $raw = parent::load();
+
+ try {
+ return $raw !== false ? $this->formatter->decode($raw) : false;
+ } catch (RuntimeException $e) {
+ throw new RuntimeException(sprintf("Failed to load file '%s': %s", $this->getFilePath(), $e->getMessage()), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileInterface::save()
+ */
+ public function save($data): void
+ {
+ if (\is_string($data)) {
+ // Make sure that the string is valid data.
+ try {
+ $this->formatter->decode($data);
+ } catch (RuntimeException $e) {
+ throw new RuntimeException(sprintf("Failed to save file '%s': %s", $this->getFilePath(), $e->getMessage()), $e->getCode(), $e);
+ }
+ $encoded = $data;
+ } else {
+ $encoded = $this->formatter->encode($data);
+ }
+
+ parent::save($encoded);
+ }
+}
diff --git a/system/src/Grav/Framework/File/File.php b/system/src/Grav/Framework/File/File.php
new file mode 100644
index 0000000..c1a2173
--- /dev/null
+++ b/system/src/Grav/Framework/File/File.php
@@ -0,0 +1,37 @@
+config = $config;
+ }
+
+ /**
+ * @return string
+ */
+ public function serialize(): string
+ {
+ return serialize($this->doSerialize());
+ }
+
+ /**
+ * @param string $serialized
+ */
+ public function unserialize($serialized): void
+ {
+ $this->doUnserialize(unserialize($serialized, ['allowed_classes' => false]));
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::getDefaultFileExtension()
+ */
+ public function getDefaultFileExtension(): string
+ {
+ $extensions = $this->getSupportedFileExtensions();
+
+ // Call fails on bad configuration.
+ return reset($extensions);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::getSupportedFileExtensions()
+ */
+ public function getSupportedFileExtensions(): array
+ {
+ $extensions = $this->getConfig('file_extension');
+
+ // Call fails on bad configuration.
+ return \is_string($extensions) ? [$extensions] : $extensions;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::encode()
+ */
+ abstract public function encode($data): string;
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::decode()
+ */
+ abstract public function decode($data);
+
+ /**
+ * Get either full configuration or a single option.
+ *
+ * @param string|null $name Configuration option (optional)
+ * @return mixed
+ */
+ protected function getConfig(string $name = null)
+ {
+ if (null !== $name) {
+ return $this->config[$name] ?? null;
+ }
+
+ return $this->config;
+ }
+
+ /**
+ * @return array
+ */
+ protected function doSerialize(): array
+ {
+ return ['config' => $this->config];
+ }
+
+ /**
+ * Note: if overridden, make sure you call parent::doUnserialize()
+ *
+ * @param array $serialized
+ */
+ protected function doUnserialize(array $serialized): void
+ {
+ $this->config = $serialized['config'];
+ }
+}
diff --git a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php
new file mode 100644
index 0000000..e412a73
--- /dev/null
+++ b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php
@@ -0,0 +1,127 @@
+ ['.csv', '.tsv'],
+ 'delimiter' => ','
+ ];
+
+ parent::__construct($config);
+ }
+
+ /**
+ * Returns delimiter used to both encode and decode CSV.
+ *
+ * @return string
+ */
+ public function getDelimiter(): string
+ {
+ // Call fails on bad configuration.
+ return $this->getConfig('delimiter');
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::encode()
+ */
+ public function encode($data, $delimiter = null): string
+ {
+ if (count($data) === 0) {
+ return '';
+ }
+ $delimiter = $delimiter ?? $this->getDelimiter();
+ $header = array_keys(reset($data));
+
+ // Encode the field names
+ $string = $this->encodeLine($header, $delimiter);
+
+ // Encode the data
+ foreach ($data as $row) {
+ $string .= $this->encodeLine($row, $delimiter);
+ }
+
+ return $string;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::decode()
+ */
+ public function decode($data, $delimiter = null): array
+ {
+ $delimiter = $delimiter ?? $this->getDelimiter();
+ $lines = preg_split('/\r\n|\r|\n/', $data);
+
+ if ($lines === false) {
+ throw new \RuntimeException('Decoding CSV failed');
+ }
+
+ // Get the field names
+ $header = str_getcsv(array_shift($lines), $delimiter);
+
+ // Allow for replacing a null string with null/empty value
+ $null_replace = $this->getConfig('null');
+
+ // Get the data
+ $list = [];
+ $line = null;
+ try {
+ foreach ($lines as $line) {
+ if (!empty($line)) {
+ $csv_line = str_getcsv($line, $delimiter);
+
+ if ($null_replace) {
+ array_walk($csv_line, function(&$el) use ($null_replace) {
+ $el = str_replace($null_replace, "\0", $el);
+ });
+ }
+
+ $list[] = array_combine($header, $csv_line);
+ }
+ }
+ } catch (\Exception $e) {
+ throw new \Exception('Badly formatted CSV line: ' . $line);
+ }
+
+ return $list;
+ }
+
+ protected function encodeLine(array $line, $delimiter = null): string
+ {
+ foreach ($line as $key => &$value) {
+ $value = $this->escape((string)$value);
+ }
+ unset($value);
+
+ return implode($delimiter, $line). "\n";
+ }
+
+ protected function escape(string $value)
+ {
+ if (preg_match('/[,"\r\n]/u', $value)) {
+ $value = '"' . preg_replace('/"/', '""', $value) . '"';
+ }
+
+ return $value;
+ }
+}
diff --git a/system/src/Grav/Framework/File/Formatter/FormatterInterface.php b/system/src/Grav/Framework/File/Formatter/FormatterInterface.php
new file mode 100644
index 0000000..a8d5bc5
--- /dev/null
+++ b/system/src/Grav/Framework/File/Formatter/FormatterInterface.php
@@ -0,0 +1,10 @@
+ '.ini'
+ ];
+
+ parent::__construct($config);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::encode()
+ */
+ public function encode($data): string
+ {
+ $string = '';
+ foreach ($data as $key => $value) {
+ $string .= $key . '="' . preg_replace(
+ ['/"/', '/\\\/', "/\t/", "/\n/", "/\r/"],
+ ['\"', '\\\\', '\t', '\n', '\r'],
+ $value
+ ) . "\"\n";
+ }
+
+ return $string;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::decode()
+ */
+ public function decode($data): array
+ {
+ $decoded = @parse_ini_string($data);
+
+ if ($decoded === false) {
+ throw new \RuntimeException('Decoding INI failed');
+ }
+
+ return $decoded;
+ }
+}
diff --git a/system/src/Grav/Framework/File/Formatter/JsonFormatter.php b/system/src/Grav/Framework/File/Formatter/JsonFormatter.php
new file mode 100644
index 0000000..1ae16ae
--- /dev/null
+++ b/system/src/Grav/Framework/File/Formatter/JsonFormatter.php
@@ -0,0 +1,100 @@
+ '.json',
+ 'encode_options' => 0,
+ 'decode_assoc' => true,
+ 'decode_depth' => 512,
+ 'decode_options' => 0
+ ];
+
+ parent::__construct($config);
+ }
+
+ /**
+ * Returns options used in encode() function.
+ *
+ * @return int
+ */
+ public function getEncodeOptions(): int
+ {
+ return $this->getConfig('encode_options');
+ }
+
+ /**
+ * Returns options used in decode() function.
+ *
+ * @return int
+ */
+ public function getDecodeOptions(): int
+ {
+ return $this->getConfig('decode_options');
+ }
+
+ /**
+ * Returns recursion depth used in decode() function.
+ *
+ * @return int
+ */
+ public function getDecodeDepth(): int
+ {
+ return $this->getConfig('decode_depth');
+ }
+
+ /**
+ * Returns true if JSON objects will be converted into associative arrays.
+ *
+ * @return bool
+ */
+ public function getDecodeAssoc(): bool
+ {
+ return $this->getConfig('decode_assoc');
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::encode()
+ */
+ public function encode($data): string
+ {
+ $encoded = @json_encode($data, $this->getEncodeOptions());
+
+ if ($encoded === false && json_last_error() !== JSON_ERROR_NONE) {
+ throw new \RuntimeException('Encoding JSON failed: ' . json_last_error_msg());
+ }
+
+ return $encoded;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::decode()
+ */
+ public function decode($data)
+ {
+ $decoded = @json_decode($data, $this->getDecodeAssoc(), $this->getDecodeDepth(), $this->getDecodeOptions());
+
+ if (null === $decoded && json_last_error() !== JSON_ERROR_NONE) {
+ throw new \RuntimeException('Decoding JSON failed: ' . json_last_error_msg());
+ }
+
+ return $decoded;
+ }
+}
diff --git a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php
new file mode 100644
index 0000000..a2f84e8
--- /dev/null
+++ b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php
@@ -0,0 +1,138 @@
+ '.md',
+ 'header' => 'header',
+ 'body' => 'markdown',
+ 'raw' => 'frontmatter',
+ 'yaml' => ['inline' => 20]
+ ];
+
+ parent::__construct($config);
+
+ $this->headerFormatter = $headerFormatter ?: new YamlFormatter($config['yaml']);
+ }
+
+ /**
+ * Returns header field used in both encode() and decode().
+ *
+ * @return string
+ */
+ public function getHeaderField(): string
+ {
+ return $this->getConfig('header');
+ }
+
+ /**
+ * Returns body field used in both encode() and decode().
+ *
+ * @return string
+ */
+ public function getBodyField(): string
+ {
+ return $this->getConfig('body');
+ }
+
+ /**
+ * Returns raw field used in both encode() and decode().
+ *
+ * @return string
+ */
+ public function getRawField(): string
+ {
+ return $this->getConfig('raw');
+ }
+
+ /**
+ * Returns header formatter object used in both encode() and decode().
+ *
+ * @return FileFormatterInterface
+ */
+ public function getHeaderFormatter(): FileFormatterInterface
+ {
+ return $this->headerFormatter;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::encode()
+ */
+ public function encode($data): string
+ {
+ $headerVar = $this->getHeaderField();
+ $bodyVar = $this->getBodyField();
+
+ $header = isset($data[$headerVar]) ? (array) $data[$headerVar] : [];
+ $body = isset($data[$bodyVar]) ? (string) $data[$bodyVar] : '';
+
+ // Create Markdown file with YAML header.
+ $encoded = '';
+ if ($header) {
+ $encoded = "---\n" . trim($this->getHeaderFormatter()->encode($data['header'])) . "\n---\n\n";
+ }
+ $encoded .= $body;
+
+ // Normalize line endings to Unix style.
+ $encoded = preg_replace("/(\r\n|\r)/", "\n", $encoded);
+
+ return $encoded;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::decode()
+ */
+ public function decode($data): array
+ {
+ $headerVar = $this->getHeaderField();
+ $bodyVar = $this->getBodyField();
+ $rawVar = $this->getRawField();
+
+ // Define empty content
+ $content = [
+ $headerVar => [],
+ $bodyVar => ''
+ ];
+
+ $headerRegex = "/^---\n(.+?)\n---\n{0,}(.*)$/uis";
+
+ // Normalize line endings to Unix style.
+ $data = preg_replace("/(\r\n|\r)/", "\n", $data);
+
+ // Parse header.
+ preg_match($headerRegex, ltrim($data), $matches);
+ if(empty($matches)) {
+ $content[$bodyVar] = $data;
+ } else {
+ // Normalize frontmatter.
+ $frontmatter = preg_replace("/\n\t/", "\n ", $matches[1]);
+ if ($rawVar) {
+ $content[$rawVar] = $frontmatter;
+ }
+ $content[$headerVar] = $this->getHeaderFormatter()->decode($frontmatter);
+ $content[$bodyVar] = $matches[2];
+ }
+
+ return $content;
+ }
+}
diff --git a/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php b/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
new file mode 100644
index 0000000..73ed812
--- /dev/null
+++ b/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
@@ -0,0 +1,89 @@
+ '.ser',
+ 'decode_options' => ['allowed_classes' => [\stdClass::class]]
+ ];
+
+ parent::__construct($config);
+ }
+
+ /**
+ * Returns options used in decode().
+ *
+ * By default only allow stdClass class.
+ *
+ * @return array|bool
+ */
+ public function getOptions()
+ {
+ return $this->getConfig('decode_options');
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::encode()
+ */
+ public function encode($data): string
+ {
+ return serialize($this->preserveLines($data, ["\n", "\r"], ['\\n', '\\r']));
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::decode()
+ */
+ public function decode($data)
+ {
+ $decoded = @unserialize($data, $this->getOptions());
+
+ if ($decoded === false && $data !== serialize(false)) {
+ throw new \RuntimeException('Decoding serialized data failed');
+ }
+
+ return $this->preserveLines($decoded, ['\\n', '\\r'], ["\n", "\r"]);
+ }
+
+ /**
+ * Preserve new lines, recursive function.
+ *
+ * @param mixed $data
+ * @param array $search
+ * @param array $replace
+ * @return mixed
+ */
+ protected function preserveLines($data, array $search, array $replace)
+ {
+ if (\is_string($data)) {
+ $data = str_replace($search, $replace, $data);
+ } elseif (\is_array($data)) {
+ foreach ($data as &$value) {
+ $value = $this->preserveLines($value, $search, $replace);
+ }
+ unset($value);
+ }
+
+ return $data;
+ }
+}
\ No newline at end of file
diff --git a/system/src/Grav/Framework/File/Formatter/YamlFormatter.php b/system/src/Grav/Framework/File/Formatter/YamlFormatter.php
new file mode 100644
index 0000000..189626d
--- /dev/null
+++ b/system/src/Grav/Framework/File/Formatter/YamlFormatter.php
@@ -0,0 +1,114 @@
+ '.yaml',
+ 'inline' => 5,
+ 'indent' => 2,
+ 'native' => true,
+ 'compat' => true
+ ];
+
+ parent::__construct($config);
+ }
+
+ /**
+ * @return int
+ */
+ public function getInlineOption(): int
+ {
+ return $this->getConfig('inline');
+ }
+
+ /**
+ * @return int
+ */
+ public function getIndentOption(): int
+ {
+ return $this->getConfig('indent');
+ }
+
+ /**
+ * @return bool
+ */
+ public function useNativeDecoder(): bool
+ {
+ return $this->getConfig('native');
+ }
+
+ /**
+ * @return bool
+ */
+ public function useCompatibleDecoder(): bool
+ {
+ return $this->getConfig('compat');
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::encode()
+ */
+ public function encode($data, $inline = null, $indent = null): string
+ {
+ try {
+ return YamlParser::dump(
+ $data,
+ $inline ? (int) $inline : $this->getInlineOption(),
+ $indent ? (int) $indent : $this->getIndentOption(),
+ YamlParser::DUMP_EXCEPTION_ON_INVALID_TYPE
+ );
+ } catch (DumpException $e) {
+ throw new \RuntimeException('Encoding YAML failed: ' . $e->getMessage(), 0, $e);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FileFormatterInterface::decode()
+ */
+ public function decode($data): array
+ {
+ // Try native PECL YAML PHP extension first if available.
+ if (\function_exists('yaml_parse') && $this->useNativeDecoder()) {
+ // Safely decode YAML.
+ $saved = @ini_get('yaml.decode_php');
+ @ini_set('yaml.decode_php', '0');
+ $decoded = @yaml_parse($data);
+ @ini_set('yaml.decode_php', $saved);
+
+ if ($decoded !== false) {
+ return (array) $decoded;
+ }
+ }
+
+ try {
+ return (array) YamlParser::parse($data);
+ } catch (ParseException $e) {
+ if ($this->useCompatibleDecoder()) {
+ return (array) FallbackYamlParser::parse($data);
+ }
+
+ throw new \RuntimeException('Decoding YAML failed: ' . $e->getMessage(), 0, $e);
+ }
+ }
+}
diff --git a/system/src/Grav/Framework/File/IniFile.php b/system/src/Grav/Framework/File/IniFile.php
new file mode 100644
index 0000000..cc861f9
--- /dev/null
+++ b/system/src/Grav/Framework/File/IniFile.php
@@ -0,0 +1,31 @@
+setNormalization()
+ *
+ * @return Filesystem
+ */
+ public static function getInstance(bool $normalize = null): Filesystem
+ {
+ if ($normalize === true) {
+ $instance = &static::$safe;
+ } elseif ($normalize === false) {
+ $instance = &static::$unsafe;
+ } else {
+ $instance = &static::$default;
+ }
+
+ if (null === $instance) {
+ $instance = new static($normalize);
+ }
+
+ return $instance;
+ }
+
+ /**
+ * Always use Filesystem::getInstance() instead.
+ *
+ * @param bool|null $normalize
+ */
+ protected function __construct(bool $normalize = null)
+ {
+ $this->normalize = $normalize;
+ }
+
+ /**
+ * Set path normalization.
+ *
+ * Default option enables normalization for the streams only, but you can force the normalization to be either
+ * on or off for every path. Disabling path normalization speeds up the calls, but may cause issues if paths were
+ * not normalized.
+ *
+ * @param bool|null $normalize
+ *
+ * @return Filesystem
+ */
+ public function setNormalization(bool $normalize = null): self
+ {
+ return static::getInstance($normalize);
+ }
+
+ /**
+ * Force all paths to be normalized.
+ *
+ * @return static
+ */
+ public function unsafe(): self
+ {
+ return static::getInstance(true);
+ }
+
+ /**
+ * Force all paths not to be normalized (speeds up the calls if given paths are known to be normalized).
+ *
+ * @return static
+ */
+ public function safe(): self
+ {
+ return static::getInstance(false);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FilesystemInterface::parent()
+ */
+ public function parent(string $path, int $levels = 1): string
+ {
+ [$scheme, $path] = $this->getSchemeAndHierarchy($path);
+
+ if ($this->normalize !== false) {
+ $path = $this->normalizePathPart($path);
+ }
+
+ if ($path === '' || $path === '.') {
+ return '';
+ }
+
+ [$scheme, $parent] = $this->dirnameInternal($scheme, $path, $levels);
+
+ return $parent !== $path ? $this->toString($scheme, $parent) : '';
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FilesystemInterface::normalize()
+ */
+ public function normalize(string $path): string
+ {
+ [$scheme, $path] = $this->getSchemeAndHierarchy($path);
+
+ $path = $this->normalizePathPart($path);
+
+ return $this->toString($scheme, $path);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FilesystemInterface::dirname()
+ */
+ public function dirname(string $path, int $levels = 1): string
+ {
+ [$scheme, $path] = $this->getSchemeAndHierarchy($path);
+
+ if ($this->normalize || ($scheme && null === $this->normalize)) {
+ $path = $this->normalizePathPart($path);
+ }
+
+ [$scheme, $path] = $this->dirnameInternal($scheme, $path, $levels);
+
+ return $this->toString($scheme, $path);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FilesystemInterface::pathinfo()
+ */
+ public function pathinfo(string $path, int $options = null)
+ {
+ [$scheme, $path] = $this->getSchemeAndHierarchy($path);
+
+ if ($this->normalize || ($scheme && null === $this->normalize)) {
+ $path = $this->normalizePathPart($path);
+ }
+
+ return $this->pathinfoInternal($scheme, $path, $options);
+ }
+
+ /**
+ * @param string|null $scheme
+ * @param string $path
+ * @param int $levels
+ *
+ * @return array
+ */
+ protected function dirnameInternal(?string $scheme, string $path, int $levels = 1): array
+ {
+ $path = \dirname($path, $levels);
+
+ if (null !== $scheme && $path === '.') {
+ return [$scheme, ''];
+ }
+
+ return [$scheme, $path];
+ }
+
+ /**
+ * @param string|null $scheme
+ * @param string $path
+ * @param int|null $options
+ *
+ * @return array
+ */
+ protected function pathinfoInternal(?string $scheme, string $path, int $options = null)
+ {
+ $info = $options ? \pathinfo($path, $options) : \pathinfo($path);
+
+ if (null !== $scheme) {
+ $info['scheme'] = $scheme;
+ $dirname = isset($info['dirname']) && $info['dirname'] !== '.' ? $info['dirname'] : null;
+
+ if (null !== $dirname) {
+ $info['dirname'] = $scheme . '://' . $dirname;
+ } else {
+ $info = ['dirname' => $scheme . '://'] + $info;
+ }
+ }
+
+ return $info;
+ }
+
+ /**
+ * Gets a 2-tuple of scheme (may be null) and hierarchical part of a filename (e.g. file:///tmp -> array(file, tmp)).
+ *
+ * @param string $filename
+ *
+ * @return array
+ */
+ protected function getSchemeAndHierarchy(string $filename): array
+ {
+ $components = explode('://', $filename, 2);
+
+ return 2 === \count($components) ? $components : [null, $components[0]];
+ }
+
+ /**
+ * @param string|null $scheme
+ * @param string $path
+ *
+ * @return string
+ */
+ protected function toString(?string $scheme, string $path): string
+ {
+ if ($scheme) {
+ return $scheme . '://' . $path;
+ }
+
+ return $path;
+ }
+
+ /**
+ * @param string $path
+ *
+ * @return string
+ * @throws \RuntimeException
+ */
+ protected function normalizePathPart(string $path): string
+ {
+ // Quick check for empty path.
+ if ($path === '' || $path === '.') {
+ return '';
+ }
+
+ // Quick check for root.
+ if ($path === '/') {
+ return '/';
+ }
+
+ // If the last character is not '/' or any of '\', './', '//' and '..' are not found, path is clean and we're done.
+ if ($path[-1] !== '/' && !preg_match('`(\\\\|\./|//|\.\.)`', $path)) {
+ return $path;
+ }
+
+ // Convert backslashes
+ $path = strtr($path, ['\\' => '/']);
+
+ $parts = explode('/', $path);
+
+ // Keep absolute paths.
+ $root = '';
+ if ($parts[0] === '') {
+ $root = '/';
+ array_shift($parts);
+ }
+
+ $list = [];
+ foreach ($parts as $i => $part) {
+ // Remove empty parts: // and /./
+ if ($part === '' || $part === '.') {
+ continue;
+ }
+
+ // Resolve /../ by removing path part.
+ if ($part === '..') {
+ $test = array_shift($list);
+ if ($test === null) {
+ // Oops, user tried to access something outside of our root folder.
+ throw new \RuntimeException("Bad path {$path}");
+ }
+ }
+
+ $list[] = $part;
+ }
+
+ // Build path back together.
+ return $root . implode('/', $list);
+ }
+}
diff --git a/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php b/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
new file mode 100644
index 0000000..7082ebf
--- /dev/null
+++ b/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
@@ -0,0 +1,75 @@
+= 1).
+ *
+ * @return string Returns parent path.
+ * @throws \RuntimeException
+ * @api
+ */
+ public function parent(string $path, int $levels = 1): string;
+
+ /**
+ * Normalize path by cleaning up `\`, `/./`, `//` and `/../`.
+ *
+ * @param string $path A filename or path, does not need to exist as a file.
+ *
+ * @return string Returns normalized path.
+ * @throws \RuntimeException
+ * @api
+ */
+ public function normalize(string $path): string;
+
+ /**
+ * Stream-safe `\dirname()` replacement.
+ *
+ * @see http://php.net/manual/en/function.dirname.php
+ *
+ * @param string $path A filename or path, does not need to exist as a file.
+ * @param int $levels The number of parent directories to go up (>= 1).
+ *
+ * @return string Returns path to the directory.
+ * @throws \RuntimeException
+ * @api
+ */
+ public function dirname(string $path, int $levels = 1): string;
+
+ /**
+ * Stream-safe `\pathinfo()` replacement.
+ *
+ * @see http://php.net/manual/en/function.pathinfo.php
+ *
+ * @param string $path A filename or path, does not need to exist as a file.
+ * @param int $options A PATHINFO_* constant.
+ *
+ * @return array|string
+ * @api
+ */
+ public function pathinfo(string $path, int $options = null);
+}
diff --git a/system/src/Grav/Framework/Flex/Flex.php b/system/src/Grav/Framework/Flex/Flex.php
new file mode 100644
index 0000000..e87e903
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/Flex.php
@@ -0,0 +1,311 @@
+ blueprint file, ...]
+ * @param array $config
+ */
+ public function __construct(array $types, array $config)
+ {
+ $this->config = $config;
+ $this->types = [];
+
+ foreach ($types as $type => $blueprint) {
+ $this->addDirectoryType($type, $blueprint);
+ }
+ }
+
+ /**
+ * @param string $type
+ * @param string $blueprint
+ * @param array $config
+ * @return $this
+ */
+ public function addDirectoryType(string $type, string $blueprint, array $config = [])
+ {
+ $config = array_merge_recursive(['enabled' => true], $this->config['object'] ?? [], $config);
+
+ $this->types[$type] = new FlexDirectory($type, $blueprint, $config);
+
+ return $this;
+ }
+
+ /**
+ * @param FlexDirectory $directory
+ * @return $this
+ */
+ public function addDirectory(FlexDirectory $directory)
+ {
+ $this->types[$directory->getFlexType()] = $directory;
+
+ return $this;
+ }
+
+ /**
+ * @param string $type
+ * @return bool
+ */
+ public function hasDirectory(string $type): bool
+ {
+ return isset($this->types[$type]);
+ }
+
+ /**
+ * @param array|string[] $types
+ * @param bool $keepMissing
+ * @return array|FlexDirectory[]
+ */
+ public function getDirectories(array $types = null, bool $keepMissing = false): array
+ {
+ if ($types === null) {
+ return $this->types;
+ }
+
+ // Return the directories in the given order.
+ $directories = [];
+ foreach ($types as $type) {
+ $directories[$type] = $this->types[$type] ?? null;
+ }
+
+ return $keepMissing ? $directories : array_filter($directories);
+ }
+
+ /**
+ * @param string $type
+ * @return FlexDirectory|null
+ */
+ public function getDirectory(string $type): ?FlexDirectory
+ {
+ return $this->types[$type] ?? null;
+ }
+
+ /**
+ * @param string $type
+ * @param array|null $keys
+ * @param string|null $keyField
+ * @return FlexCollectionInterface|null
+ */
+ public function getCollection(string $type, array $keys = null, string $keyField = null): ?FlexCollectionInterface
+ {
+ $directory = $type ? $this->getDirectory($type) : null;
+
+ return $directory ? $directory->getCollection($keys, $keyField) : null;
+ }
+
+ /**
+ * @param array $keys
+ * @param array $options In addition to the options in getObjects(), following options can be passed:
+ * collection_class: Class to be used to create the collection. Defaults to ObjectCollection.
+ * @return FlexCollectionInterface
+ * @throws \RuntimeException
+ */
+ public function getMixedCollection(array $keys, array $options = []): FlexCollectionInterface
+ {
+ $collectionClass = $options['collection_class'] ?? ObjectCollection::class;
+ if (!class_exists($collectionClass)) {
+ throw new \RuntimeException(sprintf('Cannot create collection: Class %s does not exist', $collectionClass));
+ }
+
+ $objects = $this->getObjects($keys, $options);
+
+ return new $collectionClass($objects);
+ }
+
+ /**
+ * @param array $keys
+ * @param array $options Following optional options can be passed:
+ * types: List of allowed types.
+ * type: Allowed type if types isn't defined, otherwise acts as default_type.
+ * default_type: Set default type for objects given without type (only used if key_field isn't set).
+ * keep_missing: Set to true if you want to return missing objects as null.
+ * key_field: Key field which is used to match the objects.
+ * @return array
+ */
+ public function getObjects(array $keys, array $options = []): array
+ {
+ $type = $options['type'] ?? null;
+ $defaultType = $options['default_type'] ?? $type ?? null;
+ $keyField = $options['key_field'] ?? 'flex_key';
+
+ // Prepare empty result lists for all requested Flex types.
+ $types = $options['types'] ?? (array)$type ?: null;
+ if ($types) {
+ $types = array_fill_keys($types, []);
+ }
+ $strict = isset($types);
+
+ $guessed = [];
+ if ($keyField === 'flex_key') {
+ // We need to split Flex key lookups into individual directories.
+ $undefined = [];
+ $keyFieldFind = 'storage_key';
+
+ foreach ($keys as $flexKey) {
+ if (!$flexKey) {
+ continue;
+ }
+
+ $flexKey = (string)$flexKey;
+ // Normalize key and type using fallback to default type if it was set.
+ [$key, $type, $guess] = $this->resolveKeyAndType($flexKey, $defaultType);
+
+ if ($type === '' && $types) {
+ // Add keys which are not associated to any Flex type. They will be included to every Flex type.
+ foreach ($types as $type => &$array) {
+ $array[] = $key;
+ $guessed[$key][] = "{$type}.obj:{$key}";
+ }
+ unset($array);
+ } elseif (!$strict || isset($types[$type])) {
+ // Collect keys by their Flex type. If allowed types are defined, only include values from those types.
+ $types[$type][] = $key;
+ if ($guess) {
+ $guessed[$key][] = "{$type}.obj:{$key}";
+ }
+ }
+ }
+ } else {
+ // We are using a specific key field, make every key undefined.
+ $undefined = $keys;
+ $keyFieldFind = $keyField;
+ }
+
+ if (!$types) {
+ return [];
+ }
+
+ $list = [[]];
+ foreach ($types as $type => $typeKeys) {
+ // Also remember to look up keys from undefined Flex types.
+ $lookupKeys = $undefined ? array_merge($typeKeys, $undefined) : $typeKeys;
+
+ $collection = $this->getCollection($type, $lookupKeys, $keyFieldFind);
+ if ($collection && $keyFieldFind !== $keyField) {
+ $collection = $collection->withKeyField($keyField);
+ }
+
+ $list[] = $collection ? $collection->toArray() : [];
+ }
+
+ // Merge objects from individual types back together.
+ $list = array_merge(...$list);
+
+ // Use the original key ordering.
+ if (!$guessed) {
+ $list = array_replace(array_fill_keys($keys, null), $list);
+ } else {
+ // We have mixed keys, we need to map flex keys back to storage keys.
+ $results = [];
+ foreach ($keys as $key) {
+ $flexKey = $guessed[$key] ?? $key;
+ if (\is_array($flexKey)) {
+ $result = null;
+ foreach ($flexKey as $tryKey) {
+ if ($result = $list[$tryKey] ?? null) {
+ // Use the first matching object (conflicting objects will be ignored for now).
+ break;
+ }
+ }
+ } else {
+ $result = $list[$flexKey] ?? null;
+ }
+
+ $results[$key] = $result;
+ }
+
+ $list = $results;
+ }
+
+ // Remove missing objects if not asked to keep them.
+ if (empty($option['keep_missing'])) {
+ $list = array_filter($list);
+ }
+
+ return $list;
+ }
+
+ /**
+ * @param string $key
+ * @param string|null $type
+ * @param string|null $keyField
+ * @return FlexObjectInterface|null
+ */
+ public function getObject(string $key, string $type = null, string $keyField = null): ?FlexObjectInterface
+ {
+ if (null === $type && null === $keyField) {
+ // Special handling for quick Flex key lookups.
+ $keyField = 'storage_key';
+ [$type, $key] = $this->resolveKeyAndType($key, $type);
+ } else {
+ $type = $this->resolveType($type);
+ }
+
+ if ($type === '' || $key === '') {
+ return null;
+ }
+
+ $directory = $this->getDirectory($type);
+
+ return $directory ? $directory->getObject($key, $keyField) : null;
+ }
+
+ /**
+ * @return int
+ */
+ public function count(): int
+ {
+ return \count($this->types);
+ }
+
+ protected function resolveKeyAndType(string $flexKey, string $type = null): array
+ {
+ $guess = false;
+ if (strpos($flexKey, ':') !== false) {
+ [$type, $key] = explode(':', $flexKey, 2);
+
+ $type = $this->resolveType($type);
+ } else {
+ $key = $flexKey;
+ $type = (string)$type;
+ $guess = true;
+ }
+
+ return [$key, $type, $guess];
+ }
+
+ protected function resolveType(string $type = null): string
+ {
+ if (null !== $type && strpos($type, '.') !== false) {
+ return preg_replace('|\.obj$|', '', $type);
+ }
+
+ return $type ?? '';
+ }
+}
diff --git a/system/src/Grav/Framework/Flex/FlexCollection.php b/system/src/Grav/Framework/Flex/FlexCollection.php
new file mode 100644
index 0000000..5e5431b
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/FlexCollection.php
@@ -0,0 +1,525 @@
+ true,
+ 'getType' => true,
+ 'getFlexDirectory' => true,
+ 'getCacheKey' => true,
+ 'getCacheChecksum' => true,
+ 'getTimestamp' => true,
+ 'hasProperty' => true,
+ 'getProperty' => true,
+ 'hasNestedProperty' => true,
+ 'getNestedProperty' => true,
+ 'orderBy' => true,
+
+ 'render' => false,
+ 'isAuthorized' => 'session',
+ 'search' => true,
+ 'sort' => true,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::createFromArray()
+ */
+ public static function createFromArray(array $entries, FlexDirectory $directory, string $keyField = null)
+ {
+ $instance = new static($entries, $directory);
+ $instance->setKeyField($keyField);
+
+ return $instance;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::__construct()
+ */
+ public function __construct(array $entries = [], FlexDirectory $directory = null)
+ {
+ parent::__construct($entries);
+
+ if ($directory) {
+ $this->setFlexDirectory($directory)->setKey($directory->getFlexType());
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::search()
+ */
+ public function search(string $search, $properties = null, array $options = null)
+ {
+ $matching = $this->call('search', [$search, $properties, $options]);
+ $matching = array_filter($matching);
+
+ if ($matching) {
+ uksort($matching, function ($a, $b) {
+ return -($a <=> $b);
+ });
+ }
+
+ return $this->select(array_keys($matching));
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::sort()
+ */
+ public function sort(array $order)
+ {
+ $criteria = Criteria::create()->orderBy($order);
+
+ /** @var FlexCollectionInterface $matching */
+ $matching = $this->matching($criteria);
+
+ return $matching;
+ }
+
+ /**
+ * @param array $filters
+ * @return FlexCollectionInterface|Collection
+ */
+ public function filterBy(array $filters)
+ {
+ $expr = Criteria::expr();
+ $criteria = Criteria::create();
+
+ foreach ($filters as $key => $value) {
+ $criteria->andWhere($expr->eq($key, $value));
+ }
+
+ return $this->matching($criteria);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getFlexType()
+ */
+ public function getFlexType(): string
+ {
+ return $this->_flexDirectory->getFlexType();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getFlexDirectory()
+ */
+ public function getFlexDirectory(): FlexDirectory
+ {
+ return $this->_flexDirectory;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getTimestamp()
+ */
+ public function getTimestamp(): int
+ {
+ $timestamps = $this->getTimestamps();
+
+ return $timestamps ? max($timestamps) : time();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getFlexDirectory()
+ */
+ public function getCacheKey(): string
+ {
+ return $this->getTypePrefix() . $this->getFlexType() . '.' . sha1(json_encode($this->call('getKey')));
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getFlexDirectory()
+ */
+ public function getCacheChecksum(): string
+ {
+ return sha1(json_encode($this->getTimestamps()));
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getFlexDirectory()
+ */
+ public function getTimestamps(): array
+ {
+ /** @var int[] $timestamps */
+ $timestamps = $this->call('getTimestamp');
+
+ return $timestamps;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getFlexDirectory()
+ */
+ public function getStorageKeys(): array
+ {
+ /** @var string[] $keys */
+ $keys = $this->call('getStorageKey');
+
+ return $keys;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getFlexDirectory()
+ */
+ public function getFlexKeys(): array
+ {
+ /** @var string[] $keys */
+ $keys = $this->call('getFlexKey');
+
+ return $keys;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::withKeyField()
+ */
+ public function withKeyField(string $keyField = null)
+ {
+ $keyField = $keyField ?: 'key';
+ if ($keyField === $this->getKeyField()) {
+ return $this;
+ }
+
+ $entries = [];
+ foreach ($this as $key => $object) {
+ // TODO: remove hardcoded logic
+ if ($keyField === 'storage_key') {
+ $entries[$object->getStorageKey()] = $object;
+ } elseif ($keyField === 'flex_key') {
+ $entries[$object->getFlexKey()] = $object;
+ } elseif ($keyField === 'key') {
+ $entries[$object->getKey()] = $object;
+ }
+ }
+
+ return $this->createFrom($entries, $keyField);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getIndex()
+ */
+ public function getIndex()
+ {
+ return $this->getFlexDirectory()->getIndex($this->getKeys(), $this->getKeyField());
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::render()
+ */
+ public function render(string $layout = null, array $context = [])
+ {
+ if (null === $layout) {
+ $layout = 'default';
+ }
+ $type = $this->getFlexType();
+
+ $grav = Grav::instance();
+
+ /** @var Debugger $debugger */
+ $debugger = $grav['debugger'];
+ $debugger->startTimer('flex-collection-' . ($debugKey = uniqid($type, false)), 'Render Collection ' . $type . ' (' . $layout . ')');
+
+ $cache = $key = null;
+ foreach ($context as $value) {
+ if (!\is_scalar($value)) {
+ $key = false;
+ }
+ }
+
+ if ($key !== false) {
+ $key = md5($this->getCacheKey() . '.' . $layout . json_encode($context));
+ $cache = $this->getCache('render');
+ }
+
+ try {
+ $data = $cache ? $cache->get($key) : null;
+
+ $block = $data ? HtmlBlock::fromArray($data) : null;
+ } catch (InvalidArgumentException $e) {
+ $debugger->addException($e);
+ $block = null;
+ } catch (\InvalidArgumentException $e) {
+ $debugger->addException($e);
+ $block = null;
+ }
+
+ $checksum = $this->getCacheChecksum();
+ if ($block && $checksum !== $block->getChecksum()) {
+ $block = null;
+ }
+
+ if (!$block) {
+ $block = HtmlBlock::create($key);
+ $block->setChecksum($checksum);
+ if ($key === false) {
+ $block->disableCache();
+ }
+
+ $grav->fireEvent('onFlexCollectionRender', new Event([
+ 'collection' => $this,
+ 'layout' => &$layout,
+ 'context' => &$context
+ ]));
+
+ $output = $this->getTemplate($layout)->render(
+ ['grav' => $grav, 'config' => $grav['config'], 'block' => $block, 'collection' => $this, 'layout' => $layout] + $context
+ );
+
+ if ($debugger->enabled()) {
+ $output = "\n\n{$output}\n\n";
+ }
+
+ $block->setContent($output);
+
+ try {
+ $cache && $block->isCached() && $cache->set($key, $block->toArray());
+ } catch (InvalidArgumentException $e) {
+ $debugger->addException($e);
+ }
+ }
+
+ $debugger->stopTimer('flex-collection-' . $debugKey);
+
+ return $block;
+ }
+
+ /**
+ * @param bool $prefix
+ * @return string
+ * @deprecated 1.6 Use `->getFlexType()` instead.
+ */
+ public function getType($prefix = false)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use ->getFlexType() method instead', E_USER_DEPRECATED);
+
+ $type = $prefix ? $this->getTypePrefix() : '';
+
+ return $type . $this->getFlexType();
+ }
+
+ /**
+ * @param FlexDirectory $type
+ * @return $this
+ */
+ public function setFlexDirectory(FlexDirectory $type)
+ {
+ $this->_flexDirectory = $type;
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getMetaData(string $key) : array
+ {
+ $object = $this->get($key);
+
+ return $object instanceof FlexObjectInterface ? $object->getMetaData() : [];
+ }
+
+ /**
+ * @param string|null $namespace
+ * @return CacheInterface
+ */
+ public function getCache(string $namespace = null)
+ {
+ return $this->_flexDirectory->getCache($namespace);
+ }
+
+ /**
+ * @return string
+ */
+ public function getKeyField(): string
+ {
+ return $this->_keyField ?? 'storage_key';
+ }
+
+ /**
+ * @param string $action
+ * @param string|null $scope
+ * @param UserInterface|null $user
+ * @return static
+ */
+ public function isAuthorized(string $action, string $scope = null, UserInterface $user = null)
+ {
+ $list = $this->call('isAuthorized', [$action, $scope, $user]);
+ $list = \array_filter($list);
+
+ return $this->select(array_keys($list));
+ }
+
+ /**
+ * @param string $value
+ * @param string $field
+ * @return FlexObject|null
+ */
+ public function find($value, $field = 'id')
+ {
+ if ($value) foreach ($this as $element) {
+ if (mb_strtolower($element->getProperty($field)) === mb_strtolower($value)) {
+ return $element;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @return array
+ */
+ public function jsonSerialize()
+ {
+ $elements = [];
+
+ /**
+ * @var string $key
+ * @var array|FlexObject $object
+ */
+ foreach ($this->getElements() as $key => $object) {
+ $elements[$key] = \is_array($object) ? $object : $object->jsonSerialize();
+ }
+
+ return $elements;
+ }
+
+ public function __debugInfo()
+ {
+ return [
+ 'type:private' => $this->getFlexType(),
+ 'key:private' => $this->getKey(),
+ 'objects_key:private' => $this->getKeyField(),
+ 'objects:private' => $this->getElements()
+ ];
+ }
+
+ /**
+ * Creates a new instance from the specified elements.
+ *
+ * This method is provided for derived classes to specify how a new
+ * instance should be created when constructor semantics have changed.
+ *
+ * @param array $elements Elements.
+ * @param string|null $keyField
+ *
+ * @return static
+ * @throws \InvalidArgumentException
+ */
+ protected function createFrom(array $elements, $keyField = null)
+ {
+ $collection = new static($elements, $this->_flexDirectory);
+ $collection->setKeyField($keyField ?: $this->_keyField);
+
+ return $collection;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getTypePrefix(): string
+ {
+ return 'c.';
+ }
+
+ /**
+ * @param string $layout
+ * @return TemplateWrapper
+ * @throws LoaderError
+ * @throws SyntaxError
+ */
+ protected function getTemplate($layout)
+ {
+ $grav = Grav::instance();
+
+ /** @var Twig $twig */
+ $twig = $grav['twig'];
+
+ try {
+ return $twig->twig()->resolveTemplate(
+ [
+ "flex-objects/layouts/{$this->getFlexType()}/collection/{$layout}.html.twig",
+ "flex-objects/layouts/_default/collection/{$layout}.html.twig"
+ ]
+ );
+ } catch (LoaderError $e) {
+ /** @var Debugger $debugger */
+ $debugger = Grav::instance()['debugger'];
+ $debugger->addException($e);
+
+ return $twig->twig()->resolveTemplate(['flex-objects/layouts/404.html.twig']);
+ }
+ }
+
+ /**
+ * @param string $type
+ * @return FlexDirectory
+ */
+ protected function getRelatedDirectory($type): ?FlexDirectory
+ {
+ /** @var Flex $flex */
+ $flex = Grav::instance()['flex_objects'];
+
+ return $flex->getDirectory($type);
+ }
+
+ protected function setKeyField($keyField = null): void
+ {
+ $this->_keyField = $keyField ?? 'storage_key';
+ }
+}
diff --git a/system/src/Grav/Framework/Flex/FlexDirectory.php b/system/src/Grav/Framework/Flex/FlexDirectory.php
new file mode 100644
index 0000000..c75a901
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/FlexDirectory.php
@@ -0,0 +1,669 @@
+type = $type;
+ $this->blueprints = [];
+ $this->blueprint_file = $blueprint_file;
+ $this->defaults = $defaults;
+ $this->enabled = !empty($defaults['enabled']);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isEnabled(): bool
+ {
+ return $this->enabled;
+ }
+
+ /**
+ * @return string
+ * @deprecated 1.6 Use ->getFlexType() method instead.
+ */
+ public function getType(): string
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use ->getFlexType() method instead', E_USER_DEPRECATED);
+
+ return $this->type;
+ }
+
+ /**
+ * @return string
+ */
+ public function getFlexType(): string
+ {
+ return $this->type;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTitle(): string
+ {
+ return $this->getBlueprintInternal()->get('title', ucfirst($this->getFlexType()));
+ }
+
+ /**
+ * @return string
+ */
+ public function getDescription(): string
+ {
+ return $this->getBlueprintInternal()->get('description', '');
+ }
+
+ /**
+ * @param string|null $name
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getConfig(string $name = null, $default = null)
+ {
+ if (null === $this->config) {
+ $this->config = new Config(array_merge_recursive($this->getBlueprintInternal()->get('config', []), $this->defaults));
+ }
+
+ return null === $name ? $this->config : $this->config->get($name, $default);
+ }
+
+ /**
+ * @param string $type
+ * @param string $context
+ * @return Blueprint
+ */
+ public function getBlueprint(string $type = '', string $context = '')
+ {
+ $blueprint = $this->getBlueprintInternal($type, $context);
+
+ if (empty($this->blueprints_init[$type])) {
+ $this->blueprints_init[$type] = true;
+
+ $blueprint->setScope('object');
+ $blueprint->init();
+ if (empty($blueprint->fields())) {
+ throw new RuntimeException(sprintf('Flex: Blueprint for %s is missing', $this->type));
+ }
+ }
+
+ return $blueprint;
+ }
+
+ /**
+ * @param string $view
+ * @return string
+ */
+ public function getBlueprintFile(string $view = ''): string
+ {
+ $file = $this->blueprint_file;
+ if ($view !== '') {
+ $file = preg_replace('/\.yaml/', "/{$view}.yaml", $file);
+ }
+
+ return $file;
+ }
+
+ /**
+ * Get collection. In the site this will be filtered by the default filters (published etc).
+ *
+ * Use $directory->getIndex() if you want unfiltered collection.
+ *
+ * @param array|null $keys Array of keys.
+ * @param string|null $keyField Field to be used as the key.
+ * @return FlexCollectionInterface
+ */
+ public function getCollection(array $keys = null, string $keyField = null): FlexCollectionInterface
+ {
+ // Get all selected entries.
+ $index = $this->getIndex($keys, $keyField);
+
+ if (!Utils::isAdminPlugin()) {
+ // If not in admin, filter the list by using default filters.
+ $filters = (array)$this->getConfig('site.filter', []);
+
+ foreach ($filters as $filter) {
+ $index = $index->{$filter}();
+ }
+ }
+
+ return $index;
+ }
+
+ /**
+ * Get the full collection of all stored objects.
+ *
+ * Use $directory->getCollection() if you want a filtered collection.
+ *
+ * @param array|null $keys Array of keys.
+ * @param string|null $keyField Field to be used as the key.
+ * @return FlexIndexInterface
+ */
+ public function getIndex(array $keys = null, string $keyField = null): FlexIndexInterface
+ {
+ $index = clone $this->loadIndex();
+ $index = $index->withKeyField($keyField);
+
+ if (null !== $keys) {
+ $index = $index->select($keys);
+ }
+
+ return $index->getIndex();
+ }
+
+ /**
+ * Returns an object if it exists.
+ *
+ * Note: It is not safe to use the object without checking if the user can access it.
+ *
+ * @param string $key
+ * @param string|null $keyField Field to be used as the key.
+ * @return FlexObjectInterface|null
+ */
+ public function getObject($key, string $keyField = null): ?FlexObjectInterface
+ {
+ return $this->getIndex(null, $keyField)->get($key);
+ }
+
+ /**
+ * @param array $data
+ * @param string|null $key
+ * @return FlexObjectInterface
+ */
+ public function update(array $data, string $key = null): FlexObjectInterface
+ {
+ $object = null !== $key ? $this->getIndex()->get($key): null;
+
+ $storage = $this->getStorage();
+
+ if (null === $object) {
+ $object = $this->createObject($data, $key, true);
+ $key = $object->getStorageKey();
+
+ if ($key) {
+ $rows = $storage->replaceRows([$key => $object->prepareStorage()]);
+ } else {
+ $rows = $storage->createRows([$object->prepareStorage()]);
+ }
+ } else {
+ $oldKey = $object->getStorageKey();
+ $object->update($data);
+ $newKey = $object->getStorageKey();
+
+ if ($oldKey !== $newKey) {
+ $object->triggerEvent('move');
+ $storage->renameRow($oldKey, $newKey);
+ // TODO: media support.
+ }
+
+ $object->save();
+ }
+
+ try {
+ $this->clearCache();
+ } catch (InvalidArgumentException $e) {
+ /** @var Debugger $debugger */
+ $debugger = Grav::instance()['debugger'];
+ $debugger->addException($e);
+
+ // Caching failed, but we can ignore that for now.
+ }
+
+ return $object;
+ }
+
+ /**
+ * @param string $key
+ * @return FlexObjectInterface|null
+ */
+ public function remove(string $key): ?FlexObjectInterface
+ {
+ $object = $this->getIndex()->get($key);
+ if (!$object) {
+ return null;
+ }
+
+ $object->delete();
+
+ return $object;
+ }
+
+ /**
+ * @param string|null $namespace
+ * @return CacheInterface
+ */
+ public function getCache(string $namespace = null)
+ {
+ $namespace = $namespace ?: 'index';
+ $cache = $this->cache[$namespace] ?? null;
+
+ if (null === $cache) {
+ try {
+ $grav = Grav::instance();
+
+ /** @var Cache $gravCache */
+ $gravCache = $grav['cache'];
+ $config = $this->getConfig('cache.' . $namespace);
+ if (empty($config['enabled'])) {
+ $cache = new MemoryCache('flex-objects-' . $this->getFlexType());
+ } else {
+ $timeout = $config['timeout'] ?? 60;
+
+ $key = $gravCache->getKey();
+ if (Utils::isAdminPlugin()) {
+ $key = substr($key, 0, -1);
+ }
+ $cache = new DoctrineCache($gravCache->getCacheDriver(), 'flex-objects-' . $this->getFlexType() . $key, $timeout);
+ }
+ } catch (\Exception $e) {
+ /** @var Debugger $debugger */
+ $debugger = Grav::instance()['debugger'];
+ $debugger->addException($e);
+
+ $cache = new MemoryCache('flex-objects-' . $this->getFlexType());
+ }
+
+ // Disable cache key validation.
+ $cache->setValidation(false);
+ $this->cache[$namespace] = $cache;
+ }
+
+ return $cache;
+ }
+
+ /**
+ * @return $this
+ */
+ public function clearCache()
+ {
+ $grav = Grav::instance();
+
+ /** @var Debugger $debugger */
+ $debugger = $grav['debugger'];
+ $debugger->addMessage(sprintf('Flex: Clearing all %s cache', $this->type), 'debug');
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $grav['locator'];
+ $locator->clearCache();
+
+ $this->getCache('index')->clear();
+ $this->getCache('object')->clear();
+ $this->getCache('render')->clear();
+
+ $this->index = null;
+
+ return $this;
+ }
+
+ /**
+ * @param string|null $key
+ * @return string
+ */
+ public function getStorageFolder(string $key = null): string
+ {
+ return $this->getStorage()->getStoragePath($key);
+ }
+
+ /**
+ * @param string|null $key
+ * @return string
+ */
+ public function getMediaFolder(string $key = null): string
+ {
+ return $this->getStorage()->getMediaPath($key);
+ }
+
+ /**
+ * @return FlexStorageInterface
+ */
+ public function getStorage(): FlexStorageInterface
+ {
+ if (null === $this->storage) {
+ $this->storage = $this->createStorage();
+ }
+
+ return $this->storage;
+ }
+
+ /**
+ * @param array $data
+ * @param string $key
+ * @param bool $validate
+ * @return FlexObjectInterface
+ */
+ public function createObject(array $data, string $key = '', bool $validate = false): FlexObjectInterface
+ {
+ /** @var string|FlexObjectInterface $className */
+ $className = $this->objectClassName ?: $this->getObjectClass();
+
+ return new $className($data, $key, $this, $validate);
+ }
+
+ /**
+ * @param array $entries
+ * @param string $keyField
+ * @return FlexCollectionInterface
+ */
+ public function createCollection(array $entries, string $keyField = null): FlexCollectionInterface
+ {
+ /** @var string|FlexCollectionInterface $className */
+ $className = $this->collectionClassName ?: $this->getCollectionClass();
+
+ return $className::createFromArray($entries, $this, $keyField);
+ }
+
+ /**
+ * @param array $entries
+ * @param string $keyField
+ * @return FlexIndexInterface
+ */
+ public function createIndex(array $entries, string $keyField = null): FlexIndexInterface
+ {
+ /** @var string|FlexIndexInterface $className */
+ $className = $this->indexClassName ?: $this->getIndexClass();
+
+ return $className::createFromArray($entries, $this, $keyField);
+ }
+
+ /**
+ * @return string
+ */
+ public function getObjectClass(): string
+ {
+ if (!$this->objectClassName) {
+ $this->objectClassName = $this->getConfig('data.object', 'Grav\\Framework\\Flex\\FlexObject');
+ }
+
+ return $this->objectClassName;
+
+ }
+
+ /**
+ * @return string
+ */
+ public function getCollectionClass(): string
+ {
+ if (!$this->collectionClassName) {
+ $this->collectionClassName = $this->getConfig('data.collection', 'Grav\\Framework\\Flex\\FlexCollection');
+ }
+
+ return $this->collectionClassName;
+ }
+
+
+ /**
+ * @return string
+ */
+ public function getIndexClass(): string
+ {
+ if (!$this->indexClassName) {
+ $this->indexClassName = $this->getConfig('data.index', 'Grav\\Framework\\Flex\\FlexIndex');
+ }
+
+ return $this->indexClassName;
+ }
+
+ /**
+ * @param array $entries
+ * @param string $keyField
+ * @return FlexCollectionInterface
+ */
+ public function loadCollection(array $entries, string $keyField = null): FlexCollectionInterface
+ {
+ return $this->createCollection($this->loadObjects($entries), $keyField);
+ }
+
+ /**
+ * @param array $entries
+ * @return FlexObjectInterface[]
+ * @internal
+ */
+ public function loadObjects(array $entries): array
+ {
+ /** @var Debugger $debugger */
+ $debugger = Grav::instance()['debugger'];
+ $debugger->startTimer('flex-objects', sprintf('Flex: Initializing %d %s', \count($entries), $this->type));
+
+ $storage = $this->getStorage();
+ $cache = $this->getCache('object');
+
+ // Get storage keys for the objects.
+ $keys = [];
+ $rows = [];
+ foreach ($entries as $key => $value) {
+ $k = $value['storage_key'];
+ $keys[$k] = $key;
+ $rows[$k] = null;
+ }
+
+ // Fetch rows from the cache.
+ try {
+ $rows = $cache->getMultiple(array_keys($rows));
+ } catch (InvalidArgumentException $e) {
+ $debugger->addException($e);
+ }
+
+ // Read missing rows from the storage.
+ $updated = [];
+ $rows = $storage->readRows($rows, $updated);
+
+ // Store updated rows to the cache.
+ if ($updated) {
+ try {
+ if (!$cache instanceof MemoryCache) {
+ $debugger->addMessage(sprintf('Flex: Caching %d %s: %s', \count($updated), $this->type, implode(', ', array_keys($updated))), 'debug');
+ }
+ $cache->setMultiple($updated);
+ } catch (InvalidArgumentException $e) {
+ $debugger->addException($e);
+
+ // TODO: log about the issue.
+ }
+ }
+
+ // Create objects from the rows.
+ $list = [];
+ foreach ($rows as $storageKey => $row) {
+ if ($row === null) {
+ $debugger->addMessage(sprintf('Flex: Object %s was not found from %s storage', $storageKey, $this->type), 'debug');
+ continue;
+ }
+
+ if (isset($row['__error'])) {
+ $message = sprintf('Flex: Object %s is broken in %s storage: %s', $storageKey, $this->type, $row['__error']);
+ $debugger->addException(new \RuntimeException($message));
+ $debugger->addMessage($message, 'error');
+ continue;
+ }
+
+ $usedKey = $keys[$storageKey];
+ $row += [
+ 'storage_key' => $storageKey,
+ 'storage_timestamp' => $entries[$usedKey]['storage_timestamp'],
+ ];
+
+ $key = $entries[$usedKey]['key'] ?? $usedKey;
+ $object = $this->createObject($row, $key, false);
+ $list[$usedKey] = $object;
+ }
+
+ $debugger->stopTimer('flex-objects');
+
+ return $list;
+ }
+
+ /**
+ * @param string $type_view
+ * @param string $context
+ * @return Blueprint
+ */
+ protected function getBlueprintInternal(string $type_view = '', string $context = '')
+ {
+ if (!isset($this->blueprints[$type_view])) {
+ if (!file_exists($this->blueprint_file)) {
+ throw new RuntimeException(sprintf('Flex: Blueprint file for %s is missing', $this->type));
+ }
+
+ $parts = explode('.', rtrim($type_view, '.'), 2);
+ $type = array_shift($parts);
+ $view = array_shift($parts) ?: '';
+
+ $blueprint = new Blueprint($this->getBlueprintFile($view));
+ if ($context) {
+ $blueprint->setContext($context);
+ }
+
+ $blueprint->load($type ?: null);
+ if ($blueprint->get('type') === 'flex-objects' && isset(Grav::instance()['admin'])) {
+ $blueprintBase = (new Blueprint('plugin://flex-objects/blueprints/flex-objects.yaml'))->load();
+ $blueprint->extend($blueprintBase, true);
+ }
+
+ $this->blueprints[$type_view] = $blueprint;
+ }
+
+ return $this->blueprints[$type_view];
+ }
+
+ /**
+ * @return FlexStorageInterface
+ */
+ protected function createStorage(): FlexStorageInterface
+ {
+ $this->collection = $this->createCollection([]);
+
+ $storage = $this->getConfig('data.storage');
+
+ if (!\is_array($storage)) {
+ $storage = ['options' => ['folder' => $storage]];
+ }
+
+ $className = $storage['class'] ?? SimpleStorage::class;
+ $options = $storage['options'] ?? [];
+
+ return new $className($options);
+ }
+
+ /**
+ * @return FlexIndexInterface
+ */
+ protected function loadIndex(): FlexIndexInterface
+ {
+ static $i = 0;
+
+ $index = $this->index;
+
+ if (null === $index) {
+ $i++; $j = $i;
+ /** @var Debugger $debugger */
+ $debugger = Grav::instance()['debugger'];
+ $debugger->startTimer('flex-keys-' . $this->type . $j, "Flex: Loading {$this->type} index");
+
+ $storage = $this->getStorage();
+ $cache = $this->getCache('index');
+
+ try {
+ $keys = $cache->get('__keys');
+ } catch (InvalidArgumentException $e) {
+ $debugger->addException($e);
+ $keys = null;
+ }
+
+ if (null === $keys) {
+ /** @var string|FlexIndexInterface $className */
+ $className = $this->getIndexClass();
+ $keys = $className::loadEntriesFromStorage($storage);
+ if (!$cache instanceof MemoryCache) {
+ $debugger->addMessage(sprintf('Flex: Caching %s index of %d objects', $this->type, \count($keys)),
+ 'debug');
+ }
+ try {
+ $cache->set('__keys', $keys);
+ } catch (InvalidArgumentException $e) {
+ $debugger->addException($e);
+ // TODO: log about the issue.
+ }
+ }
+
+ // We need to do this in two steps as orderBy() calls loadIndex() again and we do not want infinite loop.
+ $this->index = $this->createIndex($keys);
+ /** @var FlexCollectionInterface $collection */
+ $collection = $this->index->orderBy($this->getConfig('data.ordering', []));
+ $this->index = $index = $collection->getIndex();
+
+ $debugger->stopTimer('flex-keys-' . $this->type . $j);
+ }
+
+ return $index;
+ }
+}
diff --git a/system/src/Grav/Framework/Flex/FlexForm.php b/system/src/Grav/Framework/Flex/FlexForm.php
new file mode 100644
index 0000000..6ded345
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/FlexForm.php
@@ -0,0 +1,344 @@
+name = $name;
+ $this->form = $form;
+
+ $uniqueId = $object->exists() ? $object->getStorageKey() : "{$object->getFlexType()}:new";
+ $this->setObject($object);
+ $this->setId($this->getName());
+ $this->setUniqueId(md5($uniqueId));
+ $this->messages = [];
+ $this->submitted = false;
+
+ $flash = $this->getFlash();
+ if ($flash->exists()) {
+ $data = $flash->getData();
+ $includeOriginal = (bool)($this->getBlueprint()->form()['images']['original'] ?? null);
+
+ $this->data = $data ? new Data($data, $this->getBlueprint()) : null;
+ $this->files = $flash->getFilesByFields($includeOriginal);
+ } else {
+ $this->data = null;
+ $this->files = [];
+ }
+ }
+
+ /**
+ * @return string
+ */
+ public function getName(): string
+ {
+ $object = $this->getObject();
+ $name = $this->name ?: 'object';
+
+ return "flex-{$object->getFlexType()}-{$name}";
+ }
+
+ /**
+ * @return Data|FlexObjectInterface|object
+ */
+ public function getData()
+ {
+ return $this->data ?? $this->getObject();
+ }
+
+ /**
+ * Get a value from the form.
+ *
+ * Note: Used in form fields.
+ *
+ * @param string $name
+ * @return mixed
+ */
+ public function getValue(string $name)
+ {
+ // Attempt to get value from the form data.
+ $value = $this->data ? $this->data[$name] : null;
+
+ // Return the form data or fall back to the object property.
+ return $value ?? $this->getObject()->getFormValue($name);
+ }
+
+ public function getDefaultValue(string $name)
+ {
+ return $this->object->getDefaultValue($name);
+ }
+
+ /**
+ * @return array
+ */
+ public function getDefaultValues(): array
+ {
+ return $this->object->getDefaultValues();
+ }
+ /**
+ * @return string
+ */
+ public function getFlexType(): string
+ {
+ return $this->object->getFlexType();
+ }
+
+ /**
+ * @return FlexObjectInterface
+ */
+ public function getObject(): FlexObjectInterface
+ {
+ return $this->object;
+ }
+
+ public function updateObject(): FlexObjectInterface
+ {
+ $data = $this->data instanceof Data ? $this->data->toArray() : [];
+ $files = $this->files;
+
+ return $this->getObject()->update($data, $files);
+ }
+
+ /**
+ * @return Blueprint
+ */
+ public function getBlueprint(): Blueprint
+ {
+ if (null === $this->blueprint) {
+ try {
+ $blueprint = $this->getObject()->getBlueprint(Utils::isAdminPlugin() ? '' : $this->name);
+ if ($this->form) {
+ // We have field overrides available.
+ $blueprint->extend(['form' => $this->form], true);
+ $blueprint->init();
+ }
+ } catch (\RuntimeException $e) {
+ if (!isset($this->form['fields'])) {
+ throw $e;
+ }
+
+ // Blueprint is not defined, but we have custom form fields available.
+ $blueprint = new Blueprint(null, ['form' => $this->form]);
+ $blueprint->load();
+ $blueprint->setScope('object');
+ $blueprint->init();
+ }
+
+ $this->blueprint = $blueprint;
+ }
+
+ return $this->blueprint;
+ }
+
+ /**
+ * @return Route|null
+ */
+ public function getFileUploadAjaxRoute(): ?Route
+ {
+ $object = $this->getObject();
+ if (!method_exists($object, 'route')) {
+ return null;
+ }
+
+ return $object->route('/edit.json/task:media.upload');
+ }
+
+ /**
+ * @param string $field
+ * @param string $filename
+ * @return Route|null
+ */
+ public function getFileDeleteAjaxRoute($field, $filename): ?Route
+ {
+ $object = $this->getObject();
+ if (!method_exists($object, 'route')) {
+ return null;
+ }
+
+ return $object->route('/edit.json/task:media.delete');
+ }
+
+ public function getMediaTaskRoute(array $params = [], $extension = null): string
+ {
+ $grav = Grav::instance();
+ /** @var Flex $flex */
+ $flex = $grav['flex_objects'];
+
+ if (method_exists($flex, 'adminRoute')) {
+ return $flex->adminRoute($this->getObject(), $params, $extension ?? 'json');
+ }
+
+ return '';
+ }
+
+ /**
+ * Implements \Serializable::unserialize().
+ *
+ * @param string $data
+ */
+ public function unserialize($data): void
+ {
+ $data = unserialize($data, ['allowed_classes' => [FlexObject::class]]);
+
+ $this->doUnserialize($data);
+ }
+
+ public function __get($name)
+ {
+ $method = "get{$name}";
+ if (method_exists($this, $method)) {
+ return $this->{$method}();
+ }
+
+ $form = $this->getBlueprint()->form();
+
+ return $form[$name] ?? null;
+ }
+
+ public function __set($name, $value)
+ {
+ $method = "set{$name}";
+ if (method_exists($this, $method)) {
+ $this->{$method}($value);
+ }
+ }
+
+ public function __isset($name)
+ {
+ $method = "get{$name}";
+ if (method_exists($this, $method)) {
+ return true;
+ }
+
+ $form = $this->getBlueprint()->form();
+
+ return isset($form[$name]);
+ }
+
+ public function __unset($name)
+ {
+ }
+
+ /**
+ * Note: this method clones the object.
+ *
+ * @param FlexObjectInterface $object
+ * @return $this
+ */
+ protected function setObject(FlexObjectInterface $object): self
+ {
+ $this->object = clone $object;
+
+ return $this;
+ }
+
+ /**
+ * @param string $layout
+ * @return Template|TemplateWrapper
+ * @throws LoaderError
+ * @throws SyntaxError
+ */
+ protected function getTemplate($layout)
+ {
+ $grav = Grav::instance();
+
+ /** @var Twig $twig */
+ $twig = $grav['twig'];
+
+ return $twig->twig()->resolveTemplate(
+ [
+ "flex-objects/layouts/{$this->getFlexType()}/form/{$layout}.html.twig",
+ "flex-objects/layouts/_default/form/{$layout}.html.twig",
+ "forms/{$layout}/form.html.twig",
+ 'forms/default/form.html.twig'
+ ]
+ );
+ }
+
+ /**
+ * @param array $data
+ * @param array $files
+ * @throws \Exception
+ */
+ protected function doSubmit(array $data, array $files)
+ {
+ /** @var FlexObject $object */
+ $object = clone $this->getObject();
+
+ $object->update($data, $files);
+ $object->save();
+
+ $this->setObject($object);
+ $this->reset();
+ }
+
+ protected function doSerialize(): array
+ {
+ return $this->doTraitSerialize() + [
+ 'object' => $this->object,
+ ];
+ }
+
+ protected function doUnserialize(array $data): void
+ {
+ $this->doTraitUnserialize($data);
+
+ $this->object = $data['object'];
+ }
+
+ /**
+ * Filter validated data.
+ *
+ * @param \ArrayAccess $data
+ */
+ protected function filterData(\ArrayAccess $data): void
+ {
+ if ($data instanceof Data) {
+ $data->filter(true, true);
+ }
+ }
+}
diff --git a/system/src/Grav/Framework/Flex/FlexIndex.php b/system/src/Grav/Framework/Flex/FlexIndex.php
new file mode 100644
index 0000000..8b96b4a
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/FlexIndex.php
@@ -0,0 +1,704 @@
+getStorage()), $directory);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::createFromArray()
+ */
+ public static function createFromArray(array $entries, FlexDirectory $directory, string $keyField = null)
+ {
+ $instance = new static($entries, $directory);
+ $instance->setKeyField($keyField);
+
+ return $instance;
+ }
+
+ /**
+ * @param FlexStorageInterface $storage
+ * @return array
+ */
+ public static function loadEntriesFromStorage(FlexStorageInterface $storage): array
+ {
+ return $storage->getExistingKeys();
+ }
+
+ /**
+ * Initializes a new FlexIndex.
+ *
+ * @param array $entries
+ * @param FlexDirectory|null $directory
+ */
+ public function __construct(array $entries = [], FlexDirectory $directory = null)
+ {
+ parent::__construct($entries);
+
+ $this->_flexDirectory = $directory;
+ $this->setKeyField(null);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::search()
+ */
+ public function search(string $search, $properties = null, array $options = null)
+ {
+ return $this->__call('search', [$search, $properties, $options]);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::sort()
+ */
+ public function sort(array $orderings)
+ {
+ return $this->orderBy($orderings);
+ }
+
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::filterBy()
+ */
+ public function filterBy(array $filters)
+ {
+ return $this->__call('filterBy', [$filters]);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getFlexType()
+ */
+ public function getFlexType(): string
+ {
+ return $this->_flexDirectory->getFlexType();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getFlexDirectory()
+ */
+ public function getFlexDirectory(): FlexDirectory
+ {
+ return $this->_flexDirectory;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getTimestamp()
+ */
+ public function getTimestamp(): int
+ {
+ $timestamps = $this->getTimestamps();
+
+ return $timestamps ? max($timestamps) : time();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getCacheKey()
+ */
+ public function getCacheKey(): string
+ {
+ return $this->getTypePrefix() . $this->getFlexType() . '.' . sha1(json_encode($this->getKeys()) . $this->_keyField);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getCacheChecksum()
+ */
+ public function getCacheChecksum(): string
+ {
+ return sha1($this->getCacheKey() . json_encode($this->getTimestamps()));
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getTimestamps()
+ */
+ public function getTimestamps(): array
+ {
+ return $this->getIndexMap('storage_timestamp');
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getStorageKeys()
+ */
+ public function getStorageKeys(): array
+ {
+ return $this->getIndexMap('storage_key');
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getFlexKeys()
+ */
+ public function getFlexKeys(): array
+ {
+ // Get storage keys for the objects.
+ $keys = [];
+ $type = $this->_flexDirectory->getFlexType() . '.obj:';
+
+ foreach ($this->getEntries() as $key => $value) {
+ $keys[$key] = $value['flex_key'] ?? $type . $value['storage_key'];
+ }
+
+ return $keys;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexIndexInterface::withKeyField()
+ */
+ public function withKeyField(string $keyField = null)
+ {
+ $keyField = $keyField ?: 'key';
+ if ($keyField === $this->getKeyField()) {
+ return $this;
+ }
+
+ $type = $keyField === 'flex_key' ? $this->_flexDirectory->getFlexType() . '.obj:' : '';
+ $entries = [];
+ foreach ($this->getEntries() as $key => $value) {
+ if (!isset($value['key'])) {
+ $value['key'] = $key;
+ }
+
+ if (isset($value[$keyField])) {
+ $entries[$value[$keyField]] = $value;
+ } elseif ($keyField === 'flex_key') {
+ $entries[$type . $value['storage_key']] = $value;
+ }
+ }
+
+ return $this->createFrom($entries, $keyField);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::getIndex()
+ */
+ public function getIndex()
+ {
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexCollectionInterface::render()
+ */
+ public function render(string $layout = null, array $context = [])
+ {
+ return $this->__call('render', [$layout, $context]);
+ }
+
+ /**
+ * @param bool $prefix
+ * @return string
+ * @deprecated 1.6 Use `->getFlexType()` instead.
+ */
+ public function getType($prefix = false)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use ->getFlexType() method instead', E_USER_DEPRECATED);
+
+ $type = $prefix ? $this->getTypePrefix() : '';
+
+ return $type . $this->getFlexType();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexIndexInterface::getFlexKeys()
+ */
+ public function getIndexMap(string $indexKey = null)
+ {
+ if (null === $indexKey) {
+ return $this->getEntries();
+ }
+
+ // Get storage keys for the objects.
+ $index = [];
+ foreach ($this->getEntries() as $key => $value) {
+ $index[$key] = $value[$indexKey] ?? null;
+ }
+
+ return $index;
+ }
+
+ /**
+ * @return array
+ */
+ public function getMetaData(string $key): array
+ {
+ return $this->getEntries()[$key] ?? [];
+ }
+
+ /**
+ * @return string
+ */
+ public function getKeyField() : string
+ {
+ return $this->_keyField ?? 'storage_key';
+ }
+
+ /**
+ * @param string|null $namespace
+ * @return CacheInterface
+ */
+ public function getCache(string $namespace = null)
+ {
+ return $this->_flexDirectory->getCache($namespace);
+ }
+
+ /**
+ * @param array $orderings
+ * @return FlexIndex|FlexCollection
+ */
+ public function orderBy(array $orderings)
+ {
+ if (!$orderings || !$this->count()) {
+ return $this;
+ }
+
+ // Check if ordering needs to load the objects.
+ if (array_diff_key($orderings, $this->getIndexKeys())) {
+ return $this->__call('orderBy', [$orderings]);
+ }
+
+ // Ordering can be done by using index only.
+ $previous = null;
+ foreach (array_reverse($orderings) as $field => $ordering) {
+ $field = (string)$field;
+ if ($this->getKeyField() === $field) {
+ $keys = $this->getKeys();
+ $search = array_combine($keys, $keys) ?: [];
+ } elseif ($field === 'flex_key') {
+ $search = $this->getFlexKeys();
+ } else {
+ $search = $this->getIndexMap($field);
+ }
+
+ // Update current search to match the previous ordering.
+ if (null !== $previous) {
+ $search = array_replace($previous, $search);
+ }
+
+ // Order by current field.
+ if ($ordering === 'DESC') {
+ arsort($search, SORT_NATURAL);
+ } else {
+ asort($search, SORT_NATURAL);
+ }
+
+ $previous = $search;
+ }
+
+ return $this->createFrom(array_replace($previous, $this->getEntries()));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function call($method, array $arguments = [])
+ {
+ return $this->__call('call', [$method, $arguments]);
+ }
+
+ public function __call($name, $arguments)
+ {
+ /** @var Debugger $debugger */
+ $debugger = Grav::instance()['debugger'];
+
+ /** @var FlexCollection $className */
+ $className = $this->_flexDirectory->getCollectionClass();
+ $cachedMethods = $className::getCachedMethods();
+
+ $flexType = $this->getFlexType();
+
+ if (!empty($cachedMethods[$name])) {
+ $type = $cachedMethods[$name];
+ if ($type === 'session') {
+ /** @var Session $session */
+ $session = Grav::instance()['session'];
+ $cacheKey = $session->getId() . $session->user->username;
+ } else {
+ $cacheKey = '';
+ }
+ $key = "{$flexType}.idx." . sha1($name . '.' . $cacheKey . json_encode($arguments) . $this->getCacheKey());
+
+ $cache = $this->getCache('object');
+
+ try {
+ $result = $cache->get($key);
+
+ // Make sure the keys aren't changed if the returned type is the same index type.
+ if ($result instanceof self && $flexType === $result->getFlexType()) {
+ $result = $result->withKeyField($this->getKeyField());
+ }
+ } catch (InvalidArgumentException $e) {
+ /** @var Debugger $debugger */
+ $debugger = Grav::instance()['debugger'];
+ $debugger->addException($e);
+ }
+
+ if (!isset($result)) {
+ $collection = $this->loadCollection();
+ $result = $collection->{$name}(...$arguments);
+
+ try {
+ // If flex collection is returned, convert it back to flex index.
+ if ($result instanceof FlexCollection) {
+ $cached = $result->getFlexDirectory()->getIndex($result->getKeys(), $this->getKeyField());
+ } else {
+ $cached = $result;
+ }
+
+ $cache->set($key, $cached);
+ } catch (InvalidArgumentException $e) {
+ $debugger->addException($e);
+
+ // TODO: log error.
+ }
+ }
+ } else {
+ $collection = $this->loadCollection();
+ $result = $collection->{$name}(...$arguments);
+ if (!isset($cachedMethods[$name])) {
+ $class = \get_class($collection);
+ $debugger->addMessage("Call '{$class}:{$name}()' isn't cached", 'debug');
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * @return string
+ */
+ public function serialize()
+ {
+ return serialize(['type' => $this->getFlexType(), 'entries' => $this->getEntries()]);
+ }
+
+ /**
+ * @param string $serialized
+ */
+ public function unserialize($serialized)
+ {
+ $data = unserialize($serialized, ['allowed_classes' => false]);
+
+ $this->_flexDirectory = Grav::instance()['flex_objects']->getDirectory($data['type']);
+ $this->setEntries($data['entries']);
+ }
+
+ /**
+ * @param array $entries
+ * @param string $keyField
+ * @return static
+ */
+ protected function createFrom(array $entries, string $keyField = null)
+ {
+ $index = new static($entries, $this->_flexDirectory);
+ $index->setKeyField($keyField ?? $this->_keyField);
+
+ return $index;
+ }
+
+ /**
+ * @param string|null $keyField
+ */
+ protected function setKeyField(string $keyField = null)
+ {
+ $this->_keyField = $keyField ?? 'storage_key';
+ }
+
+ protected function getIndexKeys()
+ {
+ if (null === $this->_indexKeys) {
+ $entries = $this->getEntries();
+ $first = reset($entries);
+ if ($first) {
+ $keys = array_keys($first);
+ $keys = array_combine($keys, $keys) ?: [];
+ } else {
+ $keys = [];
+ }
+
+ $this->setIndexKeys($keys);
+ }
+
+ return $this->_indexKeys;
+ }
+
+ /**
+ * @param array $indexKeys
+ */
+ protected function setIndexKeys(array $indexKeys)
+ {
+ // Add defaults.
+ $indexKeys += [
+ 'key' => 'key',
+ 'storage_key' => 'storage_key',
+ 'storage_timestamp' => 'storage_timestamp',
+ 'flex_key' => 'flex_key'
+ ];
+
+
+ $this->_indexKeys = $indexKeys;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getTypePrefix()
+ {
+ return 'i.';
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ * @return ObjectInterface|null
+ */
+ protected function loadElement($key, $value): ?ObjectInterface
+ {
+ $objects = $this->_flexDirectory->loadObjects([$key => $value]);
+
+ return $objects ? reset($objects): null;
+ }
+
+ /**
+ * @param array|null $entries
+ * @return ObjectInterface[]
+ */
+ protected function loadElements(array $entries = null): array
+ {
+ return $this->_flexDirectory->loadObjects($entries ?? $this->getEntries());
+ }
+
+ /**
+ * @param array|null $entries
+ * @return ObjectCollectionInterface
+ */
+ protected function loadCollection(array $entries = null): CollectionInterface
+ {
+ return $this->_flexDirectory->loadCollection($entries ?? $this->getEntries(), $this->_keyField);
+ }
+
+ /**
+ * @param mixed $value
+ * @return bool
+ */
+ protected function isAllowedElement($value): bool
+ {
+ return $value instanceof FlexObject;
+ }
+
+ /**
+ * @param FlexObjectInterface $object
+ * @return mixed
+ */
+ protected function getElementMeta($object)
+ {
+ return $object->getTimestamp();
+ }
+
+ /**
+ * @param FlexStorageInterface $storage
+ * @param array $index Saved index
+ * @param array $entries Updated index
+ * @return array Compiled list of entries
+ */
+ protected static function updateIndexFile(FlexStorageInterface $storage, array $index, array $entries): array
+ {
+ // Calculate removed objects.
+ $removed = array_diff_key($index, $entries);
+
+ // First get rid of all removed objects.
+ if ($removed) {
+ $index = array_diff_key($index, $removed);
+ }
+
+ if ($entries) {
+ // Calculate difference between saved index and current data.
+ foreach ($index as $key => $entry) {
+ $storage_key = $entry['storage_key'] ?? null;
+ if (isset($entries[$storage_key]) && $entries[$storage_key]['storage_timestamp'] === $entry['storage_timestamp']) {
+ // Entry is up to date, no update needed.
+ unset($entries[$storage_key]);
+ }
+ }
+
+ if (empty($entries) && empty($removed)) {
+ // No objects were added, updated or removed.
+ return $index;
+ }
+ } elseif (!$removed) {
+ // There are no objects and nothing was removed.
+ return [];
+ }
+
+ // Index should be updated, lock the index file for saving.
+ $indexFile = static::getIndexFile($storage);
+ $indexFile->lock();
+
+ // Read all the data rows into an array.
+ $keys = array_fill_keys(array_keys($entries), null);
+ $rows = $storage->readRows($keys);
+
+ $keyField = $storage->getKeyField();
+
+ // Go through all the updated objects and refresh their index data.
+ $updated = $added = [];
+ foreach ($rows as $key => $row) {
+ if (null !== $row) {
+ $entry = ['key' => $key] + $entries[$key];
+ if ($keyField !== 'storage_key' && isset($row[$keyField])) {
+ $entry['key'] = $row[$keyField];
+ }
+ static::updateIndexData($entry, $row);
+ if (isset($row['__error'])) {
+ $entry['__error'] = true;
+ static::onException(new \RuntimeException(sprintf('Object failed to load: %s (%s)', $key, $row['__error'])));
+ }
+ if (isset($index[$key])) {
+ // Update object in the index.
+ $updated[$key] = $entry;
+ } else {
+ // Add object into the index.
+ $added[$key] = $entry;
+ }
+
+ // Either way, update the entry.
+ $index[$key] = $entry;
+ } elseif (isset($index[$key])) {
+ // Remove object from the index.
+ $removed[$key] = $index[$key];
+ unset($index[$key]);
+ }
+ }
+
+ // Sort the index before saving it.
+ ksort($index, SORT_NATURAL);
+
+ static::onChanges($index, $added, $updated, $removed);
+
+ $indexFile->save(['count' => \count($index), 'index' => $index]);
+ $indexFile->unlock();
+
+ return $index;
+ }
+
+ protected static function updateIndexData(array &$entry, array $data)
+ {
+ }
+
+ protected static function loadEntriesFromIndex(FlexStorageInterface $storage)
+ {
+ $indexFile = static::getIndexFile($storage);
+
+ $data = [];
+ try {
+ $data = (array)$indexFile->content();
+ } catch (\Exception $e) {
+ $e = new \RuntimeException(sprintf('Index failed to load: %s', $e->getMessage()), $e->getCode(), $e);
+
+ static::onException($e);
+ }
+
+ return $data['index'] ?? [];
+ }
+
+ protected static function getIndexFile(FlexStorageInterface $storage)
+ {
+ // Load saved index file.
+ $grav = Grav::instance();
+ $locator = $grav['locator'];
+ $filename = $locator->findResource($storage->getStoragePath() . '/index.yaml', true, true);
+
+ return CompiledYamlFile::instance($filename);
+ }
+
+ protected static function onException(\Exception $e)
+ {
+ $grav = Grav::instance();
+
+ /** @var Logger $logger */
+ $logger = $grav['log'];
+ $logger->addAlert($e->getMessage());
+
+ /** @var Debugger $debugger */
+ $debugger = $grav['debugger'];
+ $debugger->addException($e);
+ $debugger->addMessage($e, 'error');
+ }
+
+ protected static function onChanges(array $entries, array $added, array $updated, array $removed)
+ {
+ $message = sprintf('Index updated, %d objects (%d added, %d updated, %d removed).', \count($entries), \count($added), \count($updated), \count($removed));
+
+ $grav = Grav::instance();
+
+ /** @var Logger $logger */
+ $logger = $grav['log'];
+ $logger->addDebug($message);
+
+ /** @var Debugger $debugger */
+ $debugger = $grav['debugger'];
+ $debugger->addMessage($message, 'debug');
+ }
+
+ public function __debugInfo()
+ {
+ return [
+ 'type:private' => $this->getFlexType(),
+ 'key:private' => $this->getKey(),
+ 'entries_key:private' => $this->getKeyField(),
+ 'entries:private' => $this->getEntries()
+ ];
+ }
+}
diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php
new file mode 100644
index 0000000..7fbdbc0
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/FlexObject.php
@@ -0,0 +1,877 @@
+ true,
+ 'getType' => true,
+ 'getFlexType' => true,
+ 'getFlexDirectory' => true,
+ 'getCacheKey' => true,
+ 'getCacheChecksum' => true,
+ 'getTimestamp' => true,
+ 'value' => true,
+ 'exists' => true,
+ 'hasProperty' => true,
+ 'getProperty' => true,
+
+ // FlexAclTrait
+ 'isAuthorized' => 'session',
+ ];
+ }
+
+ public static function createFromStorage(array $elements, array $storage, FlexDirectory $directory, bool $validate = false)
+ {
+ $instance = new static($elements, $storage['key'], $directory, $validate);
+ $instance->setStorage($storage);
+
+ return $instance;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::__construct()
+ */
+ public function __construct(array $elements, $key, FlexDirectory $directory, bool $validate = false)
+ {
+ $this->_flexDirectory = $directory;
+
+ if ($validate) {
+ $blueprint = $this->getFlexDirectory()->getBlueprint();
+
+ $blueprint->validate($elements);
+
+ $elements = $blueprint->filter($elements);
+ }
+
+ $this->filterElements($elements);
+
+ $this->objectConstruct($elements, $key);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getFlexType()
+ */
+ public function getFlexType(): string
+ {
+ return $this->_flexDirectory->getFlexType();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getFlexDirectory()
+ */
+ public function getFlexDirectory(): FlexDirectory
+ {
+ return $this->_flexDirectory;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getTimestamp()
+ */
+ public function getTimestamp(): int
+ {
+ return $this->_storage['storage_timestamp'] ?? 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getCacheKey()
+ */
+ public function getCacheKey(): string
+ {
+ return $this->getTypePrefix() . $this->getFlexType() . '.' . $this->getStorageKey();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getCacheChecksum()
+ */
+ public function getCacheChecksum(): string
+ {
+ return (string)$this->getTimestamp();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::search()
+ */
+ public function search(string $search, $properties = null, array $options = null): float
+ {
+ $options = $options ?? $this->getFlexDirectory()->getConfig('data.search.options', []);
+ $properties = $properties ?? $this->getFlexDirectory()->getConfig('data.search.fields', []);
+ if (!$properties) {
+ foreach ($this->getFlexDirectory()->getConfig('admin.list.fields', []) as $property => $value) {
+ if (!empty($value['link'])) {
+ $properties[] = $property;
+ }
+ }
+ }
+
+ $weight = 0;
+ foreach ((array)$properties as $property) {
+ $weight += $this->searchNestedProperty($property, $search, $options);
+ }
+
+ return $weight > 0 ? min($weight, 1) : 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see ObjectInterface::getFlexKey()
+ */
+ public function getKey()
+ {
+ return $this->_key ?: $this->getFlexType() . '@@' . spl_object_hash($this);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getFlexKey()
+ */
+ public function getFlexKey(): string
+ {
+ return $this->_storage['flex_key'] ?? $this->_flexDirectory->getFlexType() . '.obj:' . $this->getStorageKey();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getStorageKey()
+ */
+ public function getStorageKey(): string
+ {
+ return $this->_storage['storage_key'] ?? $this->getTypePrefix() . $this->getFlexType() . '@@' . spl_object_hash($this);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getMetaData()
+ */
+ public function getMetaData(): array
+ {
+ return $this->getStorage();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::exists()
+ */
+ public function exists(): bool
+ {
+ $key = $this->getStorageKey();
+
+ return $key && $this->getFlexDirectory()->getStorage()->hasKey($key);
+ }
+
+ /**
+ * @param string $property
+ * @param string $search
+ * @param array|null $options
+ * @return float
+ */
+ public function searchProperty(string $property, string $search, array $options = null): float
+ {
+ $options = $options ?? $this->getFlexDirectory()->getConfig('data.search.options', []);
+ $value = $this->getProperty($property);
+
+ return $this->searchValue($property, $value, $search, $options);
+ }
+
+ /**
+ * @param string $property
+ * @param string $search
+ * @param array|null $options
+ * @return float
+ */
+ public function searchNestedProperty(string $property, string $search, array $options = null): float
+ {
+ $options = $options ?? $this->getFlexDirectory()->getConfig('data.search.options', []);
+ $value = $this->getNestedProperty($property);
+
+ return $this->searchValue($property, $value, $search, $options);
+ }
+
+ /**
+ * @param string $name
+ * @param mixed $value
+ * @param string $search
+ * @param array|null $options
+ * @return float
+ */
+ protected function searchValue(string $name, $value, string $search, array $options = null): float
+ {
+ $search = trim($search);
+
+ if ($search === '') {
+ return 0;
+ }
+
+ if (!\is_string($value) || $value === '') {
+ return 0;
+ }
+
+ $tested = false;
+ if (($tested |= !empty($options['starts_with'])) && Utils::startsWith($value, $search, $options['case_sensitive'] ?? false)) {
+ return (float)$options['starts_with'];
+ }
+ if (($tested |= !empty($options['ends_with'])) && Utils::endsWith($value, $search, $options['case_sensitive'] ?? false)) {
+ return (float)$options['ends_with'];
+ }
+ if ((!$tested || !empty($options['contains'])) && Utils::contains($value, $search, $options['case_sensitive'] ?? false)) {
+ return (float)($options['contains'] ?? 1);
+ }
+
+ return 0;
+ }
+
+ /**
+ * Get any changes based on data sent to update
+ *
+ * @return array
+ */
+ public function getChanges(): array
+ {
+ return $this->_changes ?? [];
+ }
+
+ /**
+ * @return string
+ */
+ protected function getTypePrefix(): string
+ {
+ return 'o.';
+ }
+
+ /**
+ * @param bool $prefix
+ * @return string
+ * @deprecated 1.6 Use `->getFlexType()` instead.
+ */
+ public function getType($prefix = false)
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use ->getFlexType() method instead', E_USER_DEPRECATED);
+
+ $type = $prefix ? $this->getTypePrefix() : '';
+
+ return $type . $this->getFlexType();
+ }
+
+ /**
+ * Alias of getBlueprint()
+ *
+ * @return Blueprint
+ * @deprecated 1.6 Admin compatibility
+ */
+ public function blueprints()
+ {
+ return $this->getBlueprint();
+ }
+
+ /**
+ * @param string|null $namespace
+ * @return CacheInterface
+ */
+ public function getCache(string $namespace = null)
+ {
+ return $this->_flexDirectory->getCache($namespace);
+ }
+
+ /**
+ * @param string|null $key
+ * @return $this
+ */
+ public function setStorageKey($key = null)
+ {
+ $this->_storage['storage_key'] = $key;
+
+ return $this;
+ }
+
+ /**
+ * @param int $timestamp
+ * @return $this
+ */
+ public function setTimestamp($timestamp = null)
+ {
+ $this->_storage['storage_timestamp'] = $timestamp ?? time();
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::render()
+ */
+ public function render(string $layout = null, array $context = [])
+ {
+ if (null === $layout) {
+ $layout = 'default';
+ }
+
+ $type = $this->getFlexType();
+
+ $grav = Grav::instance();
+
+ /** @var Debugger $debugger */
+ $debugger = $grav['debugger'];
+ $debugger->startTimer('flex-object-' . ($debugKey = uniqid($type, false)), 'Render Object ' . $type . ' (' . $layout . ')');
+
+ $cache = $key = null;
+ foreach ($context as $value) {
+ if (!\is_scalar($value)) {
+ $key = false;
+ }
+ }
+
+ if ($key !== false) {
+ $key = md5($this->getCacheKey() . '.' . $layout . json_encode($context));
+ $cache = $this->getCache('render');
+ }
+
+ try {
+ $data = $cache && $key ? $cache->get($key) : null;
+
+ $block = $data ? HtmlBlock::fromArray($data) : null;
+ } catch (InvalidArgumentException $e) {
+ $debugger->addException($e);
+
+ $block = null;
+ } catch (\InvalidArgumentException $e) {
+ $debugger->addException($e);
+
+ $block = null;
+ }
+
+ $checksum = $this->getCacheChecksum();
+ if ($block && $checksum !== $block->getChecksum()) {
+ $block = null;
+ }
+
+ if (!$block) {
+ $block = HtmlBlock::create($key ?: null);
+ $block->setChecksum($checksum);
+ if ($key === false) {
+ $block->disableCache();
+ }
+
+ $grav->fireEvent('onFlexObjectRender', new Event([
+ 'object' => $this,
+ 'layout' => &$layout,
+ 'context' => &$context
+ ]));
+
+ $output = $this->getTemplate($layout)->render(
+ ['grav' => $grav, 'config' => $grav['config'], 'block' => $block, 'object' => $this, 'layout' => $layout] + $context
+ );
+
+ if ($debugger->enabled()) {
+ $name = $this->getKey() . ' (' . $type . ')';
+ $output = "\n\n{$output}\n\n";
+ }
+
+ $block->setContent($output);
+
+ try {
+ $cache && $key && $block->isCached() && $cache->set($key, $block->toArray());
+ } catch (InvalidArgumentException $e) {
+ $debugger->addException($e);
+ }
+ }
+
+ $debugger->stopTimer('flex-object-' . $debugKey);
+
+ return $block;
+ }
+
+ /**
+ * @return array
+ */
+ public function jsonSerialize()
+ {
+ return $this->getElements();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::prepareStorage()
+ */
+ public function prepareStorage(): array
+ {
+ return $this->getElements();
+ }
+
+ /**
+ * @param string $name
+ * @return $this
+ */
+ public function triggerEvent($name)
+ {
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::update()
+ */
+ public function update(array $data, array $files = [])
+ {
+ if ($data) {
+ $blueprint = $this->getBlueprint();
+
+ // Process updated data through the object filters.
+ $this->filterElements($data);
+
+ // Get currently stored data.
+ $elements = $this->getElements();
+
+ // Merge existing object to the test data to be validated.
+ $test = $blueprint->mergeData($elements, $data);
+
+ // Validate and filter elements and throw an error if any issues were found.
+ $blueprint->validate($test + ['storage_key' => $this->getStorageKey(), 'timestamp' => $this->getTimestamp()]);
+ $data = $blueprint->filter($data, false, true);
+
+ // Finally update the object.
+ foreach ($blueprint->flattenData($data) as $key => $value) {
+ if ($value === null) {
+ $this->unsetNestedProperty($key);
+ } else {
+ $this->setNestedProperty($key, $value);
+ }
+ }
+
+ // Store the changes
+ $this->_changes = Utils::arrayDiffMultidimensional($this->getElements(), $elements);
+ }
+
+ if ($files && method_exists($this, 'setUpdatedMedia')) {
+ $this->setUpdatedMedia($files);
+ }
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::create()
+ */
+ public function create(string $key = null)
+ {
+ if ($key) {
+ $this->setStorageKey($key);
+ }
+
+ if ($this->exists()) {
+ throw new \RuntimeException('Cannot create new object (Already exists)');
+ }
+
+ return $this->save();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::save()
+ */
+ public function save()
+ {
+ $this->triggerEvent('onBeforeSave');
+
+ $result = $this->getFlexDirectory()->getStorage()->replaceRows([$this->getStorageKey() => $this->prepareStorage()]);
+
+ $value = reset($result);
+ $storageKey = (string)key($result);
+ if ($value && $storageKey) {
+ $this->setStorageKey($storageKey);
+ if (!$this->hasKey()) {
+ $this->setKey($storageKey);
+ }
+ }
+
+ // FIXME: For some reason locator caching isn't cleared for the file, investigate!
+ $locator = Grav::instance()['locator'];
+ $locator->clearCache();
+
+ // Make sure that the object exists before continuing (just in case).
+ if (!$this->exists()) {
+ throw new \RuntimeException('Saving failed: Object does not exist!');
+ }
+
+ if (method_exists($this, 'saveUpdatedMedia')) {
+ $this->saveUpdatedMedia();
+ }
+
+ try {
+ $this->getFlexDirectory()->clearCache();
+ if (method_exists($this, 'clearMediaCache')) {
+ $this->clearMediaCache();
+ }
+ } catch (\Exception $e) {
+ /** @var Debugger $debugger */
+ $debugger = Grav::instance()['debugger'];
+ $debugger->addException($e);
+
+ // Caching failed, but we can ignore that for now.
+ }
+
+ $this->triggerEvent('onAfterSave');
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::delete()
+ */
+ public function delete()
+ {
+ $this->triggerEvent('onBeforeDelete');
+
+ $this->getFlexDirectory()->getStorage()->deleteRows([$this->getStorageKey() => $this->prepareStorage()]);
+
+ try {
+ $this->getFlexDirectory()->clearCache();
+ if (method_exists($this, 'clearMediaCache')) {
+ $this->clearMediaCache();
+ }
+ } catch (\Exception $e) {
+ /** @var Debugger $debugger */
+ $debugger = Grav::instance()['debugger'];
+ $debugger->addException($e);
+
+ // Caching failed, but we can ignore that for now.
+ }
+
+ $this->triggerEvent('onAfterDelete');
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getBlueprint()
+ */
+ public function getBlueprint(string $name = '')
+ {
+ return $this->_flexDirectory->getBlueprint($name ? '.' . $name : $name);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getForm()
+ */
+ public function getForm(string $name = '', array $form = null)
+ {
+ if (!isset($this->_forms[$name])) {
+ $this->_forms[$name] = $this->createFormObject($name, $form);
+ }
+
+ return $this->_forms[$name];
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getDefaultValue()
+ */
+ public function getDefaultValue(string $name, string $separator = null)
+ {
+ $separator = $separator ?: '.';
+ $path = explode($separator, $name) ?: [];
+ $offset = array_shift($path) ?? '';
+
+ $current = $this->getDefaultValues();
+
+ if (!isset($current[$offset])) {
+ return null;
+ }
+
+ $current = $current[$offset];
+
+ while ($path) {
+ $offset = array_shift($path);
+
+ if ((\is_array($current) || $current instanceof \ArrayAccess) && isset($current[$offset])) {
+ $current = $current[$offset];
+ } elseif (\is_object($current) && isset($current->{$offset})) {
+ $current = $current->{$offset};
+ } else {
+ return null;
+ }
+ };
+
+ return $current;
+ }
+
+ /**
+ * @return array
+ */
+ public function getDefaultValues(): array
+ {
+ return $this->getBlueprint()->getDefaults();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexObjectInterface::getFormValue()
+ */
+ public function getFormValue(string $name, $default = null, string $separator = null)
+ {
+ if ($name === 'storage_key') {
+ return $this->getStorageKey();
+ }
+ if ($name === 'storage_timestamp') {
+ return $this->getTimestamp();
+ }
+
+ return $this->getNestedProperty($name, $default, $separator);
+ }
+
+ /**
+ * @param string $name
+ * @param mixed|null $default
+ * @param string|null $separator
+ * @return mixed
+ *
+ * @deprecated 1.6 Use ->getFormValue() method instead.
+ */
+ public function value($name, $default = null, $separator = null)
+ {
+ return $this->getFormValue($name, $default, $separator);
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->getFlexKey();
+ }
+
+ public function __debugInfo()
+ {
+ return [
+ 'type:private' => $this->getFlexType(),
+ 'key:private' => $this->getKey(),
+ 'elements:private' => $this->getElements(),
+ 'storage:private' => $this->getStorage()
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ protected function doSerialize(): array
+ {
+ return [
+ 'type' => $this->getFlexType(),
+ 'key' => $this->getKey(),
+ 'elements' => $this->getElements(),
+ 'storage' => $this->getStorage()
+ ];
+ }
+
+ /**
+ * @param array $serialized
+ */
+ protected function doUnserialize(array $serialized): void
+ {
+ $type = $serialized['type'] ?? 'unknown';
+
+ if (!isset($serialized['key'], $serialized['type'], $serialized['elements'])) {
+ throw new \InvalidArgumentException("Cannot unserialize '{$type}': Bad data");
+ }
+
+ $grav = Grav::instance();
+ /** @var Flex|null $flex */
+ $flex = $grav['flex_objects'] ?? null;
+ $directory = $flex ? $flex->getDirectory($type) : null;
+ if (!$directory) {
+ throw new \InvalidArgumentException("Cannot unserialize '{$type}': Not found");
+ }
+ $this->setFlexDirectory($directory);
+ $this->setStorage($serialized['storage']);
+ $this->setKey($serialized['key']);
+ $this->setElements($serialized['elements']);
+ }
+
+ /**
+ * @param FlexDirectory $directory
+ */
+ public function setFlexDirectory(FlexDirectory $directory): void
+ {
+ $this->_flexDirectory = $directory;
+ }
+ /**
+ * @param array $storage
+ */
+ protected function setStorage(array $storage) : void
+ {
+ $this->_storage = $storage;
+ }
+
+ /**
+ * @return array
+ */
+ protected function getStorage() : array
+ {
+ return $this->_storage ?? [];
+ }
+
+ /**
+ * @param string $type
+ * @param string $property
+ * @return FlexCollectionInterface
+ */
+ protected function getCollectionByProperty($type, $property)
+ {
+ $directory = $this->getRelatedDirectory($type);
+ $collection = $directory->getCollection();
+ $list = $this->getNestedProperty($property) ?: [];
+
+ /** @var FlexCollection $collection */
+ $collection = $collection->filter(function ($object) use ($list) { return \in_array($object->id, $list, true); });
+
+ return $collection;
+ }
+
+ /**
+ * @param string $type
+ * @return FlexDirectory
+ * @throws \RuntimeException
+ */
+ protected function getRelatedDirectory($type): FlexDirectory
+ {
+ /** @var Flex $flex */
+ $flex = Grav::instance()['flex_objects'];
+ $directory = $flex->getDirectory($type);
+ if (!$directory) {
+ throw new \RuntimeException(ucfirst($type). ' directory does not exist!');
+ }
+
+ return $directory;
+ }
+
+ /**
+ * @param string $layout
+ * @return Template|TemplateWrapper
+ * @throws LoaderError
+ * @throws SyntaxError
+ */
+ protected function getTemplate($layout)
+ {
+ $grav = Grav::instance();
+
+ /** @var Twig $twig */
+ $twig = $grav['twig'];
+
+ try {
+ return $twig->twig()->resolveTemplate(
+ [
+ "flex-objects/layouts/{$this->getFlexType()}/object/{$layout}.html.twig",
+ "flex-objects/layouts/_default/object/{$layout}.html.twig"
+ ]
+ );
+ } catch (LoaderError $e) {
+ /** @var Debugger $debugger */
+ $debugger = Grav::instance()['debugger'];
+ $debugger->addException($e);
+
+ return $twig->twig()->resolveTemplate(['flex-objects/layouts/404.html.twig']);
+ }
+ }
+
+ /**
+ * Filter data coming to constructor or $this->update() request.
+ *
+ * NOTE: The incoming data can be an arbitrary array so do not assume anything from its content.
+ *
+ * @param array $elements
+ */
+ protected function filterElements(array &$elements): void
+ {
+ if (!empty($elements['storage_key'])) {
+ $this->_storage['storage_key'] = trim($elements['storage_key']);
+ }
+ if (!empty($elements['storage_timestamp'])) {
+ $this->_storage['storage_timestamp'] = (int)$elements['storage_timestamp'];
+ }
+
+ unset ($elements['storage_key'], $elements['storage_timestamp'], $elements['_post_entries_save']);
+ }
+
+ /**
+ * This methods allows you to override form objects in child classes.
+ *
+ * @param string $name Form name
+ * @param array|null $form Form fields
+ * @return FlexFormInterface
+ */
+ protected function createFormObject(string $name, array $form = null)
+ {
+ return new FlexForm($name, $this, $form);
+ }
+}
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php
new file mode 100644
index 0000000..cfcb8a9
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php
@@ -0,0 +1,32 @@
+ 'ASC'|'DESC', ...].
+ *
+ * @return FlexCollectionInterface Returns a sorted version from the collection.
+ */
+ public function sort(array $orderings);
+
+ /**
+ * Filter collection by filter array with keys and values.
+ *
+ * @param array $filters
+ * @return FlexCollectionInterface
+ */
+ public function filterBy(array $filters);
+
+ /**
+ * Get timestamps from all the objects in the collection.
+ *
+ * This method can be used for example in caching.
+ *
+ * @return int[] Returns [key => timestamp, ...] pairs.
+ */
+ public function getTimestamps(): array;
+
+ /**
+ * Get storage keys from all the objects in the collection.
+ *
+ * @see FlexDirectory::getObject() If you want to get Flex Object from the Flex Directory.
+ *
+ * @return string[] Returns [key => storage_key, ...] pairs.
+ */
+ public function getStorageKeys(): array;
+
+ /**
+ * Get Flex keys from all the objects in the collection.
+ *
+ * @see Flex::getObjects() If you want to get list of Flex Objects from any Flex Directory.
+ *
+ * @return string[] Returns[key => flex_key, ...] pairs.
+ */
+ public function getFlexKeys(): array;
+
+ /**
+ * Return new collection with a different key.
+ *
+ * @param string|null $keyField Switch key field of the collection.
+ *
+ * @return FlexCollectionInterface Returns a new Flex Collection with new key field.
+ * @api
+ */
+ public function withKeyField(string $keyField = null);
+
+ /**
+ * Get Flex Index from the Flex Collection.
+ *
+ * @return FlexIndexInterface Returns a Flex Index from the current collection.
+ */
+ public function getIndex();
+}
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php
new file mode 100644
index 0000000..482aef2
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php
@@ -0,0 +1,64 @@
+ [storage_key => xxx, storage_timestamp => 123456, ...]]
+ */
+ public static function loadEntriesFromStorage(FlexStorageInterface $storage): array;
+
+ /**
+ * Return new collection with a different key.
+ *
+ * @param string|null $keyField Switch key field of the collection.
+ *
+ * @return FlexIndexInterface Returns a new Flex Collection with new key field.
+ * @api
+ */
+ public function withKeyField(string $keyField = null);
+
+ /**
+ * @param string $indexKey
+ * @return array
+ */
+ public function getIndexMap(string $indexKey = null);
+}
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
new file mode 100644
index 0000000..a10ee84
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
@@ -0,0 +1,208 @@
+ [storage_key => key, storage_timestamp => timestamp], ...]`.
+ */
+ public function getExistingKeys(): array;
+
+ /**
+ * Check if the key exists in the storage.
+ *
+ * @param string $key Storage key of an object.
+ *
+ * @return bool Returns `true` if the key exists in the storage, `false` otherwise.
+ */
+ public function hasKey(string $key): bool;
+
+ /**
+ * Check if the key exists in the storage.
+ *
+ * @param string[] $keys Storage key of an object.
+ *
+ * @return bool[] Returns keys with `true` if the key exists in the storage, `false` otherwise.
+ */
+ public function hasKeys(array $keys): array;
+
+ /**
+ * Create new rows into the storage.
+ *
+ * New keys will be assigned when the objects are created.
+ *
+ * @param array $rows List of rows as `[row, ...]`.
+ *
+ * @return array Returns created rows as `[key => row, ...] pairs.
+ */
+ public function createRows(array $rows): array;
+
+ /**
+ * Read rows from the storage.
+ *
+ * If you pass object or array as value, that value will be used to save I/O.
+ *
+ * @param array $rows Array of `[key => row, ...]` pairs.
+ * @param array $fetched Optional reference to store only fetched items.
+ *
+ * @return array Returns rows. Note that non-existing rows will have `null` as their value.
+ */
+ public function readRows(array $rows, array &$fetched = null): array;
+
+ /**
+ * Update existing rows in the storage.
+ *
+ * @param array $rows Array of `[key => row, ...]` pairs.
+ *
+ * @return array Returns updated rows. Note that non-existing rows will not be saved and have `null` as their value.
+ */
+ public function updateRows(array $rows): array;
+
+ /**
+ * Delete rows from the storage.
+ *
+ * @param array $rows Array of `[key => row, ...]` pairs.
+ *
+ * @return array Returns deleted rows. Note that non-existing rows have `null` as their value.
+ */
+ public function deleteRows(array $rows): array;
+
+ /**
+ * Replace rows regardless if they exist or not.
+ *
+ * All rows should have a specified key for replace to work properly.
+ *
+ * @param array $rows Array of `[key => row, ...]` pairs.
+ *
+ * @return array Returns both created and updated rows.
+ */
+ public function replaceRows(array $rows): array;
+
+ /**
+ * @param string $src
+ * @param string $dst
+ *
+ * @return bool
+ */
+ public function renameRow(string $src, string $dst): bool;
+
+ /**
+ * Get filesystem path for the collection or object storage.
+ *
+ * @param string|null $key Optional storage key.
+ *
+ * @return string Path in the filesystem. Can be URI.
+ */
+ public function getStoragePath(string $key = null): string;
+
+ /**
+ * Get filesystem path for the collection or object media.
+ *
+ * @param string|null $key Optional storage key.
+ *
+ * @return string Path in the filesystem. Can be URI.
+ */
+ public function getMediaPath(string $key = null): string;
+}
diff --git a/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php b/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php
new file mode 100644
index 0000000..cc460cc
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php
@@ -0,0 +1,154 @@
+hasKey((string)$key);
+ }
+
+ return $list;
+ }
+
+ /**
+ * @return string
+ */
+ public function getKeyField(): string
+ {
+ return $this->keyField;
+ }
+
+ protected function initDataFormatter($formatter): void
+ {
+ // Initialize formatter.
+ if (!\is_array($formatter)) {
+ $formatter = ['class' => $formatter];
+ }
+ $formatterClassName = $formatter['class'] ?? JsonFormatter::class;
+ $formatterOptions = $formatter['options'] ?? [];
+
+ $this->dataFormatter = new $formatterClassName($formatterOptions);
+ }
+
+ /**
+ * @param string $filename
+ * @return null|string
+ */
+ protected function detectDataFormatter(string $filename): ?string
+ {
+ if (preg_match('|(\.[a-z0-9]*)$|ui', $filename, $matches)) {
+ switch ($matches[1]) {
+ case '.json':
+ return JsonFormatter::class;
+ case '.yaml':
+ return YamlFormatter::class;
+ case '.md':
+ return MarkdownFormatter::class;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @param string $filename
+ * @return File
+ */
+ protected function getFile(string $filename)
+ {
+ $filename = $this->resolvePath($filename);
+
+ switch ($this->dataFormatter->getDefaultFileExtension()) {
+ case '.json':
+ $file = CompiledJsonFile::instance($filename);
+ break;
+ case '.yaml':
+ $file = CompiledYamlFile::instance($filename);
+ break;
+ case '.md':
+ $file = CompiledMarkdownFile::instance($filename);
+ break;
+ default:
+ throw new RuntimeException('Unknown extension type ' . $this->dataFormatter->getDefaultFileExtension());
+ }
+
+ return $file;
+ }
+
+ /**
+ * @param string $path
+ * @return string
+ */
+ protected function resolvePath(string $path): string
+ {
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+
+ if (!$locator->isStream($path)) {
+ return $path;
+ }
+
+ return (string)($locator->findResource($path) ?: $locator->findResource($path, true, true));
+ }
+
+ /**
+ * Generates a random, unique key for the row.
+ *
+ * @return string
+ */
+ protected function generateKey(): string
+ {
+ return substr(hash('sha256', random_bytes(32)), 0, 32);
+ }
+
+ /**
+ * Checks if a key is valid.
+ *
+ * @param string $key
+ * @return bool
+ */
+ protected function validateKey(string $key): bool
+ {
+ return (bool) preg_match('/^[^\\/\\?\\*:;{}\\\\\\n]+$/u', $key);
+ }
+}
diff --git a/system/src/Grav/Framework/Flex/Storage/FileStorage.php b/system/src/Grav/Framework/Flex/Storage/FileStorage.php
new file mode 100644
index 0000000..e263e6c
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/Storage/FileStorage.php
@@ -0,0 +1,82 @@
+dataPattern = '{FOLDER}/{KEY}';
+
+ if (!isset($options['formatter']) && isset($options['pattern'])) {
+ $options['formatter'] = $this->detectDataFormatter($options['pattern']);
+ }
+
+ parent::__construct($options);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::getMediaPath()
+ */
+ public function getMediaPath(string $key = null): string
+ {
+ return $key ? \dirname($this->getStoragePath($key)) . '/' . $key : $this->getStoragePath();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getKeyFromPath(string $path): string
+ {
+ return basename($path, $this->dataFormatter->getDefaultFileExtension());
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function buildIndex(): array
+ {
+ if (!file_exists($this->getStoragePath())) {
+ return [];
+ }
+
+ $flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS;
+ $iterator = new \FilesystemIterator($this->getStoragePath(), $flags);
+ $list = [];
+ /** @var \SplFileInfo $info */
+ foreach ($iterator as $filename => $info) {
+ if (!$info->isFile() || !($key = $this->getKeyFromPath($filename)) || strpos($info->getFilename(), '.') === 0) {
+ continue;
+ }
+
+ $list[$key] = [
+ 'storage_key' => $key,
+ 'storage_timestamp' => $info->getMTime()
+ ];
+ }
+
+ ksort($list, SORT_NATURAL);
+
+ return $list;
+ }
+}
diff --git a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php
new file mode 100644
index 0000000..76397c2
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php
@@ -0,0 +1,470 @@
+initDataFormatter($options['formatter'] ?? []);
+ $this->initOptions($options);
+
+ // Make sure that the data folder exists.
+ $folder = $this->resolvePath($this->dataFolder);
+ if (!file_exists($folder)) {
+ try {
+ Folder::create($folder);
+ } catch (\RuntimeException $e) {
+ throw new \RuntimeException(sprintf('Flex: %s', $e->getMessage()));
+ }
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::getExistingKeys()
+ */
+ public function getExistingKeys(): array
+ {
+ return $this->buildIndex();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::hasKey()
+ */
+ public function hasKey(string $key): bool
+ {
+ return $key && strpos($key, '@@') === false && file_exists($this->getPathFromKey($key));
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::createRows()
+ */
+ public function createRows(array $rows): array
+ {
+ $list = [];
+ foreach ($rows as $key => $row) {
+ // Create new file and save it.
+ $key = $this->getNewKey();
+ $path = $this->getPathFromKey($key);
+ $file = $this->getFile($path);
+ $list[$key] = $this->saveFile($file, $row);
+ }
+
+ return $list;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::readRows()
+ */
+ public function readRows(array $rows, array &$fetched = null): array
+ {
+ $list = [];
+ foreach ($rows as $key => $row) {
+ if (null === $row || (!\is_object($row) && !\is_array($row))) {
+ // Only load rows which haven't been loaded before.
+ $key = (string)$key;
+ if (!$this->hasKey($key)) {
+ $list[$key] = null;
+ } else {
+ $path = $this->getPathFromKey($key);
+ $file = $this->getFile($path);
+ $list[$key] = $this->loadFile($file);
+ }
+ if (null !== $fetched) {
+ $fetched[$key] = $list[$key];
+ }
+ } else {
+ // Keep the row if it has been loaded.
+ $list[$key] = $row;
+ }
+ }
+
+ return $list;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::updateRows()
+ */
+ public function updateRows(array $rows): array
+ {
+ $list = [];
+ foreach ($rows as $key => $row) {
+ $key = (string)$key;
+ if (!$this->hasKey($key)) {
+ $list[$key] = null;
+ } else {
+ $path = $this->getPathFromKey($key);
+ $file = $this->getFile($path);
+ $list[$key] = $this->saveFile($file, $row);
+ }
+ }
+
+ return $list;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::deleteRows()
+ */
+ public function deleteRows(array $rows): array
+ {
+ $list = [];
+ foreach ($rows as $key => $row) {
+ $key = (string)$key;
+ if (!$this->hasKey($key)) {
+ $list[$key] = null;
+ } else {
+ $path = $this->getPathFromKey($key);
+ $file = $this->getFile($path);
+ $list[$key] = $this->deleteFile($file);
+
+ $storage = $this->getStoragePath($key);
+ $media = $this->getMediaPath($key);
+
+ $this->deleteFolder($storage, true);
+ $media && $this->deleteFolder($media, true);
+ }
+ }
+
+ return $list;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::replaceRows()
+ */
+ public function replaceRows(array $rows): array
+ {
+ $list = [];
+ foreach ($rows as $key => $row) {
+ $key = (string)$key;
+ if (strpos($key, '@@')) {
+ $key = $this->getNewKey();
+ }
+ $path = $this->getPathFromKey($key);
+ $file = $this->getFile($path);
+ $list[$key] = $this->saveFile($file, $row);
+ }
+
+ return $list;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::renameRow()
+ */
+ public function renameRow(string $src, string $dst): bool
+ {
+ if ($this->hasKey($dst)) {
+ throw new \RuntimeException("Cannot rename object: key '{$dst}' is already taken");
+ }
+
+ if (!$this->hasKey($src)) {
+ return false;
+ }
+
+ return $this->moveFolder($this->getMediaPath($src), $this->getMediaPath($dst));
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::getStoragePath()
+ */
+ public function getStoragePath(string $key = null): string
+ {
+ if (null === $key) {
+ $path = $this->dataFolder;
+ } else {
+ $path = sprintf($this->dataPattern, $this->dataFolder, $key, substr($key, 0, 2));
+ }
+
+ return $path;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::getMediaPath()
+ */
+ public function getMediaPath(string $key = null): string
+ {
+ return null !== $key ? \dirname($this->getStoragePath($key)) : $this->getStoragePath();
+ }
+
+ /**
+ * Get filesystem path from the key.
+ *
+ * @param string $key
+ * @return string
+ */
+ public function getPathFromKey(string $key): string
+ {
+ return sprintf($this->dataPattern, $this->dataFolder, $key, substr($key, 0, 2));
+ }
+
+ /**
+ * @param File $file
+ * @return array|null
+ */
+ protected function loadFile(File $file): ?array
+ {
+ if (!$file->exists()) {
+ return null;
+ }
+
+ try {
+ $content = (array)$file->content();
+ if (isset($content[0])) {
+ throw new \RuntimeException('Broken object file.');
+ }
+ } catch (\RuntimeException $e) {
+ $content = ['__error' => $e->getMessage()];
+ }
+
+ return $content;
+ }
+
+ /**
+ * @param File $file
+ * @param array $data
+ * @return array
+ */
+ protected function saveFile(File $file, array $data): array
+ {
+ try {
+ $file->save($data);
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ if ($locator->isStream($file->filename())) {
+ $locator->clearCache($file->filename());
+ }
+ } catch (\RuntimeException $e) {
+ throw new \RuntimeException(sprintf('Flex saveFile(%s): %s', $file->filename(), $e->getMessage()));
+ }
+
+ return $data;
+ }
+
+ /**
+ * @param File $file
+ * @return array|string
+ */
+ protected function deleteFile(File $file)
+ {
+ try {
+ $data = $file->content();
+ $file->delete();
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ if ($locator->isStream($file->filename())) {
+ $locator->clearCache($file->filename());
+ }
+ } catch (\RuntimeException $e) {
+ throw new \RuntimeException(sprintf('Flex deleteFile(%s): %s', $file->filename(), $e->getMessage()));
+ }
+
+ return $data;
+ }
+
+ /**
+ * @param string $src
+ * @param string $dst
+ * @return bool
+ */
+ protected function moveFolder(string $src, string $dst): bool
+ {
+ try {
+ Folder::move($this->resolvePath($src), $this->resolvePath($dst));
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ if ($locator->isStream($src) || $locator->isStream($dst)) {
+ $locator->clearCache();
+ }
+ } catch (\RuntimeException $e) {
+ throw new \RuntimeException(sprintf('Flex moveFolder(%s, %s): %s', $src, $dst, $e->getMessage()));
+ }
+
+ return true;
+ }
+
+ /**
+ * @param string $path
+ * @param bool $include_target
+ * @return bool
+ */
+ protected function deleteFolder(string $path, bool $include_target = false): bool
+ {
+ try {
+ $success = Folder::delete($this->resolvePath($path), $include_target);
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+ if ($locator->isStream($path)) {
+ $locator->clearCache();
+ }
+
+ return $success;
+ } catch (\RuntimeException $e) {
+ throw new \RuntimeException(sprintf('Flex deleteFolder(%s): %s', $path, $e->getMessage()));
+ }
+ }
+
+ /**
+ * Get key from the filesystem path.
+ *
+ * @param string $path
+ * @return string
+ */
+ protected function getKeyFromPath(string $path): string
+ {
+ return basename($path);
+ }
+
+ /**
+ * Returns list of all stored keys in [key => timestamp] pairs.
+ *
+ * @return array
+ */
+ protected function buildIndex(): array
+ {
+ $path = $this->getStoragePath();
+ if (!file_exists($path)) {
+ return [];
+ }
+
+ if ($this->prefixed) {
+ $list = $this->buildPrefixedIndexFromFilesystem($path);
+ } else {
+ $list = $this->buildIndexFromFilesystem($path);
+ }
+
+ ksort($list, SORT_NATURAL);
+
+ return $list;
+ }
+
+ protected function buildIndexFromFilesystem($path)
+ {
+ $flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS;
+
+ $iterator = new \FilesystemIterator($path, $flags);
+ $list = [];
+ /** @var \SplFileInfo $info */
+ foreach ($iterator as $filename => $info) {
+ if (!$info->isDir()) {
+ continue;
+ }
+
+ $key = $this->getKeyFromPath($filename);
+ $filename = $this->getPathFromKey($key);
+ $modified = is_file($filename) ? filemtime($filename) : null;
+ if (null === $modified) {
+ continue;
+ }
+
+ $list[$key] = [
+ 'storage_key' => $key,
+ 'storage_timestamp' => $modified
+ ];
+ }
+
+ return $list;
+ }
+
+ protected function buildPrefixedIndexFromFilesystem($path)
+ {
+ $flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS;
+
+ $iterator = new \FilesystemIterator($path, $flags);
+ $list = [];
+ /** @var \SplFileInfo $info */
+ foreach ($iterator as $filename => $info) {
+ if (!$info->isDir() || strpos($info->getFilename(), '.') === 0) {
+ continue;
+ }
+
+ $list[] = $this->buildIndexFromFilesystem($filename);
+ }
+
+ if (!$list) {
+ return [];
+ }
+
+ return \count($list) > 1 ? array_merge(...$list) : $list[0];
+ }
+
+ /**
+ * @return string
+ */
+ protected function getNewKey(): string
+ {
+ // Make sure that the file doesn't exist.
+ do {
+ $key = $this->generateKey();
+ } while (file_exists($this->getPathFromKey($key)));
+
+ return $key;
+ }
+
+ /**
+ * @param array $options
+ */
+ protected function initOptions(array $options): void
+ {
+ $extension = $this->dataFormatter->getDefaultFileExtension();
+
+ /** @var string $pattern */
+ $pattern = !empty($options['pattern']) ? $options['pattern'] : $this->dataPattern;
+
+ $this->dataFolder = $options['folder'];
+ $this->prefixed = (bool)($options['prefixed'] ?? strpos($pattern, '/{KEY:2}/'));
+ $this->indexed = (bool)($options['indexed'] ?? false);
+ $this->keyField = $options['key'] ?? 'storage_key';
+
+ $pattern = preg_replace(['/{FOLDER}/', '/{KEY}/', '/{KEY:2}/'], ['%1$s', '%2$s', '%3$s'], $pattern);
+ $this->dataPattern = \dirname($pattern) . '/' . basename($pattern, $extension) . $extension;
+ }
+}
diff --git a/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
new file mode 100644
index 0000000..088b952
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
@@ -0,0 +1,323 @@
+detectDataFormatter($options['folder']);
+ $this->initDataFormatter($formatter);
+
+ $extension = $this->dataFormatter->getDefaultFileExtension();
+ $pattern = basename($options['folder']);
+
+ $this->dataPattern = basename($pattern, $extension) . $extension;
+ $this->dataFolder = \dirname($options['folder']);
+
+ // Make sure that the data folder exists.
+ if (!file_exists($this->dataFolder)) {
+ try {
+ Folder::create($this->dataFolder);
+ } catch (\RuntimeException $e) {
+ throw new \RuntimeException(sprintf('Flex: %s', $e->getMessage()));
+ }
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::getExistingKeys()
+ */
+ public function getExistingKeys(): array
+ {
+ return $this->buildIndex();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::hasKey()
+ */
+ public function hasKey(string $key): bool
+ {
+ if (null === $this->data) {
+ $this->buildIndex();
+ }
+
+ return $key && strpos($key, '@@') === false && isset($this->data[$key]);
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::createRows()
+ */
+ public function createRows(array $rows): array
+ {
+ if (null === $this->data) {
+ $this->buildIndex();
+ }
+
+ $list = [];
+ foreach ($rows as $key => $row) {
+ $key = $this->getNewKey();
+ $this->data[$key] = $list[$key] = $row;
+ }
+
+ if ($list) {
+ $this->save();
+ }
+
+ return $list;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::readRows()
+ */
+ public function readRows(array $rows, array &$fetched = null): array
+ {
+ if (null === $this->data) {
+ $this->buildIndex();
+ }
+
+ $list = [];
+ foreach ($rows as $key => $row) {
+ if (null === $row || (!\is_object($row) && !\is_array($row))) {
+ // Only load rows which haven't been loaded before.
+ $key = (string)$key;
+ $list[$key] = $this->hasKey($key) ? $this->data[$key] : null;
+ if (null !== $fetched) {
+ $fetched[$key] = $list[$key];
+ }
+ } else {
+ // Keep the row if it has been loaded.
+ $list[$key] = $row;
+ }
+ }
+
+ return $list;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::updateRows()
+ */
+ public function updateRows(array $rows): array
+ {
+ if (null === $this->data) {
+ $this->buildIndex();
+ }
+
+ $list = [];
+ foreach ($rows as $key => $row) {
+ $key = (string)$key;
+ if ($this->hasKey($key)) {
+ $this->data[$key] = $list[$key] = $row;
+ }
+ }
+
+ if ($list) {
+ $this->save();
+ }
+
+ return $list;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::deleteRows()
+ */
+ public function deleteRows(array $rows): array
+ {
+ if (null === $this->data) {
+ $this->buildIndex();
+ }
+
+ $list = [];
+ foreach ($rows as $key => $row) {
+ $key = (string)$key;
+ if ($this->hasKey($key)) {
+ unset($this->data[$key]);
+ $list[$key] = $row;
+ }
+ }
+
+ if ($list) {
+ $this->save();
+ }
+
+ return $list;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::replaceRows()
+ */
+ public function replaceRows(array $rows): array
+ {
+ if (null === $this->data) {
+ $this->buildIndex();
+ }
+
+ $list = [];
+ foreach ($rows as $key => $row) {
+ if (strpos($key, '@@')) {
+ $key = $this->getNewKey();
+ }
+ $this->data[$key] = $list[$key] = $row;
+ }
+
+ if ($list) {
+ $this->save();
+ }
+
+ return $list;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::renameRow()
+ */
+ public function renameRow(string $src, string $dst): bool
+ {
+ if (null === $this->data) {
+ $this->buildIndex();
+ }
+
+ if ($this->hasKey($dst)) {
+ throw new \RuntimeException("Cannot rename object: key '{$dst}' is already taken");
+ }
+
+ if (!$this->hasKey($src)) {
+ return false;
+ }
+
+ // Change single key in the array without changing the order or value.
+ $keys = array_keys($this->data);
+ $keys[array_search($src, $keys, true)] = $dst;
+
+ $data = array_combine($keys, $this->data);
+ if (false === $data) {
+ throw new \LogicException('Bad data');
+ }
+
+ $this->data = $data;
+
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::getStoragePath()
+ */
+ public function getStoragePath(string $key = null): string
+ {
+ return $this->dataFolder . '/' . $this->dataPattern;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FlexStorageInterface::getMediaPath()
+ */
+ public function getMediaPath(string $key = null): string
+ {
+ return sprintf('%s/%s/%s', $this->dataFolder, basename($this->dataPattern, $this->dataFormatter->getDefaultFileExtension()), $key);
+ }
+
+ protected function save() : void
+ {
+ if (null === $this->data) {
+ $this->buildIndex();
+ }
+
+ try {
+ $file = $this->getFile($this->getStoragePath());
+ $file->save($this->data);
+ $file->free();
+ } catch (\RuntimeException $e) {
+ throw new \RuntimeException(sprintf('Flex save(): %s', $e->getMessage()));
+ }
+ }
+
+ /**
+ * Get key from the filesystem path.
+ *
+ * @param string $path
+ * @return string
+ */
+ protected function getKeyFromPath(string $path): string
+ {
+ return basename($path);
+ }
+
+ /**
+ * Returns list of all stored keys in [key => timestamp] pairs.
+ *
+ * @return array
+ */
+ protected function buildIndex(): array
+ {
+ $file = $this->getFile($this->getStoragePath());
+ $modified = $file->modified();
+
+ $this->data = (array) $file->content();
+
+ $list = [];
+ foreach ($this->data as $key => $info) {
+ $list[$key] = [
+ 'storage_key' => $key,
+ 'storage_timestamp' => $modified
+ ];
+ }
+
+ return $list;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getNewKey(): string
+ {
+ if (null === $this->data) {
+ $this->buildIndex();
+ }
+
+ // Make sure that the key doesn't exist.
+ do {
+ $key = $this->generateKey();
+ } while (isset($this->data[$key]));
+
+ return $key;
+ }
+}
diff --git a/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php
new file mode 100644
index 0000000..e1b63d9
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php
@@ -0,0 +1,60 @@
+isAuthorizedAction($user, $action, $scope) || $this->isAuthorizedSuperAdmin($user));
+ }
+
+ protected function isAuthorizedSuperAdmin(UserInterface $user): bool
+ {
+ return $user->authorize('admin.super');
+ }
+
+ protected function isAuthorizedAction(UserInterface $user, string $action, string $scope = null) : bool
+ {
+ $scope = $scope ?? isset(Grav::instance()['admin']) ? 'admin' : 'site';
+
+ if ($action === 'save' && $this instanceof FlexObjectInterface) {
+ $action = $this->exists() ? 'update' : 'create';
+ }
+
+ $directory = $this instanceof FlexDirectory ? $this : $this->getFlexDirectory();
+ $config = $directory->getConfig();
+ $allowed = $config->get("{$scope}.actions.{$action}") ?? $config->get("actions.{$action}") ?? true;
+
+ return $allowed && $user->authorize(sprintf($this->_authorize, $scope, $action));
+ }
+
+ protected function setAuthorizeRule(string $authorize) : void
+ {
+ $this->_authorize = $authorize;
+ }
+}
diff --git a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
new file mode 100644
index 0000000..c894634
--- /dev/null
+++ b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
@@ -0,0 +1,346 @@
+ $this->getUpdatedMedia()
+ ];
+ }
+
+ /**
+ * @return string
+ */
+ public function getStorageFolder()
+ {
+ return $this->exists() ? $this->getFlexDirectory()->getStorageFolder($this->getStorageKey()) : '';
+ }
+
+ /**
+ * @return string
+ */
+ public function getMediaFolder()
+ {
+ return $this->exists() ? $this->getFlexDirectory()->getMediaFolder($this->getStorageKey()) : '';
+ }
+
+ /**
+ * @return MediaCollectionInterface
+ */
+ public function getMedia()
+ {
+ if ($this->media === null) {
+ /** @var AbstractMedia $media */
+ $media = $this->getExistingMedia();
+
+ // Include uploaded media to the object media.
+ /** @var FormFlashFile $upload */
+ foreach ($this->getUpdatedMedia() as $filename => $upload) {
+ // Just make sure we do not include removed or moved media.
+ if ($upload && $upload->getError() === \UPLOAD_ERR_OK && !$upload->isMoved()) {
+ $media->add($filename, MediumFactory::fromUploadedFile($upload));
+ }
+ }
+
+ $media->setTimestamps();
+ }
+
+ return $this->media;
+ }
+
+ public function checkUploadedMediaFile(UploadedFileInterface $uploadedFile)
+ {
+ $grav = Grav::instance();
+ $language = $grav['language'];
+
+ switch ($uploadedFile->getError()) {
+ case UPLOAD_ERR_OK:
+ break;
+ case UPLOAD_ERR_NO_FILE:
+ if ($uploadedFile instanceof FormFlashFile) {
+ break;
+ }
+ throw new RuntimeException($language->translate('PLUGIN_ADMIN.NO_FILES_SENT'), 400);
+ case UPLOAD_ERR_INI_SIZE:
+ case UPLOAD_ERR_FORM_SIZE:
+ throw new RuntimeException($language->translate('PLUGIN_ADMIN.EXCEEDED_FILESIZE_LIMIT'), 400);
+ case UPLOAD_ERR_NO_TMP_DIR:
+ throw new RuntimeException($language->translate('PLUGIN_ADMIN.UPLOAD_ERR_NO_TMP_DIR'), 400);
+ default:
+ throw new RuntimeException($language->translate('PLUGIN_ADMIN.UNKNOWN_ERRORS'), 400);
+ }
+
+ $filename = $uploadedFile->getClientFilename();
+
+ if (!Utils::checkFilename($filename)) {
+ throw new RuntimeException(sprintf($language->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_UPLOAD'), $filename, 'Bad filename'), 400);
+ }
+
+ $grav_limit = Utils::getUploadLimit();
+ if ($grav_limit > 0 && $uploadedFile->getSize() > $grav_limit) {
+ throw new RuntimeException($language->translate('PLUGIN_ADMIN.EXCEEDED_GRAV_FILESIZE_LIMIT'), 400);
+ }
+
+ $this->checkMediaFilename($filename);
+ }
+
+ public function checkMediaFilename(string $filename)
+ {
+ // Check the file extension.
+ $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
+
+ $grav = Grav::instance();
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ // If not a supported type, return
+ if (!$extension || !$config->get("media.types.{$extension}")) {
+ $language = $grav['language'];
+ throw new RuntimeException($language->translate('PLUGIN_ADMIN.UNSUPPORTED_FILE_TYPE') . ': ' . $extension, 400);
+ }
+ }
+
+ public function uploadMediaFile(UploadedFileInterface $uploadedFile, string $filename = null): void
+ {
+ $this->checkUploadedMediaFile($uploadedFile);
+
+ if ($filename) {
+ $this->checkMediaFilename(basename($filename));
+ } else {
+ $filename = $uploadedFile->getClientFilename();
+ }
+
+ $media = $this->getMedia();
+ $grav = Grav::instance();
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $grav['locator'];
+ $path = $media->getPath();
+ if (!$path) {
+ $language = $grav['language'];
+
+ throw new RuntimeException($language->translate('PLUGIN_ADMIN.FAILED_TO_MOVE_UPLOADED_FILE'), 400);
+ }
+
+ if ($locator->isStream($path)) {
+ $path = $locator->findResource($path, true, true);
+ $locator->clearCache($path);
+ }
+
+ try {
+ // Upload it
+ $filepath = sprintf('%s/%s', $path, $filename);
+ Folder::create(\dirname($filepath));
+ if ($uploadedFile instanceof FormFlashFile) {
+ $metadata = $uploadedFile->getMetaData();
+ if ($metadata) {
+ $file = YamlFile::instance($filepath . '.meta.yaml');
+ $file->save(['upload' => $metadata]);
+ }
+ if ($uploadedFile->getError() === \UPLOAD_ERR_OK) {
+ $uploadedFile->moveTo($filepath);
+ } elseif (!file_exists($filepath) && $pos = strpos($filename, '/')) {
+ $origpath = sprintf('%s/%s', $path, substr($filename, $pos));
+ if (file_exists($origpath)) {
+ copy($origpath, $filepath);
+ }
+ }
+ } else {
+ $uploadedFile->moveTo($filepath);
+ }
+ } catch (\Exception $e) {
+ $language = $grav['language'];
+
+ throw new RuntimeException($language->translate('PLUGIN_ADMIN.FAILED_TO_MOVE_UPLOADED_FILE'), 400);
+ }
+
+ $this->clearMediaCache();
+ }
+
+ public function deleteMediaFile(string $filename): void
+ {
+ $grav = Grav::instance();
+ $language = $grav['language'];
+
+ $basename = basename($filename);
+ $dirname = dirname($filename);
+ $dirname = $dirname === '.' ? '' : '/' . $dirname;
+
+ if (!Utils::checkFilename($basename)) {
+ throw new RuntimeException($language->translate('PLUGIN_ADMIN.FILE_COULD_NOT_BE_DELETED') . ': Bad filename: ' . $filename, 400);
+ }
+
+ $media = $this->getMedia();
+ $path = $media->getPath();
+ if (!$path) {
+ return;
+ }
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $grav['locator'];
+
+ $targetPath = $path . '/' . $dirname;
+ $targetFile = $path . '/' . $filename;
+ if ($locator->isStream($targetFile)) {
+ $targetPath = $locator->findResource($targetPath, true, true);
+ $targetFile = $locator->findResource($targetFile, true, true);
+ $locator->clearCache($targetPath);
+ $locator->clearCache($targetFile);
+ }
+
+ $fileParts = pathinfo($basename);
+
+ if (!file_exists($targetPath)) {
+ return;
+ }
+
+ if (file_exists($targetFile)) {
+ $result = unlink($targetFile);
+ if (!$result) {
+ throw new RuntimeException($language->translate('PLUGIN_ADMIN.FILE_COULD_NOT_BE_DELETED') . ': ' . $filename, 500);
+ }
+ }
+
+ // Remove Extra Files
+ foreach (scandir($targetPath, SCANDIR_SORT_NONE) as $file) {
+ $preg_name = preg_quote($fileParts['filename'], '`');
+ $preg_ext =preg_quote($fileParts['extension'], '`');
+ $preg_filename = preg_quote($basename, '`');
+
+ if (preg_match("`({$preg_name}@\d+x\.{$preg_ext}(?:\.meta\.yaml)?$|{$preg_filename}\.meta\.yaml)$`", $file)) {
+ $testPath = $targetPath . '/' . $file;
+ if ($locator->isStream($testPath)) {
+ $testPath = $locator->findResource($testPath, true, true);
+ $locator->clearCache($testPath);
+ }
+
+ if (is_file($testPath)) {
+ $result = unlink($testPath);
+ if (!$result) {
+ throw new RuntimeException($language->translate('PLUGIN_ADMIN.FILE_COULD_NOT_BE_DELETED') . ': ' . $filename, 500);
+ }
+ }
+ }
+ }
+
+ $this->clearMediaCache();
+ }
+
+ /**
+ * @param array $files
+ */
+ protected function setUpdatedMedia(array $files): void
+ {
+ $list = [];
+ foreach ($files as $field => $group) {
+ if ($field === '' || \strpos($field, '/', true)) {
+ continue;
+ }
+ foreach ($group as $filename => $file) {
+ $list[$filename] = $file;
+ }
+ }
+
+ $this->_uploads = $list;
+ }
+
+ /**
+ * @return array
+ */
+ protected function getUpdatedMedia(): array
+ {
+ return $this->_uploads ?? [];
+ }
+
+ protected function saveUpdatedMedia(): void
+ {
+ /**
+ * @var string $filename
+ * @var UploadedFileInterface $file
+ */
+ foreach ($this->getUpdatedMedia() as $filename => $file) {
+ if ($file) {
+ $this->uploadMediaFile($file, $filename);
+ } else {
+ $this->deleteMediaFile($filename);
+ }
+ }
+
+ $this->setUpdatedMedia([]);
+ }
+
+ /**
+ * @param string $uri
+ * @return Medium|null
+ */
+ protected function createMedium($uri)
+ {
+ $grav = Grav::instance();
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $grav['locator'];
+
+ $file = $uri && $locator->isStream($uri) ? $locator->findResource($uri) : $uri;
+
+ return $file && file_exists($file) ? MediumFactory::fromFile($file) : null;
+ }
+
+ /**
+ * @return Cache
+ */
+ protected function getMediaCache()
+ {
+ return $this->getCache('object');
+ }
+
+ protected function offsetLoad_media()
+ {
+ return $this->getMedia();
+ }
+
+ protected function offsetSerialize_media()
+ {
+ return null;
+ }
+
+ abstract public function getFlexDirectory(): FlexDirectory;
+
+ abstract public function getStorageKey(): string;
+}
diff --git a/system/src/Grav/Framework/Form/FormFlash.php b/system/src/Grav/Framework/Form/FormFlash.php
new file mode 100644
index 0000000..e2ba826
--- /dev/null
+++ b/system/src/Grav/Framework/Form/FormFlash.php
@@ -0,0 +1,519 @@
+ $args[0],
+ 'unique_id' => $args[1] ?? null,
+ 'form_name' => $args[2] ?? null,
+ ];
+ }
+
+ $this->sessionId = $config['session_id'] ?? 'no-session';
+ $this->uniqueId = $config['unique_id'] ?? '';
+
+ $folder = $config['folder'] ?? ($this->sessionId ? 'tmp://forms/' . $this->sessionId : '');
+
+ /** @var UniformResourceLocator $locator */
+ $locator = Grav::instance()['locator'];
+
+ $this->folder = $folder && $locator->isStream($folder) ? $locator->findResource($folder, true, true) : $folder;
+ $file = $this->getTmpIndex();
+ $this->exists = $file->exists();
+
+ if ($this->exists) {
+ try {
+ $data = (array)$file->content();
+ } catch (\Exception $e) {
+ $data = [];
+ }
+ $this->formName = $content['form'] ?? $config['form_name'] ?? '';
+ $this->url = $data['url'] ?? '';
+ $this->user = $data['user'] ?? null;
+ $this->updatedTimestamp = $data['timestamps']['updated'] ?? time();
+ $this->createdTimestamp = $data['timestamps']['created'] ?? $this->updatedTimestamp;
+ $this->data = $data['data'] ?? null;
+ $this->files = $data['files'] ?? [];
+ } else {
+ $this->formName = $config['form_name'] ?? '';
+ $this->url = '';
+ $this->createdTimestamp = $this->updatedTimestamp = time();
+ $this->files = [];
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getSessionId(): string
+ {
+ return $this->sessionId;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getUniqueId(): string
+ {
+ return $this->uniqueId;
+ }
+
+ /**
+ * @deprecated 1.6.11 Use '->getUniqueId()' method instead.
+ */
+ public function getUniqieId(): string
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6.11, use ->getUniqueId() method instead', E_USER_DEPRECATED);
+
+ return $this->getUniqueId();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getFormName(): string
+ {
+ return $this->formName;
+ }
+
+
+ /**
+ * @inheritDoc
+ */
+ public function getUrl(): string
+ {
+ return $this->url;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getUsername(): string
+ {
+ return $this->user['username'] ?? '';
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getUserEmail(): string
+ {
+ return $this->user['email'] ?? '';
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getCreatedTimestamp(): int
+ {
+ return $this->createdTimestamp;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getUpdatedTimestamp(): int
+ {
+ return $this->updatedTimestamp;
+ }
+
+
+ /**
+ * @inheritDoc
+ */
+ public function getData(): ?array
+ {
+ return $this->data;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setData(?array $data): void
+ {
+ $this->data = $data;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function exists(): bool
+ {
+ return $this->exists;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function save(): self
+ {
+ if (!($this->folder && $this->uniqueId)) {
+ return $this;
+ }
+
+ if ($this->data || $this->files) {
+ // Only save if there is data or files to be saved.
+ $file = $this->getTmpIndex();
+ $file->save($this->jsonSerialize());
+ $this->exists = true;
+ } elseif ($this->exists) {
+ // Delete empty form flash if it exists (it carries no information).
+ return $this->delete();
+ }
+
+ return $this;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function delete(): self
+ {
+ if ($this->folder && $this->uniqueId) {
+ $this->removeTmpDir();
+ $this->files = [];
+ $this->exists = false;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getFilesByField(string $field): array
+ {
+ if (!isset($this->uploadObjects[$field])) {
+ $objects = [];
+ foreach ($this->files[$field] ?? [] as $name => $upload) {
+ $objects[$name] = $upload ? new FormFlashFile($field, $upload, $this) : null;
+ }
+ $this->uploadedFiles[$field] = $objects;
+ }
+
+ return $this->uploadedFiles[$field];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getFilesByFields($includeOriginal = false): array
+ {
+ $list = [];
+ foreach ($this->files as $field => $values) {
+ if (!$includeOriginal && strpos($field, '/')) {
+ continue;
+ }
+ $list[$field] = $this->getFilesByField($field);
+ }
+
+ return $list;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function addUploadedFile(UploadedFileInterface $upload, string $field = null, array $crop = null): string
+ {
+ $tmp_dir = $this->getTmpDir();
+ $tmp_name = Utils::generateRandomString(12);
+ $name = $upload->getClientFilename();
+
+ // Prepare upload data for later save
+ $data = [
+ 'name' => $name,
+ 'type' => $upload->getClientMediaType(),
+ 'size' => $upload->getSize(),
+ 'tmp_name' => $tmp_name
+ ];
+
+ Folder::create($tmp_dir);
+ $upload->moveTo("{$tmp_dir}/{$tmp_name}");
+
+ $this->addFileInternal($field, $name, $data, $crop);
+
+ return $name;
+ }
+
+
+ /**
+ * @inheritDoc
+ */
+ public function addFile(string $filename, string $field, array $crop = null): bool
+ {
+ if (!file_exists($filename)) {
+ throw new \RuntimeException("File not found: {$filename}");
+ }
+
+ // Prepare upload data for later save
+ $data = [
+ 'name' => basename($filename),
+ 'type' => Utils::getMimeByLocalFile($filename),
+ 'size' => filesize($filename),
+ ];
+
+ $this->addFileInternal($field, $data['name'], $data, $crop);
+
+ return true;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function removeFile(string $name, string $field = null): bool
+ {
+ if (!$name) {
+ return false;
+ }
+
+ $field = $field ?: 'undefined';
+
+ $upload = $this->files[$field][$name] ?? null;
+ if (null !== $upload) {
+ $this->removeTmpFile($upload['tmp_name'] ?? '');
+ }
+ $upload = $this->files[$field . '/original'][$name] ?? null;
+ if (null !== $upload) {
+ $this->removeTmpFile($upload['tmp_name'] ?? '');
+ }
+
+ // Mark file as deleted.
+ $this->files[$field][$name] = null;
+ $this->files[$field . '/original'][$name] = null;
+
+ unset(
+ $this->uploadedFiles[$field][$name],
+ $this->uploadedFiles[$field . '/original'][$name]
+ );
+
+ return true;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function clearFiles()
+ {
+ foreach ($this->files as $field => $files) {
+ foreach ($files as $name => $upload) {
+ $this->removeTmpFile($upload['tmp_name'] ?? '');
+ }
+ }
+
+ $this->files = [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function jsonSerialize(): array
+ {
+ return [
+ 'form' => $this->formName,
+ 'unique_id' => $this->uniqueId,
+ 'url' => $this->url,
+ 'user' => $this->user,
+ 'timestamps' => [
+ 'created' => $this->createdTimestamp,
+ 'updated' => time(),
+ ],
+ 'data' => $this->data,
+ 'files' => $this->files
+ ];
+ }
+
+ /**
+ * @param string $url
+ * @return $this
+ */
+ public function setUrl(string $url): self
+ {
+ $this->url = $url;
+
+ return $this;
+ }
+
+ /**
+ * @param UserInterface|null $user
+ * @return $this
+ */
+ public function setUser(UserInterface $user = null)
+ {
+ if ($user && $user->username) {
+ $this->user = [
+ 'username' => $user->username,
+ 'email' => $user->email ?? ''
+ ];
+ } else {
+ $this->user = null;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param string|null $username
+ * @return $this
+ */
+ public function setUserName(string $username = null): self
+ {
+ $this->user['username'] = $username;
+
+ return $this;
+ }
+
+ /**
+ * @param string|null $email
+ * @return $this
+ */
+ public function setUserEmail(string $email = null): self
+ {
+ $this->user['email'] = $email;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTmpDir(): string
+ {
+ return $this->folder && $this->uniqueId ? "{$this->folder}/{$this->uniqueId}" : '';
+ }
+
+ /**
+ * @return YamlFile
+ */
+ protected function getTmpIndex(): YamlFile
+ {
+ // Do not use CompiledYamlFile as the file can change multiple times per second.
+ return YamlFile::instance($this->getTmpDir() . '/index.yaml');
+ }
+
+ /**
+ * @param string $name
+ */
+ protected function removeTmpFile(string $name): void
+ {
+ $tmpDir = $this->getTmpDir();
+ $filename = $tmpDir ? $tmpDir . '/' . $name : '';
+ if ($name && $filename && is_file($filename)) {
+ unlink($filename);
+ }
+ }
+
+ protected function removeTmpDir(): void
+ {
+ $tmpDir = $this->getTmpDir();
+ if ($tmpDir && file_exists($tmpDir)) {
+ Folder::delete($tmpDir);
+ }
+ }
+
+ /**
+ * @param string $field
+ * @param string $name
+ * @param array $data
+ * @param array|null $crop
+ */
+ protected function addFileInternal(?string $field, string $name, array $data, array $crop = null): void
+ {
+ if (!($this->folder && $this->uniqueId)) {
+ throw new \RuntimeException('Cannot upload files: form flash folder not defined');
+ }
+
+ $field = $field ?: 'undefined';
+ if (!isset($this->files[$field])) {
+ $this->files[$field] = [];
+ }
+
+ $oldUpload = $this->files[$field][$name] ?? null;
+
+ if ($crop) {
+ // Deal with crop upload
+ if ($oldUpload) {
+ $originalUpload = $this->files[$field . '/original'][$name] ?? null;
+ if ($originalUpload) {
+ // If there is original file already present, remove the modified file
+ $this->files[$field . '/original'][$name]['crop'] = $crop;
+ $this->removeTmpFile($oldUpload['tmp_name'] ?? '');
+ } else {
+ // Otherwise make the previous file as original
+ $oldUpload['crop'] = $crop;
+ $this->files[$field . '/original'][$name] = $oldUpload;
+ }
+ } else {
+ $this->files[$field . '/original'][$name] = [
+ 'name' => $name,
+ 'type' => $data['type'],
+ 'crop' => $crop
+ ];
+ }
+ } else {
+ // Deal with replacing upload
+ $originalUpload = $this->files[$field . '/original'][$name] ?? null;
+ $this->files[$field . '/original'][$name] = null;
+
+ $this->removeTmpFile($oldUpload['tmp_name'] ?? '');
+ $this->removeTmpFile($originalUpload['tmp_name'] ?? '');
+ }
+
+ // Prepare data to be saved later
+ $this->files[$field][$name] = $data;
+ }
+}
diff --git a/system/src/Grav/Framework/Form/FormFlashFile.php b/system/src/Grav/Framework/Form/FormFlashFile.php
new file mode 100644
index 0000000..9183689
--- /dev/null
+++ b/system/src/Grav/Framework/Form/FormFlashFile.php
@@ -0,0 +1,159 @@
+field = $field;
+ $this->upload = $upload;
+ $this->flash = $flash;
+
+ $tmpFile = $this->getTmpFile();
+ if (!$tmpFile && $this->isOk()) {
+ $this->upload['error'] = \UPLOAD_ERR_NO_FILE;
+ }
+
+ if (!isset($this->upload['size'])) {
+ $this->upload['size'] = $tmpFile && $this->isOk() ? filesize($tmpFile) : 0;
+ }
+ }
+
+ /**
+ * @return StreamInterface
+ */
+ public function getStream()
+ {
+ $this->validateActive();
+
+ $resource = \fopen($this->getTmpFile(), 'rb');
+
+ return Stream::create($resource);
+ }
+
+ public function moveTo($targetPath)
+ {
+ $this->validateActive();
+
+ if (!\is_string($targetPath) || empty($targetPath)) {
+ throw new \InvalidArgumentException('Invalid path provided for move operation; must be a non-empty string');
+ }
+
+ $this->moved = \copy($this->getTmpFile(), $targetPath);
+
+ if (false === $this->moved) {
+ throw new \RuntimeException(\sprintf('Uploaded file could not be moved to %s', $targetPath));
+ }
+
+ $this->flash->removeFile($this->getClientFilename(), $this->field);
+ }
+
+ public function getSize()
+ {
+ return $this->upload['size'];
+ }
+
+ public function getError()
+ {
+ return $this->upload['error'] ?? \UPLOAD_ERR_OK;
+ }
+
+ public function getClientFilename()
+ {
+ return $this->upload['name'] ?? 'unknown';
+ }
+
+ public function getClientMediaType()
+ {
+ return $this->upload['type'] ?? 'application/octet-stream';
+ }
+
+ public function isMoved() : bool
+ {
+ return $this->moved;
+ }
+
+ public function getMetaData() : array
+ {
+ if (isset($this->upload['crop'])) {
+ return ['crop' => $this->upload['crop']];
+ }
+
+ return [];
+ }
+
+ public function getDestination()
+ {
+ return $this->upload['path'] ?? '';
+ }
+
+ public function jsonSerialize()
+ {
+ return $this->upload;
+ }
+
+ public function getTmpFile() : ?string
+ {
+ $tmpName = $this->upload['tmp_name'] ?? null;
+
+ if (!$tmpName) {
+ return null;
+ }
+
+ $tmpFile = $this->flash->getTmpDir() . '/' . $tmpName;
+
+ return file_exists($tmpFile) ? $tmpFile : null;
+ }
+
+ public function __debugInfo()
+ {
+ return [
+ 'field:private' => $this->field,
+ 'moved:private' => $this->moved,
+ 'upload:private' => $this->upload,
+ ];
+ }
+
+ /**
+ * @throws \RuntimeException if is moved or not ok
+ */
+ private function validateActive(): void
+ {
+ if (!$this->isOk()) {
+ throw new \RuntimeException('Cannot retrieve stream due to upload error');
+ }
+
+ if ($this->moved) {
+ throw new \RuntimeException('Cannot retrieve stream after it has already been moved');
+ }
+
+ if (!$this->getTmpFile()) {
+ throw new \RuntimeException('Cannot retrieve stream as the file is missing');
+ }
+ }
+
+ /**
+ * @return bool return true if there is no upload error
+ */
+ private function isOk(): bool
+ {
+ return \UPLOAD_ERR_OK === $this->getError();
+ }
+}
diff --git a/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php b/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php
new file mode 100644
index 0000000..fb57db1
--- /dev/null
+++ b/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php
@@ -0,0 +1,38 @@
+id;
+ }
+
+ public function setId(string $id): void
+ {
+ $this->id = $id;
+ }
+
+ public function getUniqueId(): string
+ {
+ return $this->uniqueid;
+ }
+
+ public function setUniqueId(string $uniqueId): void
+ {
+ $this->uniqueid = $uniqueId;
+ }
+
+ public function getName(): string
+ {
+ return $this->name;
+ }
+
+ public function getFormName(): string
+ {
+ return $this->name;
+ }
+
+ public function getNonceName(): string
+ {
+ return 'form-nonce';
+ }
+
+ public function getNonceAction(): string
+ {
+ return 'form';
+ }
+
+ public function getNonce(): string
+ {
+ return Utils::getNonce($this->getNonceAction());
+ }
+
+ public function getAction(): string
+ {
+ return '';
+ }
+
+ public function getTask(): string
+ {
+ return $this->getBlueprint()->get('form/task') ?? '';
+ }
+
+ public function getData(string $name = null)
+ {
+ return null !== $name ? $this->data[$name] : $this->data;
+ }
+
+ /**
+ * @return array|UploadedFileInterface[]
+ */
+ public function getFiles(): array
+ {
+ return $this->files ?? [];
+ }
+
+ public function getValue(string $name)
+ {
+ return $this->data[$name] ?? null;
+ }
+
+ public function getDefaultValue(string $name)
+ {
+ $path = explode('.', $name) ?: [];
+ $offset = array_shift($path) ?? '';
+
+ $current = $this->getDefaultValues();
+
+ if (!isset($current[$offset])) {
+ return null;
+ }
+
+ $current = $current[$offset];
+
+ while ($path) {
+ $offset = array_shift($path);
+
+ if ((\is_array($current) || $current instanceof \ArrayAccess) && isset($current[$offset])) {
+ $current = $current[$offset];
+ } elseif (\is_object($current) && isset($current->{$offset})) {
+ $current = $current->{$offset};
+ } else {
+ return null;
+ }
+ };
+
+ return $current;
+ }
+
+ /**
+ * @return array
+ */
+ public function getDefaultValues(): array
+ {
+ return $this->getBlueprint()->getDefaults();
+ }
+
+ /**
+ * @param ServerRequestInterface $request
+ * @return FormInterface|$this
+ */
+ public function handleRequest(ServerRequestInterface $request): FormInterface
+ {
+ // Set current form to be active.
+ $grav = Grav::instance();
+ $forms = $grav['forms'] ?? null;
+ if ($forms) {
+ $forms->setActiveForm($this);
+
+ /** @var Twig $twig */
+ $twig = $grav['twig'];
+ $twig->twig_vars['form'] = $this;
+
+ }
+
+ try {
+ [$data, $files] = $this->parseRequest($request);
+
+ $this->submit($data, $files);
+ } catch (\Exception $e) {
+ $this->setError($e->getMessage());
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ServerRequestInterface $request
+ * @return FormInterface|$this
+ */
+ public function setRequest(ServerRequestInterface $request): FormInterface
+ {
+ [$data, $files] = $this->parseRequest($request);
+
+ $this->data = new Data($data, $this->getBlueprint());
+ $this->files = $files;
+
+ return $this;
+ }
+
+ public function isValid(): bool
+ {
+ return $this->status === 'success';
+ }
+
+ public function getError(): ?string
+ {
+ return !$this->isValid() ? $this->message : null;
+ }
+
+ public function getErrors(): array
+ {
+ return !$this->isValid() ? $this->messages : [];
+ }
+
+ public function isSubmitted(): bool
+ {
+ return $this->submitted;
+ }
+
+ public function validate(): bool
+ {
+ if (!$this->isValid()) {
+ return false;
+ }
+
+ try {
+ $this->validateData($this->data);
+ $this->validateUploads($this->getFiles());
+ } catch (ValidationException $e) {
+ $this->setErrors($e->getMessages());
+ } catch (\Exception $e) {
+ $this->setError($e->getMessage());
+ }
+
+ $this->filterData($this->data);
+
+ return $this->isValid();
+ }
+
+ /**
+ * @param array $data
+ * @param UploadedFileInterface[] $files
+ * @return FormInterface|$this
+ */
+ public function submit(array $data, array $files = null): FormInterface
+ {
+ try {
+ if ($this->isSubmitted()) {
+ throw new \RuntimeException('Form has already been submitted');
+ }
+
+ $this->data = new Data($data, $this->getBlueprint());
+ $this->files = $files ?? [];
+
+ if (!$this->validate()) {
+ return $this;
+ }
+
+ $this->doSubmit($this->data->toArray(), $this->files);
+
+ $this->submitted = true;
+ } catch (\Exception $e) {
+ $this->setError($e->getMessage());
+ }
+
+ return $this;
+ }
+
+ public function reset(): void
+ {
+ // Make sure that the flash object gets deleted.
+ $this->getFlash()->delete();
+
+ $this->data = null;
+ $this->files = [];
+ $this->status = 'success';
+ $this->message = null;
+ $this->messages = [];
+ $this->submitted = false;
+ $this->flash = null;
+ }
+
+ public function getFields(): array
+ {
+ return $this->getBlueprint()->fields();
+ }
+
+ public function getButtons(): array
+ {
+ return $this->getBlueprint()->get('form/buttons') ?? [];
+ }
+
+ public function getTasks(): array
+ {
+ return $this->getBlueprint()->get('form/tasks') ?? [];
+ }
+
+ abstract public function getBlueprint(): Blueprint;
+
+ /**
+ * Implements \Serializable::serialize().
+ *
+ * @return string
+ */
+ public function serialize(): string
+ {
+ return serialize($this->doSerialize());
+ }
+
+ /**
+ * Implements \Serializable::unserialize().
+ *
+ * @param string $serialized
+ */
+ public function unserialize($serialized): void
+ {
+ $data = unserialize($serialized, ['allowed_classes' => false]);
+
+ $this->doUnserialize($data);
+ }
+
+ /**
+ * Get form flash object.
+ *
+ * @return FormFlash
+ */
+ public function getFlash(): FormFlash
+ {
+ if (null === $this->flash) {
+ $grav = Grav::instance();
+ $config = [
+ 'session_id' => $this->getSessionId(),
+ 'unique_id' => $this->getUniqueId(),
+ 'form_name' => $this->getName(),
+ 'folder' => $this->getFlashFolder()
+ ];
+
+
+ $this->flash = new FormFlash($config);
+ $this->flash->setUrl($grav['uri']->url)->setUser($grav['user'] ?? null);
+ }
+
+ return $this->flash;
+ }
+
+ /**
+ * Get all available form flash objects for this form.
+ *
+ * @return FormFlash[]
+ */
+ public function getAllFlashes(): array
+ {
+ $folder = $this->getFlashFolder();
+ if (!$folder || !is_dir($folder)) {
+ return [];
+ }
+
+ $name = $this->getName();
+
+ $list = [];
+ /** @var \SplFileInfo $file */
+ foreach (new \FilesystemIterator($folder) as $file) {
+ $uniqueId = $file->getFilename();
+ $config = [
+ 'session_id' => $this->getSessionId(),
+ 'unique_id' => $uniqueId,
+ 'form_name' => $name,
+ 'folder' => $this->getFlashFolder()
+ ];
+ $flash = new FormFlash($config);
+ if ($flash->exists() && $flash->getFormName() === $name) {
+ $list[] = $flash;
+ }
+ }
+
+ return $list;
+
+ }
+
+ /**
+ * {@inheritdoc}
+ * @see FormInterface::render()
+ */
+ public function render(string $layout = null, array $context = [])
+ {
+ if (null === $layout) {
+ $layout = 'default';
+ }
+
+ $grav = Grav::instance();
+
+ $block = HtmlBlock::create();
+ $block->disableCache();
+
+ $output = $this->getTemplate($layout)->render(
+ ['grav' => $grav, 'config' => $grav['config'], 'block' => $block, 'form' => $this, 'layout' => $layout] + $context
+ );
+
+ $block->setContent($output);
+
+ return $block;
+ }
+
+ protected function getSessionId(): string
+ {
+ /** @var Grav $grav */
+ $grav = Grav::instance();
+
+ /** @var SessionInterface $session */
+ $session = $grav['session'] ?? null;
+
+ return $session ? ($session->getId() ?? '') : '';
+ }
+
+ protected function unsetFlash(): void
+ {
+ $this->flash = null;
+ }
+
+ protected function getFlashFolder(): ?string
+ {
+ $grav = Grav::instance();
+
+ /** @var UserInterface $user */
+ $user = $grav['user'] ?? null;
+ $userExists = $user && $user->exists();
+ $username = $userExists ? $user->username : null;
+ $mediaFolder = $userExists ? $user->getMediaFolder() : null;
+ $session = $grav['session'] ?? null;
+ $sessionId = $session ? $session->getId() : null;
+
+ // Fill template token keys/value pairs.
+ $dataMap = [
+ '[FORM_NAME]' => $this->getName(),
+ '[SESSIONID]' => $sessionId ?? '!!',
+ '[USERNAME]' => $username ?? '!!',
+ '[USERNAME_OR_SESSIONID]' => $username ?? $sessionId ?? '!!',
+ '[ACCOUNT]' => $mediaFolder ?? '!!'
+ ];
+
+ $flashFolder = $this->getBlueprint()->get('form/flash_folder', 'tmp://forms/[SESSIONID]');
+
+ $path = str_replace(array_keys($dataMap), array_values($dataMap), $flashFolder);
+
+ // Make sure we only return valid paths.
+ return strpos($path, '!!') === false ? rtrim($path, '/') : null;
+ }
+
+ /**
+ * Set a single error.
+ *
+ * @param string $error
+ */
+ protected function setError(string $error): void
+ {
+ $this->status = 'error';
+ $this->message = $error;
+ }
+
+ /**
+ * Set all errors.
+ *
+ * @param array $errors
+ */
+ protected function setErrors(array $errors): void
+ {
+ $this->status = 'error';
+ $this->messages = $errors;
+ }
+
+ /**
+ * @param string $layout
+ * @return TemplateWrapper
+ * @throws LoaderError
+ * @throws SyntaxError
+ */
+ protected function getTemplate($layout)
+ {
+ $grav = Grav::instance();
+
+ /** @var Twig $twig */
+ $twig = $grav['twig'];
+
+ return $twig->twig()->resolveTemplate(
+ [
+ "forms/{$layout}/form.html.twig",
+ 'forms/default/form.html.twig'
+ ]
+ );
+ }
+
+ /**
+ * Parse PSR-7 ServerRequest into data and files.
+ *
+ * @param ServerRequestInterface $request
+ * @return array
+ */
+ protected function parseRequest(ServerRequestInterface $request): array
+ {
+ $method = $request->getMethod();
+ if (!\in_array($method, ['PUT', 'POST', 'PATCH'])) {
+ throw new \RuntimeException(sprintf('FlexForm: Bad HTTP method %s', $method));
+ }
+
+ $body = $request->getParsedBody();
+ $data = isset($body['data']) ? $this->decodeData($body['data']) : null;
+
+ $flash = $this->getFlash();
+ /*
+ if (null !== $data) {
+ $flash->setData($data);
+ $flash->save();
+ }
+ */
+
+ $blueprint = $this->getBlueprint();
+ $includeOriginal = (bool)($blueprint->form()['images']['original'] ?? null);
+ $files = $flash->getFilesByFields($includeOriginal);
+
+ $data = $blueprint->processForm($data ?? [], $body['toggleable_data'] ?? []);
+
+ return [
+ $data,
+ $files ?? []
+ ];
+ }
+
+ /**
+ * Form submit logic goes here.
+ *
+ * @param array $data
+ * @param array $files
+ * @return mixed
+ */
+ abstract protected function doSubmit(array $data, array $files);
+
+ /**
+ * Validate data and throw validation exceptions if validation fails.
+ *
+ * @param \ArrayAccess $data
+ * @throws ValidationException
+ * @throws \Exception
+ */
+ protected function validateData(\ArrayAccess $data): void
+ {
+ if ($data instanceof Data) {
+ $data->validate();
+ }
+ }
+
+ /**
+ * Filter validated data.
+ *
+ * @param \ArrayAccess $data
+ */
+ protected function filterData(\ArrayAccess $data): void
+ {
+ if ($data instanceof Data) {
+ $data->filter();
+ }
+ }
+
+ /**
+ * Validate all uploaded files.
+ *
+ * @param array $files
+ */
+ protected function validateUploads(array $files): void
+ {
+ foreach ($files as $file) {
+ if (null === $file) {
+ continue;
+ }
+ if ($file instanceof UploadedFileInterface) {
+ $this->validateUpload($file);
+ } else {
+ $this->validateUploads($file);
+ }
+ }
+ }
+
+ /**
+ * Validate uploaded file.
+ *
+ * @param UploadedFileInterface $file
+ */
+ protected function validateUpload(UploadedFileInterface $file): void
+ {
+ // Handle bad filenames.
+ $filename = $file->getClientFilename();
+
+ if (!Utils::checkFilename($filename)) {
+ $grav = Grav::instance();
+ throw new \RuntimeException(
+ sprintf($grav['language']->translate('PLUGIN_FORM.FILEUPLOAD_UNABLE_TO_UPLOAD', null, true), $filename, 'Bad filename')
+ );
+ }
+ }
+
+ /**
+ * Decode POST data
+ *
+ * @param array $data
+ * @return array
+ */
+ protected function decodeData($data): array
+ {
+ if (!\is_array($data)) {
+ return [];
+ }
+
+ // Decode JSON encoded fields and merge them to data.
+ if (isset($data['_json'])) {
+ $data = array_replace_recursive($data, $this->jsonDecode($data['_json']));
+ unset($data['_json']);
+ }
+
+ return $data;
+ }
+
+ /**
+ * Recursively JSON decode POST data.
+ *
+ * @param array $data
+ * @return array
+ */
+ protected function jsonDecode(array $data): array
+ {
+ foreach ($data as $key => &$value) {
+ if (\is_array($value)) {
+ $value = $this->jsonDecode($value);
+ } elseif (trim($value) === '') {
+ unset($data[$key]);
+ } else {
+ $value = json_decode($value, true);
+ if ($value === null && json_last_error() !== JSON_ERROR_NONE) {
+ unset($data[$key]);
+ $this->setError("Badly encoded JSON data (for {$key}) was sent to the form");
+ }
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * @return array
+ */
+ protected function doSerialize(): array
+ {
+ $data = $this->data instanceof Data ? $this->data->toArray() : null;
+
+ return [
+ 'name' => $this->name,
+ 'id' => $this->id,
+ 'uniqueid' => $this->uniqueid,
+ 'submitted' => $this->submitted,
+ 'status' => $this->status,
+ 'message' => $this->message,
+ 'messages' => $this->messages,
+ 'data' => $data,
+ 'files' => $this->files,
+ ];
+ }
+
+ /**
+ * @param array $data
+ */
+ protected function doUnserialize(array $data): void
+ {
+ $this->name = $data['name'];
+ $this->id = $data['id'];
+ $this->uniqueid = $data['uniqueid'];
+ $this->submitted = $data['submitted'] ?? false;
+ $this->status = $data['status'] ?? 'success';
+ $this->message = $data['message'] ?? null;
+ $this->messages = $data['messages'] ?? [];
+ $this->data = isset($data['data']) ? new Data($data['data'], $this->getBlueprint()) : null;
+ $this->files = $data['files'] ?? [];
+ }
+}
diff --git a/system/src/Grav/Framework/Interfaces/RenderInterface.php b/system/src/Grav/Framework/Interfaces/RenderInterface.php
new file mode 100644
index 0000000..ca6d9bc
--- /dev/null
+++ b/system/src/Grav/Framework/Interfaces/RenderInterface.php
@@ -0,0 +1,38 @@
+render('custom', ['variable' => 'value']);
+ * @example {% render object layout 'custom' with { variable: 'value' } %}
+ *
+ * @param string|null $layout Layout to be used.
+ * @param array $context Extra context given to the renderer.
+ *
+ * @return ContentBlockInterface|HtmlBlock Returns `HtmlBlock` containing the rendered output.
+ * @api
+ */
+ public function render(string $layout = null, array $context = []);
+}
diff --git a/system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php b/system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php
new file mode 100644
index 0000000..e834bc8
--- /dev/null
+++ b/system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php
@@ -0,0 +1,17 @@
+hasProperty($offset);
+ }
+
+ /**
+ * Returns the value at specified offset.
+ *
+ * @param mixed $offset The offset to retrieve.
+ * @return mixed Can return all value types.
+ */
+ public function offsetGet($offset)
+ {
+ return $this->getProperty($offset);
+ }
+
+ /**
+ * Assigns a value to the specified offset.
+ *
+ * @param mixed $offset The offset to assign the value to.
+ * @param mixed $value The value to set.
+ */
+ public function offsetSet($offset, $value)
+ {
+ $this->setProperty($offset, $value);
+ }
+
+ /**
+ * Unsets an offset.
+ *
+ * @param mixed $offset The offset to unset.
+ */
+ public function offsetUnset($offset)
+ {
+ $this->unsetProperty($offset);
+ }
+
+ abstract public function hasProperty($property);
+ abstract public function getProperty($property, $default = null);
+ abstract public function setProperty($property, $value);
+ abstract public function unsetProperty($property);
+}
diff --git a/system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php b/system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php
new file mode 100644
index 0000000..858b391
--- /dev/null
+++ b/system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php
@@ -0,0 +1,65 @@
+hasNestedProperty($offset);
+ }
+
+ /**
+ * Returns the value at specified offset.
+ *
+ * @param mixed $offset The offset to retrieve.
+ * @return mixed Can return all value types.
+ */
+ public function offsetGet($offset)
+ {
+ return $this->getNestedProperty($offset);
+ }
+
+ /**
+ * Assigns a value to the specified offset.
+ *
+ * @param mixed $offset The offset to assign the value to.
+ * @param mixed $value The value to set.
+ */
+ public function offsetSet($offset, $value)
+ {
+ $this->setNestedProperty($offset, $value);
+ }
+
+ /**
+ * Unsets an offset.
+ *
+ * @param mixed $offset The offset to unset.
+ */
+ public function offsetUnset($offset)
+ {
+ $this->unsetNestedProperty($offset);
+ }
+
+ abstract public function hasNestedProperty($property, $separator = null);
+ abstract public function getNestedProperty($property, $default = null, $separator = null);
+ abstract public function setNestedProperty($property, $value, $separator = null);
+ abstract public function unsetNestedProperty($property, $separator = null);
+}
diff --git a/system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php b/system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php
new file mode 100644
index 0000000..5ac0390
--- /dev/null
+++ b/system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php
@@ -0,0 +1,125 @@
+getIterator() as $id => $element) {
+ $list[$id] = $element->hasNestedProperty($property, $separator);
+ }
+
+ return $list;
+ }
+
+ /**
+ * @param string $property Object property to be fetched.
+ * @param mixed $default Default value if not set.
+ * @param string $separator Separator, defaults to '.'
+ * @return array Key/Value pairs of the properties.
+ */
+ public function getNestedProperty($property, $default = null, $separator = null)
+ {
+ $list = [];
+
+ /** @var NestedObjectInterface $element */
+ foreach ($this->getIterator() as $id => $element) {
+ $list[$id] = $element->getNestedProperty($property, $default, $separator);
+ }
+
+ return $list;
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param string $value New value.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function setNestedProperty($property, $value, $separator = null)
+ {
+ /** @var NestedObjectInterface $element */
+ foreach ($this->getIterator() as $element) {
+ $element->setNestedProperty($property, $value, $separator);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function unsetNestedProperty($property, $separator = null)
+ {
+ /** @var NestedObjectInterface $element */
+ foreach ($this->getIterator() as $element) {
+ $element->unsetNestedProperty($property, $separator);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param string $default Default value.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ */
+ public function defNestedProperty($property, $default, $separator = null)
+ {
+ /** @var NestedObjectInterface $element */
+ foreach ($this->getIterator() as $element) {
+ $element->defNestedProperty($property, $default, $separator);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Group items in the collection by a field.
+ *
+ * @param string $property Object property to be used to make groups.
+ * @param string $separator Separator, defaults to '.'
+ * @return array
+ */
+ public function group($property, $separator = null)
+ {
+ $list = [];
+
+ /** @var NestedObjectInterface $element */
+ foreach ($this->getIterator() as $element) {
+ $list[(string) $element->getNestedProperty($property, null, $separator)][] = $element;
+ }
+
+ return $list;
+ }
+
+ /**
+ * @return \Traversable
+ */
+ abstract public function getIterator();
+}
diff --git a/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
new file mode 100644
index 0000000..2200871
--- /dev/null
+++ b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
@@ -0,0 +1,183 @@
+getNestedProperty($property, $test, $separator) !== $test;
+ }
+
+ /**
+ * @param string $property Object property to be fetched.
+ * @param mixed $default Default value if property has not been set.
+ * @param string $separator Separator, defaults to '.'
+ * @return mixed Property value.
+ */
+ public function getNestedProperty($property, $default = null, $separator = null)
+ {
+ $separator = $separator ?: '.';
+ $path = explode($separator, $property) ?: [];
+ $offset = array_shift($path) ?? '';
+
+ if (!$this->hasProperty($offset)) {
+ return $default;
+ }
+
+ $current = $this->getProperty($offset);
+
+ while ($path) {
+ // Get property of nested Object.
+ if ($current instanceof ObjectInterface) {
+ if (method_exists($current, 'getNestedProperty')) {
+ return $current->getNestedProperty(implode($separator, $path), $default, $separator);
+ }
+ return $current->getProperty(implode($separator, $path), $default);
+ }
+
+ $offset = array_shift($path);
+
+ if ((\is_array($current) || is_a($current, 'ArrayAccess')) && isset($current[$offset])) {
+ $current = $current[$offset];
+ } elseif (\is_object($current) && isset($current->{$offset})) {
+ $current = $current->{$offset};
+ } else {
+ return $default;
+ }
+ };
+
+ return $current;
+ }
+
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param string $value New value.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ * @throws \RuntimeException
+ */
+ public function setNestedProperty($property, $value, $separator = null)
+ {
+ $separator = $separator ?: '.';
+ $path = explode($separator, $property) ?: [];
+ $offset = array_shift($path) ?? '';
+
+ if (!$path) {
+ $this->setProperty($offset, $value);
+
+ return $this;
+ }
+
+ $current = &$this->doGetProperty($offset, null, true);
+
+ while ($path) {
+ $offset = array_shift($path);
+
+ // Handle arrays and scalars.
+ if ($current === null) {
+ $current = [$offset => []];
+ } elseif (\is_array($current)) {
+ if (!isset($current[$offset])) {
+ $current[$offset] = [];
+ }
+ } else {
+ throw new \RuntimeException("Cannot set nested property {$property} on non-array value");
+ }
+
+ $current = &$current[$offset];
+ };
+
+ $current = $value;
+
+ return $this;
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ * @throws \RuntimeException
+ */
+ public function unsetNestedProperty($property, $separator = null)
+ {
+ $separator = $separator ?: '.';
+ $path = explode($separator, $property) ?: [];
+ $offset = array_shift($path) ?? '';
+
+ if (!$path) {
+ $this->unsetProperty($offset);
+
+ return $this;
+ }
+
+ $last = array_pop($path);
+ $current = &$this->doGetProperty($offset, null, true);
+
+ while ($path) {
+ $offset = array_shift($path);
+
+ // Handle arrays and scalars.
+ if ($current === null) {
+ return $this;
+ }
+ if (\is_array($current)) {
+ if (!isset($current[$offset])) {
+ return $this;
+ }
+ } else {
+ throw new \RuntimeException("Cannot unset nested property {$property} on non-array value");
+ }
+
+ $current = &$current[$offset];
+ };
+
+ unset($current[$last]);
+
+ return $this;
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param mixed $default Default value.
+ * @param string $separator Separator, defaults to '.'
+ * @return $this
+ * @throws \RuntimeException
+ */
+ public function defNestedProperty($property, $default, $separator = null)
+ {
+ if (!$this->hasNestedProperty($property, $separator)) {
+ $this->setNestedProperty($property, $default, $separator);
+ }
+
+ return $this;
+ }
+
+
+ abstract public function hasProperty($property);
+ abstract public function getProperty($property, $default = null);
+ abstract public function setProperty($property, $value);
+ abstract public function unsetProperty($property);
+ abstract protected function &doGetProperty($property, $default = null, $doCreate = false);
+}
diff --git a/system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php b/system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php
new file mode 100644
index 0000000..029dbba
--- /dev/null
+++ b/system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php
@@ -0,0 +1,65 @@
+hasProperty($offset);
+ }
+
+ /**
+ * Returns the value at specified offset.
+ *
+ * @param mixed $offset The offset to retrieve.
+ * @return mixed Can return all value types.
+ */
+ public function __get($offset)
+ {
+ return $this->getProperty($offset);
+ }
+
+ /**
+ * Assigns a value to the specified offset.
+ *
+ * @param mixed $offset The offset to assign the value to.
+ * @param mixed $value The value to set.
+ */
+ public function __set($offset, $value)
+ {
+ $this->setProperty($offset, $value);
+ }
+
+ /**
+ * Magic method to unset the attribute
+ *
+ * @param mixed $offset The name value to unset
+ */
+ public function __unset($offset)
+ {
+ $this->unsetProperty($offset);
+ }
+
+ abstract public function hasProperty($property);
+ abstract public function getProperty($property, $default = null);
+ abstract public function setProperty($property, $value);
+ abstract public function unsetProperty($property);
+}
diff --git a/system/src/Grav/Framework/Object/ArrayObject.php b/system/src/Grav/Framework/Object/ArrayObject.php
new file mode 100644
index 0000000..a7062e8
--- /dev/null
+++ b/system/src/Grav/Framework/Object/ArrayObject.php
@@ -0,0 +1,29 @@
+getIterator() as $key => $value) {
+ $list[$key] = \is_object($value) ? clone $value : $value;
+ }
+
+ return $this->createFrom($list);
+ }
+
+ /**
+ * @return array
+ */
+ public function getObjectKeys()
+ {
+ return $this->call('getKey');
+ }
+
+ /**
+ * @param string $property Object property to be matched.
+ * @return bool[] Key/Value pairs of the properties.
+ */
+ public function doHasProperty($property)
+ {
+ $list = [];
+
+ /** @var ObjectInterface $element */
+ foreach ($this->getIterator() as $id => $element) {
+ $list[$id] = $element->hasProperty($property);
+ }
+
+ return $list;
+ }
+
+ /**
+ * @param string $property Object property to be fetched.
+ * @param mixed $default Default value if not set.
+ * @return mixed[] Key/Value pairs of the properties.
+ */
+ public function doGetProperty($property, $default = null)
+ {
+ $list = [];
+
+ /** @var ObjectInterface $element */
+ foreach ($this->getIterator() as $id => $element) {
+ $list[$id] = $element->getProperty($property, $default);
+ }
+
+ return $list;
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param mixed $value New value.
+ * @return $this
+ */
+ public function doSetProperty($property, $value)
+ {
+ /** @var ObjectInterface $element */
+ foreach ($this->getIterator() as $element) {
+ $element->setProperty($property, $value);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @return $this
+ */
+ public function doUnsetProperty($property)
+ {
+ /** @var ObjectInterface $element */
+ foreach ($this->getIterator() as $element) {
+ $element->unsetProperty($property);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param mixed $default Default value.
+ * @return $this
+ */
+ public function doDefProperty($property, $default)
+ {
+ /** @var ObjectInterface $element */
+ foreach ($this->getIterator() as $element) {
+ $element->defProperty($property, $default);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param string $method Method name.
+ * @param array $arguments List of arguments passed to the function.
+ * @return mixed[] Return values.
+ */
+ public function call($method, array $arguments = [])
+ {
+ $list = [];
+
+ /**
+ * @var string|int $id
+ * @var ObjectInterface $element
+ */
+ foreach ($this->getIterator() as $id => $element) {
+ $callable = method_exists($element, $method) ? [$element, $method] : null;
+ $list[$id] = $callable ? \call_user_func_array($callable, $arguments) : null;
+ }
+
+ return $list;
+ }
+
+ /**
+ * Group items in the collection by a field and return them as associated array.
+ *
+ * @param string $property
+ * @return array
+ */
+ public function group($property)
+ {
+ $list = [];
+
+ /** @var ObjectInterface $element */
+ foreach ($this->getIterator() as $element) {
+ $list[(string) $element->getProperty($property)][] = $element;
+ }
+
+ return $list;
+ }
+
+ /**
+ * Group items in the collection by a field and return them as associated array of collections.
+ *
+ * @param string $property
+ * @return static[]
+ */
+ public function collectionGroup($property)
+ {
+ $collections = [];
+ foreach ($this->group($property) as $id => $elements) {
+ $collection = $this->createFrom($elements);
+
+ $collections[$id] = $collection;
+ }
+
+ return $collections;
+ }
+
+ /**
+ * @return \Traversable
+ */
+ abstract public function getIterator();
+}
diff --git a/system/src/Grav/Framework/Object/Base/ObjectTrait.php b/system/src/Grav/Framework/Object/Base/ObjectTrait.php
new file mode 100644
index 0000000..baeeb2b
--- /dev/null
+++ b/system/src/Grav/Framework/Object/Base/ObjectTrait.php
@@ -0,0 +1,204 @@
+getTypePrefix() : '';
+
+ if (static::$type) {
+ return $type . static::$type;
+ }
+
+ $class = \get_class($this);
+ return $type . strtolower(substr($class, strrpos($class, '\\') + 1));
+ }
+
+ /**
+ * @return string
+ */
+ public function getKey()
+ {
+ return $this->_key ?: $this->getType() . '@@' . spl_object_hash($this);
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasKey()
+ {
+ return !empty($this->_key);
+ }
+
+ /**
+ * @param string $property Object property name.
+ * @return bool|bool[] True if property has been defined (can be null).
+ */
+ public function hasProperty($property)
+ {
+ return $this->doHasProperty($property);
+ }
+
+ /**
+ * @param string $property Object property to be fetched.
+ * @param mixed $default Default value if property has not been set.
+ * @return mixed|mixed[] Property value.
+ */
+ public function getProperty($property, $default = null)
+ {
+ return $this->doGetProperty($property, $default);
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param mixed $value New value.
+ * @return $this
+ */
+ public function setProperty($property, $value)
+ {
+ $this->doSetProperty($property, $value);
+
+ return $this;
+ }
+
+ /**
+ * @param string $property Object property to be unset.
+ * @return $this
+ */
+ public function unsetProperty($property)
+ {
+ $this->doUnsetProperty($property);
+
+ return $this;
+ }
+
+ /**
+ * @param string $property Object property to be defined.
+ * @param mixed $default Default value.
+ * @return $this
+ */
+ public function defProperty($property, $default)
+ {
+ if (!$this->hasProperty($property)) {
+ $this->setProperty($property, $default);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Implements Serializable interface.
+ *
+ * @return string
+ */
+ public function serialize()
+ {
+ return serialize($this->doSerialize());
+ }
+
+ /**
+ * @param string $serialized
+ */
+ public function unserialize($serialized)
+ {
+ $data = unserialize($serialized);
+
+ if (method_exists($this, 'initObjectProperties')) {
+ $this->initObjectProperties();
+ }
+ $this->doUnserialize($data);
+ }
+
+ /**
+ * @return array
+ */
+ protected function doSerialize()
+ {
+ return ['key' => $this->getKey(), 'type' => $this->getType(), 'elements' => $this->getElements()];
+ }
+
+ /**
+ * @param array $serialized
+ */
+ protected function doUnserialize(array $serialized)
+ {
+ if (!isset($serialized['key'], $serialized['type'], $serialized['elements']) || $serialized['type'] !== $this->getType()) {
+ throw new \InvalidArgumentException("Cannot unserialize '{$this->getType()}': Bad data");
+ }
+
+ $this->setKey($serialized['key']);
+ $this->setElements($serialized['elements']);
+ }
+
+ /**
+ * Implements JsonSerializable interface.
+ *
+ * @return array
+ */
+ public function jsonSerialize()
+ {
+ return $this->doSerialize();
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->getKey();
+ }
+
+ /**
+ * @param string $key
+ * @return $this
+ */
+ protected function setKey($key)
+ {
+ $this->_key = (string) $key;
+
+ return $this;
+ }
+
+ abstract protected function doHasProperty($property);
+ abstract protected function &doGetProperty($property, $default = null, $doCreate = false);
+ abstract protected function doSetProperty($property, $value);
+ abstract protected function doUnsetProperty($property);
+ abstract protected function getElements();
+ abstract protected function setElements(array $elements);
+}
diff --git a/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
new file mode 100644
index 0000000..0eefb78
--- /dev/null
+++ b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
@@ -0,0 +1,199 @@
+{$accessor}();
+ break;
+ }
+ }
+
+ if ($op) {
+ $function = 'filter' . ucfirst(strtolower($op));
+ if (method_exists(static::class, $function)) {
+ $value = static::$function($value);
+ }
+ }
+
+ return $value;
+ }
+
+ public static function filterLower($str)
+ {
+ return mb_strtolower($str);
+ }
+
+ public static function filterUpper($str)
+ {
+ return mb_strtoupper($str);
+ }
+
+ public static function filterLength($str)
+ {
+ return mb_strlen($str);
+ }
+
+ public static function filterLtrim($str)
+ {
+ return ltrim($str);
+ }
+
+ public static function filterRtrim($str)
+ {
+ return rtrim($str);
+ }
+
+ public static function filterTrim($str)
+ {
+ return trim($str);
+ }
+
+ /**
+ * Helper for sorting arrays of objects based on multiple fields + orientations.
+ *
+ * @param string $name
+ * @param int $orientation
+ * @param \Closure $next
+ *
+ * @return \Closure
+ */
+ public static function sortByField($name, $orientation = 1, \Closure $next = null)
+ {
+ if (!$next) {
+ $next = function($a, $b) {
+ return 0;
+ };
+ }
+
+ return function ($a, $b) use ($name, $next, $orientation) {
+ $aValue = static::getObjectFieldValue($a, $name);
+ $bValue = static::getObjectFieldValue($b, $name);
+
+ if ($aValue === $bValue) {
+ return $next($a, $b);
+ }
+
+ return (($aValue > $bValue) ? 1 : -1) * $orientation;
+ };
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function walkComparison(Comparison $comparison)
+ {
+ $field = $comparison->getField();
+ $value = $comparison->getValue()->getValue(); // shortcut for walkValue()
+
+ switch ($comparison->getOperator()) {
+ case Comparison::EQ:
+ return function ($object) use ($field, $value) {
+ return static::getObjectFieldValue($object, $field) === $value;
+ };
+
+ case Comparison::NEQ:
+ return function ($object) use ($field, $value) {
+ return static::getObjectFieldValue($object, $field) !== $value;
+ };
+
+ case Comparison::LT:
+ return function ($object) use ($field, $value) {
+ return static::getObjectFieldValue($object, $field) < $value;
+ };
+
+ case Comparison::LTE:
+ return function ($object) use ($field, $value) {
+ return static::getObjectFieldValue($object, $field) <= $value;
+ };
+
+ case Comparison::GT:
+ return function ($object) use ($field, $value) {
+ return static::getObjectFieldValue($object, $field) > $value;
+ };
+
+ case Comparison::GTE:
+ return function ($object) use ($field, $value) {
+ return static::getObjectFieldValue($object, $field) >= $value;
+ };
+
+ case Comparison::IN:
+ return function ($object) use ($field, $value) {
+ return \in_array(static::getObjectFieldValue($object, $field), $value, true);
+ };
+
+ case Comparison::NIN:
+ return function ($object) use ($field, $value) {
+ return !\in_array(static::getObjectFieldValue($object, $field), $value, true);
+ };
+
+ case Comparison::CONTAINS:
+ return function ($object) use ($field, $value) {
+ return false !== strpos(static::getObjectFieldValue($object, $field), $value);
+ };
+
+ case Comparison::MEMBER_OF:
+ return function ($object) use ($field, $value) {
+ $fieldValues = static::getObjectFieldValue($object, $field);
+ if (!\is_array($fieldValues)) {
+ $fieldValues = iterator_to_array($fieldValues);
+ }
+ return \in_array($value, $fieldValues, true);
+ };
+
+ case Comparison::STARTS_WITH:
+ return function ($object) use ($field, $value) {
+ return 0 === strpos(static::getObjectFieldValue($object, $field), $value);
+ };
+
+ case Comparison::ENDS_WITH:
+ return function ($object) use ($field, $value) {
+ return $value === substr(static::getObjectFieldValue($object, $field), -strlen($value));
+ };
+
+
+ default:
+ throw new \RuntimeException("Unknown comparison operator: " . $comparison->getOperator());
+ }
+ }
+}
diff --git a/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php b/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
new file mode 100644
index 0000000..8d6025a
--- /dev/null
+++ b/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
@@ -0,0 +1,58 @@
+setElements($elements));
+
+ $this->setKey($key ?? '');
+ }
+
+ /**
+ * @param array $ordering
+ * @return Collection|static
+ */
+ public function orderBy(array $ordering)
+ {
+ $criteria = Criteria::create()->orderBy($ordering);
+
+ return $this->matching($criteria);
+ }
+
+ /**
+ * @param int $start
+ * @param int|null $limit
+ * @return static
+ */
+ public function limit($start, $limit = null)
+ {
+ return $this->createFrom($this->slice($start, $limit));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function matching(Criteria $criteria)
+ {
+ $expr = $criteria->getWhereExpression();
+ $filtered = $this->getElements();
+
+ if ($expr) {
+ $visitor = new ObjectExpressionVisitor();
+ $filter = $visitor->dispatch($expr);
+ $filtered = array_filter($filtered, $filter);
+ }
+
+ if ($orderings = $criteria->getOrderings()) {
+ $next = null;
+ /**
+ * @var string $field
+ * @var string $ordering
+ */
+ foreach (array_reverse($orderings) as $field => $ordering) {
+ $next = ObjectExpressionVisitor::sortByField($field, $ordering === Criteria::DESC ? -1 : 1, $next);
+ }
+
+ if ($next) {
+ uasort($filtered, $next);
+ }
+ }
+
+ $offset = $criteria->getFirstResult();
+ $length = $criteria->getMaxResults();
+
+ if ($offset || $length) {
+ $filtered = \array_slice($filtered, (int)$offset, $length);
+ }
+
+ return $this->createFrom($filtered);
+ }
+
+ protected function getElements()
+ {
+ return $this->toArray();
+ }
+
+ protected function setElements(array $elements)
+ {
+ return $elements;
+ }
+}
diff --git a/system/src/Grav/Framework/Object/ObjectIndex.php b/system/src/Grav/Framework/Object/ObjectIndex.php
new file mode 100644
index 0000000..4ba9b75
--- /dev/null
+++ b/system/src/Grav/Framework/Object/ObjectIndex.php
@@ -0,0 +1,251 @@
+getTypePrefix() : '';
+
+ if (static::$type) {
+ return $type . static::$type;
+ }
+
+ $class = \get_class($this);
+ return $type . strtolower(substr($class, strrpos($class, '\\') + 1));
+ }
+
+ /**
+ * @return string
+ */
+ public function getKey()
+ {
+ return $this->_key ?: $this->getType() . '@@' . spl_object_hash($this);
+ }
+
+ /**
+ * @param string $key
+ * @return $this
+ */
+ public function setKey($key)
+ {
+ $this->_key = $key;
+
+ return $this;
+ }
+
+ /**
+ * @param string $property Object property name.
+ * @return array True if property has been defined (can be null).
+ */
+ public function hasProperty($property)
+ {
+ return $this->__call('hasProperty', [$property]);
+ }
+
+ /**
+ * @param string $property Object property to be fetched.
+ * @param mixed $default Default value if property has not been set.
+ * @return array Property values.
+ */
+ public function getProperty($property, $default = null)
+ {
+ return $this->__call('getProperty', [$property, $default]);
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param string $value New value.
+ * @return ObjectCollectionInterface
+ */
+ public function setProperty($property, $value)
+ {
+ return $this->__call('setProperty', [$property, $value]);
+ }
+
+ /**
+ * @param string $property Object property to be defined.
+ * @param mixed $default Default value.
+ * @return ObjectCollectionInterface
+ */
+ public function defProperty($property, $default)
+ {
+ return $this->__call('defProperty', [$property, $default]);
+ }
+
+ /**
+ * @param string $property Object property to be unset.
+ * @return ObjectCollectionInterface
+ */
+ public function unsetProperty($property)
+ {
+ return $this->__call('unsetProperty', [$property]);
+ }
+
+ /**
+ * @param string $property Object property name.
+ * @param string $separator Separator, defaults to '.'
+ * @return bool True if property has been defined (can be null).
+ */
+ public function hasNestedProperty($property, $separator = null)
+ {
+ return $this->__call('hasNestedProperty', [$property, $separator]);
+ }
+
+ /**
+ * @param string $property Object property to be fetched.
+ * @param mixed $default Default value if property has not been set.
+ * @param string $separator Separator, defaults to '.'
+ * @return mixed Property value.
+ */
+ public function getNestedProperty($property, $default = null, $separator = null)
+ {
+ return $this->__call('getNestedProperty', [$property, $default, $separator]);
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param string $value New value.
+ * @param string $separator Separator, defaults to '.'
+ * @return ObjectCollectionInterface
+ */
+ public function setNestedProperty($property, $value, $separator = null)
+ {
+ return $this->__call('setNestedProperty', [$property, $value, $separator]);
+ }
+
+ /**
+ * @param string $property Object property to be defined.
+ * @param mixed $default Default value.
+ * @param string $separator Separator, defaults to '.'
+ * @return ObjectCollectionInterface
+ */
+ public function defNestedProperty($property, $default, $separator = null)
+ {
+ return $this->__call('defNestedProperty', [$property, $default, $separator]);
+ }
+
+ /**
+ * @param string $property Object property to be unset.
+ * @return ObjectCollectionInterface
+ */
+ public function unsetNestedProperty($property, $separator = null)
+ {
+ return $this->__call('unsetNestedProperty', [$property, $separator]);
+ }
+
+ /**
+ * Create a copy from this collection by cloning all objects in the collection.
+ *
+ * @return static
+ */
+ public function copy()
+ {
+ $list = [];
+ foreach ($this->getIterator() as $key => $value) {
+ $list[$key] = \is_object($value) ? clone $value : $value;
+ }
+
+ return $this->createFrom($list);
+ }
+
+ /**
+ * @return array
+ */
+ public function getObjectKeys()
+ {
+ return $this->getKeys();
+ }
+
+ /**
+ * @param array $ordering
+ * @return ObjectCollectionInterface
+ */
+ public function orderBy(array $ordering)
+ {
+ return $this->__call('orderBy', [$ordering]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function call($method, array $arguments = [])
+ {
+ return $this->__call('call', [$method, $arguments]);
+ }
+
+ /**
+ * Group items in the collection by a field and return them as associated array.
+ *
+ * @param string $property
+ * @return array
+ */
+ public function group($property)
+ {
+ return $this->__call('group', [$property]);
+ }
+
+ /**
+ * Group items in the collection by a field and return them as associated array of collections.
+ *
+ * @param string $property
+ * @return ObjectCollectionInterface[]
+ */
+ public function collectionGroup($property)
+ {
+ return $this->__call('collectionGroup', [$property]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function matching(Criteria $criteria)
+ {
+ /** @var ObjectCollectionInterface $collection */
+ $collection = $this->loadCollection($this->getEntries());
+
+ return $collection->matching($criteria);
+ }
+
+ abstract public function __call($name, $arguments);
+
+ /**
+ * @return string
+ */
+ protected function getTypePrefix()
+ {
+ return '';
+ }
+}
diff --git a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
new file mode 100644
index 0000000..7092e15
--- /dev/null
+++ b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
@@ -0,0 +1,110 @@
+setElements($elements);
+ $this->setKey($key ?? '');
+ }
+
+ /**
+ * @param string $property Object property name.
+ * @return bool True if property has been defined (can be null).
+ */
+ protected function doHasProperty($property)
+ {
+ return array_key_exists($property, $this->_elements);
+ }
+
+ /**
+ * @param string $property Object property to be fetched.
+ * @param mixed $default Default value if property has not been set.
+ * @param bool $doCreate Set true to create variable.
+ * @return mixed Property value.
+ */
+ protected function &doGetProperty($property, $default = null, $doCreate = false)
+ {
+ if (!array_key_exists($property, $this->_elements)) {
+ if ($doCreate) {
+ $this->_elements[$property] = null;
+ } else {
+ return $default;
+ }
+ }
+
+ return $this->_elements[$property];
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param mixed $value New value.
+ */
+ protected function doSetProperty($property, $value)
+ {
+ $this->_elements[$property] = $value;
+ }
+
+ /**
+ * @param string $property Object property to be unset.
+ */
+ protected function doUnsetProperty($property)
+ {
+ unset($this->_elements[$property]);
+ }
+
+ /**
+ * @param string $property
+ * @param mixed|null $default
+ * @return mixed|null
+ */
+ protected function getElement($property, $default = null)
+ {
+ return array_key_exists($property, $this->_elements) ? $this->_elements[$property] : $default;
+ }
+
+ /**
+ * @return array
+ */
+ protected function getElements()
+ {
+ return array_filter($this->_elements, function ($val) { return $val !== null; });
+ }
+
+ /**
+ * @param array $elements
+ */
+ protected function setElements(array $elements)
+ {
+ $this->_elements = $elements;
+ }
+
+ abstract protected function setKey($key);
+}
diff --git a/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php b/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php
new file mode 100644
index 0000000..1066b99
--- /dev/null
+++ b/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php
@@ -0,0 +1,118 @@
+offsetLoad($offset, $value)` called first time object property gets accessed
+ * - `$this->offsetPrepare($offset, $value)` called on every object property set
+ * - `$this->offsetSerialize($offset, $value)` called when the raw or serialized object property value is needed
+ *
+ * @package Grav\Framework\Object\Property
+ */
+trait LazyPropertyTrait
+{
+ use ArrayPropertyTrait, ObjectPropertyTrait {
+ ObjectPropertyTrait::__construct insteadof ArrayPropertyTrait;
+ ArrayPropertyTrait::doHasProperty as hasArrayProperty;
+ ArrayPropertyTrait::doGetProperty as getArrayProperty;
+ ArrayPropertyTrait::doSetProperty as setArrayProperty;
+ ArrayPropertyTrait::doUnsetProperty as unsetArrayProperty;
+ ArrayPropertyTrait::getElement as getArrayElement;
+ ArrayPropertyTrait::getElements as getArrayElements;
+ ArrayPropertyTrait::setElements insteadof ObjectPropertyTrait;
+ ObjectPropertyTrait::doHasProperty as hasObjectProperty;
+ ObjectPropertyTrait::doGetProperty as getObjectProperty;
+ ObjectPropertyTrait::doSetProperty as setObjectProperty;
+ ObjectPropertyTrait::doUnsetProperty as unsetObjectProperty;
+ ObjectPropertyTrait::getElement as getObjectElement;
+ ObjectPropertyTrait::getElements as getObjectElements;
+ }
+
+ /**
+ * @param string $property Object property name.
+ * @return bool True if property has been defined (can be null).
+ */
+ protected function doHasProperty($property)
+ {
+ return $this->hasArrayProperty($property) || $this->hasObjectProperty($property);
+ }
+
+ /**
+ * @param string $property Object property to be fetched.
+ * @param mixed $default Default value if property has not been set.
+ * @return mixed Property value.
+ */
+ protected function &doGetProperty($property, $default = null, $doCreate = false)
+ {
+ if ($this->hasObjectProperty($property)) {
+ return $this->getObjectProperty($property, $default, function ($default = null) use ($property) {
+ return $this->getArrayProperty($property, $default);
+ });
+ }
+
+ return $this->getArrayProperty($property, $default, $doCreate);
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param mixed $value New value.
+ * @return $this
+ */
+ protected function doSetProperty($property, $value)
+ {
+ if ($this->hasObjectProperty($property)) {
+ $this->setObjectProperty($property, $value);
+ } else {
+ $this->setArrayProperty($property, $value);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param string $property Object property to be unset.
+ * @return $this
+ */
+ protected function doUnsetProperty($property)
+ {
+ $this->hasObjectProperty($property) ?
+ $this->unsetObjectProperty($property) : $this->unsetArrayProperty($property);
+
+ return $this;
+ }
+
+ /**
+ * @param string $property
+ * @param mixed|null $default
+ * @return mixed|null
+ */
+ protected function getElement($property, $default = null)
+ {
+ if ($this->isPropertyLoaded($property)) {
+ return $this->getObjectElement($property, $default);
+ }
+
+ return $this->getArrayElement($property, $default);
+ }
+
+ /**
+ * @return array
+ */
+ protected function getElements()
+ {
+ return $this->getObjectElements() + $this->getArrayElements();
+ }
+}
diff --git a/system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php b/system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php
new file mode 100644
index 0000000..149ac40
--- /dev/null
+++ b/system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php
@@ -0,0 +1,123 @@
+offsetLoad($offset, $value)` called first time object property gets accessed
+ * - `$this->offsetPrepare($offset, $value)` called on every object property set
+ * - `$this->offsetSerialize($offset, $value)` called when the raw or serialized object property value is needed
+
+ *
+ * @package Grav\Framework\Object\Property
+ */
+trait MixedPropertyTrait
+{
+ use ArrayPropertyTrait, ObjectPropertyTrait {
+ ObjectPropertyTrait::__construct insteadof ArrayPropertyTrait;
+ ArrayPropertyTrait::doHasProperty as hasArrayProperty;
+ ArrayPropertyTrait::doGetProperty as getArrayProperty;
+ ArrayPropertyTrait::doSetProperty as setArrayProperty;
+ ArrayPropertyTrait::doUnsetProperty as unsetArrayProperty;
+ ArrayPropertyTrait::getElement as getArrayElement;
+ ArrayPropertyTrait::getElements as getArrayElements;
+ ArrayPropertyTrait::setElements as setArrayElements;
+ ObjectPropertyTrait::doHasProperty as hasObjectProperty;
+ ObjectPropertyTrait::doGetProperty as getObjectProperty;
+ ObjectPropertyTrait::doSetProperty as setObjectProperty;
+ ObjectPropertyTrait::doUnsetProperty as unsetObjectProperty;
+ ObjectPropertyTrait::getElement as getObjectElement;
+ ObjectPropertyTrait::getElements as getObjectElements;
+ ObjectPropertyTrait::setElements as setObjectElements;
+ }
+
+ /**
+ * @param string $property Object property name.
+ * @return bool True if property has been defined (can be null).
+ */
+ protected function doHasProperty($property)
+ {
+ return $this->hasArrayProperty($property) || $this->hasObjectProperty($property);
+ }
+
+ /**
+ * @param string $property Object property to be fetched.
+ * @param mixed $default Default value if property has not been set.
+ * @return mixed Property value.
+ */
+ protected function &doGetProperty($property, $default = null, $doCreate = false)
+ {
+ if ($this->hasObjectProperty($property)) {
+ return $this->getObjectProperty($property);
+ }
+
+ return $this->getArrayProperty($property, $default, $doCreate);
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param mixed $value New value.
+ * @return $this
+ */
+ protected function doSetProperty($property, $value)
+ {
+ $this->hasObjectProperty($property)
+ ? $this->setObjectProperty($property, $value) : $this->setArrayProperty($property, $value);
+
+ return $this;
+ }
+
+ /**
+ * @param string $property Object property to be unset.
+ * @return $this
+ */
+ protected function doUnsetProperty($property)
+ {
+ $this->hasObjectProperty($property) ?
+ $this->unsetObjectProperty($property) : $this->unsetArrayProperty($property);
+
+ return $this;
+ }
+
+ /**
+ * @param string $property
+ * @param mixed|null $default
+ * @return mixed|null
+ */
+ protected function getElement($property, $default = null)
+ {
+ if ($this->hasObjectProperty($property)) {
+ return $this->getObjectElement($property, $default);
+ }
+
+ return $this->getArrayElement($property, $default);
+ }
+
+ /**
+ * @return array
+ */
+ protected function getElements()
+ {
+ return $this->getObjectElements() + $this->getArrayElements();
+ }
+
+ /**
+ * @param array $elements
+ */
+ protected function setElements(array $elements)
+ {
+ $this->setObjectElements(array_intersect_key($elements, $this->_definedProperties));
+ $this->setArrayElements(array_diff_key($elements, $this->_definedProperties));
+ }
+}
diff --git a/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php b/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
new file mode 100644
index 0000000..5f8fdf0
--- /dev/null
+++ b/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
@@ -0,0 +1,207 @@
+offsetLoad($offset, $value)` called first time object property gets accessed
+ * - `$this->offsetPrepare($offset, $value)` called on every object property set
+ * - `$this->offsetSerialize($offset, $value)` called when the raw or serialized object property value is needed
+ *
+ * @package Grav\Framework\Object\Property
+ */
+trait ObjectPropertyTrait
+{
+ /**
+ * @var array
+ */
+ private $_definedProperties;
+
+ /**
+ * @param array $elements
+ * @param string $key
+ * @throws \InvalidArgumentException
+ */
+ public function __construct(array $elements = [], $key = null)
+ {
+ $this->initObjectProperties();
+ $this->setElements($elements);
+ $this->setKey($key ?? '');
+ }
+
+ /**
+ * @param string $property Object property name.
+ * @return bool True if property has been loaded.
+ */
+ protected function isPropertyLoaded($property)
+ {
+ return !empty($this->_definedProperties[$property]);
+ }
+
+ /**
+ * @param string $offset
+ * @param mixed $value
+ * @return mixed
+ */
+ protected function offsetLoad($offset, $value)
+ {
+ $methodName = "offsetLoad_{$offset}";
+
+ return method_exists($this, $methodName)? $this->{$methodName}($value) : $value;
+ }
+
+ /**
+ * @param string $offset
+ * @param mixed $value
+ * @return mixed
+ */
+ protected function offsetPrepare($offset, $value)
+ {
+ $methodName = "offsetPrepare_{$offset}";
+
+ return method_exists($this, $methodName) ? $this->{$methodName}($value) : $value;
+ }
+
+ /**
+ * @param string $offset
+ * @param mixed $value
+ * @return mixed
+ */
+ protected function offsetSerialize($offset, $value)
+ {
+ $methodName = "offsetSerialize_{$offset}";
+
+ return method_exists($this, $methodName) ? $this->{$methodName}($value) : $value;
+ }
+
+ /**
+ * @param string $property Object property name.
+ * @return bool True if property has been defined (can be null).
+ */
+ protected function doHasProperty($property)
+ {
+ return array_key_exists($property, $this->_definedProperties);
+ }
+
+ /**
+ * @param string $property Object property to be fetched.
+ * @param mixed $default Default value if property has not been set.
+ * @param callable|bool $doCreate Set true to create variable.
+ * @return mixed Property value.
+ */
+ protected function &doGetProperty($property, $default = null, $doCreate = false)
+ {
+ if (!array_key_exists($property, $this->_definedProperties)) {
+ throw new \InvalidArgumentException("Property '{$property}' does not exist in the object!");
+ }
+
+ if (empty($this->_definedProperties[$property])) {
+ if ($doCreate === true) {
+ $this->_definedProperties[$property] = true;
+ $this->{$property} = null;
+ } elseif (\is_callable($doCreate)) {
+ $this->_definedProperties[$property] = true;
+ $this->{$property} = $this->offsetLoad($property, $doCreate());
+ } else {
+ return $default;
+ }
+ }
+
+ return $this->{$property};
+ }
+
+ /**
+ * @param string $property Object property to be updated.
+ * @param mixed $value New value.
+ * @throws \InvalidArgumentException
+ */
+ protected function doSetProperty($property, $value)
+ {
+ if (!array_key_exists($property, $this->_definedProperties)) {
+ throw new \InvalidArgumentException("Property '{$property}' does not exist in the object!");
+ }
+
+ $this->_definedProperties[$property] = true;
+ $this->{$property} = $this->offsetPrepare($property, $value);
+ }
+
+ /**
+ * @param string $property Object property to be unset.
+ */
+ protected function doUnsetProperty($property)
+ {
+ if (!array_key_exists($property, $this->_definedProperties)) {
+ return;
+ }
+
+ $this->_definedProperties[$property] = false;
+ unset($this->{$property});
+ }
+
+ protected function initObjectProperties()
+ {
+ $this->_definedProperties = [];
+ foreach (\get_object_vars($this) as $property => $value) {
+ if ($property[0] !== '_') {
+ $this->_definedProperties[$property] = ($value !== null);
+ }
+ }
+ }
+
+ /**
+ * @param string $property
+ * @param mixed|null $default
+ * @return mixed|null
+ */
+ protected function getElement($property, $default = null)
+ {
+ if (empty($this->_definedProperties[$property])) {
+ return $default;
+ }
+
+ return $this->offsetSerialize($property, $this->{$property});
+ }
+
+ /**
+ * @return array
+ */
+ protected function getElements()
+ {
+ $properties = array_intersect_key(get_object_vars($this), array_filter($this->_definedProperties));
+
+ $elements = [];
+ foreach ($properties as $offset => $value) {
+ $serialized = $this->offsetSerialize($offset, $value);
+ if ($serialized !== null) {
+ $elements[$offset] = $this->offsetSerialize($offset, $value);
+ }
+ }
+
+ return $elements;
+ }
+
+ /**
+ * @param array $elements
+ */
+ protected function setElements(array $elements)
+ {
+ foreach ($elements as $property => $value) {
+ $this->setProperty($property, $value);
+ }
+ }
+
+ abstract public function setProperty($property, $value);
+ abstract protected function setKey($key);
+}
diff --git a/system/src/Grav/Framework/Object/PropertyObject.php b/system/src/Grav/Framework/Object/PropertyObject.php
new file mode 100644
index 0000000..f740fc6
--- /dev/null
+++ b/system/src/Grav/Framework/Object/PropertyObject.php
@@ -0,0 +1,29 @@
+ 'page',
+ 'limit' => 10,
+ 'display' => 5,
+ 'opening' => 0,
+ 'ending' => 0,
+ 'url' => null
+ ];
+
+ /** @var array */
+ private $items;
+
+ public function isEnabled(): bool
+ {
+ return $this->count() > 1;
+ }
+
+ public function getOptions(): array
+ {
+ return $this->options;
+ }
+
+ public function getRoute(): ?Route
+ {
+ return $this->route;
+ }
+
+ public function getTotalPages(): int
+ {
+ return $this->pages;
+ }
+
+ public function getPageNumber(): int
+ {
+ return $this->page;
+ }
+
+ public function getPrevNumber(int $count = 1): ?int
+ {
+ $page = $this->page - $count;
+
+ return $page >= 1 ? $page : null;
+ }
+
+ public function getNextNumber(int $count = 1): ?int
+ {
+ $page = $this->page + $count;
+
+ return $page <= $this->pages ? $page : null;
+ }
+
+ public function getPage(int $page, string $label = null): ?PaginationPage
+ {
+ if ($page < 1 || $page > $this->pages) {
+ return null;
+ }
+
+ $start = ($page - 1) * $this->limit;
+ if ($this->getOptions()['type'] === 'page') {
+ $name = 'page';
+ $offset = $page;
+ } else {
+ $name = 'start';
+ $offset = $start;
+ }
+
+ return new PaginationPage(
+ [
+ 'label' => $label ?? (string)$page,
+ 'number' => $page,
+ 'offset_start' => $start,
+ 'offset_end' => min($start + $this->limit, $this->total) - 1,
+ 'enabled' => $page !== $this->page || $this->viewAll,
+ 'active' => $page === $this->page,
+ 'route' => $this->route->withGravParam($name, $offset)
+ ]
+ );
+ }
+
+ public function getFirstPage(string $label = null, int $count = 0): ?PaginationPage
+ {
+ return $this->getPage(1 + $count, $label ?? $this->getOptions()['label_first'] ?? null);
+ }
+
+ public function getPrevPage(string $label = null, int $count = 1): ?PaginationPage
+ {
+ return $this->getPage($this->page - $count, $label ?? $this->getOptions()['label_prev'] ?? null);
+ }
+
+ public function getNextPage(string $label = null, int $count = 1): ?PaginationPage
+ {
+ return $this->getPage($this->page + $count, $label ?? $this->getOptions()['label_next'] ?? null);
+ }
+
+ public function getLastPage(string $label = null, int $count = 0): ?PaginationPage
+ {
+ return $this->getPage($this->pages - $count, $label ?? $this->getOptions()['label_last'] ?? null);
+ }
+
+ public function getStart(): int
+ {
+ return $this->start;
+ }
+
+ public function getLimit(): int
+ {
+ return $this->limit;
+ }
+
+ public function getTotal(): int
+ {
+ return $this->total;
+ }
+
+ public function count(): int
+ {
+ $this->loadItems();
+
+ return \count($this->items);
+ }
+
+ public function getIterator()
+ {
+ $this->loadItems();
+
+ return new \ArrayIterator($this->items);
+ }
+
+ public function getPages(): array
+ {
+ $this->loadItems();
+
+ return $this->items;
+ }
+
+ protected function loadItems()
+ {
+ $this->calculateRange();
+
+ // Make list like: 1 ... 4 5 6 ... 10
+ $range = range($this->pagesStart, $this->pagesStop);
+ //$range[] = 1;
+ //$range[] = $this->pages;
+ natsort($range);
+ $range = array_unique($range);
+
+ $this->items = [];
+ foreach ($range as $i) {
+ $this->items[$i] = $this->getPage($i);
+ }
+ }
+
+ protected function setRoute(Route $route)
+ {
+ $this->route = $route;
+
+ return $this;
+ }
+
+ protected function setOptions(array $options = null)
+ {
+ $this->options = $options ? array_merge($this->defaultOptions, $options) : $this->defaultOptions;
+
+ return $this;
+ }
+
+ protected function setPage(int $page = null)
+ {
+ $this->page = (int)max($page, 1);
+ $this->start = null;
+
+ return $this;
+ }
+
+ /**
+ * @param int $start
+ * @return $this
+ */
+ protected function setStart(int $start = null)
+ {
+ $this->start = (int)max($start, 0);
+ $this->page = null;
+
+ return $this;
+ }
+
+ /**
+ * @param int|null $limit
+ * @return $this
+ */
+ protected function setLimit(int $limit = null)
+ {
+ $this->limit = (int)max($limit ?? $this->getOptions()['limit'], 0);
+
+ // No limit, display all records in a single page.
+ $this->viewAll = !$limit;
+
+ return $this;
+ }
+
+ /**
+ * @param int $total
+ * @return $this
+ */
+ protected function setTotal(int $total)
+ {
+ $this->total = (int)max($total, 0);
+
+ return $this;
+ }
+
+ protected function initialize(Route $route, int $total, int $pos = null, int $limit = null, array $options = null)
+ {
+ $this->setRoute($route);
+ $this->setOptions($options);
+ $this->setTotal($total);
+ if ($this->getOptions()['type'] === 'start') {
+ $this->setStart($pos);
+ } else {
+ $this->setPage($pos);
+ }
+ $this->setLimit($limit);
+ $this->calculateLimits();
+ }
+
+ protected function calculateLimits()
+ {
+ $limit = $this->limit;
+ $total = $this->total;
+
+ if (!$limit || $limit > $total) {
+ // All records fit into a single page.
+ $this->start = 0;
+ $this->page = 1;
+ $this->pages = 1;
+
+ return;
+ }
+
+ if (null === $this->start) {
+ // If we are using page, convert it to start.
+ $this->start = (int)(($this->page - 1) * $limit);
+ }
+
+ if ($this->start > $total - $limit) {
+ // If start is greater than total count (i.e. we are asked to display records that don't exist)
+ // then set start to display the last natural page of results.
+ $this->start = (int)max(0, (ceil($total / $limit) - 1) * $limit);
+ }
+
+ // Set the total pages and current page values.
+ $this->page = (int)ceil(($this->start + 1) / $limit);
+ $this->pages = (int)ceil($total / $limit);
+ }
+
+ protected function calculateRange()
+ {
+ $options = $this->getOptions();
+ $displayed = $options['display'];
+ $opening = $options['opening'];
+ $ending = $options['ending'];
+
+ // Set the pagination iteration loop values.
+ $this->pagesStart = $this->page - (int)($displayed / 2);
+ if ($this->pagesStart < 1 + $opening) {
+ $this->pagesStart = 1 + $opening;
+ }
+ if ($this->pagesStart + $displayed - $opening > $this->pages) {
+ $this->pagesStop = $this->pages;
+ if ($this->pages < $displayed) {
+ $this->pagesStart = 1 + $opening;
+ } else {
+ $this->pagesStart = $this->pages - $displayed + 1 + $opening;
+ }
+ } else {
+ $this->pagesStop = (int)max(1, $this->pagesStart + $displayed - 1 - $ending);
+ }
+ }
+}
diff --git a/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php b/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php
new file mode 100644
index 0000000..04f536b
--- /dev/null
+++ b/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php
@@ -0,0 +1,53 @@
+options['active'] ?? false;
+ }
+
+ public function isEnabled(): bool
+ {
+ return $this->options['enabled'] ?? false;
+ }
+
+ public function getOptions(): array
+ {
+ return $this->options ?? [];
+ }
+
+ public function getNumber(): ?int
+ {
+ return $this->options['number'] ?? null;
+ }
+
+ public function getLabel(): string
+ {
+ return $this->options['label'] ?? (string)$this->getNumber();
+ }
+
+ public function getUrl(): ?string
+ {
+ return $this->options['route'] ? (string)$this->options['route']->getUri() : null;
+ }
+
+ protected function setOptions(array $options): void
+ {
+ $this->options = $options;
+ }
+}
diff --git a/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php b/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
new file mode 100644
index 0000000..0a14525
--- /dev/null
+++ b/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
@@ -0,0 +1,43 @@
+initialize($route, $total, $pos, $limit, $options);
+ }
+}
diff --git a/system/src/Grav/Framework/Pagination/PaginationPage.php b/system/src/Grav/Framework/Pagination/PaginationPage.php
new file mode 100644
index 0000000..ca35a8d
--- /dev/null
+++ b/system/src/Grav/Framework/Pagination/PaginationPage.php
@@ -0,0 +1,18 @@
+setOptions($options);
+ }
+}
diff --git a/system/src/Grav/Framework/Parsedown/Parsedown.php b/system/src/Grav/Framework/Parsedown/Parsedown.php
new file mode 100644
index 0000000..20b634d
--- /dev/null
+++ b/system/src/Grav/Framework/Parsedown/Parsedown.php
@@ -0,0 +1,1554 @@
+DefinitionData = array();
+
+ # standardize line breaks
+ $text = str_replace(array("\r\n", "\r"), "\n", $text);
+
+ # remove surrounding line breaks
+ $text = trim($text, "\n");
+
+ # split text into lines
+ $lines = explode("\n", $text);
+
+ # iterate through lines to identify blocks
+ $markup = $this->lines($lines);
+
+ # trim line breaks
+ $markup = trim($markup, "\n");
+
+ return $markup;
+ }
+
+ #
+ # Setters
+ #
+
+ function setBreaksEnabled($breaksEnabled)
+ {
+ $this->breaksEnabled = $breaksEnabled;
+
+ return $this;
+ }
+
+ protected $breaksEnabled;
+
+ function setMarkupEscaped($markupEscaped)
+ {
+ $this->markupEscaped = $markupEscaped;
+
+ return $this;
+ }
+
+ protected $markupEscaped;
+
+ function setUrlsLinked($urlsLinked)
+ {
+ $this->urlsLinked = $urlsLinked;
+
+ return $this;
+ }
+
+ protected $urlsLinked = true;
+
+ #
+ # Lines
+ #
+
+ protected $BlockTypes = array(
+ '#' => array('Header'),
+ '*' => array('Rule', 'List'),
+ '+' => array('List'),
+ '-' => array('SetextHeader', 'Table', 'Rule', 'List'),
+ '0' => array('List'),
+ '1' => array('List'),
+ '2' => array('List'),
+ '3' => array('List'),
+ '4' => array('List'),
+ '5' => array('List'),
+ '6' => array('List'),
+ '7' => array('List'),
+ '8' => array('List'),
+ '9' => array('List'),
+ ':' => array('Table'),
+ '<' => array('Comment', 'Markup'),
+ '=' => array('SetextHeader'),
+ '>' => array('Quote'),
+ '[' => array('Reference'),
+ '_' => array('Rule'),
+ '`' => array('FencedCode'),
+ '|' => array('Table'),
+ '~' => array('FencedCode'),
+ );
+
+ # ~
+
+ protected $unmarkedBlockTypes = array(
+ 'Code',
+ );
+
+ #
+ # Blocks
+ #
+
+ protected function lines(array $lines)
+ {
+ $CurrentBlock = null;
+
+ foreach ($lines as $line)
+ {
+ if (chop($line) === '')
+ {
+ if (isset($CurrentBlock))
+ {
+ $CurrentBlock['interrupted'] = true;
+ }
+
+ continue;
+ }
+
+ if (strpos($line, "\t") !== false)
+ {
+ $parts = explode("\t", $line);
+
+ $line = $parts[0];
+
+ unset($parts[0]);
+
+ foreach ($parts as $part)
+ {
+ $shortage = 4 - mb_strlen($line, 'utf-8') % 4;
+
+ $line .= str_repeat(' ', $shortage);
+ $line .= $part;
+ }
+ }
+
+ $indent = 0;
+
+ while (isset($line[$indent]) and $line[$indent] === ' ')
+ {
+ $indent ++;
+ }
+
+ $text = $indent > 0 ? substr($line, $indent) : $line;
+
+ # ~
+
+ $Line = array('body' => $line, 'indent' => $indent, 'text' => $text);
+
+ # ~
+
+ if (isset($CurrentBlock['continuable']))
+ {
+ $Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock);
+
+ if (isset($Block))
+ {
+ $CurrentBlock = $Block;
+
+ continue;
+ }
+ else
+ {
+ if ($this->isBlockCompletable($CurrentBlock['type']))
+ {
+ $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
+ }
+ }
+ }
+
+ # ~
+
+ $marker = $text[0];
+
+ # ~
+
+ $blockTypes = $this->unmarkedBlockTypes;
+
+ if (isset($this->BlockTypes[$marker]))
+ {
+ foreach ($this->BlockTypes[$marker] as $blockType)
+ {
+ $blockTypes []= $blockType;
+ }
+ }
+
+ #
+ # ~
+
+ foreach ($blockTypes as $blockType)
+ {
+ $Block = $this->{'block'.$blockType}($Line, $CurrentBlock);
+
+ if (isset($Block))
+ {
+ $Block['type'] = $blockType;
+
+ if ( ! isset($Block['identified']))
+ {
+ $Blocks []= $CurrentBlock;
+
+ $Block['identified'] = true;
+ }
+
+ if ($this->isBlockContinuable($blockType))
+ {
+ $Block['continuable'] = true;
+ }
+
+ $CurrentBlock = $Block;
+
+ continue 2;
+ }
+ }
+
+ # ~
+
+ if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
+ {
+ $CurrentBlock['element']['text'] .= "\n".$text;
+ }
+ else
+ {
+ $Blocks []= $CurrentBlock;
+
+ $CurrentBlock = $this->paragraph($Line);
+
+ $CurrentBlock['identified'] = true;
+ }
+ }
+
+ # ~
+
+ if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type']))
+ {
+ $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
+ }
+
+ # ~
+
+ $Blocks []= $CurrentBlock;
+
+ unset($Blocks[0]);
+
+ # ~
+
+ $markup = '';
+
+ foreach ($Blocks as $Block)
+ {
+ if (isset($Block['hidden']))
+ {
+ continue;
+ }
+
+ $markup .= "\n";
+ $markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']);
+ }
+
+ $markup .= "\n";
+
+ # ~
+
+ return $markup;
+ }
+
+ protected function isBlockContinuable($Type)
+ {
+ return method_exists($this, 'block'.$Type.'Continue');
+ }
+
+ protected function isBlockCompletable($Type)
+ {
+ return method_exists($this, 'block'.$Type.'Complete');
+ }
+
+ #
+ # Code
+
+ protected function blockCode($Line, $Block = null)
+ {
+ if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
+ {
+ return;
+ }
+
+ if ($Line['indent'] >= 4)
+ {
+ $text = substr($Line['body'], 4);
+
+ $Block = array(
+ 'element' => array(
+ 'name' => 'pre',
+ 'handler' => 'element',
+ 'text' => array(
+ 'name' => 'code',
+ 'text' => $text,
+ ),
+ ),
+ );
+
+ return $Block;
+ }
+ }
+
+ protected function blockCodeContinue($Line, $Block)
+ {
+ if ($Line['indent'] >= 4)
+ {
+ if (isset($Block['interrupted']))
+ {
+ $Block['element']['text']['text'] .= "\n";
+
+ unset($Block['interrupted']);
+ }
+
+ $Block['element']['text']['text'] .= "\n";
+
+ $text = substr($Line['body'], 4);
+
+ $Block['element']['text']['text'] .= $text;
+
+ return $Block;
+ }
+ }
+
+ protected function blockCodeComplete($Block)
+ {
+ $text = $Block['element']['text']['text'];
+
+ $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
+
+ $Block['element']['text']['text'] = $text;
+
+ return $Block;
+ }
+
+ #
+ # Comment
+
+ protected function blockComment($Line)
+ {
+ if ($this->markupEscaped)
+ {
+ return;
+ }
+
+ if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!')
+ {
+ $Block = array(
+ 'markup' => $Line['body'],
+ );
+
+ if (preg_match('/-->$/', $Line['text']))
+ {
+ $Block['closed'] = true;
+ }
+
+ return $Block;
+ }
+ }
+
+ protected function blockCommentContinue($Line, array $Block)
+ {
+ if (isset($Block['closed']))
+ {
+ return;
+ }
+
+ $Block['markup'] .= "\n" . $Line['body'];
+
+ if (preg_match('/-->$/', $Line['text']))
+ {
+ $Block['closed'] = true;
+ }
+
+ return $Block;
+ }
+
+ #
+ # Fenced Code
+
+ protected function blockFencedCode($Line)
+ {
+ if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches))
+ {
+ $Element = array(
+ 'name' => 'code',
+ 'text' => '',
+ );
+
+ if (isset($matches[1]))
+ {
+ $class = 'language-'.$matches[1];
+
+ $Element['attributes'] = array(
+ 'class' => $class,
+ );
+ }
+
+ $Block = array(
+ 'char' => $Line['text'][0],
+ 'element' => array(
+ 'name' => 'pre',
+ 'handler' => 'element',
+ 'text' => $Element,
+ ),
+ );
+
+ return $Block;
+ }
+ }
+
+ protected function blockFencedCodeContinue($Line, $Block)
+ {
+ if (isset($Block['complete']))
+ {
+ return;
+ }
+
+ if (isset($Block['interrupted']))
+ {
+ $Block['element']['text']['text'] .= "\n";
+
+ unset($Block['interrupted']);
+ }
+
+ if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text']))
+ {
+ $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1);
+
+ $Block['complete'] = true;
+
+ return $Block;
+ }
+
+ $Block['element']['text']['text'] .= "\n".$Line['body'];
+
+ return $Block;
+ }
+
+ protected function blockFencedCodeComplete($Block)
+ {
+ $text = $Block['element']['text']['text'];
+
+ $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
+
+ $Block['element']['text']['text'] = $text;
+
+ return $Block;
+ }
+
+ #
+ # Header
+
+ protected function blockHeader($Line)
+ {
+ if (isset($Line['text'][1]))
+ {
+ $level = 1;
+
+ while (isset($Line['text'][$level]) and $Line['text'][$level] === '#')
+ {
+ $level ++;
+ }
+
+ if ($level > 6)
+ {
+ return;
+ }
+
+ $text = trim($Line['text'], '# ');
+
+ $Block = array(
+ 'element' => array(
+ 'name' => 'h' . min(6, $level),
+ 'text' => $text,
+ 'handler' => 'line',
+ ),
+ );
+
+ return $Block;
+ }
+ }
+
+ #
+ # List
+
+ protected function blockList($Line)
+ {
+ list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]');
+
+ if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches))
+ {
+ $Block = array(
+ 'indent' => $Line['indent'],
+ 'pattern' => $pattern,
+ 'element' => array(
+ 'name' => $name,
+ 'handler' => 'elements',
+ ),
+ );
+
+ if($name === 'ol')
+ {
+ $listStart = stristr($matches[0], '.', true);
+
+ if($listStart !== '1')
+ {
+ $Block['element']['attributes'] = array('start' => $listStart);
+ }
+ }
+
+ $Block['li'] = array(
+ 'name' => 'li',
+ 'handler' => 'li',
+ 'text' => array(
+ $matches[2],
+ ),
+ );
+
+ $Block['element']['text'] []= & $Block['li'];
+
+ return $Block;
+ }
+ }
+
+ protected function blockListContinue($Line, array $Block)
+ {
+ if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
+ {
+ if (isset($Block['interrupted']))
+ {
+ $Block['li']['text'] []= '';
+
+ unset($Block['interrupted']);
+ }
+
+ unset($Block['li']);
+
+ $text = isset($matches[1]) ? $matches[1] : '';
+
+ $Block['li'] = array(
+ 'name' => 'li',
+ 'handler' => 'li',
+ 'text' => array(
+ $text,
+ ),
+ );
+
+ $Block['element']['text'] []= & $Block['li'];
+
+ return $Block;
+ }
+
+ if ($Line['text'][0] === '[' and $this->blockReference($Line))
+ {
+ return $Block;
+ }
+
+ if ( ! isset($Block['interrupted']))
+ {
+ $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
+
+ $Block['li']['text'] []= $text;
+
+ return $Block;
+ }
+
+ if ($Line['indent'] > 0)
+ {
+ $Block['li']['text'] []= '';
+
+ $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
+
+ $Block['li']['text'] []= $text;
+
+ unset($Block['interrupted']);
+
+ return $Block;
+ }
+ }
+
+ #
+ # Quote
+
+ protected function blockQuote($Line)
+ {
+ if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
+ {
+ $Block = array(
+ 'element' => array(
+ 'name' => 'blockquote',
+ 'handler' => 'lines',
+ 'text' => (array) $matches[1],
+ ),
+ );
+
+ return $Block;
+ }
+ }
+
+ protected function blockQuoteContinue($Line, array $Block)
+ {
+ if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
+ {
+ if (isset($Block['interrupted']))
+ {
+ $Block['element']['text'] []= '';
+
+ unset($Block['interrupted']);
+ }
+
+ $Block['element']['text'] []= $matches[1];
+
+ return $Block;
+ }
+
+ if ( ! isset($Block['interrupted']))
+ {
+ $Block['element']['text'] []= $Line['text'];
+
+ return $Block;
+ }
+ }
+
+ #
+ # Rule
+
+ protected function blockRule($Line)
+ {
+ if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text']))
+ {
+ $Block = array(
+ 'element' => array(
+ 'name' => 'hr'
+ ),
+ );
+
+ return $Block;
+ }
+ }
+
+ #
+ # Setext
+
+ protected function blockSetextHeader($Line, array $Block = null)
+ {
+ if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
+ {
+ return;
+ }
+
+ if (chop($Line['text'], $Line['text'][0]) === '')
+ {
+ $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
+
+ return $Block;
+ }
+ }
+
+ #
+ # Markup
+
+ protected function blockMarkup($Line)
+ {
+ if ($this->markupEscaped)
+ {
+ return;
+ }
+
+ if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
+ {
+ $element = strtolower($matches[1]);
+
+ if (in_array($element, $this->textLevelElements))
+ {
+ return;
+ }
+
+ $Block = array(
+ 'name' => $matches[1],
+ 'depth' => 0,
+ 'markup' => $Line['text'],
+ );
+
+ $length = strlen($matches[0]);
+
+ $remainder = substr($Line['text'], $length);
+
+ if (trim($remainder) === '')
+ {
+ if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
+ {
+ $Block['closed'] = true;
+
+ $Block['void'] = true;
+ }
+ }
+ else
+ {
+ if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
+ {
+ return;
+ }
+
+ if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder))
+ {
+ $Block['closed'] = true;
+ }
+ }
+
+ return $Block;
+ }
+ }
+
+ protected function blockMarkupContinue($Line, array $Block)
+ {
+ if (isset($Block['closed']))
+ {
+ return;
+ }
+
+ if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
+ {
+ $Block['depth'] ++;
+ }
+
+ if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
+ {
+ if ($Block['depth'] > 0)
+ {
+ $Block['depth'] --;
+ }
+ else
+ {
+ $Block['closed'] = true;
+ }
+ }
+
+ if (isset($Block['interrupted']))
+ {
+ $Block['markup'] .= "\n";
+
+ unset($Block['interrupted']);
+ }
+
+ $Block['markup'] .= "\n".$Line['body'];
+
+ return $Block;
+ }
+
+ #
+ # Reference
+
+ protected function blockReference($Line)
+ {
+ if (preg_match('/^\[(.+?)\]:[ ]*(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches))
+ {
+ $id = strtolower($matches[1]);
+
+ $Data = array(
+ 'url' => $matches[2],
+ 'title' => null,
+ );
+
+ if (isset($matches[3]))
+ {
+ $Data['title'] = $matches[3];
+ }
+
+ $this->DefinitionData['Reference'][$id] = $Data;
+
+ $Block = array(
+ 'hidden' => true,
+ );
+
+ return $Block;
+ }
+ }
+
+ #
+ # Table
+
+ protected function blockTable($Line, array $Block = null)
+ {
+ if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
+ {
+ return;
+ }
+
+ if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '')
+ {
+ $alignments = array();
+
+ $divider = $Line['text'];
+
+ $divider = trim($divider);
+ $divider = trim($divider, '|');
+
+ $dividerCells = explode('|', $divider);
+
+ foreach ($dividerCells as $dividerCell)
+ {
+ $dividerCell = trim($dividerCell);
+
+ if ($dividerCell === '')
+ {
+ continue;
+ }
+
+ $alignment = null;
+
+ if ($dividerCell[0] === ':')
+ {
+ $alignment = 'left';
+ }
+
+ if (substr($dividerCell, - 1) === ':')
+ {
+ $alignment = $alignment === 'left' ? 'center' : 'right';
+ }
+
+ $alignments []= $alignment;
+ }
+
+ # ~
+
+ $HeaderElements = array();
+
+ $header = $Block['element']['text'];
+
+ $header = trim($header);
+ $header = trim($header, '|');
+
+ $headerCells = explode('|', $header);
+
+ foreach ($headerCells as $index => $headerCell)
+ {
+ $headerCell = trim($headerCell);
+
+ $HeaderElement = array(
+ 'name' => 'th',
+ 'text' => $headerCell,
+ 'handler' => 'line',
+ );
+
+ if (isset($alignments[$index]))
+ {
+ $alignment = $alignments[$index];
+
+ $HeaderElement['attributes'] = array(
+ 'style' => 'text-align: '.$alignment.';',
+ );
+ }
+
+ $HeaderElements []= $HeaderElement;
+ }
+
+ # ~
+
+ $Block = array(
+ 'alignments' => $alignments,
+ 'identified' => true,
+ 'element' => array(
+ 'name' => 'table',
+ 'handler' => 'elements',
+ ),
+ );
+
+ $Block['element']['text'] []= array(
+ 'name' => 'thead',
+ 'handler' => 'elements',
+ );
+
+ $Block['element']['text'] []= array(
+ 'name' => 'tbody',
+ 'handler' => 'elements',
+ 'text' => array(),
+ );
+
+ $Block['element']['text'][0]['text'] []= array(
+ 'name' => 'tr',
+ 'handler' => 'elements',
+ 'text' => $HeaderElements,
+ );
+
+ return $Block;
+ }
+ }
+
+ protected function blockTableContinue($Line, array $Block)
+ {
+ if (isset($Block['interrupted']))
+ {
+ return;
+ }
+
+ if ($Line['text'][0] === '|' or strpos($Line['text'], '|'))
+ {
+ $Elements = array();
+
+ $row = $Line['text'];
+
+ $row = trim($row);
+ $row = trim($row, '|');
+
+ preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches);
+
+ foreach ($matches[0] as $index => $cell)
+ {
+ $cell = trim($cell);
+
+ $Element = array(
+ 'name' => 'td',
+ 'handler' => 'line',
+ 'text' => $cell,
+ );
+
+ if (isset($Block['alignments'][$index]))
+ {
+ $Element['attributes'] = array(
+ 'style' => 'text-align: '.$Block['alignments'][$index].';',
+ );
+ }
+
+ $Elements []= $Element;
+ }
+
+ $Element = array(
+ 'name' => 'tr',
+ 'handler' => 'elements',
+ 'text' => $Elements,
+ );
+
+ $Block['element']['text'][1]['text'] []= $Element;
+
+ return $Block;
+ }
+ }
+
+ #
+ # ~
+ #
+
+ protected function paragraph($Line)
+ {
+ $Block = array(
+ 'element' => array(
+ 'name' => 'p',
+ 'text' => $Line['text'],
+ 'handler' => 'line',
+ ),
+ );
+
+ return $Block;
+ }
+
+ #
+ # Inline Elements
+ #
+
+ protected $InlineTypes = array(
+ '"' => array('SpecialCharacter'),
+ '!' => array('Image'),
+ '&' => array('SpecialCharacter'),
+ '*' => array('Emphasis'),
+ ':' => array('Url'),
+ '<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'),
+ '>' => array('SpecialCharacter'),
+ '[' => array('Link'),
+ '_' => array('Emphasis'),
+ '`' => array('Code'),
+ '~' => array('Strikethrough'),
+ '\\' => array('EscapeSequence'),
+ );
+
+ # ~
+
+ protected $inlineMarkerList = '!"*_&[:<>`~\\';
+
+ #
+ # ~
+ #
+
+ public function line($text)
+ {
+ $markup = '';
+
+ # $excerpt is based on the first occurrence of a marker
+
+ while ($excerpt = strpbrk($text, $this->inlineMarkerList))
+ {
+ $marker = $excerpt[0];
+
+ $markerPosition = strpos($text, $marker);
+
+ $Excerpt = array('text' => $excerpt, 'context' => $text);
+
+ foreach ($this->InlineTypes[$marker] as $inlineType)
+ {
+ $Inline = $this->{'inline'.$inlineType}($Excerpt);
+
+ if ( ! isset($Inline))
+ {
+ continue;
+ }
+
+ # makes sure that the inline belongs to "our" marker
+
+ if (isset($Inline['position']) and $Inline['position'] > $markerPosition)
+ {
+ continue;
+ }
+
+ # sets a default inline position
+
+ if ( ! isset($Inline['position']))
+ {
+ $Inline['position'] = $markerPosition;
+ }
+
+ # the text that comes before the inline
+ $unmarkedText = substr($text, 0, $Inline['position']);
+
+ # compile the unmarked text
+ $markup .= $this->unmarkedText($unmarkedText);
+
+ # compile the inline
+ $markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']);
+
+ # remove the examined text
+ $text = substr($text, $Inline['position'] + $Inline['extent']);
+
+ continue 2;
+ }
+
+ # the marker does not belong to an inline
+
+ $unmarkedText = substr($text, 0, $markerPosition + 1);
+
+ $markup .= $this->unmarkedText($unmarkedText);
+
+ $text = substr($text, $markerPosition + 1);
+ }
+
+ $markup .= $this->unmarkedText($text);
+
+ return $markup;
+ }
+
+ #
+ # ~
+ #
+
+ protected function inlineCode($Excerpt)
+ {
+ $marker = $Excerpt['text'][0];
+
+ if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(? strlen($matches[0]),
+ 'element' => array(
+ 'name' => 'code',
+ 'text' => $text,
+ ),
+ );
+ }
+ }
+
+ protected function inlineEmailTag($Excerpt)
+ {
+ if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches))
+ {
+ $url = $matches[1];
+
+ if ( ! isset($matches[2]))
+ {
+ $url = 'mailto:' . $url;
+ }
+
+ return array(
+ 'extent' => strlen($matches[0]),
+ 'element' => array(
+ 'name' => 'a',
+ 'text' => $matches[1],
+ 'attributes' => array(
+ 'href' => $url,
+ ),
+ ),
+ );
+ }
+ }
+
+ protected function inlineEmphasis($Excerpt)
+ {
+ if ( ! isset($Excerpt['text'][1]))
+ {
+ return;
+ }
+
+ $marker = $Excerpt['text'][0];
+
+ if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
+ {
+ $emphasis = 'strong';
+ }
+ elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
+ {
+ $emphasis = 'em';
+ }
+ else
+ {
+ return;
+ }
+
+ return array(
+ 'extent' => strlen($matches[0]),
+ 'element' => array(
+ 'name' => $emphasis,
+ 'handler' => 'line',
+ 'text' => $matches[1],
+ ),
+ );
+ }
+
+ protected function inlineEscapeSequence($Excerpt)
+ {
+ if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters))
+ {
+ return array(
+ 'markup' => $Excerpt['text'][1],
+ 'extent' => 2,
+ );
+ }
+ }
+
+ protected function inlineImage($Excerpt)
+ {
+ if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
+ {
+ return;
+ }
+
+ $Excerpt['text']= substr($Excerpt['text'], 1);
+
+ $Link = $this->inlineLink($Excerpt);
+
+ if ($Link === null)
+ {
+ return;
+ }
+
+ $Inline = array(
+ 'extent' => $Link['extent'] + 1,
+ 'element' => array(
+ 'name' => 'img',
+ 'attributes' => array(
+ 'src' => $Link['element']['attributes']['href'],
+ 'alt' => $Link['element']['text'],
+ ),
+ ),
+ );
+
+ $Inline['element']['attributes'] += $Link['element']['attributes'];
+
+ unset($Inline['element']['attributes']['href']);
+
+ return $Inline;
+ }
+
+ protected function inlineLink($Excerpt)
+ {
+ $Element = array(
+ 'name' => 'a',
+ 'handler' => 'line',
+ 'text' => null,
+ 'attributes' => array(
+ 'href' => null,
+ 'title' => null,
+ ),
+ );
+
+ $extent = 0;
+
+ $remainder = $Excerpt['text'];
+
+ if (preg_match('/\[((?:[^][]++|(?R))*+)\]/', $remainder, $matches))
+ {
+ $Element['text'] = $matches[1];
+
+ $extent += strlen($matches[0]);
+
+ $remainder = substr($remainder, $extent);
+ }
+ else
+ {
+ return;
+ }
+
+ if (preg_match('/^[(]\s*+((?:[^ ()]++|[(][^ )]+[)])++)(?:[ ]+("[^"]*"|\'[^\']*\'))?\s*[)]/', $remainder, $matches))
+ {
+ $Element['attributes']['href'] = $matches[1];
+
+ if (isset($matches[2]))
+ {
+ $Element['attributes']['title'] = substr($matches[2], 1, - 1);
+ }
+
+ $extent += strlen($matches[0]);
+ }
+ else
+ {
+ if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
+ {
+ $definition = strlen($matches[1]) ? $matches[1] : $Element['text'];
+ $definition = strtolower($definition);
+
+ $extent += strlen($matches[0]);
+ }
+ else
+ {
+ $definition = strtolower($Element['text']);
+ }
+
+ if ( ! isset($this->DefinitionData['Reference'][$definition]))
+ {
+ return;
+ }
+
+ $Definition = $this->DefinitionData['Reference'][$definition];
+
+ $Element['attributes']['href'] = $Definition['url'];
+ $Element['attributes']['title'] = $Definition['title'];
+ }
+
+ $Element['attributes']['href'] = str_replace(array('&', '<'), array('&', '<'), $Element['attributes']['href']);
+
+ return array(
+ 'extent' => $extent,
+ 'element' => $Element,
+ );
+ }
+
+ protected function inlineMarkup($Excerpt)
+ {
+ if ($this->markupEscaped or strpos($Excerpt['text'], '>') === false)
+ {
+ return;
+ }
+
+ if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w*[ ]*>/s', $Excerpt['text'], $matches))
+ {
+ return array(
+ 'markup' => $matches[0],
+ 'extent' => strlen($matches[0]),
+ );
+ }
+
+ if ($Excerpt['text'][1] === '!' and preg_match('/^/s', $Excerpt['text'], $matches))
+ {
+ return array(
+ 'markup' => $matches[0],
+ 'extent' => strlen($matches[0]),
+ );
+ }
+
+ if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches))
+ {
+ return array(
+ 'markup' => $matches[0],
+ 'extent' => strlen($matches[0]),
+ );
+ }
+ }
+
+ protected function inlineSpecialCharacter($Excerpt)
+ {
+ if ($Excerpt['text'][0] === '&' and ! preg_match('/^?\w+;/', $Excerpt['text']))
+ {
+ return array(
+ 'markup' => '&',
+ 'extent' => 1,
+ );
+ }
+
+ $SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot');
+
+ if (isset($SpecialCharacter[$Excerpt['text'][0]]))
+ {
+ return array(
+ 'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';',
+ 'extent' => 1,
+ );
+ }
+ }
+
+ protected function inlineStrikethrough($Excerpt)
+ {
+ if ( ! isset($Excerpt['text'][1]))
+ {
+ return;
+ }
+
+ if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches))
+ {
+ return array(
+ 'extent' => strlen($matches[0]),
+ 'element' => array(
+ 'name' => 'del',
+ 'text' => $matches[1],
+ 'handler' => 'line',
+ ),
+ );
+ }
+ }
+
+ protected function inlineUrl($Excerpt)
+ {
+ if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
+ {
+ return;
+ }
+
+ if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE))
+ {
+ $Inline = array(
+ 'extent' => strlen($matches[0][0]),
+ 'position' => $matches[0][1],
+ 'element' => array(
+ 'name' => 'a',
+ 'text' => $matches[0][0],
+ 'attributes' => array(
+ 'href' => $matches[0][0],
+ ),
+ ),
+ );
+
+ return $Inline;
+ }
+ }
+
+ protected function inlineUrlTag($Excerpt)
+ {
+ if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches))
+ {
+ $url = str_replace(array('&', '<'), array('&', '<'), $matches[1]);
+
+ return array(
+ 'extent' => strlen($matches[0]),
+ 'element' => array(
+ 'name' => 'a',
+ 'text' => $url,
+ 'attributes' => array(
+ 'href' => $url,
+ ),
+ ),
+ );
+ }
+ }
+
+ # ~
+
+ protected function unmarkedText($text)
+ {
+ if ($this->breaksEnabled)
+ {
+ $text = preg_replace('/[ ]*\n/', " \n", $text);
+ }
+ else
+ {
+ $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', " \n", $text);
+ $text = str_replace(" \n", "\n", $text);
+ }
+
+ return $text;
+ }
+
+ #
+ # Handlers
+ #
+
+ protected function element(array $Element)
+ {
+ $markup = '<'.$Element['name'];
+
+ if (isset($Element['attributes']))
+ {
+ foreach ($Element['attributes'] as $name => $value)
+ {
+ if ($value === null)
+ {
+ continue;
+ }
+
+ $markup .= ' '.$name.'="'.$value.'"';
+ }
+ }
+
+ if (isset($Element['text']))
+ {
+ $markup .= '>';
+
+ if (isset($Element['handler']))
+ {
+ $markup .= $this->{$Element['handler']}($Element['text']);
+ }
+ else
+ {
+ $markup .= $Element['text'];
+ }
+
+ $markup .= ''.$Element['name'].'>';
+ }
+ else
+ {
+ $markup .= ' />';
+ }
+
+ return $markup;
+ }
+
+ protected function elements(array $Elements)
+ {
+ $markup = '';
+
+ foreach ($Elements as $Element)
+ {
+ $markup .= "\n" . $this->element($Element);
+ }
+
+ $markup .= "\n";
+
+ return $markup;
+ }
+
+ # ~
+
+ protected function li($lines)
+ {
+ $markup = $this->lines($lines);
+
+ $trimmedMarkup = trim($markup);
+
+ if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '')
+ {
+ $markup = $trimmedMarkup;
+ $markup = substr($markup, 3);
+
+ $position = strpos($markup, "
");
+
+ $markup = substr_replace($markup, '', $position, 4);
+ }
+
+ return $markup;
+ }
+
+ #
+ # Deprecated Methods
+ #
+
+ function parse($text)
+ {
+ $markup = $this->text($text);
+
+ return $markup;
+ }
+
+ #
+ # Static Methods
+ #
+
+ static function instance($name = 'default')
+ {
+ if (isset(self::$instances[$name]))
+ {
+ return self::$instances[$name];
+ }
+
+ $instance = new static();
+
+ self::$instances[$name] = $instance;
+
+ return $instance;
+ }
+
+ private static $instances = array();
+
+ #
+ # Fields
+ #
+
+ protected $DefinitionData;
+
+ #
+ # Read-Only
+
+ protected $specialCharacters = array(
+ '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|',
+ );
+
+ protected $StrongRegex = array(
+ '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s',
+ '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us',
+ );
+
+ protected $EmRegex = array(
+ '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s',
+ '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us',
+ );
+
+ protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?';
+
+ protected $voidElements = array(
+ 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source',
+ );
+
+ protected $textLevelElements = array(
+ 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
+ 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',
+ 'i', 'rp', 'del', 'code', 'strike', 'marquee',
+ 'q', 'rt', 'ins', 'font', 'strong',
+ 's', 'tt', 'kbd', 'mark',
+ 'u', 'xm', 'sub', 'nobr',
+ 'sup', 'ruby',
+ 'var', 'span',
+ 'wbr', 'time',
+ );
+}
diff --git a/system/src/Grav/Framework/Parsedown/ParsedownExtra.php b/system/src/Grav/Framework/Parsedown/ParsedownExtra.php
new file mode 100644
index 0000000..8219005
--- /dev/null
+++ b/system/src/Grav/Framework/Parsedown/ParsedownExtra.php
@@ -0,0 +1,532 @@
+BlockTypes[':'] []= 'DefinitionList';
+ $this->BlockTypes['*'] []= 'Abbreviation';
+
+ # identify footnote definitions before reference definitions
+ array_unshift($this->BlockTypes['['], 'Footnote');
+
+ # identify footnote markers before before links
+ array_unshift($this->InlineTypes['['], 'FootnoteMarker');
+ }
+
+ #
+ # ~
+
+ function text($text)
+ {
+ $markup = parent::text($text);
+
+ # merge consecutive dl elements
+
+ $markup = preg_replace('/<\/dl>\s+\s+/', '', $markup);
+
+ # add footnotes
+
+ if (isset($this->DefinitionData['Footnote']))
+ {
+ $Element = $this->buildFootnoteElement();
+
+ $markup .= "\n" . $this->element($Element);
+ }
+
+ return $markup;
+ }
+
+ #
+ # Blocks
+ #
+
+ #
+ # Abbreviation
+
+ protected function blockAbbreviation($Line)
+ {
+ if (preg_match('/^\*\[(.+?)\]:[ ]*(.+?)[ ]*$/', $Line['text'], $matches))
+ {
+ $this->DefinitionData['Abbreviation'][$matches[1]] = $matches[2];
+
+ $Block = array(
+ 'hidden' => true,
+ );
+
+ return $Block;
+ }
+ }
+
+ #
+ # Footnote
+
+ protected function blockFootnote($Line)
+ {
+ if (preg_match('/^\[\^(.+?)\]:[ ]?(.*)$/', $Line['text'], $matches))
+ {
+ $Block = array(
+ 'label' => $matches[1],
+ 'text' => $matches[2],
+ 'hidden' => true,
+ );
+
+ return $Block;
+ }
+ }
+
+ protected function blockFootnoteContinue($Line, $Block)
+ {
+ if ($Line['text'][0] === '[' and preg_match('/^\[\^(.+?)\]:/', $Line['text']))
+ {
+ return;
+ }
+
+ if (isset($Block['interrupted']))
+ {
+ if ($Line['indent'] >= 4)
+ {
+ $Block['text'] .= "\n\n" . $Line['text'];
+
+ return $Block;
+ }
+ }
+ else
+ {
+ $Block['text'] .= "\n" . $Line['text'];
+
+ return $Block;
+ }
+ }
+
+ protected function blockFootnoteComplete($Block)
+ {
+ $this->DefinitionData['Footnote'][$Block['label']] = array(
+ 'text' => $Block['text'],
+ 'count' => null,
+ 'number' => null,
+ );
+
+ return $Block;
+ }
+
+ #
+ # Definition List
+
+ protected function blockDefinitionList($Line, $Block)
+ {
+ if ( ! isset($Block) or isset($Block['type']))
+ {
+ return;
+ }
+
+ $Element = array(
+ 'name' => 'dl',
+ 'handler' => 'elements',
+ 'text' => array(),
+ );
+
+ $terms = explode("\n", $Block['element']['text']);
+
+ foreach ($terms as $term)
+ {
+ $Element['text'] []= array(
+ 'name' => 'dt',
+ 'handler' => 'line',
+ 'text' => $term,
+ );
+ }
+
+ $Block['element'] = $Element;
+
+ $Block = $this->addDdElement($Line, $Block);
+
+ return $Block;
+ }
+
+ protected function blockDefinitionListContinue($Line, array $Block)
+ {
+ if ($Line['text'][0] === ':')
+ {
+ $Block = $this->addDdElement($Line, $Block);
+
+ return $Block;
+ }
+ else
+ {
+ if (isset($Block['interrupted']) and $Line['indent'] === 0)
+ {
+ return;
+ }
+
+ if (isset($Block['interrupted']))
+ {
+ $Block['dd']['handler'] = 'text';
+ $Block['dd']['text'] .= "\n\n";
+
+ unset($Block['interrupted']);
+ }
+
+ $text = substr($Line['body'], min($Line['indent'], 4));
+
+ $Block['dd']['text'] .= "\n" . $text;
+
+ return $Block;
+ }
+ }
+
+ #
+ # Header
+
+ protected function blockHeader($Line)
+ {
+ $Block = parent::blockHeader($Line);
+
+ if ($Block !== null && preg_match('/[ #]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
+ {
+ $attributeString = $matches[1][0];
+
+ $Block['element']['attributes'] = $this->parseAttributeData($attributeString);
+
+ $Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
+ }
+
+ return $Block;
+ }
+
+ #
+ # Markup
+
+ protected function blockMarkupComplete($Block)
+ {
+ if ( ! isset($Block['void']))
+ {
+ $Block['markup'] = $this->processTag($Block['markup']);
+ }
+
+ return $Block;
+ }
+
+ #
+ # Setext
+
+ protected function blockSetextHeader($Line, array $Block = null)
+ {
+ $Block = parent::blockSetextHeader($Line, $Block);
+
+ if ($Block !== null && preg_match('/[ ]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
+ {
+ $attributeString = $matches[1][0];
+
+ $Block['element']['attributes'] = $this->parseAttributeData($attributeString);
+
+ $Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
+ }
+
+ return $Block;
+ }
+
+ #
+ # Inline Elements
+ #
+
+ #
+ # Footnote Marker
+
+ protected function inlineFootnoteMarker($Excerpt)
+ {
+ if (preg_match('/^\[\^(.+?)\]/', $Excerpt['text'], $matches))
+ {
+ $name = $matches[1];
+
+ if ( ! isset($this->DefinitionData['Footnote'][$name]))
+ {
+ return;
+ }
+
+ $this->DefinitionData['Footnote'][$name]['count'] ++;
+
+ if ( ! isset($this->DefinitionData['Footnote'][$name]['number']))
+ {
+ $this->DefinitionData['Footnote'][$name]['number'] = ++ $this->footnoteCount; # » &
+ }
+
+ $Element = array(
+ 'name' => 'sup',
+ 'attributes' => array('id' => 'fnref'.$this->DefinitionData['Footnote'][$name]['count'].':'.$name),
+ 'handler' => 'element',
+ 'text' => array(
+ 'name' => 'a',
+ 'attributes' => array('href' => '#fn:'.$name, 'class' => 'footnote-ref'),
+ 'text' => $this->DefinitionData['Footnote'][$name]['number'],
+ ),
+ );
+
+ return array(
+ 'extent' => strlen($matches[0]),
+ 'element' => $Element,
+ );
+ }
+ }
+
+ private $footnoteCount = 0;
+
+ #
+ # Link
+
+ protected function inlineLink($Excerpt)
+ {
+ $Link = parent::inlineLink($Excerpt);
+
+ $remainder = $Link !== null ? substr($Excerpt['text'], $Link['extent']) : '';
+
+ if (preg_match('/^[ ]*{('.$this->regexAttribute.'+)}/', $remainder, $matches))
+ {
+ $Link['element']['attributes'] += $this->parseAttributeData($matches[1]);
+
+ $Link['extent'] += strlen($matches[0]);
+ }
+
+ return $Link;
+ }
+
+ #
+ # ~
+ #
+
+ protected function unmarkedText($text)
+ {
+ $text = parent::unmarkedText($text);
+
+ if (isset($this->DefinitionData['Abbreviation']))
+ {
+ foreach ($this->DefinitionData['Abbreviation'] as $abbreviation => $meaning)
+ {
+ $pattern = '/\b'.preg_quote($abbreviation, '/').'\b/';
+
+ $text = preg_replace($pattern, ''.$abbreviation.' ', $text);
+ }
+ }
+
+ return $text;
+ }
+
+ #
+ # Util Methods
+ #
+
+ protected function addDdElement(array $Line, array $Block)
+ {
+ $text = substr($Line['text'], 1);
+ $text = trim($text);
+
+ unset($Block['dd']);
+
+ $Block['dd'] = array(
+ 'name' => 'dd',
+ 'handler' => 'line',
+ 'text' => $text,
+ );
+
+ if (isset($Block['interrupted']))
+ {
+ $Block['dd']['handler'] = 'text';
+
+ unset($Block['interrupted']);
+ }
+
+ $Block['element']['text'] []= & $Block['dd'];
+
+ return $Block;
+ }
+
+ protected function buildFootnoteElement()
+ {
+ $Element = array(
+ 'name' => 'div',
+ 'attributes' => array('class' => 'footnotes'),
+ 'handler' => 'elements',
+ 'text' => array(
+ array(
+ 'name' => 'hr',
+ ),
+ array(
+ 'name' => 'ol',
+ 'handler' => 'elements',
+ 'text' => array(),
+ ),
+ ),
+ );
+
+ uasort($this->DefinitionData['Footnote'], 'self::sortFootnotes');
+
+ foreach ($this->DefinitionData['Footnote'] as $definitionId => $DefinitionData)
+ {
+ if ( ! isset($DefinitionData['number']))
+ {
+ continue;
+ }
+
+ $text = $DefinitionData['text'];
+
+ $text = parent::text($text);
+
+ $numbers = range(1, $DefinitionData['count']);
+
+ $backLinksMarkup = '';
+
+ foreach ($numbers as $number)
+ {
+ $backLinksMarkup .= ' ';
+ }
+
+ $backLinksMarkup = substr($backLinksMarkup, 1);
+
+ if (substr($text, - 4) === '
')
+ {
+ $backLinksMarkup = ' '.$backLinksMarkup;
+
+ $text = substr_replace($text, $backLinksMarkup.'', - 4);
+ }
+ else
+ {
+ $text .= "\n".''.$backLinksMarkup.'
';
+ }
+
+ $Element['text'][1]['text'] []= array(
+ 'name' => 'li',
+ 'attributes' => array('id' => 'fn:'.$definitionId),
+ 'text' => "\n".$text."\n",
+ );
+ }
+
+ return $Element;
+ }
+
+ # ~
+
+ protected function parseAttributeData($attributeString)
+ {
+ $Data = array();
+
+ $attributes = preg_split('/[ ]+/', $attributeString, - 1, PREG_SPLIT_NO_EMPTY);
+
+ foreach ($attributes as $attribute)
+ {
+ if ($attribute[0] === '#')
+ {
+ $Data['id'] = substr($attribute, 1);
+ }
+ else # "."
+ {
+ $classes []= substr($attribute, 1);
+ }
+ }
+
+ if (isset($classes))
+ {
+ $Data['class'] = implode(' ', $classes);
+ }
+
+ return $Data;
+ }
+
+ # ~
+
+ protected function processTag($elementMarkup) # recursive
+ {
+ # http://stackoverflow.com/q/1148928/200145
+ libxml_use_internal_errors(true);
+
+ $DOMDocument = new \DOMDocument;
+
+ # http://stackoverflow.com/q/11309194/200145
+ $elementMarkup = mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8');
+
+ # http://stackoverflow.com/q/4879946/200145
+ $DOMDocument->loadHTML($elementMarkup);
+ $DOMDocument->removeChild($DOMDocument->doctype);
+ $DOMDocument->replaceChild($DOMDocument->firstChild->firstChild->firstChild, $DOMDocument->firstChild);
+
+ $elementText = '';
+
+ if ($DOMDocument->documentElement->getAttribute('markdown') === '1')
+ {
+ foreach ($DOMDocument->documentElement->childNodes as $Node)
+ {
+ $elementText .= $DOMDocument->saveHTML($Node);
+ }
+
+ $DOMDocument->documentElement->removeAttribute('markdown');
+
+ $elementText = "\n".$this->text($elementText)."\n";
+ }
+ else
+ {
+ foreach ($DOMDocument->documentElement->childNodes as $Node)
+ {
+ $nodeMarkup = $DOMDocument->saveHTML($Node);
+
+ if ($Node instanceof \DOMElement and ! in_array($Node->nodeName, $this->textLevelElements))
+ {
+ $elementText .= $this->processTag($nodeMarkup);
+ }
+ else
+ {
+ $elementText .= $nodeMarkup;
+ }
+ }
+ }
+
+ # because we don't want for markup to get encoded
+ $DOMDocument->documentElement->nodeValue = 'placeholder\x1A';
+
+ $markup = $DOMDocument->saveHTML($DOMDocument->documentElement);
+ $markup = str_replace('placeholder\x1A', $elementText, $markup);
+
+ return $markup;
+ }
+
+ # ~
+
+ protected function sortFootnotes($A, $B) # callback
+ {
+ return $A['number'] - $B['number'];
+ }
+
+ #
+ # Fields
+ #
+
+ protected $regexAttribute = '(?:[#.][-\w]+[ ]*)';
+}
diff --git a/system/src/Grav/Framework/Psr7/AbstractUri.php b/system/src/Grav/Framework/Psr7/AbstractUri.php
new file mode 100644
index 0000000..e0d46b6
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/AbstractUri.php
@@ -0,0 +1,408 @@
+ 80,
+ 'https' => 443
+ ];
+
+ /** @var string Uri scheme. */
+ private $scheme = '';
+
+ /** @var string Uri user. */
+ private $user = '';
+
+ /** @var string Uri password. */
+ private $password = '';
+
+ /** @var string Uri host. */
+ private $host = '';
+
+ /** @var int|null Uri port. */
+ private $port;
+
+ /** @var string Uri path. */
+ private $path = '';
+
+ /** @var string Uri query string (without ?). */
+ private $query = '';
+
+ /** @var string Uri fragment (without #). */
+ private $fragment = '';
+
+ /**
+ * Please define constructor which calls $this->init().
+ */
+ abstract public function __construct();
+
+ /**
+ * @inheritdoc
+ */
+ public function getScheme()
+ {
+ return $this->scheme;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getAuthority()
+ {
+ $authority = $this->host;
+
+ $userInfo = $this->getUserInfo();
+ if ($userInfo !== '') {
+ $authority = $userInfo . '@' . $authority;
+ }
+
+ if ($this->port !== null) {
+ $authority .= ':' . $this->port;
+ }
+
+ return $authority;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getUserInfo()
+ {
+ $userInfo = $this->user;
+
+ if ($this->password !== '') {
+ $userInfo .= ':' . $this->password;
+ }
+
+ return $userInfo;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getHost()
+ {
+ return $this->host;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getPort()
+ {
+ return $this->port;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getPath()
+ {
+ return $this->path;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getQuery()
+ {
+ return $this->query;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getFragment()
+ {
+ return $this->fragment;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function withScheme($scheme)
+ {
+ $scheme = UriPartsFilter::filterScheme($scheme);
+
+ if ($this->scheme === $scheme) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->scheme = $scheme;
+ $new->unsetDefaultPort();
+ $new->validate();
+
+ return $new;
+ }
+
+ /**
+ * @inheritdoc
+ * @throws \InvalidArgumentException
+ */
+ public function withUserInfo($user, $password = null)
+ {
+ $user = UriPartsFilter::filterUserInfo($user);
+ $password = UriPartsFilter::filterUserInfo($password ?? '');
+
+ if ($this->user === $user && $this->password === $password) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->user = $user;
+ $new->password = $user !== '' ? $password : '';
+ $new->validate();
+
+ return $new;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function withHost($host)
+ {
+ $host = UriPartsFilter::filterHost($host);
+
+ if ($this->host === $host) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->host = $host;
+ $new->validate();
+
+ return $new;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function withPort($port)
+ {
+ $port = UriPartsFilter::filterPort($port);
+
+ if ($this->port === $port) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->port = $port;
+ $new->unsetDefaultPort();
+ $new->validate();
+
+ return $new;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function withPath($path)
+ {
+ $path = UriPartsFilter::filterPath($path);
+
+ if ($this->path === $path) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->path = $path;
+ $new->validate();
+
+ return $new;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function withQuery($query)
+ {
+ $query = UriPartsFilter::filterQueryOrFragment($query);
+
+ if ($this->query === $query) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->query = $query;
+
+ return $new;
+ }
+
+ /**
+ * @inheritdoc
+ * @throws \InvalidArgumentException
+ */
+ public function withFragment($fragment)
+ {
+ $fragment = UriPartsFilter::filterQueryOrFragment($fragment);
+
+ if ($this->fragment === $fragment) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->fragment = $fragment;
+
+ return $new;
+ }
+
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->getUrl();
+ }
+
+ /**
+ * @return array
+ */
+ protected function getParts()
+ {
+ return [
+ 'scheme' => $this->scheme,
+ 'host' => $this->host,
+ 'port' => $this->port,
+ 'user' => $this->user,
+ 'pass' => $this->password,
+ 'path' => $this->path,
+ 'query' => $this->query,
+ 'fragment' => $this->fragment
+ ];
+ }
+
+ /**
+ * Return the fully qualified base URL ( like http://getgrav.org ).
+ *
+ * Note that this method never includes a trailing /
+ *
+ * @return string
+ */
+ protected function getBaseUrl()
+ {
+ $uri = '';
+
+ $scheme = $this->getScheme();
+ if ($scheme !== '') {
+ $uri .= $scheme . ':';
+ }
+
+ $authority = $this->getAuthority();
+ if ($authority !== '' || $scheme === 'file') {
+ $uri .= '//' . $authority;
+ }
+
+ return $uri;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getUrl()
+ {
+ $uri = $this->getBaseUrl() . $this->getPath();
+
+ $query = $this->getQuery();
+ if ($query !== '') {
+ $uri .= '?' . $query;
+ }
+
+ $fragment = $this->getFragment();
+ if ($fragment !== '') {
+ $uri .= '#' . $fragment;
+ }
+
+ return $uri;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getUser()
+ {
+ return $this->user;
+ }
+
+ /**
+ * @return string
+ */
+ protected function getPassword()
+ {
+ return $this->password;
+ }
+
+ /**
+ * @param array $parts
+ * @throws \InvalidArgumentException
+ */
+ protected function initParts(array $parts)
+ {
+ $this->scheme = isset($parts['scheme']) ? UriPartsFilter::filterScheme($parts['scheme']) : '';
+ $this->user = isset($parts['user']) ? UriPartsFilter::filterUserInfo($parts['user']) : '';
+ $this->password = isset($parts['pass']) ? UriPartsFilter::filterUserInfo($parts['pass']) : '';
+ $this->host = isset($parts['host']) ? UriPartsFilter::filterHost($parts['host']) : '';
+ $this->port = isset($parts['port']) ? UriPartsFilter::filterPort((int)$parts['port']) : null;
+ $this->path = isset($parts['path']) ? UriPartsFilter::filterPath($parts['path']) : '';
+ $this->query = isset($parts['query']) ? UriPartsFilter::filterQueryOrFragment($parts['query']) : '';
+ $this->fragment = isset($parts['fragment']) ? UriPartsFilter::filterQueryOrFragment($parts['fragment']) : '';
+
+ $this->unsetDefaultPort();
+ $this->validate();
+ }
+
+ /**
+ * @throws \InvalidArgumentException
+ */
+ private function validate()
+ {
+ if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) {
+ throw new \InvalidArgumentException('Uri with a scheme must have a host');
+ }
+
+ if ($this->getAuthority() === '') {
+ if (0 === strpos($this->path, '//')) {
+ throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes \'//\'');
+ }
+ if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
+ throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
+ }
+ } elseif (isset($this->path[0]) && $this->path[0] !== '/') {
+ throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash \'/\' or be empty');
+ }
+ }
+
+ protected function isDefaultPort()
+ {
+ $scheme = $this->scheme;
+ $port = $this->port;
+
+ return $this->port === null
+ || (isset(static::$defaultPorts[$scheme]) && $port === static::$defaultPorts[$scheme]);
+ }
+
+ private function unsetDefaultPort()
+ {
+ if ($this->isDefaultPort()) {
+ $this->port = null;
+ }
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/Request.php b/system/src/Grav/Framework/Psr7/Request.php
new file mode 100644
index 0000000..24ea3b6
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/Request.php
@@ -0,0 +1,34 @@
+message = new \Nyholm\Psr7\Request($method, $uri, $headers, $body, $version);
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/Response.php b/system/src/Grav/Framework/Psr7/Response.php
new file mode 100644
index 0000000..960621d
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/Response.php
@@ -0,0 +1,265 @@
+message = new \Nyholm\Psr7\Response($status, $headers, $body, $version, $reason);
+ }
+
+ /**
+ * Json.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * This method prepares the response object to return an HTTP Json
+ * response to the client.
+ *
+ * @param mixed $data The data
+ * @param int $status The HTTP status code.
+ * @param int $options Json encoding options
+ * @param int $depth Json encoding max depth
+ * @return static
+ */
+ public function withJson($data, int $status = null, int $options = 0, int $depth = 512): ResponseInterface
+ {
+ $json = (string) json_encode($data, $options, $depth);
+
+ if (json_last_error() !== JSON_ERROR_NONE) {
+ throw new RuntimeException(json_last_error_msg(), json_last_error());
+ }
+
+ $response = $this->getResponse()
+ ->withHeader('Content-Type', 'application/json;charset=utf-8')
+ ->withBody(new Stream($json));
+
+ if ($status !== null) {
+ $response = $response->withStatus($status);
+ }
+
+ $new = clone $this;
+ $new->message = $response;
+
+ return $new;
+ }
+
+ /**
+ * Redirect.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * This method prepares the response object to return an HTTP Redirect
+ * response to the client.
+ *
+ * @param string $url The redirect destination.
+ * @param int|null $status The redirect HTTP status code.
+ * @return static
+ */
+ public function withRedirect(string $url, $status = null): ResponseInterface
+ {
+ $response = $this->getResponse()->withHeader('Location', $url);
+
+ if ($status === null) {
+ $status = 302;
+ }
+
+ $new = clone $this;
+ $new->message = $response->withStatus($status);
+
+ return $new;
+ }
+
+ /**
+ * Is this response empty?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isEmpty(): bool
+ {
+ return \in_array($this->getResponse()->getStatusCode(), [204, 205, 304], true);
+ }
+
+
+ /**
+ * Is this response OK?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isOk(): bool
+ {
+ return $this->getResponse()->getStatusCode() === 200;
+ }
+
+ /**
+ * Is this response a redirect?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isRedirect(): bool
+ {
+ return \in_array($this->getResponse()->getStatusCode(), [301, 302, 303, 307, 308], true);
+ }
+
+ /**
+ * Is this response forbidden?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ * @api
+ */
+ public function isForbidden(): bool
+ {
+ return $this->getResponse()->getStatusCode() === 403;
+ }
+
+ /**
+ * Is this response not Found?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isNotFound(): bool
+ {
+ return $this->getResponse()->getStatusCode() === 404;
+ }
+
+ /**
+ * Is this response informational?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isInformational(): bool
+ {
+ $response = $this->getResponse();
+
+ return $response->getStatusCode() >= 100 && $response->getStatusCode() < 200;
+ }
+
+ /**
+ * Is this response successful?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isSuccessful(): bool
+ {
+ $response = $this->getResponse();
+
+ return $response->getStatusCode() >= 200 && $response->getStatusCode() < 300;
+ }
+
+ /**
+ * Is this response a redirection?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isRedirection(): bool
+ {
+ $response = $this->getResponse();
+
+ return $response->getStatusCode() >= 300 && $response->getStatusCode() < 400;
+ }
+
+ /**
+ * Is this response a client error?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isClientError(): bool
+ {
+ $response = $this->getResponse();
+
+ return $response->getStatusCode() >= 400 && $response->getStatusCode() < 500;
+ }
+
+ /**
+ * Is this response a server error?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isServerError(): bool
+ {
+ $response = $this->getResponse();
+
+ return $response->getStatusCode() >= 500 && $response->getStatusCode() < 600;
+ }
+
+ /**
+ * Convert response to string.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return string
+ */
+ public function __toString(): string
+ {
+ $response = $this->getResponse();
+ $output = sprintf(
+ 'HTTP/%s %s %s%s',
+ $response->getProtocolVersion(),
+ $response->getStatusCode(),
+ $response->getReasonPhrase(),
+ self::EOL
+ );
+
+ foreach ($response->getHeaders() as $name => $values) {
+ $output .= sprintf('%s: %s', $name, $response->getHeaderLine($name)) . self::EOL;
+ }
+
+ $output .= self::EOL;
+ $output .= (string) $response->getBody();
+
+ return $output;
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/ServerRequest.php b/system/src/Grav/Framework/Psr7/ServerRequest.php
new file mode 100644
index 0000000..bb6b8b8
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/ServerRequest.php
@@ -0,0 +1,372 @@
+message = new \Nyholm\Psr7\ServerRequest($method, $uri, $headers, $body, $version, $serverParams);
+ }
+
+ /**
+ * Get serverRequest content character set, if known.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return string|null
+ */
+ public function getContentCharset(): ?string
+ {
+ $mediaTypeParams = $this->getMediaTypeParams();
+
+ if (isset($mediaTypeParams['charset'])) {
+ return $mediaTypeParams['charset'];
+ }
+
+ return null;
+ }
+
+ /**
+ * Get serverRequest content type.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return string|null The serverRequest content type, if known
+ */
+ public function getContentType(): ?string
+ {
+ $result = $this->getRequest()->getHeader('Content-Type');
+
+ return $result ? $result[0] : null;
+ }
+
+ /**
+ * Get serverRequest content length, if known.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return int|null
+ */
+ public function getContentLength(): ?int
+ {
+ $result = $this->getRequest()->getHeader('Content-Length');
+
+ return $result ? (int) $result[0] : null;
+ }
+
+ /**
+ * Fetch cookie value from cookies sent by the client to the server.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @param string $key The attribute name.
+ * @param mixed $default Default value to return if the attribute does not exist.
+ *
+ * @return mixed
+ */
+ public function getCookieParam($key, $default = null)
+ {
+ $cookies = $this->getRequest()->getCookieParams();
+ $result = $default;
+
+ if (isset($cookies[$key])) {
+ $result = $cookies[$key];
+ }
+
+ return $result;
+ }
+
+ /**
+ * Get serverRequest media type, if known.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return string|null The serverRequest media type, minus content-type params
+ */
+ public function getMediaType(): ?string
+ {
+ $contentType = $this->getContentType();
+
+ if ($contentType) {
+ $contentTypeParts = preg_split('/\s*[;,]\s*/', $contentType);
+ if ($contentTypeParts === false) {
+ return null;
+ }
+ return strtolower($contentTypeParts[0]);
+ }
+
+ return null;
+ }
+
+ /**
+ * Get serverRequest media type params, if known.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return mixed[]
+ */
+ public function getMediaTypeParams(): array
+ {
+ $contentType = $this->getContentType();
+ $contentTypeParams = [];
+
+ if ($contentType) {
+ $contentTypeParts = preg_split('/\s*[;,]\s*/', $contentType);
+ if ($contentTypeParts !== false) {
+ $contentTypePartsLength = count($contentTypeParts);
+ for ($i = 1; $i < $contentTypePartsLength; $i++) {
+ $paramParts = explode('=', $contentTypeParts[$i]);
+ $contentTypeParams[strtolower($paramParts[0])] = $paramParts[1];
+ }
+ }
+ }
+
+ return $contentTypeParams;
+ }
+
+ /**
+ * Fetch serverRequest parameter value from body or query string (in that order).
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @param string $key The parameter key.
+ * @param string $default The default value.
+ *
+ * @return mixed The parameter value.
+ */
+ public function getParam($key, $default = null)
+ {
+ $postParams = $this->getParsedBody();
+ $getParams = $this->getQueryParams();
+ $result = $default;
+
+ if (is_array($postParams) && isset($postParams[$key])) {
+ $result = $postParams[$key];
+ } elseif (is_object($postParams) && property_exists($postParams, $key)) {
+ $result = $postParams->$key;
+ } elseif (isset($getParams[$key])) {
+ $result = $getParams[$key];
+ }
+
+ return $result;
+ }
+
+ /**
+ * Fetch associative array of body and query string parameters.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return mixed[]
+ */
+ public function getParams(): array
+ {
+ $params = $this->getQueryParams();
+ $postParams = $this->getParsedBody();
+
+ if ($postParams) {
+ $params = array_merge($params, (array)$postParams);
+ }
+
+ return $params;
+ }
+
+ /**
+ * Fetch parameter value from serverRequest body.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @param string $key
+ * @param mixed $default
+ *
+ * @return mixed
+ */
+ public function getParsedBodyParam($key, $default = null)
+ {
+ $postParams = $this->getParsedBody();
+ $result = $default;
+
+ if (is_array($postParams) && isset($postParams[$key])) {
+ $result = $postParams[$key];
+ } elseif (is_object($postParams) && property_exists($postParams, $key)) {
+ $result = $postParams->{$key};
+ }
+
+ return $result;
+ }
+
+ /**
+ * Fetch parameter value from query string.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @param string $key
+ * @param mixed $default
+ *
+ * @return mixed
+ */
+ public function getQueryParam($key, $default = null)
+ {
+ $getParams = $this->getQueryParams();
+ $result = $default;
+
+ if (isset($getParams[$key])) {
+ $result = $getParams[$key];
+ }
+
+ return $result;
+ }
+
+ /**
+ * Retrieve a server parameter.
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function getServerParam($key, $default = null)
+ {
+ $serverParams = $this->getRequest()->getServerParams();
+
+ return $serverParams[$key] ?? $default;
+ }
+
+ /**
+ * Does this serverRequest use a given method?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @param string $method HTTP method
+ * @return bool
+ */
+ public function isMethod($method): bool
+ {
+ return $this->getRequest()->getMethod() === $method;
+ }
+
+ /**
+ * Is this a DELETE serverRequest?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isDelete(): bool
+ {
+ return $this->isMethod('DELETE');
+ }
+
+ /**
+ * Is this a GET serverRequest?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isGet(): bool
+ {
+ return $this->isMethod('GET');
+ }
+
+ /**
+ * Is this a HEAD serverRequest?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isHead(): bool
+ {
+ return $this->isMethod('HEAD');
+ }
+
+ /**
+ * Is this a OPTIONS serverRequest?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isOptions(): bool
+ {
+ return $this->isMethod('OPTIONS');
+ }
+
+ /**
+ * Is this a PATCH serverRequest?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isPatch(): bool
+ {
+ return $this->isMethod('PATCH');
+ }
+
+ /**
+ * Is this a POST serverRequest?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isPost(): bool
+ {
+ return $this->isMethod('POST');
+ }
+
+ /**
+ * Is this a PUT serverRequest?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isPut(): bool
+ {
+ return $this->isMethod('PUT');
+ }
+
+ /**
+ * Is this an XHR serverRequest?
+ *
+ * Note: This method is not part of the PSR-7 standard.
+ *
+ * @return bool
+ */
+ public function isXhr(): bool
+ {
+ return $this->getRequest()->getHeaderLine('X-Requested-With') === 'XMLHttpRequest';
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/Stream.php b/system/src/Grav/Framework/Psr7/Stream.php
new file mode 100644
index 0000000..9431052
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/Stream.php
@@ -0,0 +1,25 @@
+stream = \Nyholm\Psr7\Stream::create($body);
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php
new file mode 100644
index 0000000..28ed1f5
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php
@@ -0,0 +1,140 @@
+
+ */
+trait MessageDecoratorTrait
+{
+ /** @var MessageInterface */
+ private $message;
+
+ /**
+ * Returns the decorated message.
+ *
+ * Since the underlying Message is immutable as well
+ * exposing it is not an issue, because it's state cannot be altered
+ *
+ * @return MessageInterface
+ */
+ public function getMessage(): MessageInterface
+ {
+ return $this->message;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getProtocolVersion(): string
+ {
+ return $this->message->getProtocolVersion();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withProtocolVersion($version): self
+ {
+ $new = clone $this;
+ $new->message = $this->message->withProtocolVersion($version);
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getHeaders(): array
+ {
+ return $this->message->getHeaders();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function hasHeader($header): bool
+ {
+ return $this->message->hasHeader($header);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getHeader($header): array
+ {
+ return $this->message->getHeader($header);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getHeaderLine($header): string
+ {
+ return $this->message->getHeaderLine($header);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBody(): StreamInterface
+ {
+ return $this->message->getBody();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withHeader($header, $value): self
+ {
+ $new = clone $this;
+ $new->message = $this->message->withHeader($header, $value);
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withAddedHeader($header, $value): self
+ {
+ $new = clone $this;
+ $new->message = $this->message->withAddedHeader($header, $value);
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withoutHeader($header): self
+ {
+ $new = clone $this;
+ $new->message = $this->message->withoutHeader($header);
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withBody(StreamInterface $body): self
+ {
+ $new = clone $this;
+ $new->message = $this->message->withBody($body);
+
+ return $new;
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php
new file mode 100644
index 0000000..ab1ffad
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php
@@ -0,0 +1,112 @@
+
+ */
+trait RequestDecoratorTrait
+{
+ use MessageDecoratorTrait {
+ getMessage as private;
+ }
+
+ /**
+ * Returns the decorated request.
+ *
+ * Since the underlying Request is immutable as well
+ * exposing it is not an issue, because it's state cannot be altered
+ *
+ * @return RequestInterface
+ */
+ public function getRequest(): RequestInterface
+ {
+ /** @var RequestInterface $message */
+ $message = $this->getMessage();
+
+ return $message;
+ }
+
+ /**
+ * Exchanges the underlying request with another.
+ *
+ * @param RequestInterface $request
+ * @return self
+ */
+ public function withRequest(RequestInterface $request): self
+ {
+ $new = clone $this;
+ $new->message = $request;
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getRequestTarget(): string
+ {
+ return $this->getRequest()->getRequestTarget();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withRequestTarget($requestTarget): self
+ {
+ $new = clone $this;
+ $new->message = $this->getRequest()->withRequestTarget($requestTarget);
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getMethod(): string
+ {
+ return $this->getRequest()->getMethod();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withMethod($method): self
+ {
+ $new = clone $this;
+ $new->message = $this->getRequest()->withMethod($method);
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getUri(): UriInterface
+ {
+ return $this->getRequest()->getUri();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withUri(UriInterface $uri, $preserveHost = false): self
+ {
+ $new = clone $this;
+ $new->message = $this->getRequest()->withUri($uri, $preserveHost);
+
+ return $new;
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php
new file mode 100644
index 0000000..32a1bfb
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php
@@ -0,0 +1,82 @@
+
+ */
+trait ResponseDecoratorTrait
+{
+ use MessageDecoratorTrait {
+ getMessage as private;
+ }
+
+ /**
+ * Returns the decorated response.
+ *
+ * Since the underlying Response is immutable as well
+ * exposing it is not an issue, because it's state cannot be altered
+ *
+ * @return ResponseInterface
+ */
+ public function getResponse(): ResponseInterface
+ {
+ /** @var ResponseInterface $message */
+ $message = $this->getMessage();
+
+ return $message;
+ }
+
+ /**
+ * Exchanges the underlying response with another.
+ *
+ * @param ResponseInterface $response
+ *
+ * @return self
+ */
+ public function withResponse(ResponseInterface $response): self
+ {
+ $new = clone $this;
+ $new->message = $response;
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getStatusCode(): int
+ {
+ return $this->getResponse()->getStatusCode();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withStatus($code, $reasonPhrase = ''): self
+ {
+ $new = clone $this;
+ $new->message = $this->getResponse()->withStatus($code, $reasonPhrase);
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getReasonPhrase(): string
+ {
+ return $this->getResponse()->getReasonPhrase();
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php
new file mode 100644
index 0000000..f9297dd
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php
@@ -0,0 +1,168 @@
+getMessage();
+
+ return $message;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getAttribute($name, $default = null)
+ {
+ return $this->getRequest()->getAttribute($name, $default);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getAttributes()
+ {
+ return $this->getRequest()->getAttributes();
+ }
+
+
+ /**
+ * @inheritdoc
+ */
+ public function getCookieParams()
+ {
+ return $this->getRequest()->getCookieParams();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getParsedBody()
+ {
+ return $this->getRequest()->getParsedBody();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getQueryParams()
+ {
+ return $this->getRequest()->getQueryParams();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getServerParams()
+ {
+ return $this->getRequest()->getServerParams();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getUploadedFiles()
+ {
+ return $this->getRequest()->getUploadedFiles();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function withAttribute($name, $value)
+ {
+ $new = clone $this;
+ $new->message = $this->getRequest()->withAttribute($name, $value);
+
+ return $new;
+ }
+
+ public function withAttributes(array $attributes)
+ {
+ $new = clone $this;
+ foreach ($attributes as $attribute => $value) {
+ $new->message = $new->withAttribute($attribute, $value);
+ }
+
+ return $new;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function withoutAttribute($name)
+ {
+ $new = clone $this;
+ $new->message = $this->getRequest()->withoutAttribute($name);
+
+ return $new;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function withCookieParams(array $cookies)
+ {
+ $new = clone $this;
+ $new->message = $this->getRequest()->withCookieParams($cookies);
+
+ return $new;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function withParsedBody($data)
+ {
+ $new = clone $this;
+ $new->message = $this->getRequest()->withParsedBody($data);
+
+ return $new;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function withQueryParams(array $query)
+ {
+ $new = clone $this;
+ $new->message = $this->getRequest()->withQueryParams($query);
+
+ return $new;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function withUploadedFiles(array $uploadedFiles)
+ {
+ $new = clone $this;
+ $new->message = $this->getRequest()->withUploadedFiles($uploadedFiles);
+
+ return $new;
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php
new file mode 100644
index 0000000..f61ea4b
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php
@@ -0,0 +1,145 @@
+stream->__toString();
+ }
+
+ public function __destruct()
+ {
+ $this->stream->close();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function close(): void
+ {
+ $this->stream->close();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function detach()
+ {
+ return $this->stream->detach();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getSize(): ?int
+ {
+ return $this->stream->getSize();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function tell(): int
+ {
+ return $this->stream->tell();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function eof(): bool
+ {
+ return $this->stream->eof();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSeekable(): bool
+ {
+ return $this->stream->isSeekable();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function seek($offset, $whence = \SEEK_SET): void
+ {
+ $this->stream->seek($offset, $whence);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function rewind(): void
+ {
+ $this->stream->rewind();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isWritable(): bool
+ {
+ return $this->stream->isWritable();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function write($string): int
+ {
+ return $this->stream->write($string);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isReadable(): bool
+ {
+ return $this->stream->isReadable();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function read($length): string
+ {
+ return $this->stream->read($length);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getContents(): string
+ {
+ return $this->stream->getContents();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getMetadata($key = null)
+ {
+ return $this->stream->getMetadata($key);
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php
new file mode 100644
index 0000000..677c4d2
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php
@@ -0,0 +1,51 @@
+uploadedFile->getStream();
+ }
+
+ public function moveTo($targetPath): void
+ {
+ $this->uploadedFile->moveTo($targetPath);
+ }
+
+ public function getSize(): ?int
+ {
+ return $this->uploadedFile->getSize();
+ }
+
+ public function getError(): int
+ {
+ return $this->uploadedFile->getError();
+ }
+
+ public function getClientFilename(): ?string
+ {
+ return $this->uploadedFile->getClientFilename();
+ }
+
+ public function getClientMediaType(): ?string
+ {
+ return $this->uploadedFile->getClientMediaType();
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php b/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php
new file mode 100644
index 0000000..9e7946a
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php
@@ -0,0 +1,128 @@
+uri->__toString();
+ }
+
+ public function getScheme(): string
+ {
+ return $this->uri->getScheme();
+ }
+
+ public function getAuthority(): string
+ {
+ return $this->uri->getAuthority();
+ }
+
+ public function getUserInfo(): string
+ {
+ return $this->uri->getUserInfo();
+ }
+
+ public function getHost(): string
+ {
+ return $this->uri->getHost();
+ }
+
+ public function getPort(): ?int
+ {
+ return $this->uri->getPort();
+ }
+
+ public function getPath(): string
+ {
+ return $this->uri->getPath();
+ }
+
+ public function getQuery(): string
+ {
+ return $this->uri->getQuery();
+ }
+
+ public function getFragment(): string
+ {
+ return $this->uri->getFragment();
+ }
+
+ public function withScheme($scheme): UriInterface
+ {
+ /** @var UriInterface|UriDecorationTrait $new */
+ $new = clone $this;
+ $new->uri = $this->uri->withScheme($scheme);
+
+ return $new;
+ }
+
+ public function withUserInfo($user, $password = null): UriInterface
+ {
+ /** @var UriInterface|UriDecorationTrait $new */
+ $new = clone $this;
+ $new->uri = $this->uri->withUserInfo($user, $password);
+
+ return $new;
+ }
+
+ public function withHost($host): UriInterface
+ {
+ /** @var UriInterface|UriDecorationTrait $new */
+ $new = clone $this;
+ $new->uri = $this->uri->withHost($host);
+
+ return $new;
+ }
+
+ public function withPort($port): UriInterface
+ {
+ /** @var UriInterface|UriDecorationTrait $new */
+ $new = clone $this;
+ $new->uri = $this->uri->withPort($port);
+
+ return $new;
+ }
+
+ public function withPath($path): UriInterface
+ {
+ /** @var UriInterface|UriDecorationTrait $new */
+ $new = clone $this;
+ $new->uri = $this->uri->withPath($path);
+
+ return $new;
+ }
+
+ public function withQuery($query): UriInterface
+ {
+ /** @var UriInterface|UriDecorationTrait $new */
+ $new = clone $this;
+ $new->uri = $this->uri->withQuery($query);
+
+ return $new;
+ }
+
+ public function withFragment($fragment): UriInterface
+ {
+ /** @var UriInterface|UriDecorationTrait $new */
+ $new = clone $this;
+ $new->uri = $this->uri->withFragment($fragment);
+
+ return $new;
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/UploadedFile.php b/system/src/Grav/Framework/Psr7/UploadedFile.php
new file mode 100644
index 0000000..d6b062f
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/UploadedFile.php
@@ -0,0 +1,33 @@
+uploadedFile = new \Nyholm\Psr7\UploadedFile($streamOrFile, $size, $errorStatus, $clientFilename, $clientMediaType);
+ }
+}
diff --git a/system/src/Grav/Framework/Psr7/Uri.php b/system/src/Grav/Framework/Psr7/Uri.php
new file mode 100644
index 0000000..28614ca
--- /dev/null
+++ b/system/src/Grav/Framework/Psr7/Uri.php
@@ -0,0 +1,134 @@
+uri = new \Nyholm\Psr7\Uri($uri);
+ }
+
+ /**
+ * @return array
+ */
+ public function getQueryParams(): array
+ {
+ return UriFactory::parseQuery($this->getQuery());
+ }
+
+ /**
+ * @param array $params
+ * @return UriInterface
+ */
+ public function withQueryParams(array $params): UriInterface
+ {
+ $query = UriFactory::buildQuery($params);
+
+ return $this->withQuery($query);
+ }
+
+ /**
+ * Whether the URI has the default port of the current scheme.
+ *
+ * `$uri->getPort()` may return the standard port. This method can be used for some non-http/https Uri.
+ *
+ * @return bool
+ */
+ public function isDefaultPort(): bool
+ {
+ return $this->getPort() === null || GuzzleUri::isDefaultPort($this);
+ }
+
+ /**
+ * Whether the URI is absolute, i.e. it has a scheme.
+ *
+ * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true
+ * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative
+ * to another URI, the base URI. Relative references can be divided into several forms:
+ * - network-path references, e.g. '//example.com/path'
+ * - absolute-path references, e.g. '/path'
+ * - relative-path references, e.g. 'subpath'
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4
+ */
+ public function isAbsolute(): bool
+ {
+ return GuzzleUri::isAbsolute($this);
+ }
+
+ /**
+ * Whether the URI is a network-path reference.
+ *
+ * A relative reference that begins with two slash characters is termed an network-path reference.
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.2
+ */
+ public function isNetworkPathReference(): bool
+ {
+ return GuzzleUri::isNetworkPathReference($this);
+ }
+
+ /**
+ * Whether the URI is a absolute-path reference.
+ *
+ * A relative reference that begins with a single slash character is termed an absolute-path reference.
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.2
+ */
+ public function isAbsolutePathReference(): bool
+ {
+ return GuzzleUri::isAbsolutePathReference($this);
+ }
+
+ /**
+ * Whether the URI is a relative-path reference.
+ *
+ * A relative reference that does not begin with a slash character is termed a relative-path reference.
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.2
+ */
+ public function isRelativePathReference(): bool
+ {
+ return GuzzleUri::isRelativePathReference($this);
+ }
+
+ /**
+ * Whether the URI is a same-document reference.
+ *
+ * A same-document reference refers to a URI that is, aside from its fragment
+ * component, identical to the base URI. When no base URI is given, only an empty
+ * URI reference (apart from its fragment) is considered a same-document reference.
+ *
+ * @param UriInterface|null $base An optional base URI to compare against
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.4
+ */
+ public function isSameDocumentReference(UriInterface $base = null): bool
+ {
+ return GuzzleUri::isSameDocumentReference($this, $base);
+ }
+}
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php b/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php
new file mode 100644
index 0000000..4cacd71
--- /dev/null
+++ b/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php
@@ -0,0 +1,47 @@
+invalidMiddleware = $invalidMiddleware;
+ }
+
+ /**
+ * Return the invalid middleware
+ *
+ * @return mixed|null
+ */
+ public function getInvalidMiddleware()
+ {
+ return $this->invalidMiddleware;
+ }
+}
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php b/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
new file mode 100644
index 0000000..5e8d22a
--- /dev/null
+++ b/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
@@ -0,0 +1,39 @@
+getMethod()), ['PUT', 'PATCH', 'DELETE'])) {
+ parent::__construct($request, 'Method Not Allowed', 405, $previous);
+ } else {
+ parent::__construct($request, 'Not Found', 404, $previous);
+ }
+ }
+
+ public function getRequest(): ServerRequestInterface
+ {
+ return $this->request;
+ }
+}
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php b/system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php
new file mode 100644
index 0000000..6696013
--- /dev/null
+++ b/system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php
@@ -0,0 +1,16 @@
+ 'Bad Request',
+ 401 => 'Unauthorized',
+ 402 => 'Payment Required',
+ 403 => 'Forbidden',
+ 404 => 'Not Found',
+ 405 => 'Method Not Allowed',
+ 406 => 'Not Acceptable',
+ 407 => 'Proxy Authentication Required',
+ 408 => 'Request Time-out',
+ 409 => 'Conflict',
+ 410 => 'Gone',
+ 411 => 'Length Required',
+ 412 => 'Precondition Failed',
+ 413 => 'Request Entity Too Large',
+ 414 => 'Request-URI Too Large',
+ 415 => 'Unsupported Media Type',
+ 416 => 'Requested range not satisfiable',
+ 417 => 'Expectation Failed',
+ 418 => 'I\'m a teapot',
+ 419 => 'Page Expired',
+ 422 => 'Unprocessable Entity',
+ 423 => 'Locked',
+ 424 => 'Failed Dependency',
+ 425 => 'Unordered Collection',
+ 426 => 'Upgrade Required',
+ 428 => 'Precondition Required',
+ 429 => 'Too Many Requests',
+ 431 => 'Request Header Fields Too Large',
+ 451 => 'Unavailable For Legal Reasons',
+
+ 500 => 'Internal Server Error',
+ 501 => 'Not Implemented',
+ 502 => 'Bad Gateway',
+ 503 => 'Service Unavailable',
+ 504 => 'Gateway Time-out',
+ 505 => 'HTTP Version not supported',
+ 506 => 'Variant Also Negotiates',
+ 507 => 'Insufficient Storage',
+ 508 => 'Loop Detected',
+ 511 => 'Network Authentication Required',
+ ];
+
+ /** @var ServerRequestInterface */
+ private $request;
+
+ /**
+ * @param ServerRequestInterface $request
+ * @param string $message
+ * @param int $code
+ * @param \Throwable|null $previous
+ */
+ public function __construct(ServerRequestInterface $request, string $message, int $code = 500, \Throwable $previous = null)
+ {
+ $this->request = $request;
+
+ parent::__construct($message, $code, $previous);
+ }
+
+ /**
+ * @return ServerRequestInterface
+ */
+ public function getRequest() : ServerRequestInterface
+ {
+ return $this->request;
+ }
+
+ public function getHttpCode() : int
+ {
+ $code = $this->getCode();
+
+ return isset(self::$phrases[$code]) ? $code : 500;
+ }
+
+ public function getHttpReason() : ?string
+ {
+ return self::$phrases[$this->getCode()] ?? self::$phrases[500];
+ }
+}
diff --git a/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php b/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
new file mode 100644
index 0000000..ec1de6d
--- /dev/null
+++ b/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
@@ -0,0 +1,44 @@
+handle($request);
+ } catch (\Throwable $exception) {
+ $response = [
+ 'error' => [
+ 'type' => \get_class($exception),
+ 'code' => $exception->getCode(),
+ 'message' => $exception->getMessage(),
+ 'file' => $exception->getFile(),
+ 'line' => $exception->getLine(),
+ 'trace' => explode("\n", $exception->getTraceAsString()),
+ ]
+ ];
+
+ /** @var string $json */
+ $json = json_encode($response);
+
+ return new Response($exception->getCode() ?: 500, ['Content-Type' => 'application/json'], $json);
+ }
+ }
+}
diff --git a/system/src/Grav/Framework/RequestHandler/RequestHandler.php b/system/src/Grav/Framework/RequestHandler/RequestHandler.php
new file mode 100644
index 0000000..c4d5387
--- /dev/null
+++ b/system/src/Grav/Framework/RequestHandler/RequestHandler.php
@@ -0,0 +1,66 @@
+middleware = $middleware;
+ $this->handler = $default;
+ $this->container = $container;
+ }
+
+ /**
+ * Add callable initializing Middleware that will be executed as soon as possible.
+ *
+ * @param string $name
+ * @param callable $callable
+ * @return $this
+ */
+ public function addCallable(string $name, callable $callable): self
+ {
+ $this->container[$name] = $callable;
+ array_unshift($this->middleware, $name);
+
+ return $this;
+ }
+
+ /**
+ * Add Middleware that will be executed as soon as possible.
+ *
+ * @param string $name
+ * @param MiddlewareInterface $middleware
+ * @return $this
+ */
+ public function addMiddleware(string $name, MiddlewareInterface $middleware): self
+ {
+ $this->container[$name] = $middleware;
+ array_unshift($this->middleware, $name);
+
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php b/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
new file mode 100644
index 0000000..153d1a1
--- /dev/null
+++ b/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
@@ -0,0 +1,59 @@
+ */
+ protected $middleware;
+
+ /** @var callable */
+ private $handler;
+
+ /** @var ContainerInterface|null */
+ private $container;
+
+ /**
+ * {@inheritdoc}
+ * @throws InvalidArgumentException
+ */
+ public function handle(ServerRequestInterface $request): ResponseInterface
+ {
+ $middleware = array_shift($this->middleware);
+
+ // Use default callable if there is no middleware.
+ if ($middleware === null) {
+ return \call_user_func($this->handler, $request);
+ }
+
+ if ($middleware instanceof MiddlewareInterface) {
+ return $middleware->process($request, clone $this);
+ }
+
+ if (null === $this->container || !$this->container->has($middleware)) {
+ throw new InvalidArgumentException(
+ sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class),
+ $middleware
+ );
+ }
+
+ array_unshift($this->middleware, $this->container->get($middleware));
+
+ return $this->handle($request);
+ }
+}
\ No newline at end of file
diff --git a/system/src/Grav/Framework/Route/Route.php b/system/src/Grav/Framework/Route/Route.php
new file mode 100644
index 0000000..541dc4f
--- /dev/null
+++ b/system/src/Grav/Framework/Route/Route.php
@@ -0,0 +1,396 @@
+initParts($parts);
+ }
+
+ /**
+ * @return array
+ */
+ public function getParts()
+ {
+ return [
+ 'path' => $this->getUriPath(true),
+ 'query' => $this->getUriQuery(),
+ 'grav' => [
+ 'root' => $this->root,
+ 'language' => $this->language,
+ 'route' => $this->route,
+ 'extension' => $this->extension,
+ 'grav_params' => $this->gravParams,
+ 'query_params' => $this->queryParams,
+ ],
+ ];
+ }
+
+ /**
+ * @return string
+ */
+ public function getRootPrefix()
+ {
+ return $this->root;
+ }
+
+ /**
+ * @return string
+ */
+ public function getLanguagePrefix()
+ {
+ return $this->language !== '' ? '/' . $this->language : '';
+ }
+
+ /**
+ * @param int $offset
+ * @param int|null $length
+ * @return string
+ */
+ public function getRoute($offset = 0, $length = null)
+ {
+ if ($offset !== 0 || $length !== null) {
+ return ($offset === 0 ? '/' : '') . implode('/', $this->getRouteParts($offset, $length));
+ }
+
+ return '/' . $this->route;
+ }
+
+ /**
+ * @return string
+ */
+ public function getExtension()
+ {
+ return $this->extension;
+ }
+
+ /**
+ * @param int $offset
+ * @param int|null $length
+ * @return array
+ */
+ public function getRouteParts($offset = 0, $length = null)
+ {
+ $parts = explode('/', $this->route);
+
+ if ($offset !== 0 || $length !== null) {
+ $parts = \array_slice($parts, $offset, $length);
+ }
+
+ return $parts;
+ }
+
+ /**
+ * Return array of both query and Grav parameters.
+ *
+ * If a parameter exists in both, prefer Grav parameter.
+ *
+ * @return array
+ */
+ public function getParams()
+ {
+ return $this->gravParams + $this->queryParams;
+ }
+
+ /**
+ * @return array
+ */
+ public function getGravParams()
+ {
+ return $this->gravParams;
+ }
+
+ /**
+ * @return array
+ */
+ public function getQueryParams()
+ {
+ return $this->queryParams;
+ }
+
+ /**
+ * Return value of the parameter, looking into both Grav parameters and query parameters.
+ *
+ * If the parameter exists in both, return Grav parameter.
+ *
+ * @param string $param
+ * @return string|array|null
+ */
+ public function getParam($param)
+ {
+ return $this->getGravParam($param) ?? $this->getQueryParam($param);
+ }
+
+ /**
+ * @param string $param
+ * @return string|null
+ */
+ public function getGravParam($param)
+ {
+ return $this->gravParams[$param] ?? null;
+ }
+
+ /**
+ * @param string $param
+ * @return string|array|null
+ */
+ public function getQueryParam($param)
+ {
+ return $this->queryParams[$param] ?? null;
+ }
+
+ /**
+ * Allow the ability to set the route to something else
+ *
+ * @param string $route
+ * @return $this
+ */
+ public function withRoute($route)
+ {
+ $this->route = $route;
+
+ return $this;
+ }
+
+ /**
+ * Allow the ability to set the root to something else
+ *
+ * @param string $root
+ * @return $this
+ */
+ public function withRoot($root)
+ {
+ $this->root = $root;
+
+ return $this;
+ }
+
+ /**
+ * @param string $path
+ * @return Route
+ */
+ public function withAddedPath($path)
+ {
+ $this->route .= '/' . ltrim($path, '/');
+
+ return $this;
+ }
+
+ /**
+ * @param string $extension
+ * @return Route
+ */
+ public function withExtension($extension)
+ {
+ $this->extension = $extension;
+
+ return $this;
+ }
+
+ /**
+ * @param string $param
+ * @param mixed $value
+ * @return Route
+ */
+ public function withGravParam($param, $value)
+ {
+ return $this->withParam('gravParams', $param, null !== $value ? (string)$value : null);
+ }
+
+ /**
+ * @param string $param
+ * @param mixed $value
+ * @return Route
+ */
+ public function withQueryParam($param, $value)
+ {
+ return $this->withParam('queryParams', $param, $value);
+ }
+
+ public function withoutParams()
+ {
+ return $this->withoutGravParams()->withoutQueryParams();
+ }
+
+ public function withoutGravParams()
+ {
+ $this->gravParams = [];
+
+ return $this;
+ }
+
+ public function withoutQueryParams()
+ {
+ $this->queryParams = [];
+
+ return $this;
+ }
+
+ /**
+ * @return \Grav\Framework\Uri\Uri
+ */
+ public function getUri()
+ {
+ return UriFactory::createFromParts($this->getParts());
+ }
+
+ /**
+ * @param bool $includeRoot
+ * @return string
+ */
+ public function toString(bool $includeRoot = false)
+ {
+ $url = $this->getUriPath($includeRoot);
+
+ if ($this->queryParams) {
+ $url .= '?' . $this->getUriQuery();
+ }
+
+ return rtrim($url,'/');
+ }
+
+ /**
+ * @return string
+ * @deprecated 1.6 Use ->toString(true) or ->getUri() instead.
+ */
+ public function __toString()
+ {
+ user_error(__CLASS__ . '::' . __FUNCTION__ . '() will change in the future to return route, not relative url: use ->toString(true) or ->getUri() instead.', E_USER_DEPRECATED);
+
+ return $this->toString(true);
+ }
+
+ /**
+ * @param string $type
+ * @param string $param
+ * @param mixed $value
+ * @return static
+ */
+ protected function withParam($type, $param, $value)
+ {
+ $values = $this->{$type} ?? [];
+ $oldValue = $values[$param] ?? null;
+
+ if ($oldValue === $value) {
+ return $this;
+ }
+
+ $new = $this->copy();
+ if ($value === null) {
+ unset($values[$param]);
+ } else {
+ $values[$param] = $value;
+ }
+
+ $new->{$type} = $values;
+
+ return $new;
+ }
+
+ protected function copy()
+ {
+ return clone $this;
+ }
+
+ /**
+ * @param bool $includeRoot
+ * @return string
+ */
+ protected function getUriPath($includeRoot = false)
+ {
+ $parts = $includeRoot ? [$this->root] : [''];
+
+ if ($this->language !== '') {
+ $parts[] = $this->language;
+ }
+
+ $parts[] = $this->extension ? $this->route . '.' . $this->extension : $this->route;
+
+
+ if ($this->gravParams) {
+ $parts[] = RouteFactory::buildParams($this->gravParams);
+ }
+
+ return implode('/', $parts);
+ }
+
+ /**
+ * @return string
+ */
+ protected function getUriQuery()
+ {
+ return UriFactory::buildQuery($this->queryParams);
+ }
+
+ /**
+ * @param array $parts
+ */
+ protected function initParts(array $parts)
+ {
+ if (isset($parts['grav'])) {
+ $gravParts = $parts['grav'];
+ $this->root = $gravParts['root'];
+ $this->language = $gravParts['language'];
+ $this->route = $gravParts['route'];
+ $this->extension = $gravParts['extension'] ?? '';
+ $this->gravParams = $gravParts['params'] ?: [];
+ $this->queryParams = $parts['query_params'] ?: [];
+
+ } else {
+ $this->root = RouteFactory::getRoot();
+ $this->language = RouteFactory::getLanguage();
+
+ $path = $parts['path'] ?? '/';
+ if (isset($parts['params'])) {
+ $this->route = trim(rawurldecode($path), '/');
+ $this->gravParams = $parts['params'];
+ } else {
+ $this->route = trim(RouteFactory::stripParams($path, true), '/');
+ $this->gravParams = RouteFactory::getParams($path);
+ }
+ if (isset($parts['query'])) {
+ $this->queryParams = UriFactory::parseQuery($parts['query']);
+ }
+ }
+ }
+}
diff --git a/system/src/Grav/Framework/Route/RouteFactory.php b/system/src/Grav/Framework/Route/RouteFactory.php
new file mode 100644
index 0000000..6b3414a
--- /dev/null
+++ b/system/src/Grav/Framework/Route/RouteFactory.php
@@ -0,0 +1,157 @@
+ $path,
+ 'query' => '',
+ 'query_params' => [],
+ 'grav' => [
+ 'root' => self::$root,
+ 'language' => self::$language,
+ 'route' => $path,
+ 'params' => ''
+ ],
+ ];
+ return new Route($parts);
+ }
+
+ public static function getRoot()
+ {
+ return self::$root;
+ }
+
+ public static function setRoot($root)
+ {
+ self::$root = rtrim($root, '/');
+ }
+
+ public static function getLanguage()
+ {
+ return self::$language;
+ }
+
+ public static function setLanguage($language)
+ {
+ self::$language = trim($language, '/');
+ }
+
+ public static function getParamValueDelimiter()
+ {
+ return self::$delimiter;
+ }
+
+ public static function setParamValueDelimiter($delimiter)
+ {
+ self::$delimiter = $delimiter ?: ':';
+ }
+
+ /**
+ * @param array $params
+ * @return string
+ */
+ public static function buildParams(array $params)
+ {
+ if (!$params) {
+ return '';
+ }
+
+ $delimiter = self::$delimiter;
+
+ $output = [];
+ foreach ($params as $key => $value) {
+ $output[] = "{$key}{$delimiter}{$value}";
+ }
+
+ return implode('/', $output);
+ }
+
+ /**
+ * @param string $path
+ * @param bool $decode
+ * @return string
+ */
+ public static function stripParams($path, $decode = false)
+ {
+ $pos = strpos($path, self::$delimiter);
+
+ if ($pos === false) {
+ return $path;
+ }
+
+ $path = \dirname(substr($path, 0, $pos));
+ if ($path === '.') {
+ return '';
+ }
+
+ return $decode ? rawurldecode($path) : $path;
+ }
+
+ /**
+ * @param string $path
+ * @return array
+ */
+ public static function getParams($path)
+ {
+ $params = ltrim(substr($path, \strlen(static::stripParams($path))), '/');
+
+ return $params !== '' ? static::parseParams($params) : [];
+ }
+
+ /**
+ * @param string $str
+ * @return array
+ */
+ public static function parseParams($str)
+ {
+ if ($str === '') {
+ return [];
+ }
+
+ $delimiter = self::$delimiter;
+
+ /** @var array $params */
+ $params = explode('/', $str);
+ foreach ($params as &$param) {
+ /** @var array $parts */
+ $parts = explode($delimiter, $param, 2);
+ if (isset($parts[1])) {
+ $var = rawurldecode($parts[0]);
+ $val = rawurldecode($parts[1]);
+ $param = [$var => $val];
+ }
+ }
+
+ return $params;
+ }
+}
diff --git a/system/src/Grav/Framework/Session/Exceptions/SessionException.php b/system/src/Grav/Framework/Session/Exceptions/SessionException.php
new file mode 100644
index 0000000..4caab82
--- /dev/null
+++ b/system/src/Grav/Framework/Session/Exceptions/SessionException.php
@@ -0,0 +1,14 @@
+isSessionStarted()) {
+ session_unset();
+ session_destroy();
+ }
+
+ // Set default options.
+ $options += [
+ 'cache_limiter' => 'nocache',
+ 'use_trans_sid' => 0,
+ 'use_cookies' => 1,
+ 'lazy_write' => 1,
+ 'use_strict_mode' => 1
+ ];
+
+ $this->setOptions($options);
+
+ session_register_shutdown();
+
+ self::$instance = $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getId()
+ {
+ return session_id();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setId($id)
+ {
+ session_id($id);
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getName()
+ {
+ return session_name();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setName($name)
+ {
+ session_name($name);
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setOptions(array $options)
+ {
+ if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) {
+ return;
+ }
+
+ $allowedOptions = [
+ 'save_path' => true,
+ 'name' => true,
+ 'save_handler' => true,
+ 'gc_probability' => true,
+ 'gc_divisor' => true,
+ 'gc_maxlifetime' => true,
+ 'serialize_handler' => true,
+ 'cookie_lifetime' => true,
+ 'cookie_path' => true,
+ 'cookie_domain' => true,
+ 'cookie_secure' => true,
+ 'cookie_httponly' => true,
+ 'use_strict_mode' => true,
+ 'use_cookies' => true,
+ 'use_only_cookies' => true,
+ 'referer_check' => true,
+ 'cache_limiter' => true,
+ 'cache_expire' => true,
+ 'use_trans_sid' => true,
+ 'trans_sid_tags' => true,
+ 'trans_sid_hosts' => true,
+ 'sid_length' => true,
+ 'sid_bits_per_character' => true,
+ 'upload_progress.enabled' => true,
+ 'upload_progress.cleanup' => true,
+ 'upload_progress.prefix' => true,
+ 'upload_progress.name' => true,
+ 'upload_progress.freq' => true,
+ 'upload_progress.min-freq' => true,
+ 'lazy_write' => true
+ ];
+
+ foreach ($options as $key => $value) {
+ if (\is_array($value)) {
+ // Allow nested options.
+ foreach ($value as $key2 => $value2) {
+ $ckey = "{$key}.{$key2}";
+ if (isset($value2, $allowedOptions[$ckey])) {
+ $this->setOption($ckey, $value2);
+ }
+ }
+ } elseif (isset($value, $allowedOptions[$key])) {
+ $this->setOption($key, $value);
+ }
+ }
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function start($readonly = false)
+ {
+ if (\PHP_SAPI === 'cli') {
+ return $this;
+ }
+
+ $sessionName = session_name();
+ $sessionExists = isset($_COOKIE[$sessionName]);
+
+ // Protection against invalid session cookie names throwing exception: http://php.net/manual/en/function.session-id.php#116836
+ if ($sessionExists && !preg_match('/^[-,a-zA-Z0-9]{1,128}$/', $_COOKIE[$sessionName])) {
+ unset($_COOKIE[$sessionName]);
+ $sessionExists = false;
+ }
+
+ $options = $this->options;
+ if ($readonly) {
+ $options['read_and_close'] = '1';
+ }
+
+ $success = @session_start($options);
+ $user = $success ? $this->__get('user') : null;
+ if (!$success) {
+ $last = error_get_last();
+ $error = $last ? $last['message'] : 'Unknown error';
+
+ throw new SessionException('Failed to start session: ' . $error, 500);
+ }
+
+ $this->started = true;
+
+ if ($user && (!$user instanceof UserInterface || !$user->isValid())) {
+ $this->invalidate();
+
+ throw new SessionException('Invalid User object, session destroyed.', 500);
+ }
+
+ // Extend the lifetime of the session.
+ if ($sessionExists) {
+ $params = session_get_cookie_params();
+
+ setcookie(
+ $sessionName,
+ session_id(),
+ time() + $params['lifetime'],
+ $params['path'],
+ $params['domain'],
+ $params['secure'],
+ $params['httponly']
+ );
+ }
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function invalidate()
+ {
+ $params = session_get_cookie_params();
+ setcookie(
+ session_name(),
+ '',
+ time() - 42000,
+ $params['path'],
+ $params['domain'],
+ $params['secure'],
+ $params['httponly']
+ );
+
+ if ($this->isSessionStarted()) {
+ session_unset();
+ session_destroy();
+ }
+
+ $this->started = false;
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function close()
+ {
+ if ($this->started) {
+ session_write_close();
+ }
+
+ $this->started = false;
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function clear()
+ {
+ session_unset();
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getAll()
+ {
+ return $_SESSION;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getIterator()
+ {
+ return new \ArrayIterator($_SESSION);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function isStarted()
+ {
+ return $this->started;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function __isset($name)
+ {
+ return isset($_SESSION[$name]);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function __get($name)
+ {
+ return $_SESSION[$name] ?? null;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function __set($name, $value)
+ {
+ $_SESSION[$name] = $value;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function __unset($name)
+ {
+ unset($_SESSION[$name]);
+ }
+
+ /**
+ * http://php.net/manual/en/function.session-status.php#113468
+ * Check if session is started nicely.
+ * @return bool
+ */
+ protected function isSessionStarted()
+ {
+ return \PHP_SAPI !== 'cli' ? \PHP_SESSION_ACTIVE === session_status() : false;
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ */
+ protected function setOption($key, $value)
+ {
+ if (!\is_string($value)) {
+ if (\is_bool($value)) {
+ $value = $value ? '1' : '0';
+ } else {
+ $value = (string)$value;
+ }
+ }
+
+ $this->options[$key] = $value;
+ ini_set("session.{$key}", $value);
+ }
+}
diff --git a/system/src/Grav/Framework/Session/SessionInterface.php b/system/src/Grav/Framework/Session/SessionInterface.php
new file mode 100644
index 0000000..75df0e9
--- /dev/null
+++ b/system/src/Grav/Framework/Session/SessionInterface.php
@@ -0,0 +1,148 @@
+initParts($parts);
+ }
+
+ /**
+ * @return string
+ */
+ public function getUser()
+ {
+ return parent::getUser();
+ }
+
+ /**
+ * @return string
+ */
+ public function getPassword()
+ {
+ return parent::getPassword();
+ }
+
+ /**
+ * @return array
+ */
+ public function getParts()
+ {
+ return parent::getParts();
+ }
+
+ /**
+ * @return string
+ */
+ public function getUrl()
+ {
+ return parent::getUrl();
+ }
+
+ /**
+ * @return string
+ */
+ public function getBaseUrl()
+ {
+ return parent::getBaseUrl();
+ }
+
+ /**
+ * @param string $key
+ * @return string|null
+ */
+ public function getQueryParam($key)
+ {
+ $queryParams = $this->getQueryParams();
+
+ return $queryParams[$key] ?? null;
+ }
+
+ /**
+ * @param string $key
+ * @return UriInterface
+ */
+ public function withoutQueryParam($key)
+ {
+ return GuzzleUri::withoutQueryValue($this, $key);
+ }
+
+ /**
+ * @param string $key
+ * @param string|null $value
+ * @return UriInterface
+ */
+ public function withQueryParam($key, $value)
+ {
+ return GuzzleUri::withQueryValue($this, $key, $value);
+ }
+
+ /**
+ * @return array
+ */
+ public function getQueryParams()
+ {
+ if ($this->queryParams === null) {
+ $this->queryParams = UriFactory::parseQuery($this->getQuery());
+ }
+
+ return $this->queryParams;
+ }
+
+ /**
+ * @param array $params
+ * @return UriInterface
+ */
+ public function withQueryParams(array $params)
+ {
+ $query = UriFactory::buildQuery($params);
+
+ return $this->withQuery($query);
+ }
+
+ /**
+ * Whether the URI has the default port of the current scheme.
+ *
+ * `$uri->getPort()` may return the standard port. This method can be used for some non-http/https Uri.
+ *
+ * @return bool
+ */
+ public function isDefaultPort()
+ {
+ return $this->getPort() === null || GuzzleUri::isDefaultPort($this);
+ }
+
+ /**
+ * Whether the URI is absolute, i.e. it has a scheme.
+ *
+ * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true
+ * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative
+ * to another URI, the base URI. Relative references can be divided into several forms:
+ * - network-path references, e.g. '//example.com/path'
+ * - absolute-path references, e.g. '/path'
+ * - relative-path references, e.g. 'subpath'
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4
+ */
+ public function isAbsolute()
+ {
+ return GuzzleUri::isAbsolute($this);
+ }
+
+ /**
+ * Whether the URI is a network-path reference.
+ *
+ * A relative reference that begins with two slash characters is termed an network-path reference.
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.2
+ */
+ public function isNetworkPathReference()
+ {
+ return GuzzleUri::isNetworkPathReference($this);
+ }
+
+ /**
+ * Whether the URI is a absolute-path reference.
+ *
+ * A relative reference that begins with a single slash character is termed an absolute-path reference.
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.2
+ */
+ public function isAbsolutePathReference()
+ {
+ return GuzzleUri::isAbsolutePathReference($this);
+ }
+
+ /**
+ * Whether the URI is a relative-path reference.
+ *
+ * A relative reference that does not begin with a slash character is termed a relative-path reference.
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.2
+ */
+ public function isRelativePathReference()
+ {
+ return GuzzleUri::isRelativePathReference($this);
+ }
+
+ /**
+ * Whether the URI is a same-document reference.
+ *
+ * A same-document reference refers to a URI that is, aside from its fragment
+ * component, identical to the base URI. When no base URI is given, only an empty
+ * URI reference (apart from its fragment) is considered a same-document reference.
+ *
+ * @param UriInterface|null $base An optional base URI to compare against
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.4
+ */
+ public function isSameDocumentReference(UriInterface $base = null)
+ {
+ return GuzzleUri::isSameDocumentReference($this, $base);
+ }
+}
diff --git a/system/src/Grav/Framework/Uri/UriFactory.php b/system/src/Grav/Framework/Uri/UriFactory.php
new file mode 100644
index 0000000..e5cb1d3
--- /dev/null
+++ b/system/src/Grav/Framework/Uri/UriFactory.php
@@ -0,0 +1,166 @@
+ $scheme,
+ 'user' => $user,
+ 'pass' => $pass,
+ 'host' => $host,
+ 'port' => $port,
+ 'path' => $path,
+ 'query' => $query
+ ];
+ }
+
+ /**
+ * UTF-8 aware parse_url() implementation.
+ *
+ * @param string $url
+ * @return array
+ * @throws \InvalidArgumentException
+ */
+ public static function parseUrl($url)
+ {
+ if (!\is_string($url)) {
+ throw new \InvalidArgumentException('URL must be a string');
+ }
+
+ $encodedUrl = preg_replace_callback(
+ '%[^:/@?&=#]+%u',
+ function ($matches) { return rawurlencode($matches[0]); },
+ $url
+ );
+
+ $parts = \is_string($encodedUrl) ? parse_url($encodedUrl) : false;
+ if ($parts === false) {
+ throw new \InvalidArgumentException("Malformed URL: {$url}");
+ }
+
+ return $parts;
+ }
+
+ /**
+ * Parse query string and return it as an array.
+ *
+ * @param string $query
+ * @return mixed
+ */
+ public static function parseQuery($query)
+ {
+ parse_str($query, $params);
+
+ return $params;
+ }
+
+ /**
+ * Build query string from variables.
+ *
+ * @param array $params
+ * @return string
+ */
+ public static function buildQuery(array $params)
+ {
+ if (!$params) {
+ return '';
+ }
+
+ $separator = ini_get('arg_separator.output') ?: '&';
+
+ return http_build_query($params, '', $separator, PHP_QUERY_RFC3986);
+ }
+}
diff --git a/system/src/Grav/Framework/Uri/UriPartsFilter.php b/system/src/Grav/Framework/Uri/UriPartsFilter.php
new file mode 100644
index 0000000..51a971a
--- /dev/null
+++ b/system/src/Grav/Framework/Uri/UriPartsFilter.php
@@ -0,0 +1,141 @@
+= 0 && $port <= 65535))) {
+ return $port;
+ }
+
+ throw new \InvalidArgumentException('Uri port must be null or an integer between 0 and 65535');
+ }
+
+ /**
+ * Filter Uri path.
+ *
+ * This method percent-encodes all reserved characters in the provided path string. This method
+ * will NOT double-encode characters that are already percent-encoded.
+ *
+ * @param string $path The raw uri path.
+ * @return string The RFC 3986 percent-encoded uri path.
+ * @throws \InvalidArgumentException If the path is invalid.
+ * @link http://www.faqs.org/rfcs/rfc3986.html
+ */
+ public static function filterPath($path)
+ {
+ if (!\is_string($path)) {
+ throw new \InvalidArgumentException('Uri path must be a string');
+ }
+
+ return preg_replace_callback(
+ '/(?:[^a-zA-Z0-9_\-\.~:@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/u',
+ function ($match) {
+ return rawurlencode($match[0]);
+ },
+ $path
+ ) ?? '';
+ }
+
+ /**
+ * Filters the query string or fragment of a URI.
+ *
+ * @param string $query The raw uri query string.
+ * @return string The percent-encoded query string.
+ * @throws \InvalidArgumentException If the query is invalid.
+ */
+ public static function filterQueryOrFragment($query)
+ {
+ if (!\is_string($query)) {
+ throw new \InvalidArgumentException('Uri query string and fragment must be a string');
+ }
+
+ return preg_replace_callback(
+ '/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/u',
+ function ($match) {
+ return rawurlencode($match[0]);
+ },
+ $query
+ ) ?? '';
+ }
+}
diff --git a/system/src/Grav/Installer/Install.php b/system/src/Grav/Installer/Install.php
new file mode 100644
index 0000000..5345ce3
--- /dev/null
+++ b/system/src/Grav/Installer/Install.php
@@ -0,0 +1,287 @@
+ [
+ 'name' => 'PHP',
+ 'versions' => [
+ '7.3' => '7.3.1',
+ '7.2' => '7.2.0',
+ '7.1' => '7.1.3',
+ '' => '7.2.14'
+ ]
+ ],
+ 'grav' => [
+ 'name' => 'Grav',
+ 'versions' => [
+ '1.5' => '1.5.0',
+ '' => '1.5.7'
+ ]
+ ],
+ 'plugins' => [
+ 'admin' => [
+ 'name' => 'Admin',
+ 'optional' => true,
+ 'versions' => [
+ '1.8' => '1.8.0',
+ '' => '1.8.16'
+ ]
+ ],
+ 'email' => [
+ 'name' => 'Email',
+ 'optional' => true,
+ 'versions' => [
+ '2.7' => '2.7.0',
+ '' => '2.7.2'
+ ]
+ ],
+ 'form' => [
+ 'name' => 'Form',
+ 'optional' => true,
+ 'versions' => [
+ '2.16' => '2.16.0',
+ '' => '2.16.4'
+ ]
+ ],
+ 'login' => [
+ 'name' => 'Login',
+ 'optional' => true,
+ 'versions' => [
+ '2.8' => '2.8.0',
+ '' => '2.8.3'
+ ]
+ ],
+ ]
+ ];
+
+ private $ignores = [
+ 'backup',
+ 'cache',
+ 'images',
+ 'logs',
+ 'tmp',
+ 'user',
+ '.htaccess',
+ 'robots.txt'
+ ];
+
+ private $classMap = [
+ // 'Grav\\Installer\\Test' => __DIR__ . '/Test.php',
+ ];
+
+ private $zip;
+ private $location;
+
+ private static $instance;
+
+ public static function instance()
+ {
+ if (null === self::$instance) {
+ self::$instance = new static();
+ }
+
+ return self::$instance;
+ }
+
+ private function __construct()
+ {
+ }
+
+ public function setZip(string $zip)
+ {
+ $this->zip = $zip;
+
+ return $this;
+ }
+
+ public function __invoke(?string $zip)
+ {
+ $this->zip = $zip;
+
+ $failedRequirements = $this->checkRequirements();
+ if ($failedRequirements) {
+ $error = ['Following requirements have failed:'];
+
+ foreach ($failedRequirements as $name => $req) {
+ $error[] = "{$req['title']} >= v{$req['minimum']} required, you have v{$req['installed']} ";
+ }
+
+ throw new \RuntimeException(implode(" \n", $error));
+ }
+
+ $this->prepare();
+ $this->install();
+ $this->finalize();
+ }
+
+ /**
+ * NOTE: This method can only be called after $grav['plugins']->init().
+ *
+ * @return array List of failed requirements. If the list is empty, installation can go on.
+ */
+ public function checkRequirements(): array
+ {
+ $results = [];
+
+ $this->checkVersion($results, 'php','php', $this->requires['php'], PHP_VERSION);
+ $this->checkVersion($results, 'grav', 'grav', $this->requires['grav'], GRAV_VERSION);
+ $this->checkPlugins($results, $this->requires['plugins']);
+
+ return $results;
+ }
+
+ /**
+ * @throws \RuntimeException
+ */
+ public function prepare(): void
+ {
+ // Locate the new Grav update and the target site from the filesystem.
+ $location = dirname(realpath(__DIR__), 4);
+ $target = dirname(realpath(GRAV_ROOT . '/index.php'));
+ if ($location === $target) {
+ // We cannot copy files into themselves, abort!
+ throw new \RuntimeException('Grav has already been installed here!', 400);
+ }
+
+ // Make sure that none of the Grav\Installer classes have been loaded, otherwise installation may fail!
+ foreach ($this->classMap as $class_name => $path) {
+ if (\class_exists($class_name, false)) {
+ throw new \RuntimeException(sprintf('Cannot update Grav, class %s has already been loaded!', $class_name), 500);
+ }
+ }
+
+ $grav = Grav::instance();
+
+ /** @var ClassLoader $loader */
+ $loader = $grav['loader'];
+
+ // Override Grav\Installer classes by using this version of Grav.
+ $loader->addClassMap($this->classMap);
+
+ $this->location = $location;
+ }
+
+ /**
+ * @throws \RuntimeException
+ */
+ public function install(): void
+ {
+ if (!$this->location) {
+ throw new \RuntimeException('Oops, installer was run without prepare()!', 500);
+ }
+
+ try {
+ Installer::install(
+ $this->zip,
+ GRAV_ROOT,
+ ['sophisticated' => true, 'overwrite' => true, 'ignore_symlinks' => true, 'ignores' => $this->ignores],
+ $this->location,
+ !($this->zip && is_file($this->zip))
+ );
+ } catch (\Exception $e) {
+ Installer::setError($e->getMessage());
+ }
+
+ $errorCode = Installer::lastErrorCode();
+
+ $success = !(is_string($errorCode) || ($errorCode & (Installer::ZIP_OPEN_ERROR | Installer::ZIP_EXTRACT_ERROR)));
+
+ if (!$success) {
+ throw new \RuntimeException(Installer::lastErrorMsg());
+ }
+ }
+
+ /**
+ * @throws \RuntimeException
+ */
+ public function finalize(): void
+ {
+ Cache::clearCache();
+
+ clearstatcache();
+ if (function_exists('opcache_reset')) {
+ @opcache_reset();
+ }
+ }
+
+ protected function checkVersion(array &$results, $type, $name, array $check, $version): void
+ {
+ if (null === $version && !empty($check['optional'])) {
+ return;
+ }
+
+ $major = $minor = 0;
+ $versions = $check['versions'] ?? [];
+ foreach ($versions as $major => $minor) {
+ if (!$major || version_compare($version, $major, '<')) {
+ continue;
+ }
+
+ if (version_compare($version, $minor, '>=')) {
+ return;
+ }
+
+ break;
+ }
+
+ if (!$major) {
+ $minor = reset($versions);
+ }
+
+ $recommended = end($versions);
+
+ if (version_compare($recommended, $minor, '<=')) {
+ $recommended = null;
+ }
+
+ $results[$name] = [
+ 'type' => $type,
+ 'name' => $name,
+ 'title' => $check['name'] ?? $name,
+ 'installed' => $version,
+ 'minimum' => $minor,
+ 'recommended' => $recommended
+ ];
+ }
+
+ protected function checkPlugins(array &$results, array $plugins): void
+ {
+ if (!\class_exists('Plugins')) {
+ return;
+ }
+
+ foreach ($plugins as $name => $check) {
+ $plugin = Plugins::get($name);
+ if (!$plugin) {
+ $this->checkVersion($results, 'plugin', $name, $check, null);
+ continue;
+ }
+
+ $blueprint = $plugin->blueprints();
+ $version = (string)$blueprint->get('version');
+ $check['name'] = ($blueprint->get('name') ?? $check['name'] ?? $name) . ' Plugin';
+ $this->checkVersion($results, 'plugin', $name, $check, $version);
+ }
+ }
+}
\ No newline at end of file
diff --git a/system/templates/partials/messages.html.twig b/system/templates/partials/messages.html.twig
new file mode 100644
index 0000000..261b3fc
--- /dev/null
+++ b/system/templates/partials/messages.html.twig
@@ -0,0 +1,14 @@
+{% set status_mapping = {'info':'green', 'error': 'red', 'warning': 'yellow'} %}
+
+{% if grav.messages.all %}
+
+ {% for message in grav.messages.fetch %}
+
+ {% set scope = message.scope|e %}
+ {% set color = status_mapping[scope] %}
+
+
{{ message.message|raw }}
+
+ {% endfor %}
+
+{% endif %}
diff --git a/system/templates/partials/metadata.html.twig b/system/templates/partials/metadata.html.twig
new file mode 100644
index 0000000..bf323e7
--- /dev/null
+++ b/system/templates/partials/metadata.html.twig
@@ -0,0 +1,3 @@
+{% for meta in page.metadata %}
+
+{% endfor %}
\ No newline at end of file
diff --git a/tmp/.gitkeep b/tmp/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/user/accounts/.gitkeep b/user/accounts/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/user/config/site.yaml b/user/config/site.yaml
new file mode 100644
index 0000000..4be78ed
--- /dev/null
+++ b/user/config/site.yaml
@@ -0,0 +1,7 @@
+title: Grav
+author:
+ name: Joe Bloggs
+ email: 'joe@example.com'
+metadata:
+ description: 'Grav is an easy to use, yet powerful, open source flat-file CMS'
+
diff --git a/user/config/system.yaml b/user/config/system.yaml
new file mode 100644
index 0000000..99a627e
--- /dev/null
+++ b/user/config/system.yaml
@@ -0,0 +1,45 @@
+absolute_urls: false
+
+home:
+ alias: '/home'
+
+pages:
+ theme: quark
+ markdown:
+ extra: false
+ process:
+ markdown: true
+ twig: false
+
+cache:
+ enabled: true
+ check:
+ method: file
+ driver: auto
+ prefix: 'g'
+
+twig:
+ cache: true
+ debug: true
+ auto_reload: true
+ autoescape: false
+
+assets:
+ css_pipeline: false
+ css_minify: true
+ css_rewrite: true
+ js_pipeline: false
+ js_minify: true
+
+errors:
+ display: true
+ log: true
+
+debugger:
+ enabled: false
+ twig: true
+ shutdown:
+ close_connection: true
+gpm:
+ releases: stable
+ verify_peer: true
diff --git a/user/data/.gitkeep b/user/data/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/user/pages/01.home/default.md b/user/pages/01.home/default.md
new file mode 100644
index 0000000..13b2376
--- /dev/null
+++ b/user/pages/01.home/default.md
@@ -0,0 +1,42 @@
+---
+title: Home
+body_classes: title-center title-h1h2
+---
+
+# Say Hello to Grav!
+## installation successful...
+
+Congratulations! You have installed the **Base Grav Package** that provides a **simple page** and the default **Quark** theme to get you started.
+
+!! If you see a **404 Error** when you click `Typography` in the menu, please refer to the [troubleshooting guide](http://learn.getgrav.org/troubleshooting/page-not-found).
+
+### Find out all about Grav
+
+* Learn about **Grav** by checking out our dedicated [Learn Grav](http://learn.getgrav.org) site.
+* Download **plugins**, **themes**, as well as other Grav **skeleton** packages from the [Grav Downloads](http://getgrav.org/downloads) page.
+* Check out our [Grav Development Blog](http://getgrav.org/blog) to find out the latest goings on in the Grav-verse.
+
+!!! If you want a more **full-featured** base install, you should check out [**Skeleton** packages available in the downloads](http://getgrav.org/downloads).
+
+### Edit this Page
+
+To edit this page, simply navigate to the folder you installed **Grav** into, and then browse to the `user/pages/01.home` folder and open the `default.md` file in your [editor of choice](http://learn.getgrav.org/basics/requirements). You will see the content of this page in [Markdown format](http://learn.getgrav.org/content/markdown).
+
+### Create a New Page
+
+Creating a new page is a simple affair in **Grav**. Simply follow these simple steps:
+
+1. Navigate to your pages folder: `user/pages/` and create a new folder. In this example, we will use [explicit default ordering](http://learn.getgrav.org/content/content-pages) and call the folder `03.mypage`.
+2. Launch your text editor and paste in the following sample code:
+
+ ---
+ title: My New Page
+ ---
+ # My New Page!
+
+ This is the body of **my new page** and I can easily use _Markdown_ syntax here.
+
+3. Save this file in the `user/pages/03.mypage/` folder as `default.md`. This will tell **Grav** to render the page using the **default** template.
+4. That is it! Reload your browser to see your new page in the menu.
+
+! NOTE: The page will automatically show up in the Menu after the "Typography" menu item. If you wish to change the name that shows up in the Menu, simple add: `menu: My Page` between the dashes in the page content. This is called the YAML front matter, and it is where you configure page-specific options.
diff --git a/user/pages/02.typography/default.md b/user/pages/02.typography/default.md
new file mode 100644
index 0000000..d3aa848
--- /dev/null
+++ b/user/pages/02.typography/default.md
@@ -0,0 +1,155 @@
+---
+title: Typography
+---
+
+! Details on the full capabilities of Spectre.css can be found in the [Official Spectre Documentation](https://picturepan2.github.io/spectre/elements.html)
+
+The [Quark theme](https://github.com/getgrav/grav-theme-quark) is the new default theme for Grav built with [Spectre.css](https://picturepan2.github.io/spectre/) the lightweight, responsive and modern CSS framework. Spectre provides basic styles for typography, elements, and a responsive layout system that utilizes best practices and consistent language design.
+
+### Headings
+
+# H1 Heading `40px`
+
+## H2 Heading `32px`
+
+### H3 Heading `28px`
+
+#### H4 Heading `24px`
+
+##### H5 Heading `20px`
+
+###### H6 Heading `16px`
+
+```html
+# H1 Heading
+# H1 Heading `40px``
+
+H1 Heading
+```
+
+### Paragraphs
+
+Lorem ipsum dolor sit amet, consectetur [adipiscing elit. Praesent risus leo, dictum in vehicula sit amet](#), feugiat tempus tellus. Duis quis sodales risus. Etiam euismod ornare consequat.
+
+Climb leg rub face on everything give attitude nap all day for under the bed. Chase mice attack feet but rub face on everything hopped up on goofballs.
+
+### Markdown Semantic Text Elements
+
+**Bold** `**Bold**`
+
+_Italic_ `_Italic_`
+
+~~Deleted~~ `~~Deleted~~`
+
+`Inline Code` `` `Inline Code` ``
+
+### HTML Semantic Text Elements
+
+I18N ``
+
+Citation ``
+
+Ctrl + S ``
+
+TextSuperscripted ``
+
+TextSubscripted ``
+
+Underlined ``
+
+Highlighted ``
+
+20:14 ``
+
+x = y + 2 ``
+
+### Blockquote
+
+> The advance of technology is based on making it fit in so that you don't really even notice it,
+> so it's part of everyday life.
+>
+> - Bill Gates
+
+```markdown
+> The advance of technology is based on making it fit in so that you don't really even notice it,
+> so it's part of everyday life.
+>
+> - Bill Gates
+```
+
+### Unordered List
+
+* list item 1
+* list item 2
+ * list item 2.1
+ * list item 2.2
+ * list item 2.3
+* list item 3
+
+```markdown
+* list item 1
+* list item 2
+ * list item 2.1
+ * list item 2.2
+ * list item 2.3
+* list item 3
+```
+
+### Ordered List
+
+1. list item 1
+1. list item 2
+ 1. list item 2.1
+ 1. list item 2.2
+ 1. list item 2.3
+1. list item 3
+
+```markdown
+1. list item 1
+1. list item 2
+ 1. list item 2.1
+ 1. list item 2.2
+ 1. list item 2.3
+1. list item 3
+```
+
+### Table
+
+| Name | Genre | Release date |
+| :-------------------------- | :---------------------------: | -------------------: |
+| The Shawshank Redemption | Crime, Drama | 14 October 1994 |
+| The Godfather | Crime, Drama | 24 March 1972 |
+| Schindler's List | Biography, Drama, History | 4 February 1994 |
+| Se7en | Crime, Drama, Mystery | 22 September 1995 |
+
+```markdown
+| Name | Genre | Release date |
+| :-------------------------- | :---------------------------: | -------------------: |
+| The Shawshank Redemption | Crime, Drama | 14 October 1994 |
+| The Godfather | Crime, Drama | 24 March 1972 |
+| Schindler's List | Biography, Drama, History | 4 February 1994 |
+| Se7en | Crime, Drama, Mystery | 22 September 1995 |
+```
+
+### Notices
+
+The notices styles are actually provided by the `markdown-notices` plugin but are useful enough to include here:
+
+! This is a warning notification
+
+!! This is a error notification
+
+!!! This is a default notification
+
+!!!! This is a success notification
+
+```markdown
+! This is a warning notification
+
+!! This is a error notification
+
+!!! This is a default notification
+
+!!!! This is a success notification
+```
+
diff --git a/user/plugins/.gitkeep b/user/plugins/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/user/plugins/admin/.gitattributes b/user/plugins/admin/.gitattributes
new file mode 100644
index 0000000..e3cf70c
--- /dev/null
+++ b/user/plugins/admin/.gitattributes
@@ -0,0 +1,8 @@
+# Linguist Normalizer
+*.yaml linguistic-language=PHP
+*.twig linguistic-language=PHP
+**/gulpfile.js linguist-vendored
+**/webpack.conf.js linguist-vendored
+**/js/*.js linguist-vendored
+**/js/*.json linguist-vendored
+**/css-compiled/*.css linguist-vendored
diff --git a/user/plugins/admin/.github/FUNDING.yml b/user/plugins/admin/.github/FUNDING.yml
new file mode 100644
index 0000000..e84f52b
--- /dev/null
+++ b/user/plugins/admin/.github/FUNDING.yml
@@ -0,0 +1,8 @@
+# These are supported funding model platforms
+
+github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
+patreon: # Replace with a single Patreon username
+open_collective: grav
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+custom: # Replace with a single custom sponsorship URL
diff --git a/user/plugins/admin/CHANGELOG.md b/user/plugins/admin/CHANGELOG.md
new file mode 100644
index 0000000..be51e65
--- /dev/null
+++ b/user/plugins/admin/CHANGELOG.md
@@ -0,0 +1,1775 @@
+# v1.9.17
+## 10/07/2020
+
+1. [](#new)
+ * Support premium themes
+ * Back-ported functionality from Admin 1.10 required for upcoming WYSIWYM Nextgen Editor
+1. [](#improved)
+ * Improved some error messages for better readability
+1. [](#bugfix)
+ * Fixed issue that would force a page reload when failing to install/update a plugin or theme
+ * Fixed proxy/browser caching issues in admin pages
+
+# v1.9.16
+## 09/01/2020
+
+1. [](#bugfix)
+ * Fixed a glitch which allows user to delete entire pages directory [#1941](https://github.com/getgrav/grav-plugin-admin/issues/1941)
+ * Fixed the hidden login plugin toggle
+
+# v1.9.15
+## 06/08/2020
+
+1. [](#bugfix)
+ * Support markdown in `fieldset.text` [#2934](https://github.com/getgrav/grav/issues/2934)
+ * Fix data URLs in avatar images [#1889](https://github.com/getgrav/grav/issues/1889)
+ * Fix for deleting files in plugin configurations
+
+# v1.9.14
+## 04/27/2020
+
+1. [](#improved)
+ * Added `slug` and `type` to blueprints
+1. [](#bugfix)
+ * Support markdown in `fieldset.text` [#2934](https://github.com/getgrav/grav/issues/2934)
+
+# v1.9.13
+## 03/05/2020
+
+1. [](#improved)
+ * Updated vendor libs
+1. [](#bugfix)
+ * Fixed toggleable buttons no longer holding false state [form#406](ttps://github.com/getgrav/grav-plugin-form/issues/406)
+
+# v1.9.12
+## 12/04/2019
+
+1. [](#bugfix)
+ * Fixed saving configuration in PHP 7.4
+
+# v1.9.11
+## 11/06/2019
+
+1. [](#improved)
+ * Added new "secure delete" functionality [#1752](https://github.com/getgrav/grav-plugin-admin/issues/1752)
+ * Center text logo [#1751](https://github.com/getgrav/grav-plugin-admin/issues/1751)
+ * Added required span to editor field [#1748](https://github.com/getgrav/grav-plugin-admin/issues/1748)
+ * Warn users if JS is disabled [#1722](https://github.com/getgrav/grav-plugin-admin/issues/1722)
+ * Added target rule to quick links [#1518](https://github.com/getgrav/grav-plugin-admin/issues/1518)
+1. [](#bugfix)
+ * Fixed `Badly encoded JSON data` warning when uploading files [grav#2663](https://github.com/getgrav/grav/issues/2663)
+ * Fixed `accept` for SVG in `file` uploaders [#1732](https://github.com/getgrav/grav-plugin-admin/issues/1732)
+
+# v1.9.10
+## 09/19/2019
+
+1. [](#bugfix)
+ * Fixed `Badly encoded JSON data` warning when uploading files [grav#2663](https://github.com/getgrav/grav/issues/2663)
+
+# v1.9.9
+## 08/21/2019
+
+1. [](#bugfix)
+ * Fixed regression with files in admin not allowing types other than images [#1737](https://github.com/getgrav/grav-plugin-admin/issues/1737)
+ * Fixed preview link for non-images files in **Page Media** [#1727](https://github.com/getgrav/grav-plugin-admin/issues/1727)
+
+# v1.9.8
+## 08/11/2019
+
+1. [](#improved)
+ * Better support for `array` field into `list` field
+ * Attach `_list_index` to fields within list items so that the index/key is available
+1. [](#bugfix)
+ * Fixed 2FA regenerate for Flex Users
+ * Added missing closing in language loops
+ * Fixed issue with nested `list` fields both utilizing the custom `key` functionality
+ * Fixed issue with `array` field nested in `list` that were losing their index order when the list reordered
+ * Fixed file form field failing resolution checks in certain circumstances
+ * Fixed issue with deleting files in config based YAML files
+
+# v1.9.7
+## 06/21/2019
+
+1. [](#bugfix)
+ * Fixed issue with charts in dashboard where label would cut off [#1700](https://github.com/getgrav/grav-plugin-admin/issues/1700)
+ * Resetting a user's password clears the user's site access [grav#2528](https://github.com/getgrav/grav/issues/2528)
+ * Fixed issue with permissions toggle [#1702](https://github.com/getgrav/grav-plugin-admin/issues/1702)
+
+# v1.9.6
+## 06/15/2019
+
+1. [](#bugfix)
+ * Fixed regression issue with `parents_levels` defaulting to `2`
+
+# v1.9.5
+## 06/14/2019
+
+1. [](#improved)
+ * Display error message if GPM class fails to initialize
+ * Better append/prepend logic that was breaking some layouts
+ * Default `backups` to an array if used outside of tools
+ * PSR 7 fixes
+
+# v1.9.4
+## 05/09/2019
+
+1. [](#new)
+ * Added support for `field.copy-to-clipboard` on Text input fields
+1. [](#improved)
+ * Only invalidate cache on creating new/deleting page to speed up the recovery
+ * Updated language strings from https://crowdin.com/project/grav-admin
+ * Use `plugins://` stream rather than `user://plugins` [#1674](https://github.com/getgrav/grav-plugin-admin/issues/1674)
+1. [](#bugfix)
+ * Fixed admin cache to detect moved and deleted pages
+ * Fixed avatar URLs with `?` in them being broken
+ * Fixed issue saving page with language that was not exactly `2` or `5` chars long [#1667](https://github.com/getgrav/grav-plugin-admin/issues/1667)
+ * Fixed admin not detecting any existing users when Flex users are being used
+ * Fixed issue with append/prepend not respecting `size:`
+ * Fixed issue with `unset` on file fields [#1427](https://github.com/getgrav/grav/issues/1427), [#1670](https://github.com/getgrav/grav/issues/1670), [#1982](https://github.com/getgrav/grav/issues/1982)
+
+# v1.9.3
+## 04/22/2019
+
+1. [](#new)
+ * Added a new **YAML Linter** report to the `Tools - Reports` section
+1. [](#improved)
+ * Updated package.json scripts to properly use gulp compiler
+
+# v1.9.2
+## 04/15/2019
+
+1. [](#bugfix)
+ * Fix for homepage admin preview [#2426](https://github.com/getgrav/grav/issues/2426)
+ * Uploaded Avatar removed from user's yaml when editing the user [#1647](https://github.com/getgrav/grav-plugin-admin/issues/1647)
+
+# v1.9.1
+## 04/13/2019
+
+1. [](#bugfix)
+ * Fix for Page saving issues [#1648](https://github.com/getgrav/grav-plugin-admin/issues/1648)
+ * Remove status message when picking folder for move [#1650](https://github.com/getgrav/grav-plugin-admin/issues/1650)
+
+# v1.9.0
+## 04/11/2019
+
+1. [](#new)
+ * New `Scheduler` configuration panel in tools
+ * New `Backups` configuration panel in tools
+ * New `Cache::purge()` option in cache drop-down to clear out old cache only
+ * New `Tools - Reports` section with event `onAdminGenerateReports()` for 3rd party plugin support
+ * Added support for the new `Flex User` object
+ * Allow admin forms to use `Form` classes
+ * Added new `Logs` section to tools to allow quick view of Grav log files
+1. [](#improved)
+ * Improved the UI for the Parent Page Route dropdown when adding a new Page / Folder
+ * Use `$grav['accounts']` instead of `$grav['users']`
+ * Improved image background overlay and tools
+ * Better unauthorized user rendering
+ * Update all Form classes to rely on `PageInterface` instead of `Page` class
+ * Removed `media.upload_limit` references
+ * Improve error when upload exceeds `upload_max_filesize`
+ * Delegate Dropzone for checking maximum file size and avoid uploading if not necessary
+ * Low level unauthorized user handling in `base-root.html.twig`
+ * Refactored "NewsFeeds" and "Notifications" for better performance and to address CORS issues
+ * Flex user profile now uses Flex Form
+ * Moved dashboard `notifications` logic to server-side for increased performance (1 request instead of 3)
+ * Refactored feeds logic for better performance
+ * Better logic for delete action to support Ajax. Fixes Flex lists
+ * Cleanly handle session corruption due to changing Flex object types
+ * Implemented [ForkAwesome](https://forkawesome.github.io/Fork-Awesome/) and removed FontAwesome + LineAwesome
+ * Various default admin theme improvements and cleanup
+ * Make new System Config layout responsive [#1579](https://github.com/getgrav/grav-plugin-admin/issues/1579)
+ * Homepage link should be `https://` [#1564](https://github.com/getgrav/grav-plugin-admin/issues/1564)
+ * Improve lang string to describe XSS security settings [#1566](https://github.com/getgrav/grav-plugin-admin/issues/1566)
+ * Take admin setting for 2FA into account when showing user 2FA badge [#1568](https://github.com/getgrav/grav-plugin-admin/issues/1568)
+ * Moved `ignore` and `key` field into form plugin
+ * Improved usability of `System` configuration blueprint with side-tabs
+ * Cleaned up UI in `Scheduler` tools page
+ * Updated languages
+1. [](#bugfix)
+ * Fixed user edit links if Flex Objects plugin is installed but user isn't Flex User
+ * Fixed deprecated `sameas()` Twig test
+ * Regression: Fixed lost user access when saving user profile without super user permissions [#1639](https://github.com/getgrav/grav-plugin-admin/issues/1639)
+ * Fixed `Page.menu` displaying in edit view rather than `Page.title` [#1642](https://github.com/getgrav/grav-plugin-admin/issues/1642)
+ * Regression from beta.8: Deleting files other than from plugins/themes fail on error
+ * Fixed issue with Safari browser and blueprint fields with `toggleable: true` [#1643](https://github.com/getgrav/grav-plugin-admin/issues/1643)
+ * Incorrect 2FA lang code [#1618](https://github.com/getgrav/grav-plugin-admin/issues/1618)
+ * Fixed potential undefined property in `onPageNotFound` event handling
+ * Proper fix for `vUndefined` when updating plugins/themes
+ * Text in Tab Tools/Direct install disappears [#1613](https://github.com/getgrav/grav-plugin-admin/issues/1613)
+ * Fallback to page `slug` in Pages list if title is empty [grav#2267](https://github.com/getgrav/grav/issues/2267)
+ * Fixes backup button issues with `;` param separator [#1602](https://github.com/getgrav/grav-plugin-admin/issues/1602) [#1502](https://github.com/getgrav/grav-plugin-admin/issues/1502)
+ * Set default state for `show_modular` to `true` [#1599](https://github.com/getgrav/grav-plugin-admin/issues/1599)
+ * Removed `tabs`, `tab`, and `toggle` fields as they are now in Form plugin
+ * Fix issue with new page always showing modular page templates [#1573](https://github.com/getgrav/grav-plugin-admin/issues/1573)
+ * Fixed issue deleting files in plugins/themes/config
+ * Fixed array support in admin languages, e.g. `DAYS_OF_THE_WEEK`
+ * Fixed user login / remember me triggering before admin gets initialized
+ * Fixed a bug when deleting files via AJAX
+ * Fixed error page not to be the frontend version
+ * Added `merge_items` option for `field.selectize` to allow storing custom items [#1461](https://github.com/getgrav/grav-plugin-admin/issues/1461)
+ * Better handling of unset in uploaded files [#1427](https://github.com/getgrav/grav-plugin-admin/issues/1427)
+ * Prefix Backup/Scheduler titles with `Tools`
+ * Regression: Media settings have bad layout [#1529](https://github.com/getgrav/grav-plugin-admin/issues/1529)
+ * Fixed Direct Install Uploader, failing to validate the uploaded files
+ * Regression: Editing interface does not keep settings properly without manual intervention on each edit [#1527](https://github.com/getgrav/grav-plugin-admin/issues/1527)
+ * Removed duplicate language strings
+ * Fixed default `job_at` so it does not fail if missing
+ * Minor JS group `bottom` fix
+
+# v1.8.20
+## 03/20/2019
+
+1. [](#improved)
+ * Added security field to column [#1622](https://github.com/getgrav/grav-plugin-admin/pull/1622)
+
+# v1.8.19
+## 02/13/2019
+
+1. [](#bugfix)
+ * Moved `show_modular` to proper place - Doh! [grav#2362](https://github.com/getgrav/grav/issues/2362)
+
+# v1.8.18
+## 02/12/2019
+
+1. [](#bugfix)
+ * Set default value for `show_modular` [grav#2362](https://github.com/getgrav/grav/issues/2362)
+
+# v1.8.17
+## 02/07/2019
+
+1. [](#improved)
+ * Improved Grav Core installer/updater to run installer script (if available)
+ * Added `unauthorized.html.twig` file that was missing [#1609](https://github.com/getgrav/grav-plugin-admin/pull/1609)
+1. [](#bugfix)
+ * Fixed direct install deleting backups and logs if used with full Grav package instead of with update package
+
+# v1.8.16
+## 01/25/2019
+
+1. [](#improved)
+ * IP pseudonymization for rate limiter [#1589](https://github.com/getgrav/grav-plugin-admin/pull/1589)
+ * Add option to hide modular pages in parent select [#1571](https://github.com/getgrav/grav-plugin-admin/pull/1571)
+ * Added `admin.tools` permission [#1550](https://github.com/getgrav/grav-plugin-admin/pull/1550)
+1. [](#bugfix)
+ * Fixed calendar js module not properly loading for datetime field [#1581](https://github.com/getgrav/grav-plugin-admin/issues/1581)
+ * Fixed deleting file when using file field type [#1558](https://github.com/getgrav/grav-plugin-admin/issues/1558)
+ * Unset state from user if not super or user admin
+
+# v1.8.15
+## 12/14/2018
+
+1. [](#improved)
+ * Fire `onAdminSave()` event during `AdminController::taskSaveAs()` [#1544](https://github.com/getgrav/grav-plugin-admin/issues/1544)
+1. [](#bugfix)
+ * Clean user post to ensure dynamically added form fields are not saved
+
+# v1.8.14
+## 11/12/2018
+
+1. [](#bugfix)
+ * Fixed Grav core update potentially spinning forever because of an error which happens after a successful upgrade
+ * Saving in expert mode can cause `undefined index: header` error [#1537](https://github.com/getgrav/grav-plugin-admin/issues/1537)
+
+# v1.8.13
+## 11/05/2018
+
+1. [](#new)
+ * Added new `|nested()` Twig filter to access array objects with dot notation syntax
+1. [](#bugfix)
+ * Fixed issue with complex lists structure and nested dot-notation [admin#2236](https://github.com/getgrav/grav/issues/2236)
+
+# v1.8.12
+## 10/24/2018
+
+1. [](#improved)
+ * Updated various lang strings
+ * Removed duplicate lang strings
+1. [](#bugfix)
+ * Fix XSS checking when empty content [#1533](https://github.com/getgrav/grav-plugin-admin/issues/1533)
+ * Fix DirectInstall not working [#1535](https://github.com/getgrav/grav-plugin-admin/issues/1535)
+
+# v1.8.11
+## 10/08/2018
+
+1. [](#improved)
+ * Change usage of basename where possible [#1480](https://github.com/getgrav/grav-plugin-admin/pull/1480)
+ * Improved filename validation (requires Grav 1.5.3)
+ * Updated various lang codes
+1. [](#bugfix)
+ * File Uploads: Do not trust mimetype sent by the browser
+ * Fixed file extension detection
+ * Fix for HTML entities in page slug [#1524](https://github.com/getgrav/grav-plugin-admin/issues/1524)
+ * Fix for port in backup download links [#1521](https://github.com/getgrav/grav-plugin-admin/issues/1521)
+
+# v1.8.10
+## 10/01/2018
+
+1. [](#new)
+ * IMPORTANT: Non `admin.super` users are now subject to XSS validation in Page content. Configurable via Configuration / Security
+ * New XSS content warnings and integration into page save
+ * Added new event `onAdminPage()` which allows plugins to customize `Page` object in `$event['page']`
+1. [](#improved)
+ * Use `Url:post()` to get the `$_POST` variable (allows common security checks/filtering for the POST data)
+ * Requires Grav 1.5.2
+1. [](#bugfix)
+ * Fixed redirect to correct URL after failed login
+ * Fixed issue in `filepicker` where missing images would cause a loop to try to load them
+ * Twig 2 compatibility fixes for macros
+ * Updated `composer.json` to better match Grav 1.5
+ * Remove `package-lock.json` as it was referencing an insecure JS package
+
+# v1.8.9
+## 08/23/2018
+
+1. [](#improved)
+ * Make order field to use context, not data
+ * Switched to new Grav Yaml class to support Native + Fallback YAML libraries
+ * Minor fix for `file` thumbnails display
+ * Requires Grav 1.5.1
+
+# v1.8.8
+## 08/17/2018
+
+1. [](#improved)
+ * Support URI Params and Query attributes in Login redirect
+ * Added support for textarea value type in `array` field
+ * Added some new lang strings for Grav 1.5.0
+1. [](#bugfix)
+ * Support params and querystring in login redirect
+ * Added field name nesting with tab field
+
+# v1.8.7
+## 07/31/2018
+
+1. [](#bugfix)
+ * Fix for deleting 'extra' media files [grav#2100](https://githubcom/getgrav/grav/issues/2100)
+
+# v1.8.6
+## 07/13/2018
+
+1. [](#bugfix)
+ * Force `html` for markdown preview [grav#2066](https://github.com/getgrav/grav/issues/2066)
+ * Add missing `authorizeTask()` checks in controller [#1483](https://github.com/getgrav/grav/issues/1483)
+ * Add support for `force_ssl` to admin URLs [#1479](https://github.com/getgrav/grav-plugin-admin/issues/1479)
+
+# v1.8.5
+## 06/20/2018
+
+1. [](#bugfix)
+ * Fixed broken folder attribute on filepicker [#1465](https://github.com/getgrav/grav-plugin-admin/issues/1465)
+ * Added translation for system.session.initialize
+ * Slight updates on new translation strings
+
+# v1.8.4
+## 06/11/2018
+
+1. [](#improved)
+ * Including EXIF JS library in the modules dependencies to fix orientation when uploading images
+1. [](#bugfix)
+ * Initialize session on setup [#1451](https://github.com/getgrav/grav-plugin-admin/issues/1451)
+ * Force a `null` order when empty in the post request
+ * Fixed some 2FA form styling issues
+
+# v1.8.3
+## 05/31/2018
+
+1. [](#new)
+ * Added support for selectize plugins as options in the selectize field
+1. [](#bugfix)
+ * Fixed deep linking in admin after login [#1456](https://github.com/getgrav/grav-plugin-admin/issues/1456)
+ * Fixed Undefined property: `stdClass::$image` in v1.8.2 [#1454](https://github.com/getgrav/grav-plugin-admin/issues/1454)
+ * Pass media order when calling `task:listmedia`
+
+# v1.8.2
+## 05/24/2018
+
+1. [](#new)
+ * Added custom object support for filepicker field
+ * Don't allow saving of a user with no local account file
+ * Controls for `list` field were not in sync between top and bottom
+1. [](#improved)
+ * More subtle `fieldset` styling
+1. [](#bugfix)
+ * Check if `$object->blueprints()` exists in `onAdminAfterSave`
+ * When creating first user, check `admin.login` not `site.login`
+ * Fix admin login redirects for multisite setups
+ * Fixed issue with filepicker field where images wouldn't properly merge with the current value if in a page header
+ * Fixed media delete for streams
+
+# v1.8.1
+## 05/15/2018
+
+1. [](#improved)
+ * use SHA1 hashing of IP addressed to support GDPR rules [#1436](https://github.com/getgrav/grav-plugin-admin/pull/1436)
+1. [](#bugfix)
+ * Fixed 2FA form showing up even if user has not turned on the feature [#1442](https://github.com/getgrav/grav-plugin-admin/issues/1442)
+ * Fixed previews of images in Pagemedia field not properly URI encoded [#1438](https://github.com/getgrav/grav-plugin-admin/issues/1438)
+
+# v1.8.0
+## 05/11/2018
+
+1. [](#new)
+ * Moved 2FA authentication to login plugin
+ * Admin login now uses login plugin events
+ * Added new decoupled `pagemedia` field that is no longer tied to just pages
+ * Updated plugin dependencies (Grav >= 1.4.4, Form >=2.14.0, Login >=2.7.0, Email >=2.7.0)
+1. [](#improved)
+ * Added support for JavaScript `bottom` block [#1425](https://github.com/getgrav/grav-plugin-admin/pull/1425)
+ * Added better typography styling for blockquote and markdown in `display` field
+ * Vendor updates
+1. [](#bugfix)
+ * Added missing MarkdownExtra strings [#1385](https://github.com/getgrav/grav-plugin-admin/pull/1385)
+ * Updated `blueprints.yaml` with missing `step` attribute [#1415](https://github.com/getgrav/grav-plugin-admin/pull/1415)
+ * Fixed preview target setting [#1430](https://github.com/getgrav/grav-plugin-admin/pull/1430)
+ * Added new modular string [#1433](https://github.com/getgrav/grav-plugin-admin/pull/1433)
+ * Fixed Firefox issue with the Regenerate button for 2FA. Forcing the page to reload
+ * Fixed jumpiness behavior for Regenerate button when on active state.
+ * Prevent the prompt for unsaved state when Regenerating a 2FA code and trying to reload/leave the page.
+
+# v1.7.4
+## 04/02/2018
+
+1. [](#bugfix)
+ * Fixed a bug for page copy caused by last release [#1409](https://github.com/getgrav/grav-plugin-admin/pull/1409)
+ * Fixed collapsible `list` option [#1410](https://github.com/getgrav/grav-plugin-admin/pull/1410)
+ * Fixed a minor typo in a label [#1397](https://github.com/getgrav/grav-plugin-admin/pull/1397)
+
+# v1.7.3
+## 04/01/2018
+
+1. [](#new)
+ * Implemented Resize Media and Resolution ('resizeWidth', 'resizeHeight', 'resizeQuality', 'resolution')
+ * Updated Dropzone to latest
+1. [](#bugfix)
+ * Implemented workaround for required text fields [#1390](https://github.com/getgrav/grav-plugin-admin/issues/1390)
+ * Fixed highlight color in Firefox [getgrav/grav#1949](https://github.com/getgrav/grav/issues/1949)
+ * Fix for bad redirect on saving simplesearch (possibly others)
+
+# v1.7.2
+## 03/21/2018
+
+1. [](#improved)
+ * Table CSS improvements for use in 3rd party plugins
+ * Translatable `add_modals` button labels [#1388](https://github.com/getgrav/grav-plugin-admin/issues/1388)
+ * Check for `SHIFT` key on editor save shortcut [#1383](https://github.com/getgrav/grav-plugin-admin/issues/1383)
+ * Fixed User permissions responsive UI [#1379](https://github.com/getgrav/grav-plugin-admin/issues/1379)
+ * Optimization to stop admin for looking for pages in disabled plugins
+ * Added configuration option to choose if you want to use new 'inline' preview or `new tab'
+1. [](#bugfix)
+ * Fix redirect bug when changing admin route to `admin-*`
+ * Changed Twig `|count` to `|length` filter [#1391](https://github.com/getgrav/grav-plugin-admin/issues/1391)
+ * Fix for page preview when `HTTP_REFERRER` is not set [grav#1930](https://github.com/getgrav/grav/issues/1930)
+
+# v1.7.1
+## 03/11/2018
+
+1. [](#new)
+ * New built-in page preview system
+1. [](#improved)
+ * Added `CTRL+K` / `CMD+K` shortcuts for editor links [#1279](https://github.com/getgrav/grav-plugin-admin/issues/1279)
+1. [](#bugfix)
+ * Automatically redirect to new `admin_route` after changing it [#1371](https://github.com/getgrav/grav-plugin-admin/issues/1371)
+ * Remove bad-shadows on alerts
+ * Fixed notifications titles not html escaped [#1272](https://github.com/getgrav/grav-plugin-admin/issues/1272)
+ * Fixed extra horizontal scrollbar with `Editor` field
+ * Fixed `mediapicker` field in lists [#1369](https://github.com/getgrav/grav-plugin-admin/issues/1369)
+
+# v1.7.0
+## 03/09/2018
+
+1. [](#new)
+ * Added styling and lang for **Route Overrides** in the default page blueprint
+ * Added clear cache permanently to quick-tray [#1353](https://github.com/getgrav/grav-plugin-admin/issues/1353)
+1. [](#improved)
+ * Added option to toggle between `line-awesome` and `font-awesome` icon sets [#1334](https://github.com/getgrav/grav-plugin-admin/issues/1334)
+ * Added preview from page list view [#1250](https://github.com/getgrav/grav-plugin-admin/pull/1250)
+ * Added `Add` plugins button to plugins details page [#1352](https://github.com/getgrav/grav-plugin-admin/pull/1352)
+ * Added support for `default` and `options` fields in taxonomy field [#1364](https://github.com/getgrav/grav-plugin-admin/issues/1364)
+ * Added support to limit parent field levels [#1298](https://github.com/getgrav/grav-plugin-admin/issues/1298)
+1. [](#bugfix)
+ * Fixed issue with custom logo text overlapping the sidebar toggle [#1334](https://github.com/getgrav/grav-plugin-admin/issues/1334)
+ * Fixed issues with minimum PHP versions in resource upgrades
+ * Fixed issue with default lang translation in admin [#1361](https://github.com/getgrav/grav-plugin-admin/issues/1361)
+ * Typos in `Tools` -> `Direct Install` page [#1345](https://github.com/getgrav/grav-plugin-admin/issues/1345)
+ * Fixed bug with frontmatter being killed when in `Expert Mode` [#1354](https://github.com/getgrav/grav-plugin-admin/issues/1354)
+
+# v1.7.0-rc.3
+## 02/15/2018
+
+1. [](#improved)
+ * Tab optimization with fixes for 'onpage' tabs
+ * Stopped Chrome from auto-completing admin user profile form [grav#1847](https://github.com/getgrav/grav/issues/1847)
+ * Added a fixed `ga-theme-17x` body class to help styling compatibility
+ * Outputs an iterable field as a string if `yaml: true` or `validate: type: yaml` set in blueprint
+1. [](#bugfix)
+ * Rolled back JS to known working versions [#1323](https://github.com/getgrav/grav-plugin-admin/issues/1323)
+ * Fixed missing translation in order field [#1324](https://github.com/getgrav/grav-plugin-admin/issues/1324)
+ * Fixed UI issue with last drop-down in button group [1325](https://github.com/getgrav/grav-plugin-admin/issues/1325)
+ * Fixed fieldset field outdated rendering [#1313](https://github.com/getgrav/grav-plugin-admin/issues/1313)
+
+# v1.7.0-rc.2
+## 01/24/2018
+
+1. [](#new)
+ * Moved to LineAwesome icons rather than FontAwesome (still compatible w/FA 4.7.0)
+1. [](#improved)
+ * Simplified open/close nav button
+ * Tidied Tools panel and added translations
+ * Tooltip and new icon for site preview
+ * Updated JS library dependencies
+ * Changed CodeMirror editor to use sans-serif font for readability
+1. [](#bugfix)
+ * Fixed z-index issue in fullscreen mode [#1317](https://github.com/getgrav/grav-plugin-admin/issues/1317)
+
+# v1.7.0-rc.1
+## 01/22/2018
+
+1. [](#new)
+ * Added support for markdown in all form fields for `label`, `help`, and `description` when `markdown: true` is set on field
+ * Changed "made by" to Trilby Media from RocketTheme
+1. [](#improved)
+ * Lightened tabs in new theme
+ * Sort languages by key [#1303](https://github.com/getgrav/grav-plugin-admin/issues/1303)
+ * Add limit to Parent Levels [#1298](https://github.com/getgrav/grav-plugin-admin/pull/1298)
+1. [](#bugfix)
+ * Fixed alignment issue with language drop-down
+ * Fixed a z-index issue with fullscreen editor [#1302](https://github.com/getgrav/grav-plugin-admin/issues/1302)
+ * Fixed missing background on register [#1307](https://github.com/getgrav/grav-plugin-admin/issues/1307)
+ * Fixed some style issues with field descriptions
+ * Fixed an issue with `File` field losing download size setting
+ * Fixed distorted thumbnails in `File` field by using `object-fit: cover`
+
+# v1.7.0-beta.1
+## 12/29/2017
+
+1. [](#new)
+ * New lighter-and-tighter admin theme developed
+1. [](#improved)
+ * Added simple value support for list field type
+ * Added checks to automatically hide collapse buttons when there's only single value in list type
+
+# v1.6.7
+## 12/05/2017
+
+1. [](#new)
+ * Logout of admin goes straight to login form with a message (that then fades out)
+ * Added `sl`, `id`, `he`, `eu`, `et` languages
+1. [](#improved)
+ * Added code to use new `GPM::loadRemoteGrav` if it exists in Gav [grav#1746](https://github.com/getgrav/grav/pull/1746)
+ * Add vertical style for order field [#1253](https://github.com/getgrav/grav-plugin-admin/pull/1253)
+ * Added classes to pagemedia field [#1274](https://github.com/getgrav/grav-plugin-admin/issues/1274)
+ * Fixed selectize field not properly updating value when `option` is provided [#1236](https://github.com/getgrav/grav-plugin-admin/pull/1236)
+ * Tab layout tweaks
+ * Updated all language files with latest from [Crowdin](https://crowdin.com/project/grav-admin)
+1. [](#bugfix)
+ * Manual image metadata can now display in pagemedia when auto-generation is disabled [#1275](https://github.com/getgrav/grav-plugin-admin/issues/1275)
+ * Removed broken `home.hide_in_urls` code in `AdminBaseController::save()` that was throwing move errors
+ * Security fix to ensure file uploads are not manipulated mid-post - thnx @FLH!
+
+# v1.6.6
+## 10/27/2017
+
+1. [](#new)
+ * Fixed issue where sortable media in expert mode would reset frontmatter [#1252](https://github.com/getgrav/grav-plugin-admin/issues/1252)
+
+# v1.6.5
+## 10/26/2017
+
+1. [](#new)
+ * Added ability to **order** page media (requires latest Grav update)
+
+# v1.6.4
+## 10/11/2017
+
+1. [](#improved)
+ * Use system PHP size for upload limit rather than `system.media.upload_limit` or `file.filesize` plugin options
+1. [](#bugfix)
+ * Fixed Dropzone timeout to address slow internet connections [#1239](https://github.com/getgrav/grav-plugin-admin/pull/1239)
+
+# v1.6.3
+## 10/02/2017
+
+1. [](#bugfix)
+ * Fixed chart labels not parsing HTML [#1234](https://github.com/getgrav/grav-plugin-admin/issues/1234)
+
+# v1.6.2
+## 09/29/2017
+
+1. [](#improved)
+ * Removed extraneous files in vendor folder for smaller download package
+
+# v1.6.1
+## 09/29/2017
+
+1. [](#improved)
+ * Added support for Latin Extended fonts [#1211](https://github.com/getgrav/grav-plugin-admin/pull/1221)
+ * Added collapsible attribute to lists [#1231](https://github.com/getgrav/grav-plugin-admin/pull/1231)
+1. [](#bugfix)
+ * Fix editor not clickable in list field [#1224](https://github.com/getgrav/grav-plugin-admin/pull/1124)
+ * Updated Google Font URLs to always connect over HTTPS. [#1106](https://github.com/getgrav/grav-plugin-admin/pull/1106)
+ * Fixed fieldset field not allowing to properly save when contained within a list [#1225](https://github.com/getgrav/grav-plugin-admin/issues/1225)
+ * Fixed Video markdown syntax when drag & dropping in the content editor [#1160](https://github.com/getgrav/grav-plugin-admin/issues/1160)
+ * Fixed headers drop-down in editor to properly align
+ * Fixed fields not working in Microsoft Edge with Selectize.js [#1222](https://github.com/getgrav/grav-plugin-admin/pull/1222)
+ * Replaced a left-over "is empty" check [#1232](https://github.com/getgrav/grav-plugin-admin/pull/1232)
+ * Fixed headers drop-down in editor to align properly
+
+
+# v1.6.0
+## 09/07/2017
+
+1. [](#new)
+ * **Added 2-Factor Authentication support to the admin!**
+ * **Added rate-limiting for "failed login attempts" and "forgot password"**
+1. [](#improved)
+ * Revamped the toggle switch CSS so it's more flexible and works better [#1198](https://github.com/getgrav/grav-plugin-admin/issues/1198)
+ * Improved toggle/button alignment on Page edit view
+1. [](#bugfix)
+ * Fixed an issue where icon-picker style was hiding field elements [#1199](https://github.com/getgrav/grav-plugin-admin/issues/1199)
+ * Fixed https -> http redirect issue [#1195](https://github.com/getgrav/grav-plugin-admin/issues/1195)
+ * Also check `/.` for home route [#1191](https://github.com/getgrav/grav-plugin-admin/issues/1191)
+ * Fixed administration being broken in multi-site environments with plugin overrides
+ * Fixed lang-switcher broken in MS Edge browser [#1213](https://github.com/getgrav/grav-plugin-admin/pull/1213)
+ * Added custom `form_id` attribute for modal forms [#1216](https://github.com/getgrav/grav-plugin-admin/issues/1216)
+ * Fixed partially cropped line in Markdown editor for MS Edge/Firefox [#1219](https://github.com/getgrav/grav-plugin-admin/pull/1219)
+ * Downgraded Babel libraries to v6.x for compatibility with webpack [#1218](https://github.com/getgrav/grav-plugin-admin/pull/1218)
+
+# v1.5.2
+## 08/16/2017
+
+1. [](#new)
+ * Added a new icon quick-tray in side navigation that plugins can utilize
+ * Added ability to set and retrieve temporary admin messages
+1. [](#improved)
+ * Allow different field to be used as page label in list of pages [#1122](https://github.com/getgrav/grav-plugin-admin/pull/1122)
+ * Updated `en` language for `cache-control` + `clear_images_by_default` system settings
+ * Allow sorting of page based on custom ordering [#1182](https://github.com/getgrav/grav-plugin-admin/pull/1182)
+ * Search for pages by slug and folder name [#1183](https://github.com/getgrav/grav-plugin-admin/pull/1183)
+ * Allow all page data to be used during `onAdminCreatePageFrontmatter()` event [#1175](https://github.com/getgrav/grav-plugin-admin/pull/1175)
+ * Remove single quotes when slugifying title [#1178](https://github.com/getgrav/grav-plugin-admin/pull/1178)
+1. [](#bugfix)
+ * Ignore missing Twig files [#1169](https://github.com/getgrav/grav-plugin-admin/issues/1169)
+ * If from is already defined, don't override it [#1129](https://github.com/getgrav/grav-plugin-admin/issues/1129)
+ * Fixed SelectUnique field not working with files with spaces
+
+# v1.5.1
+## 07/19/2017
+
+1. [](#bugfix)
+ * Fixes issue when saving pages without a `folder` element [#1163](https://github.com/getgrav/grav-plugin-admin/issues/1163)
+ * Fixed mediapicker field inside lists not properly updating the value on the target input [#1157](https://github.com/getgrav/grav-plugin-admin/issues/1157)
+
+# v1.5.0
+## 07/16/2017
+
+1. [](#new)
+ * Implemented Offline mode. Notifies in the admin when disconnected.
+1. [](#bugfix)
+ * Fixed fetch issue throwing error when request not completed and while unloading the page [#1301](https://github.com/getgrav/grav-plugin-admin/issues/1301)
+ * Fixed ordering when > 100 pages [grav#1564](https://github.com/getgrav/grav/pull/1564)
+ * Fixed Lists issue when reindexing, causing Radio fields to potentially lose their `checked` status ([#1154](https://github.com/getgrav/grav-plugin-admin/issues/1154) | related: [1d55ffc](https://github.com/getgrav/grav-plugin-admin/commit/1d55ffc616125047f245efe9f2180ef2c16b4949))
+
+# v1.5.0-rc.4
+## 07/05/2017
+
+1. [](#new)
+ * New `multilevel` field, useful for defining collections definitions, metadata and other complex YAML data [#1135](https://github.com/getgrav/grav-plugin-admin/pull/1135) - (EXPERIMENTAL)
+ * Fix plugins hooked nav authorize not working with array of permissions [#1148](https://github.com/getgrav/grav-plugin-admin/pull/1148)
+1. [](#improved)
+ * Add badge to plugins hooked into nav [#1147](https://github.com/getgrav/grav-plugin-admin/pull/1147)
+ * Added `field.outerclasses` to default form field [#1124](https://github.com/getgrav/grav-plugin-admin/pull/1124)
+ * Reverted back to textarea/YAML for `media.yaml` image options
+ * Fixed color of textarea fields in admin
+1. [](#bugfix)
+ * Fix for bad referenced to `shouldLoadAdditionalFilesInBackground()` [#1145](https://github.com/getgrav/grav-plugin-admin/pull/1145)
+ * Expose Page Media instance to Grav Admin JS API
+ * Fixed mediapicker issue where newly added list items would not work
+ * Fixed issue with min/max setting of list collections. Removing a list item would not refresh properly the count
+ * If folder is empty/not sent, fallback to page slug [#1146](https://github.com/getgrav/grav-plugin-admin/issues/1146)
+ * Escape the URI basename before using it in Twig
+ * Ignore missing Twig file in the Tools page
+
+# v1.5.0-rc.3
+## 06/22/2017
+
+1. [](#new)
+ * New `Admin::getPageMedia()` static method that can be used in blueprints
+ * Added a new `mediapicker` form field which allows to select a media from any page [#1125](https://github.com/getgrav/grav-plugin-admin/pull/1125)
+ * Added info metadata button for images to view EXIF and other useful details about an image
+1. [](#improved)
+ * Pass original image filename via the `AdminController::taskListedia()` task
+ * Various form styling improvements
+ * Provided an option to control how parent select field displays
+1. [](#bugfix)
+ * Fix referencing DI element when not initialized [#1141](https://github.com/getgrav/grav-plugin-admin/pull/1141)
+
+# v1.5.0-rc.2
+## 05/22/2017
+
+1. [](#improved)
+ * Remove save button and save location notification on Config Info tab [#1116](https://github.com/getgrav/grav-plugin-admin/pull/1116)
+ * Allow taxonomy field to just list one or more specific taxonomies if the `taxonomies` field is filled in the blueprint
+ * `File` field now renders thumbnail previews of the selected value on load
+ * Use new unified `Utils::getPagePathFromToken()` method rather
+1. [](#bugfix)
+ * Fix for undefined `include_metadata` error
+
+
+# v1.5.0-rc.1
+## 05/16/2017
+
+1. [](#new)
+ * Add support for a single array field in forms
+ * Added Prev/Next support on page editing view [#1112](https://github.com/getgrav/grav-plugin-admin/pull/1112)
+1. [](#improved)
+ * Improved full-screen editor for better browser compatibility [#1093](https://github.com/getgrav/grav-plugin-admin/pull/1093)
+ * Added ability to choose how you want the preview button to open [#1096](https://github.com/getgrav/grav-plugin-admin/pull/1096)
+ * `base.html.twig` now extends a `base-root.html.twig` file
+ * Add month+date indication to the stats graph to avoid confusion when there are days without visits
+ * Added `min` and `max` options for `list` form field [#1113](https://github.com/getgrav/grav-plugin-admin/pull/1113)
+ * Remove page metadata file on deletion of media
+ * Improved layout on pages list for pages with long titles [#1102](https://github.com/getgrav/grav-plugin-admin/pull/1102)
+ * Added option to make custom "Add page" dropdown entries [#1104](https://github.com/getgrav/grav-plugin-admin/pull/1104)
+1. [](#bugfix)
+ * Fixed issue with tab widths on Pages overlapping non-english toggle switch [#1089](https://github.com/getgrav/grav-plugin-admin/issues/1089)
+ * Added `vendor` to ignores for direct install of Grav
+ * Translated `field.default` for `editor` form field
+ * Fixed an quote error in `en.yaml`
+ * Resolved z-index issues with mobile nav and pages form elements
+ * Fixed issue with file picker where the selected file preview would not show
+ * Refresh page media on media upload
+ * Default to config file slug if translation is missing, otherwise use translation also in the tab title, not just in the page heading [#1039](https://github.com/getgrav/grav-plugin-admin/issues/1039)
+ * Fix language toggle button in admin top bar visible also in fullscreen mode [#1110](https://github.com/getgrav/grav-plugin-admin/issues/1110)
+ * Fix for editor padding [#1111](https://github.com/getgrav/grav-plugin-admin/issues/1111)
+ * Fix tabs inside blueprint overlapping above content [#1115](https://github.com/getgrav/grav-plugin-admin/pull/1115)
+
+# v1.4.2
+## 04/24/2017
+
+1. [](#new)
+ * Added a new `Content Padding` option to tighten up UI padding space (default `true`)
+1. [](#bugfix)
+ * Added back `Admin::initTheme()` relying on Grav fix [#1069](https://github.com/getgrav/grav-plugin-admin/pull/1069) as it conflicts ith Gantry5
+ * Fix for missing scrollbar when in full-size editor for Firefox [#1077](https://github.com/getgrav/grav-plugin-admin/issues/1077)
+ * Fix for overlay of Add-Page button in full-size editor [#1077](https://github.com/getgrav/grav-plugin-admin/issues/1077)
+ * Better fix for session-based parent overriding root page parents [#1078](https://github.com/getgrav/grav-plugin-admin/issues/1078)
+ * Allow support for `Pages::getList()` with `show_modular` option [#1080](https://github.com/getgrav/grav-plugin-admin/issues/1080)
+ * Added `[tmp,user]` ignores for direct install of Grav [grav#1447](https://github.com/getgrav/grav/issues/1447)
+
+# v1.4.1
+## 04/19/2017
+
+1. [](#bugfix)
+ * Reverted [#1069](https://github.com/getgrav/grav-plugin-admin/pull/1069) as it conflicts ith Gantry5
+
+# v1.4.0
+## 04/19/2017
+
+1. [](#new)
+ * Added ability to add new pages/folders while editing existing page
+1. [](#improved)
+ * Initialize theme in Admin Plugin [#1069](https://github.com/getgrav/grav-plugin-admin/pull/1069)
+ * Use new system configuration entries for username and password format
+ * Reworked Page parent field to use `Pages::getList()` rather than logic in Twig field itself
+ * More robust styling of admin themes page [#1067](https://github.com/getgrav/grav-plugin-admin/pull/1067)
+ * Fix fullscreen editor height [#1065](https://github.com/getgrav/grav-plugin-admin/pull/1065)
+ * Fix small UI issue in the editor with `codemirror.lineNumbers` && `codemirror.styleActiveLine` enabled
+ * Fix UI performance issue in the dashboard [#1064](https://github.com/getgrav/grav-plugin-admin/issues/1064)
+1. [](#bugfix)
+ * Fixed issue with parent not working with custom slug [#1068](https://github.com/getgrav/grav-plugin-admin/issues/1068)
+ * Fixed issue with new page modal not remembering last choice [#1072](https://github.com/getgrav/grav-plugin-admin/issues/1072)
+
+# v1.3.3
+## 04/12/2017
+
+1. [](#bugfix)
+ * Fix for regression introduced in the automatic page template switch when changing page parent [#1059](https://github.com/getgrav/grav-plugin-admin/issues/1059) [grav#1403](https://github.com/getgrav/grav/issues/1403) [#1062](https://github.com/getgrav/grav-plugin-admin/issues/1062)
+ * Fix issue with editor field in lists [#1037](https://github.com/getgrav/grav-plugin-admin/issues/1037)
+
+# v1.3.2
+## 04/10/2017
+
+1. [](#improved)
+ * Added new 'parents' field and switched Page blueprints to use this
+1. [](#bugfix)
+ * Fix for regression in h3 style in the Spacer field [#267](https://github.com/getgrav/grav-plugin-admin/issues/267)
+ * Fix missing preview in page media for SVG images [#1051](https://github.com/getgrav/grav-plugin-admin/issues/1051)
+ * Fix missing check when reordering [#1053](https://github.com/getgrav/grav-plugin-admin/issues/1053)
+ * Fix for editors not getting refreshed when changing tab [#1052](https://github.com/getgrav/grav-plugin-admin/issues/1052)
+ * Fix for mobile tabs in page editing [#1057](https://github.com/getgrav/grav-plugin-admin/issues/1057)
+
+# v1.3.1
+## 03/31/2017
+
+1. [](#bugfix)
+ * Fix for `Undefined index: file_path` error with Direct Install [#1043](https://github.com/getgrav/grav-plugin-admin/issues/1043)
+
+# v1.3.0
+## 03/31/2017
+
+1. [](#new)
+ * User uploadable avatar (still falls back to Gravatar if not provided)
+1. [](#improved)
+ * Improved tabs CSS to handle long titles [#1036](https://github.com/getgrav/grav-plugin-admin/issues/1036)
+ * Fixed `step` in range field [Form#136](https://github.com/getgrav/grav-plugin-form/issues/136)
+1. [](#bugfix)
+ * Fixed issue with exception thrown when `copying` and `moving` a page [#1042](https://github.com/getgrav/grav-plugin-admin/issues/1042)
+ * Automatically calculate the *next* numeric folder prefix [Core#1386](https://github.com/getgrav/grav/issues/1386)
+
+# v1.3.0-rc.3
+## 03/22/2017
+
+1. [](#new)
+ * All new `Page Ordering` implementation. Completely revamped and will only reorder with folder-prefix enabled. You can now reorder all siblings at the same time.
+ * Added a new `Advanced - Override` to allow option to display pages by folder name (default) or Collection definition
+ * Improved `range` form field with touch and counter support [#1016](https://github.com/getgrav/grav-plugin-admin/pull/1016)
+1. [](#bugfix)
+ * Cleanup package files via GPM install to make them more windows-friendly [#1361](https://github.com/getgrav/grav/pull/1361)
+
+# v1.3.0-rc.2
+## 03/17/2017
+
+1. [](#improved)
+ * Do not attempt to fetch any notification if settings are disabled [#942](https://github.com/getgrav/grav-plugin-admin/issues/942)
+
+# v1.3.0-rc.1
+## 03/13/2017
+
+1. [](#new)
+ * New flex-based/js Tabs system for better flexibility and improved UX.
+ * Added new **toolbox** with `Direct-Install` option via ZIP or URL.
+ * Added an option to reinstall a plugin/theme already installed [#984](https://github.com/getgrav/grav-plugin-admin/issues/984)
+ * Added a new **range field** [#995](https://github.com/getgrav/grav-plugin-admin/issues/995)
+ * When creating a new page, automatically select the Page Template based on Parent Page Child Type [#1008](https://github.com/getgrav/grav-plugin-admin/issues/1008)
+1. [](#improved)
+ * Page Media field now is available when folder is created, not just markdown file [#1000](https://github.com/getgrav/grav-plugin-admin/issues/1000)
+ * Separated user details and avatar in separate twig to allow more granular overriding in plugins [#989](https://github.com/getgrav/grav-plugin-admin/issues/989)
+ * Nicer layout of themes list on wider screen
+ * Editor full-screen option displays title/save options [#948](https://github.com/getgrav/grav-plugin-admin/issues/948)
+ * Use native OS highlight colors for the editor [#977](https://github.com/getgrav/grav-plugin-admin/issues/977)
+ * Force admin pages to set `Page::expires(0)` so it's not cached [#1009](https://github.com/getgrav/grav-plugin-admin/issues/1009)
+ * Added support for up to 15 tabs (was 10) [#954](https://github.com/getgrav/grav-plugin-admin/issues/954)
+ * Only reorder pages in the admin if collection uses `@self` and `order.by`
+ * Improved configuration tab sizes when you have lots of tabs
+ * Modified default media select size from 150px x 100px to 200px x 150px
+1. [](#bugfix)
+ * Fixed rendering issue with Chrome and sortables collections [#1002](https://github.com/getgrav/grav-plugin-admin/issues/1002)
+ * Fixed issue with removal of file that has been just uploaded and stored in the session
+
+
+# v1.2.14
+## 02/17/2017
+
+1. [](#bugfix)
+ * Fixed bad bug with `GPM::install()` from a change in Admin v1.2.13
+
+# v1.2.13
+## 02/17/2017
+
+1. [](#bugfix)
+ * Fix issue with validating page when switching language [#963](https://github.com/getgrav/grav-plugin-admin/issues/963)
+ * Fix issue with quotes in Admin strings used in JS [#965](https://github.com/getgrav/grav-plugin-admin/issues/965)
+ * Refactored `AdminController::taskGetUpdates` to use standard task/response [#980](https://github.com/getgrav/grav-plugin-admin/issues/980)
+ * Sync Admin pages blueprints with core [core#212d35221a9bbcc242508ba49a551b3f6e62af8e](https://github.com/getgrav/grav/commit/212d35221a9bbcc242508ba49a551b3f6e62af8e)
+
+# v1.2.12
+## 02/12/2017
+
+1. [](#bugfix)
+ * Rebuilt the JS bundle to address various JS-related issues that cropped up in `v1.2.11`
+ * Fixed Firefox Network Error issue when updating multiple plugins/themes at concurrently [#1301](https://github.com/getgrav/grav/issues/1301)
+
+# v1.2.11
+## 02/10/2017
+
+1. [](#new)
+ * Added lang strings for `CLI_COMPATIBILITY` which is new in Grav v1.1.16
+1. [](#improved)
+ * Allow plugin to set custom 'authorize' and 'location' in `onAdminMenu()` event
+ * Updated all language files with latest from [Crowdin](https://crowdin.com/project/grav-admin)
+1. [](#bugfix)
+ * Fixed issue `admin.super` or `admin.users` users changing the account when saving another user [#713](https://github.com/getgrav/grav-plugin-admin/issues/713)
+ * Fix issue where non `admin.super`/`admin.users` users could see other users profiles [#713](https://github.com/getgrav/grav-plugin-admin/issues/713)
+ * Fix removing responsive image from page media [#111](https://github.com/getgrav/grav-plugin-admin/issues/111) [#952](https://github.com/getgrav/grav-plugin-admin/issues/952)
+ * Use @2x & @3x fallback images in the filepicker. [#952](https://github.com/getgrav/grav-plugin-admin/issues/952)
+
+# v1.2.10
+## 1/30/2017
+
+1. [](#improved)
+ * It is now possible to manually specify a format for the `datetime` field [#1261](https://github.com/getgrav/grav/issues/1261)
+ * Allow to see plugins and themes list without internet connection. Also add a more helpful message in the "add" view [grav#1008](https://github.com/getgrav/grav/issues/1008)
+1. [](#bugfix)
+ * Fixed issue with downloaded package when installing a testing release
+ * Allow non admin.super users to change their account information. Allow `admin.super` and `admin.users` to change other users information. [#943](https://github.com/getgrav/grav/issues/943)
+ * Handle removing a media file also if it's not a json request. Was not working after https://github.com/getgrav/grav-plugin-admin/commit/6b343365996ce838759d80fa3917d4d994f1aeb4
+
+# v1.2.9
+## 01/18/2017
+
+1. [](#improved)
+ * Added lang strings for `ALLOW_WEBSERVER_GZIP` in System configuration
+
+# v1.2.8
+## 01/17/2017
+
+1. [](#improved)
+ * Allow the ability to clear the cache if `admin.maintenance`, as stated in the docs [#908](https://github.com/getgrav/grav-plugin-admin/issues/908)
+ * Added lang strings for `DEFAULT_LANG` in Site configuration
+ * Added lang strings for `NEVER_CACHE_TWIG` in System and Page configuration
+1. [](#bugfix)
+ * Fixed saving the configuration if not `admin.super`
+ * Show the clear cache buttons if the user has `admin.cache` permissions [#908](https://github.com/getgrav/grav-plugin-admin/issues/908#issuecomment-270748616)
+ * Fix colorpicker validation when transparency is set to 1.00 [#921](https://github.com/getgrav/grav-plugin-admin/issues/921)
+ * Fix html markup in section twig [#922](https://github.com/getgrav/grav-plugin-admin/pull/922)
+ * Fix bug in deleting a file uploaded with the `file` field [#920](github.com/getgrav/grav-plugin-admin/issues/920)
+ * Fix for plugin throwing event-based errors when plugin is removed and no longer available to process said event
+
+# v1.2.7
+## 12/22/2016
+
+1. [](#improved)
+ * Fixed an issue with non `.html` extensions not setting application type properly when fallback template not found.
+1. [](#bugfix)
+ * Fix plugins and themes json calls after the introduction of [HTML fallback for templates not found](https://github.com/getgrav/grav/commit/364209a27da0f5dfba5fde9c4b07b6d5844cda47)
+
+
+# v1.2.6
+## 12/21/2016
+
+1. [](#improved)
+ * Added a delay before reloading the page when a plugin or theme get installed
+ * Fix prompting to remove Grav itself when removing a package that requires a specific Grav version
+ * Remove cli-server exception since we now have compatibility with a custom router in Grav [#1219](https://github.com/getgrav/grav/pull/1219)
+1. [](#bugfix)
+ * Fix issue with array field and `value_only: true`
+
+# v1.2.5
+## 12/13/2016
+
+1. [](#new)
+ * RC released as stable
+1. [](#bugfix)
+ * YAML syntax fixes
+
+# v1.2.5-rc.4
+## 12/07/2016
+
+1. [](#new)
+ * Added a new `permissions` form field, used in the user profile to simplify editing permissions
+ * Added several new `onAdminAfter...()` events to allow for more 3rd party plugin interaction
+1. [](#bugfix)
+ * Updated admin-user-details to allow longer user names in the sidebar [#879](https://github.com/getgrav/grav-plugin-admin/issues/879)
+ * Redirect to a 404 page when accessing nonexistent plugins and themes [#880](https://github.com/getgrav/grav-plugin-admin/issues/880)
+
+# v1.2.5-rc.3
+## 11/26/2016
+
+1. [](#bugfix)
+ * Update class namespace for Admin class [#874](https://github.com/getgrav/grav-plugin-admin/issues/874)
+ * Fix updating/installing packages from admin
+
+# v1.2.5-rc.2
+## 11/19/2016
+
+1. [](#bugfix)
+ * Make default value work for filepicker [#859](https://github.com/getgrav/grav-plugin-admin/issues/859)
+
+# v1.2.5-rc.1
+## 11/09/2016
+
+1. [](#new)
+ * Updated to FontAwesome 4.7.0 with [Grav icon](http://fontawesome.io/icon/grav/)
+1. [](#improved)
+ * Always delete image alternatives in AdminController#taskDelmedia [#814](https://github.com/getgrav/grav-plugin-admin/issues/814)
+ * Use Media class to retrieve files in AdminController#taskGetFilesInFolder [#842](https://github.com/getgrav/grav-plugin-admin/issues/842)
+ * Increased specificity for Colorpicker field to prevent 3rd party conflicts
+1. [](#bugfix)
+ * Editor link button doesn't prefix links with `http://` anymore [#813](https://github.com/getgrav/grav-plugin-admin/issues/813)
+ * Dashboard Charts now always refresh no matter what [#753](https://github.com/getgrav/grav-plugin-admin/issues/753)
+ * Use rawRoute for parent too when saving [#843](https://github.com/getgrav/grav-plugin-admin/issues/843)
+ * Avoid different output when users exist or not in password recovery [#849](https://github.com/getgrav/grav/issues/849)
+ * Fix login to admin with permission inherited from group [#857](https://github.com/getgrav/grav-plugin-admin/issues/857)
+
+
+# v1.2.4
+## 10/22/2016
+
+1. [](#bugfix)
+ * Fix for accented media files [#833](https://github.com/getgrav/grav-plugin-admin/issues/833)
+ * Fix for `CTRL + s` not saving in editor [#832](https://github.com/getgrav/grav-plugin-admin/pull/832)
+ * Fix for missing REDIS translations in admin [#1123](https://github.com/getgrav/grav/issues/1123)
+
+# v1.2.3
+## 10/19/2016
+
+1. [](#new)
+ * Added new `onAdminCreatePageFrontmatter()` event to support plugins such as `auto-date` by allowing frontmatter to be modified by plugins.
+ * Added a new independent `cache_enabled` option for admin plugin (default is `false`). Should fix various sync issues.
+ * Add an `onAdminData` event to allow plugins to add additional blueprints data
+1. [](#improved)
+ * Handle errors when a resource fails to install
+ * Page media and File field images thumbnail are now properly proportionate and 150x100
+ * Added the Codeception testing suite with an initial test
+1. [](#bugfix)
+ * Fix [#1034](https://github.com/getgrav/grav/issues/1034) redirect of page creation procedure when system.home.hide_in_urls is enabled
+ * Media (Page): Do not extend parent metehod for sending files since Safari and IE API for FormData don’t implement `delete` ([#772](https://github.com/getgrav/grav-plugin-admin/issues/772))
+ * Clean up POST keys containing square brackets, allows for regex ranges in routes ([#776](https://github.com/getgrav/grav-plugin-admin/issues/776))
+ * Fix [#773](https://github.com/getgrav/grav-plugin-admin/issues/773) allow filepicker work inside lists, respond to mutation event
+ * Better error handling for Feed when unable to connect
+ * Fixed UI for Pagemedia note when files cannot yet be uploaded ([#798](https://github.com/getgrav/grav-plugin-admin/issues/798))
+ * Fixed Submit buttons getting disabled in case of form invalidity disallowing to submit again ([#802](https://github.com/getgrav/grav-plugin-admin/issues/802))
+ * Fixed issue when reading the file size setting if set to `0` (in Pagemedia and File fields)
+ * Fixed issue with `file` field in collections that caused unexpected duplication of items ([#775](https://github.com/getgrav/grav-plugin-admin/issues/775))
+ * Dramatically improved `filepicker` performance. Data is only ever loaded when the drop-down is on focus, as it was supposed to be. Image preview of a selected item won't be rendered unless the field gains focus to avoid wasting resources. ([#788](https://github.com/getgrav/grav-plugin-admin/issues/788))
+ * Allow `filepicker` field to peak at the pending uploaded files and optimistically select them ([#792](https://github.com/getgrav/grav-plugin-admin/issues/792))
+ * Fix [#821](https://github.com/getgrav/grav-plugin-admin/issues/821) issue in saving a page to a new language when the filename does not contain the filename yet.
+
+# v1.2.2
+## 09/08/2016
+
+1. [](#bugfix)
+ * Fix [#767](https://github.com/getgrav/grav-plugin-admin/issues/767) Add styling for new HTML5 input field types
+ * Fix issue with checking the package dependencies when more than one package is being inspected
+
+# v1.2.1
+## 09/07/2016
+
+1. [](#bugfix)
+ * Fixed `tmp://` stream issue with Admin updated to 1.2 before Grav updated 1.1.4
+
+# v1.2.0
+## 09/07/2016
+
+1. [](#new)
+ * All new `file` field. All files get uploaded via Ajax and are stored upon Save. This improves the Save task tremendously as now there is no longer the need of waiting for the files to finish uploading. Fully backward compatible, `file` field now includes also a `limit` and `filesize` option in the blueprints. The former determines how many files are allowed to be uploaded when in combination with `multiple: true` (default: 10), the latter determines the file size limit (in MB) allowed for each file (default: 5MB)
+ * Added a new `filepicker` field, which allows to pick any file from an ajax-powered select box. The `pagemediaselect` field now internally uses the `filepicker` field to live-reload the available files, and to show image previews.
+1. [](#improved)
+ * Better error handling for 500 Internal Server Errors, when Fetch fails
+ * Various notifications style and other CSS fixes
+ * More language strings added
+ * Added `clear-tmp` to cache clear drop-down
+ * Unified JSON twig templates
+ * Better error handling for 500 Internal Server Errors, when Fetch fails.
+ * Updated vendor Libraries
+1. [](#bugfix)
+ * Curl fix for invalid cert errors with News Feed
+ * Avoid requiring `admin.super` for ajax calls [#739](https://github.com/getgrav/grav-plugin-admin/issues/739)
+ * Fix showing HTML in notifications, in the feed
+ * Fixed broken page type filtering
+ * Fixed `beforeunload` event not prompting to offer the choice to stay on the page in case of unsaved changes
+ * Fixed click-away detection for preventing loss of changes, that would get ignored in some circumstances (ie, from modal confirmation)
+ * Fixed issue with `_json` elements where nested fields merging would get stored in an unexpected way
+ * Fixed composer dependencies missing error message
+
+# v1.1.4
+## 08/14/2016
+
+1. [](#bugfix)
+ * Fixed Firefox News Feed dashboard widget layout
+
+# v1.1.3
+## 08/10/2016
+
+1. [](#new)
+ * Admin notifications system. Admin will pull and cache notifications. This will be used to announce important updates, security vulnerabilities, and general interest news.
+ * Ability to disable widgets in the dashboard
+ * Added news feed widget to the dashboard
+1. [](#improved)
+ * Updated FontAwesome to v4.6.3
+ * Use new List functionality for Media Configuration
+ * Get fresh media list for `Controller::getListMedia()` rather that cache so always latest.
+ * Add translation strings for the new system.force_ssl option
+ * Reworked List UI to better handle drag & drop sort. To sort it is now required to use the left drag handle [#724](https://github.com/getgrav/grav-plugin-admin/issues/724)
+ * Lists now features a new YAML option `controls: [top|bottom|both]` (default: bottom) which will display the "Add Item" button at the Top and/or Bottom position relative to the list. When the Top button is pressed, a new item will be added at the beginning of the list, when the Bottom button is pressed, a new item will be appended to the list.
+ * Lists now features two new YAML options `sortby: [field]` (default: disabled) and `sortby_dir: [asc|desc]` (default: asc) which will display a new Sorting button in the list allowing to automatically reindex the collection based on the given sort field set.
+ * Lists now features a new YAML option `collapsed: [true|false]` (default: false) and a new UI/UX that allows for collapsing / expanding collection items, allowing to better managing long lists of items. It is advised to always put as first field the most significant one, so that when a list is collapsed it can be still easily browsed.
+ * It is now possible to sort Array fields via drag & drop [#950](https://github.com/getgrav/grav/issues/950)
+1. [](#bugfix)
+ * Fixed issue in Admin favicon URL [#704](https://github.com/getgrav/grav-plugin-admin/issues/704)
+ * Fixed issue in `selfupgrade` where the package would get downloaded in the wrong destination
+ * Hide tab when user is not authorized to access it [#712](https://github.com/getgrav/grav-plugin-admin/issues/712)
+ * Fixed Lists issue when reindexing, causing Radio fields to potentially lose their `checked` status
+ * Avoid overwriting a file when uploaded with the same filename through the Admin blueprint `file` field type if `avoid_overwriting` is enabled on the field
+ * Fixed issue with Array field in `value_only` mode, improperly displaying the key when no value was set
+ * Translate the description of a blueprint field [#729](https://github.com/getgrav/grav-plugin-admin/issues/729)
+
+# v1.1.2
+## 07/16/2016
+
+1. [](#improved)
+ * Forcing limit of upload files based on System settings
+1. [](#bugfix)
+ * Definitive fix for multi form submission in Microsoft Edge causing the Save to not work [#694](https://github.com/getgrav/grav-plugin-admin/issues/694)
+ * Fix issue with calculating the `theme_url` with `open_basedir` restrictions [#699](https://github.com/getgrav/grav-plugin-admin/issues/699)
+ * Check for null payload before going on [#526](https://github.com/getgrav/grav-plugin-admin/issues/526)
+ * Redraw Dashboard Charts when collapsing/expanding the sidebar
+ * Fix for `cache/compiled` errors resulting from page media uploads [getgrav/grav#938](https://github.com/getgrav/grav/issues/938)
+
+# v1.1.1
+## 07/14/2016
+
+1. [](#bugfix)
+ * Fixed issue with forms causing creation of new pages not to work [#698](https://github.com/getgrav/grav-plugin-admin/issues/698) and [getgrav/grav#934](https://github.com/getgrav/grav/issues/934)
+
+# v1.1.0
+## 07/14/2016
+
+1. [](#improved)
+ * Added the ability to login with the email in addition to the username. [#674](https://github.com/getgrav/grav-plugin-admin/issues/674)
+ * It is now possible to sort the Plugins and Themes views by 'Name', 'Author', 'GravTeam', 'Release Date', 'Updates Available' and 'Testing' releases (if in Testing Channel), both Ascending and Descending. [#583](https://github.com/getgrav/grav-plugin-admin/issues/583)
+ * Prevent external links (like the Preview button) to trigger the "Changes Detected" notice [#689](https://github.com/getgrav/grav-plugin-admin/issues/689)
+ * Added a filter field in Plugins and Themes list views, to allow for quick search of a particular resource
+ * Added new `Enabled` sorting option for Plugins list view
+1. [](#bugfix)
+ * Fixed an issue that prevented removing more than one page, in the pages listng [#672](https://github.com/getgrav/grav-plugin-admin/issues/672)
+ * Fixed toggleables in lists that were always loading as checked even when not stored [#688](https://github.com/getgrav/grav-plugin-admin/issues/688)
+ * Fixed Fullscreen tooltip in Editor displaying off screen (when in fullscreen mode) [#677](https://github.com/getgrav/grav-plugin-admin/issues/677)
+ * Fixed inconsistency in the way selectized fields would be rendered [#692](https://github.com/getgrav/grav-plugin-admin/issues/692)
+ * Fixed issue with Save in Microsoft Edge [#694](https://github.com/getgrav/grav-plugin-admin/issues/694)
+
+# v1.1.0-rc.4
+## 06/21/2016
+
+1. [](#bugfix)
+ * Fix for 'front-end' shortcut showing in mobile sidebar incorrectly.
+ * Append progressive number to the copied page title. [#394](https://github.com/getgrav/grav-plugin-admin/issues/394)
+ * Add field description to forms [#667](https://github.com/getgrav/grav-plugin-admin/pull/667)
+ * Fix clearing all cache [#658](https://github.com/getgrav/grav-plugin-admin/issues/658)
+ * Assign the correct ordering when saving a page that didn't have ordering set before [#628](https://github.com/getgrav/grav-plugin-admin/issues/628)
+ * Fix issue when saving a modular child folder as 05.somethin and being reset to 01.something upon save [#628](https://github.com/getgrav/grav-plugin-admin/issues/628)
+
+# v1.1.0-rc.3
+## 06/14/2016
+
+1. [](#bugfix)
+ * Fix for Gemini Scrollbar CSS breaking layout in IE 9+ [#644](https://github.com/getgrav/grav-plugin-admin/issues/644)
+ * Fall back to english for UI language if admin's language is not set [#641](https://github.com/getgrav/grav-plugin-admin/issues/641)
+ * List field has the wrong label/field width. Switched to "1/3 | 2/3" like all other fields.
+ * Correctly set the page slug on page copy. Avoids having two pages with the same slug [#394](https://github.com/getgrav/grav-plugin-admin/issues/394)
+ * When copying a page, if there's a page prefix (used for ordering), update the value to avoid having two pages with the same order number [#429](https://github.com/getgrav/grav-plugin-admin/issues/429)
+ * Fixed size of dropdown text in responsive views to be readable [#647](https://github.com/getgrav/grav-plugin-admin/issues/647)
+ * Fixed issue with checkbox in toggleables getting submitted with the form even when disabled (fixes #646)
+
+# v1.1.0-rc.2
+## 06/02/2016
+
+1. [](#improved)
+ * Cleaned up the Page Preview CSS to make it more 'standard' [#634](https://github.com/getgrav/grav-plugin-admin/issues/634)
+ * Added a legend with the Page colors explained [#637](https://github.com/getgrav/grav-plugin-admin/issues/637)
+ * Hide email output when sending forgot password instructions [#571](https://github.com/getgrav/grav-plugin-admin/issues/571)
+1. [](#bugfix)
+ * Fixed "Data type `System` doesn't exist!" error when activating a theme [#635](https://github.com/getgrav/grav-plugin-admin/issues/635)
+ * Fixed issue with custom media types not deleting on save [#633](https://github.com/getgrav/grav-plugin-admin/issues/633)
+ * Fixed issue when saving `List` field type in plugins + pages
+ * Fixed JS error on login/logout page due to jQuery not being loaded
+
+
+# v1.1.0-rc.1
+## 06/01/2016
+
+1. [](#new)
+ * Major improvements with the **File Upload** (`file`) field type. Now fully supports themes, plugins, configuration + pages
+1. [](#improved)
+ * Updated with latest languages via [Crowdin](https://crowdin.com/project/grav-admin/)
+ * Provide security options for single tabs [#615](https://github.com/getgrav/grav-plugin-admin/issues/615)
+ * Disable double clicking on Save/Delete/Copy page actions [#611](https://github.com/getgrav/grav-plugin-admin/issues/611)
+ * Tweaked the avatar alignment in sidebar [#592](https://github.com/getgrav/grav-plugin-admin/issues/592)
+ * Added page name to delete dialog [#511](https://github.com/getgrav/grav-plugin-admin/issues/511)
+ * Enabling / Disabling a Plugin doesn't trigger the expand / collapse details anymore [#614](https://github.com/getgrav/grav-plugin-admin/issues/614)
+ * Added hover on plugins list rows to match pages [#619](https://github.com/getgrav/grav-plugin-admin/issues/619)
+ * Translate media configuration [#608](https://github.com/getgrav/grav-plugin-admin/issues/608)
+ * Use raw routes in blueprints to better support multi-language [#798](https://github.com/getgrav/grav-plugin-admin/issues/798)
+ * Updated NPM modules dependencies
+1. [](#bugfix)
+ * Fix double "Removed successfully" appearing when removing a package [#609](https://github.com/getgrav/grav-plugin-admin/issues/609)
+ * Prevent removing required plugins dependencies when removing a package [#613](https://github.com/getgrav/grav-plugin-admin/issues/613)
+ * Show page title in Delete Confirmation modal if this information is available
+ * Don't try to uninstall admin/form/login/email plugins
+ * Only check for updates if not `admin.maintenance` or `admin.super` [#557](https://github.com/getgrav/grav-plugin-admin/issues/557)
+ * Always submit checkboxes that are not checked and force a 0 value [#616](https://github.com/getgrav/grav-plugin-admin/issues/616)
+ * Fix encoding in tooltips again [#622](https://github.com/getgrav/grav-plugin-admin/issues/622)
+ * Do not show `move` cursor for Collections that aren't sortable [#624](https://github.com/getgrav/grav-plugin-admin/issues/624)
+ * Properly handle Collections that specify a custom key, rather than falling back to indexed list [#632](https://github.com/getgrav/grav-plugin-admin/issues/632)
+
+# v1.1.0-beta.5
+## 05/23/2016
+
+1. [](#improved)
+ * Set sidebar navigation defaults back to "Tab Activation" and "Auto Width"
+ * Custom logo text is displayed as first letter in small sidebar view [#829](https://github.com/getgrav/grav/issues/829)
+ * Copied admin-only blueprints from Grav core to the Admin plugin
+ * Allow `field.label` to have HTML in it [#601](https://github.com/getgrav/grav-plugin-admin/issues/601)
+1. [](#bugfix)
+ * Fixed Togggle field with doubled `checked="checked"` when `toggleable: true` [#579](https://github.com/getgrav/grav-plugin-admin/issues/579)
+ * Strip HTML tags and lowercase username from login/reset forms [#577](https://github.com/getgrav/grav-plugin-admin/issues/577)
+ * Fixed issue with version numbers not showing up for dependencies [#581](https://github.com/getgrav/grav-plugin-admin/issues/581)
+ * Fixed editor tooltips in fullscreen mode and tablet devices rendering [#566](https://github.com/getgrav/grav-plugin-admin/issues/566)
+ * Fixed issue with `file` form field not functioning [#838](https://github.com/getgrav/grav/issues/838)
+ * Fixed issue with creating pages [#595](https://github.com/getgrav/grav-plugin-admin/issues/595)
+
+# v1.1.0-beta.4
+## 05/09/2016
+
+1. [](#new)
+ * Implemented Quickopen functionality to automatically open / close the Sidebar when mouseover
+1. [](#improved)
+ * Better error handling when `obj->validate()` fails with exception [#594](https://github.com/getgrav/grav-plugin-admin/issues/564)
+ * Improve markup of update and add package dependencies in update modal [#560](https://github.com/getgrav/grav-plugin-admin/issues/560)
+1. [](#bugfix)
+ * Fix for admin translation filter (`|tu`) not substituting text - [#567](https://github.com/getgrav/grav-plugin-admin/issues/567)
+ * Translated "Publishing" tab text [#561](https://github.com/getgrav/grav-plugin-admin/issues/561)
+ * Fix invalid argument supplied in foreach [#563](https://github.com/getgrav/grav-plugin-admin/issues/563)
+ * CSS fixes for editor button alignment
+ * Fix for forgot password not finding anyone
+ * Fix UI issue with update button on a package page in Firefox
+ * Fix issue with update button when automatic check for updates is disabled
+ * Fix issue caused by clicking "Check for updates" multiple times
+ * Added missing translations
+ * Fix for Themes with an array of keywords [#823](https://github.com/getgrav/grav/issues/823)
+
+# v1.1.0-beta.3
+## 05/04/2016
+
+1. [](#new)
+ * Added a `|adminNicetime` Twig filter to show 'nicetime' in admin user's language
+ * Added a `prepend` and `append` field option for text input type
+ * Added a WIP `onAdminRegisterPermissions` event
+ * Added several new languages: Arabic, Danish, Greek, Farsi, Korean, Romanian, Thai. Huge thanks to the [translation teams](https://crowdin.com/project/grav-admin)
+1. [](#improved)
+ * Fixed UI issue with Backup / Update buttons positioning
+ * Tweaked placeholders color in login/new user panels [#542](https://github.com/getgrav/grav-plugin-admin/issues/542)
+1. [](#bugfix)
+ * Fixed several untranslated strings
+ * Fix the version information after updating Grav from Admin
+ * Fix a Twig autoescape issue on Plugins descriptions
+ * Fix for showing empty drop-down with only one supported language [#522](https://github.com/getgrav/grav-plugin-admin/issues/522)
+ * Fix for visibility toggle on new page not working [#551](https://github.com/getgrav/grav-plugin-admin/issues/551)
+ * Page tooltips usability issue [#496](https://github.com/getgrav/grav-plugin-admin/issues/496)
+ * Fix removed title attribute from editor toolbar buttons [#539](https://github.com/getgrav/grav-plugin-admin/issues/539)
+ * Allow Incognito / Private browsing to still function in Safari [#527](https://github.com/getgrav/grav-plugin-admin/issues/527)
+
+# v1.1.0-beta.2
+## 04/27/2016
+
+1. [](#new)
+ * Added `grav ~1.1` to dependencies
+ * Added a persistent message if you try to run Admin 1.1 on Grav 1.0
+1. [](#improved)
+ * Used locator instead of `CACHE_DIR`
+ * Added a better way to get Admin version
+ * Show account page for users with certain ACL [#524](https://github.com/getgrav/grav-plugin-admin/pull/524)
+1. [](#bugfix)
+ * Fixed Editor Preview using wrong parameters for the ajax call
+ * Fixed toggle for stable/testing channel
+ * Fixed blueprint JSON fields
+ * If not logged in redirect to base path [#445](https://github.com/getgrav/grav-plugin-admin/pull/445)
+ * Various autoescape fixes
+ * ColorPicker CSS fixes
+ * Fix for translation of admin login [#500](https://github.com/getgrav/grav-plugin-admin/issues/500)
+ * Fix list not applying `toggleable: true` and `style: vertical` [#518](https://github.com/getgrav/grav-plugin-admin/pull/518)
+ * Fixed issue with update for wrong plugin displaying on plugin details pages
+ * Fixed error with the **close sidebar** toggle in some browsers (Firefox, iOS Safari)
+
+# v1.1.0-beta.1
+## 04/20/2016
+
+1. [](#new)
+ * JavaScript Rewrite. Admin is now built in ES6
+ * Lists can now be nested and 'fancy fields' (such as editor, datetime picker, selectize, other lists) get automatically initialized so they are always available no matter if you add or remove items from the lists
+ * The Editor has been reworked to be more flexible. In fact you can now pass any CodeMirror setting via blueprints, through the codemirror: attribute. The buttons have also a new API that allow to add or ignore buttons and behaviors into the toolbar from any plugin (see grav-plugin-editor-buttons). We also added the headers buttons (H1-H6) and Undo / Redo buttons, due to popular demand
+ * We introduced a new colorpicker field. You can now add more colors to your admin plugins :)
+ * Along with the versioning support added in the Grav Core for 1.1, the admin plugin can now install dependencies with the same versioning requirements as the GPM CLI commands.
+ * New System configuration field for toggling GPM release version (testing/stable)
+ * Several new system configuration options for new functionality such as `Process frontmatter Twig`
+ * Ability to collapse the sidebar to a smaller icon view if you need more room.
+1. [](#improved)
+ * The default Grav theme has been tweaked and in many places completely rewritten to ensure that it's as flexible as possible. The primary reason for this was to ensure theming and customization compatibility for the upcoming Admin Pro plugin, but a key benefit includes greatly improved mobile compatibility.
+ * We reworked the Datetimepicker, you will notice a new refreshed UI with a much better support for translations
+ * Tabs are now persistent. In views such as Page editing, when switching tab and saving or refreshing, would cause the tab to be reset to the initial one.
+ * When editing a page in Expert mode, the frontmatter editor is now more friendly. You will now get line numbers, undo/redo and YAML linter.
+ * Behind the scenes we have reworked how the form and toggleables work. This added a lot more reliability and consistency across the whole admin.
+ * The Pages view has more persistent states. It will now remember your expanded/collapsed states as well as filtering.
+ * Lists can now accept a custom button label with the 'btnLabel' property
+ * After login to Admin, redirect to the original URL called
+ * Admin now has an unique cache key compared to the 'site' so pages can be cached independently
+ * Improved the layout of the User Profile page.
+ * Set cache key uniquely for admin so cache does not colide with site
+1. [](#bugfix)
+ * Fix for modular preview - [#254](https://github.com/getgrav/grav-plugin-admin/issues/254)
+ * Fix for long content and page tabs - [#441](https://github.com/getgrav/grav-plugin-admin/issues/441)
+ * Fix for clear cache after adding new folder - [#393](https://github.com/getgrav/grav-plugin-admin/issues/393)
+
+# v1.0.9
+## 02/11/2016
+
+1. [](#bugfix)
+ * Fix language translation files
+
+# v1.0.8
+## 02/05/2016
+
+1. [](#new)
+ * Added a logout button when not authorized to access a page in Admin
+ * Added the option to hide a tab from an extended blueprint (https://github.com/getgrav/grav/issues/620)
+ * Many new languages and updates to existing languages from the Translation team.
+1. [](#improved)
+ * Check frontmatter for validity prior to saving
+ * Add noindex, nofollow across the entire admin theme if no other robots headers are set on a page
+ * Allow to hide a configuration blueprint section / tab and still save its values
+ * Allow to show user defined blueprints in configuration
+ * Updated FontAwesome to latest 4.5.0 version
+1. [](#bugfix)
+ * Fixed an issue with user registration on Linux caused by `glob()` possibly returning false.
+ * Fixed an issue preventing Admin to work correctly in a multisite configuration
+ * Fixed preview and insertion of images with non-lowercase extension
+ * Fixed an incorrect number of pages being displayed in the sidebar in some cases
+ * [Security] Don't reveal Grav filesystem path when trying to delete non-existing images
+ * [Security] Fix PHP error happening when uploading file without extension if the JS dropzone uploader is configured to allow empty file extensions
+ * [Security] Ensure correct escaping in various Twig files
+
+# v1.0.7
+## 01/15/2016
+
+1. [](#new)
+ * Added onAdminDashboard event
+ * Added onAdminSave event
+ * New lang strings for reverse proxy toggle
+1. [](#improved)
+ * More robust YAML file checking in config folders
+ * Removed deprecated menu event
+ * Removed old logs code
+ * Used new onAdminDashboard event for current dashboard widgets
+1. [](#bugfix)
+ * Fix for missing access checks on config pages #397
+ * Fix parent not loaded on admin form save #587
+ * When no route field is added to a page blueprint, add it as page root
+ * Fix for wrong page count (will show dynamic added pages in count too - Need to fix this)
+ * Fix for IE/Edge saving forms #391
+
+# v1.0.6
+## 01/07/2016
+
+1. [](#bugfix)
+ * Fix for forms appending `_json` fields on every save
+
+# v1.0.5
+## 01/07/2016
+
+1. [](#new)
+ * Added a pointer to Grav's contributing guide
+ * Handle the optional logic to strip home from Page routes and urls
+ * The Configuration page now shows any blueprint found in the user/blueprints/config/ folder, thus allowing to add custom configurations
+1. [](#improved)
+ * Allow the nonce for a POST action to be set in the query url
+ * Add a fallback twig template to use in case Twig cannot find a template file
+ * Modified update Theme and Plugin buttons to use more reliably markup
+1. [](#bugfix)
+ * Fix additional `on` parameter when saving plugins configs that contain tabs in their blueprint
+ * Fixes for the `pagemediaselect` form field
+ * Fix an untranslated message in the logout form when `system.languages.translations` is disabled
+ * Fixed a hardcoded `http://` reference throwing warnings under HTTPS
+ * Ensure download package has `.zip` extension, just in case
+
+# v1.0.4
+## 12/22/2015
+
+1. [](#improved)
+ * Improved File input field for admin
+ * Restore file inputs functionality and process form via JS if no inputs found
+1. [](#bugfix)
+ * Fix for the image preview in the file field on multi-lang sites
+ * Fix problem in form code introduced by fix to allow file uploads
+ * Fix redirect in deleting page media
+
+# v1.0.3
+## 12/20/2015
+
+1. [](#new)
+ * Added `pagemediaselect` field for use in pages
+1. [](#improved)
+ * Updated various languages
+ * Check for method `meetsRequirements()` prior to using
+ * Enable `file` form field to be used in plugins and theme blueprints
+
+# v1.0.2
+## 12/18/2015
+
+1. [](#bugfix)
+ * Fixed issue with user edit page causing error due to individual language files
+
+# v1.0.1
+## 12/18/2015
+
+1. [](#new)
+ * Moved languages into individual files under `languages/` folder
+ * Added a check for PHP version
+ * Dutch translation added
+1. [](#improved)
+ * Let forms work with file inputs
+ * Various file input improvements
+ * Language updates
+ * Better checks for existence of Popularity JSON data
+ * Add file processing to admin forms
+ * More Admin Pro integration fixes
+1. [](#bugfix)
+ * Set form to multipart if it contains a file field
+ * `cleanFilesData()` now returns just the filename
+
+# v1.0.0
+## 12/11/2015
+
+1. [](#new)
+ * New built-in admin registration process
+ * Added security check to `section` form field
+ * Added new RocketTheme font with various icons
+ * Add `onAdminThemeInitialized()` event to admin `Themes::init()`
+ * Force timestamp on CSS/JS assets based on `GRAV_VERSION`
+ * Additions for Gantry5 support
+1. [](#improved)
+ * Force lowercase `username` when logging in
+ * Hide markdown preview except for pages
+ * Added a notice if you don't have permission to see dashboard
+ * Updated admin login page logic
+ * Return "Invalid Security Token" instead of "Unauthorized"
+ * Throw exception if you used with built-in PHP web server
+ * Updated languages
+ * Removed `noreply@getgrav.org` default email address
+ * Use new methods to disable CSS/JS pipeline if available
+ * Various code cleanups
+1. [](#bugfix)
+ * Handle case when email `from` is not configured
+ * Fix tabs support in plugin/themes settings
+ * Fix param separator in page media Ajax call
+ * Fix favicon base URL
+
+# v1.0.0-rc.7
+## 12/01/2015
+
+1. [](#new)
+ * Display error page if page does not exist in admin
+ * Removed Beta message option and added toggle for GitHub message
+ * Added functionality to support Admin Pro plugin (in development)
+1. [](#improved)
+ * Added support for Markdown editor in lists #239
+ * Better Markdown Editor API with dynamic initialization
+ * Various language updates
+ * Removed some unused variables
+ * Added admin check for pages existence
+ * Prevent the admin to cause an error when an Ajax action is in progress
+ * Force translations to be active even when disabled in site #299
+ * Do not reinitialize `Selectize` if already available
+1. [](#bugfix)
+ * Fixed full-screen markdown Editor
+ * Fix modular preview not working reliably #254
+ * **Nonce fixes** (hopefully the last of them!)
+ * Fix broken plugin enable/disable
+ * Fix issue where `_redirect: /plugins` was getting stored in the plugin configuration
+ * Replace default them service with admin one
+ * Fix saving array fields #304
+ * Fix missing translations when default language is not english
+ * Fix title variables not translated #310
+
+# v1.0.0-rc.6
+## 11/21/2015
+
+1. [](#improved)
+ * Implemented logic to detect when offline and suppress Ajax calls
+ * Added nonce logic to be used by JS
+1. [](#bugfix)
+ * Nonce fix for updating themes
+ * Nonce fix for deleting pages
+
+# v1.0.0-rc.5
+## 11/20/2015
+
+1. [](#new)
+ * Use **Nonce** mechanism for form security
+ * Added Hungarian translation
+ * Add support for Markdown labels #271
+ * Added support for Markdown Editor in all the things
+ * Implemented save keyboard shortcut (Ctrl + S / CMD + S)
+1. [](#improved)
+ * Better error for "Internal Server Error" when accessing GPM
+ * Updated French translation
+ * Updated Russian translation
+ * Load Gravatar image with protocol-less `//:` syntax
+ * Improved header UI in mobile browsers #265
+ * Dropped unused version of JQuery
+ * More visible Preview link icon
+ * Hide **Latest pages** if there are none
+ * Improved toggle to better support different length strings
+1. [](#bugfix)
+ * Force rescanning fields when submitting a form #243
+ * Set default lang for pages on fresh session
+ * Escaped values in `array.html.twig`
+ * Fix saving in IE Edge
+ * Fixed various typos
+ * Fixed JS button issues #370
+ * Fixed JS error in private browsing #272
+ * Fixed date field border
+ * Fixed multiple instance of Markdown Editor #285
+ * Fixed Spacer CSS #267
+
+# v1.0.0-rc.4
+## 10/29/2015
+
+1. [](#improved)
+ * Changed admin menu event hook to `onAdminMenu()`
+ * Minor improvements for admin page location
+ * Additional lang strings for Grav 1.0.0-rc.3
+
+# v1.0.0-rc.3
+## 10/27/2015
+
+1. [](#improved)
+ * Rely on context-language for active language
+ * Improved some Russian translations
+ * Only show login if not already logged in
+1. [](#bugfix)
+ * Disable asset pipeline in admin only
+ * Fix Editor cursor insertion point when text is selected in some actions
+
+# v1.0.0-rc.2
+## 10/23/2015
+
+1. [](#bugfix)
+ * Reverted lang redirect code. Needs to be reworked to be more reliable
+
+# v1.0.0-rc.1
+## 10/23/2015
+
+1. [](#new)
+ * Redirect to non-language URL except for `pages/`
+1. [](#improved)
+ * New language strings for new `system.yaml` fields
+ * Improved Russian translations
+ * Improved compatibility with PECL Yaml parser
+1. [](#bugfix)
+ * Redirect to correct page if you change folder/slug
+ * Fix issue with Asset pipeline not being disabled in admin
+ * Fix for HTML in text input fields
+ * Fixed various icons in headers
+
+# v0.6.2
+## 10/15/2015
+
+1. [](#improved)
+ * Use `title` rather than `menu` in Page listing
+ * Wrapped language strings in double-quotes
+ * New language strings for new fields
+1. [](#bugfix)
+ * Fixed issue with IE not able to save pages
+
+# v0.6.1
+## 10/07/2015
+
+1. [](#new)
+ * Added the ability to render front-end templates in markdown preview
+ * Option to disable Google-based fonts. Useful for Cyrillic languages.
+ * Couple of new static helper methods used by new page blueprints
+ * New `fieldset` form field (thanks @Sommerregen!)
+1. [](#improved)
+ * Hide editor buttons in preview mode
+ * Improved support for admin when offline
+ * Use relative URL in Login form
+ * Added some more missing lang strings
+ * Improved German translation
+ * Compressed CSS files for improved performance
+ * Only get last 7 days in week count calculation
+1. [](#bugfix)
+ * Fix saving pages in local-specific languages
+ * Only track 'human' page hits in statistics
+ * Responsive fixes for 'wordy' languages
+ * Fixed delete issue with array field type
+ * Fixed some hardcoded `admin` references to allow admin path change
+ * Fix for issue with lang code being added twice
+ * Fix language name in admin buttons
+
+# v0.6.0
+## 09/16/2015
+
+1. [](#new)
+ * Support for custom markdown editor buttons!
+ * Added Russian translations
+ * Added Japanese translations
+ * Ajax session keep-alive when editing forms
+1. [](#improved)
+ * Added missing Italian translations
+ * Added additional options field into the pages form field
+1. [](#bugfix)
+ * Fix GPM errors in offline mode
+ * Fix for duplicate status messages
+
+# v0.5.0
+## 09/11/2015
+
+1. [](#new)
+ * Responsive layout for mobile compatibility (thanks @Vivalldi!)
+ * Added page type and many other new filters to Page list view
+ * Added granular ACL requirements to admin pages
+ * Ability to define page date format
+ * Added `onAdminTemplateNavPluginHook` to allow for plugins to hook into sidebar
+ * Added YAML Twig filters (to and from)
+ * Support for nested metadata
+ * Added ability to disable automatic update checks via admin plugin configuration
+ * Initial Spanish translation
+1. [](#improved)
+ * Check for existence of a user account
+ * Various language additions
+ * Refactored form fields to remove duplicates from form plugin
+ * Improved date picker
+ * Improved display field
+ * Add page template type to page list view
+ * Various UI fixes
+ * Added some default field 'focus' to save clicking
+ * Only allow "Add Modular" if the theme has modular templates
+ * Updated `chartist.js` library
+ * Updated 'fontawesome' fonts to the latest v4.4
+1. [](#bugfix)
+ * Fix for "drag-n-drop" of non-image media
+ * Fix a fatal error in GPM when offline
+ * Fix a z-index bug with tooltips
+ * Fix a z-index bug in lang dropdowns
+ * Don't allow deleting of last empty array field
+ * Fix for images with parenthesis in filenames
+ * Fix for page title visualization when not set
+ * Fix for cursor position in folder/array fields
+
+# v0.4.3
+## 08/31/2015
+
+1. [](#new)
+ * Added Japanese translation
+ * Support for independent file name and template override
+1. [](#improved)
+ * Improved slug generation using `slugify.js`
+ * Allow the `title` twig variables to set the page title
+ * Improved Page media handling with several bugfixes
+ * Prevent error when there are no pages on a site
+ * If all updates are applied, show "Fully Updated" text in dashboard
+ * Better preview link (requires `rtrim` filter from Grav 0.9.40)
+ * Order all plugins and themes alphabetically
+ * Removed duplicate language entries
+1. [](#bugfix)
+ * Fix for redirect after saving when multilang not enabled
+ * Fix for deleting responsive media
+ * Fix for HTML encoding in markdown field
+
+# v0.4.2
+## 08/25/2015
+
+1. [](#bugfix)
+ * Fix for current admin lang not showing up in page lang dropdown
+ * Fix for incorrect NAME/CONTENT lang keys
+ * Fix for incorrect site link
+
+# v0.4.1
+## 08/24/2015
+
+1. [](#bugfix)
+ * Fix for broken **Add Page** - Doh!
+ * Fix for empty site link when at root
+
+# v0.4.0
+## 08/24/2015
+
+1. [](#new)
+ * Multi-language Page support!!!
+ * Admin languages configurable per user
+ * Toastr messages for `check updates`
+ * new `tu` filter for admin translations
+ * Italian and German admin translations
+ * Added a save location in system and site configuration
+ * Page metadata now uses flexible array field
+1. [](#improved)
+ * Allow subpages of modular pages to display in pages list
+ * Open external pages in new tabs
+ * Reworked `visibility` of pages
+ * Use `PLUGIN_ADMIN` prefix for translations
+ * Added link to gravatar.com to avoid confusion on avatar
+ * Limit page count to 200 in ordering field
+ * Fixed various Safari _flex_ issues
+ * Use `rawRoute()` for page links
+ * Minor `param separator` fixes
+ * Various CSS fixes
+ * Improved CodeMirror to force spaces
+ * Added **Selectize** dropdowns to various forms and modals
+1. [](#bugfix)
+ * Fix for `Call to a member function path() on non-object` error
+ * Fixed dropdown z-index issues
+ * Correctly set the filename including language if set
+ * Fix for empty taxonomies on page save
+ * Fix for page not redirecting properly on folder change
+ * Fix for table headers styling
+ * Added missing translation strings
+ * Unique page counting in total page counts
+ * Fixed JS warning with page filtering and deleting
+
+
+# v0.3.0
+## 08/11/2015
+
+1. [](#new)
+ * Show current date in form date format fields
+ * Added a new **check for updates** button to flush GPM
+ * Added session timeout configuration for admin
+ * Added `isSymlink` logic for Grav
+ * Added new `phpinfo` page
+1. [](#improved)
+ * Improved toggleables
+ * Support `param_separator` for Apache on windows
+ * Logout now goes to interstitial to provide session messages
+ * Updated hints and improved formatting
+ * Encoding URI for images in editor preview
+ * Create user `system.yaml` and `site.yaml` if they are missing
+ * Open external links in new tab by default
+ * Set edit mode to `normal` by default
+ * Disable CSS/JS pipelining in the admin
+1. [](#bugfix)
+ * Fixed form submission not working in IE
+ * Fix fatal error when deleting homepage
+ * Prevent admin plugin activating when the URL of a page contains partial route
+
+# v0.2.0
+## 08/06/2015
+
+1. [](#new)
+ * Added multiple **clear cache** types
+ * Added back to themes link when adding new themes
+ * Properly handles visibility and ordering and guesses best option on new
+ * Added new templates field with support for custom (unsupported) template type
+ * Added new display field for displaying simple text value
+ * **Update Grav** button now works
+ * Added spanish translation
+ * Added german translation
+1. [](#improved)
+ * Improved page order handling logic
+ * Implemented 2-step theme switching logic with warning
+ * Force `modular` page class for modular template
+ * Clear page cache on page delete (ghost pages still showing)
+ * Clears route on page save so changes such as `slug` are picked up
+ * Fix dashboard layout in Safari
+ * Added tooltips for official 'Team Grav' themes/plugins
+1. [](#bugfix)
+ * Handle modular page templates on create
+ * Fixed Firefox JS error for arrays
+ * Ensure we don't change page type to empty and save (causing page to be deleted)
+ * Fixed some minor CSS issues with editor
+ * Fixed link to RocketTheme.com
+ * Disabled fields now stay properly disabled
+
+# v0.1.1
+## 08/04/2015
+
+1. [](#bugfix)
+ * Fixed GitHub URLs
+ * Hiding toggle for disabling Admin plugin
+ * Removed extra text not needed
+
+# v0.1.0
+## 08/04/2015
+
+1. [](#new)
+ * ChangeLog started...
diff --git a/user/plugins/admin/CONTRIBUTING.md b/user/plugins/admin/CONTRIBUTING.md
new file mode 100644
index 0000000..ef2bc6f
--- /dev/null
+++ b/user/plugins/admin/CONTRIBUTING.md
@@ -0,0 +1 @@
+Please read the Contributing Guidelines of the Grav Project
\ No newline at end of file
diff --git a/user/plugins/admin/LICENSE b/user/plugins/admin/LICENSE
new file mode 100644
index 0000000..f7d4bb6
--- /dev/null
+++ b/user/plugins/admin/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 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/user/plugins/admin/README.md b/user/plugins/admin/README.md
new file mode 100644
index 0000000..430509d
--- /dev/null
+++ b/user/plugins/admin/README.md
@@ -0,0 +1,111 @@
+# Grav Standard Administration Panel Plugin
+
+This **admin plugin** for [Grav](http://github.com/getgrav/grav) is an HTML user interface that provides a convenient way to configure Grav and easily create and modify pages. This will remain a totally optional plugin, and is not in any way required or needed to use Grav effectively. In fact, the admin provides an intentionally limited view to ensure it remains easy to use and not overwhelming. I'm sure power users will still prefer to work with the configuration files directly.
+
+
+
+# Features
+
+* User login with automatic password encryption
+* Forgot password functionality
+* Logged-in-user management
+* One click Grav core updates
+* Dashboard with maintenance status, site activity and latest page updates
+* Notifications system for latest news, blogs, and announcements
+* Ajax-powered backup capability
+* Ajax-powered clear-cache capability
+* System configuration management
+* Site configuration management
+* Normal and Expert modes which allow editing via forms or YAML
+* Page listing with filtering and search
+* Page creation, editing, moving, copying, and deleting
+* Powerful syntax highlighting code editor with instant Grav-powered preview
+* Editor features, hot keys, toolbar, and distraction-free fullscreen mode
+* Drag-n-drop upload of page media files including drag-n-drop placement in the editor
+* One click theme and plugin updates
+* Plugin manager that allows listing and configuration of installed plugins
+* Theme manager that allows listing and configuration of installed themes
+* GPM-powered installation of new plugins and themes
+
+# Support
+
+#### Support
+
+We have tested internally, but we hope to use this public beta phase to identify, isolate, and fix issues related to the plugin to ensure it is as solid and reliable as possible.
+
+For **live chatting**, please use the dedicated [Slack Chat Room](https://getgrav.org/slack) for discussions directly related to Grav.
+
+For **bugs, features, improvements**, please ensure you [create issues in the admin plugin GitHub repository](https://github.com/getgrav/grav-plugin-admin).
+
+# Installation
+
+First ensure you are running the latest **Grav 1.6.7 or later**. This is required for the admin plugin to run properly (`-f` forces a refresh of the GPM index).
+
+```
+$ bin/gpm selfupgrade -f
+```
+
+The admin plugin actually requires the help of 3 other plugins, so to get the admin plugin to work you first need to install **admin**, **login**, **forms**, and **email** plugins. These are available via GPM, and because the plugin has dependencies you just need to proceed and install the admin plugin, and agree when prompted to install the others:
+
+```
+$ bin/gpm install admin
+```
+
+### Manual Installation
+
+Manual installation is not the recommended method of installation, however, it is still possible to install the admin plugin manually. Basically, you need to download each of the following plugins individually:
+
+* [admin](https://github.com/getgrav/grav-plugin-admin/archive/develop.zip)
+* [login](https://github.com/getgrav/grav-plugin-login/archive/develop.zip)
+* [form](https://github.com/getgrav/grav-plugin-form/archive/develop.zip)
+* [email](https://github.com/getgrav/grav-plugin-email/archive/develop.zip)
+
+Extract each archive file into your `user/plugins` folder, then ensure the folders are renamed to just `admin/`, `login/`, `form/`, and `email/`. Then proceed with the **Usage instructions below**.
+
+# Usage
+
+### Create User with CLI
+
+After this you need to create a user account with admin privileges:
+
+```
+$ bin/plugin login new-user
+```
+
+### Create User Manually
+
+Alternatively, you can create a user account manually, in a file called `user/accounts/admin.yaml`. This **filename** is actually the **username** that you will use to login. The contents will contain the other information for the user.
+
+```
+password: 'password'
+email: 'youremail@mail.com'
+fullname: 'Johnny Appleseed'
+title: 'Site Administrator'
+access:
+ admin:
+ login: true
+ super: true
+```
+
+Of course you should edit your `email`, `password`, `fullname`, and `title` to suit your needs.
+
+> You can use any password when you manually put it in this `.yaml` file. However, when you change your password in the admin, it must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters.
+
+# Accessing the Admin
+
+By default, you can access the admin by pointing your browser to `http://yoursite.com/admin`. You can simply log in with the `username` and `password` set in the YAML file you configured earlier.
+
+> After logging in, your **plaintext password** will be removed and replaced by an **encrypted** one.
+
+# Standard Free & Paid Pro Versions
+
+If you have been following the [blog](http://getgrav.org/blog), [Twitter](https://twitter.com/getgrav), [Slack chat](https://getgrav.org/slack), etc., you probably already know now that our intention is to provide two versions of this plugin.
+
+The **standard free version**, is very powerful, and has more functionality than most commercial flat-file CMS systems.
+
+We also intend to release in the near future a more feature-rich **pro version** that will include enhanced functionality, as well as some additional nice-to-have capabilities. This pro version will be a **paid** plugin the price of which is not yet 100% finalized.
+
+# Running Tests
+
+First install the dev dependencies by running `composer update` from the Grav root.
+Then `composer test` will run the Unit Tests, which should be always executed successfully on any site.
diff --git a/user/plugins/admin/admin.php b/user/plugins/admin/admin.php
new file mode 100644
index 0000000..a6c4285
--- /dev/null
+++ b/user/plugins/admin/admin.php
@@ -0,0 +1,1017 @@
+ 1000,
+ ];
+
+ /** @var bool */
+ protected $active = false;
+
+ /** @var string */
+ protected $template;
+
+ /** @var string */
+ protected $theme;
+
+ /** @var string */
+ protected $route;
+
+ /** @var string */
+ protected $admin_route;
+
+ /** @var Uri */
+ protected $uri;
+
+ /** @var Admin */
+ protected $admin;
+
+ /** @var Session */
+ protected $session;
+
+ /** @var Popularity */
+ protected $popularity;
+
+ /** @var string */
+ protected $base;
+
+ /** @var string */
+ protected $version;
+
+ /**
+ * @return array
+ */
+ public static function getSubscribedEvents()
+ {
+ return [
+ 'onPluginsInitialized' => [
+ ['autoload', 100001],
+ ['setup', 100000],
+ ['onPluginsInitialized', 1001]
+ ],
+ 'onPageInitialized' => ['onPageInitialized', 0],
+ 'onFormProcessed' => ['onFormProcessed', 0],
+ 'onShutdown' => ['onShutdown', 1000],
+ 'onAdminDashboard' => ['onAdminDashboard', 0],
+ 'onAdminTools' => ['onAdminTools', 0],
+ ];
+ }
+
+ /**
+ * Get list of form field types specified in this plugin. Only special types needs to be listed.
+ *
+ * @return array
+ */
+ public function getFormFieldTypes()
+ {
+ return [
+ 'column' => [
+ 'input@' => false
+ ],
+ 'columns' => [
+ 'input@' => false
+ ],
+ 'fieldset' => [
+ 'input@' => false
+ ],
+ 'section' => [
+ 'input@' => false
+ ],
+ 'list' => [
+ 'array' => true
+ ],
+ 'file' => [
+ 'array' => true
+ ]
+ ];
+ }
+
+ /**
+ * [onPluginsInitialized:100000] Composer autoload.
+ *
+ * @return ClassLoader
+ */
+ public function autoload()
+ {
+ return require __DIR__ . '/vendor/autoload.php';
+ }
+
+ /**
+ * [onPluginsInitialized:100000]
+ *
+ * If the admin path matches, initialize the Login plugin configuration and set the admin
+ * as active.
+ */
+ public function setup()
+ {
+ $route = $this->config->get('plugins.admin.route');
+ if (!$route) {
+ return;
+ }
+
+ $this->base = '/' . trim($route, '/');
+ $this->admin_route = rtrim($this->grav['pages']->base(), '/') . $this->base;
+ $this->uri = $this->grav['uri'];
+
+ $users_exist = Admin::doAnyUsersExist();
+
+ // If no users found, go to register
+ if (!$users_exist) {
+ if (!$this->isAdminPath()) {
+ $this->grav->redirect($this->admin_route);
+ }
+ $this->template = 'register';
+ }
+
+ // Only activate admin if we're inside the admin path.
+ if ($this->isAdminPath()) {
+ try {
+ $this->grav['session']->init();
+ } catch (SessionException $e) {
+ $this->grav['session']->init();
+ $message = 'Session corruption detected, restarting session...';
+
+ /** @var Debugger $debugger */
+ $debugger = $this->grav['debugger'];
+ $debugger->addMessage($message);
+
+ $this->grav['messages']->add($message, 'error');
+ }
+ $this->active = true;
+
+ // Set cache based on admin_cache option
+ $this->grav['cache']->setEnabled($this->config->get('plugins.admin.cache_enabled'));
+ $pages = $this->grav['pages'];
+ if (method_exists($pages, 'setCheckMethod')) {
+ // Force file hash checks to fix caching on moved and deleted pages.
+ $pages->setCheckMethod('hash');
+ }
+ }
+ }
+
+ /**
+ * [onPluginsInitialized:1001]
+ *
+ * If the admin plugin is set as active, initialize the admin
+ */
+ public function onPluginsInitialized()
+ {
+ // Only activate admin if we're inside the admin path.
+ if ($this->active) {
+ // Store this version.
+ $this->version = $this->getBlueprint()->get('version');
+
+ // Have a unique Admin-only Cache key
+ if (method_exists($this->grav['cache'], 'setKey')) {
+ /** @var Cache $cache */
+ $cache = $this->grav['cache'];
+ $cache_key = $cache->getKey();
+ $cache->setKey($cache_key . '$');
+ }
+
+ // Turn on Twig autoescaping
+ if (method_exists($this->grav['twig'], 'setAutoescape') && $this->grav['uri']->param('task') !== 'processmarkdown') {
+ $this->grav['twig']->setAutoescape(true);
+ }
+
+ $this->grav['debugger']->addMessage('Admin v' . $this->version);
+ $this->initializeAdmin();
+
+ // Disable Asset pipelining (old method - remove this after Grav is updated)
+ if (!method_exists($this->grav['assets'], 'setJsPipeline')) {
+ $this->config->set('system.assets.css_pipeline', false);
+ $this->config->set('system.assets.js_pipeline', false);
+ }
+
+ // Replace themes service with admin.
+ $this->grav['themes'] = function () {
+ return new Themes($this->grav);
+ };
+ }
+
+ // We need popularity no matter what
+ $this->popularity = new Popularity();
+
+ // Fire even to register permissions from other plugins
+ $this->grav->fireEvent('onAdminRegisterPermissions', new Event(['admin' => $this->admin]));
+ }
+
+ /**
+ * [onPageInitialized:0]
+ */
+ public function onPageInitialized()
+ {
+ $page = $this->grav['page'];
+
+ $template = $this->grav['uri']->param('tmpl');
+
+ if ($template) {
+ $page->template($template);
+ }
+ }
+
+ /**
+ * [onFormProcessed:0]
+ *
+ * Process the admin registration form.
+ *
+ * @param Event $event
+ */
+ public function onFormProcessed(Event $event)
+ {
+ $form = $event['form'];
+ $action = $event['action'];
+
+ switch ($action) {
+ case 'register_admin_user':
+
+ if (Admin::doAnyUsersExist()) {
+ throw new \RuntimeException('A user account already exists, please create an admin account manually.');
+ }
+
+ if (!$this->config->get('plugins.login.enabled')) {
+ throw new \RuntimeException($this->grav['language']->translate('PLUGIN_LOGIN.PLUGIN_LOGIN_DISABLED'));
+ }
+
+ $data = [];
+ $username = $form->value('username');
+
+ if ($form->value('password1') !== $form->value('password2')) {
+ $this->grav->fireEvent('onFormValidationError', new Event([
+ 'form' => $form,
+ 'message' => $this->grav['language']->translate('PLUGIN_LOGIN.PASSWORDS_DO_NOT_MATCH')
+ ]));
+ $event->stopPropagation();
+
+ return;
+ }
+
+ $data['password'] = $form->value('password1');
+
+ $fields = [
+ 'email',
+ 'fullname',
+ 'title'
+ ];
+
+ foreach ($fields as $field) {
+ // Process value of field if set in the page process.register_user
+ if (!isset($data[$field]) && $form->value($field)) {
+ $data[$field] = $form->value($field);
+ }
+ }
+
+ // Don't store plain text password or username (part of the filename).
+ unset($data['password1'], $data['password2'], $data['username']);
+
+ // Extra lowercase to ensure file is saved lowercase
+ $username = strtolower($username);
+
+ $inflector = new Inflector();
+
+ $data['fullname'] = $data['fullname'] ?? $inflector->titleize($username);
+ $data['title'] = $data['title'] ?? 'Administrator';
+ $data['state'] = 'enabled';
+ $data['access'] = ['admin' => ['login' => true, 'super' => true], 'site' => ['login' => true]];
+
+ /** @var UserCollectionInterface $users */
+ $users = $this->grav['accounts'];
+
+ // Create user object and save it
+ $user = $users->load($username);
+ $user->update($data);
+ $user->save();
+
+ //Login user
+ $this->grav['session']->user = $user;
+ unset($this->grav['user']);
+ $this->grav['user'] = $user;
+ $user->authenticated = true;
+ $user->authorized = $user->authorize('admin.login');
+
+ $messages = $this->grav['messages'];
+ $messages->add($this->grav['language']->translate('PLUGIN_ADMIN.LOGIN_LOGGED_IN'), 'info');
+ $this->grav->redirect($this->admin_route);
+
+ break;
+ }
+ }
+
+ /**
+ * [onShutdown:1000]
+ *
+ * Handles the shutdown
+ */
+ public function onShutdown()
+ {
+ if ($this->active) {
+ //only activate when Admin is active
+ if ($this->admin->shouldLoadAdditionalFilesInBackground()) {
+ $this->admin->loadAdditionalFilesInBackground();
+ }
+ } else {
+ //if popularity is enabled, track non-admin hits
+ if ($this->config->get('plugins.admin.popularity.enabled')) {
+ $this->popularity->trackHit();
+ }
+ }
+ }
+
+ /**
+ * [onAdminDashboard:0]
+ */
+ public function onAdminDashboard()
+ {
+ $this->grav['twig']->plugins_hooked_dashboard_widgets_top[] = ['template' => 'dashboard-maintenance'];
+ $this->grav['twig']->plugins_hooked_dashboard_widgets_top[] = ['template' => 'dashboard-statistics'];
+ $this->grav['twig']->plugins_hooked_dashboard_widgets_top[] = ['template' => 'dashboard-notifications'];
+ $this->grav['twig']->plugins_hooked_dashboard_widgets_top[] = ['template' => 'dashboard-feed'];
+ $this->grav['twig']->plugins_hooked_dashboard_widgets_main[] = ['template' => 'dashboard-pages'];
+ }
+
+
+ /**
+ * [onAdminTools:0]
+ *
+ * Provide the tools for the Tools page, currently only direct install
+ *
+ * @return Event
+ */
+ public function onAdminTools(Event $event)
+ {
+ $event['tools'] = array_merge($event['tools'], [
+ 'backups' => [['admin.maintenance', 'admin.super'], $this->grav['language']->translate('PLUGIN_ADMIN.BACKUPS')],
+ 'scheduler' => [['admin.super'], $this->grav['language']->translate('PLUGIN_ADMIN.SCHEDULER')],
+ 'logs' => [['admin.super'], $this->grav['language']->translate('PLUGIN_ADMIN.LOGS')],
+ 'reports' => [['admin.super'], $this->grav['language']->translate('PLUGIN_ADMIN.REPORTS')],
+ 'direct-install' => [['admin.super'], $this->grav['language']->translate('PLUGIN_ADMIN.DIRECT_INSTALL')],
+ ]);
+
+ return $event;
+ }
+
+ /**
+ * Sets longer path to the home page allowing us to have list of pages when we enter to pages section.
+ */
+ public function onPagesInitialized()
+ {
+ $config = $this->config;
+
+ // Force SSL with redirect if required
+ if ($config->get('system.force_ssl')) {
+ if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
+ $url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+ $this->grav->redirect($url);
+ }
+ }
+
+ $this->session = $this->grav['session'];
+
+ // Set original route for the home page.
+ $home = '/' . trim($this->config->get('system.home.alias'), '/');
+
+ // set session variable if it's passed via the url
+ if ($this->uri->param('mode') === 'expert') {
+ $this->session->expert = true;
+ } elseif ($this->uri->param('mode') === 'normal') {
+ $this->session->expert = false;
+ } else {
+ // set the default if not set before
+ $this->session->expert = $this->session->expert ?? false;
+ }
+
+ /** @var Pages $pages */
+ $pages = $this->grav['pages'];
+
+ $this->grav['admin']->routes = $pages->routes();
+
+ // Remove default route from routes.
+ if (isset($this->grav['admin']->routes['/'])) {
+ unset($this->grav['admin']->routes['/']);
+ }
+
+ $page = $pages->dispatch('/', true);
+
+ // If page is null, the default page does not exist, and we cannot route to it
+ if ($page) {
+ $page->route($home);
+ }
+
+ // Make local copy of POST.
+ $post = $this->grav['uri']->post();
+
+ // Initialize Page Types
+ Pages::types();
+
+ // Handle tasks.
+ $this->admin->task = $task = $this->grav['task'] ?? $this->grav['action'];
+ if ($task) {
+ $this->initializeController($task, $post);
+ } elseif ($this->template === 'logs' && $this->route) {
+ // Display RAW error message.
+ echo $this->admin->logEntry();
+ exit();
+ }
+
+ $self = $this;
+
+ // make sure page is not frozen!
+ unset($this->grav['page']);
+
+ $this->admin->pagesCount();
+
+ // Replace page service with admin.
+ $this->grav['page'] = function () use ($self) {
+ $page = new Page();
+
+ // Plugins may not have the correct Cache-Control header set, force no-store for the proxies.
+ $page->expires(0);
+
+ if ($this->grav['user']->authorize('admin.login')) {
+ $event = new Event(['page' => $page]);
+ $event = $this->grav->fireEvent('onAdminPage', $event);
+ $page = $event['page'];
+
+ if ($page->slug()) {
+ return $page;
+ }
+ }
+
+ // Look in the pages provided by the Admin plugin itself
+ if (file_exists(__DIR__ . "/pages/admin/{$self->template}.md")) {
+ $page->init(new \SplFileInfo(__DIR__ . "/pages/admin/{$self->template}.md"));
+ $page->slug(basename($self->template));
+
+ return $page;
+ }
+
+ // If not provided by Admin, lookup pages added by other plugins
+ $plugins = $this->grav['plugins'];
+ $locator = $this->grav['locator'];
+
+ foreach ($plugins as $plugin) {
+ if ($this->config->get("plugins.{$plugin->name}.enabled") !== true) {
+ continue;
+ }
+
+ $path = $locator->findResource("plugins://{$plugin->name}/admin/pages/{$self->template}.md");
+
+ if ($path) {
+ $page->init(new \SplFileInfo($path));
+ $page->slug(basename($self->template));
+
+ return $page;
+ }
+ }
+
+ return null;
+ };
+
+ if (empty($this->grav['page'])) {
+ if ($this->grav['user']->authenticated) {
+ $event = new Event(['page' => null]);
+ $event->page = null;
+ $event = $this->grav->fireEvent('onPageNotFound', $event);
+ /** @var PageInterface $page */
+ $page = $event->page;
+
+ if (!$page || !$page->routable()) {
+ $error_file = $this->grav['locator']->findResource('plugins://admin/pages/admin/error.md');
+ $page = new Page();
+ $page->init(new \SplFileInfo($error_file));
+ $page->slug(basename($this->route));
+ $page->routable(true);
+ }
+
+ unset($this->grav['page']);
+ $this->grav['page'] = $page;
+ } else {
+ // Not Found and not logged in: Display login page.
+ $login_file = $this->grav['locator']->findResource('plugins://admin/pages/admin/login.md');
+ $page = new Page();
+ $page->init(new \SplFileInfo($login_file));
+ $page->slug(basename($this->route));
+ unset($this->grav['page']);
+ $this->grav['page'] = $page;
+ }
+ }
+
+ // Explicitly set a timestamp on assets
+ $this->grav['assets']->setTimestamp(substr(md5(GRAV_VERSION . $this->grav['config']->checksum()), 0, 10));
+ }
+
+ /**
+ * Handles initializing the assets
+ */
+ public function onAssetsInitialized()
+ {
+ // Disable Asset pipelining
+ $assets = $this->grav['assets'];
+ $assets->setJsPipeline(false);
+ $assets->setCssPipeline(false);
+ }
+
+ /**
+ * Add twig paths to plugin templates.
+ */
+ public function onTwigTemplatePaths()
+ {
+ $twig_paths = [];
+ $this->grav->fireEvent('onAdminTwigTemplatePaths', new Event(['paths' => &$twig_paths]));
+
+ $twig_paths[] = __DIR__ . '/themes/' . $this->theme . '/templates';
+
+ $this->grav['twig']->twig_paths = $twig_paths;
+ }
+
+ /**
+ * Set all twig variables for generating output.
+ */
+ public function onTwigSiteVariables()
+ {
+ $twig = $this->grav['twig'];
+ $page = $this->grav['page'];
+
+ $twig->twig_vars['location'] = $this->template;
+ $twig->twig_vars['base_url_relative_frontend'] = $twig->twig_vars['base_url_relative'] ?: '/';
+ $twig->twig_vars['admin_route'] = trim($this->admin_route, '/');
+ $twig->twig_vars['template_route'] = $this->template;
+ $twig->twig_vars['current_route'] = '/' . $twig->twig_vars['admin_route'] . '/' . $this->template . '/' . $this->route;
+ $twig->twig_vars['base_url_relative'] = $twig->twig_vars['base_url_simple'] . '/' . $twig->twig_vars['admin_route'];
+ $twig->twig_vars['current_url'] = rtrim($twig->twig_vars['base_url_relative'] . '/' . $this->template . '/' . $this->route, '/');
+ $theme_url = '/' . ltrim($this->grav['locator']->findResource('plugin://admin/themes/' . $this->theme,
+ false), '/');
+ $twig->twig_vars['theme_url'] = $theme_url;
+ $twig->twig_vars['preset_url'] = $twig->twig_vars['preset_url'] ?? $theme_url;
+ $twig->twig_vars['base_url'] = $twig->twig_vars['base_url_relative'];
+ $twig->twig_vars['base_path'] = GRAV_ROOT;
+ $twig->twig_vars['admin'] = $this->admin;
+ $twig->twig_vars['admin_version'] = $this->version;
+ $twig->twig_vars['logviewer'] = new LogViewer();
+ $twig->twig_vars['form_max_filesize'] = Utils::getUploadLimit() / 1024 / 1024;
+
+ $fa_icons_file = CompiledYamlFile::instance($this->grav['locator']->findResource('plugin://admin/themes/grav/templates/forms/fields/iconpicker/icons' . YAML_EXT));
+ $fa_icons = $fa_icons_file->content();
+ $fa_icons = array_map(function ($icon) {
+ //only pick used values
+ return ['id' => $icon['id'], 'unicode' => $icon['unicode']];
+ }, $fa_icons['icons']);
+
+ $twig->twig_vars['fa_icons'] = $fa_icons;
+
+ // add form if it exists in the page
+ $header = $page->header();
+
+ $forms = [];
+ if (isset($header->forms)) foreach ($header->forms as $key => $form) {
+ $forms[$key] = new Form($page, null, $form);
+ }
+ $twig->twig_vars['forms'] = $forms;
+
+ // preserve form validation
+ if (!isset($twig->twig_vars['form'])) {
+ if (isset($header->form)) {
+ $twig->twig_vars['form'] = new Form($page);
+ } elseif (isset($header->forms)) {
+ $twig->twig_vars['form'] = new Form($page, null, reset($header->forms));
+ }
+ }
+
+ // Gather Plugin-hooked nav items
+ $this->grav->fireEvent('onAdminMenu');
+
+ switch ($this->template) {
+ case 'dashboard':
+ $twig->twig_vars['popularity'] = $this->popularity;
+
+ // Gather Plugin-hooked dashboard items
+ $this->grav->fireEvent('onAdminDashboard');
+
+ break;
+ }
+
+ $flashData = $this->grav['session']->getFlashCookieObject(Admin::TMP_COOKIE_NAME);
+
+ if (isset($flashData->message)) {
+ $this->grav['messages']->add($flashData->message, $flashData->status);
+ }
+ }
+
+ // Add images to twig template paths to allow inclusion of SVG files
+ public function onTwigLoader()
+ {
+ $theme_paths = Grav::instance()['locator']->findResources('plugins://admin/themes/' . $this->theme . '/images');
+ foreach($theme_paths as $images_path) {
+ $this->grav['twig']->addPath($images_path, 'admin-images');
+ }
+ }
+
+ /**
+ * Add the Admin Twig Extensions
+ */
+ public function onTwigExtensions()
+ {
+ require_once __DIR__ . '/classes/Twig/AdminTwigExtension.php';
+
+ $this->grav['twig']->twig->addExtension(new AdminTwigExtension);
+ }
+
+ public function onAdminAfterSave(Event $event)
+ {
+ // Special case to redirect after changing the admin route to avoid 'breaking'
+ $obj = $event['object'];
+
+ if (null !== $obj && method_exists($obj, 'blueprints')) {
+ $blueprint = $obj->blueprints()->getFilename();
+
+ if ($blueprint === 'admin/blueprints' && isset($obj->route) && $this->admin_route !== $obj->route) {
+ $redirect = preg_replace('/^' . str_replace('/','\/',$this->admin_route) . '/',$obj->route,$this->uri->path());
+ $this->grav->redirect($redirect);
+ }
+ }
+ }
+
+ /**
+ * Convert some types where we want to process out of the standard config path
+ *
+ * @param Event $e
+ */
+ public function onAdminData(Event $e)
+ {
+ $type = $e['type'] ?? null;
+ switch ($type) {
+ case 'tools/scheduler':
+ $e['type'] = 'config/scheduler';
+ break;
+ case 'tools':
+ case 'tools/backups':
+ $e['type'] = 'config/backups';
+ break;
+ }
+ }
+
+ public function onOutputGenerated()
+ {
+ // Clear flash objects for previously uploaded files whenever the user switches page or reloads
+ // ignoring any JSON / extension call
+ if ($this->admin->task !== 'save' && empty($this->uri->extension())) {
+ // Discard any previously uploaded files session and remove all uploaded files.
+ if ($flash = $this->session->getFlashObject('files-upload')) {
+ $flash = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($flash));
+ foreach ($flash as $key => $value) {
+ if ($key !== 'tmp_name') {
+ continue;
+ }
+ @unlink($value);
+ }
+ }
+ }
+ }
+
+ /**
+ * Initial stab at registering permissions (WIP)
+ *
+ * @param Event $e
+ */
+ public function onAdminRegisterPermissions(Event $e)
+ {
+ $admin = $e['admin'];
+ $permissions = [
+ 'admin.super' => 'boolean',
+ 'admin.login' => 'boolean',
+ 'admin.cache' => 'boolean',
+ 'admin.configuration' => 'boolean',
+ 'admin.configuration_system' => 'boolean',
+ 'admin.configuration_site' => 'boolean',
+ 'admin.configuration_media' => 'boolean',
+ 'admin.configuration_info' => 'boolean',
+ 'admin.settings' => 'boolean',
+ 'admin.pages' => 'boolean',
+ 'admin.maintenance' => 'boolean',
+ 'admin.statistics' => 'boolean',
+ 'admin.plugins' => 'boolean',
+ 'admin.themes' => 'boolean',
+ 'admin.tools' => 'boolean',
+ 'admin.users' => 'boolean',
+ ];
+ $admin->addPermissions($permissions);
+ }
+
+ /**
+ * Check if the current route is under the admin path
+ *
+ * @return bool
+ */
+ public function isAdminPath()
+ {
+ $route = $this->uri->route();
+
+ return $route === $this->base || 0 === strpos($route, $this->base . '/');
+ }
+
+ /**
+ * Helper function to replace Pages::Types()
+ * and to provide an event to manipulate the data
+ *
+ * Dispatches 'onAdminPageTypes' event
+ * with 'types' data member which is a
+ * reference to the data
+ */
+ public static function pagesTypes()
+ {
+ $types = Pages::types();
+
+ // First filter by configuration
+ $hideTypes = Grav::instance()['config']->get('plugins.admin.hide_page_types', []);
+ foreach ((array) $hideTypes as $type) {
+ unset($types[$type]);
+ }
+
+ // Allow manipulating of the data by event
+ $e = new Event(['types' => &$types]);
+ Grav::instance()->fireEvent('onAdminPageTypes', $e);
+
+ return $types;
+ }
+
+ /**
+ * Helper function to replace Pages::modularTypes()
+ * and to provide an event to manipulate the data
+ *
+ * Dispatches 'onAdminModularPageTypes' event
+ * with 'types' data member which is a
+ * reference to the data
+ */
+ public static function pagesModularTypes()
+ {
+ $types = Pages::modularTypes();
+
+ // First filter by configuration
+ $hideTypes = (array) Grav::instance()['config']->get('plugins.admin.hide_modular_page_types', []);
+ foreach ($hideTypes as $type) {
+ unset($types[$type]);
+ }
+
+ // Allow manipulating of the data by event
+ $e = new Event(['types' => &$types]);
+ Grav::instance()->fireEvent('onAdminModularPageTypes', $e);
+
+ return $types;
+ }
+
+ /**
+ * Validate a value. Currently validates
+ *
+ * - 'user' for username format and username availability.
+ * - 'password1' for password format
+ * - 'password2' for equality to password1
+ *
+ * @param string $type The field type
+ * @param string $value The field value
+ * @param string $extra Any extra value required
+ *
+ * @return bool
+ */
+ protected function validate($type, $value, $extra = '')
+ {
+ /** @var Login $login */
+ $login = $this->grav['login'];
+
+ return $login->validateField($type, $value, $extra);
+ }
+
+ protected function initializeController($task, $post)
+ {
+ $controller = new AdminController();
+ $controller->initialize($this->grav, $this->template, $task, $this->route, $post);
+ $controller->execute();
+ $controller->redirect();
+ }
+
+ /**
+ * Initialize the admin.
+ *
+ * @throws \RuntimeException
+ */
+ protected function initializeAdmin()
+ {
+ $this->enable([
+ 'onTwigExtensions' => ['onTwigExtensions', 1000],
+ 'onPagesInitialized' => ['onPagesInitialized', 1000],
+ 'onTwigLoader' => ['onTwigLoader', 1000],
+ 'onTwigTemplatePaths' => ['onTwigTemplatePaths', 1000],
+ 'onTwigSiteVariables' => ['onTwigSiteVariables', 1000],
+ 'onAssetsInitialized' => ['onAssetsInitialized', 1000],
+ 'onAdminRegisterPermissions' => ['onAdminRegisterPermissions', 0],
+ 'onOutputGenerated' => ['onOutputGenerated', 0],
+ 'onAdminAfterSave' => ['onAdminAfterSave', 0],
+ 'onAdminData' => ['onAdminData', 0],
+ ]);
+
+ // Autoload classes
+ require_once __DIR__ . '/vendor/autoload.php';
+
+
+ // Check for required plugins
+ if (!$this->grav['config']->get('plugins.login.enabled') || !$this->grav['config']->get('plugins.form.enabled') || !$this->grav['config']->get('plugins.email.enabled')) {
+ throw new \RuntimeException('One of the required plugins is missing or not enabled');
+ }
+
+ // Initialize Admin Language if needed
+ /** @var Language $language */
+ $language = $this->grav['language'];
+ if ($language->enabled() && empty($this->grav['session']->admin_lang)) {
+ $this->grav['session']->admin_lang = $language->getLanguage();
+ }
+
+ // Decide admin template and route.
+ $path = trim(substr($this->uri->route(), strlen($this->base)), '/');
+
+ if (empty($this->template)) {
+ $this->template = 'dashboard';
+ }
+
+ // Can't access path directly...
+ if ($path && $path !== 'register') {
+ $array = explode('/', $path, 2);
+ $this->template = array_shift($array);
+ $this->route = array_shift($array);
+ }
+
+ // Initialize admin class (also registers it to Grav services).
+ $this->admin = new Admin($this->grav, $this->admin_route, $this->template, $this->route);
+
+ // Double check we have system.yaml, site.yaml etc
+ $config_path = $this->grav['locator']->findResource('user://config');
+ foreach ($this->admin::configurations() as $config_file) {
+ $config_file = "{$config_path}/{$config_file}.yaml";
+ if (!file_exists($config_file)) {
+ touch($config_file);
+ }
+ }
+
+ // Get theme for admin
+ $this->theme = $this->config->get('plugins.admin.theme', 'grav');
+
+ $assets = $this->grav['assets'];
+ $translations = 'this.GravAdmin = this.GravAdmin || {}; if (!this.GravAdmin.translations) this.GravAdmin.translations = {}; ' . PHP_EOL . 'this.GravAdmin.translations.PLUGIN_ADMIN = {';
+
+ // Enable language translations
+ $translations_actual_state = $this->config->get('system.languages.translations');
+ $this->config->set('system.languages.translations', true);
+
+ $strings = [
+ 'EVERYTHING_UP_TO_DATE',
+ 'UPDATES_ARE_AVAILABLE',
+ 'IS_AVAILABLE_FOR_UPDATE',
+ 'AND',
+ 'IS_NOW_AVAILABLE',
+ 'CURRENT',
+ 'UPDATE_GRAV_NOW',
+ 'TASK_COMPLETED',
+ 'UPDATE',
+ 'UPDATING_PLEASE_WAIT',
+ 'GRAV_SYMBOLICALLY_LINKED',
+ 'OF_YOUR',
+ 'OF_THIS',
+ 'HAVE_AN_UPDATE_AVAILABLE',
+ 'UPDATE_AVAILABLE',
+ 'UPDATES_AVAILABLE',
+ 'FULLY_UPDATED',
+ 'DAYS',
+ 'PAGE_MODES',
+ 'PAGE_TYPES',
+ 'ACCESS_LEVELS',
+ 'NOTHING_TO_SAVE',
+ 'FILE_UNSUPPORTED',
+ 'FILE_ERROR_ADD',
+ 'FILE_ERROR_UPLOAD',
+ 'DROP_FILES_HERE_TO_UPLOAD',
+ 'DELETE',
+ 'UNSET',
+ 'INSERT',
+ 'METADATA',
+ 'VIEW',
+ 'UNDO',
+ 'REDO',
+ 'HEADERS',
+ 'BOLD',
+ 'ITALIC',
+ 'STRIKETHROUGH',
+ 'SUMMARY_DELIMITER',
+ 'LINK',
+ 'IMAGE',
+ 'BLOCKQUOTE',
+ 'UNORDERED_LIST',
+ 'ORDERED_LIST',
+ 'EDITOR',
+ 'PREVIEW',
+ 'FULLSCREEN',
+ 'MODULAR',
+ 'NON_MODULAR',
+ 'VISIBLE',
+ 'NON_VISIBLE',
+ 'ROUTABLE',
+ 'NON_ROUTABLE',
+ 'PUBLISHED',
+ 'NON_PUBLISHED',
+ 'PLUGINS',
+ 'THEMES',
+ 'ALL',
+ 'FROM',
+ 'TO',
+ 'DROPZONE_CANCEL_UPLOAD',
+ 'DROPZONE_CANCEL_UPLOAD_CONFIRMATION',
+ 'DROPZONE_DEFAULT_MESSAGE',
+ 'DROPZONE_FALLBACK_MESSAGE',
+ 'DROPZONE_FALLBACK_TEXT',
+ 'DROPZONE_FILE_TOO_BIG',
+ 'DROPZONE_INVALID_FILE_TYPE',
+ 'DROPZONE_MAX_FILES_EXCEEDED',
+ 'DROPZONE_REMOVE_FILE',
+ 'DROPZONE_RESPONSE_ERROR'
+ ];
+
+ foreach ($strings as $string) {
+ $separator = (end($strings) === $string) ? '' : ',';
+ $translations .= '"' . $string . '": "' . htmlspecialchars($this->admin::translate('PLUGIN_ADMIN.' . $string)) . '"' . $separator;
+ }
+
+ $translations .= '};';
+
+ $translations .= 'this.GravAdmin.translations.PLUGIN_FORM = {';
+ $strings = ['RESOLUTION_MIN', 'RESOLUTION_MAX'];
+ foreach ($strings as $string) {
+ $separator = (end($strings) === $string) ? '' : ',';
+ $translations .= '"' . $string . '": "' . $this->admin::translate('PLUGIN_FORM.' . $string) . '"' . $separator;
+ }
+ $translations .= '};';
+
+ $translations .= 'this.GravAdmin.translations.GRAV_CORE = {';
+ $strings = [
+ 'NICETIME.SECOND',
+ 'NICETIME.MINUTE',
+ 'NICETIME.HOUR',
+ 'NICETIME.DAY',
+ 'NICETIME.WEEK',
+ 'NICETIME.MONTH',
+ 'NICETIME.YEAR',
+ 'CRON.EVERY',
+ 'CRON.EVERY_HOUR',
+ 'CRON.EVERY_MINUTE',
+ 'CRON.EVERY_DAY_OF_WEEK',
+ 'CRON.EVERY_DAY_OF_MONTH',
+ 'CRON.EVERY_MONTH',
+ 'CRON.TEXT_PERIOD',
+ 'CRON.TEXT_MINS',
+ 'CRON.TEXT_TIME',
+ 'CRON.TEXT_DOW',
+ 'CRON.TEXT_MONTH',
+ 'CRON.TEXT_DOM',
+ 'CRON.ERROR1',
+ 'CRON.ERROR2',
+ 'CRON.ERROR3',
+ 'CRON.ERROR4',
+ 'MONTHS_OF_THE_YEAR',
+ 'DAYS_OF_THE_WEEK'
+ ];
+ foreach ($strings as $string) {
+ $separator = (end($strings) === $string) ? '' : ',';
+ $translations .= '"' . $string . '": ' . json_encode($this->admin::translate('GRAV.'.$string)) . $separator;
+ }
+ $translations .= '};';
+
+ // set the actual translations state back
+ $this->config->set('system.languages.translations', $translations_actual_state);
+
+ $assets->addInlineJs($translations);
+ }
+}
diff --git a/user/plugins/admin/admin.yaml b/user/plugins/admin/admin.yaml
new file mode 100644
index 0000000..56b3977
--- /dev/null
+++ b/user/plugins/admin/admin.yaml
@@ -0,0 +1,48 @@
+enabled: true
+route: '/admin'
+cache_enabled: false
+theme: grav
+logo_text: ''
+body_classes: ''
+content_padding: true
+twofa_enabled: true
+log_viewer_files: ['grav', 'email']
+sidebar:
+ activate: tab
+ hover_delay: 100
+ size: auto
+dashboard:
+ days_of_stats: 7
+widgets:
+ dashboard-maintenance: true
+ dashboard-statistics: true
+ dashboard-notifications: true
+ dashboard-feed: true
+ dashboard-pages: true
+pages:
+ show_parents: both
+ show_modular: true
+session:
+ timeout: 1800
+warnings:
+ delete_page: true
+ secure_delete: false
+edit_mode: normal
+frontend_preview_target: inline
+show_github_msg: true
+pages_list_display_field: title
+google_fonts: false
+admin_icons: line-awesome
+enable_auto_updates_check: true
+notifications:
+ feed: true
+ dashboard: true
+ plugins: true
+ themes: true
+popularity:
+ enabled: true
+ ignore: ['/test*','/modular']
+ history:
+ daily: 30
+ monthly: 12
+ visitors: 20
diff --git a/user/plugins/admin/assets/admin-dashboard.png b/user/plugins/admin/assets/admin-dashboard.png
new file mode 100644
index 0000000000000000000000000000000000000000..599743e6e9149d9572257670ce92a2fd3ca1426b
GIT binary patch
literal 241372
zcmdSAg;Sf|x;_k)QYgiX6p9pgic{QOf;$u_p}0eFX>q4`a7pmsE-g-QcPZ}f)-T;>
zpWiui_S-+;n^}{|Jd-TB*R9umJz)T48H|_2FA)$BFyv$<)esP#b0Q!-^F>90Kk1*%
zl0iUtS!XFB0g#iBpa3}811)XL5fEg<5|dwOsOu8<9(%E6d?P?56+f26L8WL#0mNeR
zh~rWu5UBwwnbuIXG$bn`cVyKoR3$aK0)xaVuF*J93)er2X-pnGOX92ca=SkGoesJe
zFmAhV-)!|7zDA(ekdmqk>%M9eY@`A0|cii`R&VqRe%&t0ZsUU;>mb
z{bqW-KJyeW)U6x+e){c~_%eja^cjLwZh8k!WwoksP@Qs}C_M^-ZctAYVc7F^Z&Y*c
zcTJ)RpxzI*@dCXc%;O92KCr7k(fc9zivlaZSt7*tZs%@SO#sL_NX@;3LwaRAyp7o0
z_#?iaX(iZJRTD-#GrT
zCi!4Ugd22~w!WRz_+D}NAwd^MeQ;fIL&c$qn%XUVj`DXt!&U`S$A(!oFi6Fbku8+r
z8i&&itkdvb{%8dMxwHzq!i^cL9IzDXZN#d6l$uP2C(_;6(x9u(42#6Pk6UMpL8nnY
zC&Qy$q1x}AZ^%WyCFWc77xhRdXBxo?ecX5oES2>T=4H|$
zBixi8=nWrBKJ1;9y}kWZAx;G$`u6ps=!;4U^w0q83Q_D;MB&x)$59k`rTk9mnN=h~e=Jnw915f^f64dc
z6=M8-(%NmP%+E^15b2The<}k|uD*WFe);w}ohaVt=Y&7-9iF*-ZC+)M4fH*E`RZ%T
z$5(+Af|3D+u>_wGQpKlZsk;1IvPJ3Nh6m#2e4@u#lfeD_riOqqFg%B22SEdaG(=f~
zFxwh{b%DJX6rAloN=OvYUqM{@0`zm@Bgz4K$WQhYK|YM(fb&)FFPsK1wSUO0O5Y%P
zKWjr*_@#YLduy~6+;fV!&6m_6R#)(Ju?jRON%L#Ufc8GW{N<_torxbS7g-RLH@U0=}
zOX#e4i`)TSbex9l7PX4nD~7K%X&UmyRED%d?^?A1fcI(+>M3PE)O88~#SV(Uip8NF
z7FCRM;Rh<23Q4iN-mmIam7!Y82kH!FiNll=5x`3y&
zyja*!NZF^-v++*Xl>s9sbu6WZd7fY%ZC+@e5JL#V7^A!gC5k^vpExg#KTSBzU`Tw(
zbErAZxMoK$KrdBqp(d>+)5@%-tj5BcZG0KxqkCT)ofaK}sSg2ce;cMU)R~dzm3J>X
z5?fMU!V&Um{U{W$Y}Xp$3B9zu6TW+MCvY*ci}eP8(emmGiomO3l9v3E37=iv3$;6%
zyNaB0lhB;56MvKBUny~os-gByl3B2X$KUol*m$XmEM4N
z!Oe;SiZVlkLu*6RAnsI*H0w0Zq4PoOp)4H$a|??TGb8hn&KmQZq|_uYmgcgLOco_B
zB~B%v>5AG2?h#L@YYfJ8&rqGWt-mJUaslkB
zcyD)XlV$GL_f+|{Sfa3#ID{a?Jz6W;rq`)gK>0O<0+Ogaq-+n-SJ_rx;e8C?obmvl
zdv3dJ+q0IliYN0YzthH>`7|R`e*MNOQnp9BN0YY{l(isVuT?*C#Cl|Ujd$edIqUh!
zbMnip;rCfTGaNrlXF=lV2G0E&~+lKW4^xJFi2J
zNkqIva*V&O6t*}2cKTh1Kuy7y{XUxs!2O=5g84)@Ru!NJupM=%a6TDdt;4pF)#BrhTr*qkgi(M;?#m$${!WjbrlMU
z+lu=TX8~LX$_%q+JyOEnS?OxXaB+KzxhP%q61AtWu*aCOn9@`pI?6jbuNSXNuRmLh
zST8`Ez)hlCl$})Gpy8qW^?fZKlP+oyExp=V`M1G#<8$ZZA`w+Cdgjn=MK)
z75G?&r9TTS7yU^lIbz
z=3~|C>V(!BpVVJfQv;sK_pBlnNP2NqxjqG_u!qFQl0a?EGTO3XgU5a1d+u&);nFDM
zg?MOkJ7c@O;YrgxQa6&x&&Nx${p;V~Zo{tCXHXy*&Ai@h8?TMns@NDA?waCSPw!|$
zlnOwfKPau8@hev)Xez_QCoVOZ^X%5n7jqNav(gA
zmvTs^o&D)&OFlDqaMe^r?L+C^9Lu)s_Ss1P@OB2dC08Q=Mze>^dn?yQe-B99U>xAhg3b%m12d^3iE{
z;7L1B+YE~S1h_RDA&KCHJYC#YJM)<|{4P5wJ6P(u);nerQT#nBjQip2!0f8Ga;!r|
zFRNIXQ`p@*>^H~zx*et`>s{UfdzO{XHjy~0J%ATTYyE(R^gE2sdJnA;0TAN0UJ&O;g3vn(tb2(-LypihkV{04An>7oL4-!$
z)hYdgGEbBG>bv5V5f*|sI>O2~j=5Q*)B}<`41Yo7Y!-_uW%6X^u@8Ac!K!Ns4KFK|IKK;s07{x_4y@p?M=c?`5v3xJG=aeC+BQKD=<<
zk#wPvw<9MRp26p@LW%hBP;-$e0}=bhsJGK~$G0}UpcdA3U`R8>%MIubyiFd~nkv!G
z@ms1Me1ah1Affsr{Qq!>PEp4KxY4$2sWYj
zvmewcXv`D{NdGtzB@osiJ&&^ZN70k}({@7f|M)BTLr3M+P(1z^WYuHYh8{k@6_cC4
z{St=~Q1E=XnEpbu+d6!-Iua;~fc%dm`aP1S{9-9%hp}d3G}S@tw}I#Xd6<7aDHKI=
zWV7k1MkOjSi1sZr-eR<(+7anU(K6y|pKLDfX9L6mtcH
z6TD$+YIj;{`GUKbD>VJN-ng732==%0$#4aHj))$!6QSf~BSUWa9LY{>E4>k{!-cD2
zR!bzT_|N~t)<#|vpJbvTj;fT-8wwRdsANu%^0bMwQ?V20nva|vl9Kr6KO!Kp%TW*q
zn&dA;x_IF<;#AW2NLeYyeWt^;mE4fd!TBc*fD0{vDp-{ITbFFjyB}0j%93_QrD3jd
zL@Euo-}Fa@qC$ZSc6T9Ie=z~k3p7df8}#}^hyC3e%CX>OquE^@oH>{PCiJrPZr^`E
zUEBVJ23s4YIon`upmr
zk`f!|^I$?hwl<*EW|6hsfO8v1ckS85VVzz6qstGwh3S0?jDJ>WxDdrD-l~q;X2{;_
zF0t49=uBZOXz2zTG(0wy5yIFs8j<#U${Uf5Cb#`(eH0bME_85=&S^O0Ofaq)
zI6N{g^gY}QGKYSSV@`h(pK@fxs#pBTKgHd7wPsx&@wff_h!gt}aY6{2DH2@dXhc_b
zJv>t5b3K@Ms?p9zB~&(6cI{w5heRXoXlUQ=RBHRRvX1{vn@*K}l>8ustrRVm4-T__
z>SU>IW>P+!n>w|D(*GQ?7Rh-ygtgAL-t2um+}jn_+I861t$j}NH#ynhplT1IYmSsJ
z!tBiPHzs+TVU`)nd{4HFGdE>w`qA&RnZP7{5C~KF(yRlP3JL
z#1K%s2m;PR-Qj11wak`zm)VF<4wDrR?%DCxnr|NW6WFQ_S>G!^X_?2>=+@G_KRkHp
zQs}g4fu9U1*Yv9R+oY0Nq8`Z20QjUsZq7#K{Np@Qjk$b
zyF)EspnhSCD98Qm+-m@npXS!<5dD!NrN8c0<5hsea{-8_mbsk`klfiQG{ttSC3kD8
zd@t3k*=^7_^K9((eYFvo)o_jm3R&9FBuT^_z&(&fZv1>6v`}lk
zZBe)HAqP4y_A#IF(P;8)_kC7Q&!Bp(qAB(_Z9zcN4DsJF&i#6d-=E4ZPx2j|3(`$1
zcEGqJY&tPedgdvV=oUV7C~(W4L?e(S-8TA4{PH7w6*kLidtfzKN#De>u_Kb`pCh$s
zb}=qCX(W{8yK$8}nE6mkFIB!IB_a^kP5Wde*O1ARENAq*I;%>CCi+`SQT8|D?2N3r
z@@CqCyf4AO$h1*Du@0BDAT!Z$Z`V9t
z`{!^uO!ENlv|n`Ztp&bh?4uyeej!B8SO&{5)dXJ$aQ*eRH8hcOLq1rVHpMddYIPK3
z7^cAIgN_1JO~Lr0)k-5F@+D3X9T;v!SBv+Ex|kRuK0bb8Cep}4pS<%P&h@N|sVOB5
zgj(H7-U^^Jr80XDI$OFDdWA*}`7(EjH(42!vuIZNd7`X8EN+2k^##(YY&OS=`)MD#
z8OncUG666O|B>QEF;bsE(M{~a!IAA>Pvv2~>@ufE#A!N~_wY?6=+6~|GdjzI2B_J@
zp!?O5zbrhu72kX+{J3dWx9d?-^Ia)X&PKV!yO2G1Q8K%sA?4-Evm)gs{)Eg-<+A}v
zB!wXJ1SMB-^Maw47Qy*iXTkz7SXE68H}xJzUngKCut1F|jKb=uR|$ke5&;^v@h&Br
zYv_1|q!}p6+;UuuENg)LZvko`AbM++A@uDaAv30mGJ6YO-!;>c^%@}7>(2CD9F-y~
zo@%BjxGn1@G&x>1b>&g}g
zlD3gzCYwT>oQpipfvSz(sVvPVohUHbk^IG$o$K$Z@9vj_F~?fAMq6Ka(o5U*lIf6q
zzz!uxs=R26Ah#l7`0vfJ{@I+t(+(+et{g>@a8~o9AzqAG^p;RU9SN6>!&{mCTbjUp
zPsedtkQt3$n%U9_gDq<{EMn-bh9A(Y&)dTS7`!Kn7Mb%fxLKSTUSNQhz-Swt2qin`
zaCVe95f=pmXNn9L6!2Brs$RA5)VDkLvKDJY%OOoh>6#+$10$L+s`F-UkKiFxe|$`M2E4DpKCldWUH
zu$&$nrx-0Q7miCcA9_c%Gsd!B(`0_&JEb`dn@vcvTq80Q2-rAKi4JomK*xKf`z1-_vwyoH#_Q}D%F|o#-%pQRrd_D>_4edZZ$HG_wcP??!^4;$<-!&2I3nlSuhm6FR)aiK
zl(qzqiml?cWyngW>Xt&&`wAfWk7E-}Dw7lV3_zGvF*e+xTsr(3?zJ*dM>Kk-wbH{B4>t_Y3!U^(8v`
zZuN-pdcpc-p-PtU)0Pb$>%DHfiO}Zemg+*C?c)oaxjIWtie%h9Cxd7y?%&h;_G3-1
z`x?`(i@E0LO{c*mhW8}vnA~pHWk2zdO(Xn!uMKT5$np^X?SqP?R!4tIaJlYjr1AQZ
zT^`S5?ae^R?~pc~8HG!Nw~(>0LkW>KAG}%9{83Ydny$0i&3XYNnL@i?v4petq3r=`
z>gn~q&XOA!&ERx1qb3)IsJqXv@d@$uG2bzK2xDzOaN@t)$zvI?jZ!wND|VvQ@5wYSfnZ|#~n|>TPm+2B;a%Xp6WF!<(XTPF6ki-UY
zJDm3*;3~)hj07xH(kolfloiO3c}(g=Lv65xE+~Y~2df!LUJsz{s|cPpF!2;ufhw7d
zyC|^jkz3l1*ADOA8)1j~Akny-h_ae%K&8iYV&Zxi`l$1}H2#XJhdIC?%^#yOrCAxHs|$kJ5k|z`w*P({!RB~@`BwIDq26p}
z^m6G+y&8yNHC2pXrdu7XReHkuSzaV3^I5&w*qeL^WGsc<_zn2y*B8kIbH?>I_kpb{
zMPEgnINjPgaVfAZkUKn9y60$28z`_Rke%w;^7)6FMyKCI0h>K@x@HG|IM}$z}WmhKJYkd5%?JPg##>PgMtyGJu
z(8f&P$4l)z(%S={hf^o)^7CyiZ>`HnQhZSgFj~U)dE?tI=MFTw1f#6GCC3!c>m%FQ
za1T%;^_X@Cs&czEj1%}q{&?9UF%fO7-In|o%L%YKK4lh%
z^`|YejleFMz$QK+Hp|UC7{>NEd9gv2o8^*7t|inI-1HtImf|z$p{ZS8QWM@SQ$WK5
zDLaFW7=Z7bNslw0o@s8sNezy*T;#aTSrQ=NGM8MVYOD3ScD504pNP>2vG_zR4rX3S
z`mK=cNJmXeWEo~%F~WK^WaFD@=GAWh6d+%PuG6Q;vqv267nakYCQdn0wpv#pbc(aW
z3F40#Ddt>ZLoSII1?lOv#kCjl{eC!)Dw?s|msha!v7RoKW6`h6ueF}3%5J25pxF-S
z#OiA#jVPvm`ig?VQB_H?W-v-H&|1D(1_5wv8nq
zRb|HQHynq>7{4{566ZNW&blb~$nTol>uVrJm@!YCOC@7Q;gFA=!snR#j@iItGqDE-
zfv-z+Ki}`B+WXcyGT@!s@f=kULpdIDF;alT@-?*msi`uJL-hg`Ge-EX5Jy2jM&zkM
zWU0`Es%du%6zNUv_l5Ml%6wpFJw}A~R;`z@53wWJ$diGzV5sL}K18z_-^OeTHabpS
zhyL(x2wEQ&lL;>%Xk-Q4csj-IbG#G#)3x33OW2Fs5|((b7=iOV8qh0C#O3XJ%m-
zcsyR4C($jk({nY6<${IfdZcgCBMEFC3}zOwSn0I5Ogxj;3yAY2wN5xqLtYW89e-h>!6bE-nW2;tcj4H12uEJW;cOyH8*O|(8
zV-`6$(Np&%V%l@C(dr)yfmZ##1#cxs4Qj3MYb_^wrsAD<=`@UUU{gecrzz}auhi!T
z6{}@#&+K}P+Q;JP2Q9Goc9h;TY5&zb(f^Zo%v8@6Vx8NE&6SUtIew
z$g=Rk^;bboQBhGjNtcD@OyMdjlA{>K;>b3L*B;zU<`t>NeATUC3Lae4u!O!(_nrC1
zxupc+dDDJ;cUhfz!)?-mY~<0zAUYViky5|{u|Atmj%pu=Nt$Sd$0e2|Fk~pf5}~t$
zmhcSlrsSi!x;ah^6$=oydiim?o7w5_NqPZ+eCr%BcpliHnn+*T%r1vN8pymv^uUsjZAiJk5-#!5=8v6@
zE+_iJ`grz8=ko9d&+;^VrO@#Xac^l~5hhov(y7Che)>4$(m^OPmewsYRs~(jMbs8n
z;a&0I2g!+4t}t*N
zbrSBzlVs+V*fo9C%RdB%1RIN^*R{y}ZZe~9b-8x9``AO!v^j76`PYT&{LZAU9dy#tK-t{wP=Qoe*p8P#6I^e*y+0YEPTFeQ%mcF|#8F3P
z=KXn{GrC>07dn(a{ixBrw%%j64VgcEEu%N+vS%PR>XV?4x9lR+G`=As7f+;NEV%%G*m$U@g+V1yo+(6+;1=Za$Hu0@L(rx!?@r
z1~*tkNRJUvU)@dg%H+Rwv{!S$QpW(L4TbvdM$$*}xG7ljUXnRQl1|
zZ@a<0nR&mPkDWT(EVdc1^v!RgJooX5-F}PgM#+SbnD^Ghz&SC$Lo!=j>B|=CQu)&z
zSTRU^Y0QlT672MwqN^sVcEIf`QontEaT9wEk#eC941U$=L_o?xeJl7SwyLU1ym73?
zaw0MnR0RQR!jl^)<&Z2i(x9k!^V7gBMO`-}nsGzhzPsWOr%PFg^Fq9>i2$$Lv
zGv_*Tbt^WamSi8eRZgm!GqQM;B>(h=-hiq?;_1qxJ&AmQ$ox?=1%Vn1_mU94c>u
z52#WX6#BT!MGxaFKjnY0lmME`YoD2}01nM*rnBR}iLV!(9me$!3`W5gzl~)YG_kR?
z<;-)Y*OIRtgQJ()a0*0BSGsb
zmn1WJTmIAhyqzD>88vkd&s_N)nXObOc)v2S=Lrj)A5^1cW>{;Fs$+>rofEPZV1Vl4
zQK@HEyd3AYQ4cw#TET~pSA%J_JEBN_%k=Xy`&vg}g{P@rV>jF^dcB%`bQlYBjzY*%
zpTfX#jwiQqUgq{?PEImLo*6&c(51YHzV)H@<9!elazGzWVNb~@Jhj~RTbZkE@w&D%
z(@a>})_%~plfiVu4pl+g^iTo$spt$%zGei9@aCuYY-$h`9|Fwc&fqwN8I3Hxv9obb
z4}S6Dq7jjYYKr9BGtvs&MSt%UT=HhXoyounJES197}~p4myk7QbmX1irAUXs(FfSv
z6L%4jD@kVL?S&cNKJPXn=iAM0c&v2!GG?Uuj}Y(aYZbwFZ3!*`gnc1%T&SP^$7$b
z;hzKRY&peaMg-mJ?HNCW9R#AYQs~+}JzlSz?_J>vU!Ht%cCPb)dq|Xx&IHy^;X<#y
zHt}F1`#KuUxcl!kMAr6uWNP0GH)t5bGyQ$!6Yt(T(vF*Ae#Fb;xGvXy^RXoJ0fv}~
z7Iw@KQ`lT>kQKRdzUO6?<$4uO!a&xCPnPuwwhJv$R@2sf;#-Foy**nOzqZ#4RhRTG
zE?SdMbw$jL!}pHQJDHV}E_d&*PaI5Xr^>#I?jcGBHqp3OBoQ(eDdj-5pJL!E+l@xxI;qVL)z5%KlfznMz%2=}mI;+H
zH`1Ja^(+#>uX2)D^vCn%zJLB1_*`{YIV+CAho+e}G!aZ=xY~+p4EcVHYXcB0KW!L78=>=
z2^{Ma3v9{6tjiUYFL{pbv#lthYuSNGNs>=-&t`VM1uPXRTOk_y`D%M!7?Z1>Uy)jl
zu0CmGh}^#>spj}jA0+bff&ChbKSh7FQl$Yd|4$Yc>N3mnrVlr#8U_Y$ktJ=^Xoc4z
z{?)#fp$sr;^^6Oxf)_k7y#s_oir>CF7~NeK-@#}-(A+AaTrd$TZq5nIls%+FZ;i$-
zMwT{4<8mE_J+}<~IlM1a2a)YY68FL$Ayx9>K7Wj5TaY+4u2FboLZn$R9P
za$(#nS`y(k5+`q3RHOEHu}|jxjR)imfne0A41QORTH+2buY6
zC#8R-7;Q+mb$UD~(_beV&d$y-wCTuOS>!@ES)EDxzKWLO{x~NsaYtF_H$|n+S0nJV
zTRj$MXx^2(SPu0YBfVZyfC_u!(Exd~=~iw+QQqojIZi^ZWm=W%S1u7+Zzs#7=Q`P1
z<>`2eq~FXeb%tC&M5XcE@p9YwFxLv*5k1u_V7?PnWSIH_%HUctL10KVxBLZ)r4SZw
z7s&F8(pq-F&u|Pp#tK^Z#LQQP3U>cS1&;^KEQ;2zoWFluF{@V-ujO~Slz@)!9yYK%
zQE(p|o$t1JJ#{E79_Noih2IVRQMWG?4%508ZTGwxO?ylk*CfT
zmmD%uepA2r%%LGr^es01h}ZnCdywz0-Q%F^!CsI6@b-SOT!}$JrCx+WmKEGVT&l-5o%L$E%}K{#TkH2Emy(0$&ZT~Rp+%;`|!d6FCxaXKSe{Y
zTNzem1RiIBqo|MHK@rtw4E-Z{kL{0=a!kLoJ3n|~5YACmHyl%dlIZ2qCUr)YEBh@gIkql{{#
z??9}GY=IM{OXO2~$+WFrQR%*p?2
ztMTt8u|vI(XrzJ?jCEw?`YjXEC>2@<0ux9FH+}LrI2dReOH039zZqep&z-z@B_FS1
zV-no5Xt1vCC@n25iXNg6ep4;STA%eskTzAdr{i<(fk-sm+*VWl9~@i0oSLTb+LPI?
zv@I1HxBL3+EjCuOGjUE@(f_I6-~Ow9|8{@-FeXD@5JKij|G6s0xAOM(_F|B8WE5Tv
zmV*onGX7N~Yz`z(?2P4MWc;*3s6x7oS72qBiByEJD`as32T%OMK5?T|5AAcDlL<9n
zukuWvDoD!AB?C;I_2x86?-@w6&u6&dFq(R4vYg&?%K^sOxo6%>gM+1^Dj`}vp+gVj
zFYH-4w=u-jp8_y>sq?|AZZXcG8|FBI^%;GBMDVm(MK#NR`in9cr=>2r`I8mhI-V9bRC+GLSy=csx5V9JX1M0WrRFe7I
ze3&sp-uvb!9xYfLCAS|ISP?wR6ZVLOzI`!;mglE|7(kWi&rFk?tciNL9DfE7);jD!
zL88D0A$Rzw4CIsIFiJc>Mc;N0o@hvi9rR3;8wz;d{0cb?f4p+&DP{~I)-H6KiVknR
za~2xwlO)6oP#b65v8>$9O>G=BVD&g1+Ye=l7mNB?iN$LQ^gt;1(k;W
zy)>6b_x>WN8nl1lYE4?Ki~pu0oJt~OX|C_unUqqjMvFFNjf5B}ZmVnCpKJN|#MRD0k1-cYktK==j8Vc9u
zHUUTPEsct0$r
zU~SKK$dM^kCWDrotqp54NXv;?UHnA8E5Bw9)||+8OFC7
z<1)R=@ZAupIlzcm4fMlnJm-vioTV#yawUchPA7bkTfXjEbO2
zhKQE>2)m#EX-qM@t8j$__=9|t;a6{H$o3sf&Gz$cgc6!X@t|A+*L_KoDYOD$#I9~w
zIOTr`J2)5*PS|BL|E?3rI57bOz8UC@S)YUURxIPN~1jFA1AfCRW1x
zYV#nEMZX>}lvW$bYX=Z%8MA9dS~65gd)3x$}zz5)b>`+QhYsnnfIjA6tQ
zsgo%46t$6~2)nK>Rfk|6&NqIaE;HTOwid#wgr?`Ck@ksUv#q^Ebhc%hNU
zU%T&+WwXh{d>_YKOPnZ@^NN6-H<9A-_No4$H&-jRUoa^!FpwhaGl`nI`d1>UW|bN&
zq(nIif@SwakH;O7fA?h8!VrW@dM1`Sbi^nGkt$Da7x$0TzPzn|=h-kOFlqbRnC(fp
zEJ_nsRX!4%k$`S_P|uV(u!`)F~3{URV)X^>gs#Tl!Cp?l&Y^9u)s
zc8sAHSm*g&HiR-ZBSYyd+#9up4Sy;Iv>&>xvv^T{kIXTy5DUkaq$%8%-8G|_%U}F^
zN4ZjPv&)krfExlcc4)@P_7PmzGbx)*i^ialnTYn^4mM-G7kEQbyx)T_QmPSo`V|0a
zAU5qQb@EUvNa-a1=JZHYT|coU`^2O-KY}w;zp<0_#(7OR+){Bi1LVC|s)=z1dTqfBzT5I5h{oI0$A+bFsav|HRh%arq
z-HPYW`??vwc%~*A&Ly;yfhK&7*}SlKo{19wWdQ_aN+pU&q4%wrKcNwhQi)pd88!8~
z$J?qD^a3|%=zoqUSJ#)E750u1a83o4=&;JFl%T%`Jylid&t34lS!!aj|GN?RpF{->
zS0rWPR7O0M_@r!Pg~a;mT{n2!hTqeNCYBNO>vcal$0nDWSo=pI+bQ2dr=q-jS-sW^
zj%uaNOPvRt|0{|A$Ff_MrO4hl_0%gjg!c-%n+)fu-CnBoGVE-6&KD{7Rmlzwx^Pld
z$9#ZdX|YXAtmU2If+k>FF_nV`z2SfB=!=@;7Ur98$up^Q($PT2@0jJy2_-$}BL@wD
z!=OirT8mA4%ZP*&%egN_s;oWmwc>fU3(BiXI1+i2pU+v0WU>hV0qFmE0Cth%zkj#f
zpDr7FD-$c+120IrY_ZE2TvueMxhVGWyx0dgA^2qFiG@PPYNR2dAY%x(+Mq+rK85=7q*UylU
zlqOwmq3mpk75$I=AUHHk`JG0ik+!$1U!s{zs&a;-V|-b%hla%F29yA;Ow7;E%SbYCAskA5|&$`VH5$iwbt_CflAz`&b$?5K<
z>Gu|7^Llv_%*4yQ+%CoE;_b?uuUi!hG==c@-Il#?K}g795(klKo-nvCIDO
z)B-QG2AiD(zNh|&izyUDawATy8tA*I5mu{I091akeXaK}`p6RgNL%mw^m0p*x=Ya+
zTGm9H33tJ(VT~=)XVAJ7S9?)|BX|KfT|&dB#)(Dc}rXd_see1Hs$uiOn&CP
z+lfMyjy2tiC1Uf2u^EQ;65bcd3A-L}eG2W6S$ri9aELdB4#6$Z^5vWfnQ
zE!On{u^_ByR?w<);khQ*bZKNUGb6@GW*pAaBcHjIjYusQaBIMRM1s2*&wF?>_f&N@
zW-I##$3P6|Oi6$9!W|xe|0|35U!U+bq!gH$nU0-FlYU8f+L0@9wxV?0b33N8GPX$l!unCc~O?$d+J1G9)+^PQKJ=8oe%qQRo@3kfmehG)O
z(Hs+XbW)1$7$MDLQ8H$EZg0+Y)ZaWC{4%%@tI5DzoYg|}>*4Z#W4N4DXcCCL^+o=L
zI*Ckv)rN^w|0WgvuY>%X{T)!O_(Pdo-7_`Z6{R@ZE~3!|4vaFHhyb5!Ix|mM2%=#NB7h2s%^cfp7lM6#C?Lh&=cGD|4d#D4UjwK$PNx
zi?Q=^5i1O?1&m?-OLAL$50H2})TaM2g#bpykLSzYcQ@NZH7*lkunz!05VXe1P|svp
zY&}qIyhLiV1MX!Db(dWB<|=tEh1$qyc3?=?e84N7w1$s#hl30h&F#jy9PhdGXwdS(
z)T$v{Q@eYaN=1%CHJ^?1bV)e3GwukDU9*ES-HO#s%quB?FJC)XRHgc8EFY9?U)G$-
z{3k`u0U2kuLwxI5UeZ|3LoU@$aY;`BBezs{Tw8HRuBl$@W%lWO4P8w6{?y<~_kudl
zXqSh;g9o)}b_?`Q#x=cO@c|gyrbqu
zr#(mJ;bzeI=IyB{!v71{@Glfd$OL6`-=w`yaH8ID4%?r{7s8X`){Bk_4T!R>Uu}`dqas`DL$Qc)rev8O_wF2o9MYpi
zd<(jLyq>$b;QW2D9ru4;ra+AmMP#Fa$8TQbm*MiScy%!&5s=2HV~vTXY}s7kYOr7!
ze^aPUKQ>;BQADCFR8l8C&!{(;fY=y7gwY=Re(mSG0C%dRxoQ$a_aRMcq?BYh1dHCZ
zUB0lBiykt{1a14dw#LCW^@kXj&`()BLs2cYIn`!JLd;bmGPI$aYyY@yIA3L6G6Oca
zHFi2RF0@!Pr171;;CI;ph^B%ReZ>$X^0*m3G#;=xyB%k8**zfZwRsnS
zXy5wWT?)kL)zB}1q|!T04rkH+`8|ke7bGK>54=d`K`&FC&Ka#n6wkj>67Hd7evi>i
zwVRmOdRpgT8s!;kG`_E4bi}5JkBZ
z>O)yGmTM!-t5e^+aT)&5$}%AS2J7TtoE)r(;Y2c6Z8kvisl@-uX9Ud(c+g-UX!HJ`
z9g{ygQWGl}qN&LQ0&y($7GZ1>o;Fl%>ubB-f{h@-jN2apu!U#TUxT{+9v+3`X@14M+P*$kkdwQLxy(MlS2fM`
zX`ImMi6kZ0SUen@c$Sp;;zPrGmwh+sSU#3&EsK$~{ahY{f6jA%#QSFm11;)px;k{0
z?+BEdcoWM~U5)7ogr4W(%QERRM~iHv1Y@G=46|D3qfp$S?D-(mM)z6ab=&BIr
z>y()I*CWeamOogiYiYUW`5GAs3!TlX_mHI}VR*hjnyvhf`L<@IMk}d%U^#=^>eGwb
zw4|gSFNb9*-W5+m{0&0nL@(}qaKX68cE+Jj8Jt<^GH(ePg;N%eb}Td-Ogg30I4y)n
z=!Je7r>Cb&KGP9>{J0_G3!3Q?CD0lAwST&zhIV`&_LroX3{7X(#BDyc7tFLGl+>lj
zG^+JY{HOauwB`c4r9h(8AUetmHjCk*p}cDmA}Ktbz8d~fNJC*CpN$OW;;qZYw#%)#
zL=?@e)90aFsR$~kvf~!sc(Bs_TqO$*7l_MJu@l-9*yJX}{X_eJ@DNJVJo
z(pOB0_=%l-KcT+y6NfHE%k`4Vb)+uE%FBIsOrH*K^s{rCeTKI_E?)e_J`4W*PR4Y~
zckg}#zxwC+_Dzfe@EXmABB2ND6#)eaab5DO%7xS~^Ds)B^6nwe9lPXHZ%m#o*tIh3
zIJqA$OSmt(l1Gv7{#5JZ(&lqH!ESxL@^ZO6A)%uEly+Y+5Ru*BxK8W2RY#usq4@2NY%iWR^J`#`A;>Xhv&%7NY%<@lEnOjSv;283{3y
zcS3hJoHf3W(n|-7EFGri!S2g%#6Y|+GEI%B1VH?52Y_;ueiP|3y*kv->pud%UQDGp
zUUbGxARWZN!QJ{P)M5W>WSA@D=T{WuAq4LGlyld;NwA%T8^(KudrAP623df(uV3Qz
zrul{TtLA{=Jx==7sqGf@oxq6le1T)%P~oQwbU5|0J(*VMUikJRLi)FUy`6h$v)71G
z=kYI@Ot*`O?hdb``w;dk!DVeC#Q$5~!jV?Drj(4Omtlm)C3mWoiT3;k8o{q83ke-y
z+TCJN-QV9)QDtoWAa*8VH+@}Z&o|rw_17M^V&)m1A@_mPZ?b$fW987}#aq5K
z0r!CYt-EW17%V3FmnT_6oFe7~OyZl^vD@eAZGH^y+j#Adffgi?1}jMZMn$E_9s`{_
zxaNW@Z`h=6v%_A@t?R+qtD-SQV3xVz*t-yS79DJk~Dyb+N$&1?*U(
zA0Z6~H}t}f7ZZhgwS)dY;S~PQZPDkcUL?FIBlJUquUdxvBQWENR;^QIE`zD+43rm88*_Ct@i7OA#rmkWtbNvWREo%~Xq1th7~f{GyE2
z%Q5wM`tq5YxO4dD7?@3y0MdGtEPCx(!uPIBhXNY149tve?+-qE-bHBEQ1#vmKm2-C
zzCTuLdBSiR)fN$srA`T*OK)?*ipr{OT@2K91HKeuuOStB=y&3e)xXWP<@0WtjJp>&
z*+3cO2)L>UP0dKPad@=a(y}rT$ly5|%$w3b#2TvIQ~0*^(~x-djm#9KtKWvlTVD4U
zLwZM`Sm)C>QAH`g-EP-rShSQ925651=BLyxHzrrxm&%CSO1<#-3v4mcTCK>V?)nW$
zOWYC;@0`=rhjS>2AJ2j29HzH{zcx!^a@-*{`BK)`&l4JlK7nZ_IFoB3GBVIlV;>w8
z_?<~8Y2EEIlsJ=*S+4Ip7TqGZ60Zm*#K9F2gzV}|7SKSjw%?SBVwV;q+3$2yN89UD
zPuKI=SCmv#RE1qFQ1jTYUw=Iy`rMMQ{2;{xJ_v*AY!|kmGzy)r?CLM?u7#4NW1c8K
zt0?)=gmm4U;_Y;xqo53y3f|@qPu5uCX>&3)yNht{d~^Sh=sTS5f!V6nN{PeK?Diqd
zHw#~Xh9!g}!xI)pJy1;J@(HoBll{=rXVtY3p(*mWql>z|@6nEF+
zUZiMnT3iDZcb6cc6f5pf+%>qnOK~SSU*7xOpT50oJ%40nCG*Uju`~PZv&W#Enh^S0
z4263pXFdjL^aV!vJN+S>Eg@6OmO(qEj~_Mc{=!}U*Kue|@h}MTXjfY|BEcQQu%VJBje(HeW}(~o1ofWHN);;BE2P}H3OtmIg=8r6ArX6=vm*6
z1k5&F)F{2fI*o-E?v~r`K(wQW_q2nh9-0D^Du3#B&CGu*^KmQ73!;R%BX?DVH9^Wn
zCB7TyYjXZx+}InJp5Pu!S~6Q8o+<-Nb$WbQ8~Gi2ars!;D!=5!P~~PXP{(U_S_K>b
z#aZpH1*yoL>p!#_&jo&12S?LYe|C;a%VX@4UZ%;fjJZJ+hNig{k738U)h^bmFbjqT
zL6&2-O9$3gP{-L+XyN*fo0BDbA_$-qO~TBfb5%RU)Y&1CjFWJ9zS+Y$
z`?wVba=0GOXtcN;X;m2^2NrHe_q>vnOyfb|8EZp{D;K`&s}ZwHoJ6s+H4Y&n;Vai-wIcgqCPzvVn!+`2n4gtMGG
zVFOTBbX?6Py$QLa;|h96c2@FzcS`JoPg#>_>rjfMmH}JBqenl=#kS9Kc4+)HZi#q(
zPcmsQ#Y(JQ6X+KR{1-^_zdpAJu3yap_816qb5(X~UGV+ATm7ZC`20x(k3C}CAT^1X
z98ziz2RZ%F%I>iv>=E(S7uX~SlI6FWco#oygC%s&!O0tn(&J>11Tjs3j++tWENNnK
z6mW(Aa7XE`Ha-`nNjfvXWVhgFjZ{+ln6rJ!VL6uC#y0aaNp8ofP@V=f|LT3!$I_>&
zmAbJh!8a4va|;iLK_!0g|DgrIxegAD+|MDAAJeksef2(`Ig~!(LrIz)Kx3u8%y-&$
z1nbr_&pF$w=Rgy$-l;;VN4HGs4d>b|zgv^)Tf?8dYPfjztFo67K&e(?2dv%?MT(7X
zI@hPnZVtY^;d_(pX}YK0UiVdrJ%jq$d{sBzb9Pn(3ltZ7%KRdO#gJIB!!-45FOZ#<
zosel)q5RFkO0nJZscoJ1{hP~pv8AHQhMNRgW<`o#TN
z;FIh-!+8epfaw`g)B8X
zbDASVkAo=k9~H8NZYgr}b0@Zv^(FSNW6B$kZW^hKArtxZoHnyDK!AOI!2#?#{wXIP
z;+3K(eE90=i=oGja~yGp!}~-)b|#0b(8E0xQ~a0rLk;`eO6SfM3Q*h|Zc7RA=P>U1
z%x=TiGAlkTI#N$wS6}6}aRelr42O|$1f{BW2Dy_)amXh#QF@S5`w_2DX@uDhSX)nM
zb8~ayX*(o+L!6;s8ozFs$FaUT`gJEd-&SR2mX|-+cE4Z?8#^N?`suu%)T40VwTv%T
zDvGTd2gLq2uUQN)Mv&Po^l*{$?x*OGy4>~%3w$UA6`Jc9L<4vFm(z|<E{q*QaJ^TzuieBeQK=4lLvFIP*I#X^BvezHEK8ytb3f8``6yps{K=$n*jP(w
zgw|$(IbP_-3L)-{8bBL`73CS%dFjrKRoMLVfi)XiyIP$Slq9>aU5^na9Ct4
zVz_M|{x+$Q#Y!nvxpuS}|
zJZp8ZRe1K%I(K4er!Hs6^Xw-|cv5{+-L~+JPRxUnBwA}KkYr}91i$w53Pt<|r1+^a
z?d{+x*{!?kLaM-iIbO*M7z*Q#edBDeaD3``MK28Wh;b?1nCq@2+74mx+u;uxU3x;!
zv|~HTx$UXqcGN+@5~!ha=FcN6nRSSzHjlk3yu_U6@aws&_QOSl(ARTA(yuBTgpA^&AG;s&z)bzfi$G
zyeBGea~mU3s(za~xNrE{_|RvCtX;k^P144q($FH>PTyjFq_sCEhJncA{Nv17(
z!{>KczkOJioS;h=hjsCA`~hrxyX^Dy5q?N!_bMZIVOVn6L8`VG%dAf7ma0kc+Q?(>
zsX9FocfDH~age(fCif1ygGj&pwdA*x*=tCt@E%znynEM`jq?WDlDqb8|HbbDph1r1
zgirQZW+W9jYxgR3Qqqglys1K|Af&hws|}4%TC(rJTNB6Qw_oFZmH4^#sMo>ijy6wb
zN#S3?lYan~pAgTwt>qyaHR-^DsS$Iwc&+q4%*HQb-h^+=EDPPa(yfXP-Y2u$imFy3
zKh!09S~~373}XYXF-;bPrOLjWXrmQEATml`En%(7ENnfni(Khbg>om|VZ^Wi2!Oiz
z>QHz7GgZg*&YT0ajZO(#ynC#b0yXy4s!L9$J^)|#mtS%>1@s|2WiA+{_=ADR(?xO-
zR=bAz?}rUm+g;>k!!I{)SFGspczZ|ALer=XTs9skBnJh;fXpsNREKkAnj~W14~RX^
z-I;%S_Uc}Aeyb!dmda=G={u;~mA`u3ar}<3*X0DjCpfv~AH@Px*+*I)VN>PU+QiMr
z$|LqI9Ek)t1(Ix%4^_?Ks2-&q#21K(6SibNSS3<<4Ln9EJ=KuaSf^W}#d&LoyfnJy
z-3GvF-eS1JaI8N1*ztT8nD8;9a-3vMvlL>@N*YZDf(>SKsRXk^!NdUFl`fcm*S1og
z{gp69;S<6AU^8!pFXUGab2FDw1{;kkM9ba9bnZrzP-pA-D*RU&RA<)HXwWL#Y9VOq
zH!P9YX{9f>CkeZ-`O7-t{eiq;n$Ek#_t(`yP7Ev7^+zV|=EZ3FBVSw3gc2$+&0_UY
z@^|h@AX!b$N(h1uMkF3vX*E5As;5LMPr~st6L0Y3>$A>vel@3b4{^5|DlNIO&f9O>
zEXAs;nRdS2SS
zCGXt*!tvWNNh0j41zM^qj!ry|+#@ZMUX&29F@L7g_hh=7%IHkq$*noNeAh$#&q+Qp
zJsRs-ifL|13x}@D6z}tvn?1)r6NXWMHW}baqb^Mbbl-pJfe{JiXG&Hi4(DsPbsRAO
z!ZL|P{%GoUV@(VgrqVaCL7VPl;yDhrBvttsv-wJ3p1=yeY4pcAj`P*_-vEwep-Ioe
zpFcx%Yi#*ro
zQmMU3+>eKqhJfLy6)YUgj&T;XU{qZxXF=aSmFTR0okE$o9f{pLymcP@w`!
zgz35nda3WyeVKGDdn)>mSqo1yvA~V7ec0OgaSB#>`91x1U_il)jWYveK2}B(PWjk&
zSZz-Y?ST=Oy@JTj3t&)XPA^>VQ1g4fJ`ZP&z?6BOg
z3|~V0W>Pk6bE((94pmyL|HycxyIE(2{*V-ipDV#PKgnWX?86*XTeyCd5@>O+Ws5JT
zW1Y}2I$stb%&-bzHkae4-X1u+k#~E(o+cpf1S~*ff@ZLqw#x=6&{Y?LOxTikdOqmP
zxTJ*Nq?#p_1vGu5p6`Ix6alYIAse4eC#VToqU|(?3=IdO?GrzexX(R_8l*OVcAjIb
z4?TBdsu6}=KlQ{C2iKheRuz^jR}D9~Z-584BvrC~Hc%8mNLUPm=;LxmANA!1QQek!
zx!2tsw0N4Wsl@N#zqg^#KPmx@waUF_oD_?W?J?&_5>sl5Lb1uaTwF<|^HWt-Q1U#7
zjv7F}MwY=6pVM=Ux{17p9}17x_mAF40fY=Gyw=#Zp|SBzW&*&>rSRt!ly}k6nLmcT
z%7-wQqrdEqZ>hejDE}Qz*JN}1+C;cV`_%{6gIP0x;jmG=!neV`!S&q1$|-;3&@Gzp
zvvfAgO^MiN3bF-6CEo-3t)|#5MV=h*m--k^*sWE~Lm&IZKt@J$gMR03N#%oa_g9Vm
z)t}oboNjmZBewSFNqqnr4h}#c5=JWeUuph)BJ`}SHXQbN;w2!8egg>mg8OBvb5puE
z>fv&8@O+)MIM$m<4sQ9HYmDgZ`MRtdfzpzL{i{@UaWXfqJbdP6j_B|8oPw{rL`&onKjk0q;v~l{OH&^SUhqWglnM*p|?MiddCR1!Y6ZTTinGkz%{kK}oS=Qjrgn9H5nS0HpzaUTOxQXVj4C)}
zO$q?KWU$5vl!bd5FW)
zOjy3o2zBI}O&bSG$v4t>Q)z)!b#Lw7hnbD^_@?HD
zaaS3Ax1JR8&FXFY7V!79Z{z$rZV7_VF8!4@(^T=KR@^oYDW8;|gS~l^fEot;_XE$g
zz=xKE9BMbFd*{Ra{B26?CavTYrbPg83OshyD-Ls0!t!@-p-K7h;BaLC&p1^Q$`FzJ
z?k{r4DiZMGqzx&0Pp9Fs))VP$tS>~HAq)LjjUo8l>w3)M76S8JYUJ*{zN!{t^(2aQ
z=L|ed=W(~(HO>g
z6vX)dq;wI8d?sP7TJHX_N-RC|qs$z+G$?-V8~qt(eWpTwc6e)mlH1KO3t*EQqsX^dcO(^M$E>Ft=Dn%=6
z1YYEP`VmIbq5MVp7~;qcbK87duU3}ztsQwT(#;*->eZ(B2a;1zmB&xR)MTJM@~Rji
zQ^q&69kOe1a_iKkwXOF2u%a!ApVZqmtpHGIPw?d{;$vYA=}UUgwL;uIUM&zKVHR&P
zuzDcQfs>_vBu-gx5f`mzpO?cJy}IeNHV
zO}c1;?d<_uZ~ovPXi$}@@pyMkkD?zusK=jb=<$21se>u5Q2?
z=waB5>fBPCvM9t4u(<_wkO>FyM(2LvK91#Gf8hR|s0HB;qVqJBdz=H3bDaGz_;{wu
z`o@TfV!p~3rzQ?OFI{5|Oy7Rk{mr`jK?v({$fs3e#rvGt`*w`~qRrbC8Ss!)(dXT~
zQ`$PVlPx_O0$X0Co8eX?f#kjmMqla=Mhbnu$GKVVYenSX;AK|%%JAC+=vSl5A)A+k
zMZ(Jgxc8!7s6w;wlSz0I^n?0f9>tlxS)cddpQD(P64{h13yr{Gb{N(qp?)>=Nu>cb
zM@x(v-+L&yJC6+mb&AhNG;r#m1NQE9mT*?^FlqfG*Lx5N0i
zGa&V=V^ad>7%Osrape&}s2{-3J2v-mw*AiRu|o{Hwe&^>j#kTD6(zWsQb60AT371M
zU0?qQzo4nwnCxoi66jP)!hxRYpjT-g<}Q<2pJS@56t_+{EjF_rXM;D4ea7Gi_HyOa
zA?UWZabmiiH?yH3D!F*hH?-8u$A&pKNk_~2kWbWmEV?@jW$KZw*pBtPi`y4utYypg
zd|#w)X1g6VH(zs**spm@NO~pQ(RkJkGz)=)Kh2
zs)Pz#idVc@QKu38j$ec@wx%ZHu6fUgh5?&M9<+n&hlrZ?{4zdU#O>@!%4^&$tN1y<#ndWo+7U#m`QdlMEr4a`%>w3qtxXwK7^ICOV@msZWlEXY&mBEQ>10ZdSToJv
zXCEDY;+C0jKFDk}Gdy4&jr;P>a4vIKc8lUbc$v~SA6nB;H1MK_s=jMHg>=#@C&Cqy
zK*@n4C1O^OTpO-&Uq-Iw?>Q^E3F5<
z1PpO=;1Oo;{*ySv^yy%Nk0(CaYV&%zlGJ=l-Xr3VK23~Pl)M6JgC7
zm?=DQJ;F=un|*p^y6)AWfZHgn#Bt(nWTYU6nWgiGj>cneiv!qfvnMy>yFPC0IZG(w
z$pdVed^7{VmJCaI0YBXbN_3I9febgA-*Iqmak_mr6f(O<7kULGe5h~>b#NtP{nQeN
zL%6O6;NU>olQCrXR}YYyOVdi~DqCv;AZXo17QU#jcds_yVto7(H+W~8SKsnh!!TMB
zGqFXpSkIO;!5m`CvVhWOqw;Ug%@^wORFs%j$Xp2aW-@aPfzR}NH`xQDr^gsY+Z5<_
z*>Kj=ndLH3CE7$LkY(Fpf!H$if*(WE1ZcU6MFdQRi^<}^G3yqs?8BnaH!V>
z1%x+TxcksY1hPjNY}SY)vh(cO6g>#D9XXNKz7~GN!QBqHp0WSK5
z64;T{l5C+78sO8E;kzKvkl3$~LIeMh&t+a!!#wKSii8wq_$DvH`*=|?b~6}S)Ebtm
zc};c=gf4}^EJtl=cRg&0#JYq
ziLFtAaQfm-bG?*=AI#)^d9G1~Vf1wcvf|emzNRg>bD5V&rA$UpJ4K}h(}=CI{HoW`
zwZML-%_pcmaeHQ1ei+^=t+JMa-7ziukqxDGxln2
zM8>rYKnxGC3>cF!nh}i6ei>0{%oCvRHMZ)@HGcg*3ZB!NAU}Ap)R;`A_Zur*xnkD;
z-TBn)>BZ`p>+Z+VHU#forZj&~L{esU!*kVB1c4$I33-CeHX7a&>7-iMy~$YJQ|EnA
ziBUKaYwBZSToR6GftTT+D7Iq3&+jb{ML!?KE~`MDZ^gah#m#Bq;*87J!E#qF36vvg
zq*pX9=#^eNinmD~v6z)an?8^H-`;+N$W3YUG_5rhX{TRA7NmB^ohUuQ2#&!zn?yN2
znY`gJ=)GU+xt|oAhXoKcHO(W@c>qsAGsfA|&X-`)a0N3xiq*H!xh-FM=e}ta@#mw#
z*^kopk30Geu%iXUWePZBXdG9!TRODEu9V@sI5UTvvd``BjS-po=7;IDhG&_O#Uu
zS79_<_Zlmie^JkUGuw!oW{f$6`t`0_Cj7l1+I6-}tVh_a0Q1vhC6L(}W(_hqIBI^Y|*}>?3cAyF1b*S30TFt8>3ataX=Zk!%o*DKf`DMxwCKIjVFKuh9kn
z>Jtj7w9hYOmCwH1kLB9BrPxS*ajtc|we`#MhEFvDY+dNBL5_1OM>xGnCu+_&aAs~)
zk*srMwpJm4m_)kG5r-lQexN_xK82*+U4!;*K|P=FQaa_mMkXB@VdCb5KK#M3C*ZJy
zlG%s?!SvbqHLyk7QXrWfflcYi+A?c$qLW-`bNexNI-b(BHunYu71i)Lk-suZ+)-V*
z6-oNMFTZjLy13}zc{HkZXOY5uTTP8&In=jjeLlEoq`(m%SxHz|3b3+fGuHd99_SQ6>`f=ba`L<6@
z+_mXlvZ0qQ7C+^3wWYksqfGz(-DTT@+S5%36GHOiFH4-EI|?trcY*XlC_KzcEFi8T
zhQ2}sW@vPnvJy`()=z6C@L4~mMV;#tDskwG1n@uYgqMwmW+=U{MM>fG#HKi_n#I*{
zJzTUUy`QK%=KXLJoO%5|KmW!z!?ECFnx-dTD9zhYyK6n
zt&H*sx&4$+R*OKYF&|DJ;t&MJ4;qtsoT5m1CSy0pfKsnWqRrST*lPnDT!kmDMYs-k
z3@wiqQ6@uR&7>|{x#}4}jfUp8#8nzGLR%sgY$o)tgWa7457jrsyWtXGmPbv2wDir;
z;;;X`50)OdPZfy&a;FN#KMkNlP8aFEXnqnKrT~}5|retYECx5*~&`;@Ar$b6k=bhp{
zKeu^P-XJ|-D98_2`m|lhx`*vN7h+wvpQ^R$CB@JJ$1<|!Q`+iY=I*6rn!yEV*$c9T
zcN)rC1rjtkH9KIt14&r+KA3}loO_j0c&=CpW^a3%#Y65(Bt|AMi2?16p8
z(|OMmcufJ95&=JdQW_sPK6!x+d=9sK!3hNn3>R$=t`qPmBh(mD=WnLC=^uC@9=oaQ
zaCMlSsoiygA9e#rb-cceoD`Lz{d|kM96)0(M^j0(Q;?tjYSdt*#XDjyIlp2x8xtin!_OgsNT})1
z1*YpHu@D)Sj_q?md6>*Q)(SFjb$*YV+X8g&8UQ6Q
z_MvYHdO~FDo(`Wc2T$B-=ayBC9Ld_ZT#^q#I94n)YhV0!*|u~#7OcBTPJpJYfX>Zs
zVI;?|g9$>PF^QIz;movd)RNq|igR{uU!@v=P8m8^?!}WTS}%K`7aiecXH!%^uhrMhi8Rp=c#?kGe
zw6V(>eOvc|Yckg*C1_GfdC^{-;g@#GhND!Y$0k~c_oJCm&4P~1fy?&pU(8?R$@oDD
zLZZiG!zb)YeqxB*y^&DhP1mzz_*R7CebO$Cz{L&T)6w~`=U*qA)Uw~sjME&IBMAU)
zTt1ns@qXE!B@`;C#~aa{=wxkuP*f7!;@6X^)9QAr*_*4j-Is#O#{+rZU!M&$+4O&F
zGv2&M4#*(Iq?K<;JAKTs1StQNpROs6IR%SKpxftnug$liP>zNn56QroIkcQRLd`Hq
z+4wmX|@32j_YX
zFl4-2fBj)ST*L@s&)_Q8a4dgf5&bB(EbsJ=V)KlFHT&s)hQ={hx0*QnfgLe(h3uz&
zLSh1I_ie!7qHZrMSd3AvDO}zpzd8YIcqZLYSy0_&XK=6$Q~OJU%$wliFNxV$G!Pn_
zqR7>T=UoP#Qz-C`_yQYIM#ue_2J|
z8(O~R{eq<6;=Z^EL2UYG(uhM&2CBD*uJJ!vDax~h9j|dS-OtVH_nnq((vqxs;oL5S
zt;)@-H2W3|ILUx?wsj??dpZ-=FxeT??)3#HyxPDYjm^Z36;6z4B?HMh$G|~Dv02t!3)#bbOXnxz+v-ynrq1usOc=li9
ztADVt)}!HD4o^L>lD0v1Ln_IWbs)5(k^<7ygglpgY*^N!xZv)hRo(f?zEzrxkJL6D
ztpoP~(K9YS
z_g~-Wdrxht)9^3U?xk|>4>&)Iv+aEMuMYiJ*bW{5U{n-IvZU!k_j@X*yl#hY2TF`A
zBjsi~w;M`A^6~Uf+7NTS8Rou`ow+F1Q`ufK5)FAXu&BqAx9e$(_i%&9bBtQ=;Uj{{
zOwxNbNI9I9y!?sv%ZkdzD!I^{Ksx0Nw^4^gZ=p%AJAZLs1>38C`A7d`|G+=A;YmC*
zHYZ)O(doJ0&CeXuhY83)-FMx8i7MVVpKdS6DpHj8mAf2z#1W@%k3wL`%~sm0q5|fb
zLQS-SRTs}*Y1A5TSqTw%7YqcELE8nlN28Ow@)IEdTNaGOC-V+h^{!wFoj~uV>Idm%
z{Ad5hXZR0VeH%YQ2zVK+;eo|lyrU>oy#wAc$T5S8Q!LUTB{kFeY|+g*{2Ds<>bQn0
zi3l1>8yOiXlQDgYi8sHFf(@rXp4+E(CzG>u?B4ikS*E29xWxL!I
zSPc?iMc{%E6fq!ZoPwHQg^ndi2A0^_jwWt50
zQ3%0b^5Gvc;Ck0OuZy)>$unke+^pL3El7gBCJQCICA+IVN60s7oOT^jTR&5g&H8-T
z>&z5ze?i9Q6rw7x^f7576gYC_!uWlV#rt$i>vtV-t6GCg>RA%A7d3kwkjTLO5^Ha8
z=BJpVBKA-Uo4gs60GdMn*!$9{(napp4++)c@jlR~?(R0to@6jS9=dGo?(Tj8E#v60
zdr9#3G5?o^S7qpx^QuXAY1c1qB}3woyi9vcs>SW>$RAERCmmeXVhr2lOY+^Vfcw+7
z@JRQtr;3Nw=w_2i?{G-1&+k>L)DM@WYqu8yOrkiQ!J^Bazg$EB0|Q;$N%XFwdt%<
ztJ-6+YC}Qpp#P$9ZndT*)L|_)D9}OiOi$<^e6@cJU3lWMmb1MW*it)1d+ONHz3e!B
z*ttNX88aJPi^aa1K72W_K)dJfOXp{`+y9{ns0L+!E&j62{(LlI72&^YLy6mq{FvE%
z{wyZ@*Z5OfQf``b4W2%UbB6*rkkI{~NQ^P6(9G4f${82$^VdwqQE6o`kJFBM$k^S;2*{WFiV7%^MCd^g1Xo-)U3_mWBW|E@i}3|n}q
z-=pzlTBFP40t0KQAXY6@G1SG&_~ggdm~c5{o&ouN#JJnKa4u}kcF4o
zcQBT|q(;%GQH=eEb{;q&s$;m^Fn>mY_md0lDt_5aoyiB2KX%%4PK4v{Egl8}=rJOh
zG^;L+-5Zx-D@4B?olOG&_y-qeKLl3u?Jc4s-3|eM^cY`E3N~}p7pHDs!94sOLYf*H
zbXP5Qhd!yp#P&NINq=ezJA!8c*N!GEBNO%Pa=!-4jm`1XbJ%
zz%v1p+tPmb2OC|mBit=byT1XZHyq6e>w^)W2h116>a&iv}RMiP8rjM5-i(;P)entQHWM5~7c
z{$WzJDZY(iROJ(1xGPx5(Cg0d;0puu6L2d@A=0kWe$TL#M$B2F;y*W=AIWP{a3@y!
z!vOM*^ljM*5~G@{wv3;gnMos#fXfWATTQ-0M@H-?j?8d(J+hveox6q4Bmi3;Jp%r3
z6~sgI7#CoAKOcv_WV-t}8Ibf(=5a>6YAksHX3{KHKLb3t@ODc^c1G<8eN<=zONmVQ%HxR~)DV8Jo^ABEt0F$?W*X#*RYN
z0tY8Y4)t5~r93U&BL37FZxB4K+^w1~1ZUiB-Z#Tk2Ni6w?iCPe%b{o%JNvIbWMpQL
zIo68hRTb;Is0gtAq1{g3L~4&)cbDOoT9Y@TLR1b
ziJRzum}1|P(VZ?J3uC7SrOPY~5aVr@_Tl)rXXvKlZF3CyVadZLa|zua{;+JmS4PLo
zb2SYEBh?U`H^_YU#gjQqQR^N;aH(%1{o@+k29mC=BYuh9h6FeF>c=g**tXA<J%
zATOIsc2f|rtGo6VI(2W3^JgY8!&!btD2cd4DKb_`a*~qxx87^R?Ypp(eaPQ=g9ax*
zRz}eH{G@yPF_sWLP<;K{7vkWM-5?9%mqd@Eqmyo5Hz-saja3(Bsafh!c{lKVzY|~V
z3%CB#FSVNvnv?zf8Q$;%4y+gY^?MLN5z`Kk{BN!IYZs@yB>QmbUB^%BQCWO6X#(8J
zO_`G%XWO*?7D61=Sh0gQYZTT?g3Bt=FZ0e+4$BR%NE6KbH8g0yd&df|wU=Jy3HNu3
z3VQEi`C>!}6M5`>o;kYMEC6l$_5KixX84@UXOWjOGoty}Xk-Y#ZEm9mHopF?8u0lD
zfUiRzmOSk|&2saU9u^Ij{Tw2U&54dok@DiC1rg9q~=ITV`5IRBJZAbv`9@cHh8yeQB$!x*xw(k{Oh7*tHdX>Dya
zCL@W6unFV*A(8Cn-@P8?`8jqs`L)D|GR9eUgjYy9xtcCLV}A~OFk7O}wtD39&n{Ou
z?Gj7>VWk73nR@gN(ki%2pS+!LN0k@o9t0daseND>O8Hc}p4&_0+Z9r>z+@1ODn=VH
z*i(XUTbQue^j(4)Pl2X)9(=7t_TVPi0DAi)rY={K45>h!VZAfKDH)?zH+8T9%seL5
zcS?=dKIwES%N*8!?%5U1u!{+=mp*-rC1wAsl}ipb`o9_L8F~)==T`r`mzHzdt?%im|WALm1Z4
z@bZUcRGVHr+)4R9fqc;30cKm^0g@lZ|J`vD(L(15l)KBAB+lQm^0Ly?8sUyPR~bB5
zJ(}hW&cTZU3E;k4(k7Zf3Krrk(KE)gEWB0SD`XlK*y}QihZ%B2At1pt!4$|8;l-
zDN}VskE(mng@>z+x{3-hUnu3a1RK=EXl&dr|FEcc6BzJ@WH2?krbhb?|0~FihNw)D
z*;U-b29I^!xaUR*)7q+sHpH1738bxOTv)GbR;Y}Au9y=l=g6@shnB9QpyDciaABP4
zF<7!&p7eIWx!!+NiKL6n@67<*H;o}c@GS33;JI|$+flfA{ijV>5%I8Di4R5oJcHni5TH6|^m;;jyD%C30NJTAy!u&%_BddPTakgXO%{
z)VXYmM2Z4sfdCee+lOcq5^)`#K+E53T0({2aG0|&YmPiFz9GR9v&5mBU?7paiHVvf
z%3?>z(W
zKR;``TPfAi9Je{V60&Hu!Nu56t6)_mdD&=GYT9Bt@A82NQEhc=IUI%eBx}Fv19o@b
zHwD1Yx(ci~Z5ZzAZ=)F#E8G##QtR10v_p{vg+k(lIIskteN`KQ!!3|u^6?{qLRQQhXCeF%0@l2WB1xc9
zAY8!lW=;tdQp1Pz#bA;;9OCx2=!X)|kJR>cNC}Umjyo64NaU^R6=kblJ&$m1Pz^Bxr+|t@*o*g#G02TXf
z@MeGcx-nSL{AWZTjvQFm#F)>WlKveCEsM7vmwn?M(pEQBP!xG&E?8G)CywxJNL*R-X%eZ=
zqKZy9Sn%r+_p+Dtbg}-*OUVjMe2Zie)ixV$0vx!P@ZYUz8>SO6s&Z_CH|1n}cV#HW
z;3!DLv@O#*s?aPaEL=zdy^Mu5*x3xZBaet0NUE7E#L#zX!siZ2Al#N00+Reomiv7
z5AU}xz>eS=4x{#62NYUlKh8HD>L*E%uV_w-71I6Ttj&z9&1Vhwr>?C@vhi>G3N@_f
zV^mNj8;^xPzEw(nH#IeNw*Be2mKTzlNk5UVl$a|o99Ll?1sw!Wn8nX{;L36EG;Zd2K6gD_wQtO1!f9EO=Cr{6A=ZEkC85Vg-`;$)clNX&T%JBti
zlkqeVa$F92@n7j|-rV&^w`p7OYk`u(!sJXcZf5rF#`nPQO=Yt5yr+En4|F(8r}k=8
zRaF5*`fiZP=_%-R$$~=a=|=CsvCkb-{R4$7R7;6hh0Au?7;w?01jraN_1RFZX6KpJy?$$)Op
z4WazUF5b3^`*PRG$hzptlQw4Uf`4;z{4%6{jm==%YJ*NE;q9rF-6&bAKo{|Nb*hOn
zu^c?^H4V~+5fPZQ*=-;~8H_^AhbBt0jdVoa*ruGY#*rd$fv9AL2W
zXich&1QO}9SkIJlkT12mFV8tF*8|^nD>PzP0S{U7Go6JbW@1R)yRyzEo^F-U+u7mQ
z{jj!i0jj>-H?-bsUM-qTV^3$e5Hos#V4lKBSo_?*&C-w0tj9PMg%geQutGll%~t<&
zSbCj*r*LoSAMg_zH
zms=rmh{SOiOtNlVTKNJ7`t&b%1ybUoLbnP-Iv6>$7D3K$bLQEm`vczX1&QnhnE?gD
zWDjuZH3Tm^5Tak?OQP_yTQ2f!@alI%-=(7v%PW&w2c_(Zdrz*#U>IAvep5Uaa#%Au
zTRdk?-5;-n_^e4X0Q!pCA!8
z^;6bor{fqq0tO0nIGZ9(0Vfv4>`2wY^S?7nr*QC#Od7bqY
z2|hUUHA3<~uwq8Rf^fvgdSJihQZp0_yC^LCLL(@ZKJZRmql;5%;H)DD2Fh{7(2|53?X&9AN%+Z`VNw
zPBa{i^%ZjKKN*D)x
z@tlboHo7Rs*seN%*3&lk*??-C-du%*xp~LDiq#%^S(xs1;#Y$G74KkRTLqqAO#Ywd|}3j
zozHu&pfy|uGA`W?EKXb=!Sd;@gyS#ar|RTEC}u)U$Hb^#&y){A58N-b`n}2g-Jfv$G*6AJt{CS$QjNex6
zq-|Q;=D>kUm|a-C{mX&UVO@_WpA)>$5_3@7OYWG1CuQidTSLa4Al{@`c|pVb+}dmz
z)Z4mg=(<9mYeGOvWh7>uwz5tDqm*8T+3w%Kr~$c!WReR!9R#ND;hf
zPGKzF*Lp+s@@|wpGG^Cr%Y1Yv_N94r0ztc!PNfSC=~9~+Zd2_3tCK}NZC#J|u>wJu
z@Pq7OHA`yrNpspdRcGVKpo(D)ur`jq!~09
zZ(^~zkK$`PvGS=5P2TM)@=ui0p55pL6J+HY#HmYuL0mn45$d}k!^JTo8D-?0T0q<2d}l)?!hYEL~sbWP%^`jUx!i-n-bf6QGMM)2QA
zmLEI}Ffq^w`UFqQdOe=|wI_FBhKGN7`PiZeGQ}Bbrv^LZ+0hj2n9ZCxEK=rwjOkSR
z^>P8*Ki@6jdi9qyGu>2ny&@6oYj))66cqD9Hv}qktyT`G&E57u_7xwx7aB?
zfI9N5J4|UaTZ4r5)g|<#(pcN>*37v?CJ`91xlQ!C;sa^rbT=kv(e>|dFTb19FiMq|
z=-;^q&m^a|83bnus?c*r@{zsaDpp`*DvHzq?tOho*EPuFDTzLBuQ|_6D%c(GwiM`W
zqd%Gaao6A#>ykE(s0uqA5pLuuI?94Nf0p{g&L%^5vY$50sZ!`Vn;I;YvtZcZWNCH9
zmAM1==(ejseM3W2FN?cd3GXK~aGh1l>=xkn8SvNbO?Exn9Pe|b`N$+G0FU=I{kQA<
z9b21u?k9S_@m5d|i>IXTLS_}Y5#mEsFEGSk4b>CQon>zsm8DNUQ7v3G`gEcRuV
zF<%>pVvQ5P!Z{LhVZm~umKAXMzudQ^$!i$Avdb(C`Div9^
ztmOzkPxi-nh-hJ`UY?XpgZ0sMlbC;-4rHcEF)P>E%$Wx$48?m0=(~g053ZfeW_u4j
za`P%S>goLaWJK<$p8vsolztb;la;Xu$m$O+CLVRn_=Q@IH~>7nNQNB*xaO!1Z~r(n4ViHp1o5_)&NDGeTF{PL@LS7@@X?LCI$aTb46m-^Q%Sit0hMz
zVvcHsypd%?DQprNa-Qd5oi8Slc0@SxhvNEANQE5h3Z&j=@P7Rf!8#E5J{6e$tYGFO
z1&@7Ag>2vBO}-dzMNKJ!c04F88MMP-Vmv25b=bX}zOp7PHd9MSvL-&@tTcNDzITnrd&fAG97sPDyP=qtsR0&^
zD44gycz?qd&9z!cm~PiA`wWhdYHPpJ7d
z=Kt)Rm3*`4CIc?Cr0f$7-sPoEqB%D0ufB3m7et766=Qd=w)L`#@?gAZ__qFys`y11
zp0;9PuLA+GAbIBI4iT|RRkh740Kn1gX{i?)(7`i3TO8MP@5RvP$4M{tvsARHFCM9A
zl!}*}_lsQUE6)y9b@g{NlU5wPtliyoJ&Y3=MN0bIYD$I6(+@v075zts0^9yV6-LX@
zksTi#I>2}RX2OE9J&JGUk7|CM+-H7WqjFeP;eR2hI~@3QtUYJ4Eb;&7`VMF~yS42^
z2tw3|AbPYQdM^_p(M#0Ph3LH#45CMm-UZS7=w0+KYLw`G)KO;){wMEw&-b14o%63{
zS(fE7&)#?4_kG>hwk))@t4}YdLhUu;eEc!Bsz0)1jmRH<#=w-->RXX8_8H2w(m6k_
z^*Y|rp_`3NsID8u{OkQ8>c?}$ya4{!wQBD;m$jN$r$Hec;lacc5BF1ZwuU5p?@buy
z;Kpt)cjo5R8L${Bx{l`j(T=rf6-QI`3mQA>mPgQ?@zqs
zxGJd8EE@=OEW;aC^!ty-x;~{QsOqTDxF#nqtpyng=c(^W5-M1_clxW~PA+kch&?5$
z9iMV#<=fcW{FWZ7K4Sx|@B`9je~8rUvNmaD=C}u>qhDJuGT7vob!gjfPJG~LX&e@p
zFPD7Jol}~Zp9r0t-I&galzeZhrcE&jilUiWY~4;w64rZ1ml7uOV!R7oF8FDvj+wzF
zOnP%jng7CJH=wye_wFiwO8vY0qCmsI@!r3tFb|1=K3rI{ttdW2;2V7&wK8f7nDt0g
z3Kdvwujcd}SXxsGwPs(Mm_G5Lvf4#nQJ-G#5zfBK@$H
z_w1Cz8$O5?=M;}&+HcF`u9@=;egLw>oo4j5^Q^u+_0b?xRwvV|LZYGy>-c&Dq(V8O
z^S7#D0JT^(7TEF4Ve7dmqGCCN!7zwnq0HBNenT~U6eAh!w!eKT=1bWzO|Xh^sYpByDT*8n*8nxE`10AIoL<#IL)`P;Dg|%ulfB^@L8YfE9
z7!nw`7~!*>*ySt6(6*C^nwsSwgyYZ1OZqs&TVS&`_9kMf4+u32`YZGs6;pvbBTK7S
zgL0m_iMMODU3s*|+gFvBjD)F*H=NM_%-f|OQNQ|P>spOG9dT%R2=kOaMvC?#ZGY|1
z70nxPWcf7Al!oui&>duW;XVs`pZ{ne?tMFv!%~A=b1A~O1R6?taf%aQ#IN)jalfd%
z!xIEf`dD!(htZLcWos2@KTl;c(pp$#bpQ+bAoTe}EqEPMFuGK?QG>tSvb7?0E}Acm
zNr{p+wY;wBXF5{^b$|M|R@kJ=pxGlfbXT^;rYbp2@1~;2*O|Kwnancr6zE25uU#c!H)Ak_pZ<2AzZVMS4aOO9Hr#Ed?chup}!SwFkzehJ7RA3Kc
zoEJ~joopt4)P+v&oGWFCy_1v1jV+@nKK8ajgAuAWw$3c_C?+YAE6x&{lwIc)(SNu3
z_|3*Z%kr6Z+r?+nv1$sCi`6*4n&0M&nbj0B0n_9ND$o<}GB=XQJ@SJ;MeP6m;^f3u
z8Ll~EovBdA6c|xde8;IiG%P9z>+}*vm#rY=OG`^LRWriPPv%H^?em@Y-4CK+Y&jFP
zR;d+R(MR$F_t2H?<483Vz+>DhG>)MOj?^t`yXvlje)CNq9tWacROehfNmW@X2i8~D!o#vs@DLnf;(a-fAzGR&>)LP$SgPy-iQ1a@gf_PJFxt)~-
zV$~ZrI&WC4a{F6=%`LNfSm6?J-LCty}JJS
z^)w;}E%{ZWBYEJ0FX~(fv2u_wAX+41)d(4NkBUk0icGTAwQ?BgsWi5ZN%OtSv+?Kr
z{tcIII!N#?W=)i3S(7!F^YJIKhTq2vZ)JZ%bDgtXdLgQ6ziCWpsCMJ`o`T1tds8#U
zM9(rscN-YZZ`{&^bZ*zB`{eZ%a|tD+qgms6gUt|=8o*ZCA3ex7(z#G*+^ZJJnA@13
z&Z2Q&t^qH3BAik8wuoxm#NZpPBR6pn$SBm{^K^6Hxtj9lm+WSV;#b~tpBfSF%En(M6y`<5@3JkO
z#@|Cn_|iSLZr@p4FYraDTDM=;C2iOWc0;>FOYfSNzwvDB4INeIPS{;8*$br98x^Ba
z3+^?98Dn?1KjE8w6i^}_jgPG>*L~0KI}8QOVMR&~*P_-d#u&?_HS}5tEYA=NEp2FO
zOE?k9LUt3Jo)h#H;5F!)exs(L&>|R2YsAmrN%t_AK=E^;*+PRHiAr~C$y;0kMQ-hs+u9ybZ(RIi!a}zihT-?AEitQ5>|8g{|St3vPN^w
zB@5~{=i9pT-by#eBSX<&vkX5;Te+l-*|!}R4F_2i!f>PfIE#$uk04Ie$l!+IMX%4#
zuWNla{6!36wX$x0VdbltN5;z2MA$CqF^q|~|B#t*r$HeYdcAXZo
zvSRUx*Y>c@_gQh2(@oGvTr?e}(`)Lhgr|#U_xcrQLtEf?qhD|E(`c1JR|fMi*~oNk
z$jh%c>rLAq2Ph0vubaj?CmnonHtB1sHmS=(LR$!U&{Idwi-SsZYHwFkCuzK?U-}|@
z0w@g(DS_!t|RTRDze(lF%GjI=fy`L%TN_Og}zsP!ZWMOuDPad%T`
z1D>2oeYSsFgs1l$Zt;)`}
z-o}%+HIhL;i$ZQY?a0T{uCiMfwo1I~nua+FG8*k>^Zx=VV6-0#DHDSC@s8&QC
zbpoCnAFs|yk&}ziZCPF$Xxu`hx
zD4X7VKu6)g=bTKwf2x5)e2K=s9hJf+I8mKC*-#!VK1AF<)Xj@p_Q6(p#H%GIGVRHY*B3qCb1I79CrV|JC)>KGNr
z6iHmSl9Kv_LK+OF;1#XMDzV+%GxmOsFO__e}rpHvTJEJx55_ON0G%?-nm)G5I
z&ek?j)++VJh_0`XqF38WVv1;=TLD4EtEZ;5^*GmWDbD8u19A^a&5)!pUUvfkzH5|I
zG{_Yf2~G5o66_XP4R^NmAFZg$#va^xXt;}zob`pjy=*f*Ofj3<);p5GE|nwuH}s5A
zHqlNxcE{`Qey}fH{`ecRLobPDVt~#%E?4zE7#R8B*rpuKoRgHJgy2c6lgTaH9Q=0u
zD<&b&nyW1F#E(sUgPbliolo+ma~{&sIpg3K?Y%eCYr(Tlq_}+HA<J?aNKG$L%01>>O8VVsG3t97}YkVS9`$T!m)
zbz)A*FyetK%zZkT8~y5Qaq(V+rH3DSlN^of?_nMeVRe2JWKFqi0qmxTa~D?tb%DLz
z7jfOhzqL@omh=E`nQ|uah-q>+eqK4TToF>|?m~{dPtfh+Gk6#Xx3!(^Q~x#^2kzte
zLhbI73PVZen}`h%60pk~MdFpXhQ4(JBj(IZC>sUx`^EiPs-des`aOaR+7abJf_co;
zqcN{)pvks)Y#brcFYSo8QQ4E_temckWbswO-;#U7%O?X_%WsQohIzvSSU9c
z6a?E$STsdFD`Bqq(6v{0DLb2CYiHG5S0wvuG)srgJ^M`|rMkro|A&ea%RXoMf61v|
zqdf?_*E8JxI|5c?ixuFXV{AfL^u|nFG@_)7GGl!wMB1^o5%*!h)lRRl76#EEtG|pk
zD_1E?;(8aavj?YrVM)S|&&JS04dy8hb0=MqnT
zbP(hDTXj_)2IkTz(A#58%LmjyIS);?+}uNF#v{~V=lnsSZ9>48R#|8MY&5uL={I&)
z$YY>dDm_Sj>yV-6*i&yh(S1_wG@Z)-_9@BZ*eVlgNtMXKB-Z(IEdjGL<|4o8Vka^Y
zvzquMt$u)%zADiIFMl;!;LU!LVR_(N)|rP=DzwnHB_ig779klCyZvWHAr6g?wr5DI
zp52z|ws)3t6eFf`EZ8RE6B5XWrb$?}D41lBz(tGQ3SC*8AJT2+sx=-xg8K{8DT3*Y
z>VN0=47UKH!YGt@;0Xj0pzg88}Qs4Pj?lSM3
zrm*as?NZ-vxqxeC(`s+{KOA&E5+
z)%O=T44xuSMReF_I_J67R4_T_wJZ>BOo{Y4`JBWNR9H~%ajFuBcC@vO
zVy@{vh595c{IXSFw1iVeB(2Q_@o8>ppYM*ls47^~8BB;%ffE7NiC$E;x-37Ad
zCoos5${{}LW9fx*(#vYK&Yv?P3DIHyS`3lNrY7FGDyyY7)H5$xngE9+CB&o{mw)~a
z1T^|g?@%4`h%QR3hp&>pghj65Y{-+JLOL46z!2EOnI8;0bI4kVcIBfd3X_f`
zG1IUGs0|igVIUfbaM2mmmtR0avs_mnYQqPd$bu~sg}S6WV8<#&g|Ct-+q>h<4U$hj
zo7{GJy6$;lDfv$!nbc=b)Tg4J74mJtHw|T66(hZoyG|wD06u_y{GELvLyt|?~o+UFYb*7QIAWfB!{eTQ`Cd3(1J
z7oEf)FCJ6B>}kkb@hCEmN%;qPP67dlsh=s!`{m{DyHG+>j<%gNcmc?eV}X_~(`RNj
z!lH0{f?K&;tnv1!elWe&Y+Vn^Kstn$?(w4vJ}wzO@EPNptkb3U%(Aj{q_5FFzNm1v
zs34O$jla{2J#eKW-TSlX_5LaRXSK4TIEngn6SN^uipuk2Y{WAzy-~4k+|#eR0NA=9
z-3cub<4T3f3uQ?k>V306xfv<2^fd?vKOr?$2OOk2T(f{)Z;S2yD0=#(>W+@Dl}4F0
z#r*xB$1P%Vc!BFlL149$6EB^Dnt98n>S@Kw2*2EaTlpmTA&K*T
zcA}+~MxBrREPK4GtrAJ#ZF8T-z5=N_mP;LqVT-3Bvr?-liVRDuuEOxYKFGJ;IRt
zd5^+lWu#JRnfZ-c2b;_U9sNu*+h_!MgV2Xe>B
z&?;cXgSiD)m7A$k61&nDj&osJzl9uka;pu7P(#>w%t!q=EyD2LNEa%h+d-P
zt36JJsvo~OF|26*3D&jR^0~}l3OD?u0r5P)Bmbrj1E@A90o+D?n$uGb2sX@SG=6?w
zI8M3jEh+n_L9CRQPrT2k;yBMC8H6A1PR4xGV97k@75vuDhwXQ5PD5pP@u1sXd)vJs
z{6DCBHRtJOH`BKnglg%1Q-yLt^}avkFC*{jW$?P69A{#Ubpq5%mj3AvnCQQEt$r+J
zCWToYvNn&AWx4RH`CCp1i=A@{9=?~5p3JzR4xzYTBjT!3!uy!#g4{g+0IyFtcDZ36
zi>Fo$KQm3kdr~Ee1zsY)%w`UOsesEhU$jQTsOU#=J6CaKXFJnf=z$G)X>M|wk_
ze)~i-_N?O+mh{}NyM-q4K;=YEERVy>zE*o(tzfhLZi`fKo7U_=PBGUSoay_%VQy;n{fGx$e1vS^#~g-NAbflf>!9&0=cPh~K7zOS{2%1@P9Jh9{c6tkD-f~BV(
z^B5sDCrdX!a=sI!$wve*)E=wjEKkP1D|k|}xt3o`^6sAa<|4*Bnwd>>^;|M~&ronD$BAC-olX2l#O7o11Av1Kml=V~hfOEv`
zvBK_TPYFFuYbL_sQy#3{jH0d!dgE2$OUsl|+rA%WjkDG#eGY~kx<_@?z#mmnx)k}9
zL}g6rHVdQ8Q=rxB1PB*6n#bkS_v&PQubdFyOvm8Hk!Rb;p|k?VAFnvQfA(J#C;$7v
z#zPK&&A9Z=q3n?a0nHymV}*L_Mwq?aSc!hx>Uy8~SZQAwH`VB9)xMrO3pANnvyRPa
z5iRm>*y*IO6wBvD>Km}Ugj2+--QV8ak{_rcN)dMrR`2@3r5Q&0rqp?}lRTXv*-qT+
zC}rZa_uEcU?RLtibp9Va=7Pd$(j_Tx3W@2~aRCcJSDU6!Mq5^?nw}~b@ttz|iP@@5;-4G3`G7#%(*V4#xgop+=jZ3!A#WKJpb5vUR?`cx2+!
zcpYI`jXRT0zT{&cR%+P(QyioIMNDFcT&Y0eSRW*0m@`M?9!MuJwQ563PK9=F-cXD#
zgsR?rFm}{;vFV#!dGpqLXzvQgt#=g5>$1_qmRrwtur$4kt@ybcWFCPz)COKw#Yn3+
zL=J=T-EJewgw$Jns59%vT6Q>3mCIM&ww(ZHs2vBwy-{zlK&qb|l@~
zW_0dd)ZF^sE%zzj;EOG-z1M%w0Sx1?mq<6<2^ixGKSN8+IU)w_`T+SB+No$CJuCVzXa%_ORtVS~(p4Gh1y&
zxp~Eihh1-$W!e;D>4%R76Bl`PV_O>JE}qZ>xDU3GF}lvs^lVu2D5pJ2&Z|!`nAex8
z5yto4{8ST1eD6bDE*%_|ydw8|ymZich$baV_E;x>sy)riS
zRjRKLUb~XS1Fb6Ah>!#;XRsTT8Wt(BtAo`z)~LW-#jbg6XII{p*@4rhLrATUwteX#pvIO*#Oj?i-|80XD%(!IwyEit?w$h|a7
zYU7`F>R_(To2LzZZ?ge~QXLyboldK3QE;h+#NE&=dJDgzka74@V#vx+L+sZ%7oF@
zdby+qfVr{;?6(`?eOmqW4&_j9L{iSu@PXx4k>>-48kcDf2wVGImtkbG=Q)S(*L1UT
zYp28dWzi}3YVGyv;^N-WND6+tuRfd_1_hxdB!$5Mz7K=W3Mz{HrRGNR5d^lPa_UE0
zUy<(7t(Bt$uIsAK)RA_*cSg2XXl((xp0FR7Zb#ZWl_|6D^wZ-LyYlDFB&R}t5|252
z^8D&>v@cq_)AovV|4B1|C;=cA4U@kmlVFp&WUgPTAChdkVF~7I8Vb8=^bGUkd(lrRasSRbXFl7DaU`|MM=oTDPal?~xwiu$F-4(rPy0jjZsTDgThi4Q5G8HbmX0SO%`O-QoLQ_t+LnPWtF=#JLUnH3CevO0KXzOO2`SH^Qh`
z%}vQU<0AaDD5$JX;|B6!uM~4aY%J8ySu`liY%=Dssf-@=uP69%Ei4q0ame9yyA}*2
z@)t6t$Vc$NZ8Tj-q+4=m0)VA}YN^!BS$}rdwfcx9B9+@y<{g1CM<^oXz5=EX9wr+ANY?xvI+Z1yt!{kye%i0hQQ_
zeD}2ZKF?O$dN`gLvkx7ubGSShp14kb2=
zl`PtRkGz)=qi^4hmvrmIS`8FV9@xTUYoBSbj%JX-;Z7sui5zWL#XBGpe%Hq%CQ;g0
zAGlhdkvwD)*>OR{DG4jtH6ie{p=KFjOYXON^k(yx>ADNK2nVo3aZmx}RF2y0SWSS=
zHg`-%Ib)1czuXM=jkHPYrZ+2DQgtp`{^SD>KpE|u)_2#`3!T5XzBHPj2^f8uHG9;SemdRD)e5l|$`s7G7eycdU(vcP=`f(HPP=TAbcb{Ae|2;<$vgely>#7ygw>G}t7JQCQ%u;U@
z+r7B8rMyJkAm*vhdd*yW<6jj@GLl?W+-3Dec$8SHm6+PFqp#P3>E225TYfdIpA6pT
zwc6EbY^@dF-Lol}woO|H=!{%!Cw|2){u|D|;~p?D%ri2AE5I*vaH05>CvPg$_8~@}Fp0zdCQ<+18x
z28Oql@O1k`98SWkT+IdqMv&R3b|vdObTwEs=+L4O2L>rlI-i5OC+#LD`gT38pVMym
z2V(9QHu~qQpU1`R-Va6*-taTYqwgd=UOD8^%coBhsRflF=k=#6%q4PzE3TqnxKOXy
z#t4FI^MP{QnUp^G;lH&cVqTk}J>lW0v}9Y3kli<+e?bm41nXc$Sef@AyZRL&c{*<I~uAMQ4uG-8H5RkBI&IKjAYAhw&k+KT)hey9k6_-E1JO{MvIf&c{1zGNSem3bUB^^q-|_pyIa{;RNTs*MahziQb@V%HC3{|gcL
z3oej?U86L7q(^Sv=5kGL-nVc~X{$jx#oMI#yM8@gS0-qnX7@s)@L(b}rQaMw5II22
zWq@*6f!hAwR;_o<*ym|gU`!;D;hGUEDYQ)lGU5~C;v`JE{CS{Kt&LaG3Ae(EA?Tbk
z9*3O_#)qxv-Gezqy?mKKB$({@VZfh&ja`@Xv5&lDhPR3?jsF_gI}0^)knlNA;5qN~
zoJvn!*+gh9H>|$2=ZVWu(|EbDR{bOL>CtDZ(J*y;SD8GtlG9}8NY|O{@%t6aFb8L1@-ZuoP@5m_K-d>AEYUPc=8|G-
z?i{llCd2;zZ{Jl7)iBIKJp>H7y+tZmlLK13onD_Lig>kVlU)bTqO?bYjm;=Rq)#7W
z6^Su?+)JoicscRh{Y%Jb%cu{#mZVkssdK&$tNFrTD}UQ(#X0z7|LlUFFGJ^}u;d2%31M?!R`eJn&*hhg0{^Aayvr{Ip=jVv
zc!?=>>(~0M&~L`jDH{WO(L(e0ij4nXItu^$iU6wxlbteHEUMRwbf`%BfMXIz
z@@p1x67!71S?79PdD+fM!)m7}UI7RkKp5ofQM825vmU}r7T{`z
z_2VN>;0R}asKAdsC)SxUn}`lM9uC7Cu6ka+y?8jgs#cYv6Ha&!HQQG+1x5Svc_r&%
zr6p2EfLh?cPA~w&{>)}>yHt`f!|XBjNo5JP8eOK#RrkrX_X(qySsfKv+$Fk)f0hj~
z(P}9y8YD?^X|ysQCOktQK4~6_cNd>$K6kb93}e|lPW}znkF?yJJ_fpFFZ7!jhX32-
z)*m;E{@YmKKYQaJ8G(S$lcq#jWNQ^`3bPt%$K!#(i)D!d
z184vv^4FL2gT?NXABwX6d+-7vvTkVJ)CUGQ4(=Qx&VQzLUoXFiv2^HvvMf;Xxt8uf
z_V8IDI(KW9*%#`<=fYn4HUC56kc95S8Cp;(t2+yx=BNltVEoS~1<{!e+zt&UxPjrn
zs&?Q
zH954^|D+mujZf%+Z6FcX$?{S7G7h_8@)ZD%JXl+m05;)Pp@YRBzZq}a(b~u{;uQ;-
zYC&Pa^DXKBP!oR%1sdJ=)wwQ|l+@j!aY;&CJYk