--- gmap_plugin_style_gmap.inc.COPY 2011-08-11 20:42:38.000000000 +0000 +++ gmap_plugin_style_gmap.inc 2011-08-11 22:19:08.000000000 +0000 @@ -33,12 +33,12 @@ $options['lonfield'] = array('default' => ''); $options['markerfield'] = array('default' => ''); - $options['center_on_nodearg'] = array('default' => 0); - $options['center_on_nodearg_arg'] = array('default' => ''); + $options['center_on_arg'] = array('default' => 0); + $options['center_on_arg_arg'] = array('default' => ''); - $options['highlight_nodearg'] = array('default' => 0); - $options['highlight_nodearg_arg'] = array('default' => ''); - $options['highlight_nodearg_color'] = array('default' => '#FF0000'); + $options['highlight_arg'] = array('default' => 0); + $options['highlight_arg_arg'] = array('default' => ''); + $options['highlight_arg_color'] = array('default' => '#FF0000'); $options['tooltipenabled'] = array('default' => 0); $options['tooltipfield'] = array('default' => ''); @@ -128,15 +128,16 @@ $offsets = array(); $center_lat = null; $center_lon = null; - $center_nid = null; - $highlight_nid = null; + $center_id = null; + $highlight_id = null; - // We search nid argument used to center map - if ($this->options['center_on_nodearg'] && $nodehandler = $this->view->display_handler->get_handler('argument', $this->options['center_on_nodearg_arg'])) { - $center_nid = $nodehandler->get_value(); + // We search nid/uid argument used to center map + $idname = $this->options['center_on_arg_arg']; + if ($this->options['center_on_arg'] && $nodehandler = $this->view->display_handler->get_handler('argument', $idname)) { + $center_id = $nodehandler->get_value(); } - if ($this->options['highlight_nodearg'] && $nodehandler = $this->view->display_handler->get_handler('argument', $this->options['highlight_nodearg_arg'])) { - $highlight_nid = $nodehandler->get_value(); + if ($this->options['highlight_arg'] && $nodehandler = $this->view->display_handler->get_handler('argument', $this->options['highlight_arg_arg'])) { + $highlight_id = $nodehandler->get_value(); } foreach ($records as $row_index => $row) { @@ -146,12 +147,12 @@ // $row->nid is present in node views, views without node as the base table must include the nid field, // which will be in $row->node_nid if present. - // If nid for a row is required use $row_nid. - $row_nid = isset($row->nid) ? $row->nid : (isset($row->node_nid) ? $row->node_nid : NULL); + // If nid/uid for a row is required use $row_id. + $row_id = isset($row->{$idname}) ? $row->{$idname} : (isset($row->node_nid) ? $row->node_nid : NULL); // If this row will be used as center map then we keep its lon/lat // If there are multiple points on a single node take the first match - if (!empty($center_nid) && !empty($row_nid) && $center_nid == $row_nid && ($center_lon === NULL || $center_lat === NULL)) { + if (!empty($center_id) && !empty($row_id) && $center_id == $row_id && ($center_lon === NULL || $center_lat === NULL)) { $center_lon = $lon; $center_lat = $lat; } @@ -197,8 +198,8 @@ 'text' => $this->row_plugin->render($row), 'opts' => array( 'title' => $tooltip, - 'highlight' => (!empty($highlight_nid) && !empty($row_nid) && $highlight_nid == $row_nid) ? 1 : 0, - 'highlightcolor' => $this->options['highlight_nodearg_color'], + 'highlight' => (!empty($highlight_id) && !empty($row_id) && $highlight_id == $row_id) ? 1 : 0, + 'highlightcolor' => $this->options['highlight_arg_color'], ), ); @@ -312,44 +313,44 @@ '#default_value' => $this->options['markertype'], ); - $form['center_on_nodearg'] = array( + $form['center_on_arg'] = array( '#type' => 'checkbox', - '#title' => t('Center on node argument'), - '#default_value' => $this->options['center_on_nodearg'], - '#description' => ($this->view->base_table == 'node') ? t('Note: The view must contain an argument whose value is a node ID.') : t('Note: The view must contain an argument whose value is a node ID.') . '
' . t("The view must contain 'Node: nid' as one of its fields because the view type is not 'Node'."), + '#title' => t('Center on node/user argument'), + '#default_value' => $this->options['center_on_arg'], + '#description' => t('Note: The view must contain an argument whose value is the id of a node or user.'), ); - $form['center_on_nodearg_arg'] = array( + $form['center_on_arg_arg'] = array( '#title' => t('Argument'), - '#description' => empty($argument_options) ? t("The value of the selected argument must be a number that matches a node ID. Use the 'Global: Null' argument if you don't want to also restrict results to that node ID. You must have added arguments to the view to use this option.") : t("The selected argument must be a number that matches a node ID. Use the 'Global: Null' argument if you don't want to also restrict results to that node ID."), + '#description' => empty($argument_options) ? t("The value of the selected argument must be a number that matches a node id or user id. Use the 'Global: Null' argument if you don't want to also restrict results to that id. You must have added arguments to the view to use this option.") : t("The selected argument must be a number that matches a node id or user id. Use the 'Global: Null' argument if you don't want to also restrict results to that id."), '#type' => 'select', '#options' => $argument_options, - '#default_value' => $this->options['center_on_nodearg_arg'], + '#default_value' => $this->options['center_on_arg_arg'], '#process' => array('views_process_dependency'), '#dependency' => array('edit-style-options-center-on-nodearg' => array(TRUE)), ); - $form['highlight_nodearg'] = array( + $form['highlight_arg'] = array( '#type' => 'checkbox', - '#title' => t('Highlight marker for node argument'), - '#default_value' => $this->options['highlight_nodearg'], - '#description' => ($this->view->base_table == 'node') ? t('Note: The view must contain an argument whose value is a node ID.') : t('Note: The view must contain an argument whose value is a node ID.') . '
' . t("The view must contain 'Node: nid' as one of its fields because the view type is not 'Node'."), + '#title' => t('Highlight marker for node/user argument'), + '#default_value' => $this->options['highlight_arg'], + '#description' => t('Note: The view must contain an argument whose value is a node id or user id.'), ); - $form['highlight_nodearg_arg'] = array( + $form['highlight_arg_arg'] = array( '#title' => t('Argument'), - '#description' => empty($argument_options) ? t("The value of the selected argument must be a number that matches a node ID. Use the 'Global: Null' argument if you don't want to also restrict results to that node ID. You must have added arguments to the view to use this option.") : t("The value of the selected argument must be a number that matches a node ID. Use the 'Global: Null' argument if you don't want to also restrict results to that node ID."), + '#description' => empty($argument_options) ? t("The value of the selected argument must be a number that matches a node id or user id. Use the 'Global: Null' argument if you don't want to also restrict results to that id. You must have added arguments to the view to use this option.") : t("The value of the selected argument must be a number that matches a node id or user id. Use the 'Global: Null' argument if you don't want to also restrict results to that id."), '#type' => 'select', '#options' => $argument_options, - '#default_value' => $this->options['highlight_nodearg_arg'], + '#default_value' => $this->options['highlight_arg_arg'], '#process' => array('views_process_dependency'), '#dependency' => array('edit-style-options-highlight-nodearg' => array(TRUE)), ); - $form['highlight_nodearg_color'] = array( + $form['highlight_arg_color'] = array( '#title' => t('Highlight color'), '#description' => t("A 6 digit hex color value to use for the highlight. Include preceding hash. Example #FF0000"), '#type' => 'textfield', '#size' => 7, '#maxlength' => 7, - '#default_value' => $this->options['highlight_nodearg_color'], + '#default_value' => $this->options['highlight_arg_color'], '#process' => array('views_process_dependency'), '#dependency' => array('edit-style-options-highlight-nodearg' => array(TRUE)), ); @@ -375,8 +376,8 @@ */ function options_validate(&$form, &$form_state) { // Check if highlight color is a valid hex color - if (!preg_match('/^#[a-f0-9]{6}$/i', $form_state['values']['style_options']['highlight_nodearg_color'])) { - form_error($form['highlight_nodearg_color'], t('Highlight colour must be a valid hex code in the form #FF0000.')); + if (!preg_match('/^#[a-f0-9]{6}$/i', $form_state['values']['style_options']['highlight_arg_color'])) { + form_error($form['highlight_arg_color'], t('Highlight colour must be a valid hex code in the form #FF0000.')); } } }