// | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software Foundation, | // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | // | | // +--------------------------------------------------------------------------+ require_once '../../../lib-common.php'; require_once 'edit_functions.php'; if (!SEC_hasRights('maps.admin')) { exit; } // Incoming variable filter $vars = array('action' => 'alpha', 'id' => 'number', 'mid' => 'number'); maps_filterVars($vars, $_POST); switch ($_POST['action']) { case 'delete': DB_delete($_TABLES['maps_map_overlay'], 'mo_id', $_POST['id']); echo '<div id="overlays_actions"><div id="overlays_list">' . MAPS_displayOverlays($_POST['mid']) . '</div>'; echo "<script type=\"text/javascript\">jQuery(document).ready(function() {\n\t\tjQuery('#load').hide();\n\t\t});\n\n\t\tjQuery(function() {\n\t\t\tjQuery(\".delete\").click(function() {\n\t\t\t\tjQuery('#load').show();\n\t\t\t\tvar id = jQuery(this).attr(\"id\");\n\t\t\t\tvar mid = jQuery(this).attr(\"mid\");\n\t\t\t\tvar oid = jQuery(this).attr(\"oid\");\n\t\t\t\tvar action = jQuery(this).attr(\"class\");\n\t\t\t\tvar string = 'id='+ id + '&action=' + action + '&mid=' + mid;\n\t\t\t\t\t\n\t\t\t\tjQuery.ajax({\n\t\t\t\t\ttype: \"POST\",\n\t\t\t\t\turl: \"ajax.php\",\n\t\t\t\t\tdata: string,\n\t\t\t\t\tcache: false,\n\t\t\t\t\tasync:false,\n\t\t\t\t\tsuccess: function(result){\n\t\t\t\t\t\tjQuery(\"#overlays_actions\").replaceWith(result);\n\t\t\t\t\t} \n\t\t\t\t});\n\t\t\t\tjQuery('#load').hide();\n\t\t\t\treturn false;\n\t\t\t});\n\t\t\tjQuery(\".add\").click(function() {\n\t\t\t\tjQuery('#load').show();\n\t\t\t\tvar id = jQuery(this).attr(\"id\");\n\t\t\t\tvar mid = jQuery(this).attr(\"mid\");\n\t\t\t\tvar oid = jQuery(this).attr(\"oid\");\n\t\t\t\tvar action = jQuery(this).attr(\"class\");\n\t\t\t\tvar string = 'id='+ id + '&action=' + action + '&mid=' + mid;\n\t\t\t\t\t\n\t\t\t\tjQuery.ajax({\n\t\t\t\t\ttype: \"POST\",\n\t\t\t\t\turl: \"ajax.php\",\n\t\t\t\t\tdata: string,\n\t\t\t\t\tcache: false,\n\t\t\t\t\tasync:false,\n\t\t\t\t\tsuccess: function(result){\n\t\t\t\t\t\tjQuery(\"#overlays_actions\").replaceWith(result);\n\t\t\t\t\t} \n\t\t\t\t});\n\t\t\t\tjQuery('#load').hide();\n\t\t\t\treturn false;\n\t\t\t});\n\t\t});\n\t</script>"; echo '<div id="overlays_list">' . MAPS_displayOverlaysToAdd($_POST['mid']) . '</div>'; break; case 'add': $sql = "mo_mid = '{$_POST['mid']}', " . "mo_oid = '{$_POST['id']}'\n\t\t\t "; $sql = "INSERT INTO {$_TABLES['maps_map_overlay']} SET {$sql} "; DB_query($sql, $ignore_errors = 0); echo '<div id="overlays_actions"><div id="overlays_list">' . MAPS_displayOverlays($_POST['mid']) . '</div>'; echo "<script type=\"text/javascript\">jQuery(document).ready(function() {\n\t\tjQuery('#load').hide();\n\t\t});\n\n\t\tjQuery(function() {\n\t\t\tjQuery(\".delete\").click(function() {\n\t\t\t\tjQuery('#load').show();\n\t\t\t\tvar id = jQuery(this).attr(\"id\");\n\t\t\t\tvar mid = jQuery(this).attr(\"mid\");\n\t\t\t\tvar oid = jQuery(this).attr(\"oid\");\n\t\t\t\tvar action = jQuery(this).attr(\"class\");\n\t\t\t\tvar string = 'id='+ id + '&action=' + action + '&mid=' + mid;\n\t\t\t\t\t\n\t\t\t\tjQuery.ajax({\n\t\t\t\t\ttype: \"POST\",\n\t\t\t\t\turl: \"ajax.php\",\n\t\t\t\t\tdata: string,\n\t\t\t\t\tcache: false,\n\t\t\t\t\tasync:false,\n\t\t\t\t\tsuccess: function(result){\n\t\t\t\t\t\tjQuery(\"#overlays_actions\").replaceWith(result);\n\t\t\t\t\t} \n\t\t\t\t});\n\t\t\t\tjQuery('#load').hide();\n\t\t\t\treturn false;\n\t\t\t});\n\t\t\tjQuery(\".add\").click(function() {\n\t\t\t\tjQuery('#load').show();\n\t\t\t\tvar id = jQuery(this).attr(\"id\");\n\t\t\t\tvar mid = jQuery(this).attr(\"mid\");\n\t\t\t\tvar oid = jQuery(this).attr(\"oid\");\n\t\t\t\tvar action = jQuery(this).attr(\"class\");\n\t\t\t\tvar string = 'id='+ id + '&action=' + action + '&mid=' + mid;\n\t\t\t\t\t\n\t\t\t\tjQuery.ajax({\n\t\t\t\t\ttype: \"POST\",\n\t\t\t\t\turl: \"ajax.php\",\n\t\t\t\t\tdata: string,\n\t\t\t\t\tcache: false,\n\t\t\t\t\tasync:false,\n\t\t\t\t\tsuccess: function(result){\n\t\t\t\t\t\tjQuery(\"#overlays_actions\").replaceWith(result);\n\t\t\t\t\t} \n\t\t\t\t});\n\t\t\t\tjQuery('#load').hide();\n\t\t\t\treturn false;\n\t\t\t});\n\t\t});\n\t</script>"; echo '<div id="overlays_list">' . MAPS_displayOverlaysToAdd($_POST['mid']) . '</div>'; break; }
/** * This function creates a map Form * * Creates a Form for a map using the supplied defaults (if specified). * * @param array $map array of values describing a map * @return string HTML string of map form */ function getMapForm($map = array()) { global $_CONF, $_TABLES, $_MAPS_CONF, $LANG_MAPS_1, $LANG_configselects, $LANG_ACCESS, $_USER, $_GROUPS, $_SCRIPTS; $_SCRIPTS->setJavaScriptLibrary('jquery'); $js = 'jQuery(function () { var tabContainers = jQuery(\'div.tabs > div\'); jQuery(\'div.tabs ul.tabNavigation a\').click(function () { tabContainers.hide().filter(this.hash).show(); jQuery(\'div.tabs ul.tabNavigation a\').removeClass(\'selected\'); jQuery(this).addClass(\'selected\'); return false; }).filter(\':first\').click(); jQuery(".delete").click(function() { jQuery("#load").show(); var id = jQuery(this).attr("id"); var mid = jQuery(this).attr("mid"); var oid = jQuery(this).attr("oid"); var action = jQuery(this).attr("class"); var string = \'id=\'+ id + \'&action=\' + action + \'&mid=\' + mid; jQuery.ajax({ type: "POST", url: "ajax.php", data: string, cache: false, async:false, success: function(result){ jQuery("#overlays_actions").replaceWith(result); } }); jQuery("#load").hide(); return false; }); jQuery(".add").click(function() { jQuery("#load").show(); var id = jQuery(this).attr("id"); var mid = jQuery(this).attr("mid"); var oid = jQuery(this).attr("oid"); var action = jQuery(this).attr("class"); var string = \'id=\'+ id + \'&action=\' + action + \'&mid=\' + mid; jQuery.ajax({ type: "POST", url: "ajax.php", data: string, cache: false, async:false, success: function(result){ jQuery("#overlays_actions").replaceWith(result); } }); jQuery("#load").hide(); return false; }); });' . LB; if ($_CONF['advanced_editor'] == true) { $js_ad = '// Setup editor path for FCKeditor JS Functions geeklogEditorBasePath = "' . $_CONF['site_url'] . '/fckeditor/" ; window.onload = function() { var map_header = new FCKeditor( \'mapheader\' ) ; map_header.Config[\'CustomConfigurationsPath\'] = geeklogEditorBaseUrl + \'/fckeditor/myconfig.js\'; map_header.BasePath = geeklogEditorBasePath; map_header.ToolbarSet = \'editor-toolbar2\'; map_header.Height = 300 ; map_header.ReplaceTextarea() ; var map_footer = new FCKeditor( \'mapfooter\' ) ; map_footer.Config[\'CustomConfigurationsPath\'] = geeklogEditorBaseUrl + \'/fckeditor/myconfig.js\'; map_footer.BasePath = geeklogEditorBasePath; map_footer.ToolbarSet = \'editor-toolbar2\'; map_footer.Height = 300 ; map_footer.ReplaceTextarea() ; };'; $_SCRIPTS->setJavaScript($js_ad, true, true); } $js .= ' jQuery(document).ready( function() { jQuery("#primary_color").simpleColor({ cellWidth: 9, cellHeight: 9, border: \'1px solid #333333\', displayColorCode: true }); jQuery("#stroke_color").simpleColor({ cellWidth: 9, cellHeight: 9, border: \'1px solid #333333\', displayColorCode: true }); jQuery("#load").hide(); }); '; $_SCRIPTS->setJavaScript('<script type="text/javascript" src="' . $_CONF['site_url'] . '/fckeditor/fckeditor.js"></script>', false); $_SCRIPTS->setJavaScript($js, true); $_SCRIPTS->setJavaScriptFile('maps_simplecolor', '/' . $_MAPS_CONF['maps_folder'] . '/js/simple-color.js'); $display = COM_startBlock($LANG_MAPS_1['map_edit'] . ' ' . $map['name']); $template = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates'); $template->set_file(array('map' => 'map_form.thtml')); $template->set_var('site_admin_url', $_CONF['site_admin_url']); $template->set_var('arrow', '<img src="' . $_CONF['site_url'] . '/maps/images/arrow.png" alt=""align="absmiddle"> '); $template->set_var('map_tab', $LANG_MAPS_1['map_tab']); $template->set_var('overlays_tab', $LANG_MAPS_1['overlays_tab']); //informations $template->set_var('informations', $LANG_MAPS_1['informations']); $template->set_var('name_label', $LANG_MAPS_1['name_label']); $template->set_var('name', stripslashes($map['name'])); $template->set_var('address_label', $LANG_MAPS_1['address_label']); $template->set_var('geo', $map['geo']); $template->set_var('description_label', $LANG_MAPS_1['description_label']); $template->set_var('description', stripslashes($map['description'])); $template->set_var('required_field', $LANG_MAPS_1['required_field']); $template->set_var('created_label', $LANG_MAPS_1['map_created']); $template->set_var('modified_label', $LANG_MAPS_1['modified']); $datecreated = COM_getUserDateTimeFormat($map['created']); $datemodified = COM_getUserDateTimeFormat($map['modified']); $template->set_var('created', $datecreated[0]); $template->set_var('modified', $datemodified[0]); //Genaral settings $template->set_var('general_settings', $LANG_MAPS_1['general_settings']); $template->set_var('map_width', $LANG_MAPS_1['map_width']); if ($map['width'] == '') { $map['width'] = $_MAPS_CONF['map_width']; } $template->set_var('width', $map['width']); $template->set_var('map_height', $LANG_MAPS_1['map_height']); if ($map['height'] == '') { $map['height'] = $_MAPS_CONF['map_height']; } $template->set_var('height', $map['height']); $template->set_var('map_zoom', $LANG_MAPS_1['map_zoom']); if ($map['zoom'] == '') { $map['zoom'] = $_MAPS_CONF['map_zoom']; } $template->set_var('zoom', $map['zoom']); $template->set_var('map_type', $LANG_MAPS_1['map_type']); $map_type = $LANG_configselects['maps']["20"]; $options = ''; foreach ($map_type as $i => $value) { $options .= '<option value="' . $value . '"'; if ($value == $map['type']) { $options .= ' selected="selected"'; } $options .= '>' . $i . '</option>' . LB; } $template->set_var('options', $options); $template->set_var('yes', $LANG_MAPS_1['yes']); $template->set_var('no', $LANG_MAPS_1['no']); $template->set_var('active', $LANG_MAPS_1['active']); if ($map['active'] == '') { $map['active'] = $_MAPS_CONF['map_active']; } if ($map['active'] == 1) { $template->set_var('active_yes', ' selected'); $template->set_var('active_no', ''); } else { $template->set_var('active_yes', ''); $template->set_var('active_no', ' selected'); } $template->set_var('hidden', $LANG_MAPS_1['hidden']); if ($map['hidden'] == '') { $map['hidden'] = $_MAPS_CONF['map_hidden']; } if ($map['hidden'] == 1) { $template->set_var('hidden_yes', ' selected'); $template->set_var('hidden_no', ''); } else { $template->set_var('hidden_yes', ''); $template->set_var('hidden_no', ' selected'); } $template->set_var('free_marker', $LANG_MAPS_1['free_marker']); if ($map['free_marker'] == '') { $map['free_marker'] = $_MAPS_CONF['free_markers']; } if ($map['free_marker'] == 1) { $template->set_var('free_marker_yes', ' selected'); $template->set_var('free_marker_no', ''); } else { $template->set_var('free_marker_yes', ''); $template->set_var('free_marker_no', ' selected'); } $template->set_var('paid_marker', $LANG_MAPS_1['paid_marker']); if ($map['paid_marker'] == '') { $map['paid_marker'] = $_MAPS_CONF['paid_markers']; } if ($map['paid_marker'] == 1) { $template->set_var('paid_marker_yes', ' selected'); $template->set_var('paid_marker_no', ''); } else { $template->set_var('paid_marker_yes', ''); $template->set_var('paid_marker_no', ' selected'); } //marker $template->set_var('mk_default', $LANG_MAPS_1['mk_default']); if ($map['mmk_default'] == '1') { $template->set_var('mk_default_yes', 'selected="selected"'); $template->set_var('mk_default_no', ''); } else { $template->set_var('mk_default_yes', ''); $template->set_var('mk_default_no', 'selected="selected"'); } //icon $sql = "SELECT * FROM {$_TABLES['maps_map_icons']} WHERE 1=1"; $result = DB_query($sql, 0); $radio = '<p>' . $LANG_MAPS_1['choose_icon'] . '</p>'; $map['mk_icon'] == 0 ? $checked = ' checked="checked"' : ($checked = ''); $radio .= '<input type="radio" name="mk_icon" value="0"' . $checked . '>' . $LANG_MAPS_1['no_icon'] . ' | '; while ($icon = DB_fetchArray($result, false)) { $map['mk_icon'] == $icon['icon_id'] ? $checked = ' checked="checked"' : ($checked = ''); $radio .= '<input type="radio" name="mk_icon" value="' . $icon['icon_id'] . '"' . $checked . '> <img src="' . $_MAPS_CONF['images_icons_url'] . $icon['icon_image'] . '" alt="' . $icon['icon_image'] . '"> | '; } $radio .= '<hr' . XHTML . '>'; $template->set_var('icon', $radio); $template->set_var('marker_label', $LANG_MAPS_1['marker_label']); $template->set_var('primary_color_label', $LANG_MAPS_1['primary_color_label']); $template->set_var('primary_color', $map['primary_color']); $template->set_var('stroke_color_label', $LANG_MAPS_1['stroke_color_label']); $template->set_var('stroke_color', $map['stroke_color']); $template->set_var('label_label', $LANG_MAPS_1['label']); $template->set_var('label', $map['label']); $template->set_var('label_color_label', $LANG_MAPS_1['label_color']); if ($map['label_color'] == '') { $map['label_color'] = $_MAPS_CONF['label_color']; } if ($map['label_color'] == 1) { $template->set_var('label_color_white', ' selected'); $template->set_var('label_color_black', ''); } else { $template->set_var('label_color_white', ''); $template->set_var('label_color_black', ' selected'); } $template->set_var('black', $LANG_MAPS_1['black']); $template->set_var('white', $LANG_MAPS_1['white']); //header and footer $template->set_var('header_footer', $LANG_MAPS_1['header_footer']); if ($map['header'] == '') { $map['header'] = ' '; } if ($map['footer'] == '') { $map['footer'] = '<p> </p>'; } $template->set_var('map_header_label', $LANG_MAPS_1['map_header_label']); $template->set_var('map_header', $map['header']); $template->set_var('map_footer_label', $LANG_MAPS_1['map_footer_label']); $template->set_var('map_footer', $map['footer']); // Permissions if ($map['perm_owner'] == '') { SEC_setDefaultPermissions($map, $_MAPS_CONF['default_permissions']); } $template->set_var('lang_accessrights', $LANG_ACCESS['accessrights']); $template->set_var('lang_owner', $LANG_ACCESS['owner']); if ($map['owner_id'] == '') { $map['owner_id'] = $_USER['uid']; } $ownername = COM_getDisplayName($map['owner_id']); //Select owner $result = DB_query("SELECT * FROM {$_TABLES['users']}"); $nRows = DB_numRows($result); $owner_select = '<select name="owner_id">'; for ($i = 0; $i < $nRows; $i++) { $row = DB_fetchArray($result); if ($row['uid'] == 1) { continue; } $owner_select .= '<option value="' . $row['uid'] . '"' . ($map['owner_id'] == $row['uid'] ? 'selected="selected"' : '') . '>' . COM_getDisplayName($row['uid']) . ' | ' . $row['uid'] . '</option>'; } $owner_select .= '</select>'; $template->set_var('owner_select', $owner_select); $template->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$map['owner_id']}")); $template->set_var('owner_name', $ownername); $template->set_var('owner', $ownername); $template->set_var('owner_id', $map['owner_id']); if ($map['group_id'] == '') { $map['group_id'] = $_GROUPS['Maps Admin']; } $template->set_var('lang_group', $LANG_ACCESS['group']); $access = 3; $template->set_var('group_dropdown', SEC_getGroupDropdown($map['group_id'], $access)); $template->set_var('permissions_editor', SEC_getPermissionsHTML($map['perm_owner'], $map['perm_group'], $map['perm_members'], $map['perm_anon'])); $template->set_var('lang_permissions', $LANG_ACCESS['permissions']); $template->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']); $template->set_var('permissions_msg', $LANG_ACCESS['permmsg']); $template->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']); //Form validation $template->set_var('save_button', $LANG_MAPS_1['save_button']); $template->set_var('delete_button', $LANG_MAPS_1['delete_button']); $template->set_var('ok_button', $LANG_MAPS_1['ok_button']); if (is_numeric($map['mid'])) { $template->set_var('mid', '<input type="hidden" name="mid" value="' . $map['mid'] . '" />'); } else { $template->set_var('mid', ''); } //overlays if ($map['mid'] != '') { $template->set_var('overlays', MAPS_displayOverlays($map['mid'])); $template->set_var('add_overlay', MAPS_displayOverlaysToAdd($map['mid'])); } else { $template->set_var('overlays', ''); $template->set_var('add_overlay', '<p>' . $LANG_MAPS_1['add_overlay'] . '</p>'); } $display .= $template->parse('output', 'map'); $display .= COM_endBlock(); return $display; }