static function getItemHierarchy($type, $_item_id = '') { // Get the type descriptor details $typedetails = SelectorCollection::getTypeDetails($type); $item = new SelectorObject($typedetails['itemTableName']); if (!empty($_item_id)) { $cc = new ConstraintChain(); $cc->add(new Constraint('id', '=', $_item_id)); } else { return null; } // Load the given item $item->loadBy($cc); $item_cc = new ConstraintChain(); // Now get each parent in turn to construct constraintchain while ($item->isLoaded()) { // TODO: added <name>_id as column in view so could change this to // $item_cc->add(New Constraint($item->description.'_id', '=', $item->id)); $item_cc->add(new Constraint($item->description, '=', $item->name)); if (is_null($item->parent_id)) { break; } $cc = new ConstraintChain(); $cc->add(new Constraint('id', '=', $item->parent_id)); $item->loadBy($cc); } return $item_cc; }
private function getHierarchy($_parent_id = '', $_description = '') { $parent = array(); if (!empty($_parent_id)) { $parent_id = $_parent_id; $child_description = $_description; if ($parent_id != '') { while (!empty($parent_id)) { $do = new SelectorObject($this->itemTableName); $do->load($parent_id); $parent[$parent_id]['description'] = $do->description; $parent[$parent_id]['child_description'] = $child_description; $parent[$parent_id]['name'] = $do->name; $parent_id = $do->parent_id; $child_description = $do->description; } } } $this->view->set('parent', array_reverse($parent, true)); return $parent; }