public function add($id = '/') { $page = $this->page($id); $blueprint = blueprint::find($page); $templates = $blueprint->pages()->template(); $options = array(); $back = array('subpages' => purl('subpages/index/' . $page->id()), 'page' => purl($page, 'show')); $form = app::form('pages.add'); $form->save = l('add'); $form->back = a::get($back, get('to')); foreach ($templates as $template) { $options[$template->name()] = $template->title(); } $select = form::field('select', array('name' => 'template', 'label' => l('pages.add.template.label'), 'options' => $options, 'required' => true)); if ($templates->count() == 1) { $select->readonly = true; $select->value = $templates->first()->name(); } $form->fields()->append('template', $select); if (api::maxPages($page, $blueprint->pages()->max())) { $form->fields = array('info' => form::field('info', array('label' => 'pages.add.error.max.headline', 'text' => 'pages.add.error.max.text'))); $form->save = false; $form->centered = true; } return view('pages/add', array('page' => $page, 'form' => $form)); }
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)); }
public function login($welcome = null) { if ($user = app::$site->user()) { go('panel'); } $form = app::form('login'); $form->cancel = false; $form->save = l('login.button'); $form->centered = true; return layout('login', array('meta' => new Snippet('meta'), 'welcome' => $welcome ? l('login.welcome') : '', 'form' => $form)); }
protected function form($user = null) { $mode = $user ? 'edit' : 'add'; return app::form('user.' . $mode); }