heimrichhannot / contao-linkchecker-bundle
简单的链接检查工具,包含后端小部件和LinkChecker类。
2.5.1
2024-02-15 09:49 UTC
Requires
- php: ^7.4 || ^8.0
- contao/core-bundle: ^4.9
- heimrichhannot/contao-ajax-bundle: ~1.0
- heimrichhannot/contao-encore-contracts: ^1.0
- heimrichhannot/contao-utils-bundle: ^2.232
- symfony/config: ^4.4 || ^5.4
- symfony/css-selector: ^4.4 || ^5.4
- symfony/dependency-injection: ^4.4 || ^5.4
- symfony/http-kernel: ^4.4 || ^5.4
- symfony/polyfill-php80: ^1.22
- wa72/htmlpagedom: ^1.3 || ^2.0
Requires (Dev)
- contao/manager-plugin: ^2.0
- contao/test-case: ^2.0 || ^3.0 || ^4.0
- friendsofphp/php-cs-fixer: ^2.2
- phpunit/phpunit: ^7.0 || ^8.0
- satooshi/php-coveralls: ^2.0
- symfony/phpunit-bridge: ^3.2
README
Contao链接检查插件包
简单的链接检查工具,包含后端小部件和LinkChecker类。使用php get_headers()函数。小部件内的链接测试通过xhr调用完成。
技术说明
测试链接
如果您想测试单个链接或多个链接,只需调用
\Contao\System::getContainer()->get('huh.linkchecker.manager.linkchecker')test('http://www.google.de');
\Contao\System::getContainer()->get('huh.linkchecker.manager.linkchecker')test(array('http://www.google.de', 'http://www.twitter.com'));
后端小部件/字段
在后台模式下,有一个名为linkChecker
的小部件可用;在您的DataContainer字段配置中提供有效的load_callback
。
//tl_sample.php
'linkChecker' => array(
'label' => &$GLOBALS['TL_LANG']['tl_sample']['linkChecker'],
'inputType' => 'linkChecker',
'load_callback' => array(
array('MyClass', 'getLinkCheckerHtml'),
),
),
您可以在load_callback
中返回带有锚标签的html代码、单个链接或链接数组。
// MyClass
public function getLinkCheckerHtml($varValue, \DataContainer $dc)
{
return '<a href="http://google.de">Google</a>'
}