public function admin_hierarchy()
{
$this->Prg->commonProcess();
if (empty($this->request->query['type'])) {
$this->Session->setFlash(__d('croogo', 'Type must be specified'), 'flash', array('class' => 'error'));
return $this->redirect(array('action' => 'index'));
}
$Node = $this->{$this->modelClass};
$Node->recursive = 0;
$alias = $this->modelClass;
$conditions = array();
$type = $Node->Taxonomy->Vocabulary->Type->find('first', array('recursive' => -1, 'conditions' => array('alias' => $this->request->query('type'))));
$types = $Node->Taxonomy->Vocabulary->Type->find('all');
$typeAliases = Hash::extract($types, '{n}.Type.alias');
$criteria = $Node->parseCriteria($this->Prg->parsedParams());
$nodeTypes = $Node->Taxonomy->Vocabulary->Type->find('list', array('fields' => array('Type.alias', 'Type.title')));
$nodesTree = $this->Node->generateTreeList($criteria);
$nodes = array();
foreach ($nodesTree as $nodeId => $title) {
$node = $Node->find('first', array('conditions' => array($Node->escapeField('id') => $nodeId)));
if ($node) {
$depth = substr_count($title, '_', 0);
$node['Node']['depth'] = $depth;
$nodes[] = $node;
}
}
$this->set(compact('nodes', 'type', 'types', 'typeAliases', 'nodeTypes'));
}