request->headers['Content-Type'] = 'application/json'; $this->request->response = sprintf('[%s]',json_encode($this->treedata)); } public static function js() { $mediapath = Route::get(static::$mediaroute); return '
'; } /** * Draw the Tree Menu * * The incoming ID is either a Branch B_x or a Node N_x * Where X is actually the module. * * @param id */ public function action_json($id=null) { if (! Auth::instance()->logged_in()) { $this->treedata = array('attr'=>array('id'=>'a_login'), 'data'=>array('title'=>_('Please Login').'...','attr'=>array('id'=>'N_login','href'=>URL::site('/login')))); return; } $this->treedata = array(); $data = array(); // @todo Our menu options array_push($data,array( 'id'=>'node', 'name'=>'Node Info', 'state'=>'none', 'attr_id'=>'1', 'attr_href'=>URL::Site('/node'), )); foreach ($data as $branch) { array_push($this->treedata,array( 'attr'=>array('id'=>sprintf('B_%s',$branch['id'])), 'state'=>$branch['state'], 'data'=>array('title'=>$branch['name']), 'attr'=>array('id'=>sprintf('N_%s',$branch['id']),'href'=>empty($branch['attr_href']) ? URL::site(sprintf('/%s/menu',$branch['name'])) : $branch['attr_href']), ) ); } } } ?>