示例#1
0
 protected function createComponentFormLoginAjax()
 {
     $form = new LiveForm($this, 'formLoginAjax');
     $form->addText('login', 'login')->addRule(Form::FILLED, 'Fill username');
     $form->addPassword('password', 'Password')->addRule(Form::FILLED, 'Fill password');
     $form->addSubmit('btn_login', 'Login');
     $form->onSubmit[] = array($this, 'formLoginAjaxSubmitted');
     return $form;
 }
示例#2
0
 public function createComponentPhotoForm($name)
 {
     $form = new LiveForm($this, $name);
     $form->getElementPrototype()->class = 'ajax_uploader';
     $form->addFile('photo', 'Photo')->getControlPrototype()->class('multi');
     $form->addText('name', 'Name')->addRule(Form::FILLED, 'Please enter a album name');
     $form->addTextArea('description', 'Description');
     $form->addButton('btnClose', 'Close');
     $form->addSubmit('btnSubmit', 'OK')->onClick[] = callback($this, 'PhotoFormSubmitted');
     $form->addHidden('album_id')->setValue($this->getParam('albumId'));
     return $form;
 }
示例#3
0
 public function __construct(Presenter $parent = null, $name = null)
 {
     parent::__construct($parent, $name);
     $this->addText('from', 'From')->addRule(Form::EMAIL, 'Please enter a valid email.');
     $this->addTextArea('text', 'Message');
     $this->addSubmit('btnSend', 'Send')->onClick[] = callback($this, 'FormSent');
 }
示例#4
0
 public function createTabMetaInfo($name, $page)
 {
     $form = new LiveForm($page, $name);
     $data = ConfigAdapterIni::load(APP_DIR . '/config/site.ini', 'site');
     $form->addText("title", "Title");
     $form->addText("author", "Author");
     $form->addText("keywords", "Keywords");
     $form->addText("description", "Description");
     $form->addSubmit("odeslat", "Odeslat");
     $form->setDefaults($data);
     $form->onSubmit[] = array($this, "saveMetaData");
     return $form;
 }
示例#5
0
 public function createComponentFormUser($name)
 {
     $form = new LiveForm($this, $name);
     $form->addText('name', 'Name')->addRule(Form::FILLED);
     $form->addText('login', 'Login')->addRule(Form::FILLED);
     $form->addText('email', 'E-mail')->addRule(Form::EMAIL);
     $form->addButton('btnClose', 'Close');
     $form->addSubmit('btnSave', 'Save');
     return $form;
 }
示例#6
0
 public function createComponentFormEditMenu($name)
 {
     $menu_id = $this->getParam('id');
     $templates = $this->model('Menu')->getTemplates();
     $data = $this->model('Menu')->getById($menu_id);
     $form = new LiveForm($this, $name);
     $form->addText('name', 'Name')->addRule(Form::FILLED, 'Please enter a name.')->setValue($data->name);
     $form->addSelect('template', 'Template', $templates);
     $form->addHidden('id')->setValue($menu_id);
     $form->setDefaults($data);
     $form->addButton('btnClose', 'Close');
     $form->addSubmit('save', 'Save')->onClick[] = array($this, 'formEditMenuSubmitted');
     return $form;
 }
