You are here

function smiley_overview_form in Smiley 7

Smileys overview form.

1 string reference to 'smiley_overview_form'
smiley_menu in ./smiley.module
Implements hook_menu().

File

./smiley.admin.inc, line 10
Smileys administrative pages.

Code

function smiley_overview_form($form, &$form_state) {
  $header = array(
    array(
      'data' => t('Picture'),
    ),
    array(
      'data' => t('File'),
      'field' => 'uri',
    ),
    array(
      'data' => t('Enabled'),
      'field' => 'status',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Acronyms'),
      'field' => 'acronyms',
    ),
    array(
      'data' => t('Description'),
      'field' => 'description',
    ),
    array(
      'data' => t('Delete'),
    ),
  );
  $query = db_select('smiley', 'em')
    ->extend('PagerDefault')
    ->extend('TableSort');
  $query
    ->fields('em');
  $result = $query
    ->orderByHeader($header)
    ->limit(15)
    ->execute();
  $smiley_path = drupal_get_path('module', 'smiley');
  foreach ($result as $smiley) {
    $form += smiley_overview_item($smiley);
  }

  // Fields for a new smiley.
  $smiley = new stdClass();
  $smiley->sid = 'new';
  $smiley->uri = '';
  $smiley->status = 0;
  $smiley->acronyms = '';
  $smiley->description = '';
  $form += smiley_overview_item($smiley);
  $form['new']['delete'] = NULL;
  $form['new']['picture']['#markup'] = 'New';
  $form['new']['uri']['#required'] = FALSE;
  $form['pager'] = array(
    '#theme' => 'pager',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  $form['#header'] = $header;
  return $form;
}