You are here

function skinr_ui_admin_library_form in Skinr 7.2

Menu callback: skins administration.

1 string reference to 'skinr_ui_admin_library_form'
skinr_ui_admin_library in ./skinr_ui.admin.inc
Menu callback for admin/structure/block.

File

./skinr_ui.admin.inc, line 644
Admin page callbacks for the Skinr UI module.

Code

function skinr_ui_admin_library_form($form, $form_state, $theme) {
  $form['edited_theme'] = array(
    '#type' => 'value',
    '#value' => $theme,
  );
  $skins = skinr_get_skin_info();
  if (empty($skins)) {
    $form['skins_empty'] = array(
      '#markup' => t("You don't have any skins to manage."),
    );
    return $form;
  }
  if (isset($form_state['storage']['sids'])) {

    // Ask for confirmation for disabling skin configurations.
    foreach ($form_state['storage']['skins'] as $skin) {
      $items[] = $skins[$skin]['title'];
    }
    $message = t('Would you like to disable all skin configurations for the selected skins?') . theme('item_list', array(
      'items' => $items,
    ));

    // Insert a confirmation form.
    return confirm_form($form, t('Disable all skin configurations for selected skins?'), 'admin/structure/skinr/library', $message, t('Yes'), t('No'));
  }

  // Apply overridden status.
  foreach ($skins as $name => $skin_info) {
    $skins[$name]['status'] = skinr_skin_info_status_get($skins[$name]);
  }
  $groups = skinr_get_group_info();
  uasort($skins, 'skinr_ui_sort_by_title');
  $form['skins'] = array(
    '#tree' => TRUE,
  );

  // Iterate through each of the skins.
  foreach ($skins as $name => $skin_info) {
    $extra = array();

    // Set status.
    $extra['enabled'] = !empty($skin_info['status'][$theme]) ? $skin_info['status'][$theme] : 0;

    // Create a row entry for this skin.
    $group = $groups[$skin_info['group']]['title'];
    $form['skins'][$group][$name] = _skinr_ui_admin_library_form_build_row($skin_info, $extra, $theme);
  }

  // Add basic information to the fieldsets.
  foreach (element_children($form['skins']) as $package) {
    $form['skins'][$package] += array(
      '#type' => 'fieldset',
      '#title' => $package,
      '#collapsible' => TRUE,
      '#theme' => 'skinr_ui_admin_library_fieldset',
      '#header' => array(
        array(
          'data' => t('Enabled'),
          'class' => array(
            'checkbox',
          ),
        ),
        t('Name'),
        t('Source'),
        t('Version'),
        t('Theme hooks'),
      ),
    );
  }
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  $form['actions']['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset to defaults'),
  );
  $form['#action'] = url('admin/structure/skinr/library');
  return $form;
}