You are here

public function InlineJS::optionsForm in Openlayers 7.3

Same name in this branch
  1. 7.3 src/Plugin/Style/InlineJS/InlineJS.php \Drupal\openlayers\Plugin\Style\InlineJS\InlineJS::optionsForm()
  2. 7.3 src/Plugin/Control/InlineJS/InlineJS.php \Drupal\openlayers\Plugin\Control\InlineJS\InlineJS::optionsForm()
  3. 7.3 src/Plugin/Component/InlineJS/InlineJS.php \Drupal\openlayers\Plugin\Component\InlineJS\InlineJS::optionsForm()
  4. 7.3 src/Plugin/Layer/InlineJS/InlineJS.php \Drupal\openlayers\Plugin\Layer\InlineJS\InlineJS::optionsForm()
  5. 7.3 src/Plugin/Interaction/InlineJS/InlineJS.php \Drupal\openlayers\Plugin\Interaction\InlineJS\InlineJS::optionsForm()
  6. 7.3 src/Plugin/Source/InlineJS/InlineJS.php \Drupal\openlayers\Plugin\Source\InlineJS\InlineJS::optionsForm()

@TODO What is this return? If it is the form, why is form by reference?

Overrides Base::optionsForm

File

src/Plugin/Style/InlineJS/InlineJS.php, line 23
Style: JS.

Class

InlineJS
Class InlineJS.

Namespace

Drupal\openlayers\Plugin\Style\InlineJS

Code

public function optionsForm(array &$form, array &$form_state) {
  $attached = array();
  if (module_exists('ace_editor')) {
    $attached = array(
      'library' => array(
        array(
          'ace_editor',
          'ace',
        ),
      ),
      'js' => array(
        drupal_get_path('module', 'openlayers') . '/js/openlayers.editor.js',
      ),
    );
  }
  else {
    \Drupal::service('messenger')
      ->addMessage(t('To get syntax highlighting, you should install the module <a href="@url1">ace_editor</a> and its <a href="@url2">library</a>.', array(
      '@url1' => 'http://drupal.org/project/ace_editor',
      '@url2' => 'http://ace.c9.io/',
    )), 'warning');
  }
  $form['options']['javascript'] = array(
    '#type' => 'textarea',
    '#title' => t('Javascript'),
    '#description' => t('Write here the content of the Javascript function for the style. The available variable are: <em>feature</em> and <em>resolution</em>. The function should return an array of ol.style.Style.'),
    '#rows' => 15,
    '#default_value' => $this
      ->getOption('javascript'),
    '#attributes' => array(
      'data-editor' => 'javascript',
    ),
    '#attached' => $attached,
  );
}