示例#1
0
 public function index()
 {
     if (app::$site->users()->count() > 0) {
         go('panel/login');
     }
     if ($problems = installation::check()) {
         $content = view('installation/check', array('problems' => $problems));
     } else {
         $form = app::form('installation', array('language' => c::get('panel.language', 'en')));
         $form->cancel = false;
         $form->save = l::get('installation.signup.button');
         $form->centered = true;
         foreach (app::languages() as $lang) {
             $form->fields()->get('language')->options[$lang->code()] = $lang->title();
         }
         $form->on('submit', function ($form) {
             try {
                 app::$site->users()->create($form->serialize());
                 go('panel/login/welcome');
             } catch (Exception $e) {
                 $form->alert($e->getMessage());
             }
         });
         $content = view('installation/signup', array('form' => $form));
     }
     return layout('installation', array('meta' => new Snippet('meta'), 'content' => $content));
 }
示例#2
0
文件: users.php 项目: kompuser/panel
 protected function form($user = null)
 {
     $mode = $user ? 'edit' : 'add';
     $fields = data::read(root('panel.app') . DS . 'forms' . DS . 'user.' . $mode . '.php', 'yaml');
     $content = $user ? $user->data() : array();
     // add all languages
     $fields['language']['options'] = array();
     $fields['language']['default'] = c::get('panel.language', 'en');
     foreach (app::languages() as $code => $lang) {
         $fields['language']['options'][$code] = $lang->title();
     }
     // make sure the password is never shown in the form
     unset($content['password']);
     return new Form($fields, $content);
 }