public function getOptions($id = null) { if (!$this->model) { $this->model = new waCountryModel(); } if ($id) { if (!($result = $this->model->name($id))) { throw new Exception('Unknown country ISO-3 code: ' . $id); } return $result; } $result = $this->model->all(); foreach ($result as &$row) { $row = $row['name']; } return $result; }
public function getOptions($id = null) { if (isset($this->options['options']) && is_array($this->options['options'])) { return $this->options['options']; } if (!$this->model) { $this->model = new waCountryModel(); } if ($id) { if (!($result = $this->model->name($id))) { throw new Exception('Unknown country ISO-3 code: ' . $id); } return $result; } $result = $this->model->all(); foreach ($result as &$row) { $row = $row['name']; } // Config option to show subset of countries only if (isset($this->options['iso_codes']) && is_array($this->options['iso_codes'])) { $result = array_intersect_key($result, array_fill_keys($this->options['iso_codes'], true)); } return $result; }
protected function getParts($data, $format = null) { $result = array('pic' => '', 'marker' => '', 'parts' => array()); $countryName = ''; // $countryPic = ''; // $searchLink = ''; if (isset($data['data']['country']) && $data['data']['country']) { $model = new waCountryModel(); $countryName = $model->name($data['data']['country']); // Do not show pic for unknown country if ($countryName) { $result['pic'] = '<img src="' . wa_url() . 'wa-content/img/country/' . strtolower($data['data']['country']) . '.gif" class="overhanging" />'; } } if (isset($data['data']['street']) || isset($data['data']['city']) || isset($data['data']['region']) || isset($data['data']['country']) || $countryName) { $searchURL = ''; foreach (array('street', 'city', 'region') as $id) { if (!isset($data['data'][$id])) { continue; } $searchURL .= ($searchURL ? ' ' : '') . $data['data'][$id]; } if ($countryName) { $searchURL .= ($searchURL ? ' ' : '') . $countryName; } $searchURL = htmlspecialchars($searchURL); $result['marker'] = '<a href="http://mapof.it/' . $searchURL . '" class="small"><i class="icon16 marker"></i><b><i>' . _w('show on map') . '</i></b></a>'; } foreach (waContactFields::get('address')->getFields() as $field) { /** * @var waContactField $field */ $id = $field->getId(); if (isset($data['data'][$id]) && trim($data['data'][$id])) { if ($id === 'country') { $result['parts'][$id] = $countryName; } else { $result['parts'][$id] = $field->format($data['data'][$id], $format, $data['data']); } $result['parts'][$id] = htmlspecialchars($result['parts'][$id]); } } $result['marker'] = ''; // marker is disabled, but may be needed in future return $result; }