Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
google_map_edit_fns.inc
1 <?php
18 require_once SQ_PACKAGES_PATH.'/cms/page_templates/page_asset_listing/page_asset_listing_edit_fns.inc';
19 
32 {
33 
34 
39  function __construct()
40  {
41  parent::__construct();
42  $this->static_screens['details']['force_unlock'] = FALSE;
43  }//end constructor
44 
45 
53  function paintDataMapping(&$asset, &$o, $prefix)
54  {
55  $write_access = $asset->writeAccess('attributes');
56  $var_list = $asset->attr('dynamic_vars');
57 
58  $o->openSection('Data Mappings');
59  $o->openRaw();
60  $map = $asset->getAttribute('parameter_map');
61 
62  $parameter_names = $map->getParameters();
63 
64  foreach ($var_list as $var_name => $default) {
65  $map->setParameter($var_name, 'Variable: '.$var_name);
66  }
67 
68  $map->paint($prefix.'_parameter_map', !$write_access);
69  $o->closeRaw();
70 
71  $o->sectionNote(translate('trim_ds_search_default_options_note'));
72 
73  return $write_access;
74 
75  }//end paintDataMapping()
76 
77 
85  function processDataMapping(&$asset, &$o, $prefix)
86  {
87  $write_access = $asset->writeAccess('attributes');
88  if (!$write_access) return FALSE;
89  $var_name_pattern = '/^[a-zA-Z_\-0-9\.]+$/';
90  $var_list = ($asset->attr('dynamic_vars'));
91 
92  $map = $asset->getAttribute('parameter_map');
93 
94  $map->process($prefix.'_parameter_map');
95 
96  $asset->setAttrValue('parameter_map', unserialize($map->value));
97 
98  return $write_access;
99 
100  }//end processDataMapping()
101 
102 
113  function redirectToBodycopy(&$asset, &$o, $prefix)
114  {
115  // get the bodycopy attached to us
116  $bodycopy_link = $GLOBALS['SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2, 'bodycopy', TRUE, 'major', 'page_contents', '1', '1');
117  $bodycopy = NULL;
118  if (!empty($bodycopy_link)) {
119  $bodycopy = $GLOBALS['SQ_SYSTEM']->am->getAsset($bodycopy_link[0]['minorid'], 'bodycopy');
120  }
121  if (is_null($bodycopy)) {
122  trigger_localised_error('CORE0016', E_USER_ERROR, $asset->name);
123  return FALSE;
124  }
125 
126  // redirect to the bodycopy's edit contents screen
127  $o->setRedirect($bodycopy->getBackendHref('contents'));
128 
129  // fudge the navigation history a little so when they click on the link to ger back to the
130  // page it doesnt take them to the edit contents screen and then redirect them again
131  $_SESSION['sq_nav_history'][(count($_SESSION['sq_nav_history']) - 1)]['screen'] = 'details';
132 
133  return FALSE;
134 
135  }//end redirectToBodycopy()
136 
137 
144  function paintDefaultIconSize(&$asset, &$o, $prefix)
145  {
146  $wa = $asset->writeAccess('attributes');
147 
148  $default_icon_size = $asset->attr('default_icon_size');
149  $default_width = $asset->attr('default_icon_width');
150  $default_height = $asset->attr('default_icon_height');
151 
152  $o->openField('Default Icon Size');
153  if ($wa) {
154  check_box($prefix.'_use_default', '1', $default_icon_size, '
155  if (this.checked==1) {
156  document.getElementById("'.$prefix.'_default_icon_width").disabled=true;
157  document.getElementById("'.$prefix.'_default_icon_height").disabled=true;
158  } else {
159  document.getElementById("'.$prefix.'_default_icon_width").disabled=false;
160  document.getElementById("'.$prefix.'_default_icon_height").disabled=false;
161  }//end else
162  ');
163  echo ' Use Default Size<br /><br />';
164  $extra = $default_icon_size ? 'disabled=true' : '';
165  text_box($prefix.'_default_icon_width', $default_width, 5, '', FALSE, $extra);echo ' px';
166  $o->note('Icon Width');
167  text_box($prefix.'_default_icon_height', $default_height, 5, '', FALSE, $extra);echo ' px';
168  $o->note('Icon Height');
169  } else {
170  echo $default_width.' px';
171  $o->note('Icon Width');
172  echo $default_height.' px';
173  $o->note('Icon Height');
174  }//end else
175 
176  $o->closeField();
177 
178  return $wa;
179 
180  }//end paintDefaultIconSize()
181 
182 
189  function processDefaultIconSize(&$asset, &$o, $prefix)
190  {
191  $wa = $asset->writeAccess('attributes');
192  $default_width = $asset->attr('default_icon_width');
193  $default_height = $asset->attr('default_icon_height');
194  $default_size = $asset->attr('default_icon_size');
195 
196  $attr_change = FALSE;
197  $new_default_size = isset($_POST[$prefix.'_use_default']) ? $_POST[$prefix.'_use_default'] : FALSE;
198  if (!is_null($new_default_size) && $new_default_size != $default_size) {
199  $attr_change = TRUE;
200  $asset->setAttrValue('default_icon_size', $new_default_size);
201  }
202 
203  if ($new_default_size != 1) {
204  $new_width = isset($_POST[$prefix.'_default_icon_width']) ? $_POST[$prefix.'_default_icon_width'] : '';
205  $new_height = isset($_POST[$prefix.'_default_icon_height']) ? $_POST[$prefix.'_default_icon_height'] : '';
206  if (!empty($new_width) && $new_width != $default_width) {
207  $asset->setAttrValue('default_icon_width', $new_width);
208  $attr_change = TRUE;
209  }//end if
210  if (!empty($new_height) && $new_height != $default_height) {
211  $asset->setAttrValue('default_icon_height', $new_height);
212  $attr_change = TRUE;
213  }//end if
214  }//end if
215 
216  if ($attr_change) $asset->saveAttributes();
217 
218  return FALSE;
219 
220  }//end processDefaultIconSize()
221 
222 
229  function paintDefaultLatLng(&$asset, &$o, $prefix)
230  {
231  $wa = $asset->writeAccess('attributes');
232 
233  $api_key = $asset->attr('api_key');
234  $default_latitude = $asset->attr('default_latitude');
235  $default_longitude = $asset->attr('default_longitude');
236  $default_zoom_level = $asset->attr('default_zoom_level');
237 
238  $o->openField('Default Map Center');
239  if ($wa) {
240  text_box($prefix.'_default_latitude', $default_latitude, 20, '', FALSE, 'onFocus="this.style.color = \'black\';"');
241  if (!empty($api_key)) {?>
242  &nbsp;
243  <a href="javascript:switch_display();" style="text-decoration:none;border:none;">
244  <img src="<?php echo sq_web_path('data').'/asset_types/google_map/images/globe.png'?>" border="0" title="Pick From Map" style="position:relative;top:5px;" />
245  </a>
246  <?php }
247  $o->note('The default Latitude of the map');
248  text_box($prefix.'_default_longitude', $default_longitude, 20, '', FALSE, 'onFocus="this.style.color = \'black\';"');
249  if (!empty($api_key)) {?>
250  &nbsp;
251  <a href="javascript:switch_display();">
252  <img src="<?php echo sq_web_path('data').'/asset_types/google_map/images/globe.png'?>" border="0" title="Pick From Map" style="position:relative;top:5px;" />
253  </a>
254  <?php }
255  $o->note('The default Longitude of the map');
256  text_box($prefix.'_default_zoom_level', $default_zoom_level, 20, '', FALSE, 'onFocus="this.style.color = \'black\';"');
257  if (!empty($api_key)) {?>
258  &nbsp;
259  <a href="javascript:switch_display();">
260  <img src="<?php echo sq_web_path('data').'/asset_types/google_map/images/globe.png'?>" border="0" title="Pick From Map" style="position:relative;top:5px;" />
261  </a>
262  <?php }
263  $o->note('The default Zoom Level of the map');
264 
265  } else {
266  echo $default_latitude;
267  $o->note('The default Latitude of the map');
268  echo $default_longitude;
269  $o->note('The default Longitude of the map');
270  echo $default_zoom_level;
271  $o->note('The default Zoom Level of the map');
272  }//end else
273 
274  $o->closeField();
275 
276  if (!empty($api_key) && $wa) {
277  $o->openRaw();
278  ?>
279  <div id="map" style="width:100%;height:250px;border:1px solid;display:none;">
280  </div>
281  <br /><br />
282  <script src="<?php echo (current_protocol()); ?>://maps.googleapis.com/maps/api/js?key=<?php echo $api_key; ?>&amp;sensor=false" type="text/javascript"></script>
283  <script type="text/javascript">
284  var loaded = false;
285  function init_picker() {
286  var map;
287  var mapOptions = {
288  center: new google.maps.LatLng(<?php echo $default_latitude; ?>, <?php echo $default_longitude; ?>),
289  zoom: <?php echo $default_zoom_level; ?>,
290  mapTypeId: google.maps.MapTypeId.ROADMAP
291  };
292  map = new google.maps.Map(document.getElementById("map"), mapOptions);
293  google.maps.event.addListener(map, 'click', function(event) {
294  var lng = event.latLng.lng();
295  var lat = event.latLng.lat()
296  document.getElementById('<?php echo $prefix; ?>_default_latitude').style.color = 'red';
297  document.getElementById('<?php echo $prefix; ?>_default_latitude').value = lat;
298 
299  document.getElementById('<?php echo $prefix; ?>_default_longitude').style.color = 'red';
300  document.getElementById('<?php echo $prefix; ?>_default_longitude').value = lng;
301  }//end function
302  )
303  google.maps.event.addListener(map, 'zoom_changed', function() {
304  var zoomLevel = map.getZoom();
305  document.getElementById('<?php echo $prefix; ?>_default_zoom_level').style.color = 'red';
306  document.getElementById('<?php echo $prefix; ?>_default_zoom_level').value = zoomLevel;
307  }//end function
308  )//end addListener
309  }//end init_picker()
310 
311  function switch_display()
312  {
313  var new_display_val = 'block';
314  var display_val = document.getElementById('map').style.display;
315  if (display_val != 'none') {
316  new_display_val = 'none';
317  }//end if
318  document.getElementById('map').style.display = new_display_val;
319  if (loaded == false) {
320  init_picker();
321  loaded = true;
322  }//end if
323  }//end switch_display()
324  </script>
325 
326  <?php
327  $o->closeRaw();
328  }//end if
329  }//end paintDefaultLatLng()
330 
331 
338  function processDefaultLatLng(&$asset, &$o, $prefix)
339  {
340  $wa = $asset->writeAccess('attributes');
341  $default_latitude = $asset->attr('default_latitude');
342  $default_longitude = $asset->attr('default_longitude');
343  $default_zoom_level = $asset->attr('default_zoom_level');
344 
345  $attr_change = FALSE;
346  $new_default_latitude = isset($_POST[$prefix.'_default_latitude']) ? $_POST[$prefix.'_default_latitude'] : '';
347  if (!is_null($new_default_latitude) && $new_default_latitude != $default_latitude) {
348  $attr_change = TRUE;
349  $asset->setAttrValue('default_latitude', $new_default_latitude);
350  }//end if
351 
352  $new_default_longitude = isset($_POST[$prefix.'_default_longitude']) ? $_POST[$prefix.'_default_longitude'] : '';
353  if (!is_null($new_default_longitude) && $new_default_longitude != $default_longitude) {
354  $attr_change = TRUE;
355  $asset->setAttrValue('default_longitude', $new_default_longitude);
356  }//end if
357 
358  $new_default_zoom_level = isset($_POST[$prefix.'_default_zoom_level']) ? $_POST[$prefix.'_default_zoom_level'] : '';
359  if (!is_null($new_default_zoom_level) && $new_default_zoom_level != $default_zoom_level) {
360  $attr_change = TRUE;
361  $asset->setAttrValue('default_zoom_level', $new_default_zoom_level);
362  }//end if
363 
364  if ($attr_change) $asset->saveAttributes();
365 
366  return FALSE;
367 
368  }//end paintDefaultLatLng()
369 
370 
377  function paintDefaultMarkerIcon(&$asset, &$o, $prefix)
378  {
379  $wa = $asset->writeAccess('attributes');
380  $use_google_marker_icon = $asset->attr('use_google_marker_icon');
381  $default_marker_icon = $asset->attr('default_marker_icon');
382 
383  $o->openField('Default Marker Icon URL');
384  if ($wa) {
385  check_box($prefix.'_use_default_marker_icon', '1', $use_google_marker_icon, '
386  if (this.checked==1) {
387  document.getElementById("'.$prefix.'_default_marker_icon_url").disabled=true;
388  } else {
389  document.getElementById("'.$prefix.'_default_marker_icon_url").disabled=false;
390  }//end else
391  ');
392  echo ' Use Google Default Marker<br /><br />';
393  $extra = $use_google_marker_icon ? 'disabled=true' : '';
394  text_box($prefix.'_default_marker_icon_url', $default_marker_icon, empty($default_marker_icon) ? 25 : strlen($default_marker_icon), '', FALSE, $extra);;
395  $o->note('The URL to default icon for markers on the map');
396  } else {
397  echo $default_marker_icon;
398  $o->note('The URL to default icon for markers on the map');
399 
400  }//end else
401 
402  $o->closeField();
403 
404  return $wa;
405 
406  }//end paintDefaultMarkerIcon()
407 
408 
415  function processDefaultMarkerIcon(&$asset, &$o, $prefix)
416  {
417  $wa = $asset->writeAccess('attributes');
418  $default_marker_icon = $asset->attr('default_marker_icon');
419  $use_google_marker_icon = $asset->attr('use_google_marker_icon');
420 
421  $attr_change = FALSE;
422  $new_use_google_marker_icon = isset($_POST[$prefix.'_use_default_marker_icon']) ? $_POST[$prefix.'_use_default_marker_icon'] : FALSE;
423  if (!is_null($new_use_google_marker_icon) && $new_use_google_marker_icon != $use_google_marker_icon) {
424  $attr_change = TRUE;
425  $asset->setAttrValue('use_google_marker_icon', $new_use_google_marker_icon);
426  }
427  if ($new_use_google_marker_icon != 1) {
428  $new_default_marker_icon = isset($_POST[$prefix.'_default_marker_icon_url']) ? $_POST[$prefix.'_default_marker_icon_url'] : '';
429  if (!is_null($new_default_marker_icon) && $new_default_marker_icon != $default_marker_icon) {
430  $asset->setAttrValue('default_marker_icon', $new_default_marker_icon);
431  $attr_change = TRUE;
432  }//end if
433  }//end if
434 
435  if ($attr_change) $asset->saveAttributes();
436 
437  return FALSE;
438 
439  }//end processDefaultMarkerIcon()
440 
441 
452  function paintListingOption(&$asset, &$o, $prefix)
453  {
454  $wa = $asset->writeAccess('attributes');
455 
456  $enable_listing = $asset->attr('enable_listing');
457  $listing_root_nodes = $asset->attr('listing_root_nodes');
458  if (!is_array($listing_root_nodes))
459  $listing_root_nodes = unserialize($listing_root_nodes);
460 
461  bam($listing_root_nodes);
462  $default_listing_asset = $asset->attr('default_listing_asset');
463  $extra_custom = $enable_listing ? '' : ' disabled="disabled"';
464  $extra_fields = $enable_listing&&$default_listing_asset ? '' : ' disabled="disabled"';
465 
466  if (!$enable_listing) {
467  echo '<span style="color:red;">Listing Feature is not enabled.</span>';
468  }//end if
469 
470  if (!empty($listing_root_nodes)) {
471  $o->openSection('Listing Nodes');
472  $o->openRaw();
473  ?>
474 
475  <div id="<?php echo $prefix ?>_mandatory_fields" style="padding: 0.5em 0px 2em 0px">
476  <table style="width:90%;padding-left: 30px;">
477  <tr>
478  <td class="sq-backend-table-cell" style="width:118px;padding-left:15px">Type Name</td>
479  <td class="sq-backend-table-cell">Listing Root Node Options</td>
480  <?php if ($wa) { ?>
481  <td class="sq-backend-table-cell"><?php echo translate('delete_question'); ?>
482  <?php }//end if ?>
483 
484  <?php
485  foreach ($listing_root_nodes as $node_info) {
486  if (is_string($node_info)) $node_info = unserialize($node_info);
487  ?>
488  <tr>
489  <td class="sq-backend-table-cell" style="width:118px;padding-left:15px;">
490  <strong><?php echo $node_info['type_name'] ?></strong>
491  <br />
492  </td>
493  <td class="sq-backend-table-cell">
494  <?php
495  if ($wa) {
496  asset_finder($prefix.'[existing_nodes]', $node_info['root_assetid'], Array('page_asset_listing'));
497  } else {
498  echo get_asset_tag_line($node_info['root_assetid']);
499  }
500  ?><br />
501  <?php if (isset($node_info['icon_url'])) { ?>
502  <br /><span>Default Icon URL: <b><?php echo $node_info['icon_url'] ?></b></span>
503  <?php }
504  if (isset($node_info['use_google_location_asset'])) {
505  $use_default = !empty($node_info['use_google_location_asset']);
506 
507  ?>
508  <br /><span>Use Default Google Location Asset: <b><?php echo $use_default ? 'Yes' : 'No' ; ?></b></span><br />
509  <?php
510  if (isset($node_info['latitude_keyword'])) {
511  ?>
512  <br /><span>Latitude Keyword: <b><?php echo $node_info['latitude_keyword']; ?></b></span>
513  <?php
514  }
515  if (isset($node_info['longitude_keyword'])) {
516  ?>
517  <br /><span>Longitude Keyword: <b><?php echo $node_info['longitude_keyword']; ?></b></span>
518  <?php
519  }
520  if (isset($node_info['description_keyword'])) {
521  ?>
522  <br /><span>Description Keyword: <b><?php echo $node_info['description_keyword']; ?></b></span>
523  <?php
524  }
525  if (isset($node_info['icon_url_keyword'])) {
526  ?>
527  <br /><span>Icon URL Keyword: <b><?php echo $node_info['icon_url_keyword']; ?></b></span>
528  <?php
529  }
530  }
531  ?>
532  </td>
533  <?php if ($wa) {?>
534  <td class="sq-backend-table-cell"><?php check_box($prefix.'[delete]['.$node_info['root_assetid'].']', $node_info['root_assetid'], FALSE); ?></td>
535  <?php } ?>
536  </tr>
537  <?php }//end foreach
538  ?>
539  </table>
540  </div>
541  <?php
542  $o->closeRaw();
543  $o->closeSection();
544  }//end if
545 
546 
547  if ($wa) {
548 
549  $o->openSection('Add New Listing Node');
550  ?>
551  <?php
552  $o->openField('New Root Node');
553  asset_finder($prefix.'_new_root_node', '', Array('page_asset_listing' => 'D'));
554  $o->note('Select an Asset Listing to use');
555  $o->closeField();
556 
557  $o->openField('Type Name');
558  text_box($prefix.'_new_type_name', '', 25);
559  $o->note('The Type Name associate with the listed assets');
560  $o->closeField();
561 
562  $o->openField('Icon URL');
563  text_box($prefix.'_new_icon_url', '', 25);
564  $o->note('The Icon URL for these listed assets');
565  $o->closeField();
566 
567  $o->openField('Use Default Google Location Asset');
568  check_box($prefix.'_new_use_google_location_asset', '1', TRUE, 'display_keywords();');
569  $o->note('');
570  $o->closeField();
571 
572  $o->openRaw();
573  ?>
574  <script type="text/javascript">
575  function display_keywords()
576  {
577  var new_display_val = 'block';
578  var display_val = document.getElementById('keyword_div').style.display;
579  if (display_val != 'none') {
580  new_display_val = 'none';
581  }//end if
582  document.getElementById('keyword_div').style.display = new_display_val;
583  }//end switch_display()
584 
585  </script>
586  <div id="keyword_div" style="width:100%;height:auto;border:0px solid;display:none;">
587  <table style="width:auto;padding-left: 0px;">
588  <tr>
589  <td width="150" style="font-weight:bold;padding-left:44px;">Location Name Keyword</td>
590  <td><?php text_box($prefix.'_new_location_name_keyword', '', 25); ?></td>
591  </tr>
592  <tr>
593  <td width="150" style="font-weight:bold;padding-left:44px;">Latitude Keyword</td>
594  <td><?php text_box($prefix.'_new_latitude_keyword', '', 25); ?></td>
595  </tr>
596  <tr>
597  <td style="font-weight:bold;padding-left:44px;">Longitude Keyword</td>
598  <td><?php text_box($prefix.'_new_longitude_keyword', '', 25); ?></td>
599  </tr>
600  <tr>
601  <td style="font-weight:bold;padding-left:44px;">Description Keyword</td>
602  <td><?php text_box($prefix.'_new_description_keyword', '', 25); ?></td>
603  </tr>
604  <tr>
605  <td style="font-weight:bold;padding-left:44px;">Icon URL Keyword</td>
606  <td><?php text_box($prefix.'_new_icon_url_keyword', '', 25); ?></td>
607  </tr>
608  </table>
609  <p style="padding-left:44px;">Use Keywords to specify custom fields. (Example: %asset_metadata_fieldname%)</p>
610  <table style="width:auto;padding-left: 0px;">
611  <tr>
612  <td width="150" style="font-weight:bold;padding-left:44px;"><br />Custom Popup Layout<br /></td>
613  <td><?php check_box($prefix.'_new_use_asset_listing_bodycopy', '1', TRUE); ?><br /><br /></td>
614  </tr>
615  </table>
616  </div>
617  <?php
618  $o->closeRaw();
619 
620  $o->closeSection();
621  }//end if
622  ?>
623  <?php
624 
625  return $wa;
626 
627  }//end paintListingOption()
628 
629 
640  function processListingOption(&$asset, &$o, $prefix)
641  {
642  $wa = $asset->writeAccess('attributes');
643 
644  $enable_listing = $asset->attr('enable_listing');
645  $listing_root_nodes = ($asset->attr('listing_root_nodes'));
646  $listing_root_nodes = unserialize($listing_root_nodes);
647 
648  $default_listing_asset = $asset->attr('default_listing_asset');
649 
650  $new_root_node = isset($_POST[$prefix.'_new_root_node']) ? $_POST[$prefix.'_new_root_node'] : '';
651  $new_type_name = isset($_POST[$prefix.'_new_type_name']) ? $_POST[$prefix.'_new_type_name'] : '';
652  $new_icon_url = isset($_POST[$prefix.'_new_icon_url']) ? $_POST[$prefix.'_new_icon_url'] : '';
653  $new_use_google_location_asset = isset($_POST[$prefix.'_new_use_google_location_asset']) ? $_POST[$prefix.'_new_use_google_location_asset'] : '';
654 
655  $new_location_name_keyword = isset($_POST[$prefix.'_new_location_name_keyword']) ? $_POST[$prefix.'_new_location_name_keyword'] : '';
656  $new_latitude_keyword = isset($_POST[$prefix.'_new_latitude_keyword']) ? $_POST[$prefix.'_new_latitude_keyword'] : '';
657  $new_longitude_keyword = isset($_POST[$prefix.'_new_longitude_keyword']) ? $_POST[$prefix.'_new_longitude_keyword'] : '';
658  $new_description_node = isset($_POST[$prefix.'_new_description_keyword']) ? $_POST[$prefix.'_new_description_keyword'] : '';
659  $new_icon_url_node = isset($_POST[$prefix.'_new_icon_url_keyword']) ? $_POST[$prefix.'_new_icon_url_keyword'] : '';
660 
661  $delete_list = isset($_POST[$prefix]['delete']) ? $_POST[$prefix]['delete'] : Array();
662 
663  $attr_change = FALSE;
664  $new_root_node_options = Array();
665 
666  if (!empty($new_root_node) && !empty($new_root_node['assetid']) && $wa) {
667  $new_root_node_options = Array (
668  'root_assetid' => $new_root_node['assetid'],
669  );
670 
671  if (!empty($new_type_name)) {
672  $new_root_node_options['type_name'] = $new_type_name;
673  }//end if
674  if (!empty($new_icon_url)) {
675  $new_root_node_options['icon_url'] = $new_icon_url;
676  }//end if
677  if (!is_null($new_use_google_location_asset)) {
678  $new_root_node_options['use_google_location_asset'] = $new_use_google_location_asset;
679  }//end if
680 
681  if (($new_use_google_location_asset == 0)) {
682  if (!empty($new_location_name_keyword)) {
683  $new_root_node_options['location_name_keyword'] = $new_location_name_keyword;
684  }//end if
685  if (!empty($new_latitude_keyword)) {
686  $new_root_node_options['latitude_keyword'] = $new_latitude_keyword;
687  }//end if
688  if (!empty($new_latitude_keyword)) {
689  $new_root_node_options['latitude_keyword'] = $new_latitude_keyword;
690  }//end if
691  if (!empty($new_longitude_keyword)) {
692  $new_root_node_options['longitude_keyword'] = $new_longitude_keyword;
693  }//end if
694  if (!empty($new_description_node)) {
695  $new_root_node_options['description_keyword'] = $new_description_node;
696  }//end if
697  if (!empty($new_icon_url_node)) {
698  $new_root_node_options['icon_url_keyword'] = $new_icon_url_node;
699  }//end if
700  }//end if
701 
702  $listing_root_nodes[$new_root_node['assetid']] = $new_root_node_options;
703  $asset->setAttrValue('listing_root_nodes', $listing_root_nodes);
704  $attr_change = TRUE;
705  }//end if
706 
707  if (!empty($delete_list)) {
708  foreach ($delete_list as $node_id => $id_node) { // They are the same thing
709  if (isset($listing_root_nodes[$node_id])) {
710  unset($listing_root_nodes[$node_id]);
711  $asset->setAttrValue('listing_root_nodes', $listing_root_nodes);
712  $attr_change = TRUE;
713  }//end if
714  }//end foreach
715  }//end if
716 
717  if ($attr_change) $asset->saveAttributes();
718 
719  return TRUE;
720 
721  }//end paintListingOption()
722 
723 
734  function paintAssetTypes(&$asset, &$o, $prefix)
735  {
736  $wa = $asset->writeAccess('attributes');
737  parent::paintAssetTypes($asset, $o, $prefix);
738  $types = $asset->attr('types');
739  $keywords_list = $asset->attr('asset_types_keywords');
740 
741  $o->openRaw();
742  foreach ($types as $type_code => $inherit) {
743  if ($type_code !== 'google_map_location') {
744 
745  ?>
746  <div id="<?php echo $prefix ?>_mandatory_fields" style="padding: 0.5em 0px 0px 30px;margin-left:75px;">
747  <?php if (!isset($keywords_list[$type_code])) echo 'Type code '.ucwords(str_replace('_',' ', $type_code)) .' is not of type Google Map Location, Mapping of keywords is required.'; ?>
748  <p class="sq-backend-section-subheading"><?php echo 'Keyword mapping for '.ucwords(str_replace('_',' ', $type_code)); ?></p>
749 
750  <div id="<?php echo $prefix ?>_connector_div" style="padding: 0px 0px 2em 30px;">
751  <table class="sq-backend-table" style="width:100%">
752  <tr>
753  <td width="100"><p></p>Location Name keyword</td>
754  <td><p><?php
755  if (!$wa) {
756  echo array_get_index($keywords_list[$type_code], 'name_keyword', '');
757  } else {
758  text_box($prefix.'_'.$type_code.'_name_keyword', array_get_index($keywords_list[$type_code], 'name_keyword', ''), 50);
759  }//end if
760  ?></p></td>
761  </tr>
762  <tr>
763  <td width="100"><p></p>Latitude keyword</td>
764  <td><p><?php
765  if (!$wa) {
766  echo array_get_index($keywords_list[$type_code], 'latitude_keyword', '');
767  } else {
768  text_box($prefix.'_'.$type_code.'_latitude_keyword', array_get_index($keywords_list[$type_code], 'latitude_keyword', ''), 50);
769  }//end if
770  ?></p></td>
771  </tr>
772  <tr>
773  <td width="100"><p></p>Longitude keyword</td>
774  <td><p><?php
775  if (!$wa) {
776  echo array_get_index($keywords_list[$type_code], 'longitude_keyword', '');
777  } else {
778  text_box($prefix.'_'.$type_code.'_longitude_keyword', array_get_index($keywords_list[$type_code], 'longitude_keyword', ''), 50);
779  }//end else
780  ?></p></td>
781  </tr>
782  <tr>
783  <td width="100"><p></p>Description keyword</td>
784  <td><p><?php
785  if (!$wa) {
786  echo array_get_index($keywords_list[$type_code], 'description_keyword', '');
787  } else {
788  text_box($prefix.'_'.$type_code.'_description_keyword', array_get_index($keywords_list[$type_code], 'description_keyword', ''), 50);
789  }//end else
790  ?></p></td>
791  </tr>
792  <tr>
793  <td width="100"><p></p>Icon URL keyword</td>
794  <td><p><?php
795  if (!$wa) {
796  echo array_get_index($keywords_list[$type_code], 'icon_url_keyword', '');
797  } else {
798  text_box($prefix.'_'.$type_code.'_icon_url_keyword', array_get_index($keywords_list[$type_code], 'icon_url_keyword', ''), 50);
799  }
800  ?></p></td>
801  </tr>
802  <tr>
803  <td width="100"><p></p>Address Keyword</td>
804  <td><p><?php
805  if (!$wa) {
806  echo array_get_index($keywords_list[$type_code], 'address_keyword', '');
807  } else {
808  text_box($prefix.'_'.$type_code.'_address_keyword', array_get_index($keywords_list[$type_code], 'address_keyword', ''), 50);
809  }
810  ?></p></td>
811  </tr>
812  </table>
813  </div>
814  </div>
815  <?php
816 
817  }//end if
818  }//end foreach
819  ?><br /><br /><?php
820  $o->closeRaw();
821 
822  }//end paintAssetTypes()
823 
824 
835  function processAssetTypes(&$asset, &$o, $prefix)
836  {
837  parent::processAssetTypes($asset, $o, $prefix);
838 
839  // In this process function we have to capture all the values given to each of the asset types.
840  $types = $asset->attr('types');
841  $keywords_list = $asset->attr('asset_types_keywords');
842 
843  foreach ($types as $type_code => $inherit) {
844  if ($type_code !== 'google_map_location') {
845  // Now we check for everything in POST
846  $keywords_list[$type_code]['name_keyword'] = array_get_index($_POST, $prefix.'_'.$type_code.'_name_keyword', NULL);
847  $keywords_list[$type_code]['latitude_keyword'] = array_get_index($_POST, $prefix.'_'.$type_code.'_latitude_keyword', NULL);
848  $keywords_list[$type_code]['longitude_keyword'] = array_get_index($_POST, $prefix.'_'.$type_code.'_longitude_keyword', NULL);
849  $keywords_list[$type_code]['description_keyword'] = array_get_index($_POST, $prefix.'_'.$type_code.'_description_keyword', NULL);
850  $keywords_list[$type_code]['icon_url_keyword'] = array_get_index($_POST, $prefix.'_'.$type_code.'_icon_url_keyword', NULL);
851  $keywords_list[$type_code]['address_keyword'] = array_get_index($_POST, $prefix.'_'.$type_code.'_address_keyword', NULL);
852  }//end if
853  }//end foreach
854  $asset->setAttrValue('asset_types_keywords', $keywords_list);
855 
856  }//end processAssetTypes()
857 
858 
865  function paintMapInitialisation(&$asset, &$o, $prefix)
866  {
867  $wa = $asset->writeAccess('attributes');
868 
869  $o->openField('Map Initialisation');
870  $map_code = $asset->attr('map_code');
871  if ($wa) {
872  text_area($prefix.'_map_code', $map_code, 100, 10);
873  } else {
874  echo nl2br(htmlentities($map_code));
875  }//end else
876  $o->closeField();
877 
878  $street_view = $asset->attr('enable_street_view');
879  $extra = 'disabled=disabled';
880 
881  $o->openField('Standalone Street View Initialisation');
882  $street_view_code = $asset->attr('street_view_code');
883  if ($wa) {
884  text_area($prefix.'_street_view_code', $street_view_code, 100, 10, FALSE, $street_view ? '' : $extra);
885  } else {
886  echo nl2br(htmlentities($street_view_code));
887  }//end else
888  $o->closeField();
889 
890  return $wa;
891 
892  }//end paintMapInitialisation()
893 
894 
901  function processMapInitialisation(&$asset, &$o, $prefix)
902  {
903  $wa = $asset->writeAccess('attributes');
904  if (isset($_POST[$prefix.'_map_code'])) {
905  $new_map_code = $_POST[$prefix.'_map_code'];
906  $map_code = $asset->attr('map_code');
907  if ($new_map_code != $map_code) {
908  $asset->setAttrValue('map_code', $new_map_code);
909  }//end if
910  }//end if
911 
912  if (isset($_POST[$prefix.'_street_view_code'])) {
913  $new_street_view_code = $_POST[$prefix.'_street_view_code'];
914  $street_view_code = $asset->attr('street_view_code');
915  if ($new_street_view_code != $street_view_code) {
916  $asset->setAttrValue('street_view_code', $new_street_view_code);
917  }//end if
918  }//end if
919 
920  return TRUE;
921 
922  }//end processMapInitialisation()
923 
924 
925 }//end class
926 ?>