Beispiel #1
0
function DateField($field_name, $field_seed, $default, &$codes)
{
    // Decode the default date
    $day = substr($default, 8, 2);
    $month = substr($default, 5, 2);
    $year = substr($default, 0, 4);
    // Create the lists
    $cur_year = Date("Y");
    for ($d = 1; $d <= 31; $d++) {
        $list_days[$d] = $d;
    }
    for ($y = $cur_year - 1; $y <= $cur_year + 5; $y++) {
        $list_years[$y] = $y;
    }
    $list_months = $codes->get("months");
    // Create the select fields
    $day_field = SelectField($field_name . "[" . $field_seed . "_day]", $list_days, $day);
    $month_field = SelectField($field_name . "[" . $field_seed . "_month]", $list_months, $month);
    $year_field = SelectField($field_name . "[" . $field_seed . "_year]", $list_years, $year);
    return $day_field . $month_field . $year_field;
}
 private function CreateQuestionsField($tpl, $db, $db_encoding, $field_type)
 {
     if ($field_type == "PAPER") {
         $tb_question = "PaperQuestion";
         $tb_choice = "PQChoice";
         $select_field = "paperQuestions";
         $namespace = "author";
     } else {
         $tb_question = "ReviewQuestion";
         $tb_choice = "RQChoice";
         $select_field = "reviewQuestions";
         $namespace = "reviewer";
     }
     // First decode the current default values, from Config
     $questions = array();
     if (!empty($db_encoding)) {
         $coded_questions = explode(";", $db_encoding);
         $questions = array();
         foreach ($coded_questions as $question) {
             $q = explode(",", $question);
             $questions[trim($q[0])] = trim($q[1]);
         }
     }
     $nb_questions = 0;
     $rq = $db->execRequete("SELECT * FROM {$tb_question}");
     while ($question = $db->objetSuivant($rq)) {
         // Get the list of choices
         $rc = $db->execRequete("SELECT * FROM {$tb_choice} " . " WHERE id_question='{$question->id}'");
         $list_choices = array("0" => "Any");
         while ($choice = $db->objetSuivant($rc)) {
             $list_choices[$choice->id_choice] = $choice->choice;
         }
         if (isset($questions[$question->id])) {
             $def_val = $questions[$question->id];
         } else {
             $def_val = SP_ANY_CHOICE;
         }
         $sel_choices = SelectField("{$select_field}" . "[{$question->id}]", $list_choices, $def_val);
         $this->view->set_var("QUESTION", "{" . "{$namespace}." . $question->question_code . "}");
         $this->view->set_var("CHOICES", $sel_choices);
         // Instantiate twice, for translations
         $this->view->assign("TMP", "{$field_type}_QUESTION");
         $this->view->append("{$field_type}_QUESTIONS", "TMP");
         $nb_questions++;
     }
     return $nb_questions;
 }