static function renderFormRow($options, $lang = "en") { $_name = ""; $_sanitized_name = ""; $_label = ""; $_type = "text"; $_attribute = ""; $_value = ""; $_value_empty = ""; $_html_input = ""; $_html = ""; $_options = array(); $_selected = ""; if (!empty($options['name'])) { $_name = $options['name']; } if (!empty($options['name'])) { $_sanitized_name = preg_replace("/[^a-zA-Z0-9\\-_]+/", "", $options['name']); } if (!empty($options['label'])) { $_label = $options['label']; } if (!empty($options['type'])) { $_type = $options['type']; } if (!empty($options['attribute'])) { $_attribute = $options['attribute']; } if (!empty($options['value'])) { $_value = $options['value']; } if (!empty($options['value_empty'])) { $_value_empty = $options['value_empty']; } if (!empty($options['options'])) { $_options = $options['options']; } if (!empty($options['selected'])) { $_selected = $options['selected']; } $_required = ""; if (strpos($_attribute, 'required') !== false) { $_required .= "<span class='required'>*</span>"; } if ($_type == "text" || $_type == "email" || $_type == "tel" || $_type == "password") { $_html_input .= "<input id='input_{$_name}' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}'>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "textarea") { $_html_input .= "<textarea name='{$_name}' {$_attribute}></textarea>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "file") { $_html_input .= "<input id='input_{$_name}' type='file' name='{$_name}' {$_attribute}>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "country") { $_countries = Helper_Paypal::getPaypalCountriesAssoc(); $_html_input_option = "<option value=\"\">-- Select Country --</option>"; foreach ($_countries as $_country_key => $_country_value) { if (!empty($_value) && $_value == $_country_key) { $_html_input_option .= "<option value='{$_country_key}' selected='selected'>{$_country_value}</option>"; } else { $_html_input_option .= "<option value='{$_country_key}'>{$_country_value}</option>"; } } $_html_input .= "<select name='{$_name}' {$_attribute}>{$_html_input_option}</select>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "salutation") { if ($lang == "id") { $_salutations = array('' => '-- Harap Dipilih --', 'Mr' => 'Tuan', 'Mrs' => 'Nyonya', 'Miss' => 'Nona', 'Dr' => 'Dr'); } else { $_salutations = array('' => '-- Please Select --', 'Mr' => 'Mr', 'Mrs' => 'Mrs', 'Miss' => 'Miss', 'Ms' => 'Ms', 'Dr' => 'Dr'); } $_html_input_option = ""; foreach ($_salutations as $_salutation_key => $_salutation_value) { if (!empty($_value) && $_value == $_salutation_value) { $_html_input_option .= "<option value='{$_salutation_key}' selected='selected'>{$_salutation_value}</option>"; } else { $_html_input_option .= "<option value='{$_salutation_key}'>{$_salutation_value}</option>"; } } $_html_input .= "<select name='{$_name}' {$_attribute}>{$_html_input_option}</select>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "checkbox") { $_html_input .= "<input name='{$_name}' {$_attribute} type='checkbox'>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-input checkbox'>\n {$_html_input}\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n </div>"; } else { if ($_type == "radio") { $_html_input = ""; if (!empty($_value)) { foreach ($_value as $_v) { $_html_image = ''; if (!empty($_v['image'])) { $_html_image = '<br/><img src="' . Helper_File::addSuffix($_v['image'], '_ori') . '"/>'; } if (isset($_selected) && $_v['value'] == $_selected) { $_html_input .= "<div class='radio'><input value='" . $_v['value'] . "' name='" . $_name . "' type='radio' " . $_attribute . " checked='checked'>" . $_v['title'] . $_html_image . "</div>\n"; } else { $_html_input .= "<div class='radio'><input value='" . $_v['value'] . "' name='" . $_name . "' type='radio' " . $_attribute . ">" . $_v['title'] . $_html_image . "</div>\n"; } } } else { if (!empty($_value_empty)) { $_html_input .= "<span class='value-empty'>{$_value_empty}</span>"; } } $_html .= <<<EOD <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'> <div class='sirclo-form-input radio'> {$_html_input}</div> </div> EOD; } else { if ($_type == "checkbox_multiple") { $_html_input = ""; if (!empty($_value)) { foreach ($_value as $_v) { if (!empty($_selected) && in_array($_v['value'], $_selected)) { $_html_input .= "<div class='checkbox-multiple'><input value='" . $_v['value'] . "' name='" . $_name . "' type='checkbox' " . $_attribute . " checked='checked'>" . $_v['title'] . "</div>"; } else { $_html_input .= "<div class='checkbox-multiple'><input value='" . $_v['value'] . "' name='" . $_name . "' type='checkbox' " . $_attribute . ">" . $_v['title'] . "</div>"; } } } else { if (!empty($_value_empty)) { $_html_input .= "<span class='value-empty'>{$_value_empty}</span>"; } } $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-input checkbox-multiple'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "subheader") { $_html .= "<h3 class='{$_sanitized_name}'>" . $_value . "</h3>"; } else { if ($_type == "hidden") { $_html .= "<input id='input_{$_sanitized_name}' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}'>"; } else { if ($_type == "div") { $_html .= "<div {$_attribute}>"; } else { if ($_type == "div_close") { $_html .= "</div>"; } else { if ($_type == "submit") { if ($lang == "id") { $_html_input .= "<div class='sirclo-form-row notice'><span class='required'>*</span> wajib diisi.</div>"; } else { $_html_input .= "<div class='sirclo-form-row notice'>Fields marked with <span class='required'>*</span> are required.</div>"; } $_html_input .= "<input type='submit' value='{$_value}' {$_attribute}>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n {$_html_input}\n </div>"; } else { if ($_type == 'dropdown') { $_attrs = array(); if ($_required) { $_attrs['required'] = 'required'; } $_html_input .= Helper_Xml::xmlSelect($_name, $_options, $_value, $_attrs); $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "plain_text") { $_html_input .= "<p>{$_value}</p>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='sirclo-form-row'>\n {$_html_input}\n </div>"; } } } } } } } } } } } } } } } return $_html; }
function xmlSelect($name, $options, $value, $attrs) { return Helper_Xml::xmlSelect($name, $options, $value, $attrs); }
function _getGeneralShippingForm($cart, $shippingForm, $dataKey, $inputKey, $labelKey, $defaultShippingLabel, $optionLabel = 'options', $pleaseSelectLabel = '-- Please Select --') { $inputs = ''; $country = Helper_Structure::getArrayValue($cart, $dataKey); $countryOptions = array(array('title' => "{$pleaseSelectLabel}", 'value' => '')); $countries = $this->_getCountries($shippingForm, $optionLabel); if (!$countries) { return ''; } $countryOptions = array_merge($countryOptions, $countries); $inputs .= Helper_Xml::xmlInputHidden('cmd', $inputKey); $inputs .= Helper_Xml::xmlSelect('shipping_value', $countryOptions, $country); $inputs .= Helper_Xml::xmlEmptyTag('input', array('type' => 'submit', 'value' => 'Update')); $shippingLabel = $defaultShippingLabel; if (isset($shippingForm[$labelKey])) { $shippingLabel = $shippingForm[$labelKey]; } $label = Helper_Xml::xmlTag('span', $shippingLabel . ': '); $shippingForm = Helper_Xml::xmlTag('form', $label . $inputs, array('action' => $cart['link'], 'method' => 'post', 'class' => 'cart-shipping')); return $shippingForm; }
static function renderFormRow($options, $lang = "en") { $_name = ""; $_sanitized_name = ""; $_label = ""; $_type = "text"; $_attribute = ""; $_value = ""; $_value_empty = ""; $_html_input = ""; $_html = ""; $_options = array(); $_selected = ""; if (!empty($options['name'])) { $_name = $options['name']; } if (!empty($options['name'])) { $_sanitized_name = preg_replace("/[^a-zA-Z0-9\\-_]+/", "", $options['name']); } if (!empty($options['label'])) { $_label = $options['label']; } if (!empty($options['type'])) { $_type = $options['type']; } if (!empty($options['attribute'])) { $_attribute = $options['attribute']; } if (!empty($options['value'])) { $_value = $options['value']; } if (!empty($options['value_empty'])) { $_value_empty = $options['value_empty']; } if (!empty($options['options'])) { $_options = $options['options']; } if (!empty($options['selected'])) { $_selected = $options['selected']; } $_required = ""; if (strpos($_attribute, 'required') !== false) { $_required .= "<span class='required'>*</span>"; } /* <div class="form-group has-feedback"> <input type="text" class="form-control" placeholder="Email" /> <i class="fa fa-envelope s-top-less-margin form-control-feedback"></i> </div> */ if ($_type == "emailLogin") { $_html_input .= "<input id='input_{$_name}' class='form-control' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}' placeholder='Email'>\n\t\t\t\t\t\t\t <i class='fa fa-envelope s-top-less-margin form-control-feedback'></i>"; $_html .= '<div id="form-row-$_sanitized_name" class="form-group"> <div class="form-group has-feedback sirclo-form-input"> ' . $_html_input . ' </div> </div>'; } else { if ($_type == "passwordLogin") { $_html_input .= "<input id='input_{$_name}' class='form-control' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}' placeholder='Password'>\n\t\t\t\t\t\t\t <i class='fa fa-lock s-top-less-margin form-control-feedback'></i>"; $_html .= '<div id="form-row-$_sanitized_name" class="form-group"> <div class="form-group has-feedback sirclo-form-input"> ' . $_html_input . ' </div> </div>'; } else { if ($_type == "text" || $_type == "password" || $_type == "email" || $_type == "tel" || $_type == "date") { $_html_input .= "<input id='input_{$_name}' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}'>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "textarea") { $_html_input .= "<textarea name='{$_name}' {$_attribute}></textarea>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "file") { $_html_input .= "<input id='input_{$_name}' type='file' name='{$_name}' {$_attribute}>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "country") { $_countries = Helper_Paypal::getPaypalCountriesAssoc(); $_html_input_option = "<option value=\"\">-- Select Country --</option>"; foreach ($_countries as $_country_key => $_country_value) { if (!empty($_value) && $_value == $_country_key) { $_html_input_option .= "<option value='{$_country_key}' selected='selected'>{$_country_value}</option>"; } else { $_html_input_option .= "<option value='{$_country_key}'>{$_country_value}</option>"; } } $_html_input .= "<select name='{$_name}' {$_attribute}>{$_html_input_option}</select>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "salutation") { if ($lang == "id") { $_salutations = array('' => '-- Harap Dipilih --', 'Mr' => 'Tuan', 'Mrs' => 'Nyonya', 'Miss' => 'Nona', 'Dr' => 'Dr'); } else { $_salutations = array('' => '-- Please Select --', 'Mr' => 'Mr', 'Mrs' => 'Mrs', 'Miss' => 'Miss', 'Ms' => 'Ms', 'Dr' => 'Dr'); } $_html_input_option = ""; foreach ($_salutations as $_salutation_key => $_salutation_value) { if (!empty($_value) && $_value == $_salutation_value) { $_html_input_option .= "<option value='{$_salutation_key}' selected='selected'>{$_salutation_value}</option>"; } else { $_html_input_option .= "<option value='{$_salutation_key}'>{$_salutation_value}</option>"; } } $_html_input .= "<select name='{$_name}' {$_attribute}>{$_html_input_option}</select>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "checkbox") { $_html_input .= "<input name='{$_name}' {$_attribute} type='checkbox'>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group checkbox'>\n <label for='{$_name}'>\n <input name ='agreement' required type='checkbox'>\n {$_label}\n {$_required}\n </label>\n </div>"; } else { if ($_type == "radio") { $_html_input = ""; if (!empty($_value)) { foreach ($_value as $_v) { $_html_image = ''; if (!empty($_v['image'])) { foreach ($_v['image'] as $img) { if ($_html_image == '') { $_html_image .= '<br/>'; } $_html_image .= '<img class="s-icon-pay" src="' . $img . '"/>'; } } if (isset($_selected) && $_v['value'] == $_selected) { $_html_input .= "<label><input value='" . $_v['value'] . "' name='" . $_name . "' type='radio' " . $_attribute . " checked='checked'>" . $_v['title'] . $_html_image . "</label>\n"; } else { $_html_input .= "<label><input value='" . $_v['value'] . "' name='" . $_name . "' type='radio' " . $_attribute . ">" . $_v['title'] . $_html_image . "</label>\n"; } } } else { if (!empty($_value_empty)) { $_html_input .= "<span class='value-empty'>{$_value_empty}</span>"; } } $_html .= <<<EOD <div id='form-row-{$_sanitized_name}' class='form-group radio'> {$_html_input} </div> EOD; } else { if ($_type == "checkbox_multiple") { $_html_input = ""; if (!empty($_value)) { foreach ($_value as $_v) { if (!empty($_selected) && in_array($_v['value'], $_selected)) { $_html_input .= "<div class='checkbox-multiple'><input value='" . $_v['value'] . "' name='" . $_name . "' type='checkbox' " . $_attribute . " checked='checked'>" . $_v['title'] . "</div>"; } else { $_html_input .= "<div class='checkbox-multiple'><input value='" . $_v['value'] . "' name='" . $_name . "' type='checkbox' " . $_attribute . ">" . $_v['title'] . "</div>"; } } } else { if (!empty($_value_empty)) { $_html_input .= "<span class='value-empty'>{$_value_empty}</span>"; } } $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-input checkbox-multiple'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "subheader") { $_html .= "<h2 class='{$_sanitized_name}'>" . $_value . "</h2>"; } else { if ($_type == "hidden") { $_html .= "<input id='input_{$_sanitized_name}' type='{$_type}' name='{$_name}' {$_attribute} value='{$_value}'>"; } else { if ($_type == "div") { $_html .= "<div {$_attribute}>"; } else { if ($_type == "div_close") { $_html .= "</div>"; } else { if ($_type == "submit") { if ($_value == "LOGIN") { $_html_input .= '<button class="btn btn-lg blue-button s-fullwidth s-bottom-margin s-top-less-margin s-login-button">LOGIN</button>'; } else { if ($_value == "REGISTER") { $_html_input .= '<button type="submit" class="btn btn-lg blue-button"> REGISTER </button>'; } else { if ($_value == "SEND") { $_html_input .= '<button type="submit" class="btn btn-lg blue-button">SEND</button>'; } else { if ($_value == "CHANGE PASSWORD") { $_html_input .= '<button type="submit" class="btn btn-lg blue-button s-change-password-submit">CHANGE PASSWORD</button>'; } else { /* if ($lang == "id") { $_html_input .= "<div class='form-group notice'><span class='required'>*</span> wajib diisi.</div>"; } else { $_html_input .= "<div class='form-group notice'>Fields marked with <span class='required'>*</span> are required.</div>"; }*/ $_html_input .= "<input type='submit' value='{$_value}' {$_attribute}>"; } } } } $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n {$_html_input}\n </div>"; } else { if ($_type == 'dropdown') { $_attrs = array(); if ($_required) { $_attrs['required'] = 'required'; } $_html_input .= Helper_Xml::xmlSelect($_name, $_options, $_value, $_attrs); $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n <div class='sirclo-form-label'>\n <label for='{$_name}'>\n {$_label}\n {$_required}\n </label>\n </div>\n <div class='sirclo-form-input'>\n {$_html_input}\n </div>\n </div>"; } else { if ($_type == "plain_text") { $_html_input .= "<p>{$_value}</p>"; $_html .= "\n <div id='form-row-{$_sanitized_name}' class='form-group'>\n {$_html_input}\n </div>"; } } } } } } } } } } } } } } } } } return $_html; }