You are here

function animate_any_get_animate_list in Animate Any 7

Get list of all animations.

1 string reference to 'animate_any_get_animate_list'
animate_any_menu in ./animate_any.module
Implements hook_menu().

File

./animate_any.module, line 257
Add CSS3 cross-browser animation to any Drupal site.

Code

function animate_any_get_animate_list() {
  $header = array();
  $header[] = array(
    'data' => t('ID'),
  );
  $header[] = array(
    'data' => t('Parent element'),
  );
  $header[] = array(
    'data' => t('Identifiers'),
  );
  $header[] = array(
    'data' => t('Operation'),
  );

  // Fetch Animate Data.
  $fetch = db_select("animate_any", "a");
  $fetch
    ->fields('a');
  $fetch
    ->orderBy('aid', 'DESC');
  $fetch = $fetch
    ->extend('TableSort')
    ->orderByHeader($header);
  $fetch = $fetch
    ->extend('PagerDefault')
    ->limit(10);
  $fetch_results = $fetch
    ->execute()
    ->fetchAll();
  foreach ($fetch_results as $items) {
    $mini_header = array();
    $mini_header[] = array(
      'data' => t('Section'),
    );
    $mini_header[] = array(
      'data' => t('Animation'),
    );
    $mini_rows = array();
    $data = json_decode($items->identifier);
    foreach ($data as $value) {
      $mini_rows[] = array(
        $value->section_identity,
        $value->section_animation,
      );
    }
    $mini_output = array();
    $mini_output['mini_list'] = array(
      '#theme' => 'table',
      '#header' => $mini_header,
      '#rows' => $mini_rows,
    );
    $identifiers = drupal_render($mini_output);
    $edit = l(t('edit'), 'admin/config/animate_any/edit/' . $items->aid, array(
      'query' => array(
        'destination' => 'admin/config/animate_any/list',
      ),
    ));
    $delete = l(t('delete'), 'admin/config/animate_any/delete/' . $items->aid);
    $rows[] = array(
      $items->aid,
      $items->parent,
      $identifiers,
      $edit . ' / ' . $delete,
    );
  }
  $add = l(t('Add Animation'), 'admin/config/animate_any/add', array(
    'attributes' => array(
      'class' => array(
        'form-submit',
      ),
    ),
  ));
  $add_link = '<ul class="action-links"><li>' . $add . '</li></ul>';
  $output['animate_list'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => 'No record found.',
    '#prefix' => $add_link,
    '#suffix' => theme('pager'),
  );
  return drupal_render($output);
}