3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class generates form components for Mapping and Geocoding.
21 class CRM_Admin_Form_Setting_Mapping
extends CRM_Admin_Form_Setting
{
23 protected $_settings = [
24 'mapAPIKey' => CRM_Core_BAO_Setting
::MAP_PREFERENCES_NAME
,
25 'mapProvider' => CRM_Core_BAO_Setting
::MAP_PREFERENCES_NAME
,
26 'geoAPIKey' => CRM_Core_BAO_Setting
::MAP_PREFERENCES_NAME
,
27 'geoProvider' => CRM_Core_BAO_Setting
::MAP_PREFERENCES_NAME
,
31 * Build the form object.
33 public function buildQuickForm() {
34 CRM_Utils_System
::setTitle(ts('Settings - Mapping and Geocoding Providers'));
35 parent
::buildQuickForm();
41 * @param array $fields
42 * The input form values.
45 * true if no errors, else array of errors
47 public static function formRule($fields) {
50 if (!CRM_Utils_System
::checkPHPVersion(5, FALSE)) {
51 $errors['_qf_default'] = ts('Mapping features require PHP version 5 or greater');
54 if ($fields['mapProvider'] == 'OpenStreetMaps' && $fields['geoProvider'] == '') {
55 $errors['geoProvider'] = "Please select a Geocoding Provider - Open Street Maps does not provide geocoding.";
62 * Add the rules (mainly global rules) for form.
64 * All local rules are added near the element
66 public function addRules() {
67 $this->addFormRule(['CRM_Admin_Form_Setting_Mapping', 'formRule']);