コード例 #1
0
    public function OnLoadPageData()
    {
        require_once "stoolball/schools/school-manager.class.php";
        $school_manager = new SchoolManager($this->GetSettings(), $this->GetDataConnection());
        $search_terms = array();
        if (isset($_GET["name"])) {
            $search_terms[] = $_GET["name"];
        }
        if (isset($_GET["town"])) {
            $search_terms[] = $_GET["town"];
        }
        if (count($search_terms)) {
            $school_manager->FilterBySearch(implode(' ', $search_terms));
        }
        $school_manager->ReadAll();
        $schools = $school_manager->GetItems();
        unset($school_manager);
        if (count($schools)) {
            # Build up the data to display in the autocomplete dropdown
            $school_data = array();
            foreach ($schools as $school) {
                /* @var $school Club */
                # escape single quotes because this will become JS string
                $escaped_name = str_replace("'", "\\'", $school->GetName());
                $escaped_url = str_replace("'", "\\'", $school->GetNavigateUrl());
                $school_data[] = '{"name":"' . $escaped_name . '","url":"' . $escaped_url . '"}';
            }
            # Write those names as a JS array
            ?>
[<?php 
            echo implode(",\n", $school_data);
            ?>
]
			<?php 
        }
        exit;
    }
コード例 #2
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;
 }