diff --git a/.github/issue_template.md b/.github/issue_template.md
new file mode 100644
index 0000000..80a8886
--- /dev/null
+++ b/.github/issue_template.md
@@ -0,0 +1,19 @@
+This is a (multiple allowed):
+
+* [x] bug
+* [ ] enhancement
+* [ ] question
+
+* CakePHP Version: EXACT RELEASE VERSION (e.g. 3.4.13).
+* Plugin Version/Branch: COMPOSER REQUIREMENTS (e.g. `dev-master`, `dev-4.0.1-alpha`, `3.1.*`).
+
+### What you did
+EXPLAIN WHAT YOU DID, PREFERABLY WITH CODE EXAMPLES, HERE.
+
+### What happened
+EXPLAIN WHAT IS ACTUALLY HAPPENING, HERE.
+
+### What you expected to happen
+EXPLAIN WHAT IS TO BE EXPECTED, HERE.
+
+Before you open an issue, please check if a similar issue already exists or has been closed before.
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 0000000..0ff16b9
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,8 @@
+1. Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
+If it fixes a bug or resolves a feature request, be sure to link to that issue.
+
+2. Make sure continuous integration is not failing, see https://travis-ci.org/Holt59/cakephp3-bootstrap-helpers
+
+3. Add unit tests for this pull-request. You can use https://webtools.typename.fr/cphp-ahtml/ to easily generate assert array for you methods.
+
+**Note:** The best way to propose a feature is to open an issue first and discuss your ideas there before implementing them.
diff --git a/.travis.yml b/.travis.yml
index bcb29e0..5c39991 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,30 +1,34 @@
language: php
php:
- - 7.0
- 5.6
+ - 7.0
- 7.1
+ - 7.2
+ - 7.3
dist: trusty
env:
- global:
- - DEFAULT=1
+ - CAKEPHP_VERSION=3.7.*
+ - CAKEPHP_VERSION=3.8.*
cache:
directories:
- vendor
- $HOME/.composer/cache
-before_script:
- - composer install --prefer-dist --no-interaction
+before_install:
+ - composer require "cakephp/cakephp:${CAKEPHP_VERSION}" --no-update
+
+install: composer update --prefer-dist --no-interaction
script:
- - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then export CODECOVERAGE=1; vendor/bin/phpunit --coverage-clover=clover.xml; fi
- - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.0 ]]; then vendor/bin/phpunit; fi
+ - if [[ $TRAVIS_PHP_VERSION = 7.0 ]]; then export CODECOVERAGE=1; vendor/bin/phpunit --coverage-clover=clover.xml; fi
+ - if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then vendor/bin/phpunit; fi
after_success:
- - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then bash <(curl -s https://codecov.io/bash); fi
+ - if [[ $TRAVIS_PHP_VERSION = 7.0 ]]; then bash <(curl -s https://codecov.io/bash); fi
notifications:
email: true
diff --git a/README.md b/README.md
index ff08cb7..8767ee1 100644
--- a/README.md
+++ b/README.md
@@ -2,23 +2,27 @@ CakePHP 3.x Helpers for Bootstrap
=================================
[](LICENSE)
-[](https://travis-ci.org/Holt59/cakephp3-bootstrap-helpers)
+[](https://travis-ci.com/Holt59/cakephp3-bootstrap-helpers)
[](https://packagist.org/packages/holt59/cakephp3-bootstrap-helpers)
CakePHP 3.x Helpers to generate HTML with @Twitter Boostrap style: `Breadcrumbs`, `Flash`, `Form`, `Html`, `Modal`, `Navbar`,
-`Panel` and `Paginator` helpers available!
+`Card` and `Paginator` helpers available!
How to... ?
===========
#### Installation
-If you want the latest **Bootstrap 3** version of the plugin:
+If you want the **Bootstrap 4** version of the plugin:
-- Add the plugin to your `composer.json` (see below if you want to use another branch / version):
+- Add the plugin to your `composer.json`:
-```
-composer require holt59/cakephp3-bootstrap-helpers:dev-master
+```bash
+# Stable version:
+composer require holt59/cakephp3-bootstrap-helpers:4.0.2
+
+# Development version (latest fixes):
+composer require holt59/cakephp3-bootstrap-helpers:dev-4.0.1-alpha
```
- Load the plugin in your `config/bootstrap.php`:
@@ -36,17 +40,37 @@ $this->loadHelper('Html', [
]);
```
+#### Breaking changes from previous versions
+
+- `FormHelper`:
+ - it is not possible to place error message in a separate column in horizontal form, the error message
+ will always be put below the input.
+
+- `NavbarHelper`:
+ - the following options of the `create()` methods have been removed or have had their meaning changed:
+ - `static` is now `sticky`
+ - `responsive` has been dropped and replace by a `collapse` option with the following meaning: `true`
+ for always collapsed, `false` for never collapsed, or a string representing indicating when the content
+ should collapse (`'lg'` is the default).
+ - `fluid` has been dropped.
+ - `container` is a new option (`bool`, default is `false`) to indicate if the content of the navbar
+ should be wrapped inside a `
`.
+ - `inverse` has been dropped.
+ - a new `theme` option has been added to the `create()` method to control, possible values are `'light'`,
+ `'dark'`, `false` (no theme), or an array `[$theme, $bg]`.
+ - when adding a `link()` to an inner menu, the `$linkOptions` parameters is not usable anymore and the
+ `$options` parameters should be used directly (their are no wrapping `` anymore for inner menu).
+
The full plugin documentation is available at https://holt59.github.io/cakephp3-bootstrap-helpers/.
#### Table of version and requirements
| Version | Bootstrap version | CakePHP version | Information |
|---------|-------------------|-----------------|-------------|
-| master / 3.1.2 | 3 | >= 3.4.0 | Current active branch. |
-| > 3.0.5, <= 3.1.1 | 3 | >= 3.2.3, < 3.4.0 | Not actively maintained (open issue(s) if necessary). |
-| <= 3.0.5 | 3 | >= 3.0.0 | Deprecated. |
-| 4.0.0-alpha | 4 | N/A | Deprecated. |
-| 4.0.1-alpha | 4 | >= 3.4.0 | Coming soon... |
+| [master](https://github.com/Holt59/cakephp3-bootstrap-helpers/tree/master) | 3 | >= 3.7.0 | Current active V3 branch. |
+| [4.0.2](https://github.com/Holt59/cakephp3-bootstrap-helpers/tree/4.0.1-alpha) | 4 | >= 3.7.0 | Current active V4 branch. |
+| [3.1.4](https://github.com/Holt59/cakephp3-bootstrap-helpers/tree/v3.1.2) | 3 | >= 3.7.0 | Open issue(s) if necessary. |
+| <= [3.1.2](https://github.com/Holt59/cakephp3-bootstrap-helpers/tree/v3.1.1) | 3 | < 3.4.0 | Deprecated. |
#### Contributing
diff --git a/composer.json b/composer.json
index a965091..158ea64 100644
--- a/composer.json
+++ b/composer.json
@@ -6,7 +6,7 @@
"type": "cakephp-plugin",
"require": {
"php": ">=5.5.9",
- "cakephp/cakephp": ">=3.4.0"
+ "cakephp/cakephp": ">=3.7.0"
},
"require-dev": {
"phpunit/phpunit": "<6.0",
diff --git a/src/Template/Element/Flash/error.ctp b/src/Template/Element/Flash/error.ctp
index 8b397d1..08b511e 100644
--- a/src/Template/Element/Flash/error.ctp
+++ b/src/Template/Element/Flash/error.ctp
@@ -13,7 +13,7 @@
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
-$helper = new \Bootstrap\View\Helper\BootstrapHtmlHelper ($this) ;
+$helper = new \Bootstrap\View\Helper\HtmlHelper ($this) ;
if (!isset($params['escape']) || $params['escape'] !== false) {
$message = h($message);
}
diff --git a/src/Template/Element/Flash/info.ctp b/src/Template/Element/Flash/info.ctp
index 57af315..341c8e3 100644
--- a/src/Template/Element/Flash/info.ctp
+++ b/src/Template/Element/Flash/info.ctp
@@ -13,7 +13,7 @@
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
-$helper = new \Bootstrap\View\Helper\BootstrapHtmlHelper ($this) ;
+$helper = new \Bootstrap\View\Helper\HtmlHelper ($this) ;
if (!isset($params['escape']) || $params['escape'] !== false) {
$message = h($message);
}
diff --git a/src/Template/Element/Flash/success.ctp b/src/Template/Element/Flash/success.ctp
index 2b9dae3..1aa22b8 100644
--- a/src/Template/Element/Flash/success.ctp
+++ b/src/Template/Element/Flash/success.ctp
@@ -13,7 +13,7 @@
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
-$helper = new \Bootstrap\View\Helper\BootstrapHtmlHelper ($this) ;
+$helper = new \Bootstrap\View\Helper\HtmlHelper ($this) ;
if (!isset($params['escape']) || $params['escape'] !== false) {
$message = h($message);
}
diff --git a/src/Template/Element/Flash/warning.ctp b/src/Template/Element/Flash/warning.ctp
index b13c65b..a5b3c94 100644
--- a/src/Template/Element/Flash/warning.ctp
+++ b/src/Template/Element/Flash/warning.ctp
@@ -13,7 +13,7 @@
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
-$helper = new \Bootstrap\View\Helper\BootstrapHtmlHelper ($this) ;
+$helper = new \Bootstrap\View\Helper\HtmlHelper ($this) ;
if (!isset($params['escape']) || $params['escape'] !== false) {
$message = h($message);
}
diff --git a/src/Utility/Matching.php b/src/Utility/Matching.php
index 95c6321..7919893 100644
--- a/src/Utility/Matching.php
+++ b/src/Utility/Matching.php
@@ -32,7 +32,7 @@ class Matching {
*
* @return bool True if the given tag was found, false otherwize.
**/
- public function matchTag($tag, $subject, &$content = null, &$attrs = null) {
+ public static function matchTag($tag, $subject, &$content = null, &$attrs = null) {
$xml = new \XMLReader();
$xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE);
@@ -67,7 +67,7 @@ public function matchTag($tag, $subject, &$content = null, &$attrs = null) {
* @return bool True if an attribute with the given name/value was found, false
* otherwize.
**/
- public function matchAttribute($attr, $value, $subject) {
+ public static function matchAttribute($attr, $value, $subject) {
$xml = new \XMLReader();
$xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE);
@@ -84,13 +84,13 @@ public function matchAttribute($attr, $value, $subject) {
* type name or attribute.
*
* @param string $tag Tag name to search for, or null if not relevant.
- * @param string $attr Array [name, value] for the attribute to search for, or null
+ * @param string $attrs Array [name => value] for the attributes to search for, or null
* if not relevant. `value` can be null if only the name should be looked.
* @param string $subject String to search.
*
* @return bool True if the given tag or given attribute is found.
**/
- public function findTagOrAttribute($tag, $attr, $subject) {
+ public static function findTagOrAttribute($tag, $attrs, $subject) {
$xml = new \XMLReader();
$xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE);
// failed to parse => false
@@ -98,19 +98,21 @@ public function findTagOrAttribute($tag, $attr, $subject) {
return false;
}
- if (!is_null($attr) && !is_array($attr)) {
- $attr = [$attr, null];
+ if (!is_null($attrs) && !is_array($attrs)) {
+ $attrs = [$attrs => null];
}
while ($xml->read()) {
if (!is_null($tag) && $xml->name == $tag) {
return true; // tag found
}
- if (!is_null($attr)) {
- $value = $xml->getAttribute($attr[0]);
- if (!is_null($value)
- && (is_null($attr[1]) || $value == $attr[1])) {
- return true;
+ if (!is_null($attrs)) {
+ foreach ($attrs as $attr => $attrValue) {
+ $value = $xml->getAttribute($attr);
+ if (!is_null($value)
+ && (is_null($attrValue) || $value == $attrValue)) {
+ return true;
+ }
}
}
}
diff --git a/src/View/EnhancedStringTemplate.php b/src/View/EnhancedStringTemplate.php
index 4bf62b8..95f0780 100644
--- a/src/View/EnhancedStringTemplate.php
+++ b/src/View/EnhancedStringTemplate.php
@@ -33,32 +33,6 @@ class EnhancedStringTemplate extends StringTemplate {
*/
protected $_callbacks = null;
- /**
- * Compile templates into a more efficient printf() compatible format.
- *
- * @param array $templates The template names to compile. If empty all templates will
- * be compiled.
- *
- * @return void
- */
- protected function _compileTemplates(array $templates = []) {
- if (empty($templates)) {
- $templates = array_keys($this->_config);
- }
- foreach ($templates as $name) {
- $template = $this->get($name);
- if ($template === null) {
- $this->_compiled[$name] = [null, null];
- }
- $template = str_replace('%', '%%', $template);
- preg_match_all('#\{\{([\w.]+)\}\}#', $template, $matches);
- $this->_compiled[$name] = [
- str_replace($matches[0], '%s', $template),
- $matches[1]
- ];
- }
- }
-
/**
* Format a template string with $data
*
diff --git a/src/View/Helper/BootstrapBreadcrumbsHelper.php b/src/View/Helper/BootstrapBreadcrumbsHelper.php
deleted file mode 100644
index a9bdf6f..0000000
--- a/src/View/Helper/BootstrapBreadcrumbsHelper.php
+++ /dev/null
@@ -1,8 +0,0 @@
- [
'wrapper' => '{{content}}
',
- 'item' => '{{title}}',
- 'itemWithoutLink' => '{{title}}',
+ 'item' => '{{title}}',
+ 'itemWithoutLink' => '{{title}}',
'separator' => ''
],
'templateClass' => 'Bootstrap\View\EnhancedStringTemplate'
];
-};
\ No newline at end of file
+};
diff --git a/src/View/Helper/PanelHelper.php b/src/View/Helper/CardHelper.php
similarity index 63%
rename from src/View/Helper/PanelHelper.php
rename to src/View/Helper/CardHelper.php
index 039308c..625993e 100644
--- a/src/View/Helper/PanelHelper.php
+++ b/src/View/Helper/CardHelper.php
@@ -20,20 +20,20 @@
use Cake\View\StringTemplateTrait;
/**
- * Panel helper library.
+ * Card helper library.
*
- * Automatic generation of Bootstrap HTML panels.
+ * Automatic generation of Bootstrap HTML cards.
*
* @property \Bootstrap\View\Helper\HtmlHelper $Html
*/
-class PanelHelper extends Helper {
+class CardHelper extends Helper {
use ClassTrait;
use EasyIconTrait;
use StringTemplateTrait;
/**
- * Other helpers used by PanelHelper.
+ * Other helpers used by CardHelper.
*
* @var array
*/
@@ -44,28 +44,28 @@ class PanelHelper extends Helper {
/**
* Default configuration for the helper.
*
- * - `collapsible` Default behavior for collapsible panel.
+ * - `collapsible` Default behavior for collapsible card.
*
* @var array
*/
protected $_defaultConfig = [
'templates' => [
- 'panelGroupStart' => '',
- 'panelGroupEnd' => '
',
- 'panelStart' => '',
- 'panelEnd' => '
',
- 'headerStart' => '',
- 'headerCollapsibleStart' => '
',
- 'headerTitle' => '
{{content}}
',
+ 'cardGroupStart' => '
',
+ 'cardGroupEnd' => '
',
+ 'cardStart' => '
',
+ 'cardEnd' => '
',
+ 'headerStart' => '