You are here

function _filebrowser_form_presentation_part in Filebrowser 6.2

2 calls to _filebrowser_form_presentation_part()
filebrowser_admin_settings in ./filebrowser.admin.inc
filebrowser_form in ./filebrowser.module
Implementation of hook_form().

File

includes/node.inc, line 119

Code

function _filebrowser_form_presentation_part($settings = NULL, $weight = 0) {
  $presentations = _filebrowser_options(_filebrowser_externals('presentations'));
  if (is_null($settings)) {
    $globale_settings = variable_get('filebrowser', NULL);
    if (!is_null($globale_settings) && isset($globale_settings['folder_presentation'])) {
      $settings = (object) $globale_settings['folder_presentation'];
    }
    if (is_null($settings)) {
      $settings = (object) array(
        'default_view' => current(array_keys($presentations)),
        'encoding' => NULL,
        'hide_extension' => FALSE,
        'visible_columns' => array(
          FILEBROWSER_DATA_NAME_ICON => 1,
          FILEBROWSER_DATA_NAME_DISPLAY_NAME => 1,
        ),
        'default_sort_order' => 'asc',
        'default_sort' => 0,
      );
    }
  }

  /** Folder presentation
   * *************************************************************** */
  $form['folder_presentation'] = array(
    '#type' => 'fieldset',
    '#title' => t('Folder presentation'),
    '#tree' => TRUE,
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#weight' => $weight,
  );
  $form['folder_presentation']['default_view'] = array(
    '#type' => 'select',
    '#title' => t("Default view"),
    '#default_value' => $settings->default_view,
    '#options' => $presentations,
    '#prefix' => "<div class=\"filebrowser-container-inline\">",
  );
  $form['folder_presentation']['hide_extension'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hide file extensions'),
    '#default_value' => $settings->hide_extension,
    '#suffix' => "</div>",
  );
  $form['folder_presentation']['encoding'] = array(
    '#type' => 'textfield',
    '#title' => t('FileSystem encoding'),
    '#description' => t('Set here your file system encoding (UTF-8, ISO-8859-15, etc.).'),
    '#default_value' => $settings->encoding,
    '#size' => 10,
  );
  $columns = _filebrowser_externals('metadata_info');
  $form['folder_presentation']['visible_columns'] = array(
    '#type' => 'select',
    '#multiple' => TRUE,
    '#title' => t("Visible columns"),
    '#default_value' => _filebrowser_properties_to_checkboxes($settings->visible_columns),
    '#options' => _filebrowser_options($columns),
    '#prefix' => "<div class=\"filebrowser-container-inline\">",
  );
  $sortable = array();
  foreach ($columns as $name => $data) {
    if (isset($data['sortable']) && $data['sortable']) {
      $sortable[$name] = $data['title'];
    }
  }
  $form['folder_presentation']['default_sort'] = array(
    '#type' => 'select',
    '#title' => t("Default sort"),
    '#default_value' => $settings->default_sort,
    '#options' => $sortable,
  );
  $form['folder_presentation']['default_sort_order'] = array(
    '#type' => 'select',
    '#title' => t("Default sort order"),
    '#default_value' => $settings->default_sort_order,
    '#options' => array(
      'asc' => t('Ascendant'),
      'desc' => t('Descendant'),
    ),
    '#suffix' => "</div>",
  );
  return $form;
}