/** * Return array containing information about all hierarchies, including their root_id's * For non-adhoc hierarchies such as places, this call returns the contents of the place_hierarchies list * with some extra information such as the # of top-level items in each hierarchy. * * For an ad-hoc hierarchy like that of an entity, there is only ever one hierarchy to display - that of the current entity. * So for adhoc hierarchies we just return a single entry corresponding to the root of the current entity hierarchy */ public function getHierarchyList($pb_dummy = false) { $vn_pk = $this->getPrimaryKey(); if (!$vn_pk) { return null; } // have to load a row first $vs_template = $this->getAppConfig()->get('ca_entities_hierarchy_browser_display_settings'); $vs_label = $this->getLabelForDisplay(false); $vs_hier_fld = $this->getProperty('HIERARCHY_ID_FLD'); $vs_parent_fld = $this->getProperty('PARENT_ID_FLD'); $vn_hier_id = $this->get($vs_hier_fld); if ($this->get($vs_parent_fld)) { // currently loaded row is not the root so get the root $va_ancestors = $this->getHierarchyAncestors(); if (!is_array($va_ancestors) || sizeof($va_ancestors) == 0) { return null; } $t_entity = new ca_entities($va_ancestors[0]); } else { $t_entity =& $this; } $va_children = $t_entity->getHierarchyChildren(null, array('idsOnly' => true)); $va_entity_hierarchy_root = array($t_entity->get($vs_hier_fld) => array('entity_id' => $vn_pk, 'name' => $vs_name = caProcessTemplateForIDs($vs_template, 'ca_entities', array($vn_pk)), 'hierarchy_id' => $vn_hier_id, 'children' => sizeof($va_children))); return $va_entity_hierarchy_root; }