add classes to lists

This commit is contained in:
Roman 2021-04-03 13:22:23 +02:00
parent c81e9e8776
commit f7d1949cc9

@ -66,19 +66,23 @@ abstract class View extends StaticView {
} }
// UI Functions // UI Functions
private function createList($items, $tag): string { private function createList($items, $tag, $classes = ""): string {
if(count($items) === 0)
return "<$tag></$tag>"; $class = ($classes ? " class=\"$classes\"" : "");
else
return "<$tag><li>" . implode("</li><li>", $items) . "</li></$tag>"; if(count($items) === 0) {
return "<$tag$class></$tag>";
} else {
return "<$tag$class><li>" . implode("</li><li>", $items) . "</li></$tag>";
}
} }
public function createOrderedList($items=array()): string { public function createOrderedList($items=array(), $classes = ""): string {
return $this->createList($items, "ol"); return $this->createList($items, "ol", $classes);
} }
public function createUnorderedList($items=array()): string { public function createUnorderedList($items=array(), $classes = ""): string {
return $this->createList($items, "ul"); return $this->createList($items, "ul", $classes);
} }
protected function createLink($link, $title=null, $classes=""): string { protected function createLink($link, $title=null, $classes=""): string {