Exemple #1
0
function mwidget_map($zoom = 9, $cat_id = null)
{
    global $content;
    global $coords;
    if (MValidate::coord($coords['lat']) && MValidate::coord($coords['lng'])) {
        ?>
						<div id="mmap" style="width: 100%; height: 100%;"></div>
	                	<script>
	                        	var mmap = new MMap();
	                        	mmap.set_lat( <?php 
        MPut::_numeric($coords['lat']);
        ?>
 );
	                        	mmap.set_lng( <?php 
        MPut::_numeric($coords['lng']);
        ?>
 );
	                        	mmap.set_zoom( <?php 
        MPut::_numeric($zoom);
        ?>
 );
	                        	mmap.create_map( 'mmap' );
	                        	<?php 
        if ($content) {
            ?>
	                        			mmap.create_marker();
	                        	<?php 
        }
        ?>


					mmap.address_search();

	                        	var mmap_control = new MMapControl( mmap );
	                        	<?php 
        if ($cat_id) {
            echo 'mmap_control.auto_on( ' . intval($cat_id) . ' );';
        }
        ?>

	                	</script>
					<div id="mmap_modal" class="modal fade">
							  	<div class="modal-dialog">
							    		<div class="modal-content">
 private function setup_object($record, $new = false)
 {
     if (!$record || !is_object($record)) {
         return null;
     }
     if ($this->title && MValidate::title($this->title)) {
         $record->title = $this->title;
     } else {
         return mapi_report_message('Not a valid content title: ' . $this->title);
     }
     if ($this->license && MValidate::id($this->license) && in_array($this->license, mapi_available_ids('licenses'))) {
         $record->license = $this->license;
     } else {
         return mapi_report_message('Not a valid content license: ' . $this->license);
     }
     $record->name = $this->name;
     if ($new) {
         if (!mapi_check_double('contents', 'name', $this->name)) {
             return mapi_report_message('Content with that name already exists: ' . $this->name);
         }
     }
     if ($this->address && MValidate::address($this->address)) {
         $record->address = $this->address;
     } else {
         return mapi_report_message('Not a valid content address: ' . $this->address);
     }
     if (isset($this->meta_name)) {
         if ($this->meta_name && MValidate::meta_name($this->meta_name)) {
             $record->meta_name = $this->meta_name;
         } else {
             return mapi_report_message('Not a valid meta name: ' . $this->meta_name);
         }
     }
     if (isset($this->meta_value)) {
         if ($this->meta_value && MValidate::meta_value($this->meta_value)) {
             $record->meta_value = $this->meta_value;
         } else {
             return mapi_report_message('Not a valid meta value: ' . $this->meta_value);
         }
     }
     if ($this->lat && MValidate::coord($this->lat)) {
         $record->lat = $this->lat;
     } else {
         return mapi_report_message('Not a valid latitude.');
     }
     if ($this->lng && MValidate::coord($this->lng)) {
         $record->lng = $this->lng;
     } else {
         return mapi_report_message('Not a valid longitude.');
     }
     if ($this->hits && $this->hits > 0) {
         $record->hits = intval($this->hits);
     }
     if ($this->parent) {
         $record->parent = intval($this->parent);
     }
     if ($this->language) {
         $record->language = strval($this->language);
     }
     if ($this->translation && 1 == $this->translation) {
         $record->translation = 1;
     }
     if ($this->enabled && 1 == $this->enabled) {
         $record->enabled = 1;
     } else {
         $record->enabled = 0;
     }
     return true;
 }