response->headers('Content-Type','application/json'); $this->response->body(sprintf('[%s]',json_encode($this->output))); } public static function js() { $mediapath = Route::get(static::$jsmediaroute); 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,array $data=array()) { if ($this->_auth_required() AND ! Auth::instance()->logged_in()) { $this->output = array('attr'=>array('id'=>'a_login'), 'data'=>array('title'=>_('Please Login').'...','attr'=>array('id'=>'N_login','href'=>URL::site('/login')))); return; } $this->output = array(); foreach ($data as $branch) { array_push($this->output,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']), ) ); } } } ?>