Index: modules/openlayers_ui/includes/openlayers_ui.styles.inc IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP <+> array(\n 'default' => '',\n 'desc' => t('The URL of an icon for points in a layer. The following options are available:\n '),\n ),\n 'pointRadius' => array(\n 'default' => 6,\n 'desc' => t('The radius of a vector point or the size of\n an icon. Note that, when using icons, this value should be half the\n width of the icon image.'),\n 'type' => 'integer',\n ),\n 'fillColor' => array(\n 'default' => '#EE9900',\n 'desc' => t('This is the color used for\n filling in Polygons. It is also used in the center of marks for\n points: the interior color of circles or other shapes. It is\n not used if an externalGraphic is applied to a point. This should be\n a hexadecimal value like #FFFFFF.'),\n ),\n 'strokeColor' => array(\n 'default' => '#EE9900',\n 'desc' => t('This is color of the line on features. On\n polygons and point marks, it is used as an outline to the feature.\n On lines, this is the representation of the feature. This should be\n a hexadecimal value like #FFFFFF.'),\n ),\n 'strokeWidth' => array(\n 'default' => 1,\n 'desc' => t('This is width of the line on features. On\n polygons and point marks, it is used as an outline to\n the feature. On lines, this is the representation of the\n feature. This is a value in pixels.'),\n 'type' => 'integer',\n ),\n 'fillOpacity' => array(\n 'default' => 1,\n 'desc' => t('This is the opacity used for filling in Polygons.\n It is also used in the center of marks for points: the interior\n color of circles or other shapes. It is not used if an\n externalGraphic is applied to a point. This should be a value\n between 0 and 1.'),\n 'type' => 'float',\n ),\n 'strokeOpacity' => array(\n 'default' => 1,\n 'desc' => t('This is opacity of the line on features.\n On polygons and point marks, it is used as an outline to the\n feature. On lines, this is the representation of the feature.\n This should be a value between 0 and 1.'),\n 'type' => 'float',\n ),\n 'strokeLinecap' => array(\n 'default' => 'round',\n 'desc' => t('Options are butt, round, square. This property\n is similar to the SVG stroke-linecap property. It determines\n what the end of lines should look like. See the SVG link for\n image examples.'),\n 'options' => array(\n 'butt' => t('Butt'),\n 'round' => t('Round'),\n 'square' => t('Square'),\n ),\n ),\n 'strokeDashstyle' => array(\n 'default' => 'solid',\n 'desc' => t('Options are dot, dash, dashdot, longdash, longdashdot, solid.'),\n 'options' => array(\n 'dot' => t('Dot'),\n 'dash' => t('Dash'),\n 'dashdot' => t('Dash-dot'),\n 'longdash' => t('Long-dash'),\n 'longdashdot' => t('Long-dash-dot'),\n 'solid' => t('Solid'),\n ),\n ),\n 'cursor' => array(\n 'default' => '',\n 'desc' => t('Cursor used when mouse is over the feature. Default\n is an empty string, which inherits from parent elements. See\n CSS cursor styles.', array(\n '!url' => 'http://www.w3schools.com/css/pr_class_cursor.asp',\n )),\n ),\n 'graphicWidth' => array(\n 'default' => '',\n 'desc' => t('This properties define the width of an externalGraphic.\n This is an alternative to the pointRadius symbolizer property\n to be used when your graphic has different sizes in the X and\n Y direction. This should be in pixels.'),\n 'type' => 'integer',\n ),\n 'graphicHeight' => array(\n 'default' => '',\n 'desc' => t('This properties define the height of an externalGraphic.\n This is an alternative to the pointRadius symbolizer property\n to be used when your graphic has different sizes in the X and\n Y direction. This should be in pixels.'),\n 'type' => 'integer',\n ),\n 'graphicOpacity' => array(\n 'default' => '1',\n 'desc' => t('Opacity of an external graphic. This should be a\n value between 0 and 1. Grahics that are already semitransparent,\n like alpha PNGs, should have this set to 1, or rendering problems in\n Internet Explorer will ensue.'),\n 'type' => 'float',\n ),\n 'graphicXOffset' => array(\n 'default' => '',\n 'desc' => t('Where the X value of the \"center\" of an\n externalGraphic should be. This should be in pixels.'),\n 'type' => 'integer',\n ),\n 'graphicYOffset' => array(\n 'default' => '',\n 'desc' => t('Where the Y value of the \"center\" of an\n externalGraphic should be. This should be in pixels.'),\n 'type' => 'integer',\n ),\n 'graphicName' => array(\n 'default' => '',\n 'desc' => t('Name of a type of symbol to be used\n for a point mark.'),\n ),\n 'rotation' => array(\n 'default' => '',\n 'desc' => t('The rotation angle in degrees clockwise for\n a point symbolizer.'),\n ),\n 'display' => array(\n 'default' => '',\n 'desc' => t('Can be set to \"none\" to hide features\n from rendering.'),\n 'options' => array(\n '' => t('On'),\n 'none' => t('None (off)'),\n ),\n ),\n 'label' => array(\n 'default' => '',\n 'desc' => t('A label to show for features. '\n . 'Tipically used with ${attribute} syntax.')\n ),\n 'labelAlign' => array(\n 'default' => 'cm',\n 'desc' => t('Label alignment.'),\n 'options' => array(\n 'cm' => t('Center, middle'),\n 'ct' => t('Center, top'),\n 'cb' => t('Center, bottom'),\n 'lm' => t('Left, middle'),\n 'lt' => t('Left, top'),\n 'lb' => t('Left, bottom'),\n 'rm' => t('Right, middle'),\n 'rt' => t('Right, top'),\n 'rb' => t('Right, bottom'),\n ),\n ),\n 'labelXOffset' => array(\n 'default' => '',\n 'desc' => t('Label X offset. Positive numbers move label right.'),\n ),\n 'labelYOffset' => array(\n 'default' => '',\n 'desc' => t('Label Y offset. Positive numbers move label up.'),\n ),\n 'fontColor' => array(\n 'default' => '',\n 'desc' => t('Label font color.'),\n ),\n 'fontSize' => array(\n 'default' => '',\n 'desc' => t('Label font size.'),\n ),\n 'fontFamily' => array(\n 'default' => '',\n 'desc' => t('Label font family.'),\n ),\n 'fontWeight' => array(\n 'default' => '',\n 'desc' => t('Label font weight.'),\n ),\n );\n\n // Pass style data along\n $form['style_data'] = array(\n '#type' => 'value',\n '#value' => $properties,\n );\n\n // Style object basics\n $form['info'] = array(\n '#type' => 'fieldset',\n '#tree' => FALSE,\n '#title' => t('Style Basics'),\n '#description' => t('The basic settings for the style.'),\n );\n\n // Provide a preview of the style\n $preview_style = (isset($form_state['values']) && $form_state['values']['preview_style']) ?\n $form_state['values']['preview_style'] : $style;\n if ($preview_style) {\n $form['info']['preview_style_container'] = array(\n '#type' => 'item',\n '#title' => t('Preview'),\n '#markup' => openlayers_ui_style_preview($preview_style, TRUE),\n '#description' => t('If you are using attribute replacement, the style may not show properly. The crosshairs point out where the feature is centered.'),\n );\n }\n\n $form['info']['name'] = array(\n '#title' => t('Style Machine Name'),\n '#type' => 'textfield',\n '#required' => TRUE,\n '#default_value' => !empty($style->name) ? $style->name : '',\n '#description' => t('This is the unique name of the style. It must contain only alphanumeric characters and underscores.'),\n );\n $form['info']['title'] = array(\n '#title' => t('Style Title'),\n '#type' => 'textfield',\n '#required' => TRUE,\n '#default_value' => !empty($style->title) ? $style->title : '',\n '#description' => t('The title of your style, which will appear in the administration interface.'),\n );\n $form['info']['description'] = array(\n '#title' => t(' Style Description'),\n '#type' => 'textfield',\n '#default_value' => !empty($style->description) ? $style->description : '',\n '#description' => t('The description of your style, which will appear in the administration interface.'),\n );\n\n // OpenLayers style properties\n $form['data'] = array(\n '#type' => 'fieldset',\n '#tree' => TRUE,\n '#title' => t('Style Properties'),\n '#description' => t('The specific properties for the style.'),\n );\n\n foreach ($properties as $key => $prop) {\n $form['data'][$key] = array(\n '#type' => !isset($prop['options']) ? 'textfield' : 'select',\n '#title' => check_plain($key),\n '#description' => filter_xss($prop['desc']),\n '#default_value' => isset($style->data[$key]) ?\n $style->data[$key] : $prop['default'],\n );\n\n // Add options if needed\n if (isset($prop['options']) && is_array($prop['options'])) {\n $form['data'][$key]['#options'] = $prop['options'];\n }\n }\n\n $form['submit'] = array(\n '#type' => 'submit',\n '#value' => t('Save'),\n );\n $form['preview'] = array(\n '#type' => 'submit',\n '#value' => t('Preview'),\n );\n return $form;\n}\n\n/**\n * Submit handler for layers.\n */\nfunction openlayers_ui_styles_form_submit(&$form, &$form_state) {\n $style_data = $form_state['values']['style_data'];\n\n // Cast and unset values so JS can handle them better,\n // Unless values are in the form ${attribute}\n foreach ($form_state['values']['data'] as $key => $value) {\n if ($form_state['values']['data'][$key] === '') {\n unset($form_state['values']['data'][$key]);\n }\n elseif (isset($style_data[$key]['type']) &&\n strpos($form_state['values']['data'][$key], '${') !== 0) {\n if ($style_data[$key]['type'] == 'integer') {\n $form_state['values']['data'][$key] =\n (int) $form_state['values']['data'][$key];\n }\n elseif ($style_data[$key]['type'] == 'float') {\n $form_state['values']['data'][$key] =\n (float) $form_state['values']['data'][$key];\n }\n }\n }\n\n // Create style object\n $style = new stdClass();\n $style->name = $form_state['values']['name'];\n $style->title = $form_state['values']['title'];\n $style->description = $form_state['values']['description'];\n $style->data = $form_state['values']['data'];\n\n // On preview, process, but don't save, rebuild.\n if ($form_state['clicked_button']['#id'] == 'edit-preview') {\n $form_state['values']['preview_style'] = $style;\n $form_state['rebuild'] = TRUE;\n return;\n }\n\n // Save\n $success = openlayers_style_save($style);\n\n // Redirect to edit page\n if ($success) {\n drupal_set_message(t('Style saved.'));\n $form_state['redirect'] = 'admin/structure/openlayers/styles/' . $style->name . '/edit';\n }\n else {\n form_set_error('openlayers', t('Error trying to save style.'));\n }\n}\n =================================================================== --- modules/openlayers_ui/includes/openlayers_ui.styles.inc (revision 48a7393e965d984859ea3e77d18c7c62ca2648ed) +++ modules/openlayers_ui/includes/openlayers_ui.styles.inc (revision ) @@ -287,7 +287,20 @@ } /** - * Submit handler for layers. + * Validation handler for styles. + */ +function openlayers_ui_styles_form_validate($form, &$form_state) { + if ($form_state['values']['fillOpacity'] < 0 || $form_state['values']['fillOpacity'] > 1) { + form_set_error('fillOpacity', t('The fillOpacity property must be between 0 and 1.')); + } + if ($form_state['values']['graphicOpacity'] < 0 || $form_state['values']['graphicOpacity'] > 1) { + form_set_error('graphicOpacity', t('The fillOpacity property must be between 0 and 1.')); + } +} + + +/** + * Submit handler for styles. */ function openlayers_ui_styles_form_submit(&$form, &$form_state) { $style_data = $form_state['values']['style_data'];