/** * Get format of the address book * * @access public * @param mixed * @param string * @return string */ public function format($address, $new_line = "\n") { $address_format = $address['address_format']; if (empty($address_format)) { $address_format = ":name\n:street_address\n:postcode :city\n:country"; } $find_array = array('/\\:name\\b/', '/\\:street_address\\b/', '/\\:suburb\\b/', '/\\:city\\b/', '/\\:postcode\\b/', '/\\:state\\b/', '/\\:zone_code\\b/', '/\\:country\\b/'); $replace_array = array(output_string_protected($address['firstname'] . ' ' . $address['lastname']), output_string_protected($address['street_address']), output_string_protected($address['suburb']), output_string_protected($address['city']), output_string_protected($address['postcode']), output_string_protected($address['zone_name']), output_string_protected($address['zone_code']), output_string_protected($address['countries_name'])); $formated = preg_replace($find_array, $replace_array, $address_format); if (config('ACCOUNT_COMPANY') > -1 && !empty($address['company'])) { $formated = output_string_protected($address['company']) . $new_line . $formated; } if ($new_line != "\n") { $formated = str_replace("\n", $new_line, $formated); } return $formated; }
public function format($address, $new_line = "\n") { $this->ci->load->helper('string'); $address_format = ''; if (is_numeric($address)) { $address = $this->ci->address_model->get_address($address); } $firstname = $lastname = ''; if (isset($address['firstname']) && !empty($address['firstname'])) { $firstname = $address['firstname']; $lastname = $address['lastname']; } elseif (isset($address['name']) && !empty($address['name'])) { $firstname = $address['name']; } $state = $address['state']; $state_code = $address['zone_code']; if (isset($address['zone_id']) && is_numeric($address['zone_id']) && $address['zone_id'] > 0) { $zone_info = $this->ci->address_model->get_zone_info($address['zone_id']); $state = $zone_info['zone_name']; $state_code = $zone_info['zone_code']; } $country = $address['country_title']; if (isset($address['country_id']) && is_numeric($address['country_id']) && $address['country_id'] > 0) { $country_info = $this->ci->address_model->get_country_name($address['country_id']); } if (empty($country) && isset($address['country_id']) && is_numeric($address['country_id']) && $address['country_id'] > 0) { $country = $country_info['countries_name']; } if (isset($address['format'])) { $address_format = $address['format']; } elseif (isset($address['country_id']) && is_numeric($address['country_id']) && $address['country_id'] > 0) { $address_format = $country_info['address_format']; } if (empty($address_format)) { $address_format = ":name\n:street_address\n:postcode :city\n:country"; } $find_array = array('/\\:name\\b/', '/\\:street_address\\b/', '/\\:suburb\\b/', '/\\:city\\b/', '/\\:postcode\\b/', '/\\:state\\b/', '/\\:state_code\\b/', '/\\:country\\b/'); $replace_array = array(output_string_protected($firstname . ' ' . $lastname), output_string_protected($address['street_address']), output_string_protected($address['suburb']), output_string_protected($address['city']), output_string_protected($address['postcode']), output_string_protected($state), output_string_protected($state_code), output_string_protected($country)); $formated = preg_replace($find_array, $replace_array, $address_format); if (ACCOUNT_COMPANY > -1 && !empty($address['company'])) { $company = output_string_protected($address['company']); $formated = $company . $new_line . $formated; } if ($new_line != "\n") { $formated = str_replace("\n", $new_line, $formated); } return $formated; }
/** * Outputs a form textarea field * * @param string $name The name and ID of the textarea field * @param string $value The default value for the textarea field * @param int $width The width of the textarea field * @param int $height The height of the textarea field * @param string $parameters Additional parameters for the textarea field * @param boolean $override Override the default value with the value found in the GET or POST scope * @access public */ function draw_textarea_field($name, $value = null, $width = 60, $height = 5, $parameters = null, $override = true) { if (!is_bool($override)) { $override = true; } if ($override === true) { if (isset($_GET[$name])) { $value = $_GET[$name]; } elseif (isset($_POST[$name])) { $value = $_POST[$name]; } } if (!is_numeric($width)) { $width = 60; } if (!is_numeric($height)) { $width = 5; } $field = '<textarea name="' . output_string($name) . '" cols="' . (int) $width . '" rows="' . (int) $height . '"'; if (strpos($parameters, 'id=') === false) { $field .= ' id="' . output_string($name) . '"'; } if (!empty($parameters)) { $field .= ' ' . $parameters; } $field .= '>' . output_string_protected($value) . '</textarea>'; return $field; }
function valueMixed($column, $type = 'string') { if (!isset($this->result)) { $this->next(); } switch ($type) { case 'protected': return output_string_protected($this->result[$column]); break; case 'int': return (int) $this->result[$column]; break; case 'decimal': return (double) $this->result[$column]; break; case 'string': default: return $this->result[$column]; } }