You are here

function htaccess_deployment in Htaccess 7.2

Admin htaccess deployment page.

1 string reference to 'htaccess_deployment'
htaccess_menu in ./htaccess.module
Implementation of hook_menu()

File

./htaccess.admin.inc, line 146
Administration pages.

Code

function htaccess_deployment($form, $form_state) {

  // Get the current htaccess deployed
  $htaccess_current = db_select('htaccess', 'h')
    ->fields('h')
    ->condition('deployed', 1, '=')
    ->execute()
    ->fetchAssoc();
  if ($htaccess_current) {
    $current = $htaccess_current['name'];
  }
  else {
    $current = t('none');
  }
  $form['htaccess_settings_current'] = array(
    '#type' => 'fieldset',
    '#title' => t('Status'),
    '#description' => t('Current deployed profile: <b>@current</b>.', array(
      '@current' => $current,
    )),
  );
  $form['htaccess_settings_version'] = array(
    '#prefix' => '<table>',
    '#suffix' => '</table>',
    '#tree' => TRUE,
    '#weight' => '110',
  );
  $form['htaccess_settings_version']['htaccess_settings_version_header'] = array(
    '#markup' => '<thead>
    <tr>
      <th>' . t('ID') . '</th>
      <th>' . t('Created date') . '</th>
      <th>' . t('Name') . '</th>
      <th>' . t('Description') . '</th>
      <th>' . t('Operations') . '</th>
    </tr>
  </thead>',
  );
  $htaccess = db_select('htaccess', 'h')
    ->fields('h')
    ->execute()
    ->fetchAll();
  $htaccess_count = count($htaccess);
  for ($i = 0; $i < $htaccess_count; $i++) {
    $form['htaccess_settings_version']['row_' . $i] = array(
      '#prefix' => '<tr class="' . ($i % 2 ? "odd" : "even") . '">',
      '#suffix' => '</tr>',
    );
    $form['htaccess_settings_version']['row_' . $i]['htaccess_settings_version_number'] = array(
      '#prefix' => '<td>',
      '#suffix' => '</td>',
      '#markup' => $htaccess[$i]->id,
    );
    $form['htaccess_settings_version']['row_' . $i]['htaccess_settings_version_created'] = array(
      '#prefix' => '<td>',
      '#suffix' => '</td>',
      '#markup' => format_date($htaccess[$i]->created, 'short'),
    );
    $form['htaccess_settings_version']['row_' . $i]['htaccess_settings_version_name'] = array(
      '#prefix' => '<td>',
      '#suffix' => '</td>',
      '#markup' => $htaccess[$i]->name,
    );
    $form['htaccess_settings_version']['row_' . $i]['htaccess_settings_version_description'] = array(
      '#prefix' => '<td>',
      '#suffix' => '</td>',
      '#markup' => $htaccess[$i]->description,
    );
    $form['htaccess_settings_version']['row_' . $i]['htaccess_settings_version_operation'] = array(
      '#markup' => l(t('View'), 'admin/config/system/htaccess/deployment/view/' . $htaccess[$i]->id . '') . ' ' . l(t('Deploy'), 'admin/config/system/htaccess/deployment/deploy/' . $htaccess[$i]->id . '') . ' ' . l(t('Download'), 'admin/config/system/htaccess/deployment/download/' . $htaccess[$i]->id . '') . ' ' . l(t('Delete'), 'admin/config/system/htaccess/deployment/delete/' . $htaccess[$i]->id . ''),
      '#prefix' => '<td>',
      '#suffix' => '</td>',
    );
  }
  return $form;
}