* @package tao */ abstract class tao_helpers_form_elements_Treeview extends tao_helpers_form_elements_MultipleElement implements TreeAware { public const WIDGET_ID = 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf#TreeView'; /** * @author Bertrand Chevrier, * @param core_kernel_classes_Class $range * @param boolean $recursive * @return array */ public function rangeToTree(core_kernel_classes_Class $range, $recursive = false) { $data = []; foreach ($range->getSubClasses(false) as $rangeClass) { $classData = [ 'data' => $rangeClass->getLabel(), 'attributes' => [ 'id' => tao_helpers_Uri::encode($rangeClass->getUri()), 'class' => 'node-instance' ] ]; $children = $this->rangeToTree($rangeClass, true); if (count($children) > 0) { $classData['state'] = 'closed'; $classData['children'] = $children; } $data[] = $classData; } if (!$recursive) { $returnValue = [ 'data' => $range->getLabel(), 'attributes' => [ 'id' => tao_helpers_Uri::encode($range->getUri()), 'class' => 'node-class' ], 'children' => $data ]; } else { $returnValue = $data; } return $returnValue; } }