Commit graph

218 commits

Author SHA1 Message Date
Daniel Rudolf a119122497 Fix coding standard violation 2016-04-22 14:31:14 +02:00
Daniel Rudolf b133f6dae5 Add Pico::VERSION_ID (like PHP_VERSION_ID) 2016-04-22 14:23:46 +02:00
Daniel Rudolf 8dfb1b14c7
Improve HTTPS detection with proxies
Fixes #344. Thanks @Robby-

Implementation details taken from Symfony 3.0.4, method \Symfony\Component\HttpFoundation\Request::isSecure(), see https://github.com/symfony/symfony/blob/v3.0.4/src/Symfony/Component/HttpFoundation/Request.php#L1169-L1192
2016-04-17 02:44:41 +02:00
Daniel Rudolf bbd8ef8847 Fix Date meta header parsing with ISO-8601 datetime strings
Symfony YAML interprets ISO-8601 datetime strings and returns timestamps instead of the string. This behavior conforms to the YAML standard, i.e. this is no bug of Symfony YAML.

Fixes #336. Thanks @csholmq for reporting this.
2016-03-16 14:27:42 +01:00
Daniel Rudolf 0a4e7443d2 Fix class doc typos 2016-03-16 13:33:52 +01:00
Daniel Rudolf 3d11b8a979 Replace is_a() function calls with instanceof operator 2016-03-11 19:07:45 +01:00
Daniel Rudolf dc621b24cd Improve class docs of Pico::loadConfig() 2016-03-06 21:00:00 +01:00
Daniel Rudolf 988a23fd02 Modular config: Load config from any config/*.config.php
Resolves #330

After loading the `config/config.php`, Pico proceeds with any existing `config/*.config.php` in alphabetical order. The file order is crucial: Config values which has been set already, cannot be overwritten by a succeeding file. This is also true for arrays, i.e. when specifying `$config['test'] = array('foo' => 'bar')` in `config/a.config.php` and `$config['test'] = array('baz' => 42)` in `config/b.config.php`, `$config['test']['baz']` will be undefined
2016-03-06 20:55:46 +01:00
Daniel Rudolf cd74b681f5 Fix scope isolated config includes 2016-03-06 20:47:25 +01:00
Daniel Rudolf 75d5081bfb Use scope isolated includes for plugins & config 2016-03-06 20:06:24 +01:00
Daniel Rudolf 5bb1c325ff Add onSinglePageLoading event; allow skipping pages in onSinglePageLoaded 2016-03-06 00:54:36 +01:00
Daniel Rudolf 245cd15770 Refactor Pico::prepareFileContent() for better performance 2016-03-06 00:49:45 +01:00
Daniel Rudolf 479926eeb4 Add Pico::VERSION constant 2016-03-06 00:38:51 +01:00
Daniel Rudolf 43705d0f76 Minor code refactoring 2016-03-06 00:29:40 +01:00
Daniel Rudolf 0d40259c06 Merge branch 'master' into pico-1.1 2016-03-03 00:34:41 +01:00
Daniel Rudolf 8426a53f63 Allow Pico::$requestFile to point to somewhere outside content_dir
Bugfix; Refactoring Pico::load404Content() and Pico::discoverCurrentPage()
2016-03-03 00:04:31 +01:00
Daniel Rudolf 2a3e2fa576 Fix typos in class docs/exception messages 2016-03-02 22:10:49 +01:00
Daniel Rudolf 1709b920d1 Add AbstractPicoPlugin::getPluginConfig() method 2016-03-02 21:46:35 +01:00
Daniel Rudolf a8f0fd1f33 Merge branch 'master' into pico-1.1 2016-02-29 21:00:14 +01:00
Daniel Rudolf a2aa46fd0e Don't let dependant plugins automatically enable plugins which should be disabled by default
Follow-up to f10440b and c0a7fdc
2016-02-29 20:58:42 +01:00
Daniel Rudolf c0a7fdc801 Don't always check dependants of a disabled plugin
This isn't necessary because dependant plugins will check their dependencies on their own. Follow-up to f10440b
2016-02-29 20:41:41 +01:00
Daniel Rudolf 5a9c02f7bf Allow plugins to trigger events
You MUST NOT trigger events of Pico's core through a plugin!
2016-02-29 19:51:06 +01:00
Daniel Rudolf 56b2ed6c7d Allow manual plugin loading 2016-02-29 19:50:35 +01:00
Daniel Rudolf 4f487b7ccf AbstractPicoPlugin: Fix typos in exception message 2016-02-29 19:47:02 +01:00
Daniel Rudolf f10440b996 Check dependencies when a plugin is enabled by default 2016-02-29 19:44:25 +01:00
Daniel Rudolf d8be108c5b Suppress PHP warning when using date_default_timezone_get()
Thanks to @nem25 for reporting this
2016-02-04 14:19:14 +01:00
Daniel Rudolf 1c2f6a1b23 Update class docs 2016-01-25 19:31:53 +01:00
Daniel Rudolf 73078a3dc3 Fix code formatting + class docs 2016-01-07 03:00:32 +01:00
Daniel Rudolf c760205d70 Pico::triggerEvent(): Fix method docs typo 2015-12-28 22:41:39 +01:00
Daniel Rudolf 070da6d73f Improve "404.md not found" exception message 2015-12-23 16:18:16 +01:00
Daniel Rudolf 5be2f8e597 Fix path handling on Windows
Fixes #307; thank you @bpgs for reporting!
2015-12-23 16:17:06 +01:00
Daniel Rudolf 9e4af2cba4 Merge pull request #294 from picocms/enhancement/YamlParseError2
Catch YAML parse errors (2)
2015-12-21 04:13:07 +01:00
Daniel Rudolf 43f953b67a Pico::readPages(): Call Pico::parseFileMeta() again when a exception is thrown 2015-12-21 04:08:35 +01:00
Daniel Rudolf 3798cbe478 Remove page title fallback 2015-12-21 04:05:25 +01:00
Daniel Rudolf 329049bd18 Fix empty meta header 2015-12-21 03:42:59 +01:00
Daniel Rudolf dc6ac516a8 Fix Pico::getPageUrl() 2015-12-13 22:27:27 +01:00
Daniel Rudolf a138d23daf Throw LogicException instead of RuntimeException in Pico::setConfig() 2015-12-13 22:19:02 +01:00
Daniel Rudolf 0c85d70820 Adding $queryData parameter to Pico::getPageUrl() method
This allows developers to easily add custom query data to an page URL without the need to check enabled URL rewriting on their own. Since Twigs `link` filter is just an alias for Pico::getPageUrl(), theme designers can do the same with e.g. `{{ "index"|link("foo=bar&baz=42") }}`.

Theme designers, heads up! Don't forget that the result of the `link` filter is never escaped, so the result could contain unescaped ampersands when passing custom query data. You should pass the result to Twigs `escape` filter when using custom query data.
2015-12-13 22:14:05 +01:00
Daniel Rudolf 93f7aaad8b Class docs: Use default markdown table format 2015-12-07 15:17:39 +01:00
Daniel Rudolf be46e19677 Merge branch 'master' into feature/PicoTwigExtension
Conflicts:
	CHANGELOG.md
2015-11-29 22:19:57 +01:00
Daniel Rudolf 2ce422d907 PicoTwigExtension: Refactor error handling 2015-11-29 22:18:41 +01:00
Daniel Rudolf 9aaab5de1a Refactor Pico::parseFileMeta() 2015-11-29 21:58:30 +01:00
Daniel Rudolf 5ea94d06e6 Catch YAML parse errors 2015-11-29 20:58:41 +01:00
Daniel Rudolf 2d9b5aa1a2 Fix operators 2015-11-29 16:39:03 +01:00
Daniel Rudolf 698a249d45 Force Pico::$requestUrl to have no leading/trailing slash
Fixes #291
2015-11-27 22:52:45 +01:00
Daniel Rudolf 2761f8b751 Refactor Pico::isUrlRewritingEnabled() 2015-11-27 20:13:17 +01:00
Daniel Rudolf 86d1f713f2 Move PHP version check to index.php 2015-11-27 19:45:21 +01:00
Daniel Rudolf 81138ce06a Merge branch 'master' of github.com:picocms/Pico 2015-11-27 19:43:47 +01:00
Daniel Rudolf 81821e7811 Improve Pico::getBaseUrl() code styling 2015-11-27 19:28:48 +01:00
theshka 1fae7ab3df * [New] added PHP_VERSION check to Pico::run() 2015-11-27 12:27:45 -06:00
Daniel Rudolf 840d41bca5 Improve type hinting 2015-11-25 04:07:46 +01:00
Daniel Rudolf c34afad4af Fix typo 2015-11-22 14:08:35 +01:00
Daniel Rudolf d252df4b98 Throw RuntimeException on invalid content dirs 2015-11-19 04:48:22 +01:00
Daniel Rudolf f5006c036a Prevent double slashes in base_url when installed to document root
Fixes #274
2015-11-13 22:29:58 +01:00
Daniel Rudolf c72ea0ecec PicoDeprecated: Sanitize content_dir and base_url options when reading config.php in Picos root dir 2015-11-13 19:10:30 +01:00
Daniel Rudolf 10de8efa11 Move markdown filter to PicoTwigExtension 2015-11-13 16:49:53 +01:00
Daniel Rudolf f19adc64b9 Add PicoTwigExtension with map and sort_by filters 2015-11-13 16:48:01 +01:00
Daniel Rudolf 78ceabe878 Various improvements
- Reuse ParsedownExtra object
- Add new markdown Twig filter
- Improve class docs in general
- Document plugin number prefix usage
2015-11-12 15:34:56 +01:00
Daniel Rudolf f9e9642c22 Fix Pico::getPageUrl()
With enabled URL rewriting we must call rawurlencode() on the file path parts rather the whole path
2015-11-08 14:01:35 +01:00
Daniel Rudolf 2ca711ad59 Add missing rawurlencode() to Pico::getPageUrl()
Replace urldecode() in Pico::evaluateRequestUrl() with rawurldecode()
See #272 for details, thanks @smcdougall for spotting!
2015-11-08 03:12:18 +01:00
Daniel Rudolf cd7cd374bb Add content filter to get the parsed contents of a page (lazy loading) 2015-11-06 01:08:31 +01:00
Daniel Rudolf af8de56512 Fix typos 2015-11-04 19:50:44 +01:00
Daniel Rudolf ccac8dd4d3 Force trailing slash of $config['base_url'] and force existance of $config['timezone'] 2015-11-04 19:43:54 +01:00
Daniel Rudolf 90128f4946 Fix possible foreach on null errors 2015-11-03 23:49:34 +01:00
Daniel Rudolf ebe007bd78 Guess content directory
As pointed out by @Lomanic (see https://github.com/picocms/Pico/pull/260#issuecomment-153091890; thank you btw\!) we actually have to explain users how to change the content directory. This runs contrary to our "stupidly simple" claim. So Pico now simply uses the `content` directory when it exists...
2015-11-02 19:48:58 +01:00
Daniel Rudolf 9a702415fb Remove return $config in config/config.php
I always thought that doing this is pretty unusual... But now it simply breaks BC - please refer to @Lomanic's [comment](https://github.com/picocms/Pico/pull/260#issuecomment-152610857). Using a return statement has no advantages, but increases the probability that something goes wrong (e.g. a clueless user removes the return statement). It was introduced with 23b90e2, but we never released it ([v0.9.1](4cb2b24fae/lib/pico.php (L188-L189))). Removing the return statement shouldn't cause any problems even for users which installed Pico in the meantime. As a result we don't break BC and moreover remove a prior BC break 😃
2015-10-31 00:32:08 +01:00
Daniel Rudolf afb55b9cb6 Improve class docs 2015-10-29 18:13:35 +01:00
Daniel Rudolf e6681ea903 Improve class docs
Also add some ToDos to inline docs
2015-10-29 18:07:45 +01:00
Daniel Rudolf 54ce5b9699 Various small improvements
- Improve class docs for phpDocumentor
- Add missing onPagesLoading() event to DummyPlugin
- Add some TODOs to the UPGRADE section of the docs
2015-10-29 02:55:30 +01:00
Daniel Rudolf 647a7b5bb7 Trap empty $requestFileParts 2015-10-28 01:41:26 +01:00
Daniel Rudolf 9e2604af85 Prevent content_dir breakouts using malicious request URLs
It's appalling that nobody (including me!) thought about that!
2015-10-28 01:36:28 +01:00
Daniel Rudolf de6b3a7c28 Fix Markdown %meta.*% replacement
Don't even try to use arrays here...
2015-10-28 01:08:45 +01:00
Daniel Rudolf a654b1585b phpDocumentor 2.8.5 currently doesn't support the Generic notations
This will likely be implemented as soon as the proposed PSR-5: PHPDoc is accepted
2015-10-27 01:48:58 +01:00
Daniel Rudolf 92af554d14 Improve inline code comments; preparing use of phpDocumentor 2015-10-27 01:39:28 +01:00
theshka 01122f2901 fix spelling 2015-10-09 20:41:00 +02:00
theshka fe83d1fa7f fix spelling 2015-10-09 20:41:00 +02:00
Daniel Rudolf b09433a37b Allow multiple calls to Pico::setConfig() 2015-10-06 20:38:34 +02:00
Daniel Rudolf 1419cf1636 Add Pico::setConfig() method
Thanks @dav-m85
2015-10-06 20:23:28 +02:00
Daniel Rudolf 7537159868 Remove the need to register headers during onMetaHeaders()
Why? I'm currently writing the user docs and I really have no idea how to explain this whole process in a non-technical way... It is very likely that a normal user wants to use custom tags and it would be absurd to tell him,that he should learn a programming language to do so. On the other hand, providing a copy-and-paste template makes the whole idea of explicitly registering headers worthless. The only reasonable solution is to remove the need to register headers.

Anyway, I think @PontusHorn is right to say that registering headers makes the whole system more predictable. So plugin developers are still instructed to register their meta headers during . We actually can't check and ensure this, but that's imho the best solution.
2015-10-05 01:50:55 +02:00
Daniel Rudolf 46ef63186a Support $config['<plugin name>']['enabled'] option
... as a alternative to $config['<plugin name>.enabled']; Thanks @theshka for giving this hint
2015-10-04 22:52:08 +02:00
Daniel Rudolf 9d518fd722 Move sorting of $pages from Pico::getPages() to Pico::sortPages() 2015-10-04 22:39:38 +02:00
Daniel Rudolf 4f1e8667c3 Cast AbstractPicoPlugin::$dependsOn to array
Plugin devs could come up with the idea of setting AbstractPicoPlugin::$dependsOn to a string (single dependency) or null (no dependencies)
2015-10-04 22:30:35 +02:00
Daniel Rudolf 27d694697f Fix code formatting 2015-10-04 21:34:37 +02:00
Daniel Rudolf 9aa62b4b44 Improve method docs of Pico::load404Content() 2015-10-04 16:57:57 +02:00
Daniel Rudolf 77f939028c Support per-directory 404.md files 2015-10-04 15:24:38 +02:00
Daniel Rudolf 3a4721a20c SCANDIR_SORT_* constants are available since PHP 5.4
Thanks @Lomanic
2015-10-04 14:15:11 +02:00
Daniel Rudolf 241a52907e Update inline code comments 2015-10-01 22:52:10 +02:00
Daniel Rudolf fd64e4fa5e Add a exception to alpha sorting: List index files first
This guarantees that e.g. sub/index.md is listed before sub/foo.md
2015-10-01 21:54:30 +02:00
Daniel Rudolf 45815e2c6d Don't read file contents of inaccessible pages 2015-10-01 17:22:14 +02:00
Daniel Rudolf 95db5ba1a1 Drop inaccessible pages
e.g. drop sub.md if sub/index.md exists
2015-10-01 15:59:47 +02:00
Daniel Rudolf cdef7a6324 Explicitly treat relative paths to be relative to Picos root dir
This tempers the BC break, we can now recommend to simply remove the ROOT_DIR part
2015-10-01 15:14:45 +02:00
Daniel Rudolf fc7632b0ac Overhaul init of Pico
This may break BC if you're using one of the now deprecated constants (e.g. ROOT_DIR)
2015-10-01 15:05:50 +02:00
Daniel Rudolf 5e77d862bf Remove twig cache dir 2015-09-29 00:42:04 +02:00
Daniel Rudolf 5533b07531 Re-add lost PicoPluginInterface 2015-09-15 13:20:52 +02:00
Daniel Rudolf 70f187fb45 Rename IPicoPlugin to PicoPluginInterface 2015-09-15 13:15:45 +02:00
Daniel Rudolf 5731ede297 Allow omitting config/config.php; Fix write context on return value
Thanks @Lomanic for reporting
2015-09-14 23:01:08 +02:00
Daniel Rudolf 71e7da28cc Various fixes
Thanks @PontusHorn for spotting!
2015-09-13 20:46:09 +02:00
Daniel Rudolf a83b01ef4f Access plugins by class name, not file name
Class name and file name can differ regarding case sensitivity
2015-09-06 14:35:23 +02:00
Daniel Rudolf 533822320e Workaround for webservers omitting QUERY_STRING
Thanks @theshka for spotting
2015-08-30 21:31:47 +02:00
Daniel Rudolf 07ae26789c Add AbstractPicoPlugin
The plugin magic takes place here...
2015-08-28 18:26:56 +02:00