public static function drawInput($input_name, $input_data, $cloneparent = false, $clonecount = false) { // handle appending clone count stuff more intelligently $original_input_name = $input_name; if ($clonecount !== false) { $input_name = $input_name . '-clone-' . $cloneparent . '-' . $clonecount; } // label (for everything except checkboxes) if ($input_data['type'] !== 'boolean') { $return_str = '<label for="' . $input_name . '">' . $input_data['label']['en'] . '</label>'; } /* start outputting markup depending on type */ if ($input_data['type'] == 'text' || $input_data['type'] == 'number') { if ($input_data['type'] == 'text' && $input_data['displaysize'] == 'large') { $return_str .= '<textarea id="' . $input_name . '" name="' . $input_name . '" class="'; } else { $return_str .= '<input type="text" id="' . $input_name . '" name="' . $input_name . '" value="{{#options_' . $input_name . '}}{{options_' . $input_name . '}}{{/options_' . $input_name . '}}{{^options_' . $input_name . '}}{{element_copy_' . $input_name . '}}{{/options_' . $input_name . '}}" class="'; } } if ($input_data['type'] == 'select') { $return_str .= '<select id="' . $input_name . '" name="' . $input_name . '" class="'; } if ($input_data['type'] == 'boolean') { $return_str = '<label class="checkbox" for="' . $input_name . '"><input type="checkbox" class="checkorradio" id="' . $input_name . '" name="' . $input_name . '" value="1"'; } if ($input_data['type'] == 'options') { $return_str .= '<div class="' . $input_data['type'] . '" data-name="' . $input_name . '">'; foreach ($input_data['values'] as $subname => $subdata) { $return_str .= AdminHelper::drawInput($original_input_name . '-' . $subname, $subdata, $cloneparent, $clonecount); } $return_str .= '</div>'; } if ($input_data['type'] == 'scalar') { if (isset($input_data['description'])) { $return_str .= '<div class="description"><p>' . $input_data['description']['en'] . '</p></div>'; } $return_str .= '<div class="' . $input_data['type'] . '" data-name="' . $input_name . '"'; if (isset($input_data['actiontext']['en'])) { $return_str .= ' data-actiontext="' . $input_data['actiontext']['en'] . '"'; } if (isset($input_data['scalar_clone_count'])) { $return_str .= ' data-clonecount="' . $input_data['scalar_clone_count'] . '"'; } else { $return_str .= ' data-clonecount="0"'; } $return_str .= '>'; $return_str .= AdminHelper::drawMarkup(false, $input_data['values'], count($input_data['values'])); /* HEY CHRIS: If we run into any trouble, here's how I was doing stuff before the drawMarkup change... foreach ($input_data['values'] as $subname => $subdata) { $return_str .= AdminHelper::drawInput($subname,$subdata); } */ $return_str .= '</div>'; if (isset($input_data['scalar_clone_count'])) { for ($i = 0; $i < $input_data['scalar_clone_count']; $i++) { $return_str .= '<div class="clonedscalar">'; $return_str .= AdminHelper::drawMarkup(false, $input_data['values'], count($input_data['values']), $input_name, $i); /* HEY CHRIS: If we run into any trouble, here's how I was doing stuff before the drawMarkup change... foreach ($input_data['values'] as $subname => $subdata) { $return_str .= AdminHelper::drawInput($subname,$subdata,$input_name,$i); } */ $return_str .= '<a href="#" class="removescalar"><div class="icon icon-plus"></div></a></div>'; } } } if ($input_data['type'] != 'scalar' && $input_data['type'] != 'scalar') { /* declare any classes that need declaring (form validation or special functionality) */ if (isset($input_data['required'])) { if ($input_data['required']) { $return_str .= ' required'; } } if ($input_data['type'] == 'number') { $return_str .= ' number'; } /* close out markup */ if ($input_data['type'] == 'text' || $input_data['type'] == 'number') { if ($input_data['type'] == 'text' && $input_data['displaysize'] == 'large') { $return_str .= '">{{#options_' . $input_name . '}}{{options_' . $input_name . '}}{{/options_' . $input_name . '}}{{^options_' . $input_name . '}}{{element_copy_' . $input_name . '}}{{/options_' . $input_name . '}}</textarea>'; } else { if (isset($input_data['placeholder'])) { $return_str .= ' placeholder="' . $input_data['placeholder']['en'] . '"'; } $return_str .= '" />'; } } if ($input_data['type'] == 'select') { $return_str .= '">{{{options_' . $input_name . '}}}</select>'; } if ($input_data['type'] == 'boolean') { $return_str .= '{{#options_' . $input_name . '}} checked="checked"{{/options_' . $input_name . '}} /> ' . $input_data['label']['en'] . '</label>'; } } return $return_str; }