示例#7
0
 public function createComponentFormNewMenuItem($name)
 {
     $form = new LiveForm($this, $name);
     $form->addGroup('Add new item');
     $form->addText('title', 'Title')->addRule(Form::FILLED, 'Please enter a name.');
     $form->addRadioList('link_type', 'Link type', array('internal' => 'internal', 'external' => 'external'))->setDefaultValue('internal');
     $pages = $this->model('pages')->getPairs();
     $temp = array();
     if (isset($pages[""])) {
         $temp = $pages[""];
         unset($pages[""]);
     }
     $pages = array('none' => $temp) + $pages;
     unset($temp);
     $categories = $this->model('categories')->getPairs('slug', 'title');
     $items = array('homepagelink' => 'Link to Homepage');
     foreach (array('none' => 'none') + $categories as $cat_slug => $cat_title) {
         if ($cat_title != 'none') {
             $items[$cat_slug] = 'cat: ' . $cat_title;
         }
         if (isset($pages[$cat_title])) {
             foreach ($pages[$cat_title] as $page_title => $data) {
                 if ($cat_title == 'none') {
                     $items[$data->page_slug] = 'page ' . $page_title;
                 } else {
                     $items[$cat_slug . '/' . $data->page_slug] = 'article in ' . $cat_title . ': ' . $page_title;
                 }
             }
         }
     }
     $form->addSelect('internal_url', 'Page', $items)->addRule(Form::FILLED, 'Please select a page.');
     $form->addText('external_url', 'Link')->addConditionOn($form['link_type'], Form::EQUAL, 'external')->addRule(Form::FILLED, 'Please enter a link')->addRule(Form::URL, 'Please enter a valid link');
     $items = $this->model('menuItems')->getByMenuId($this->menu->id)->fetchPairs('id_level', 'title');
     $items = array_merge(array('0;0' => 'none'), $items);
     $form->addSelect('parent_data', 'Parent', $items);
     $form->addButton('btnClose', 'Close');
     $form->addSubmit('save', 'Add')->onClick[] = array($this, 'formNewMenuItemSubmitted');
     $form['save']->getControlPrototype()->class('ajax');
     return $form;
 }
 public function createComponentFormLogin()
 {
     $form = new LiveForm();
     $renderer = $form->getRenderer();
     $form->getElementPrototype()->id = 'formLogin';
     $form->addText('email', 'E-mail')->addRule(Form::FILLED, 'Fill username');
     $form->addPassword('password', 'Password')->addRule(Form::FILLED, 'Fill password');
     $form->addSubmit('btn_login', _('Login'));
     $form['btn_login']->getControlPrototype()->class('bt_login');
     $form->onSubmit[] = array($this, 'formLoginSubmitted');
     return $form;
 }
示例#9
0
 public function createComponentFormAdminProfile($name)
 {
     $form = new LiveForm();
     $form->addGroup('My profile');
     foreach ($this->profile_data as $field => $value) {
         if ($field != 'password') {
             $form->addText($field, String::capitalize($field))->setValue($value);
         } else {
             $form->addPassword($field, 'Current ' . $field);
             $form->addPassword($field . '_new', 'New ' . $field);
             $form->addPassword($field . '_new_confirm', 'Confirm ' . $field);
         }
     }
     $form->addSubmit('btnSave', 'Save')->onClick[] = array($this, 'SaveProfile');
     return $form;
 }
示例#10
0
 public function createComponentFormCategory($name)
 {
     $form = new LiveForm($this, $name);
     $form->addText('title', 'Title')->addRule(Form::FILLED, 'Fill title');
     try {
         $categories = $this->model('categories')->getIdLevel();
     } catch (DibiDriverException $e) {
         $this->flash($e->getMessage());
         $categories = array();
     }
     $categories = array('0;0' => 'none') + $categories;
     $form->addSelect('parent', 'Parent', $categories);
     $form->addTextarea('description', 'Description');
     $templates = array('category' => 'default');
     $form->addSelect('template', 'template', $templates);
     $form->addButton('btnClose', 'Close');
     $form->addSubmit('btnSave', 'Save')->onClick[] = array($this, 'formNewCategorySubmitted');
     return $form;
 }
示例#11
0
 public function createComponentFormPreviewToolbar($name)
 {
     $form = new LiveForm($this, $name);
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = null;
     $renderer->wrappers['pair']['container'] = NULL;
     $renderer->wrappers['label']['container'] = null;
     $renderer->wrappers['control']['container'] = null;
     $form->addButton('btnClose', 'Close');
     $form->addSubmit('btnUpdate', 'Update')->onClick[] = array($this, 'formPreviewToolbarUpdate');
     $form['btnUpdate']->getControlPrototype()->class('ajax');
     return $form;
 }
示例#12
0
 public function createComponentFormModuleInstaller($name)
 {
     $form = new LiveForm($this, $name);
     $form->addFile('file', 'Select file')->addCondition(Form::FILLED, 'Please select a file');
     $form->addButton('btnClose', 'Close');
     $form->addSubmit('btnSubmit', 'Install')->onClick[] = array($this, 'formModuleInstallerSubmitted');
     return $form;
 }
