/**
  * Override's BaseModel method to intercept calls for field 'idno'; uses the specified IDNumbering
  * plugin to generate HTML for idno. If no plugin is specified then the call is passed on to BaseModel::htmlFormElement()
  * Calls for fields other than idno are passed to BaseModel::htmlFormElement()
  */
 public function htmlFormElement($ps_field, $ps_format = null, $pa_options = null)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     foreach (array('name', 'form_name', 'request', 'field_errors', 'display_form_field_tips', 'no_tooltips', 'label', 'readonly') as $vs_key) {
         if (!isset($pa_options[$vs_key])) {
             $pa_options[$vs_key] = null;
         }
     }
     if (!$this->opo_idno_plugin_instance) {
         $this->loadIDNoPlugInInstance($pa_options);
     }
     if ($ps_field == $this->getProperty('ID_NUMBERING_ID_FIELD') && $this->opo_idno_plugin_instance && $pa_options['request']) {
         $vs_idno_fld = $this->getProperty('ID_NUMBERING_ID_FIELD');
         if ($vn_parent_id = $this->get($this->getProperty('HIERARCHY_PARENT_ID_FLD'))) {
             $this->opo_idno_plugin_instance->isChild(true);
         }
         // if it has a parent_id then set the id numbering plugin using "child_only" numbering schemes (if defined)
         if (!$this->getPrimaryKey() && $vn_parent_id && $this->opo_idno_plugin_instance->isChild()) {
             $t_parent = $this->getAppDatamodel()->getInstanceByTableName($this->tableName(), false);
             if ($this->inTransaction()) {
                 $t_parent->setTransaction($this->getTransaction());
             }
             if ($t_parent->load($vn_parent_id)) {
                 $this->set($vs_idno_fld, $x = $this->opo_idno_plugin_instance->makeTemplateFromValue($t_parent->get($vs_idno_fld), 1, true));
                 // chop off last serial element
             }
         }
         $this->opo_idno_plugin_instance->setValue($this->get($ps_field));
         if (method_exists($this, "getTypeCode")) {
             $this->opo_idno_plugin_instance->setType($this->getTypeCode());
         }
         $vs_element = $this->opo_idno_plugin_instance->htmlFormElement($ps_field, $va_errors, array_merge($pa_options, array('error_icon' => caGetThemeGraphicURL($pa_options['request'], 'icons/warning_small.gif'), 'progress_indicator' => caGetThemeGraphicURL($pa_options['request'], 'icons/indicator.gif'), 'show_errors' => $this->getPrimaryKey() ? true : false, 'context_id' => isset($pa_options['context_id']) ? $pa_options['context_id'] : null, 'table' => $this->tableName(), 'row_id' => $this->getPrimaryKey(), 'check_for_dupes' => true, 'search_url' => caSearchUrl($pa_options['request'], $this->tableName(), ''))));
         if (is_null($ps_format)) {
             if (isset($pa_options['field_errors']) && is_array($pa_options['field_errors']) && sizeof($pa_options['field_errors'])) {
                 $ps_format = $this->_CONFIG->get('bundle_element_error_display_format');
                 $va_field_errors = array();
                 foreach ($pa_options['field_errors'] as $o_e) {
                     $va_field_errors[] = $o_e->getErrorDescription();
                 }
                 $vs_errors = join('; ', $va_field_errors);
             } else {
                 $ps_format = $this->_CONFIG->get('bundle_element_display_format');
                 $vs_errors = '';
             }
         }
         if ($ps_format != '') {
             $ps_formatted_element = $ps_format;
             $ps_formatted_element = str_replace("^ELEMENT", $vs_element, $ps_formatted_element);
             $va_attr = $this->getFieldInfo($ps_field);
             foreach (array('DISPLAY_DESCRIPTION', 'DESCRIPTION', 'LABEL', 'DESCRIPTION') as $vs_key) {
                 if (!isset($va_attr[$vs_key])) {
                     $va_attr[$vs_key] = null;
                 }
             }
             // TODO: should be in config file
             $pa_options["display_form_field_tips"] = true;
             if ($pa_options["display_form_field_tips"] || !isset($pa_options["display_form_field_tips"]) && $va_attr["DISPLAY_DESCRIPTION"] || !isset($pa_options["display_form_field_tips"]) && !isset($va_attr["DISPLAY_DESCRIPTION"]) && $vb_fl_display_form_field_tips) {
                 if (preg_match("/\\^DESCRIPTION/", $ps_formatted_element)) {
                     $ps_formatted_element = str_replace("^LABEL", isset($pa_options['label']) ? $pa_options['label'] : $va_attr["LABEL"], $ps_formatted_element);
                     $ps_formatted_element = str_replace("^DESCRIPTION", $va_attr["DESCRIPTION"], $ps_formatted_element);
                 } else {
                     // no explicit placement of description text, so...
                     $vs_field_id = '_' . $this->tableName() . '_' . $this->getPrimaryKey() . '_' . $pa_options["name"] . '_' . $pa_options['form_name'];
                     $ps_formatted_element = str_replace("^LABEL", '<span id="' . $vs_field_id . '">' . (isset($pa_options['label']) ? $pa_options['label'] : $va_attr["LABEL"]) . '</span>', $ps_formatted_element);
                     if (!$pa_options['no_tooltips']) {
                         TooltipManager::add('#' . $vs_field_id, "<h3>" . (isset($pa_options['label']) ? $pa_options['label'] : $va_attr["LABEL"]) . "</h3>" . $va_attr["DESCRIPTION"]);
                     }
                 }
             } else {
                 $ps_formatted_element = str_replace("^LABEL", isset($pa_options['label']) ? $pa_options['label'] : $va_attr["LABEL"], $ps_formatted_element);
                 $ps_formatted_element = str_replace("^DESCRIPTION", "", $ps_formatted_element);
             }
             $ps_formatted_element = str_replace("^ERRORS", $vs_errors, $ps_formatted_element);
             $vs_element = $ps_formatted_element;
         }
         return $vs_element;
     } else {
         return parent::htmlFormElement($ps_field, $ps_format, $pa_options);
     }
 }
