@@ -19,7 +19,7 @@ class Optlist extends Optcode
1919 protected bool $ timemodif = false ;
2020 protected bool $ author = false ;
2121 protected bool $ hidecurrent = false ;
22- protected bool $ checkbox = false ;
22+ protected bool $ tagcheck = false ;
2323 protected string $ style = self ::LIST ;
2424
2525 public const LIST = 'list ' ;
@@ -29,6 +29,7 @@ class Optlist extends Optcode
2929 self ::CARD => self ::CARD ,
3030 ];
3131
32+ /** @var array<string, int> $usefulltags */
3233 protected array $ usefulltags = [];
3334
3435 /**
@@ -159,7 +160,7 @@ public function listhtml(array $pagelist, Page $currentpage): string
159160 $ thumbnail ->setAttribute ('alt ' , htmlspecialchars ($ page ->title ()));
160161 $ parent ->appendChild ($ thumbnail );
161162 }
162- if ($ this ->checkbox ) {
163+ if ($ this ->tagcheck ) {
163164 $ tags = $ page ->tag ();
164165 $ this ->addusefulltags ($ tags );
165166 foreach ($ tags as $ tag ) {
@@ -169,15 +170,19 @@ public function listhtml(array $pagelist, Page $currentpage): string
169170 }
170171 $ dom ->appendChild ($ ul );
171172
172- if ($ this ->checkbox ) {
173+ if ($ this ->tagcheck ) {
174+ $ hash = crc32 (serialize ($ this ));
173175 $ domform = new DOMDocument ('1.0 ' , 'UTF-8 ' );
174176 $ form = $ domform ->createElement ('form ' );
177+ $ form ->setAttribute ('class ' , 'tagcheck ' );
178+ $ form ->setAttribute ('id ' , "tagcheck- $ hash " );
175179 foreach ($ this ->usefulltags as $ tag => $ count ) {
176180 if ($ count === $ pagecount ) {
177181 continue ; // skip this tag as it's used by all pages
178182 }
179183 $ span = $ domform ->createElement ('span ' );
180- $ id = "checkbox-tag_ $ tag " ;
184+ $ span ->setAttribute ('class ' , "tag_ $ tag " );
185+ $ id = "tagcheck- $ hash-tag_ $ tag " ;
181186 $ input = $ domform ->createElement ('input ' );
182187 $ input ->setAttribute ('id ' , $ id );
183188 $ input ->setAttribute ('value ' , $ tag );
@@ -203,7 +208,9 @@ public function listhtml(array $pagelist, Page $currentpage): string
203208
204209 /**
205210 * merge list of tags within the list of usefull tags.
206- * Tag names are stored as key and value count the time it's used.
211+ * Tag name is key and value count the time it's used.
212+ *
213+ * @param string[] $tags
207214 */
208215 private function addusefulltags (array $ tags ): void
209216 {
@@ -267,9 +274,9 @@ public function hidecurrent(): bool
267274 return $ this ->hidecurrent ;
268275 }
269276
270- public function checkbox (): bool
277+ public function tagcheck (): bool
271278 {
272- return $ this ->checkbox ;
279+ return $ this ->tagcheck ;
273280 }
274281
275282 public function style (): string
@@ -325,12 +332,12 @@ public function sethidecurrent(bool $hidecurrent): void
325332 $ this ->hidecurrent = $ hidecurrent ;
326333 }
327334
328- public function setcheckbox ( $ checkbox )
335+ public function settagcheck ( bool $ tagcheck ): void
329336 {
330- $ this ->checkbox = boolval ( $ checkbox ) ;
337+ $ this ->tagcheck = $ tagcheck ;
331338 }
332339
333- public function setstyle (string $ style )
340+ public function setstyle (string $ style ): void
334341 {
335342 if (key_exists ($ style , self ::STYLES )) {
336343 $ this ->style = $ style ;
0 commit comments