diff --git a/RockFrontend.module.php b/RockFrontend.module.php
index e7cdb14..67fc9ee 100644
--- a/RockFrontend.module.php
+++ b/RockFrontend.module.php
@@ -17,6 +17,7 @@
use Sabberworm\CSS\Rule\Rule;
use Sabberworm\CSS\RuleSet\AtRuleSet;
use Sabberworm\CSS\RuleSet\RuleSet;
+use Wa72\HtmlPageDom\HtmlPageCrawler;
/**
* @author Bernhard Baumrock, 05.01.2022
@@ -597,6 +598,28 @@ private function createPermission($name, $title)
$p->setAndSave('title', $title);
}
+ /**
+ * Load HtmlPageDom
+ *
+ * If you have plain HTML like from TinyMCE field some methods will not work
+ * because they need a hierarchy with a single root element. That's why by
+ * default the dom() method will add a wrapping div unless you specify
+ * FALSE as second param.
+ *
+ * Usage:
+ * $rockfrontend->dom("your html string")
+ * ->filter("img")
+ * ->each(function($img) {
+ * $img->attr('src', '/foo/bar.png');
+ * });
+ */
+ public function dom($data, $addWrapperDiv = true): HtmlPageCrawler
+ {
+ require_once __DIR__ . "/vendor/autoload.php";
+ if ($addWrapperDiv) $data = "
$data
";
+ return HtmlPageCrawler::create($data);
+ }
+
/**
* Download uikit
* @return void
diff --git a/composer.json b/composer.json
index cc1aed3..56395d6 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,8 @@
{
- "require": {
- "latte/latte": "^3.0",
- "sabberworm/php-css-parser": "^8.4",
- "matthiasmullie/minify": "^1.3"
- }
+ "require": {
+ "latte/latte": "^3",
+ "sabberworm/php-css-parser": "^8.4",
+ "matthiasmullie/minify": "^1.3",
+ "wa72/htmlpagedom": "^3.0"
+ }
}
diff --git a/composer.lock b/composer.lock
index 97d71fe..ad2fe9a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,32 +4,33 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "c3af7f6ba9a810968b0d0aff1e8d796a",
+ "content-hash": "51fe9e312aee207f6f36e49b457ce1f6",
"packages": [
{
"name": "latte/latte",
- "version": "v3.0.2",
+ "version": "v3.0.6",
"source": {
"type": "git",
"url": "https://github.com/nette/latte.git",
- "reference": "c3eee2e4e2c21cdf9f9c158c4bfa6150625457e1"
+ "reference": "6f66dcfea7ad76f60b8234139161421e9e1e309f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nette/latte/zipball/c3eee2e4e2c21cdf9f9c158c4bfa6150625457e1",
- "reference": "c3eee2e4e2c21cdf9f9c158c4bfa6150625457e1",
+ "url": "https://api.github.com/repos/nette/latte/zipball/6f66dcfea7ad76f60b8234139161421e9e1e309f",
+ "reference": "6f66dcfea7ad76f60b8234139161421e9e1e309f",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-tokenizer": "*",
- "php": ">=8.0 <8.2"
+ "php": ">=8.0 <8.3"
},
"conflict": {
- "nette/application": "<2.4.1"
+ "nette/application": "<3.1.7",
+ "nette/caching": "<3.1.4"
},
"require-dev": {
- "nette/php-generator": "^3.3.4",
+ "nette/php-generator": "^3.6 || ^4.0",
"nette/tester": "^2.0",
"nette/utils": "^3.0",
"phpstan/phpstan": "^1",
@@ -86,22 +87,89 @@
],
"support": {
"issues": "https://github.com/nette/latte/issues",
- "source": "https://github.com/nette/latte/tree/v3.0.2"
+ "source": "https://github.com/nette/latte/tree/v3.0.6"
},
- "time": "2022-06-15T13:42:57+00:00"
+ "time": "2023-03-09T01:34:56+00:00"
+ },
+ {
+ "name": "masterminds/html5",
+ "version": "2.8.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Masterminds/html5-php.git",
+ "reference": "3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3",
+ "reference": "3c5d5a56d56f48a1ca08a0670f0f80c1dad368f3",
+ "shasum": ""
+ },
+ "require": {
+ "ext-dom": "*",
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7 || ^8"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.7-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Masterminds\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Matt Butcher",
+ "email": "technosophos@gmail.com"
+ },
+ {
+ "name": "Matt Farina",
+ "email": "matt@mattfarina.com"
+ },
+ {
+ "name": "Asmir Mustafic",
+ "email": "goetas@gmail.com"
+ }
+ ],
+ "description": "An HTML5 parser and serializer.",
+ "homepage": "http://masterminds.github.io/html5-php",
+ "keywords": [
+ "HTML5",
+ "dom",
+ "html",
+ "parser",
+ "querypath",
+ "serializer",
+ "xml"
+ ],
+ "support": {
+ "issues": "https://github.com/Masterminds/html5-php/issues",
+ "source": "https://github.com/Masterminds/html5-php/tree/2.8.0"
+ },
+ "time": "2023-04-26T07:27:39+00:00"
},
{
"name": "matthiasmullie/minify",
- "version": "1.3.69",
+ "version": "1.3.70",
"source": {
"type": "git",
"url": "https://github.com/matthiasmullie/minify.git",
- "reference": "a61c949cccd086808063611ef9698eabe42ef22f"
+ "reference": "2807d9f9bece6877577ad44acb5c801bb3ae536b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/a61c949cccd086808063611ef9698eabe42ef22f",
- "reference": "a61c949cccd086808063611ef9698eabe42ef22f",
+ "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/2807d9f9bece6877577ad44acb5c801bb3ae536b",
+ "reference": "2807d9f9bece6877577ad44acb5c801bb3ae536b",
"shasum": ""
},
"require": {
@@ -110,9 +178,10 @@
"php": ">=5.3.0"
},
"require-dev": {
- "friendsofphp/php-cs-fixer": "~2.0",
- "matthiasmullie/scrapbook": "dev-master",
- "phpunit/phpunit": ">=4.8"
+ "friendsofphp/php-cs-fixer": ">=2.0",
+ "matthiasmullie/scrapbook": ">=1.3",
+ "phpunit/phpunit": ">=4.8",
+ "squizlabs/php_codesniffer": ">=3.0"
},
"suggest": {
"psr/cache-implementation": "Cache implementation to use with Minify::cache"
@@ -135,12 +204,12 @@
{
"name": "Matthias Mullie",
"email": "minify@mullie.eu",
- "homepage": "http://www.mullie.eu",
+ "homepage": "https://www.mullie.eu",
"role": "Developer"
}
],
"description": "CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.",
- "homepage": "http://www.minifier.org",
+ "homepage": "https://github.com/matthiasmullie/minify",
"keywords": [
"JS",
"css",
@@ -150,7 +219,7 @@
],
"support": {
"issues": "https://github.com/matthiasmullie/minify/issues",
- "source": "https://github.com/matthiasmullie/minify/tree/1.3.69"
+ "source": "https://github.com/matthiasmullie/minify/tree/1.3.70"
},
"funding": [
{
@@ -158,7 +227,7 @@
"type": "github"
}
],
- "time": "2022-08-01T09:00:18+00:00"
+ "time": "2022-12-09T12:56:44+00:00"
},
{
"name": "matthiasmullie/path-converter",
@@ -265,6 +334,372 @@
"source": "https://github.com/sabberworm/PHP-CSS-Parser/tree/8.4.0"
},
"time": "2021-12-11T13:40:54+00:00"
+ },
+ {
+ "name": "symfony/css-selector",
+ "version": "v6.2.7",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/css-selector.git",
+ "reference": "aedf3cb0f5b929ec255d96bbb4909e9932c769e0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/css-selector/zipball/aedf3cb0f5b929ec255d96bbb4909e9932c769e0",
+ "reference": "aedf3cb0f5b929ec255d96bbb4909e9932c769e0",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\CssSelector\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Jean-François Simon",
+ "email": "jeanfrancois.simon@sensiolabs.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Converts CSS selectors to XPath expressions",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/css-selector/tree/v6.2.7"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-02-14T08:44:56+00:00"
+ },
+ {
+ "name": "symfony/dom-crawler",
+ "version": "v6.2.9",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/dom-crawler.git",
+ "reference": "328bc3795059651d2d4e462e8febdf7ec2d7a626"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/328bc3795059651d2d4e462e8febdf7ec2d7a626",
+ "reference": "328bc3795059651d2d4e462e8febdf7ec2d7a626",
+ "shasum": ""
+ },
+ "require": {
+ "masterminds/html5": "^2.6",
+ "php": ">=8.1",
+ "symfony/polyfill-ctype": "~1.8",
+ "symfony/polyfill-mbstring": "~1.0"
+ },
+ "require-dev": {
+ "symfony/css-selector": "^5.4|^6.0"
+ },
+ "suggest": {
+ "symfony/css-selector": ""
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\DomCrawler\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Eases DOM navigation for HTML and XML documents",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/dom-crawler/tree/v6.2.9"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-04-11T16:03:19+00:00"
+ },
+ {
+ "name": "symfony/polyfill-ctype",
+ "version": "v1.27.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-ctype.git",
+ "reference": "5bbc823adecdae860bb64756d639ecfec17b050a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a",
+ "reference": "5bbc823adecdae860bb64756d639ecfec17b050a",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "provide": {
+ "ext-ctype": "*"
+ },
+ "suggest": {
+ "ext-ctype": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.27-dev"
+ },
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Ctype\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Gert de Pagter",
+ "email": "BackEndTea@gmail.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for ctype functions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "ctype",
+ "polyfill",
+ "portable"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-11-03T14:55:06+00:00"
+ },
+ {
+ "name": "symfony/polyfill-mbstring",
+ "version": "v1.27.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-mbstring.git",
+ "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
+ "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "provide": {
+ "ext-mbstring": "*"
+ },
+ "suggest": {
+ "ext-mbstring": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.27-dev"
+ },
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for the Mbstring extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "mbstring",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-11-03T14:55:06+00:00"
+ },
+ {
+ "name": "wa72/htmlpagedom",
+ "version": "v3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/wasinger/htmlpagedom.git",
+ "reference": "568a7379e66c3a8cf973885b7811900487f11fbb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/wasinger/htmlpagedom/zipball/568a7379e66c3a8cf973885b7811900487f11fbb",
+ "reference": "568a7379e66c3a8cf973885b7811900487f11fbb",
+ "shasum": ""
+ },
+ "require": {
+ "ext-dom": "*",
+ "ext-libxml": "*",
+ "ext-mbstring": "*",
+ "php": "^8.0",
+ "symfony/css-selector": "^6",
+ "symfony/dom-crawler": "^6"
+ },
+ "require-dev": {
+ "mikey179/vfsstream": "^1.6.10",
+ "phpunit/phpunit": "^9",
+ "scrutinizer/ocular": "^1.9",
+ "wa72/html-pretty-min": "~0.1"
+ },
+ "suggest": {
+ "wa72/html-pretty-min": "Minify or indent HTML documents"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Wa72\\HtmlPageDom\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christoph Singer",
+ "email": "singer@webagentur72.de",
+ "homepage": "http://www.webagentur72.de"
+ }
+ ],
+ "description": "jQuery-inspired DOM manipulation extension for Symfony's Crawler",
+ "homepage": "http://github.com/wasinger/htmlpagedom",
+ "keywords": [
+ "crawler",
+ "dom",
+ "html"
+ ],
+ "support": {
+ "issues": "https://github.com/wasinger/htmlpagedom/issues",
+ "source": "https://github.com/wasinger/htmlpagedom/tree/v3.0.0"
+ },
+ "time": "2022-04-13T15:28:55+00:00"
}
],
"packages-dev": [],