/** * Constructor. * * @param array $options List of options used to configure the object * * @since 1.0 */ protected function __construct($options) { $keys = $this->getKeys(); // Initialise object variables. self::$maxLoadSize = isset($options['size']) ? $options['size'] : ($keys->maxloadsize ? $keys->maxloadsize : 100); parent::__construct($options); }
function display($tpl = null) { $this->lists = array(); JHTML::stylesheet(JoaktreeHelper::joaktreecss()); //load the language file MBJService::setLanguage(); $this->lists['version'] = JoaktreeHelper::getJoaktreeVersion(); $this->lists['providers'] = $this->get('providers'); JoaktreeHelper::addSubmenu('default'); $this->addToolbar(); $this->sidebar = JHtmlSidebar::render(); parent::display($tpl); }
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(); }
public function getMapSettings() { $settings = MBJService::getKeys(); MBJService::setLanguage(); // count locations without coordinates $query = $this->_db->getQuery(true); $query->select(' COUNT(id) '); $query->from(' #__joaktree_locations '); $this->_db->setQuery($query); $total = $this->_db->loadResult(); $query->clear(); $query->select(' COUNT(id) '); $query->from(' #__joaktree_locations '); $query->where(' latitude IS NOT NULL '); $query->where(' latitude <> 0 '); $query->where(' longitude IS NOT NULL '); $query->where(' longitude <> 0 '); $this->_db->setQuery($query); $valid = $this->_db->loadResult(); $settings->valid = (int) $valid; $settings->total = (int) $total; $settings->invalid = $settings->total - $settings->valid; $settings->validpc = $settings->total ? round(100 * ($settings->valid / $settings->total), 0) : 0; $settings->invalidpc = $settings->total ? round(100 * ($settings->invalid / $settings->total), 0) : 0; return $settings; }
function getInput() { $html = array(); $script = array(); $APIkey = array(); $options = array(); $extrafields = array(); //load the language file MBJService::setLanguage(); // Script $script[] = '<script type="text/javascript">'; $script[] = "function MBJServiceKey() {"; $script[] = ' var newKey = ""; '; // convert value to keys $key = json_decode($this->value); $html[] = '<input type="hidden" id="' . $this->id . '" name="' . $this->name . '" value="" />'; $services = MBJService::getServices(); $html[] = '<p style="clear: both; font-size: 110%; color: red;">' . JText::_('MBJ_DISCAIMER') . '</p>'; //$html[] = '<ul class="config-option-list">'; $count = count($services); foreach ((array) $services as $service) { $count--; $script[] = ' newKey = newKey + \'"\' + \'' . $service . '\' + \'"\' + \':\' + \'"\' + document.getElementById("MBJ_' . $service . '").value + \'"\'; '; $script[] = $count ? ' newKey = newKey + \',\';' : ''; //$html[] = '<li>'; $html[] = '<div class="control-group">'; //$html[] = '<label>'.JText::_('MBJ_'.strtoupper($service)).'</label>'; $html[] = '<div class="control-label"><label>' . JText::_('MBJ_' . strtoupper($service)) . '</label></div>'; $html[] = '<div class="controls">'; $html[] = '<select id="MBJ_' . $service . '" name="MBJ_' . $service . '" class="inputbox" onchange="MBJServiceKey();">'; $html[] = '<option value="0" ' . (!isset($key->{$service}) ? 'selected="selected"' : '') . '>' . JText::_('JNO') . '</option>'; $providers = MBJService::getConnectors($service); foreach ((array) $providers as $provider) { $selected = isset($key->{$service}) && $key->{$service} == $provider ? 'selected="selected"' : ''; $html[] = '<option value="' . $provider . '" ' . $selected . '>' . ucfirst($provider) . '</option>'; if (!isset($APIkey[$provider])) { $options['service'] = $service; $options['provider'] = $provider; $providerObject = MBJProvider::getInstance($options); $APIkey[$provider] = $providerObject->needsAPIkey() ? true : false; } // look for additional parametrs $params = call_user_func(array('MBJService' . ucfirst($service) . ucfirst($provider), 'parameters')); foreach ((array) $params as $param => $attributes) { if (!$attributes['value']) { $extrafields[$param] = $attributes['type']; } } } $html[] = '</select>'; //$html[] = '</li>'; $html[] = '</div>'; $html[] = '</div>'; } // API keys foreach ($APIkey as $provider => $needsKey) { if ($needsKey) { $tmp = $provider . 'APIkey'; $script[] = ' newKey = newKey + \',\' + \'"\' + \'' . $tmp . '\' + \'"\' + \':\' + \'"\' + document.getElementById("MBJ_APIkey' . $provider . '").value + \'"\'; '; //$html[] = '<li>'; $html[] = '<div class="control-group">'; //$html[] = '<label>'.JText::sprintf('MBJ_PROVIDER_APIKEY', ucfirst($provider)).'</label>'; $html[] = '<div class="control-label"><label>' . JText::sprintf('MBJ_PROVIDER_APIKEY', ucfirst($provider)) . '</label></div>'; $html[] = '<div class="controls">'; $html[] = '<input id="MBJ_APIkey' . $provider . '" ' . 'size="100" ' . 'value="' . (isset($key->{$tmp}) ? $key->{$tmp} : '') . '" ' . 'onchange="MBJServiceKey();" ' . '> '; //$html[] = '</li>'; $html[] = '</div>'; $html[] = '</div>'; } } // Extra fields foreach ($extrafields as $extrafield => $type) { $script[] = ' newKey = newKey + \',\' + \'"\' + \'' . $extrafield . '\' + \'"\' + \':\' + \'"\' + document.getElementById("MBJ_' . $extrafield . '").value + \'"\'; '; //$html[] = '<li>'; $html[] = '<div class="control-group">'; //$html[] = '<label class="hasTip" title="'.JText::_('MBJ_DESCR_'.strtoupper($extrafield)).'">'; $html[] = '<div class="control-label"><label class="hasTip" title="' . JText::_('MBJ_DESCR_' . strtoupper($extrafield)) . '">'; $html[] = JText::_('MBJ_LABEL_' . strtoupper($extrafield)) . '</label></div>'; $html[] = '<div class="controls">'; if ($type == 'boolean') { $html[] = '<select id="MBJ_' . $extrafield . '" ' . 'onchange="MBJServiceKey();" ' . '> '; $html[] = '<option value="0" ' . (!isset($key->{$extrafield}) || !$key->{$extrafield} ? 'selected="selected"' : '') . '>' . JText::_('JNO') . '</option>'; $html[] = '<option value="1" ' . (isset($key->{$extrafield}) && $key->{$extrafield} ? 'selected="selected"' : '') . '>' . JText::_('JYES') . '</option>'; $html[] = '</select>'; } else { $html[] = '<input id="MBJ_' . $extrafield . '" ' . 'size="100" ' . 'value="' . (isset($key->{$extrafield}) ? $key->{$extrafield} : '') . '" ' . 'onchange="MBJServiceKey();" ' . '> '; } //$html[] = '</li>'; $html[] = '</div>'; $html[] = '</div>'; } // max load size $script[] = ' newKey = newKey + \',\' + \'"\' + \'maxloadsize\' + \'"\' + \':\' + \'"\' + document.getElementById("MBJ_maxloadsize").value + \'"\'; '; //$html[] = '<li>'; $html[] = '<div class="control-group">'; //$html[] = '<label>'.JText::_('MBJ_LABEL_LOADSIZE').'</label>'; $html[] = '<div class="control-label"><label>' . JText::_('MBJ_LABEL_LOADSIZE') . '</label></div>'; $html[] = '<div class="controls">'; $html[] = '<input id="MBJ_maxloadsize" ' . 'size="100" ' . 'value="' . (isset($key->maxloadsize) ? $key->maxloadsize : '100') . '" ' . 'onchange="MBJServiceKey();" ' . '> '; //$html[] = '</li>'; $html[] = '</div>'; $html[] = '</div>'; //$html[] = '</ul>'; // Continue script $script[] = ' newKey = "{" + newKey + "}"; '; $script[] = ' document.getElementById("' . $this->id . '").value = newKey; '; $script[] = "}"; $script[] = 'window.onload = MBJServiceKey;'; $script[] = '</script>'; $script[] = ''; return implode("\n", array_merge($script, $html)); }
/** * The configuration keys * * @var string * @since 1.0 */ public function getKeys() { return MBJService::getKeys(); }
public static function getInstance($options = array()) { // Sanitize the service connector options. $options['service'] = isset($options['service']) ? $options['service'] : self::$service; return parent::getInstance($options); }