Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function optionsToObjects()
 {
     $import = parent::optionsToObjects();
     if ($layer = $this->getOption('layer')) {
         $layer = Openlayers::load('layer', $layer);
         $import = array_merge($layer->getCollection()->getFlatList(), $import);
     }
     return $import;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function optionsToObjects()
 {
     $import = parent::optionsToObjects();
     if ($select = $this->getOption('select')) {
         $select = Openlayers::load('interaction', $select);
         $import = array_merge($select->getCollection()->getFlatList(), $import);
     }
     return $import;
 }
 /**
  * {@inheritDoc}
  */
 public function optionsToObjects()
 {
     $import = parent::optionsToObjects();
     if ($source = $this->getOption('source')) {
         $source = Openlayers::load('source', $source);
         // This source is a dependency of the current one, we need a lighter weight.
         $this->setWeight($source->getWeight() + 1);
         $import = array_merge($source->getCollection()->getFlatList(), $import);
     }
     return $import;
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function optionsToObjects()
 {
     $import = parent::optionsToObjects();
     if ($style = $this->getOption('style')) {
         $import = array_merge($import, Openlayers::load('style', $style)->getCollection()->getFlatList());
     }
     if ($source = $this->getOption('source')) {
         $import = array_merge($import, Openlayers::load('source', $source)->getCollection()->getFlatList());
     }
     return $import;
 }
Exemplo n.º 5
0
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 public function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting.
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     list($plugin_manager, $plugin_id) = explode(':', $item->factory_service);
     list($module, $plugin_type) = explode('.', $plugin_manager);
     $object = \Drupal\openlayers\Openlayers::load($plugin_type, $item->machine_name);
     // Note: $item->{$schema['export']['export type string']} should have
     // already been set up by export.inc so we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'title':
             $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'class':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     // Generate a map and use the style on it to make a preview.
     $map = Openlayers::load('map', 'openlayers_ui_map_style_demo');
     foreach ($map->getCollection()->getFlatList(array('layer')) as $layer) {
         $layer->setStyle($object);
         $map->getCollection()->import(array($layer));
     }
     $map_build = $map->build();
     $map_render = drupal_render($map_build);
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     $this->rows[$name]['data'][] = array('data' => $map_render, 'class' => array('ctools-export-ui-title'));
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
     }
     $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->factory_service), 'class' => array('ctools-export-ui-service'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
     }
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function optionsToObjects()
 {
     $import = parent::optionsToObjects();
     foreach (array('style', 'source') as $option) {
         if ($option_value = $this->getOption($option, FALSE)) {
             if ($object = $this->getCollection()->getObjectById($option, $option_value)) {
                 $import = array_merge($import, $object->getCollection()->getFlatList());
             } else {
                 $import = array_merge($import, Openlayers::load($option, $option_value)->getCollection()->getFlatList());
             }
         }
     }
     return $import;
 }
Exemplo n.º 7
0
 /**
  * {@inheritdoc}
  */
 public function optionsToObjects()
 {
     $import = parent::optionsToObjects();
     foreach ($this->getOptions() as $geometry_type => $data) {
         if ($styles = $this->getOption(array($geometry_type, 'styles'), array())) {
             foreach ($styles as $style) {
                 $style = Openlayers::load('style', $style);
                 // This source is a dependency of the current one,
                 // we need a lighter weight.
                 $this->setWeight($style->getWeight() + 1);
                 $import = array_merge($style->getCollection()->getFlatList(), $import);
             }
         }
     }
     return $import;
 }
 /**
  * Build a row based on the item.
  *
  * By default all of the rows are placed into a table by the render
  * method, so this is building up a row suitable for theme('table').
  * This doesn't have to be true if you override both.
  */
 public function list_build_row($item, &$form_state, $operations)
 {
     // Set up sorting.
     $name = $item->{$this->plugin['export']['key']};
     $schema = ctools_export_get_schema($this->plugin['schema']);
     list($plugin_manager, $plugin_id) = explode(':', $item->factory_service);
     list($module, $plugin_type) = explode('.', $plugin_manager);
     $count_parents = 0;
     if ($object = \Drupal\openlayers\Openlayers::load($plugin_type, $item->machine_name)) {
         $count_parents = count($object->getParents());
     }
     // Note: $item->{$schema['export']['export type string']} should have
     // already been set up by export.inc so we can use it safely.
     switch ($form_state['values']['order']) {
         case 'disabled':
             $this->sorts[$name] = empty($item->disabled) . $name;
             break;
         case 'title':
             $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
             break;
         case 'name':
             $this->sorts[$name] = $name;
             break;
         case 'class':
             $this->sorts[$name] = $name;
             break;
         case 'storage':
             $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
             break;
     }
     $this->rows[$name]['data'] = array();
     $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
     // If we have an admin title, make it the first row.
     if (!empty($this->plugin['export']['admin_title'])) {
         $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
     }
     $this->rows[$name]['data'][] = array('data' => check_plain($name), 'class' => array('ctools-export-ui-name'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->factory_service), 'class' => array('ctools-export-ui-service'));
     $this->rows[$name]['data'][] = array('data' => check_plain($count_parents), 'class' => array('ctools-export-ui-parents'));
     $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
     $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
     $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
     // Add an automatic mouseover of the description if one exists.
     if (!empty($this->plugin['export']['admin_description'])) {
         $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
     }
 }
Exemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function optionsToObjects()
 {
     $import = parent::optionsToObjects();
     if ($style = $this->getOption('editStyle')) {
         $style = Openlayers::load('style', $style);
         $this->setWeight($style->getWeight() + 1);
         $import = array_merge($style->getCollection()->getFlatList(), $import);
     }
     if ($layer = $this->getOption('editLayer')) {
         $layer = Openlayers::load('layer', $layer);
         $import = array_merge($layer->getCollection()->getFlatList(), $import);
     }
     if ($control = $this->getOption('editControl')) {
         $control = Openlayers::load('control', $control);
         $import = array_merge($control->getCollection()->getFlatList(), $import);
     }
     return $import;
 }
Exemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function optionsForm(&$form, &$form_state)
 {
     $form['options']['label'] = array('#type' => 'textfield', '#title' => t('Title of the control'), '#default_value' => $this->getOption('label', 'Layers'));
     $form['options']['layers'] = array('#type' => 'select', '#title' => t('Layers'), '#empty_option' => t('- Select a Layer -'), '#multiple' => TRUE, '#default_value' => $this->getOption('layers'), '#options' => Openlayers::loadAllAsOptions('Layer'));
     $form['options']['multiselect'] = array('#type' => 'checkbox', '#title' => t('Allow selecting multiple layers'), '#default_value' => $this->getOption('multiselect', FALSE));
     $form['options']['layer_labels_hint'] = array('#markup' => t('You need to save the configuration before being able to set custom layer labels.'));
     $labels = $this->getOption('layer_labels', array());
     foreach ((array) $this->getOption('layers') as $i => $machine_name) {
         if (($map_layer = Openlayers::load('Layer', $machine_name)) == TRUE) {
             $label = check_plain($map_layer->getName());
             if (isset($labels[$machine_name])) {
                 $label = $labels[$machine_name];
             }
             $form['options']['layer_labels'][$machine_name] = array('#type' => 'textfield', '#title' => t('Label for layer @label:', array('@label' => $map_layer->getName())), '#default_value' => $label);
         }
     }
     // @TODO Add configuration for initial visibility. (Adjust JS accordingly)
     // @TODO Add configuration for ordering?
 }
Exemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function optionsForm(&$form, &$form_state)
 {
     $form['options']['ui'] = array('#type' => 'fieldset', '#title' => t('User interface'), 'width' => array('#type' => 'textfield', '#title' => 'Width of the map', '#default_value' => $this->getOption('width', 'auto'), '#parents' => array('options', 'width')), 'height' => array('#type' => 'textfield', '#title' => t('Height of the map'), '#default_value' => $this->getOption('height', '300px'), '#parents' => array('options', 'height')));
     $form['options']['view'] = array('#type' => 'fieldset', '#title' => t('Center and rotation'), '#tree' => TRUE);
     if ($this->getMachineName() != Config::get('openlayers.edit_view_map')) {
         if (($map = Openlayers::load('Map', Config::get('openlayers.edit_view_map'))) == TRUE) {
             $map_configuration = $map->getConfiguration();
             if ($view = $this->getOption('view')) {
                 // Don't apply min / max zoom settings to this map to avoid lock-in.
                 $view['minZoom'] = 0;
                 $view['maxZoom'] = 0;
                 $map->setOption('view', $view);
             }
             $form['options']['view']['map'] = array('#type' => 'openlayers', '#description' => $map->getPluginDescription(), '#map' => $map);
         }
     }
     $form['options']['view']['center'] = array('#tree' => TRUE, 'lat' => array('#type' => 'textfield', '#title' => t('Latitude'), '#default_value' => $this->getOption(array('view', 'center', 'lat'), 0)), 'lon' => array('#type' => 'textfield', '#title' => t('Longitude'), '#default_value' => $this->getOption(array('view', 'center', 'lat'), 0)));
     $form['options']['view']['rotation'] = array('#type' => 'textfield', '#title' => t('Rotation'), '#default_value' => $this->getOption(array('view', 'rotation'), 0));
     $form['options']['view']['zoom'] = array('#type' => 'textfield', '#title' => t('Zoom'), '#default_value' => $this->getOption(array('view', 'zoom'), 0));
     $form['options']['view']['minZoom'] = array('#type' => 'textfield', '#title' => t('Min zoom'), '#default_value' => $this->getOption(array('view', 'minZoom'), 0));
     $form['options']['view']['maxZoom'] = array('#type' => 'textfield', '#title' => t('Max zoom'), '#default_value' => $this->getOption(array('view', 'maxZoom'), 0));
     $form['options']['view']['limit_extent'] = array('#type' => 'select', '#title' => t('Limit to extent'), '#empty_option' => t('Disabled'), '#empty_value' => '', '#options' => array('custom' => 'Custom extent', 'projection' => 'Map projection'), '#description' => t('If enabled navigation on the map is limited to the give extent.'), '#default_value' => $this->getOption(array('view', 'limit_extent'), FALSE));
     $form['options']['view']['extent'] = array('#type' => 'textfield', '#title' => t('Extent [minx, miny, maxx, maxy]'), '#default_value' => $this->getOption(array('view', 'extent'), ''), '#states' => array('visible' => array(':input[name="options[view][limit_extent]"]' => array('value' => 'custom'))));
     $form['options']['misc'] = array('#type' => 'fieldset', '#title' => t('Miscellaneous options'));
     $form['options']['misc']['renderer'] = array('#type' => 'radios', '#title' => t('Renderer'), '#description' => t('Renderer by default. Canvas, DOM and WebGL renderers are tested for support in that order. Note that at present only the Canvas renderer support vector data.'), '#options' => array('canvas' => t('Canvas'), 'dom' => t('DOM'), 'webgl' => t('WebGL')), '#default_value' => $this->getOption('renderer', 'canvas'), '#parents' => array('options', 'renderer'));
     $i = 0;
     $data = array();
     $map_options = $this->getOptions();
     /* @var \Drupal\openlayers\Types\Object $object */
     foreach ($this->getCollection()->getFlatList() as $object) {
         $weight = 0;
         if (isset($map_options['capabilities']['options']['table'][$object->getMachineName()])) {
             $weight = array_search($object->getMachineName(), array_keys($map_options['capabilities']['options']['table']));
         }
         $data[$object->getMachineName()] = array('name' => $object->getName(), 'machine_name' => $object->getMachineName(), 'text' => isset($map_options['capabilities']['options']['table'][$object->getMachineName()]) ? $map_options['capabilities']['options']['table'][$object->getMachineName()] : $object->getPluginDescription(), 'weight' => $weight, 'enabled' => isset($map_options['capabilities']['options']['table'][$object->getMachineName()]) ? TRUE : FALSE, 'default' => 1);
     }
     uasort($data, function ($a, $b) {
         if ($a['enabled'] > $b['enabled']) {
             return -1;
         } elseif ($a['enabled'] < $b['enabled']) {
             return 1;
         }
         if ($a['weight'] < $b['weight']) {
             return -1;
         } elseif ($a['weight'] > $b['weight']) {
             return 1;
         }
         return 0;
     });
     $rows = array();
     $row_elements = array();
     foreach ($data as $id => $entry) {
         $rows[$id] = array('data' => array(array('class', array('entry-cross')), array('data' => array('#type' => 'weight', '#title' => t('Weight'), '#title_display' => 'invisible', '#default_value' => $entry['weight'], '#attributes' => array('class' => array('entry-order-weight')))), array('data' => array('#type' => 'hidden', '#default_value' => $entry['machine_name'])), array('data' => array('#type' => 'checkbox', '#title' => t('Enable'), '#title_display' => 'invisible', '#default_value' => $entry['enabled'])), array('data' => array('#type' => 'textfield', '#title' => t('Text'), '#title_display' => 'invisible', '#default_value' => $entry['text'], '#maxlength' => 256)), check_plain($entry['name']), check_plain($entry['machine_name'])), 'class' => array('draggable'));
         // Build rows of the form elements in the table.
         $row_elements[$id] = array('weight' => &$rows[$id]['data'][1]['data'], 'machine_name' => &$rows[$id]['data'][2]['data'], 'enabled' => &$rows[$id]['data'][3]['data'], 'text' => &$rows[$id]['data'][4]['data']);
     }
     $form['options']['capabilities'] = array('#type' => 'fieldset', '#title' => 'Map description and capabilities', '#collapsible' => FALSE, '#collapsed' => FALSE, 'enabled' => array('#type' => 'checkbox', '#title' => t('Enable map capabilities ?'), '#default_value' => (bool) $this->getOption(array('capabilities'), FALSE)), 'options' => array('#type' => 'container', '#states' => array('visible' => array(':input[name="options[capabilities][enabled]"]' => array('checked' => TRUE))), 'container_type' => array('#type' => 'select', '#title' => t('Container type'), '#options' => array('fieldset' => 'Fieldset', 'container' => 'Simple div'), '#default_value' => $this->getOption(array('capabilities', 'options', 'container_type'), 'fieldset')), 'title' => array('#type' => 'textfield', '#title' => t('Title'), '#description' => t('Show a title ? Empty to disable.'), '#default_value' => $this->getOption(array('capabilities', 'options', 'title'), t('Map capabilities')), '#states' => array('visible' => array(':input[name="options[capabilities][options][container_type]"]' => array('value' => 'fieldset')))), 'description' => array('#type' => 'textfield', '#title' => t('Description'), '#description' => t('Show a description ? Empty to disable.'), '#default_value' => $this->getOption(array('capabilities', 'options', 'description'), t('Description')), '#states' => array('visible' => array(':input[name="options[capabilities][options][container_type]"]' => array('value' => 'fieldset')))), 'collapsible' => array('#type' => 'checkbox', '#title' => t('Collapsible'), '#default_value' => (bool) $this->getOption(array('capabilities', 'options', 'collapsible'), TRUE), '#states' => array('visible' => array(':input[name="options[capabilities][options][container_type]"]' => array('value' => 'fieldset')))), 'collapsed' => array('#type' => 'checkbox', '#title' => t('Collapsed'), '#default_value' => (bool) $this->getOption(array('capabilities', 'options', 'collapsed'), TRUE), '#states' => array('visible' => array(':input[name="options[capabilities][options][container_type]"]' => array('value' => 'fieldset'))))));
     // Add the table to the form.
     $form['options']['capabilities']['options']['table'] = array('#theme' => 'table', 'elements' => $row_elements, '#header' => array(array('data' => NULL, 'colspan' => 2), array('data' => t('Enabled'), 'colspan' => 2), array('data' => t('Description'), 'colspan' => 1), t('Name'), t('Machine name')), '#rows' => $rows, '#empty' => t('There are no entries available.'), '#attributes' => array('id' => 'entry-order-objects'));
     drupal_add_tabledrag('entry-order-objects', 'order', 'sibling', 'entry-order-weight');
 }
Exemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function optionsToObjects()
 {
     $import = array();
     foreach ($this->getOption('grouplayers', array()) as $weight => $object) {
         if ($merge_object = Openlayers::load('layer', $object)) {
             $merge_object->setWeight($weight);
             $import[] = $merge_object;
         }
     }
     return $import;
 }
Exemplo n.º 13
0
 /**
  * Load all objects.
  *
  * @param string $object_type
  *   Type of object to load:
  *   map|layer|source|control|interaction|style|component.
  *
  * @return \Drupal\openlayers\Types\ObjectInterface[]
  *   The array of objects.
  */
 public static function loadAll($object_type = NULL)
 {
     $objects = array();
     foreach (Openlayers::loadAllExportable($object_type) as $exportable) {
         if (is_object($exportable)) {
             $objects[$exportable->machine_name] = Openlayers::load($object_type, $exportable);
         }
     }
     return $objects;
 }
Exemplo n.º 14
0
 /**
  * {@inheritdoc}
  */
 public function optionsToObjects()
 {
     $import = array();
     foreach (Openlayers::getPluginTypes(array('map')) as $type) {
         foreach ($this->getOption($type . 's', array()) as $weight => $object) {
             if ($merge_object = Openlayers::load($type, $object)) {
                 $merge_object->setWeight($weight);
                 $import[] = $merge_object;
             }
         }
     }
     return $import;
 }
Exemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 public function optionsToObjects()
 {
     $import = array();
     // TODO: Simplify this.
     // Add the objects from the configuration.
     foreach (Openlayers::getPluginTypes(array('map')) as $weight_type => $type) {
         foreach ($this->getOption($type . 's', array()) as $weight => $object) {
             if ($col_object = $this->getCollection()->getObjectById($type, $object)) {
                 //$col_object->setWeight($weight_type . '.' . $weight);
                 //$import[] = $col_object;
             } else {
                 if ($merge_object = Openlayers::load($type, $object)) {
                     $merge_object->setWeight($weight_type . '.' . $weight);
                     $import[$type . '_' . $merge_object->getMachineName()] = $merge_object;
                 }
             }
         }
     }
     foreach ($this->getCollection()->getFlatList() as $object) {
         $import[$object->getType() . '_' . $object->getMachineName()] = $object;
     }
     return $import;
 }