/** * build a select expression * Example: * array ( * array ( * 'COL' => 'fieldname', * 'FROM' => 'tablealias', * 'AS' => 'colalias', * 'FUNC' => 'count', * 'ARG' => "last_name,', ',first_name" * 'MATH' => '+' * 'LEFT' => array (...) * 'RIGHT' => array (...) * ) * ); * * => make := Funktion die String baut * => S = make(LEFT) + MATH + make(RIGHT) END;// if MATH, LEFT * => S = FUNC(ARG)// if FUNC && ARG * => S = COL // if COL == * && !FUNC && ARG * => S = `COL` // if !FUNC && ARG * => S = FROM.S // if FROM * => S = FUNC(S) // if FUNC * => S = S AS "AS" END;// if AS * * @param $col * @return string */ private function select_expr($col) { initstr($cols_list); if (isset($col['MATH'], $col['LEFT'], $col['RIGHT'])) { $cols_list = '(' . $this->select_expr($col['LEFT']) . ') ' . $col['MATH'] . ' (' . $this->select_expr($col['RIGHT']) . ')'; } else { //=> S = FUNC(ARG)// if FUNC && ARG if (isset($col['FUNC'], $col['ARG'])) { $cols_list = $col['FUNC'] . '(' . $col['ARG'] . ')'; } else { //=> S = COL || `COL` $cols_list = $col['COL'] == '*' ? $col['COL'] : '`' . $col['COL'] . '`'; //=> S = FROM.S // if FROM $cols_list = isset($col['FROM']) ? $col['FROM'] . '.' . $cols_list : $cols_list; //=> S = FUNC(S) // if FUNC $cols_list = isset($col['FUNC']) ? $col['FUNC'] . '(' . $cols_list . ')' : $cols_list; } //=> S = S AS "AS" // if AS $cols_list = isset($col['AS']) ? $cols_list . " AS '" . $col['AS'] . "'" : $cols_list; } return $cols_list; }
$antworten .= $template; } // Get Template $template = new \template(); $template->setFile('0_polls.tpl'); $template->load('APPLET_RESULT_BODY'); $template->tag('question', $poll_arr['poll_quest']); $template->tag('answers', $antworten); $template->tag('all_votes', $all_votes); $template->tag('participants', $poll_arr['poll_participants']); $template = $template->display(); } elseif (isset($poll_arr['poll_id']) && !checkVotedPoll($poll_arr['poll_id'])) { $poll_arr['poll_type_text'] = $poll_arr['poll_type'] == 1 ? $FD->text("frontend", "multiple_choise") : $FD->text("frontend", "single_choice"); /** @var \PDOStatement $index2 */ $index2 = $FD->db()->conn()->query('SELECT * FROM ' . $FD->db()->getPrefix() . 'poll_answers WHERE poll_id = ' . $poll_arr['poll_id'] . ' ORDER BY answer_id ASC'); initstr($antworten); while ($answer_arr = $index2->fetch(\PDO::FETCH_ASSOC)) { if ($poll_arr['poll_type'] == 0) { $poll_arr['poll_type2'] = 'radio'; $poll_arr['poll_type3'] = ''; } if ($poll_arr['poll_type'] == 1) { $poll_arr['poll_type2'] = 'checkbox'; $poll_arr['poll_type3'] = '[]'; } // Get Template $template = new \template(); $template->setFile('0_polls.tpl'); $template->load('APPLET_POLL_ANSWER_LINE'); $template->tag('answer_id', $answer_arr['answer_id']); $template->tag('answer', $answer_arr['answer']);