Exemple #1
0
 function __construct($id)
 {
     $this->_db = JFactory::getDBO();
     $query = $this->_db->getQuery(true);
     if (isset($id['map']) && !empty($id['map'])) {
         // select from maps
         $query->select(' jmp.* ');
         $query->from(' #__joaktree_maps jmp ');
         $query->where(' jmp.id = ' . (int) $id['map'] . ' ');
         $this->_db->setQuery($query);
         $tmp = $this->_db->loadAssoc();
         if ($tmp) {
             $params = (array) json_decode($tmp['params']);
             unset($tmp['params']);
             $this->mapId = $id['map'];
             $this->params = array_merge($tmp, $params);
         }
     } else {
         if (isset($id['location']) && !empty($id['location'])) {
             // select from locations
             $query->clear();
             $query->select(' jln.latitude, jln.longitude ');
             $query->from(' #__joaktree_locations jln ');
             $query->where(' jln.id     = ' . (int) $id['location'] . ' ');
             $this->_db->setQuery($query);
             $this->params = $this->_db->loadAssoc();
             // select from trees
             $query->clear();
             $query->select(' jte.app_id ');
             $query->from(' #__joaktree_trees jte ');
             $query->where(' jte.id     = ' . (int) $id['tree'] . ' ');
             $this->_db->setQuery($query);
             $this->params['app_id'] = $this->_db->loadResult();
             $this->params['selection'] = 'location';
             $this->params['service'] = 'interactivemap';
             $this->params['tree_id'] = $id['tree'];
             $this->params['loc_id'] = $id['location'];
             $this->params['distance'] = $id['distance'];
             // zoom
             switch ($this->params['distance']) {
                 case 0:
                     // continue
                 // continue
                 case 1:
                     // continue
                 // continue
                 case 2:
                     // continue
                 // continue
                 case 5:
                     $this->params['zoomlevel'] = 11;
                     break;
                 case 10:
                     $this->params['zoomlevel'] = 10;
                     break;
                 case 20:
                     $this->params['zoomlevel'] = 9;
                     break;
                 case 50:
                     // continue
                 // continue
                 default:
                     $this->params['zoomlevel'] = 8;
                     break;
             }
         } else {
             if (isset($id['person']) && !empty($id['person'])) {
                 // select from persons admin
                 $query->select(' jan.* ');
                 $query->from(' #__joaktree_admin_persons jan ');
                 $query->where(' jan.app_id = ' . (int) $id['app'] . ' ');
                 $query->where(' jan.id     = ' . $this->_db->quote($id['person']) . ' ');
                 $this->_db->setQuery($query);
                 $this->params = $this->_db->loadAssoc();
                 $this->params['selection'] = 'person';
                 $this->params['service'] = $this->params['map'] == 1 ? 'staticmap' : ($this->params['map'] == 2 ? 'interactivemap' : '');
                 unset($this->params['map']);
                 $this->params['tree_id'] = $this->params['default_tree_id'];
                 unset($this->params['default_tree_id']);
                 $this->params['person_id'] = $this->params['id'];
                 unset($this->params['id']);
                 $this->params['relations'] = 0;
                 $this->params['period_start'] = 0;
                 $this->params['period_end'] = 0;
                 unset($this->params['published']);
                 unset($this->params['access']);
                 unset($this->params['living']);
                 unset($this->params['page']);
                 unset($this->params['robots']);
             }
         }
     }
     if (isset($this->params)) {
         $this->service = MBJService::getInstance($this->params);
     }
     parent::__construct();
 }
Exemple #2
0
 public static function getInstance($options = array())
 {
     // Sanitize the service connector options.
     $options['service'] = isset($options['service']) ? $options['service'] : self::$service;
     return parent::getInstance($options);
 }