1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) { 9 header('location: index.php'); 10 exit; 11} 12 13 14/** 15 * @return array 16 */ 17function module_map_edit_features_info() 18{ 19 return [ 20 'name' => tra('Map Feature Editor'), 21 'description' => tra('Allows shapes to be drawn over the map.'), 22 'prefs' => [], 23 'params' => [ 24 'trackerId' => [ 25 'name' => tr('Tracker'), 26 'description' => tr('Tracker to store the feature in.'), 27 'required' => true, 28 'filter' => 'digits', 29 'profile_reference' => 'tracker', 30 ], 31 'hiddeninput' => [ 32 'name' => tr('Hidden Input'), 33 'description' => tr('Hidden values to be sent over to the dialog. fieldName(value)'), 34 'filter' => 'text', 35 ], 36 'standard' => [ 37 'name' => tr('Standard controls'), 38 'description' => tr('Dispay the standard draw controls'), 39 'filter' => 'int', 40 'default' => 1, 41 ], 42 'insertmode' => [ 43 'name' => tr('Mode change on insert'), 44 'description' => tr('Target mode to enter after successfully inserting an item'), 45 'filter' => 'text', 46 'default' => '', 47 ], 48 'editdetail' => [ 49 'name' => tr('Edit details'), 50 'description' => tr("Edit the tracker item's details through a dialog after the initial item creation."), 51 'filter' => 'int', 52 'default' => 0, 53 ], 54 ], 55 ]; 56} 57 58/** 59 * @param $mod_reference 60 * @param $module_params 61 */ 62function module_map_edit_features($mod_reference, $module_params) 63{ 64 $targetField = null; 65 $smarty = TikiLib::lib('smarty'); 66 67 $definition = Tracker_Definition::get($module_params['trackerId']); 68 69 if ($definition) { 70 foreach ($definition->getFields() as $field) { 71 if ($field['type'] == 'GF') { 72 $targetField = $field; 73 break; 74 } 75 } 76 } 77 78 $hiddeninput = isset($module_params['hiddeninput']) ? $module_params['hiddeninput'] : ''; 79 preg_match_all('/(\w+)\(([^\)]*)\)/', $hiddeninput, $parts, PREG_SET_ORDER); 80 $hidden = []; 81 foreach ($parts as $p) { 82 $hidden[$p[1]] = $p[2]; 83 } 84 85 $smarty->assign( 86 'edit_features', 87 [ 88 'trackerId' => $module_params['trackerId'], 89 'definition' => $definition, 90 'field' => $targetField, 91 'hiddenInput' => $hidden, 92 'standardControls' => isset($module_params['standard']) ? (int)$module_params['standard'] : 1, 93 'editDetails' => isset($module_params['editdetail']) ? (int)$module_params['editdetail'] : 0, 94 'insertMode' => isset($module_params['insertmode']) ? $module_params['insertmode'] : '', 95 ] 96 ); 97} 98