/**
  * @return array Asynchronous result array
  */
 public function __async_form($structureId = 0)
 {
     /** @var array $table Result of asynchronous controller
      * Represented as array of rendered table and pager objects */
     $table = $this->__async_table($structureId);
     if ($structureId == 0) {
         // If parent structure is not set, store structure by itself instead
         $parent = isset($parent) ? $parent : CMSNav::fullTree();
         /** @var SamsonTree $tree Tree structure object */
         $tree = new SamsonTree('tree/template', 0, $this->id . '/getchild');
         /** @var string $treeHTML Rendered tree */
         $treeHTML = $tree->htmlTree($parent);
         $treeHide = false;
     } else {
         $treeHTML = '';
         $treeHide = true;
     }
     // Return asynchronous result
     return array('status' => 1, 'html' => $this->view('form')->set($table)->set($treeHTML, 'tree')->set($treeHide, 'treeHide')->set($structureId, 'structureID')->output());
 }
 /**
  * Построение нового дерева. (Вызывается в цепи контроллеров)
  * @param null $currentMainNavID - указатель на родителя
  *
  * @return array
  */
 public function __async_tree($currentMainNavID = null)
 {
     /** @var CMSNav $currentMainNav */
     $currentMainNav = null;
     if (dbQuery('\\samson\\cms\\web\\navigation\\CMSNav')->StructureID($currentMainNavID)->first($currentMainNav)) {
         $currentMainNav->currentNavID = $currentMainNavID;
     } else {
         $currentMainNav = CMSNav::fullTree();
     }
     $tree = new \samson\treeview\SamsonTree('tree/tree-template', 0, 'structure/addchildren');
     $sub_menu = $this->view('sub_menu')->parentnav_id($currentMainNavID)->nav_id($currentMainNavID)->output();
     // return Ajax response
     return array('status' => 1, 'tree' => $tree->htmlTree($currentMainNav), 'sub_menu' => $sub_menu);
 }