function subpools__multi_select_field($postvarname, $selected, $mpoptions = array()) { // $postvarname - name of form field // selected - array of pre-selected experimenter usernames global $lang, $settings; $out = ""; $subpools = subpools__get_subpools(); $mylist = array(); foreach ($subpools as $pool) { $mylist[$pool['subpool_id']] = $pool['subpool_name']; } if (!is_array($mpoptions)) { $mpoptions = array(); } if (!isset($mpoptions['picker_icon'])) { $mpoptions['picker_icon'] = 'globe'; } $out .= get_multi_picker($postvarname, $mylist, $selected, $mpoptions); return $out; }
function language__multiselectfield_item($content_type, $ptablevarname, $formfieldvarname, $selected, $language = "", $existing = false, $where = '', $show_count = false, $multi = true, $mpoptions = array()) { if (!$language) { global $lang; $language = lang('lang'); } $items = array(); $pars = array(':content_type' => $content_type); $query = "SELECT *, " . lang('lang') . " AS item\n FROM " . table('lang') . "\n WHERE content_type= :content_type\n ORDER BY " . pdo_escape_string($language); $result = or_query($query, $pars); while ($line = pdo_fetch_assoc($result)) { $items[$line['content_name']] = stripslashes($line['item']); } $mylist = array(); if (!$existing) { $mylist = $items; } else { $query = "SELECT count(*) as tf_count, " . pdo_escape_string($ptablevarname) . " as tf_value\n FROM " . table('participants') . "\n WHERE " . table('participants') . ".participant_id IS NOT NULL "; if ($where) { $query .= " AND " . $where . " "; } $query .= " GROUP BY " . pdo_escape_string($ptablevarname) . "\n ORDER BY " . pdo_escape_string($ptablevarname); $result = or_query($query); while ($line = pdo_fetch_assoc($result)) { $thisname = ""; if (isset($items[$line['tf_value']])) { $thisname .= $items[$line['tf_value']]; } elseif ($line['tf_value'] == 0) { $thisname .= '-'; } else { $thisname .= $line['tf_value']; } if ($show_count) { $thisname .= ' (' . $line['tf_count'] . ')'; } $mylist[$line['tf_value']] = $thisname; } } $out = ""; if (!is_array($mpoptions)) { $mpoptions = array(); } if (!isset($mpoptions['picker_icon'])) { $mpoptions['picker_icon'] = 'bars'; } if ($multi) { $out .= get_multi_picker($formfieldvarname, $mylist, $selected, $mpoptions); } else { $out .= '<SELECT name="' . $formfieldvarname . '"> <OPTION value=""'; if (!is_array($selected) || count($selected) == 0) { $out .= ' SELECTED'; } $out .= '>-</OPTION> '; foreach ($mylist as $k => $v) { $out .= '<OPTION value="' . $k . '"'; if (is_array($selected) && $selected[0] == $out || $selected == $k) { $out .= ' SELECTED'; } $out .= '>' . $v . '</OPTION> '; } $out .= '</SELECT> '; } return $out; }
function payments__paytype_multiselectfield($postvarname, $selected, $mpoptions = array()) { // $postvarname - name of form field // selected - array of pre-selected class ids if (!is_array($mpoptions)) { $mpoptions = array(); } $default_options = array('tag_color' => '#33CC33', 'picker_icon' => 'money', 'picker_color' => '#33CC33', 'picker_maxnumcols' => 1); foreach ($default_options as $k => $v) { if (!isset($mpoptions[$k])) { $mpoptions[$k] = $v; } } $mylist = payments__load_paytypes(); $out = ""; $out .= get_multi_picker($postvarname, $mylist, $selected, $mpoptions); return $out; }
function participant_status__multi_select_field($postvarname, $selected, $mpoptions = array()) { // $postvarname - name of form field // selected - array of pre-selected experimenter usernames global $lang, $settings; $out = ""; $statuses = participant_status__get_statuses(); $mylist = array(); foreach ($statuses as $status_id => $status) { $mylist[$status_id] = $status['name']; } if (!is_array($mpoptions)) { $mpoptions = array(); } if (!isset($mpoptions['picker_icon'])) { $mpoptions['picker_icon'] = 'star'; } $out .= get_multi_picker($postvarname, $mylist, $selected, $mpoptions); return $out; }
function experiment__other_experiments_select_field($postvarname, $type = "assigned", $experiment_id = "", $selected, $multi = true, $mpoptions = array()) { // $postvarname - name of form field // selected - array of pre-selected experimenter usernames global $lang, $preloaded_experiments, $settings; $out = ""; if (!(is_array($preloaded_experiments) && count($preloaded_experiments) > 0)) { $preloaded_experiments = experiment__preload_experiments(); } $mylist = array(); foreach ($preloaded_experiments as $e) { if ($e['experiment_id'] != $experiment_id && ($type == 'all' || $type == 'assigned' && $e['assigned'] == 'y' || $type == 'participated' && $e['participated'] == 'y')) { $ename = $e['experiment_name']; if ($e['time'] || $e['experimenter']) { $ename .= ' ('; } if ($e['experimenter']) { $ename .= experiment__list_experimenters($e['experimenter'], false, false); } if ($e['time'] && $e['experimenter']) { $ename .= ', '; } if ($e['time']) { $ename .= ortime__format(ortime__sesstime_to_unixtime($e['start_date']), 'hide_time:true') . '-' . ortime__format(ortime__sesstime_to_unixtime($e['end_date']), 'hide_time:true'); } if ($e['time'] || $e['experimenter']) { $ename .= ')'; } $mylist[$e['experiment_id']] = $ename; } } if (!is_array($mpoptions)) { $mpoptions = array(); } if (!isset($mpoptions['picker_icon'])) { $mpoptions['picker_icon'] = 'cogs'; } if ($multi) { $out .= get_multi_picker($postvarname, $mylist, $selected, $mpoptions); } else { $out .= '<SELECT name="' . $postvarname . '"> <OPTION value=""'; if (!$selected) { $out .= ' SELECTED'; } $out .= '>-</OPTION> '; foreach ($mylist as $k => $v) { $out .= '<OPTION value="' . $k . '"'; if ($selected == $k) { $out .= ' SELECTED'; } $out .= '>' . $v . '</OPTION> '; } $out .= '</SELECT> '; } return $out; }