getClassService()->getRootClass(); } /** * Visualises the tree */ public function getTree() { $tree = $this->getClass($this->getRequestParameter('uri')); $struct = $this->getClassService()->getFlatStructure( $tree, function ($label) { return wordwrap($label, 30, "\n"); } ); $this->returnJson($struct); } /** * Renders a tree * @requiresRight id READ */ public function viewTree() { $this->setData('id', $this->getRequestParameter('id')); $this->setView('Trees/viewTree.tpl'); } /** * Returns an empty view */ public function dummy() { } /** * Populates the Tree of Trees * * @requiresRight classUri READ */ public function getTreeData() { $data = [ 'data' => __("Trees"), 'type' => 'class', 'attributes' => [ 'id' => \tao_helpers_Uri::encode($this->getRootClass()->getUri()), 'class' => 'node-class', 'data-uri' => $this->getRootClass()->getUri() ], ]; $sublasses = $this->getRootClass()->getSubClasses(false); if (count($sublasses)) { $data['children'] = []; } foreach ($sublasses as $class) { $data['children'][] = [ 'data' => $class->getLabel(), 'type' => 'instance', 'attributes' => [ 'id' => \tao_helpers_Uri::encode($class->getUri()), 'class' => 'node-instance', 'data-uri' => $class->getUri() ] ]; } //retrieve resources permissions $user = $this->getSession()->getUser(); $permissions = $this->getResourceService()->getResourcesPermissions($user, $data); //expose the tree $this->returnJson([ 'tree' => $data, 'permissions' => $permissions ]); } }