Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
185 lines
6.2 KiB
PHP
185 lines
6.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Component\CssSelector\XPath\Extension;
|
|
|
|
use Symfony\Component\CssSelector\Exception\ExpressionErrorException;
|
|
use Symfony\Component\CssSelector\Node\FunctionNode;
|
|
use Symfony\Component\CssSelector\XPath\Translator;
|
|
use Symfony\Component\CssSelector\XPath\XPathExpr;
|
|
|
|
/**
|
|
* XPath expression translator HTML extension.
|
|
*
|
|
* This component is a port of the Python cssselect library,
|
|
* which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
|
|
*
|
|
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
|
*
|
|
* @internal
|
|
*/
|
|
class HtmlExtension extends AbstractExtension
|
|
{
|
|
// Each disabled fieldset ancestor disables the element, except the one whose first legend
|
|
// child the element sits in. Those excepted fieldsets are exactly the parents of the
|
|
// ancestors-or-self that are a first legend child of a disabled fieldset, one for one, so
|
|
// the element is disabled as soon as the first count exceeds the second one. Counting keeps
|
|
// this to two cheap ancestor walks instead of a predicate run on every ancestor.
|
|
private const DISABLING_FIELDSET = 'count(ancestor::fieldset[@disabled]) > count(ancestor-or-self::legend[not(preceding-sibling::legend)][parent::fieldset[@disabled]])';
|
|
|
|
public function __construct(Translator $translator)
|
|
{
|
|
$translator
|
|
->getExtension('node')
|
|
->setFlag(NodeExtension::ELEMENT_NAME_IN_LOWER_CASE, true)
|
|
->setFlag(NodeExtension::ATTRIBUTE_NAME_IN_LOWER_CASE, true);
|
|
}
|
|
|
|
public function getPseudoClassTranslators(): array
|
|
{
|
|
return [
|
|
'checked' => $this->translateChecked(...),
|
|
'link' => $this->translateLink(...),
|
|
'disabled' => $this->translateDisabled(...),
|
|
'enabled' => $this->translateEnabled(...),
|
|
'selected' => $this->translateSelected(...),
|
|
'invalid' => $this->translateInvalid(...),
|
|
'hover' => $this->translateHover(...),
|
|
'visited' => $this->translateVisited(...),
|
|
];
|
|
}
|
|
|
|
public function getFunctionTranslators(): array
|
|
{
|
|
return [
|
|
'lang' => $this->translateLang(...),
|
|
];
|
|
}
|
|
|
|
public function translateChecked(XPathExpr $xpath): XPathExpr
|
|
{
|
|
return $xpath->addCondition(
|
|
'(@checked '
|
|
."and (name(.) = 'input' or name(.) = 'command')"
|
|
."and (@type = 'checkbox' or @type = 'radio'))"
|
|
);
|
|
}
|
|
|
|
public function translateLink(XPathExpr $xpath): XPathExpr
|
|
{
|
|
return $xpath->addCondition("@href and (name(.) = 'a' or name(.) = 'link' or name(.) = 'area')");
|
|
}
|
|
|
|
public function translateDisabled(XPathExpr $xpath): XPathExpr
|
|
{
|
|
return $xpath->addCondition(
|
|
'('
|
|
.'@disabled and'
|
|
.'('
|
|
."(name(.) = 'input' and @type != 'hidden')"
|
|
." or name(.) = 'button'"
|
|
." or name(.) = 'select'"
|
|
." or name(.) = 'textarea'"
|
|
." or name(.) = 'command'"
|
|
." or name(.) = 'fieldset'"
|
|
." or name(.) = 'optgroup'"
|
|
." or name(.) = 'option'"
|
|
.')'
|
|
.') or ('
|
|
."(name(.) = 'input' and @type != 'hidden')"
|
|
." or name(.) = 'button'"
|
|
." or name(.) = 'select'"
|
|
." or name(.) = 'textarea'"
|
|
." or name(.) = 'fieldset'"
|
|
.')'
|
|
.' and '.self::DISABLING_FIELDSET
|
|
);
|
|
}
|
|
|
|
public function translateEnabled(XPathExpr $xpath): XPathExpr
|
|
{
|
|
return $xpath->addCondition(
|
|
'('
|
|
.'@href and ('
|
|
."name(.) = 'a'"
|
|
." or name(.) = 'link'"
|
|
." or name(.) = 'area'"
|
|
.')'
|
|
.') or ('
|
|
.'('
|
|
."name(.) = 'command'"
|
|
." or name(.) = 'optgroup'"
|
|
.')'
|
|
.' and not(@disabled)'
|
|
.') or ('
|
|
.'('
|
|
."(name(.) = 'input' and @type != 'hidden')"
|
|
." or name(.) = 'button'"
|
|
." or name(.) = 'select'"
|
|
." or name(.) = 'textarea'"
|
|
." or name(.) = 'keygen'"
|
|
." or name(.) = 'fieldset'"
|
|
.')'
|
|
.' and not(@disabled or '.self::DISABLING_FIELDSET.')'
|
|
.') or ('
|
|
."name(.) = 'option' and not("
|
|
.'@disabled or ancestor::optgroup[@disabled]'
|
|
.')'
|
|
.')'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @throws ExpressionErrorException
|
|
*/
|
|
public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathExpr
|
|
{
|
|
$arguments = $function->getArguments();
|
|
foreach ($arguments as $token) {
|
|
if (!($token->isString() || $token->isIdentifier())) {
|
|
throw new ExpressionErrorException('Expected a single string or identifier for :lang(), got '.implode(', ', $arguments));
|
|
}
|
|
}
|
|
|
|
return $xpath->addCondition(\sprintf(
|
|
'ancestor-or-self::*[@lang][1][starts-with(concat('
|
|
."translate(@%s, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '-')"
|
|
.', %s)]',
|
|
'lang',
|
|
Translator::getXpathLiteral(strtolower($arguments[0]->getValue()).'-')
|
|
));
|
|
}
|
|
|
|
public function translateSelected(XPathExpr $xpath): XPathExpr
|
|
{
|
|
return $xpath->addCondition("(@selected and name(.) = 'option')");
|
|
}
|
|
|
|
public function translateInvalid(XPathExpr $xpath): XPathExpr
|
|
{
|
|
return $xpath->addCondition('0');
|
|
}
|
|
|
|
public function translateHover(XPathExpr $xpath): XPathExpr
|
|
{
|
|
return $xpath->addCondition('0');
|
|
}
|
|
|
|
public function translateVisited(XPathExpr $xpath): XPathExpr
|
|
{
|
|
return $xpath->addCondition('0');
|
|
}
|
|
|
|
public function getName(): string
|
|
{
|
|
return 'html';
|
|
}
|
|
}
|