[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php declare(strict_types=1); 2 3 /** 4 * @package s9e\TextFormatter 5 * @copyright Copyright (c) 2010-2022 The s9e authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\TextFormatter\Plugins\TaskLists; 9 10 use s9e\TextFormatter\Configurator\Items\Tag; 11 use s9e\TextFormatter\Plugins\ConfiguratorBase; 12 13 class Configurator extends ConfiguratorBase 14 { 15 /** 16 * {@inheritdoc} 17 */ 18 public function asConfig() 19 { 20 return; 21 } 22 23 /** 24 * {@inheritdoc} 25 */ 26 public function finalize() 27 { 28 $this->configureListItemTag(); 29 } 30 31 protected function setUp(): void 32 { 33 if (!isset($this->configurator->tags['LI'])) 34 { 35 $this->configurator->Litedown; 36 } 37 38 $this->createTaskTag(); 39 $this->configureListItemTag(); 40 } 41 42 protected function configureListItemTag(): void 43 { 44 if (!isset($this->configurator->tags['LI'])) 45 { 46 return; 47 } 48 49 $tag = $this->configurator->tags['LI']; 50 $callback = Helper::class . '::filterListItem'; 51 if (!$tag->filterChain->containsCallback($callback)) 52 { 53 $tag->filterChain->append($callback) 54 ->resetParameters() 55 ->addParameterByName('parser') 56 ->addParameterByName('tag') 57 ->addParameterByName('text') 58 ->setJS(file_get_contents(__DIR__ . '/filterListItem.js')); 59 } 60 61 $dom = $tag->template->asDOM(); 62 foreach ($dom->query('//li[not(xsl:if[@test="TASK"])]') as $li) 63 { 64 $if = $li->prependXslIf('TASK'); 65 $if->appendXslAttribute('data-s9e-livepreview-ignore-attrs', 'data-task-id'); 66 $if->appendXslAttribute('data-task-id')->appendXslValueOf('TASK/@id'); 67 $if->appendXslAttribute('data-task-state')->appendXslValueOf('TASK/@state'); 68 } 69 $dom->saveChanges(); 70 } 71 72 protected function createTaskTag(): void 73 { 74 $tag = $this->configurator->tags->add('TASK'); 75 $tag->attributes->add('id')->filterChain->append('#identifier'); 76 $tag->attributes->add('state')->filterChain->append('#identifier'); 77 $tag->template = '<input data-task-id="{@id}" data-s9e-livepreview-ignore-attrs="data-task-id" type="checkbox"> 78 <xsl:if test="@state = \'checked\'"><xsl:attribute name="checked"/></xsl:if> 79 <xsl:if test="not($TASKLISTS_EDITABLE)"><xsl:attribute name="disabled"/></xsl:if> 80 </input>'; 81 } 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |