Exemplo n.º 1
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->machine_name != Config::get('openlayers.edit_view_map')) {
         $map = openlayers_object_load('Map', Config::get('openlayers.edit_view_map'));
         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;
             // Same goes for limit extent.
             $view['limit_extent'] = 0;
             $map->setOption('view', $view);
         }
         $form['options']['view']['map'] = array('#type' => 'openlayers', '#description' => $map->description, '#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' => 'checkbox', '#title' => t('Limit to extent'), '#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('invisible' => array(':input[name="options[view][limit_extent]"]' => array('checked' => FALSE))));
     $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'));
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function buildCollection()
 {
     parent::buildCollection();
     foreach (array('source', 'style') as $type) {
         if ($data = $this->getOption($type, FALSE)) {
             // @TODO Throw proper exception if an object isn't available?
             if ($object = openlayers_object_load($type, $data)) {
                 $this->getCollection()->merge($object->getCollection());
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 protected function buildCollection()
 {
     parent::buildCollection();
     $ol_types = array('source', 'layer', 'control', 'interaction', 'component', 'projection');
     foreach ($ol_types as $type) {
         foreach ($this->getOption($type . 's', array()) as $object) {
             // @TODO Throw proper exception if an object isn't available?
             if ($merge_object = openlayers_object_load($type, $object)) {
                 $this->getCollection()->merge($merge_object->getCollection());
             }
         }
     }
 }
Exemplo n.º 4
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'), '#multiple' => TRUE, '#default_value' => $this->getOption('layers'), '#options' => openlayers_layer_options(FALSE));
     $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 ($this->getOption('layers') as $i => $machine_name) {
         $map_layer = openlayers_object_load('Layer', $machine_name);
         $label = check_plain($map_layer->name);
         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->name)), '#default_value' => $label);
     }
     // @TODO Add configuration for initial visibility. (Adjust JS accordingly)
     // @TODO Add configuration for ordering?
 }
 /**
  * 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 = openlayers_object_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;
     }
     $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($object->getParents())), '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.º 6
0
 /**
  * Returns an array with the maps this object is attached on.
  *
  * @return array
  *   An array of map objects this object is attached on. Keyed by the map
  *   machine name.
  */
 public function getParents()
 {
     $maps = ctools_export_crud_load_all('openlayers_maps');
     $parents = array();
     foreach ($maps as $map) {
         $map = openlayers_object_load('map', $map);
         foreach ($map->getCollection()->getFlatList() as $object) {
             if ($object->machine_name == $this->machine_name) {
                 $parents[$map->machine_name] = $map;
             }
         }
     }
     return $parents;
 }