$item_created_list .= '</select>'; $item1_list = '<select name="item1">'; for ($i = 0; $i < count($items); $i++) { $item1_list .= '<option value = "' . $items[$i]['item_id'] . '"' . html_selected($items[$i]['item_id'] == $combine1_item) . '>' . $items[$i]['item_name'] . '</option>'; } $item1_list .= '</select>'; // Show item2 list $item2_list = '<select name="item2">'; for ($i = 0; $i < count($items); $i++) { $item2_list .= '<option value = "' . $items[$i]['item_id'] . '"' . html_selected($items[$i]['item_id'] == $combine2_item) . '>' . $items[$i]['item_name'] . '</option>'; } $item2_list .= '</select>'; // Show item3 list $item3_list = '<select name="item3">'; for ($i = 0; $i < count($items); $i++) { $item3_list .= '<option value = "' . $items[$i]['item_id'] . '"' . html_selected($items[$i]['item_id'] == $combine3_item) . '>' . $items[$i]['item_name'] . '</option>'; } $item3_list .= '</select>'; // //END Item Choice List // $template->assign_vars(array("ITEM1" => $item1_list, "ITEM2" => $item2_list, "ITEM3" => $item3_list, "ITEM_CREATED" => $item_created_list, "L_CAULDRON_TITLE" => $lang['Adr_cauldron'], "L_CAULDRON_EXPLAIN" => $lang['Adr_cauldron_explain'], "L_ITEM1_TITLE" => $lang['Adr_item1_combine_name'], "L_ITEM2_TITLE" => $lang['Adr_item2_combine_name'], "L_ITEM3_TITLE" => $lang['Adr_item3_combine_name'], "L_ITEM_CREATED_TITLE" => $lang['Adr_item_created_name'], "L_SUBMIT" => $lang['Submit'], "S_HIDDEN_FIELDS" => $s_hidden_fields, "S_CAULDRON_ACTION" => append_sid("admin_adr_cauldron.{$phpEx}"))); $template->pparse("body"); break; case "save": $pack_id = !empty($HTTP_POST_VARS['pack_id']) ? intval($HTTP_POST_VARS['pack_id']) : intval($HTTP_GET_VARS['pack_id']); $combine1 = isset($HTTP_POST_VARS['item1']) ? trim($HTTP_POST_VARS['item1']) : trim($HTTP_GET_VARS['item1']); $combine2 = isset($HTTP_POST_VARS['item2']) ? trim($HTTP_POST_VARS['item2']) : trim($HTTP_GET_VARS['item2']); $combine3 = isset($HTTP_POST_VARS['item3']) ? trim($HTTP_POST_VARS['item3']) : trim($HTTP_GET_VARS['item3']); $combine_result = isset($HTTP_POST_VARS['item_created']) ? trim($HTTP_POST_VARS['item_created']) : trim($HTTP_GET_VARS['item_created']); if ($combine1 == '0' || $combine2 == '0' || $combine3 == '0' || $combine_result == '0') {
/** * Options. * @param any $input * @param any $current * @param any $extra * @param array $pairs * @return string */ function html_options($input, $current = null, $extra = null, array $pairs = null) : string { // shorcuts for date-time stuff if (is_string($input)) { switch ($input) { case 'day': case 'days': $input = []; for ($i = 1; $i <= 31; $i++) { $input[$i] = $i; } break; case 'month': case 'months': $input = []; for ($i = 1; $i <= 12; $i++) { $input[$i] = strftime('%B', strtotime('December +' . $i . ' months')); } break; case 'year': case 'years': if (is_array($extra)) { @(list($start, $stop) = $extra); if (!$stop) { $stop = date('Y') + 1; } $extra = ''; } else { $start = date('Y'); $stop = date('Y') + 1; } $input = []; for ($i = $start; $i <= $stop; $i++) { $input[$i] = $i; } break; case 'hour': case 'hours': $input = []; for ($i = 0; $i < 24; $i++) { if ($extra === true) { $value = sprintf('%02d:00', $i); } else { $value = sprintf('%02d', $i); } $input[$value] = $value; } break; case 'minute': case 'minutes': $input = []; for ($i = 0; $i < 60; $i++) { $value = sprintf('%02d', $i); $input[$value] = $value; } break; } } elseif (is_array($input) && !empty($pairs)) { // only two dimentions like "id => 1, name => foo" list($key, $value) = $pairs; $tmp = []; foreach ($input as $input) { $input = (array) $input; $tmp[$input[$key]] = $input[$value]; } $input = $tmp; } // check input if (!is_array($input)) { trigger_error('Cannot iterate input.'); } if (is_string($extra) && $extra != '') { $extra = ' ' . trim($extra); } else { $extra = ''; } $return = ''; foreach ($input as $key => $value) { $return .= sprintf('<option value="%s"%s%s>%s</option>', $key, html_selected($key, $current), $extra, $value); } return $return; }