You are here

function page_manager_get_pages in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 page_manager/page_manager.admin.inc \page_manager_get_pages()

Sort tasks into buckets based upon whether or not they have subtasks.

2 calls to page_manager_get_pages()
page_manager_list_page in page_manager/page_manager.admin.inc
Output a list of pages that are managed.
page_manager_panels_dashboard_blocks in page_manager/page_manager.module
Implementation of hook_panels_dashboard_blocks().

File

page_manager/page_manager.admin.inc, line 117
Administrative functions for the page manager.

Code

function page_manager_get_pages($tasks, &$pages, $task_id = NULL) {
  foreach ($tasks as $id => $task) {
    if (empty($task_id) && !empty($task['page operations'])) {
      $pages['operations'] = array_merge($pages['operations'], $task['page operations']);
    }

    // If a type has subtasks, add its subtasks in its own table.
    if (!empty($task['subtasks'])) {
      page_manager_get_pages(page_manager_get_task_subtasks($task), $pages, $task['name']);
      continue;
    }
    if (isset($task_id)) {
      $task_name = page_manager_make_task_name($task_id, $task['name']);
    }
    else {
      $task_name = $task['name'];
    }
    $class = 'page-task-' . $id;
    if (isset($task['row class'])) {
      $class .= ' ' . $task['row class'];
    }
    if (!empty($task['disabled'])) {
      $class .= ' page-manager-disabled';
    }
    $path = array();
    $visible_path = '';
    if (!empty($task['admin path'])) {
      foreach (explode('/', $task['admin path']) as $bit) {
        if ($bit[0] != '!') {
          $path[] = $bit;
        }
      }
      $path = implode('/', $path);
      if (empty($task['disabled']) && strpos($path, '%') === FALSE) {
        $visible_path = l('/' . $task['admin path'], $path);
      }
      else {
        $visible_path = '/' . $task['admin path'];
      }
    }
    $row = array(
      'data' => array(),
      'class' => $class,
      'title' => strip_tags($task['admin description']),
    );
    $type = isset($task['admin type']) ? $task['admin type'] : t('System');
    $pages['types'][$type] = $type;
    $row['data']['type'] = array(
      'data' => $type,
      'class' => 'page-manager-page-type',
    );
    $row['data']['name'] = array(
      'data' => $task_name,
      'class' => 'page-manager-page-name',
    );
    $row['data']['title'] = array(
      'data' => $task['admin title'],
      'class' => 'page-manager-page-title',
    );
    $row['data']['path'] = array(
      'data' => $visible_path,
      'class' => 'page-manager-page-path',
    );
    $storage = isset($task['storage']) ? $task['storage'] : t('In code');
    $pages['storages'][$storage] = $storage;
    $row['data']['storage'] = array(
      'data' => $storage,
      'class' => 'page-manager-page-storage',
    );

    /*
        if (empty($task['disabled'])) {
          $item = menu_get_item($path);
          if (empty($item)) {
            dsm($path);
          }
          else {
            dsm($item);
          }
        }
    */
    $operations = array(
      array(
        'title' => t('Edit'),
        'href' => page_manager_edit_url($task_name),
      ),
    );
    if (!empty($task['enable callback'])) {
      if (!empty($task['disabled'])) {
        $operations[] = array(
          'title' => t('Enable'),
          'href' => 'admin/build/pages/nojs/enable/' . $task_name,
          'query' => array(
            'token' => drupal_get_token($task_name),
          ),
        );
      }
      else {
        $operations[] = array(
          'title' => t('Disable'),
          'href' => 'admin/build/pages/nojs/disable/' . $task_name,
          'query' => array(
            'token' => drupal_get_token($task_name),
          ),
        );
      }
    }
    $row['data']['operations'] = array(
      'data' => theme('links', $operations),
      'class' => 'page-manager-page-operations',
    );
    $pages['disabled'][$task_name] = !empty($task['disabled']);
    $pages['tasks'][] = $task_name;
    $pages['rows'][$task_name] = $row;
  }
}