You are here

function tinybrowser_profile_form in TinyBrowser 7

1 string reference to 'tinybrowser_profile_form'
tinybrowser_profile_operations in ./tinybrowser.module
Add/Edit/Delete profile

File

./tinybrowser.module, line 793

Code

function tinybrowser_profile_form($form, &$form_state, $pid = 0) {
  if ($pid && ($profile = tinybrowser_load_profile($pid))) {
    drupal_set_title($profile['name']);
  }
  else {
    $pid = 0;
    $profile = tinybrowser_sample_profile();
    $profile['name'] = '';
  }
  $form_state['profile'] = $profile;

  // store original profile just in case
  $form = array(
    '#tree' => TRUE,
  );
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Proile name'),
    '#default_value' => $profile['name'],
    '#description' => t('Give a name to this profile.'),
    '#required' => TRUE,
  );
  $form['max_file_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum size of the file your can upload'),
    '#size' => 20,
    '#maxlength' => 20,
    '#default_value' => $profile['max_file_size'],
    '#description' => t('Set to 0 to use the maximum size available. The PHP settings of the server limit the maximum file size for upload to %size.', array(
      '%size' => format_size(file_upload_max_size()),
    )),
    '#field_suffix' => t('bytes'),
  );
  $form['max_image_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum image resolution'),
    '#size' => 20,
    '#maxlength' => 20,
    '#field_suffix' => t('WIDTHxHEIGHT'),
    '#default_value' => $profile['max_image_size'],
    '#description' => t('Maximum image size allowed (e.g: 640x480). Set 0 for no restriction. Images bigger than this size will be scaled down to fit this size.'),
  );
  $form['directory'] = array(
    '#type' => 'fieldset',
    '#title' => t('Directory options'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['directory']['path_note'] = array(
    '#type' => 'item',
    '#markup' => '<div class="description">' . t('Please specify the directories using absolute path from the server\'s DocumentRoot. They should start and end with a slash character.  If you want to assign separate directory for each user, use <strong>%u</strong> as a placeholder for user ID.  For example, actual directory specified by <em>/sites/default/files/%u/</em> for the user whose ID is 1 will be <em>/sites/default/files/1/</em>. <br/>If you want to use image styles with TinyBrowser, the directories you specify here have be the Drupal\'s stanrard file directory or the sub-directories below.') . '</div>',
  );
  $form['directory']['path_file'] = array(
    '#type' => 'textfield',
    '#title' => t('File directory'),
    '#default_value' => $profile['directory']['path_file'],
    '#size' => 60,
    '#maxlength' => 80,
  );
  $form['directory']['path_image'] = array(
    '#type' => 'textfield',
    '#title' => t('Image directory'),
    '#default_value' => $profile['directory']['path_image'],
    '#size' => 60,
    '#maxlength' => 80,
  );
  $form['directory']['path_media'] = array(
    '#type' => 'textfield',
    '#title' => t('Media directory'),
    '#default_value' => $profile['directory']['path_media'],
    '#size' => 60,
    '#maxlength' => 80,
  );
  $form['directory']['quota'] = array(
    '#type' => 'textfield',
    '#title' => t('Directory quota'),
    '#size' => 20,
    '#maxlength' => 20,
    '#default_value' => $profile['directory']['quota'],
    '#description' => t('Define the upload directory quota per file type (image/media/file). Set to 0 to unlimit.'),
    '#field_suffix' => t('bytes'),
  );
  $form['permissions'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Permitted operations'),
    '#default_value' => $profile['permissions'],
    '#options' => array(
      'upload' => t('Upload files'),
      'edit' => t('Edit files (rename, resize, rotate)'),
      'folders' => t('Use subfolders (create, rename, move)'),
      'delete' => t('Delete files and folders'),
      'userpage' => t('Use TinyBrowser at user account page'),
    ),
    '#description' => t('Even if no permissions are selected above, users still can browse files. File upload function requires <em>Adobe Flash Player 9</em> or later version installed to the web browser. <strong>Please note that allowing file upload will be a possible security risk.</strong>'),
  );
  $form['imagestyle'] = array(
    '#type' => 'checkbox',
    '#title' => t('Image style support'),
    '#default_value' => $profile['imagestyle'],
    '#description' => t('If checked, users can insert converted images instead of the original images simply by selecting image style from the context menu.'),
  );
  $form = array(
    'profile' => $form,
  );
  $form['pid'] = array(
    '#type' => 'hidden',
    '#value' => $pid,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  $form['#submit'][] = 'tinybrowser_profile_submit';
  return $form;
}