예제 #2
0
<!DOCTYPE html>
<html lang="en">
	<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"/>

	<?php 
print MetaTagManager::getHTML();
?>
	<?php 
print AssetLoadManager::getLoadHTML($this->request);
?>
	<link rel="icon" href="<?php 
print caGetThemeGraphicURL($this->request, 'favicon.jpg');
?>
">
	<title><?php 
print $this->request->config->get('html_page_title');
?>
</title>
</head>
<body>
	<div id="headerWrapper">
		<div id="hpLogo">
	<?php 
print caNavLink($this->request, caGetThemeGraphic($this->request, 'MF_logo.jpg', array('width' => '150px', 'height' => '112px')), '', '', '', '');
?>
	
		</div>
		<div class="navbar navbar-inverse">
		  <div class="container">
예제 #3
0
 /**
  * Returns HTML for editable Geocode attribute, suitable for inclusion in a bundleable editing form 
  *
  * @param array $pa_element_info Array of information about the element the bundle is being generate for
  * @param array $pa_options Options are:
  *		width = Width of map + controls in pixels; default is 690
  *		height = Height of map + controls in pixels; default is 300
  *		baseLayer = Tiles to user for base layer. Should be full class name with optional constructor string (Eg. OpenLayers.Layer.Stamen('toner')); default is OpenLayers.Layer.OSM()
  *		pointRadius = Radius, in pixels, of plotted points. Default is 5 pixels
  *		fillColor = Color (in hex format with leading "#") to fill regions and points with
  *		strokeWidth = Width of plotted paths, in pixels. Default is 2
  *		strokeColor = Color of plotted paths, in hex format with leading "#"
  *		fillColorSelected = Color to fill regions with when selected, in hex format with leading "#"
  *		strokeColorSelected = Color of plotted paths when selected, in hex format with leading "#"
  *
  * @return string HTML output
  */
 public function getAttributeBundleHTML($pa_element_info, $pa_options = null)
 {
     AssetLoadManager::register('openlayers');
     $o_config = Configuration::load();
     $va_element_width = caParseFormElementDimension($pa_element_info['settings']['fieldWidth']);
     $vn_element_width = $va_element_width['dimension'];
     $va_element_height = caParseFormElementDimension($pa_element_info['settings']['fieldHeight']);
     $vn_element_height = $va_element_height['dimension'];
     $va_options = caGetOptions($pa_options, array('width' => $vn_element_width, 'height' => $vn_element_height));
     if (($vn_width = $va_options['width']) < 100) {
         $vn_width = 690;
     }
     if (($vn_height = $va_options['height']) < 100) {
         $vn_height = 300;
     }
     if (!($vs_base_layer = $va_options['baseLayer'])) {
         if (!($vs_base_layer = $o_config->get('openlayers_base_layer'))) {
             $vs_base_layer = 'OpenLayers.Layer.OSM()';
         }
     }
     if (($vn_point_radius = $va_options['pointRadius']) < 1) {
         if (!($vn_point_radius = $o_config->get('openlayers_point_radius'))) {
             $vn_point_radius = 5;
         }
     }
     if (($vs_fill_color = $va_options['fillColor']) < 1) {
         if (!($vs_fill_color = $o_config->get('openlayers_fill_color'))) {
             $vs_fill_color = '#ffcc66';
         }
     }
     if (($vn_stroke_width = $va_options['strokeWidth']) < 1) {
         if (!($vn_stroke_width = $o_config->get('openlayers_stroke_width'))) {
             $vn_stroke_width = 2;
         }
     }
     if (($vs_stroke_color = $va_options['strokeColor']) < 1) {
         if (!($vs_stroke_color = $o_config->get('openlayers_stroke_color'))) {
             $vs_stroke_color = '#ff9933';
         }
     }
     if (($vs_fill_color_selected = $va_options['fillColorSelected']) < 1) {
         if (!($vs_fill_color_selected = $o_config->get('openlayers_fill_color_selected'))) {
             $vs_fill_color_selected = '#66ccff';
         }
     }
     if (($vs_stroke_color_selected = $va_options['strokeColorSelected']) < 1) {
         if (!($vs_stroke_color_selected = $o_config->get('openlayers_stroke_color_selected'))) {
             $vs_stroke_color_selected = '#3399ff';
         }
     }
     $po_request = isset($pa_options['request']) ? $pa_options['request'] : null;
     $vs_id = $pa_element_info['element_id'];
     $vs_element = '<div id="{fieldNamePrefix}mapholder_' . $vs_id . '_{n}" class="mapholder" style="width:' . $vn_width . 'spx; height:' . ($vn_height + 40) . 'px; float: left; margin:-18px 0 0 0;">';
     $vs_element .= '<div class="olMapSearchControls" id="{fieldNamePrefix}Controls_{n}">';
     if ($po_request) {
         $vs_element .= '<div class="olMapSearchBox">';
         $vs_element .= '<input type="text" class="olMapSearchText" name="{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}_search"  id="{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}_search" size="30" value="" autocomplete="off" onfocus="this.value = \'\';" onkeypress="return map_geocode_' . $vs_id . '(event);"/>';
         $vs_element .= "<a href='#' onclick='map_geocode_{$vs_id}();'>" . caGetThemeGraphic($po_request, 'buttons/glass.png', array('alt' => _t('Search'), 'class' => 'olMapSearchBoxIcon', 'id' => '{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}_search_button')) . "</a>";
         $vs_element .= '</div>';
     }
     $vs_element .= '<div class="olMapKmlControl" id="{fieldNamePrefix}showKmlControl_{n}">';
     $vs_element .= '<div style="position: absolute; bottom: 0px; left: 0px;"><a href="#" class="button" id="{fieldNamePrefix}showKmlControl_{n}_button">' . _t('Upload KML file') . ' &rsaquo;</a></div>';
     $vs_element .= '</div>';
     $vs_element .= '</div>';
     $vs_element .= '<div class="olMapKMLInput" id="{fieldNamePrefix}KmlControl_{n}">';
     $vs_element .= _t("Select KML or KMZ file") . ': <input type="file" name="{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}"/><a href="#" class="button"  id="{fieldNamePrefix}hideKmlControl_{n}_button">' . _t('Use map') . ' &rsaquo;</a>';
     $vs_element .= '</div>';
     $vs_element .= '<div class="olMap" id="{fieldNamePrefix}map_' . $vs_id . '_{n}" style="width:' . $vn_width . 'px; height:' . $vn_height . 'px;"> </div>';
     $vs_element .= '</div>';
     $vs_element .= "<script type='text/javascript'>\n\t\t\n\tvar map_{$vs_id};\n\tvar points_{$vs_id};\n\tjQuery(document).ready(function() {\n\t\t// Styles\n\t\tvar styles_{$vs_id} = new OpenLayers.StyleMap({\n\t\t\t'default': new OpenLayers.Style({\n\t\t\t\tpointRadius: '{$vn_point_radius}',\n\t\t\t\tfillColor: '{$vs_fill_color}',\n\t\t\t\tstrokeColor: '{$vs_stroke_color}',\n\t\t\t\tstrokeWidth: '{$vn_stroke_width}',\n\t\t\t\tgraphicZIndex: 1\n\t\t\t}),\n\t\t\t'select': new OpenLayers.Style({\n\t\t\t\tfillColor: '{$vs_fill_color_selected}',\n\t\t\t\tstrokeColor: '{$vs_stroke_color_selected}',\n\t\t\t\tgraphicZIndex: 2\n\t\t\t})\n\t\t});\n\n\t\tvar map_{$vs_id}_editing_toolbar;\n\t\t\n\t\tfunction map_serialize_features_{$vs_id}() {\n\t\t\t// get all points\n\t\t\tvar features = [];\n\t\t\tfor(var i=0; i < points_{$vs_id}.features.length; i++) {\n\t\t\t\tvar pl = [];\n\t\t\t\tvar geometry_type = points_{$vs_id}.features[i].geometry.CLASS_NAME;\n\t\t\t\tvar n = points_{$vs_id}.features[i].geometry.getVertices();\n\t\t\t\tfor (var j=0; j<n.length; j++) {\n\t\t\t\t\tvar np = n[j].clone();\n\t\t\t\t\tnp.transform(map_{$vs_id}.getProjectionObject(), new OpenLayers.Projection('EPSG:4326'));\n\t\t\t\t\tpl.push(np.y + ',' + np.x);\n\t\t\t\t}\n\t\t\t\tif ((pl.length > 1) && (geometry_type == 'OpenLayers.Geometry.Polygon')) { pl.push(pl[0]); } // close polygons\n\t\t\t\tfeatures.push(pl.join(';'));\n\t\t\t}\n\t\t\t\n\t\t\tjQuery('#{fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}').val('[' + features.join(':') + ']');\n\t\t}\n\t\t\n\t\t// Set up layer for added points/paths\n\t\tpoints_{$vs_id} = new OpenLayers.Layer.Vector('Points', {\n\t\t\tstyleMap: styles_{$vs_id},\n\t\t\trendererOptions: {zIndexing: true},\n\t\t\teventListeners: {\n\t\t\t\t'featureadded': map_serialize_features_{$vs_id}\n\t\t\t}\n\t\t});\n\t\t\n\t\tmap_{$vs_id}_editing_toolbar = new OpenLayers.Control.EditingToolbar(points_{$vs_id});\n\t\t\n\t\t// Set up map\n\t\tmap_{$vs_id} = new OpenLayers.Map({\n\t\t\tdiv: '{fieldNamePrefix}map_{$vs_id}_{n}',\n\t\t\tlayers: [new {$vs_base_layer}],\n\t\t\tcontrols: [\n\t\t\t\tnew OpenLayers.Control.Navigation({\n\t\t\t\t\tdragPanOptions: {\n\t\t\t\t\t\tenableKinetic: true\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tnew OpenLayers.Control.Zoom()\n\t\t\t],\n\t\t\tcenter: [0,0],\n\t\t\tzoom: 1\n\t\t});\n\t\t\n\t\tvar map_{$vs_id}_drag_ctrl = new OpenLayers.Control.DragFeature(points_{$vs_id}, {\n\t\t\tonComplete: function(f) { map_serialize_features_{$vs_id}(f); }\n\t\t});\n\t\tmap_{$vs_id}.addControl(map_{$vs_id}_drag_ctrl);\n\t\tmap_{$vs_id}_drag_ctrl.activate();\n\t\t\n\t\t// add delete control\n\t\tvar map_{$vs_id}_delete_button = new OpenLayers.Control.Button ({displayClass: 'olControlDelete', trigger: function() { \n\t\t\tif (points_{$vs_id}.selectedFeatures) { \n\t\t\t\tpoints_{$vs_id}.removeFeatures(points_{$vs_id}.selectedFeatures);\n\t\t\t\tmap_serialize_features_{$vs_id}();\n\t\t\t}\n\t\t}, title: '" . _t('Remove') . "'});\n\t\tvar map_{$vs_id}_delete_panel = new OpenLayers.Control.Panel({type: OpenLayers.Control.TYPE_BUTTON, displayClass: 'olControlDeletePanel'});\n\t\tmap_{$vs_id}_delete_panel.addControls([map_{$vs_id}_delete_button]);\n\t\tmap_{$vs_id}.addControl(map_{$vs_id}_delete_panel);\n\t\tmap_{$vs_id}_delete_button.activate();\n\t\t\n\t\t// Grab current map coordinates from input\n\t\tvar map_{$ps_id}_loc_str = '{" . $pa_element_info['element_id'] . "}';\n\t\tvar map_{$ps_id}_loc_features = map_{$ps_id}_loc_str.match(/\\[([\\d\\,\\-\\.\\:\\;]+)\\]/)\n\t\tif (map_{$ps_id}_loc_features && (map_{$ps_id}_loc_features.length > 1)) {\n\t\t\tmap_{$ps_id}_loc_features = map_{$ps_id}_loc_features[1].split(/:/);\n\t\t} else {\n\t\t\tmap_{$ps_id}_loc_features = [];\n\t\t}\n\t\tvar features_{$vs_id} = [];\n\t\t\n\t\tvar i, j, c=0;\n\t\tfor(i=0; i < map_{$ps_id}_loc_features.length; i++) {\n\t\t\tvar ptlist = map_{$ps_id}_loc_features[i].split(/;/);\n\t\t\t\n\t\t\tif (ptlist.length > 1) {\n\t\t\t\t// path\n\t\t\t\tvar ptolist = [];\n\t\t\t\tfor(j=0; j < ptlist.length; j++) {\n\t\t\t\t\tvar pt = ptlist[j].split(/,/);\n\t\t\t\t\tptolist.push(new OpenLayers.Geometry.Point(pt[1], pt[0]));\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\tfeatures_{$vs_id}.push(new OpenLayers.Feature.Vector(\n\t\t\t\t\tnew OpenLayers.Geometry.LineString(ptolist).transform(new OpenLayers.Projection('EPSG:4326'),map_{$vs_id}.getProjectionObject()), {}\n\t\t\t\t));\n\t\t\t} else {\n\t\t\t\t// point\n\t\t\t\tvar pt = ptlist[0].split(/,/);\n\t\t\t\tfeatures_{$vs_id}.push(new OpenLayers.Feature.Vector(\n\t\t\t\t\tnew OpenLayers.Geometry.Point(pt[1], pt[0]).transform(new OpenLayers.Projection('EPSG:4326'),map_{$vs_id}.getProjectionObject()), {}\n\t\t\t\t));\n\t\t\t}\n\t\t\tc++;\n\t\t}\n\t\n\t\tpoints_{$vs_id}.addFeatures(features_{$vs_id});\n\t\t\n\t\tvar map_{$vs_id}_highlight_ctrl = new OpenLayers.Control.SelectFeature(points_{$vs_id}, {\n\t\t\thover: false,\n\t\t\trenderIntent: 'temporary',\n\t\t\tmultiple: true, clickout: true, toggle: true, box: true,\n\t\t\teventListeners: {}\n\t\t});\n\t\tmap_{$vs_id}.addControl(map_{$vs_id}_highlight_ctrl);\n\t\tmap_{$vs_id}_highlight_ctrl.activate();\n\t\t\n\t\tmap_{$vs_id}.addControl(map_{$vs_id}_editing_toolbar);\n\t\tmap_{$vs_id}_editing_toolbar.activate();\n \n\t\tmap_{$vs_id}.addLayer(points_{$vs_id});\n\t\t\n\t\tif (c > 0) {\n\t\t\tmap_{$vs_id}.zoomToExtent(points_{$vs_id}.getDataExtent());\n\t\t\tif (map_{$vs_id}.zoom > 14) { map_{$vs_id}.zoomTo(14); }\n\t\t}\n\t\t\n\t\tjQuery('#{fieldNamePrefix}showKmlControl_{n}_button').click(function(event) {\n\t\t\tevent.preventDefault();\n\t\t\tjQuery('#{fieldNamePrefix}Controls_{n}').hide(200, function() {\n\t\t\t\tjQuery('#{fieldNamePrefix}KmlControl_{n}').slideDown(200);\n\t\t\t});\n\t\t});\n\t\t\n\t\tjQuery('#{fieldNamePrefix}hideKmlControl_{n}_button').click(function(event) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tjQuery(this).parent().hide(200, function() {\n\t\t\t\t\tjQuery('#{fieldNamePrefix}Controls_{n}').slideDown(200);\n\t\t\t\t});\n\t\t\t});\n\t});\n\t\tfunction map_geocode_{$vs_id}(e) {\n\t\t\tif (e && ((e.keyCode || e.which || e.charCode || 0) !== 13)) { return true; }\n\t\t\tvar t = jQuery('#{fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}_search').val();\n\t\t\tjQuery('#{fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}_search_button').attr('src', '" . caGetThemeGraphicURL($po_request, '/icons/indicator.gif') . "');\n\t\t\tvar geocoder = new google.maps.Geocoder();\n\t\t\tgeocoder.geocode( { 'address': t}, function(results, status) {\n\t\t\t\tjQuery('#{fieldNamePrefix}" . $pa_element_info['element_id'] . "_{n}_search_button').attr('src', '" . caGetThemeGraphicURL($po_request, '/buttons/glass.png') . "');\n\t\t\t\tif (status == google.maps.GeocoderStatus.OK) {\n\t\t\t\t\tvar loc = results[0]['geometry']['location'];\n\t\t\t\t\tvar pt = new OpenLayers.LonLat(loc.lng(), loc.lat()).transform(new OpenLayers.Projection('EPSG:4326'),map_{$vs_id}.getProjectionObject());\n\t\t\t\t\tmap_{$vs_id}.panTo(pt);\n\t\t\t\t\tmap_{$vs_id}.zoomTo((results[0]['geometry']['location_type'] == 'APPROXIMATE') ? 10 : 14);\n\t\t\t\t\tpoints_{$vs_id}.addFeatures([new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(loc.lng(), loc.lat()).transform(new OpenLayers.Projection('EPSG:4326'),map_{$vs_id}.getProjectionObject()))]);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn false;\n\t\t}\n\t</script>";
     $vs_element .= '<input class="coordinates mapCoordinateDisplay" type="hidden" name="{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}" id="{fieldNamePrefix}' . $pa_element_info['element_id'] . '_{n}"/>';
     return $vs_element;
 }