You are here

public function elFinderPageController::buildBrowserPage in elFinder file manager 8.2

5 calls to elFinderPageController::buildBrowserPage()
elFinder::alterEditorJS in src/Plugin/BUEditorPlugin/elFinder.php
elFinderBlock::build in src/Plugin/Block/elFinderBlock.php
Builds and returns the renderable array for this block plugin.
elFinderPageController::getBrowser in src/Controller/elFinderPageController.php
elFinderPageController::getBrowserPage in src/Controller/elFinderPageController.php
elfinder_page_attachments_alter in ./elfinder.module

File

src/Controller/elFinderPageController.php, line 69

Class

elFinderPageController

Namespace

Drupal\elfinder\Controller

Code

public function buildBrowserPage($is_page_layout = FALSE) {
  global $language;
  $path = drupal_get_path('module', 'elfinder');
  $editorApp = '';
  $langCode = isset($language->language) ? $language->language : 'en';
  if (isset($_GET['app'])) {
    if (preg_match("/^[a-zA-Z]+\$/", $_GET['app'])) {
      $editorApp = $_GET['app'];
    }
    elseif (preg_match("/^([a-zA-Z]+)|/", $_GET['app'], $m)) {
      $editorApp = $m[1];
    }
  }
  if (isset($_GET['langCode'])) {
    if (preg_match("/^[a-zA-z]{2}\$/", $_GET['langCode'])) {
      $langCode = $_GET['langCode'];
    }
  }
  $token_generator = \Drupal::csrfToken();

  //  $url = Url::fromRoute('elfinder.connector')->toString();

  //drupal_set_message(var_export($args['url'],true));
  $elfinder_js_settings = array(
    'editorApp' => $editorApp,
    'langCode' => $langCode,
    'rememberLastDir' => \Drupal::config('elfinder.settings')
      ->get('misc.rememberlastdir') == 'true' ? TRUE : FALSE,
    // remember last opened directory
    'disabledCommands' => elfinder_get_disabled_commands(),
    'requestType' => 'get',
    'browserMode' => $browser_mode,
    'token' => $token_generator
      ->get(),
    'moduleUrl' => $is_page_layout ? \Drupal::url('elfinder') : \Drupal::request()
      ->getRequestUri(),
    'connectorUrl' => $is_page_layout ? \Drupal::url('elfinder.connector') : \Drupal::request()
      ->getRequestUri() . '/connector',
  );
  $build = array();
  $build['#attached']['library'][] = 'elfinder/drupal.elfinder';
  $build['#attached']['drupalSettings']['elfinder'] = $elfinder_js_settings;
  return $build;
}