示例#13
0
 public function createComponentFormAddTerm($name)
 {
     Form::extensionMethod('addDatePicker', array($this, 'Form_addDatePicker'));
     Form::extensionMethod('addTimePicker', array($this, 'Form_addTimePicker'));
     Form::extensionMethod('addNumericUpDown', array($this, 'Form_addNumericUpDown'));
     $form = new LiveForm($this, $name);
     $form->getElementPrototype()->class('ajax');
     $form->addGroup('Exam room and time');
     $rooms = SchoolManager::getRooms();
     $rooms = array('0' => 'Please select') + $rooms;
     $form->addSelect('room', 'Room', $rooms)->addRule(Form::FILLED, 'Please select a room')->skipFirst();
     $form->addDatePicker('start_date', 'Date', 10)->addRule(Form::FILLED, 'Please select a starting date');
     $form->addTimePicker('start_date_time', 'Start time', 10)->addRule(Form::FILLED, 'Please select a starting time');
     $form->addGroup('Application deadline');
     $form->addDatePicker('deadline_date', 'Date', 10)->addRule(Form::FILLED, 'Please select an application deadline date');
     $form->addTimePicker('deadline_date_time', 'Time', 10)->addRule(Form::FILLED, 'Please select an application deadline time');
     $form->addGroup('Conditions');
     $form->addText('max_students', 'Student limit')->addRule(Form::FILLED, 'Please enter a student limit.')->addRule(Form::NUMERIC, 'Limit must be numeric');
     $form->addText('min_seminar_points', 'Minimum points')->addCondition(Form::FILLED)->addRule(Form::NUMERIC, 'Limit must be numeric');
     $form->addGroup('Note')->setOption('container', Html::el('fieldset')->class('no-label'));
     $form->addTextArea('note');
     $form->addHidden('course_id')->setValue($this->course_id);
     $form->addHidden('id');
     $form->addSubmit('btnSubmit', 'Save')->onClick[] = callback($this, 'FormAddTermSubmitted');
     if ($this->isSignalReceiver($this[$name])) {
         $this->template->show_popup = true;
     }
     if (isset($this->exam_id)) {
         $session = Environment::getSession('exam_terms_edit_form_' . $this->exam_id);
         if (isset($session['form_data'])) {
             $form_data = $session->form_data;
         } else {
             $form_data = ExamManager::getExam($this->exam_id);
             $form_data->start_date = $form_data->start_datetime;
             $form_data->deadline_date = $form_data->application_deadline;
             $form_data->start_date_time = $form_data->start_datetime;
             $form_data->deadline_date_time = $form_data->application_deadline;
             $session->form_data = $form_data;
         }
         $form->setDefaults($form_data);
         $form['id']->setValue($this->exam_id);
     }
     return $form;
 }
示例#14
0
 public function createComponentFormSearch($name)
 {
     $form = new LiveForm($this, $name);
     $renderer = $form->getRenderer();
     $renderer->wrappers['form']['container'] = Html::el('div')->id('search-form');
     $renderer->wrappers['controls']['container'] = null;
     $renderer->wrappers['pair']['container'] = null;
     $renderer->wrappers['label']['container'] = null;
     $renderer->wrappers['control']['container'] = null;
     $form->addGroup('Search')->setOption('container', Html::el('fieldset')->id('search'));
     $form->addText('search_query', '');
     $form->addSubmit('ok', 'GO!')->onClick[] = array($this, 'getSearchResults');
 }
示例#15
0
 public function createComponentFormTeachersCourses($name)
 {
     $teacher_id = $this->teacher_id;
     if ($teacher_id != null) {
         $assigned_courses = $this->model('teachers')->getAssignedCourses($teacher_id);
     } else {
         $assigned_courses = array();
     }
     $form = new LiveForm();
     $form->addProtection();
     $form->addHidden('teacher_id')->setValue($teacher_id);
     $form->addSelect('course_id', 'Assigned courses', $assigned_courses, 10);
     $form->addSubmit('btnSubmitRemove', 'Remove');
     $form->onSubmit[] = array($this, 'removeCourseFromTeacher');
     return $form;
 }